Game.Net.Composition
Assembly: Assembly-CSharp (game runtime/user mod assembly)
Namespace: Game.Net
Type: public struct
Base: Implements: Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter, Colossal.Serialization.Entities.IEmptySerializable
Summary: Composition is a small ECS component used to describe a network "composition" relationship in the game's entity-component system. It holds references to an edge entity and the two node entities (start and end) that define that edge. It is a plain data component intended for queries and serialization (marker IEmptySerializable), and is typically used by systems that manage network topology (roads, connections, nodes) or need to traverse/update net segments and their endpoints.
Fields
-
public Unity.Entities.Entity m_Edge
Represents the edge entity (e.g., a road/segment) that this composition entry refers to. This is the central segment entity connecting the two nodes. -
public Unity.Entities.Entity m_StartNode
The entity that represents the starting node/junction of the edge. -
public Unity.Entities.Entity m_EndNode
The entity that represents the ending node/junction of the edge.
Properties
- None
This struct exposes only public fields. It is intended to be used as a plain data container compatible with the Unity.Entities API.
Constructors
- Default parameterless constructor (implicit)
The compiler-provided default constructor initializes the Entity fields to their default (invalid) values. You can initialize instances with an object initializer when creating or adding the component.
Methods
- None (marker interfaces only)
The implemented interfaces (IComponentData, IQueryTypeParameter, IEmptySerializable) do not add instance methods to this struct; they mark it for ECS usage and for the custom serialization infrastructure.
Usage Example
// Example: creating an entity and adding a Composition component to it
using Unity.Entities;
public void AssignComposition(EntityManager entityManager, Entity edgeEntity, Entity startNode, Entity endNode)
{
// Create a new entity that will hold composition data (or add to an existing entity)
Entity compEntity = entityManager.CreateEntity();
var composition = new Game.Net.Composition
{
m_Edge = edgeEntity,
m_StartNode = startNode,
m_EndNode = endNode
};
// Add the component to the entity
entityManager.AddComponentData(compEntity, composition);
}
// Querying entities that have Composition components (example in a SystemBase)
protected override void OnUpdate()
{
Entities.ForEach((ref Game.Net.Composition comp) =>
{
// Access comp.m_Edge, comp.m_StartNode, comp.m_EndNode here
}).ScheduleParallel();
}
{{ This component is commonly used by systems that need to inspect or modify network segments and their endpoints. Because it is an IEmptySerializable, it participates in the game's custom serialization logic for saving/loading composition-related data. }}