Record Class Entity.Action
java.lang.Object
java.lang.Record
nz.ac.vuw.ecs.swen225.gp22.domain.Entity.Action
- Record Components:
id
- ID of the entity this action belongs to.moveVector
- Amount the entity moved by in this action.oldDir
- Direction entity was facing before action.newDir
- Direction entity is facing after action.interaction
- The interaction, if any that happened this action.
- Enclosing class:
- Entity<S extends Observable<S>>
public static record Entity.Action(int id, Maze.Point moveVector, Entity.Direction oldDir, Entity.Direction newDir, Entity.Action.Interaction interaction)
extends Record
A record used to store an action taken. This will be
used to revert actions when replaying a game.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final record
Represents an interaction with a tile that happened in the action. -
Constructor Summary
ConstructorDescriptionAction
(int id, Maze.Point moveVector, Entity.Direction oldDir, Entity.Direction newDir, Entity.Action.Interaction interaction) Creates an instance of aAction
record class. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.int
id()
Returns the value of theid
record component.Returns the value of theinteraction
record component.Returns the value of themoveVector
record component.newDir()
Returns the value of thenewDir
record component.oldDir()
Returns the value of theoldDir
record component.final String
toString()
Returns a string representation of this record class.
-
Constructor Details
-
Action
public Action(int id, Maze.Point moveVector, Entity.Direction oldDir, Entity.Direction newDir, Entity.Action.Interaction interaction) Creates an instance of aAction
record class.- Parameters:
id
- the value for theid
record componentmoveVector
- the value for themoveVector
record componentoldDir
- the value for theoldDir
record componentnewDir
- the value for thenewDir
record componentinteraction
- the value for theinteraction
record component
-
-
Method Details
-
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 theid
record component.- Returns:
- the value of the
id
record component
-
moveVector
Returns the value of themoveVector
record component.- Returns:
- the value of the
moveVector
record component
-
oldDir
Returns the value of theoldDir
record component.- Returns:
- the value of the
oldDir
record component
-
newDir
Returns the value of thenewDir
record component.- Returns:
- the value of the
newDir
record component
-
interaction
Returns the value of theinteraction
record component.- Returns:
- the value of the
interaction
record component
-