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 idarea- currently occupied areamoveSpeed- movement speed used for predictionattackRange- Chebyshev attack range from the occupied areaattackCycle- ticks between attacksattackCooldown- ticks until this entity can attackmovementBlockTicks- ticks until this entity can moveexpiresIn- ticks until this entity should be removedmelee- whether this entity uses melee movement/attack rulesignoreEntityCollision- whether this entity ignores simulated entity collisionhitsInside- whether this entity can hit targets inside its footprintwalksToYouAnyway- 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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInput-aware line-of-sight rule used by simulated entity attacks. -
Constructor Summary
ConstructorsConstructorDescriptionSimulationEntity(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 aSimulationEntityrecord class. -
Method Summary
Modifier and TypeMethodDescriptionarea()Returns the value of thearearecord component.attack()Returns a copy with the attack cooldown reset after attacking.intReturns the value of theattackCooldownrecord component.attackCooldown(int attackCooldown) Returns a copy with a different attack cooldown.intReturns the value of theattackCyclerecord component.intReturns the value of theattackRangerecord component.booleanReturns whether this entity can currently attack a target area.final booleanIndicates whether some other object is "equal to" this one.intReturns the value of theexpiresInrecord component.expiresIn(int expiresIn) Returns a copy that expires after the supplied number of ticks.final inthashCode()Returns a hash code value for this object.booleanReturns the value of thehitsInsiderecord component.Returns a copy that can hit targets inside its occupied area.intid()Returns the value of theidrecord component.booleanReturns the value of theignoreEntityCollisionrecord component.Returns a copy that ignores simulated entity collision.booleanmelee()Returns the value of themeleerecord component.static SimulationEntityCreates a walking melee entity with a normal attack cycle.movementBlocked(int movementBlockTicks) Returns a copy that cannot move for the supplied number of ticks.intReturns the value of themovementBlockTicksrecord component.Returns the value of themoveSpeedrecord component.Returns a copy with a different movement speed.Returns a copy at a new occupied area.predictToward(Rect target) Predicts this entity moving directly toward the target for one tick.tick()Returns a copy after one simulated tick has elapsed.final StringtoString()Returns a string representation of this record class.Returns a copy that continues pathing toward the target even when already in attack range.booleanReturns the value of thewalksToYouAnywayrecord component.
-
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 aSimulationEntityrecord class.- Parameters:
id- the value for theidrecord componentarea- the value for thearearecord componentmoveSpeed- the value for themoveSpeedrecord componentattackRange- the value for theattackRangerecord componentattackCycle- the value for theattackCyclerecord componentattackCooldown- the value for theattackCooldownrecord componentmovementBlockTicks- the value for themovementBlockTicksrecord componentexpiresIn- the value for theexpiresInrecord componentmelee- the value for themeleerecord componentignoreEntityCollision- the value for theignoreEntityCollisionrecord componenthitsInside- the value for thehitsInsiderecord componentwalksToYouAnyway- the value for thewalksToYouAnywayrecord component
-
-
Method Details
-
melee
Creates a walking melee entity with a normal attack cycle.- Parameters:
id- entity idarea- occupied areaattackRange- Chebyshev attack rangeattackCycle- ticks between attacks
-
moveSpeed
Returns a copy with a different movement speed.- Parameters:
moveSpeed- movement speed to use when predicting future positions
-
moveTo
Returns a copy at a new occupied area.- Parameters:
area- new occupied area
-
attackCooldown
Returns a copy with a different attack cooldown.- Parameters:
attackCooldown- ticks until this entity can attack
-
movementBlocked
Returns a copy that cannot move for the supplied number of ticks.- Parameters:
movementBlockTicks- ticks until this entity can move
-
expiresIn
Returns a copy that expires after the supplied number of ticks.- Parameters:
expiresIn- ticks until this entity should be removed
-
ignoringEntityCollision
Returns a copy that ignores simulated entity collision. -
hittingInside
Returns a copy that can hit targets inside its occupied area. -
walkingToTargetAnyway
Returns a copy that continues pathing toward the target even when already in attack range. -
tick
Returns a copy after one simulated tick has elapsed. -
attack
Returns a copy with the attack cooldown reset after attacking. -
canAttack
Returns whether this entity can currently attack a target area.- Parameters:
target- target area
-
predictToward
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
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
id
public int id()Returns the value of theidrecord component.- Returns:
- the value of the
idrecord component
-
area
Returns the value of thearearecord component.- Returns:
- the value of the
arearecord component
-
moveSpeed
Returns the value of themoveSpeedrecord component.- Returns:
- the value of the
moveSpeedrecord component
-
attackRange
public int attackRange()Returns the value of theattackRangerecord component.- Returns:
- the value of the
attackRangerecord component
-
attackCycle
public int attackCycle()Returns the value of theattackCyclerecord component.- Returns:
- the value of the
attackCyclerecord component
-
attackCooldown
public int attackCooldown()Returns the value of theattackCooldownrecord component.- Returns:
- the value of the
attackCooldownrecord component
-
movementBlockTicks
public int movementBlockTicks()Returns the value of themovementBlockTicksrecord component.- Returns:
- the value of the
movementBlockTicksrecord component
-
expiresIn
public int expiresIn()Returns the value of theexpiresInrecord component.- Returns:
- the value of the
expiresInrecord component
-
melee
public boolean melee()Returns the value of themeleerecord component.- Returns:
- the value of the
meleerecord component
-
ignoreEntityCollision
public boolean ignoreEntityCollision()Returns the value of theignoreEntityCollisionrecord component.- Returns:
- the value of the
ignoreEntityCollisionrecord component
-
hitsInside
public boolean hitsInside()Returns the value of thehitsInsiderecord component.- Returns:
- the value of the
hitsInsiderecord component
-
walksToYouAnyway
public boolean walksToYouAnyway()Returns the value of thewalksToYouAnywayrecord component.- Returns:
- the value of the
walksToYouAnywayrecord component
-