Record Class SimulationThreat
java.lang.Object
java.lang.Record
dev.twilite.game.simulation.model.threat.SimulationThreat
- Record Components:
kind- broad source categoryid- source id, such as a projectile, effect, or animation idposition- center coordinate of the hazardstartTick- first simulated tick when this hazard is activeduration- number of simulated ticks this hazard remains activeradius- Chebyshev radius aroundpositionpenalty- penalty amount to add to matching nodesavoid- whether matching nodes should be excluded from final movement destinations
public record SimulationThreat(SimulationThreatKind kind, int id, Coord position, int startTick, int duration, int radius, int penalty, boolean avoid)
extends Record
Timed hazard centered on a coordinate.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordBuilder for coordinate threats. -
Constructor Summary
ConstructorsConstructorDescriptionSimulationThreat(SimulationThreatKind kind, int id, Coord position, int startTick, int duration, int radius, int penalty, boolean avoid) Creates an instance of aSimulationThreatrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanactiveAt(SimulationNode node) Returns whether this threat is active for a candidate node.booleanactiveOn(int tick) Returns whether this threat is active on a simulated tick.static SimulationThreat.BuilderStarts a builder for a coordinate threat.static SimulationThreatCreates a one-tick coordinate threat that is not tied to a specific source id.static SimulationThreatCreates a coordinate threat that is not tied to a specific source id.static SimulationThreatat(SimulationThreatKind kind, int id, Coord position, int startTick, int radius, int penalty, boolean avoid) Creates a one-tick coordinate threat with an explicit source kind and id.static SimulationThreatat(SimulationThreatKind kind, int id, Coord position, int startTick, int duration, int radius, int penalty, boolean avoid) Creates a coordinate threat with an explicit source kind and id.booleanavoid()Returns the value of theavoidrecord component.static SimulationThreatCreates a one-tick coordinate threat that should be avoided as a final destination.static SimulationThreatCreates a coordinate threat that should be avoided as a final destination.intduration()Returns the value of thedurationrecord component.static SimulationThreatCreates an immediate effect threat at the effect coordinate.static SimulationThreatCreates an immediate effect threat at the effect coordinate.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intid()Returns the value of theidrecord component.kind()Returns the value of thekindrecord component.intpenalty()Returns the value of thepenaltyrecord component.position()Returns the value of thepositionrecord component.static SimulationThreatprojectile(Projectile projectile, int radius, int penalty, boolean avoid) Creates a timed projectile threat at the projectile target coordinate.static SimulationThreatprojectile(Projectile projectile, int duration, int radius, int penalty, boolean avoid) Creates a timed projectile threat at the projectile target coordinate.intradius()Returns the value of theradiusrecord component.intReturns the value of thestartTickrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
SimulationThreat
public SimulationThreat(SimulationThreatKind kind, int id, Coord position, int startTick, int duration, int radius, int penalty, boolean avoid) Creates an instance of aSimulationThreatrecord class.- Parameters:
kind- the value for thekindrecord componentid- the value for theidrecord componentposition- the value for thepositionrecord componentstartTick- the value for thestartTickrecord componentduration- the value for thedurationrecord componentradius- the value for theradiusrecord componentpenalty- the value for thepenaltyrecord componentavoid- the value for theavoidrecord component
-
-
Method Details
-
at
Starts a builder for a coordinate threat.- Parameters:
position- center coordinate of the hazard
-
at
public static SimulationThreat at(Coord position, int startTick, int radius, int penalty, boolean avoid) Creates a one-tick coordinate threat that is not tied to a specific source id.- Parameters:
position- center coordinate of the hazardstartTick- first simulated tick when this hazard is activeradius- Chebyshev radius aroundpositionpenalty- penalty amount to add to matching nodesavoid- whether matching nodes should be excluded from final destinations
-
at
public static SimulationThreat at(Coord position, int startTick, int duration, int radius, int penalty, boolean avoid) Creates a coordinate threat that is not tied to a specific source id.- Parameters:
position- center coordinate of the hazardstartTick- first simulated tick when this hazard is activeduration- number of simulated ticks this hazard remains activeradius- Chebyshev radius aroundpositionpenalty- penalty amount to add to matching nodesavoid- whether matching nodes should be excluded from final destinations
-
at
public static SimulationThreat at(SimulationThreatKind kind, int id, Coord position, int startTick, int radius, int penalty, boolean avoid) Creates a one-tick coordinate threat with an explicit source kind and id.- Parameters:
kind- broad source categoryid- source idposition- center coordinate of the hazardstartTick- first simulated tick when this hazard is activeradius- Chebyshev radius aroundpositionpenalty- penalty amount to add to matching nodesavoid- whether matching nodes should be excluded from final destinations
-
at
public static SimulationThreat at(SimulationThreatKind kind, int id, Coord position, int startTick, int duration, int radius, int penalty, boolean avoid) Creates a coordinate threat with an explicit source kind and id.- Parameters:
kind- broad source categoryid- source idposition- center coordinate of the hazardstartTick- first simulated tick when this hazard is activeduration- number of simulated ticks this hazard remains activeradius- Chebyshev radius aroundpositionpenalty- penalty amount to add to matching nodesavoid- whether matching nodes should be excluded from final destinations
-
avoid
Creates a one-tick coordinate threat that should be avoided as a final destination.- Parameters:
position- center coordinate of the hazardstartTick- first simulated tick when this hazard is activeradius- Chebyshev radius aroundpositionpenalty- penalty amount to add to matching nodes
-
avoid
public static SimulationThreat avoid(Coord position, int startTick, int duration, int radius, int penalty) Creates a coordinate threat that should be avoided as a final destination.- Parameters:
position- center coordinate of the hazardstartTick- first simulated tick when this hazard is activeduration- number of simulated ticks this hazard remains activeradius- Chebyshev radius aroundpositionpenalty- penalty amount to add to matching nodes
-
projectile
public static SimulationThreat projectile(Projectile projectile, int radius, int penalty, boolean avoid) Creates a timed projectile threat at the projectile target coordinate.- Parameters:
projectile- projectile to modelradius- Chebyshev radius around the target coordinatepenalty- penalty amount to add when the projectile landsavoid- whether matching nodes should be excluded from final destinations
-
projectile
public static SimulationThreat projectile(Projectile projectile, int duration, int radius, int penalty, boolean avoid) Creates a timed projectile threat at the projectile target coordinate.- Parameters:
projectile- projectile to modelduration- number of simulated ticks the projectile impact remains activeradius- Chebyshev radius around the target coordinatepenalty- penalty amount to add when the projectile landsavoid- whether matching nodes should be excluded from final destinations
-
effect
Creates an immediate effect threat at the effect coordinate.- Parameters:
effect- effect to modelradius- Chebyshev radius around the effect coordinatepenalty- penalty amount to add while the effect is activeavoid- whether matching nodes should be excluded from final destinations
-
effect
public static SimulationThreat effect(Effect effect, int duration, int radius, int penalty, boolean avoid) Creates an immediate effect threat at the effect coordinate.- Parameters:
effect- effect to modelduration- number of simulated ticks the effect remains activeradius- Chebyshev radius around the effect coordinatepenalty- penalty amount to add while the effect is activeavoid- whether matching nodes should be excluded from final destinations
-
activeAt
Returns whether this threat is active for a candidate node.- Parameters:
node- candidate node to test
-
activeOn
public boolean activeOn(int tick) Returns whether this threat is active on a simulated tick.- Parameters:
tick- simulated tick to test
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
kind
Returns the value of thekindrecord component.- Returns:
- the value of the
kindrecord component
-
id
public int id()Returns the value of theidrecord component.- Returns:
- the value of the
idrecord component
-
position
Returns the value of thepositionrecord component.- Returns:
- the value of the
positionrecord component
-
startTick
public int startTick()Returns the value of thestartTickrecord component.- Returns:
- the value of the
startTickrecord component
-
duration
public int duration()Returns the value of thedurationrecord component.- Returns:
- the value of the
durationrecord component
-
radius
public int radius()Returns the value of theradiusrecord component.- Returns:
- the value of the
radiusrecord component
-
penalty
public int penalty()Returns the value of thepenaltyrecord component.- Returns:
- the value of the
penaltyrecord component
-
avoid
public boolean avoid()Returns the value of theavoidrecord component.- Returns:
- the value of the
avoidrecord component
-