Game.WaterPipeNodeConnection
Assembly:
Namespace: Game.Simulation
Type: struct
Base: IComponentData, IQueryTypeParameter, ISerializable
Summary:
A lightweight ECS component that holds a reference to a water pipe node Entity. Used to associate an entity (e.g., a pipe segment or connection) with its corresponding water node within the simulation. Implements ISerializable to support reading/writing the Entity reference during save/load or network serialization.
Fields
public Unity.Entities.Entity m_WaterPipeNode
Stores the Entity reference pointing to the water pipe node. This is the primary data carried by this component and is used by systems that need to resolve or traverse water network nodes.
Properties
- This type has no properties.
All data is exposed via the single public field; accessors are not provided.
Constructors
public WaterPipeNodeConnection()
Structs in C# have an implicit parameterless constructor that initializes the Entity field to Entity.Null. You can also initialize using an object initializer: var conn = new WaterPipeNodeConnection { m_WaterPipeNode = myNodeEntity };
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the m_WaterPipeNode Entity to the provided writer. Used during saving/streaming the component state. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads an Entity from the provided reader and assigns it to m_WaterPipeNode. Used when loading/restoring the component state.
Usage Example
// Create or obtain Entities via the ECS world / EntityManager
Entity pipeEntity = entityManager.CreateEntity(typeof(WaterPipeNodeConnection));
Entity waterNodeEntity = /* existing node Entity */;
// Assign the node reference to the pipe entity
var connection = new WaterPipeNodeConnection { m_WaterPipeNode = waterNodeEntity };
entityManager.SetComponentData(pipeEntity, connection);
// Example of serialization usage (conceptual — actual writer setup depends on framework)
void SaveComponent(WaterPipeNodeConnection comp, IWriter writer)
{
comp.Serialize(writer);
}
void LoadComponent(out WaterPipeNodeConnection comp, IReader reader)
{
comp = new WaterPipeNodeConnection();
comp.Deserialize(reader);
}