Class StructureActivityManager
java.lang.Object
nl.pim16aap2.animatedarchitecture.core.api.restartable.Restartable
nl.pim16aap2.animatedarchitecture.core.animation.StructureActivityManager
- All Implemented Interfaces:
IDebuggable, IRestartable, StructureDeletionManager.IDeletionListener
@Singleton
public final class StructureActivityManager
extends Restartable
implements StructureDeletionManager.IDeletionListener, IDebuggable
Keeps track of which structures are currently active.
-
Constructor Summary
ConstructorsConstructorDescriptionStructureActivityManager(RestartableHolder holder, IAnimatedArchitectureEventFactory eventFactory, IAnimatedArchitectureEventCaller animatedArchitectureEventCaller, IExecutor executor, DebuggableRegistry debuggableRegistry, StructureDeletionManager structureDeletionManager) Constructs a newStructureActivityManager. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAnimator(long stamp, Animator animator) Stores aAnimatorin the appropriate slot inanimatorsGets all the currently activeAnimators.Gets the debug information for this object.voidHandles the initialization.voidonStructureDeletion(IStructureConst structure) Called when a structure is deleted.registerAnimation(Structure targetStructure, boolean requiresWriteAccess) Attempts to register a new animation.voidshutDown()Handles a shutdown.voidstopAnimators(long uid) Stops all active animators regardless of read/write access.voidstopAnimatorsWithWriteAccess(long uid) Stops an active animator with write access if one currently exists for the structure with the provided UID.voidunregisterAnimation(long uid, long stamp) Unregisters an animation.
-
Constructor Details
-
StructureActivityManager
@Inject public StructureActivityManager(RestartableHolder holder, IAnimatedArchitectureEventFactory eventFactory, IAnimatedArchitectureEventCaller animatedArchitectureEventCaller, IExecutor executor, DebuggableRegistry debuggableRegistry, StructureDeletionManager structureDeletionManager) Constructs a newStructureActivityManager.- Parameters:
holder- TheRestartableHolderthat manages this object.
-
-
Method Details
-
registerAnimation
@CheckReturnValue public OptionalLong registerAnimation(Structure targetStructure, boolean requiresWriteAccess) Attempts to register a new animation.The registration attempt returns an optional long. This value is the stamp of the registry. In case the registered animation is registered with read/write access, the stamp will be a unique, non-zero value.
Registrations with read-only access all share a single stamp for all animators for the same structure UID. The stamp is still unique between each group of animators.
Once registered, the animator for the animation can be inserted using
addAnimator(long, Animator).- Parameters:
targetStructure- The structure being animated.requiresWriteAccess- True to register the animation with read/write access. Only one such animator can be active per structure.- Returns:
- The stamp of the animation entry if it was registered successfully. If the animation could not be
registered,
OptionalLong.empty()is returned.
-
unregisterAnimation
public void unregisterAnimation(long uid, long stamp) Unregisters an animation.- Parameters:
uid- The UID of the structure for which the animation was registered.stamp- The stamp of the registry entry.- Throws:
IllegalArgumentException- If an entry was found and its stamp does not match the provided stamp.
-
stopAnimatorsWithWriteAccess
public void stopAnimatorsWithWriteAccess(long uid) Stops an active animator with write access if one currently exists for the structure with the provided UID.- Parameters:
uid- The UID of the structure being animated.
-
stopAnimators
public void stopAnimators(long uid) Stops all active animators regardless of read/write access.- Parameters:
uid- The UID of the structure whose animation(s) to stop.
-
addAnimator
Stores aAnimatorin the appropriate slot inanimators- Parameters:
stamp- The stamp of the entry.The stamp is used to validate the correct
animator- TheAnimator.- Throws:
IllegalStateException- When no existing entry exists for the provided animator.
-
getBlockMovers
-
onStructureDeletion
Description copied from interface:StructureDeletionManager.IDeletionListenerCalled when a structure is deleted.- Specified by:
onStructureDeletionin interfaceStructureDeletionManager.IDeletionListener- Parameters:
structure- The structure that was deleted.
-
shutDown
public void shutDown()Description copied from interface:IRestartableHandles a shutdown.- Specified by:
shutDownin interfaceIRestartable
-
initialize
public void initialize()Description copied from interface:IRestartableHandles the initialization.- Specified by:
initializein interfaceIRestartable
-
getDebugInformation
Description copied from interface:IDebuggableGets the debug information for this object.- Specified by:
getDebugInformationin interfaceIDebuggable- Returns:
- The debug information or null if there's nothing to log at this time.
-