Game.Rendering.Animated
Assembly: Assembly-CSharp
Namespace: Game.Rendering
Type: struct
Base: System.ValueType, Unity.Entities.IBufferElementData, Colossal.Serialization.Entities.IEmptySerializable
Summary:
Represents per-entity animation data used by the rendering/animation subsystem. This buffer element holds references to bone allocations, clip indices (body/face), timing and interpolation values, and movement speed information. It's intended to be stored in an ECS dynamic buffer (InternalBufferCapacity(1)) so each entity can have one Animated element for animation state and playback control.
Fields
-
public Colossal.Collections.NativeHeapBlock m_BoneAllocation
Reference/handle to the native heap allocation that stores bone data for the animated entity (bone transforms, matrices or related GPU/CPU buffers). Managed by the animation system; should be allocated and freed by the owning system. -
public int m_MetaIndex
Index into animation metadata or a table identifying which animation set/metadata applies to this entity. -
public Unity.Mathematics.float4 m_Time
Stores timing values used by the animation system. Typically contains current time(s) for animation channels (for example, different components/channels or blending state). -
public Unity.Mathematics.float2 m_MovementSpeed
Movement speed vector (usually X/Z or forward/side components) used for animation blending (e.g., locomotion blend trees). -
public float m_Interpolation
Interpolation/blend factor used when blending between animation states or frames. -
public float m_PreviousTime
Previous frame time value used to compute deltas or drive interpolation. -
public short m_ClipIndexBody0
Index of the primary body animation clip. -
public short m_ClipIndexBody0I
Index used for interpolation/blending partner (or previous) for body clip 0. -
public short m_ClipIndexBody1
Index of the secondary body animation clip (for blending/mixing). -
public short m_ClipIndexBody1I
Index used for interpolation/blending partner (or previous) for body clip 1. -
public short m_ClipIndexFace0
Index of the face animation clip (facial expressions or lip-sync). -
public short m_ClipIndexFace1
Index of an alternate face animation clip.
Properties
- None — this type exposes public fields and does not define properties.
Constructors
public Animated()
No explicit constructors are defined in the source. Use the default value-type constructor or object/collection initializers. When creating an instance, ensure native allocations (m_BoneAllocation) are handled properly by the owning system.
Methods
- None defined on this type.
Implements Unity.Entities.IBufferElementData to be used as an element in an ECS DynamicBuffer and Colossal.Serialization.Entities.IEmptySerializable as a marker for serialization support.
Usage Example
using Unity.Entities;
using Unity.Mathematics;
using Colossal.Collections;
using Game.Rendering;
// Example: add and initialize the Animated buffer element for an entity
var em = World.DefaultGameObjectInjectionWorld.EntityManager;
var entity = em.CreateEntity();
// Ensure the buffer type is present on the entity (InternalBufferCapacity(1) allows a single element)
var buffer = em.AddBuffer<Animated>(entity);
// Create and initialize an Animated element.
// Note: m_BoneAllocation must be created/assigned using whatever native allocation API your mod/system uses.
var anim = new Animated
{
m_BoneAllocation = new NativeHeapBlock(), // placeholder — allocate properly in your system
m_MetaIndex = 0,
m_Time = new float4(0f, 0f, 0f, 0f),
m_MovementSpeed = new float2(0f, 0f),
m_Interpolation = 0f,
m_PreviousTime = 0f,
m_ClipIndexBody0 = -1,
m_ClipIndexBody0I = -1,
m_ClipIndexBody1 = -1,
m_ClipIndexBody1I = -1,
m_ClipIndexFace0 = -1,
m_ClipIndexFace1 = -1
};
buffer.Add(anim);
Notes and tips:
- Be careful with native resources (m_BoneAllocation). Allocate and free with the appropriate APIs to avoid leaks or crashes.
- Clip index values appear to be small integers (short). Use negative values (e.g., -1) to indicate "none" if the animation system treats them that way.
- The struct is intended for use inside an ECS DynamicBuffer; systems querying animation state should GetBuffer