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 id
area - rectangular hazard area
startTick - first simulated tick when this hazard is active
duration - number of simulated ticks this hazard remains active
penalty - penalty amount to add to matching nodes
avoid - 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 Classes
    Modifier and Type
    Class
    Description
    static final record 
    Builder for rectangular area threats.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SimulationAreaThreat(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 a SimulationAreaThreat record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns whether this threat is active for a candidate node.
    boolean
    activeOn(int tick)
    Returns whether this threat is active on a simulated tick.
    Returns the value of the area record component.
    area(int id, Rect area, int startTick, int duration, int penalty, boolean avoid)
    Creates an area threat with an explicit source id.
    area(Rect area, int startTick, int penalty, boolean avoid)
    Creates a one-tick area threat that is not tied to a specific source id.
    area(Rect area, int startTick, int duration, int penalty, boolean avoid)
    Creates an area threat that is not tied to a specific source id.
    boolean
    Returns the value of the avoid record component.
    avoidArea(Rect area, int startTick, int penalty)
    Creates a one-tick area threat that should be avoided as a final destination.
    avoidArea(Rect area, int startTick, int duration, int penalty)
    Creates an area threat that should be avoided as a final destination.
    covering(Rect area)
    Starts a builder for an area threat.
    int
    Returns the value of the duration record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    int
    id()
    Returns the value of the id record component.
    int
    Returns the value of the penalty record component.
    int
    Returns the value of the startTick record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • SimulationAreaThreat

      public SimulationAreaThreat(int id, Rect area, int startTick, int penalty, boolean avoid)
      Creates a one-tick area threat.
      Parameters:
      id - source id, such as a projectile, effect, or animation id
      area - rectangular hazard area
      startTick - simulated tick when this hazard is active
      penalty - penalty amount to add to matching nodes
      avoid - 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 a SimulationAreaThreat record class.
      Parameters:
      id - the value for the id record component
      area - the value for the area record component
      startTick - the value for the startTick record component
      duration - the value for the duration record component
      penalty - the value for the penalty record component
      avoid - the value for the avoid record component
  • Method Details

    • covering

      public static SimulationAreaThreat.Builder covering(Rect area)
      Starts a builder for an area threat.
      Parameters:
      area - rectangular hazard area
    • area

      public static SimulationAreaThreat area(Rect area, int startTick, int penalty, boolean avoid)
      Creates a one-tick area threat that is not tied to a specific source id.
      Parameters:
      area - rectangular hazard area
      startTick - simulated tick when this hazard is active
      penalty - penalty amount to add to matching nodes
      avoid - 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 area
      startTick - first simulated tick when this hazard is active
      duration - number of simulated ticks this hazard remains active
      penalty - penalty amount to add to matching nodes
      avoid - 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 id
      area - rectangular hazard area
      startTick - first simulated tick when this hazard is active
      duration - number of simulated ticks this hazard remains active
      penalty - penalty amount to add to matching nodes
      avoid - whether matching nodes should be excluded from final destinations
    • avoidArea

      public static SimulationAreaThreat avoidArea(Rect area, int startTick, int penalty)
      Creates a one-tick area threat that should be avoided as a final destination.
      Parameters:
      area - rectangular hazard area
      startTick - simulated tick when this hazard is active
      penalty - penalty amount to add to matching nodes
    • avoidArea

      public static SimulationAreaThreat avoidArea(Rect area, int startTick, int duration, int penalty)
      Creates an area threat that should be avoided as a final destination.
      Parameters:
      area - rectangular hazard area
      startTick - first simulated tick when this hazard is active
      duration - number of simulated ticks this hazard remains active
      penalty - penalty amount to add to matching nodes
    • activeAt

      public boolean activeAt(SimulationNode node)
      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

      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
    • area

      public Rect area()
      Returns the value of the area record component.
      Returns:
      the value of the area record component
    • startTick

      public int startTick()
      Returns the value of the startTick record component.
      Returns:
      the value of the startTick record component
    • duration

      public int duration()
      Returns the value of the duration record component.
      Returns:
      the value of the duration 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