Game.Prefabs.SubNet
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: struct
Base: Unity.Entities.IBufferElementData
Summary:
SubNet is an ECS buffer element (IBufferElementData) used to represent a single sub-segment / sub-entity entry of a network prefab in Cities: Skylines 2. It carries the prefab Entity reference plus geometry and configuration data required to instantiate or simulate a piece of a network (Bezier curve, node indices, mesh parent info, inversion mode, upgrade flags and snapping state). The type is annotated with [InternalBufferCapacity(0)] which configures the entity's internal inline buffer capacity (0 = no inline storage; elements are allocated externally). Common usage is attaching a dynamic buffer
Fields
-
public Entity m_Prefab
Reference to the prefab Entity for this sub-net piece. Typically used when instantiating or mapping to the original prefab/entity asset. -
public Bezier4x3 m_Curve
Bezier curve data (from Colossal.Mathematics) describing the geometry of this sub-segment. Holds control points/handles for smooth network geometry. -
public int2 m_NodeIndex
Two-component integer vector (Unity.Mathematics.int2) used to store node/index information associated with the sub-net. Typically encodes indices relevant to nodes or segment endpoints (start/end or local indices). -
public int2 m_ParentMesh
Two-component integer vector used to identify the parent mesh or sub-mesh this sub-net belongs to (for example mesh id and submesh index or other mesh grouping identifiers). -
public NetInvertMode m_InvertMode
Enum value indicating any inversion/flip mode that should be applied to this sub-net (affects orientation or mirrored placement). -
public CompositionFlags m_Upgrades
Flag enum describing applied upgrades or composition modifiers for this sub-net piece (e.g., level/upgrade bits). -
public bool2 m_Snapping
Two-component boolean vector indicating snapping state(s) for this sub-net. Often used to mark start/end snapping availability or whether endpoints are pinned/snapped.
Properties
- This type defines no C# properties. It's a plain data-only struct exposing public fields for use as a buffer element.
Constructors
public SubNet()
Implicit parameterless struct constructor (provided by C#). All fields are initialized to their default values (Entity = Entity.Null, numeric vectors = zero, enums = default, bool2 = false,false). No explicit constructor is declared in the source.
Methods
- This struct declares no methods. It is a plain data container intended for use inside DynamicBuffer
.
Usage Example
// Add a dynamic buffer to an entity and append a SubNet element
EntityManager em = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity myEntity = em.CreateEntity();
// Add buffer (requires Unity.Entities using)
var buffer = em.AddBuffer<Game.Prefabs.SubNet>(myEntity);
// Create and populate a SubNet entry
var entry = new Game.Prefabs.SubNet
{
m_Prefab = somePrefabEntity,
m_Curve = new Bezier4x3(...), // set control points appropriately
m_NodeIndex = new int2(0, 1),
m_ParentMesh = new int2(meshId, subMeshIndex),
m_InvertMode = NetInvertMode.None,
m_Upgrades = CompositionFlags.None,
m_Snapping = new bool2(false, false)
};
buffer.Add(entry);
// In a system, iterate buffers:
Entities
.WithAll<SomeTag>()
.ForEach((Entity e, DynamicBuffer<Game.Prefabs.SubNet> subs) =>
{
for (int i = 0; i < subs.Length; i++)
{
var s = subs[i];
// use s.m_Prefab, s.m_Curve, etc.
}
}).Schedule();
Additional notes:
- Because this is an IBufferElementData type, prefer using DynamicBuffer