package com.tiedup.remake.entities.ai.damsel;

import com.tiedup.remake.entities.EntityDamsel;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.goal.LookAtPlayerGoal;

/**
 * AI Goal: Damsel watches nearby players.
 *
 *
 * <p><b>Behavior:</b></p>
 * <ul>
 *   <li>Only active if NOT blindfolded (can't watch if can't see)</li>
 *   <li>Looks at players within 6 blocks</li>
 *   <li>Idle head tracking</li>
 * </ul>
 */
public class DamselWatchPlayerGoal extends LookAtPlayerGoal {

    private final EntityDamsel damsel;

    /**
     * Create watch player goal.
     *
     * @param damsel Damsel entity
     * @param entityType Entity type to watch (usually Player.class)
     * @param lookDistance Max distance to watch (blocks)
     */
    public DamselWatchPlayerGoal(
        EntityDamsel damsel,
        Class<? extends LivingEntity> entityType,
        float lookDistance
    ) {
        super(damsel, entityType, lookDistance);
        this.damsel = damsel;
    }

    @Override
    public boolean canUse() {
        // Can't watch if blindfolded
        if (damsel.isBlindfolded()) {
            return false;
        }

        // DOG pose: Can still watch players - body rotation is smoothed in tick()
        // and head compensation is applied in the model

        return super.canUse();
    }

    @Override
    public boolean canContinueToUse() {
        // Stop watching if got blindfolded
        if (damsel.isBlindfolded()) {
            return false;
        }

        return super.canContinueToUse();
    }
}
