Record Class SimulationAreaThreat
java.lang.Object
java.lang.Record
dev.twilite.game.simulation.model.threat.SimulationAreaThreat
- Record Components:
id- source id, such as a projectile, effect, or animation idarea- rectangular hazard areastartTick- first simulated tick when this hazard is activeduration- number of simulated ticks this hazard remains activepenalty- penalty amount to add to matching nodesavoid- whether matching nodes should be excluded from final movement destinations
public record SimulationAreaThreat(int id, Rect area, int startTick, int duration, int penalty, boolean avoid)
extends Record
Timed hazard covering a rectangular area.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordBuilder for rectangular area threats. -
Constructor Summary
ConstructorsConstructorDescriptionSimulationAreaThreat(int id, Rect area, int startTick, int penalty, boolean avoid) Creates a one-tick area threat.SimulationAreaThreat(int id, Rect area, int startTick, int duration, int penalty, boolean avoid) Creates an instance of aSimulationAreaThreatrecord 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.area()Returns the value of thearearecord component.static SimulationAreaThreatCreates an area threat with an explicit source id.static SimulationAreaThreatCreates a one-tick area threat that is not tied to a specific source id.static SimulationAreaThreatCreates an area threat that is not tied to a specific source id.booleanavoid()Returns the value of theavoidrecord component.static SimulationAreaThreatCreates a one-tick area threat that should be avoided as a final destination.static SimulationAreaThreatCreates an area threat that should be avoided as a final destination.static SimulationAreaThreat.BuilderStarts a builder for an area threat.intduration()Returns the value of thedurationrecord component.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.intpenalty()Returns the value of thepenaltyrecord component.intReturns the value of thestartTickrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
SimulationAreaThreat
Creates a one-tick area threat.- Parameters:
id- source id, such as a projectile, effect, or animation idarea- rectangular hazard areastartTick- simulated tick when this hazard is activepenalty- penalty amount to add to matching nodesavoid- whether matching nodes should be excluded from final movement destinations
-
SimulationAreaThreat
public SimulationAreaThreat(int id, Rect area, int startTick, int duration, int penalty, boolean avoid) Creates an instance of aSimulationAreaThreatrecord class.- Parameters:
id- the value for theidrecord componentarea- the value for thearearecord componentstartTick- the value for thestartTickrecord componentduration- the value for thedurationrecord componentpenalty- the value for thepenaltyrecord componentavoid- the value for theavoidrecord component
-
-
Method Details
-
covering
Starts a builder for an area threat.- Parameters:
area- rectangular hazard area
-
area
Creates a one-tick area threat that is not tied to a specific source id.- Parameters:
area- rectangular hazard areastartTick- simulated tick when this hazard is activepenalty- penalty amount to add to matching nodesavoid- whether matching nodes should be excluded from final destinations
-
area
public static SimulationAreaThreat area(Rect area, int startTick, int duration, int penalty, boolean avoid) Creates an area threat that is not tied to a specific source id.- Parameters:
area- rectangular hazard areastartTick- first simulated tick when this hazard is activeduration- number of simulated ticks this hazard remains activepenalty- penalty amount to add to matching nodesavoid- whether matching nodes should be excluded from final destinations
-
area
public static SimulationAreaThreat area(int id, Rect area, int startTick, int duration, int penalty, boolean avoid) Creates an area threat with an explicit source id.- Parameters:
id- source idarea- rectangular hazard areastartTick- first simulated tick when this hazard is activeduration- number of simulated ticks this hazard remains activepenalty- penalty amount to add to matching nodesavoid- whether matching nodes should be excluded from final destinations
-
avoidArea
Creates a one-tick area threat that should be avoided as a final destination.- Parameters:
area- rectangular hazard areastartTick- simulated tick when this hazard is activepenalty- penalty amount to add to matching nodes
-
avoidArea
Creates an area threat that should be avoided as a final destination.- Parameters:
area- rectangular hazard areastartTick- first simulated tick when this hazard is activeduration- number of simulated ticks this hazard remains activepenalty- penalty amount to add to matching nodes
-
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 '=='. -
id
public int id()Returns the value of theidrecord component.- Returns:
- the value of the
idrecord component
-
area
Returns the value of thearearecord component.- Returns:
- the value of the
arearecord 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
-
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
-