package common.ai;

import common.entity.types.EntityLiving;
import common.pathfinding.PathNavigateGround;
import common.world.AWorldServer;

public class EntityAIRestrictSun extends EntityAIBase
{
    private EntityLiving theEntity;

    public EntityAIRestrictSun(EntityLiving creature)
    {
        this.theEntity = creature;
    }

    /**
     * Returns whether the EntityAIBase should begin execution.
     */
    public boolean shouldExecute()
    {
        return ((AWorldServer)this.theEntity.worldObj).isDaytime();
    }

    /**
     * Execute a one shot task or start executing a continuous task
     */
    public void startExecuting()
    {
        ((PathNavigateGround)this.theEntity.getNavigator()).setAvoidSun(true);
    }

    /**
     * Resets the task
     */
    public void resetTask()
    {
        ((PathNavigateGround)this.theEntity.getNavigator()).setAvoidSun(false);
    }
}
