Game.Simulation.WaterPipeBuildingConnection
Assembly:
Assembly-CSharp
Namespace:
Game.Simulation
Type:
struct
Base:
IComponentData, IQueryTypeParameter, ISerializable
Summary:
Represents a link between a building and the water-pipe network by storing the pipe edges that connect a producer (supply) and a consumer (demand) for that building. This struct is an ECS component (value type) intended to be attached to entities representing building connections. It provides convenience methods to obtain the corresponding pipe nodes from a ComponentLookup
Fields
-
public Entity m_ProducerEdge
Reference to the water-pipe edge entity that acts as the producer/supply side of the connection. May be Entity.Null if no producer is assigned. Used by GetProducerNode to lookup the producer node via the WaterPipeEdge component. -
public Entity m_ConsumerEdge
Reference to the water-pipe edge entity that acts as the consumer/demand side of the connection. May be Entity.Null if no consumer is assigned. Used by GetConsumerNode to lookup the consumer node via the WaterPipeEdge component.
Properties
- This type does not declare any managed properties. It exposes its data via public fields and methods.
Constructors
public WaterPipeBuildingConnection()
Implicit default constructor provided by the C# compiler (value-type default). Initializes both entity fields to Entity.Null by default. No explicit constructor logic is defined in source.
Methods
-
public Entity GetProducerNode(ref ComponentLookup<WaterPipeEdge> flowEdges)
Returns the producer node entity for this connection by looking up the WaterPipeEdge component from m_ProducerEdge and returning its m_End field. Assumes the referenced edge entity has a valid WaterPipeEdge component; callers should ensure the edge exists (or handle Entity.Null). -
public Entity GetConsumerNode(ref ComponentLookup<WaterPipeEdge> flowEdges)
Returns the consumer node entity for this connection by looking up the WaterPipeEdge component from m_ConsumerEdge and returning its m_Start field. Assumes the referenced edge entity has a valid WaterPipeEdge component; callers should validate the edge entity before use. -
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the two edge Entity references (producer and consumer) into the provided writer. Uses writer.Write(Entity) for each field. This is the implementation used during saving/serialization to persist entity references. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads the two edge Entity references from the provided reader into the struct's fields. Uses reader.Read(out Entity) for each field. This is the implementation used during loading/deserialization to restore entity references.
Usage Example
// Example usage inside a system or utility method
public void ExampleUsage(ref ComponentLookup<WaterPipeEdge> flowEdges)
{
// Create a connection (fields default to Entity.Null)
var connection = new WaterPipeBuildingConnection
{
m_ProducerEdge = producerEdgeEntity, // obtained elsewhere
m_ConsumerEdge = consumerEdgeEntity // obtained elsewhere
};
// Get corresponding pipe nodes (check for nulls/valid components in production code)
Entity producerNode = connection.GetProducerNode(ref flowEdges);
Entity consumerNode = connection.GetConsumerNode(ref flowEdges);
// Serialization example (writer is provided by save system)
// writer.Write will write the Entity references so they can be restored later
connection.Serialize(writer);
// Deserialization example (reader provided by load system)
// var connection = new WaterPipeBuildingConnection();
// connection.Deserialize(reader);
}