package com.tiedup.remake.v2.furniture;

import com.tiedup.remake.v2.BodyRegionV2;
import java.util.List;
import java.util.Set;
import net.minecraft.world.entity.Entity;
import org.jetbrains.annotations.Nullable;

/**
 * Contract for entities that hold passengers in named seats.
 *
 * <p>{@link EntityFurniture} is currently the only implementation. The
 * interface covers the seat-lookup / lock / region surface but NOT
 * animation state or definition reference — callers that need those
 * still downcast to {@code EntityFurniture}. Adding a second
 * implementation (NPC carrying a captive, a block acting as a chair,
 * …) would require extending this interface first; the existing
 * consumers aren't polymorphic over those methods today.</p>
 */
public interface ISeatProvider {
    /** All seat definitions for this entity. */
    List<SeatDefinition> getSeats();

    /** Which seat is this passenger in? Null if not seated. */
    @Nullable
    SeatDefinition getSeatForPassenger(Entity passenger);

    /**
     * Find the passenger entity currently assigned to {@code seatId}, or
     * null if the seat is unoccupied. Used by reconnection / force-mount
     * paths to refuse a seat-takeover that would orphan an existing
     * occupant.
     */
    @Nullable
    Entity findPassengerInSeat(String seatId);

    /** Assign a passenger to a specific seat. */
    void assignSeat(Entity passenger, String seatId);

    /** Release a passenger's seat assignment. */
    void releaseSeat(Entity passenger);

    /** Is this specific seat locked? */
    boolean isSeatLocked(String seatId);

    /** Lock/unlock a specific seat. */
    void setSeatLocked(String seatId, boolean locked);

    /** The locked difficulty for this seat. */
    int getLockedDifficulty(String seatId);

    /** Blocked body regions for a specific seat. */
    Set<BodyRegionV2> getBlockedRegions(String seatId);

    /** Whether items on non-blocked regions add to escape difficulty. */
    boolean hasItemDifficultyBonus(String seatId);

    /** Convenience: get the entity this interface is attached to. */
    default Entity asEntity() {
        return (Entity) this;
    }
}
