Game.Prefabs.RouteModifierData
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: struct
Base: IBufferElementData
Summary:
RouteModifierData is a small ECS buffer element used to describe a single modifier applied to routes (road/track segments) on a prefab. Each element encodes the modifier type, how the modifier value is interpreted, and the 1D range along the route where the modifier applies. The struct is marked with InternalBufferCapacity(0), meaning no elements are stored inline on the entity; the buffer is fully dynamic.
Fields
-
public RouteModifierType m_Type
Stores which kind of route modifier this element represents (e.g., speed change, lane change, routing preference). This is an enum (RouteModifierType) used by the route system to identify the modifier behavior. -
public ModifierValueMode m_Mode
Specifies how the modifier value should be interpreted/applied (for example, additive vs. absolute). This is an enum (ModifierValueMode) used when evaluating the modifier effect. -
public Bounds1 m_Range
A 1D bounds structure that defines the range along the route (typically a start and end position along a segment or prefab) where this modifier is active. Bounds1 represents a numeric interval; consult its API for constructors and semantics.
Properties
- This struct does not define any properties.
Constructors
public RouteModifierData(RouteModifierType type, ModifierValueMode mode, Bounds1 range)
Initializes a RouteModifierData element with the provided modifier type, mode, and range.
Methods
- This struct does not define any methods.
Usage Example
// Example: attaching route modifier entries to a prefab entity's dynamic buffer
using Unity.Entities;
using Game.Prefabs;
using Game.Routes;
using Colossal.Mathematics; // for Bounds1
// Acquire EntityManager (context-dependent; shown for typical ECS usage)
var em = World.DefaultGameObjectInjectionWorld.EntityManager;
// Assume 'prefabEntity' is an existing entity representing a route-prefab
Entity prefabEntity = /* obtain prefab entity */;
// Add a dynamic buffer for RouteModifierData
var buffer = em.AddBuffer<RouteModifierData>(prefabEntity);
// Create a modifier: (example enum values; replace with actual enum members)
// - RouteModifierType.Speed (example): modify speed along the route
// - ModifierValueMode.Add (example): apply as additive value
// - Bounds1(10f, 50f): apply from 10 to 50 units along the route
buffer.Add(new RouteModifierData(
RouteModifierType.Speed,
ModifierValueMode.Add,
new Bounds1(10f, 50f)
));
Notes:
- Because this type implements IBufferElementData, multiple modifiers can be attached to a single entity via its DynamicBuffer