Class Animator
java.lang.Object
nl.pim16aap2.animatedarchitecture.core.animation.Animator
- All Implemented Interfaces:
IAnimator
Represents a class that animates blocks.
-
Constructor Summary
ConstructorsConstructorDescriptionAnimator(Structure structure, AnimationRequestData data, IAnimationComponent animationComponent, IAnimatedBlockContainer animatedBlockContainer) Constructs aAnimator. -
Method Summary
Modifier and TypeMethodDescriptionvoidabort()Aborts the animation.voidapplyMovement(IAnimatedBlock animatedBlock, RotatedPosition targetPosition) Moves the selected animated block.voidAborts the animation and blocks until the animation has finished.The type of action that is fulfilled by moving the structure.getCause()What caused the structure to be moved.The player responsible for the movement.A snapshot of the structure created before the toggle.The structure whose blocks are going to be moved.longGets the UID of theStructurebeing moved.doublegetTime()The amount of time (in seconds) that the animation will take.booleanFlag that indicates whether the animation has been aborted.booleanWhen true, the blocks are moved without animating them.voidReplaces all blocks of theStructurewith animated blocks and starts the animation.voidStops the animation gracefully.toString()
-
Constructor Details
-
Animator
public Animator(Structure structure, AnimationRequestData data, IAnimationComponent animationComponent, IAnimatedBlockContainer animatedBlockContainer) Constructs aAnimator.Once created, the animation does not start immediately. Use
startAnimation()to start it.- Parameters:
structure- TheStructurethat 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
- Specified by:
getAnimatedBlocksin interfaceIAnimator- Returns:
- All the animated blocks that are part of the animation.
-
startAnimation
public void startAnimation()Replaces all blocks of theStructurewith animated blocks and starts the animation.Note that if
skipAnimationis true, the blocks will be placed in the new position immediately without any animations. -
applyMovement
Description copied from interface:IAnimatorMoves the selected animated block.- Specified by:
applyMovementin interfaceIAnimator- 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 theStructurebeing moved.- Returns:
- The UID of the
Structurebeing moved.
-
toString
-
getStructure
The structure whose blocks are going to be moved. -
getSnapshot
A snapshot of the structure created before the toggle. -
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
What caused the structure to be moved. -
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
-