package com.tiedup.remake.entities.kidnapper.components;

import com.tiedup.remake.cells.CellDataV2;
import com.tiedup.remake.entities.ai.kidnapper.KidnapperState;
import com.tiedup.remake.state.IBondageState;
import java.util.List;
import java.util.UUID;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.goal.GoalSelector;
import net.minecraft.world.entity.ai.navigation.PathNavigation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.Nullable;

/**
 * Host interface for KidnapperAIManager callbacks.
 * Provides access to entity properties and components needed for AI goal registration.
 */
public interface IAIHost {
    // NAVIGATION & BASIC

    /**
     * Get the entity's navigation system.
     */
    PathNavigation getNavigation();

    /**
     * Get the goal selector for registering AI goals.
     */
    GoalSelector getGoalSelector();

    /**
     * Get the entity's level/world.
     */
    Level getLevel();

    // STATE MANAGEMENT

    /**
     * Get the current behavioral state.
     */
    KidnapperState getCurrentState();

    /**
     * Set the current behavioral state.
     */
    void setCurrentState(KidnapperState state);

    // TARGET MANAGEMENT

    /**
     * Get the current hunt target.
     */
    @Nullable
    LivingEntity getTarget();

    /**
     * Set the current hunt target.
     */
    void setTarget(@Nullable LivingEntity target);

    /**
     * Check if an entity is a suitable target for capture.
     */
    boolean isSuitableTarget(LivingEntity entity);

    /**
     * Check if target is still valid during an active chase.
     */
    boolean isTargetStillValidForChase(LivingEntity entity);

    /**
     * Check if kidnapper is close enough to capture target.
     */
    boolean isCloseToTarget();

    /**
     * Find closest suitable target within radius.
     */
    @Nullable
    LivingEntity getClosestSuitableTarget(int radius);

    // CAPTIVE MANAGEMENT

    /**
     * Get the current captive.
     */
    @Nullable
    IBondageState getCaptive();

    /**
     * Check if kidnapper has captives.
     */
    boolean hasCaptives();

    // AGGRESSION SYSTEM

    /**
     * Get the last entity that attacked this kidnapper.
     */
    @Nullable
    LivingEntity getLastAttacker();

    /**
     * Get the escaped target if still within memory time.
     */
    @Nullable
    LivingEntity getEscapedTarget();

    // ALERT SYSTEM

    /**
     * Get the alert target (escapee being searched for).
     */
    @Nullable
    LivingEntity getAlertTarget();

    /**
     * Set the alert target.
     */
    void setAlertTarget(@Nullable LivingEntity target);

    // CAMP SYSTEM

    /**
     * Get the associated structure UUID for this kidnapper.
     */
    @Nullable
    UUID getAssociatedStructure();

    /**
     * Check if this kidnapper is a "hunter" that patrols far from camp.
     */
    boolean isHunter();

    // CELL SYSTEM

    /**
     * Get all nearby cells that have prisoners in them.
     */
    List<CellDataV2> getNearbyCellsWithPrisoners();

    /**
     * Get the PATROL markers near this kidnapper.
     */
    List<BlockPos> getNearbyPatrolMarkers(int radius);

    // SALE & JOB SYSTEM

    /**
     * Check if currently selling captive.
     */
    boolean isSellingCaptive();

    /**
     * Check if waiting for worker to complete job.
     */
    boolean isWaitingForJobToBeCompleted();

    // COLLAR CONFIG

    /**
     * Check if kidnapping mode is fully ready (enabled + prison set).
     */
    boolean isKidnappingModeReady();

    /**
     * Get cell ID from collar.
     */
    @Nullable
    UUID getCellIdFromCollar();

    // CAPTURE EQUIPMENT

    /**
     * Equip themed bind and gag items before capture.
     */
    void setUpHeldItems();

    /**
     * Get bind item to use for capture.
     */
    ItemStack getBindItem();

    /**
     * Get gag item to use for capture.
     */
    ItemStack getGagItem();

    // STATE FLAGS

    /**
     * Check if in "get out" state (flee behavior).
     */
    boolean isGetOutState();

    /**
     * Check if currently dogwalking a prisoner.
     */
    boolean isDogwalking();
}
