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

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

import com.hypixel.hytale.server.npc.sensorinfo.InfoProvider;
import com.hypixel.hytale.server.npc.movement.controllers.MotionController;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.server.npc.role.Role;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.server.npc.corecomponents.builders.BuilderSensorBase;
import com.hypixel.hytale.server.npc.asset.builder.BuilderSupport;
import javax.annotation.Nonnull;
import com.hypixel.hytale.server.npc.corecomponents.movement.builders.BuilderSensorNav;
import com.hypixel.hytale.server.npc.movement.NavState;
import java.util.EnumSet;
import com.hypixel.hytale.server.npc.corecomponents.SensorBase;

public class SensorNav extends SensorBase
{
    protected final EnumSet<NavState> navStates;
    protected final double throttleDuration;
    protected final double targetDeltaSquared;
    
    public SensorNav(@Nonnull final BuilderSensorNav builderSensorNav, @Nonnull final BuilderSupport builderSupport) {
        super(builderSensorNav);
        this.navStates = builderSensorNav.getNavStates(builderSupport);
        this.throttleDuration = builderSensorNav.getThrottleDuration(builderSupport);
        final double targetDelta = builderSensorNav.getTargetDelta(builderSupport);
        this.targetDeltaSquared = targetDelta * targetDelta;
    }
    
    @Override
    public boolean matches(@Nonnull final Ref<EntityStore> ref, @Nonnull final Role role, final double dt, @Nonnull final Store<EntityStore> store) {
        if (!super.matches(ref, role, dt, store)) {
            return false;
        }
        final MotionController motionController = role.getActiveMotionController();
        return (this.throttleDuration == 0.0 || motionController.getThrottleDuration() >= this.throttleDuration) && (this.targetDeltaSquared == 0.0 || motionController.getTargetDeltaSquared() >= this.targetDeltaSquared) && (this.navStates.isEmpty() || this.navStates.contains(motionController.getNavState()));
    }
    
    @Override
    public InfoProvider getSensorInfo() {
        return null;
    }
}
