Record Class BattleAnimationContext

java.lang.Object
java.lang.Record
com.pixelmonmod.pixelmon.api.battles.animation.BattleAnimationContext

public record BattleAnimationContext(BattleController controller, @Nullable BattleController rootController, @Nullable PixelmonWrapper user, @Nullable PixelmonWrapper target, @Nullable Attack attack) extends Record
Shared server-side context for creating and playing battle animations.

The root controller is populated for multi-lane battles so UI-scoped animations can still be coordinated across the whole raid or battle group when necessary.

  • Constructor Details

    • BattleAnimationContext

      public BattleAnimationContext(BattleController controller, @Nullable BattleController rootController, @Nullable PixelmonWrapper user, @Nullable PixelmonWrapper target, @Nullable Attack attack)
      Creates an instance of a BattleAnimationContext record class.
      Parameters:
      controller - the value for the controller record component
      rootController - the value for the rootController record component
      user - the value for the user record component
      target - the value for the target record component
      attack - the value for the attack record component
  • Method Details

    • attack

      public static BattleAnimationContext attack(BattleController controller, PixelmonWrapper user, PixelmonWrapper target, Attack attack)
      Creates an animation context for an attack animation and derives the root controller when the attack is part of a multi-lane battle.
      Parameters:
      controller - the battle controller that produced the attack
      user - the attacking Pokemon
      target - the targeted Pokemon
      attack - the attack being animated
      Returns:
      a populated attack animation context
    • withController

      public BattleAnimationContext withController(BattleController controller)
      Returns a copy of this context bound to another battle controller.
      Parameters:
      controller - the replacement controller
      Returns:
      a copied context using the replacement controller
    • from

      @Nullable public static BattleAnimationContext from(StoredContext context)
      Builds an animation context from an interaction or battle stored context.
      Parameters:
      context - the source context
      Returns:
      an animation context, or null when no battle controller is present
    • 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.
    • controller

      public BattleController controller()
      Returns the value of the controller record component.
      Returns:
      the value of the controller record component
    • rootController

      @Nullable public BattleController rootController()
      Returns the value of the rootController record component.
      Returns:
      the value of the rootController record component
    • user

      @Nullable public PixelmonWrapper user()
      Returns the value of the user record component.
      Returns:
      the value of the user record component
    • target

      @Nullable public PixelmonWrapper target()
      Returns the value of the target record component.
      Returns:
      the value of the target record component
    • attack

      @Nullable public Attack attack()
      Returns the value of the attack record component.
      Returns:
      the value of the attack record component