Game.Effects.EnabledEffect
Assembly:
Game (inferred from [FormerlySerializedAs] attribute)
Namespace:
Game.Effects
Type:
public struct EnabledEffect
Base:
Implements Unity.Entities.IBufferElementData, Colossal.Serialization.Entities.IEmptySerializable
Summary:
Represents a single entry in a dynamic buffer that associates an effect identifier with an enabled-instance index. This struct is intended to be used as a buffer element (DynamicBuffer
Fields
-
public int m_EffectIndex
Index identifying which effect this entry refers to. Typically used as a key or index into a centralized effect table/registry. -
public int m_EnabledIndex
Index used to identify the enabled instance (for example, an index into the owner's enabled-effects array or slot). Combined with m_EffectIndex it distinguishes which particular enabled occurrence is represented.
Properties
- This type has no properties. It is a simple POD-style buffer element (public fields only).
Constructors
public EnabledEffect()
As a value type (struct) there is an implicit default constructor that initializes both integer fields to 0. No explicit constructors are defined in source.
Methods
- This type exposes no methods. It is a plain data container used with Unity.Entities dynamic buffers and the Colossal serialization system.
Usage Example
// Add and use EnabledEffect as a DynamicBuffer on an entity (ECS context)
using Unity.Entities;
using Game.Effects;
public void AddEnabledEffect(EntityManager em, Entity entity, int effectIndex, int enabledIndex)
{
// Ensure the entity has a dynamic buffer of EnabledEffect (e.g., defined on a archetype or added at runtime)
var buffer = em.GetBuffer<EnabledEffect>(entity);
buffer.Add(new EnabledEffect {
m_EffectIndex = effectIndex,
m_EnabledIndex = enabledIndex
});
}
// Reading back entries:
public void ProcessEnabledEffects(EntityManager em, Entity entity)
{
if (!em.HasBuffer<EnabledEffect>(entity))
return;
var buffer = em.GetBuffer<EnabledEffect>(entity);
for (int i = 0; i < buffer.Length; i++)
{
var entry = buffer[i];
// Use entry.m_EffectIndex and entry.m_EnabledIndex
}
}
Notes:
- The [InternalBufferCapacity(2)] attribute reserves inline space for two entries before the buffer spills to heap allocation — useful for common small counts to reduce allocations.
- The [FormerlySerializedAs("Game.Effects.EffectOwner, Game")] attribute indicates a previous serialization name, enabling backward compatibility with saved data that used the old name.
- Because this implements IBufferElementData, it is intended for use with Unity's Entity component system (DynamicBuffer