Record Class SimulationThreat

java.lang.Object
java.lang.Record
dev.twilite.game.simulation.model.threat.SimulationThreat
Record Components:
kind - broad source category
id - source id, such as a projectile, effect, or animation id
position - center coordinate of the hazard
startTick - first simulated tick when this hazard is active
duration - number of simulated ticks this hazard remains active
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 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 Classes
    Modifier and Type
    Class
    Description
    static final record 
    Builder for coordinate threats.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SimulationThreat(SimulationThreatKind kind, int id, Coord position, int startTick, int duration, int radius, int penalty, boolean avoid)
    Creates an instance of a SimulationThreat 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.
    at(Coord position)
    Starts a builder for a coordinate threat.
    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.
    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.
    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.
    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.
    boolean
    Returns the value of the avoid record component.
    avoid(Coord position, int startTick, int radius, int penalty)
    Creates a one-tick coordinate threat that should be avoided as a final destination.
    avoid(Coord position, int startTick, int duration, int radius, int penalty)
    Creates a coordinate threat that should be avoided as a final destination.
    int
    Returns the value of the duration record component.
    effect(Effect effect, int radius, int penalty, boolean avoid)
    Creates an immediate effect threat at the effect coordinate.
    effect(Effect effect, int duration, int radius, int penalty, boolean avoid)
    Creates an immediate effect threat at the effect coordinate.
    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.
    Returns the value of the kind record component.
    int
    Returns the value of the penalty record component.
    Returns the value of the position record component.
    projectile(Projectile projectile, int radius, int penalty, boolean avoid)
    Creates a timed projectile threat at the projectile target coordinate.
    projectile(Projectile projectile, int duration, int radius, int penalty, boolean avoid)
    Creates a timed projectile threat at the projectile target coordinate.
    int
    Returns the value of the radius 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

    • SimulationThreat

      public SimulationThreat(SimulationThreatKind kind, int id, Coord position, int startTick, int duration, int radius, int penalty, boolean avoid)
      Creates an instance of a SimulationThreat record class.
      Parameters:
      kind - the value for the kind record component
      id - the value for the id record component
      position - the value for the position record component
      startTick - the value for the startTick record component
      duration - the value for the duration 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 SimulationThreat.Builder at(Coord position)
      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 hazard
      startTick - first simulated tick when this hazard is active
      radius - Chebyshev radius around position
      penalty - penalty amount to add to matching nodes
      avoid - 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 hazard
      startTick - first simulated tick when this hazard is active
      duration - number of simulated ticks this hazard remains active
      radius - Chebyshev radius around position
      penalty - penalty amount to add to matching nodes
      avoid - 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 category
      id - source id
      position - center coordinate of the hazard
      startTick - first simulated tick when this hazard is active
      radius - Chebyshev radius around position
      penalty - penalty amount to add to matching nodes
      avoid - 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 category
      id - source id
      position - center coordinate of the hazard
      startTick - first simulated tick when this hazard is active
      duration - number of simulated ticks this hazard remains active
      radius - Chebyshev radius around position
      penalty - penalty amount to add to matching nodes
      avoid - whether matching nodes should be excluded from final destinations
    • avoid

      public static SimulationThreat avoid(Coord position, int startTick, int radius, int penalty)
      Creates a one-tick coordinate threat that should be avoided as a final destination.
      Parameters:
      position - center coordinate of the hazard
      startTick - first simulated tick when this hazard is active
      radius - Chebyshev radius around position
      penalty - 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 hazard
      startTick - first simulated tick when this hazard is active
      duration - number of simulated ticks this hazard remains active
      radius - Chebyshev radius around position
      penalty - 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 model
      radius - Chebyshev radius around the target coordinate
      penalty - penalty amount to add when the projectile lands
      avoid - 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 model
      duration - number of simulated ticks the projectile impact remains active
      radius - Chebyshev radius around the target coordinate
      penalty - penalty amount to add when the projectile lands
      avoid - whether matching nodes should be excluded from final destinations
    • effect

      public static SimulationThreat effect(Effect effect, int radius, int penalty, boolean avoid)
      Creates an immediate effect threat at the effect coordinate.
      Parameters:
      effect - effect to model
      radius - Chebyshev radius around the effect coordinate
      penalty - penalty amount to add while the effect is active
      avoid - 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 model
      duration - number of simulated ticks the effect remains active
      radius - Chebyshev radius around the effect coordinate
      penalty - penalty amount to add while the effect is active
      avoid - whether matching nodes should be excluded from final destinations
    • 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.
    • kind

      public SimulationThreatKind kind()
      Returns the value of the kind record component.
      Returns:
      the value of the kind record component
    • 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
    • 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
    • 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