Contents
Class PathRetryThrottle
java.lang.Object
com.hypixel.hytale.server.npc.util.PathRetryThrottle
Back-off for a path search that keeps getting the NPC nowhere. A retry runs the same search against
the same world, so something has to change before it can answer differently. This counts the
attempts that delivered no usable path and holds the motion still for a while once they pass the
allowance the role grants.
The first few retries carry no delay. That covers a partial path that gets the NPC closer on each try, which is progress even though the search never reached the goal.
The caller owns the clock and calls advance(double) once per tick. The counts and the delay
live here, so nothing mirrors them.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadvance(double dt) Moves the clock on by one tick.voidarmDelay()Starts a delay, unless one already runs or the retries are still free.intdoubleTime the throttle has been active.booleanTrue while a delay runs, so the caller must not search again yet.booleanTrue once the retries have used up the free allowance, which is when a delay applies.voidCounts one attempt that left the NPC where it was.voidreset()Drops the count, the delay and the accumulated time, so the next search starts clean.
-
Constructor Details
-
PathRetryThrottle
public PathRetryThrottle(double delayMin, double delayMax, int ignoredRetryCount) - Parameters:
delayMin- shortest delay a retry can draw, in secondsdelayMax- longest delay a retry can draw, in seconds. Zero turns the delay offignoredRetryCount- retries that carry no delay
-
-
Method Details
-
advance
public void advance(double dt) Moves the clock on by one tick. Counts the time spent throttling up, and the delay down. -
isDelayed
public boolean isDelayed()True while a delay runs, so the caller must not search again yet. -
isThrottling
public boolean isThrottling()True once the retries have used up the free allowance, which is when a delay applies. -
recordRetry
public void recordRetry()Counts one attempt that left the NPC where it was. -
armDelay
public void armDelay()Starts a delay, unless one already runs or the retries are still free. -
reset
public void reset()Drops the count, the delay and the accumulated time, so the next search starts clean. -
getRetryCount
public int getRetryCount() -
getThrottledTime
public double getThrottledTime()Time the throttle has been active. A nav state reports it, and a sensor can match on it.
-