Class Animator

java.lang.Object
nl.pim16aap2.animatedarchitecture.core.animation.Animator
All Implemented Interfaces:
IAnimator

public final class Animator extends Object implements IAnimator
Represents a class that animates blocks.
  • Constructor Details

    • Animator

      public Animator(Structure structure, AnimationRequestData data, IAnimationComponent animationComponent, IAnimatedBlockContainer animatedBlockContainer)
      Constructs a Animator.

      Once created, the animation does not start immediately. Use startAnimation() to start it.

      Parameters:
      structure - The Structure that is being animated.
      data - The data of the movement request.
      animationComponent - The animation component to use for the animation. This determines the type of animation.
      animatedBlockContainer - The manager of the animated blocks. This is responsible for handling the lifecycle of the animated blocks.
  • Method Details

    • stopAnimation

      public void stopAnimation()
      Stops the animation gracefully. May cause the animation to restart later.
    • abort

      public void abort()
      Aborts the animation.

      Unlike blockingAbort(), this method does not block until the animation has finished.

    • blockingAbort

      public void blockingAbort()
      Aborts the animation and blocks until the animation has finished.

      Note that this excludes database operations, which are always asynchronous.

      If it is undesirable to block the main thread, use abort() instead.

    • getAnimatedBlocks

      public List<IAnimatedBlock> getAnimatedBlocks()
      Description copied from interface: IAnimator
      Returns all the animated blocks that are part of this animation.
      Specified by:
      getAnimatedBlocks in interface IAnimator
      Returns:
      An unmodifiable list with the animated blocks that are part of the animation.
    • startAnimation

      public void startAnimation()
      Replaces all blocks of the Structure with animated blocks and starts the animation.

      Note that if skipAnimation is true, the blocks will be placed in the new position immediately without any animations.

    • applyMovement

      public void applyMovement(IAnimatedBlock animatedBlock, RotatedPosition targetPosition)
      Description copied from interface: IAnimator
      Moves the selected animated block.
      Specified by:
      applyMovement in interface IAnimator
      Parameters:
      animatedBlock - The animated block that should be moved.
      targetPosition - The target position of the animated block.
    • getStructureUID

      public long getStructureUID()
      Gets the UID of the Structure being moved.
      Returns:
      The UID of the Structure being moved.
    • toString

      public @NonNull String toString()
      Overrides:
      toString in class Object
    • getStructure

      public Structure getStructure()
      The structure whose blocks are going to be moved.
    • getSnapshot

      public StructureSnapshot getSnapshot()
      A snapshot of the structure created before the toggle.
    • getPlayer

      public IPlayer getPlayer()
      The player responsible for the movement.

      This player may be offline.

    • isAborted

      public boolean isAborted()
      Flag that indicates whether the animation has been aborted.
    • getCause

      public StructureActionCause getCause()
      What caused the structure to be moved.
    • getActionType

      public StructureActionType getActionType()
      The type of action that is fulfilled by moving the structure.
    • getTime

      public double getTime()
      The amount of time (in seconds) that the animation will take.
    • isSkipAnimation

      public boolean isSkipAnimation()
      When true, the blocks are moved without animating them. No animated blocks are spawned.
    • getAnimationType

      public AnimationType getAnimationType()
      The type of animation performed by this animator.