Record Class SimulationMovingThreat
java.lang.Object
java.lang.Record
dev.twilite.game.simulation.model.threat.SimulationMovingThreat
- Record Components:
id- source idposition- current threat coordinateradius- Chebyshev radius aroundpositionpenalty- penalty amount to add to matching nodesavoid- whether matching nodes should be excluded from final movement destinations
public record SimulationMovingThreat(int id, Coord position, int radius, int penalty, boolean avoid)
extends Record
Threat whose next position depends on the simulated player path.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordBuilder for moving threats. -
Constructor Summary
ConstructorsConstructorDescriptionSimulationMovingThreat(int id, Coord position, int radius, int penalty, boolean avoid) Creates an instance of aSimulationMovingThreatrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanactiveAt(SimulationNode node) Returns whether this threat overlaps a candidate node.Starts a builder for a moving threat.booleanavoid()Returns the value of theavoidrecord 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.Returns a copy at a new position.static SimulationMovingThreatCreates a moving threat with an explicit source id.static SimulationMovingThreatCreates a moving threat that is not tied to a specific source id.static SimulationMovingThreatmovingAvoid(Coord position, int radius, int penalty) Creates a moving threat that should be avoided as a final destination.intpenalty()Returns the value of thepenaltyrecord component.position()Returns the value of thepositionrecord component.intradius()Returns the value of theradiusrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
SimulationMovingThreat
Creates an instance of aSimulationMovingThreatrecord class.
-
-
Method Details
-
at
Starts a builder for a moving threat.- Parameters:
position- current threat coordinate
-
moving
Creates a moving threat that is not tied to a specific source id.- Parameters:
position- current threat coordinateradius- Chebyshev radius aroundpositionpenalty- penalty amount to add to matching nodesavoid- whether matching nodes should be excluded from final destinations
-
moving
public static SimulationMovingThreat moving(int id, Coord position, int radius, int penalty, boolean avoid) Creates a moving threat with an explicit source id.- Parameters:
id- source idposition- current threat coordinateradius- Chebyshev radius aroundpositionpenalty- penalty amount to add to matching nodesavoid- whether matching nodes should be excluded from final destinations
-
movingAvoid
Creates a moving threat that should be avoided as a final destination.- Parameters:
position- current threat coordinateradius- Chebyshev radius aroundpositionpenalty- penalty amount to add to matching nodes
-
moveTo
Returns a copy at a new position.- Parameters:
position- new threat coordinate
-
activeAt
Returns whether this threat overlaps a candidate node.- Parameters:
node- candidate node 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
-
position
Returns the value of thepositionrecord component.- Returns:
- the value of the
positionrecord 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
-