// 
// Decompiled by Procyon v0.6.0
// 

package com.hypixel.hytale.server.npc.corecomponents.movement;

import com.hypixel.hytale.server.npc.navigation.AStarNode;
import com.hypixel.hytale.component.ComponentAccessor;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.server.npc.movement.controllers.MotionController;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.server.npc.corecomponents.movement.builders.BuilderBodyMotionFindBase;
import com.hypixel.hytale.server.npc.asset.builder.BuilderSupport;
import javax.annotation.Nonnull;
import com.hypixel.hytale.server.npc.corecomponents.movement.builders.BuilderBodyMotionLeave;
import com.hypixel.hytale.server.npc.navigation.AStarBase;

public class BodyMotionLeave extends BodyMotionFindBase<AStarBase>
{
    protected final double distanceSquared;
    
    public BodyMotionLeave(@Nonnull final BuilderBodyMotionLeave builderMotionLeave, @Nonnull final BuilderSupport support) {
        super(builderMotionLeave, support, new AStarBase());
        final double distance = builderMotionLeave.getDistance(support);
        this.distanceSquared = distance * distance;
    }
    
    public boolean isGoalReached(final Ref<EntityStore> ref, @Nonnull final MotionController controller, final Vector3d position, final ComponentAccessor<EntityStore> componentAccessor) {
        return controller.waypointDistanceSquared(this.aStar.getStartPosition(), position) >= this.distanceSquared;
    }
    
    @Override
    public boolean isGoalReached(final Ref<EntityStore> ref, @Nonnull final AStarBase aStarBase, @Nonnull final AStarNode aStarNode, @Nonnull final MotionController controller, final ComponentAccessor<EntityStore> componentAccessor) {
        return controller.waypointDistanceSquared(aStarBase.getStartPosition(), aStarNode.getPosition()) >= this.distanceSquared;
    }
    
    @Override
    public float estimateToGoal(final AStarBase aStarBase, final Vector3d fromPosition, final MotionController motionController) {
        return 0.0f;
    }
    
    @Override
    public void findBestPath(@Nonnull final AStarBase aStarBase, final MotionController controller) {
        aStarBase.buildFurthestPath();
    }
}
