Record Class SimulationEntity

java.lang.Object
java.lang.Record
dev.twilite.game.simulation.model.entity.SimulationEntity
Record Components:
id - source id, such as an NPC index or NPC id
area - currently occupied area
moveSpeed - movement speed used for prediction
attackRange - Chebyshev attack range from the occupied area
attackCycle - ticks between attacks
attackCooldown - ticks until this entity can attack
movementBlockTicks - ticks until this entity can move
expiresIn - ticks until this entity should be removed
melee - whether this entity uses melee movement/attack rules
ignoreEntityCollision - whether this entity ignores simulated entity collision
hitsInside - whether this entity can hit targets inside its footprint
walksToYouAnyway - whether this entity should still walk when already in range

public record SimulationEntity(int id, Rect area, MoveSpeed moveSpeed, int attackRange, int attackCycle, int attackCooldown, int movementBlockTicks, int expiresIn, boolean melee, boolean ignoreEntityCollision, boolean hitsInside, boolean walksToYouAnyway) extends Record
Simulated entity state for movement and combat prediction.
  • Constructor Details

    • SimulationEntity

      public SimulationEntity(int id, Rect area, MoveSpeed moveSpeed, int attackRange, int attackCycle, int attackCooldown, int movementBlockTicks, int expiresIn, boolean melee, boolean ignoreEntityCollision, boolean hitsInside, boolean walksToYouAnyway)
      Creates an instance of a SimulationEntity record class.
      Parameters:
      id - the value for the id record component
      area - the value for the area record component
      moveSpeed - the value for the moveSpeed record component
      attackRange - the value for the attackRange record component
      attackCycle - the value for the attackCycle record component
      attackCooldown - the value for the attackCooldown record component
      movementBlockTicks - the value for the movementBlockTicks record component
      expiresIn - the value for the expiresIn record component
      melee - the value for the melee record component
      ignoreEntityCollision - the value for the ignoreEntityCollision record component
      hitsInside - the value for the hitsInside record component
      walksToYouAnyway - the value for the walksToYouAnyway record component
  • Method Details

    • melee

      public static SimulationEntity melee(int id, Rect area, int attackRange, int attackCycle)
      Creates a walking melee entity with a normal attack cycle.
      Parameters:
      id - entity id
      area - occupied area
      attackRange - Chebyshev attack range
      attackCycle - ticks between attacks
    • moveSpeed

      public SimulationEntity moveSpeed(MoveSpeed moveSpeed)
      Returns a copy with a different movement speed.
      Parameters:
      moveSpeed - movement speed to use when predicting future positions
    • moveTo

      public SimulationEntity moveTo(Rect area)
      Returns a copy at a new occupied area.
      Parameters:
      area - new occupied area
    • attackCooldown

      public SimulationEntity attackCooldown(int attackCooldown)
      Returns a copy with a different attack cooldown.
      Parameters:
      attackCooldown - ticks until this entity can attack
    • movementBlocked

      public SimulationEntity movementBlocked(int movementBlockTicks)
      Returns a copy that cannot move for the supplied number of ticks.
      Parameters:
      movementBlockTicks - ticks until this entity can move
    • expiresIn

      public SimulationEntity expiresIn(int expiresIn)
      Returns a copy that expires after the supplied number of ticks.
      Parameters:
      expiresIn - ticks until this entity should be removed
    • ignoringEntityCollision

      public SimulationEntity ignoringEntityCollision()
      Returns a copy that ignores simulated entity collision.
    • hittingInside

      public SimulationEntity hittingInside()
      Returns a copy that can hit targets inside its occupied area.
    • walkingToTargetAnyway

      public SimulationEntity walkingToTargetAnyway()
      Returns a copy that continues pathing toward the target even when already in attack range.
    • tick

      public SimulationEntity tick()
      Returns a copy after one simulated tick has elapsed.
    • attack

      public SimulationEntity attack()
      Returns a copy with the attack cooldown reset after attacking.
    • canAttack

      public boolean canAttack(Rect target)
      Returns whether this entity can currently attack a target area.
      Parameters:
      target - target area
    • predictToward

      public SimulationEntity predictToward(Rect target)
      Predicts this entity moving directly toward the target for one tick.

      This is intentionally simple and collision-free. Use a custom predictor when a plugin needs real clipping.

      Parameters:
      target - target area
    • 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
    • moveSpeed

      public MoveSpeed moveSpeed()
      Returns the value of the moveSpeed record component.
      Returns:
      the value of the moveSpeed record component
    • attackRange

      public int attackRange()
      Returns the value of the attackRange record component.
      Returns:
      the value of the attackRange record component
    • attackCycle

      public int attackCycle()
      Returns the value of the attackCycle record component.
      Returns:
      the value of the attackCycle record component
    • attackCooldown

      public int attackCooldown()
      Returns the value of the attackCooldown record component.
      Returns:
      the value of the attackCooldown record component
    • movementBlockTicks

      public int movementBlockTicks()
      Returns the value of the movementBlockTicks record component.
      Returns:
      the value of the movementBlockTicks record component
    • expiresIn

      public int expiresIn()
      Returns the value of the expiresIn record component.
      Returns:
      the value of the expiresIn record component
    • melee

      public boolean melee()
      Returns the value of the melee record component.
      Returns:
      the value of the melee record component
    • ignoreEntityCollision

      public boolean ignoreEntityCollision()
      Returns the value of the ignoreEntityCollision record component.
      Returns:
      the value of the ignoreEntityCollision record component
    • hitsInside

      public boolean hitsInside()
      Returns the value of the hitsInside record component.
      Returns:
      the value of the hitsInside record component
    • walksToYouAnyway

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