Record Class SimulationAreaThreat.Builder

java.lang.Object
java.lang.Record
dev.twilite.game.simulation.model.threat.SimulationAreaThreat.Builder
Enclosing class:
SimulationAreaThreat

public static record SimulationAreaThreat.Builder(int id, Rect area, int startTick, int duration, int penalty) extends Record
Builder for rectangular area threats.
  • Constructor Details

    • Builder

      public Builder(int id, Rect area, int startTick, int duration, int penalty)
      Creates an instance of a Builder 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
  • Method Details

    • id

      public SimulationAreaThreat.Builder id(int id)
      Sets the source id.
      Parameters:
      id - source id
    • active

      public SimulationAreaThreat.Builder active(int startTick, int duration)
      Sets the active tick range.
      Parameters:
      startTick - first simulated tick when this hazard is active
      duration - number of simulated ticks this hazard remains active
    • always

      Marks this threat as active for the full simulation horizon.
    • penalty

      public SimulationAreaThreat.Builder penalty(int penalty)
      Sets the penalty added to matching nodes.
      Parameters:
      penalty - penalty amount
    • penalize

      public SimulationAreaThreat penalize()
      Builds a threat that penalizes matching nodes without rejecting them as final destinations.
    • avoid

      public SimulationAreaThreat avoid()
      Builds a threat that should be avoided as a final destination.
    • 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