Game.Notifications.Animation
Assembly: Assembly-CSharp (likely)
Namespace: Game.Notifications
Type: struct
Base: IComponentData, IQueryTypeParameter, ISerializable
Summary: Component that represents the state of a notification animation in the ECS world. It stores a timer and total duration for the animation and an AnimationType enum value that indicates which animation phase/type is active. Implements ISerializable to allow the component to be written to and read from the game's serialization system (used for save/load and entity serialization).
Fields
-
public float m_Timer
Current time (progress) for the animation. Typically advances from 0 to m_Duration. -
public float m_Duration
Total duration (in seconds) of the animation. Used to compute progress or completion. -
public AnimationType m_Type
The type/phase of the animation (enum). Serialized as a single byte.
Properties
- (none)
Constructors
public Animation(AnimationType type, float timer, float duration)
Creates a new Animation with the provided type, initial timer value and duration. Parameters:- type: AnimationType value describing the animation phase.
- timer: initial timer/progress (usually 0 for just-started animations).
- duration: total length of the animation in seconds.
Methods
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the component fields to the provided writer in the following order:- m_Timer (float)
- m_Duration (float)
- m_Type (written as a byte)
This deterministic ordering must be matched by Deserialize.
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads component data from the provided reader in the same order as Serialize. Reads timer and duration as floats and reads a byte which is cast back into AnimationType.
Usage Example
// Create an animation component and add it to an entity via an EntityManager
var anim = new Game.Notifications.Animation(AnimationType.FadeIn, 0f, 2.0f);
entityManager.AddComponentData(notificationEntity, anim);
// Example system update (pseudo)
public void UpdateAnimation(ref Game.Notifications.Animation anim, float deltaTime)
{
anim.m_Timer += deltaTime;
if (anim.m_Timer >= anim.m_Duration)
{
// transition or mark complete
anim.m_Timer = anim.m_Duration;
}
}