Game.Rendering.Emissive
Assembly: Assembly-CSharp.dll
Namespace: Game.Rendering
Type: struct Emissive
Base: System.ValueType, Colossal.Serialization.Entities.IEmptySerializable, Unity.Entities.IBufferElementData
Summary:
A Unity ECS dynamic buffer element used by the rendering system to hold per-entity emissive-related data. The struct stores a native heap allocation handle (for variable-size emissive data), an integer offset used by the lighting/emissive subsystem, and a flag indicating whether the emissive data was updated and needs processing. The type is marked with [InternalBufferCapacity(1)] to suggest a small inline capacity for the dynamic buffer.
Fields
-
public Colossal.Collections.NativeHeapBlock m_BufferAllocation
Handles the underlying unmanaged/native memory block where emissive payload (vertex/texture/light data) is stored. Mod authors should be careful about allocation and deallocation lifetimes and ensure the native memory is managed consistently with the engine's expectations. -
public System.Int32 m_LightOffset
An integer offset / index used by the rendering/lighting system to locate the corresponding light or emissive entry within a larger array or packed buffer. -
public System.Boolean m_Updated
A flag indicating whether the emissive data has been modified since last processing. The rendering pipeline or a job can check this flag to decide whether to re-upload or reprocess the emissive data.
Properties
- None (no properties are declared on this struct)
Constructors
public Emissive()
Default value-type constructor (provided implicitly for structs). Fields will be zero-initialized (m_BufferAllocation default, m_LightOffset = 0, m_Updated = false). Custom allocation/initialization should be performed after creation, especially for m_BufferAllocation.
Methods
- None (no methods are declared on this struct)
Remarks / Notes for Modders
- The struct implements IBufferElementData and is intended to be used as elements of a DynamicBuffer
attached to entities. - The [InternalBufferCapacity(1)] attribute suggests that the dynamic buffer should reserve a small inline capacity (1 element) before moving to heap-backed storage — useful to reduce allocations for the common small-case.
- NativeHeapBlock manages unmanaged memory; ensure you follow the same allocation/free patterns used by the game to avoid leaks or crashes. Avoid manipulating NativeHeapBlock from the main thread or jobs in unsupported ways — prefer using provided APIs or engine wrappers.
- The m_Updated flag is typically used to gate expensive updates (GPU uploads, job scheduling). Clear or set it appropriately when you make changes to the native buffer.
Usage Example
// Add a DynamicBuffer<Emissive> to an entity and initialize an element.
using Unity.Entities;
using Colossal.Collections;
using Game.Rendering;
EntityManager em = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity e = em.CreateEntity();
// Ensure the entity has a DynamicBuffer<Emissive>
var buffer = em.AddBuffer<Emissive>(e);
// Add and initialize an Emissive element
var emissiveElement = new Emissive
{
m_BufferAllocation = default(NativeHeapBlock), // allocate/populate as required by the game APIs
m_LightOffset = 0,
m_Updated = true
};
buffer.Add(emissiveElement);
// Later, when you have a valid native allocation you might replace or update the element:
var elem = buffer[0];
elem.m_LightOffset = calculatedOffset;
elem.m_Updated = true;
buffer[0] = elem;