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

import com.tiedup.remake.entities.EntityDamsel;
import net.minecraft.world.entity.ai.goal.WaterAvoidingRandomStrollGoal;

/**
 * AI Goal: Damsel wanders randomly when not restrained.
 *
 *
 * <p><b>Behavior:</b></p>
 * <ul>
 *   <li>Only active if NOT tied up</li>
 *   <li>Only active if NOT collared (enslaved damsels don't wander)</li>
 *   <li>Random walking within 10 block range</li>
 * </ul>
 */
public class DamselWanderGoal extends WaterAvoidingRandomStrollGoal {

    private final EntityDamsel damsel;

    /**
     * Create wander goal.
     *
     * @param damsel Damsel entity
     * @param speedModifier Walking speed multiplier
     */
    public DamselWanderGoal(EntityDamsel damsel, double speedModifier) {
        super(damsel, speedModifier);
        this.damsel = damsel;
    }

    @Override
    public boolean canUse() {
        // Can't wander if tied up or collared
        if (damsel.isTiedUp() || damsel.hasCollar()) {
            return false;
        }

        return super.canUse();
    }

    @Override
    public boolean canContinueToUse() {
        // Stop wandering if got tied or collared
        if (damsel.isTiedUp() || damsel.hasCollar()) {
            return false;
        }

        return super.canContinueToUse();
    }
}
