Game.Prefabs.DistrictModifierData
Assembly:
Namespace: Game.Prefabs
Type: struct
Base: System.ValueType, Unity.Entities.IBufferElementData
Summary:
A lightweight ECS buffer element that describes a district modifier for prefabs. It stores the modifier type, how the modifier value is applied (mode), and the numeric range for that modifier. The struct is marked with [InternalBufferCapacity(0)], meaning no internal inline buffer storage is reserved on the entity; the buffer will be a separate dynamic buffer. This type is intended to be used as elements in a DynamicBuffer
Fields
-
public DistrictModifierType m_Type
Type of district modifier (enum/identifier). Indicates which modifier this entry represents (for example tax, crime, etc.). Defined elsewhere (likely in Game.Areas or a related enum). -
public ModifierValueMode m_Mode
How the modifier's value should be interpreted/applied (for example Add, Multiply, Override). The exact modes are defined by the ModifierValueMode type. -
public Bounds1 m_Range
Numeric range for the modifier's value (min/max). Uses Bounds1 from Colossal.Mathematics to express the allowed or target value range for this modifier.
Properties
- This struct defines no properties. It only exposes public fields and implements IBufferElementData.
Constructors
public DistrictModifierData(DistrictModifierType type, ModifierValueMode mode, Bounds1 range)
Initializes a new DistrictModifierData with the specified modifier type, value mode, and value range.
Methods
- This struct defines no methods.
Usage Example
using Colossal.Mathematics;
using Game.Prefabs;
using Unity.Entities;
using Game.Areas; // where DistrictModifierType / ModifierValueMode are defined
// Example: add a district modifier element to an entity's dynamic buffer
EntityManager em = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity prefabEntity = /* obtain or create entity for prefab */;
var buffer = em.AddBuffer<DistrictModifierData>(prefabEntity);
// Create a modifier element
var modifier = new DistrictModifierData(
DistrictModifierType.SomeModifier, // replace with actual enum member
ModifierValueMode.Add, // example mode
new Bounds1(0.0f, 10.0f) // example range (min 0, max 10)
);
// Add to the dynamic buffer
buffer.Add(modifier);
Notes: - Because this type implements IBufferElementData, it is suitable for attaching as a dynamic buffer to entities and iterating in ECS systems. - The [InternalBufferCapacity(0)] attribute indicates the buffer has no inline capacity; all elements are stored in separate buffer memory. Adjustments to buffer allocation should be considered if many modifiers are expected.