Skip to content

AnimatorComponent Class

ECS component that holds a SpriteAnimator and an AnimationStateMachine for an entity. Add this alongside SpriteComponent and register AnimationSystem in the scene.

public class AnimatorComponent : Brine2D.ECS.Component, System.IDisposable

Inheritance System.ObjectComponent → AnimatorComponent

Implements System.IDisposable

Remarks

Layers are applied after the base animator in ascending Priority order; the base animator is priority 0. Assign BlendSelector1D or BlendSelector2D to drive clip selection from a continuous parameter.

Call Brine2D.Animation.AnimatorComponent.Dispose when using this component outside the ECS (e.g. in tests). Inside the ECS it is disposed automatically via OnRemoved().

Properties
Animator The primary animator that drives sprite frame selection for this entity.
BlendSelector1D Optional 1D blend tree for the primary animator. Evaluated automatically each frame by AnimationSystem.
BlendSelector2D Optional 2D blend tree for the primary animator. When both BlendSelector1D and BlendSelector2D are set, BlendSelector1D takes precedence.
CurrentFrame Gets the current frame of the primary animator, or null if no animation is active. Equivalent to CurrentFrame on Animator.
CurrentHitBox Returns the HitBox of the primary animator's current frame, or null if no animation is playing or the current frame has no hitbox defined.
IsFinished true when the primary animator's current non-looping clip has finished. Equivalent to IsFinished on Animator.
IsPaused true when the primary animator has been explicitly paused. Equivalent to IsPaused on Animator.
IsPlaying true when the primary animator is currently playing (not paused, not finished). Equivalent to IsPlaying on Animator.
Layers Read-only ordered view of all additional animation layers, sorted by Priority ascending.
Parameters Shared parameter store for the primary StateMachine transition conditions.
StateMachine The state machine that evaluates transitions each frame for the primary animator.
Methods
AddLayer(string, int, ILogger<SpriteAnimator>) Adds an animation layer. Layers are kept sorted by Priority.
GetCurrentHitBox(string) Returns the named hit box from the primary animator's current frame, or null if no animation is playing or the named box is not defined on the current frame.
GetLayer(string) Returns the first layer with the given name, or null.
GetLayerHitBox(string) Returns the primary HitBox of the named layer's current frame, or null if the layer doesn't exist, no animation is playing, or no hitbox is defined.
GetLayerHitBox(string, string) Returns a named hit box from the named layer's current frame, or null.
HasLayer(string) Returns true if a layer with the given name has been added.
OnRemoved() Called when the component is removed from an entity.
PauseAllLayers() Pauses the primary Animator and every layer animator simultaneously. No-op for animators that are already paused or not playing.
RemoveLayer(string) Removes the first layer with the given name and disposes it.
ResumeAllLayers() Resumes the primary Animator and every layer animator simultaneously. No-op for animators that are not paused.
StopAllLayers() Stops the primary Animator and every layer animator simultaneously, clearing the active clip on each. No-op for animators that are already stopped.