Record Class SimulationMovingThreat

java.lang.Object
java.lang.Record
dev.twilite.game.simulation.model.threat.SimulationMovingThreat
Record Components:
id - source id
position - current threat coordinate
radius - Chebyshev radius around position
penalty - penalty amount to add to matching nodes
avoid - 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.
  • Constructor Details

    • SimulationMovingThreat

      public SimulationMovingThreat(int id, Coord position, int radius, int penalty, boolean avoid)
      Creates an instance of a SimulationMovingThreat record class.
      Parameters:
      id - the value for the id record component
      position - the value for the position record component
      radius - the value for the radius record component
      penalty - the value for the penalty record component
      avoid - the value for the avoid record component
  • Method Details

    • at

      public static SimulationMovingThreat.Builder at(Coord position)
      Starts a builder for a moving threat.
      Parameters:
      position - current threat coordinate
    • moving

      public static SimulationMovingThreat moving(Coord position, int radius, int penalty, boolean avoid)
      Creates a moving threat that is not tied to a specific source id.
      Parameters:
      position - current threat coordinate
      radius - Chebyshev radius around position
      penalty - penalty amount to add to matching nodes
      avoid - 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 id
      position - current threat coordinate
      radius - Chebyshev radius around position
      penalty - penalty amount to add to matching nodes
      avoid - whether matching nodes should be excluded from final destinations
    • movingAvoid

      public static SimulationMovingThreat movingAvoid(Coord position, int radius, int penalty)
      Creates a moving threat that should be avoided as a final destination.
      Parameters:
      position - current threat coordinate
      radius - Chebyshev radius around position
      penalty - penalty amount to add to matching nodes
    • moveTo

      public SimulationMovingThreat moveTo(Coord position)
      Returns a copy at a new position.
      Parameters:
      position - new threat coordinate
    • activeAt

      public boolean activeAt(SimulationNode node)
      Returns whether this threat overlaps a candidate node.
      Parameters:
      node - candidate node to test
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • id

      public int id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component
    • position

      public Coord position()
      Returns the value of the position record component.
      Returns:
      the value of the position record component
    • radius

      public int radius()
      Returns the value of the radius record component.
      Returns:
      the value of the radius record component
    • penalty

      public int penalty()
      Returns the value of the penalty record component.
      Returns:
      the value of the penalty record component
    • avoid

      public boolean avoid()
      Returns the value of the avoid record component.
      Returns:
      the value of the avoid record component