Record Class MoveAction

java.lang.Object
java.lang.Record
megamek.common.autoResolve.acar.action.MoveAction
All Implemented Interfaces:
EntityAction, Action

public record MoveAction(int formationId, int targetFormationId, Coords destination) extends Record implements Action
  • Constructor Details

    • MoveAction

      public MoveAction(int formationId, int targetFormationId, Coords destination)
      Creates an instance of a MoveAction record class.
      Parameters:
      formationId - the value for the formationId record component
      targetFormationId - the value for the targetFormationId record component
      destination - the value for the destination record component
  • Method Details

    • getEntityId

      public int getEntityId()
      Specified by:
      getEntityId in interface EntityAction
      Returns:
      The ID of the acting game unit. Note that when an entity is destroyed, it may no longer be available from Game.getEntity(int) but rather only from Game.getOutOfGameEntity(int) or Game.getEntityFromAllSources(int). As this can happen in the middle of resolving complicated situations in the GameManager, this is a potential cause for bugs.
      Note that this is not restricted to Entity; it can be used for all InGameObjects that are handled in the game.
    • getHandler

      public MoveActionHandler getHandler(SimulationManager gameManager)
      Specified by:
      getHandler in interface Action
      Returns:
      A handler that will process this action as an extension of the SBFGameManager
    • isDataValid

      public boolean isDataValid(SimulationContext context)
      Description copied from interface: Action
      Validates the data of this action. Validation should not check game rule details, only if the action can be handled without running into missing or false data (NullPointerExceptions). Errors should be logged. The action will typically be ignored and removed if validation fails.
      Specified by:
      isDataValid in interface Action
      Parameters:
      context - The simulation context
      Returns:
      true when this action is valid, false otherwise
    • toString

      @Nonnull public 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.
    • formationId

      public int formationId()
      Returns the value of the formationId record component.
      Returns:
      the value of the formationId record component
    • targetFormationId

      public int targetFormationId()
      Returns the value of the targetFormationId record component.
      Returns:
      the value of the targetFormationId record component
    • destination

      public Coords destination()
      Returns the value of the destination record component.
      Returns:
      the value of the destination record component