Record Class EntityCombat.Builder<I>

java.lang.Object
java.lang.Record
dev.twilite.game.simulation.rules.combat.EntityCombat.Builder<I>
Type Parameters:
I - plugin-defined input for each run
Record Components:
entities - function that supplies initial entity states for the current input
prediction - entity prediction function
lineOfSight - line-of-sight rule
Enclosing class:
EntityCombat

public static record EntityCombat.Builder<I>(Function<I,? extends Collection<SimulationEntity>> entities, EntityCombat.Prediction<I> prediction, SimulationEntity.LineOfSight<? super I> lineOfSight) extends Record
Builder for entity combat tasks.
  • Constructor Details

  • Method Details

    • predictWith

      public EntityCombat.Builder<I> predictWith(EntityCombat.Prediction<I> prediction)
      Uses a custom entity prediction function.
      Parameters:
      prediction - entity prediction function
    • lineOfSight

      public EntityCombat.Builder<I> lineOfSight(SimulationEntity.LineOfSight<? super I> lineOfSight)
      Uses a custom line-of-sight rule.
      Parameters:
      lineOfSight - line-of-sight rule
    • penalty

      public SimulationTask<I> penalty(int penalty)
      Builds a task that penalizes candidates hit by predicted entity attacks.
      Parameters:
      penalty - penalty amount to add when a predicted entity can attack the candidate
    • avoid

      public SimulationTask<I> avoid()
      Builds a task that rejects candidates hit by predicted entity attacks.
    • avoid

      public SimulationTask<I> avoid(int penalty)
      Builds a task that rejects candidates hit by predicted entity attacks and records a penalty.
      Parameters:
      penalty - penalty amount to add when a predicted entity can attack the candidate
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • entities

      public Function<I,? extends Collection<SimulationEntity>> entities()
      Returns the value of the entities record component.
      Returns:
      the value of the entities record component
    • prediction

      public EntityCombat.Prediction<I> prediction()
      Returns the value of the prediction record component.
      Returns:
      the value of the prediction record component
    • lineOfSight

      public SimulationEntity.LineOfSight<? super I> lineOfSight()
      Returns the value of the lineOfSight record component.
      Returns:
      the value of the lineOfSight record component