Skip to content

Game.Simulation.ElectricityNodeConnection

Assembly:
Game (Assembly containing game simulation types; in many builds this may be Assembly-CSharp)
Namespace: Game.Simulation

Type:
struct

Base:
IComponentData, IQueryTypeParameter, ISerializable

Summary:
Represents a component that links an entity to an electricity node within the ECS simulation. This struct holds a single Unity.Entities.Entity reference (the electricity node) and implements ISerializable so it can be written/read by the game's serialization system. It is intended to be used as component data on entities that need to know which electricity node they are connected to (for example, power consumers, producers, or network segments).


Fields

  • public Unity.Entities.Entity m_ElectricityNode
    Holds the Entity id of the connected electricity node. This is a public field and represents the connection target in the ECS world. Use this to identify or query the node entity associated with the owner entity.

Properties

  • None. This struct exposes data via a public field rather than properties.

Constructors

  • Implicit default constructor (value-type default)
    There is no user-defined constructor; the default parameterless constructor provided by the C# compiler initializes m_ElectricityNode to Entity.Null.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Serializes the m_ElectricityNode field by writing the Entity to the provided writer. This allows the component to be saved by the game's serialization pipeline.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Deserializes the m_ElectricityNode field by reading an Entity from the provided reader. This restores the connection when loading or synchronizing state.

Usage Example

// Creating and assigning the component to an entity
var connection = new ElectricityNodeConnection
{
    m_ElectricityNode = nodeEntity // nodeEntity is a Unity.Entities.Entity representing the electricity node
};
entityManager.AddComponentData(someEntity, connection);

// Example of how the component's serialize/deserialize methods are implemented (internal to the type)
[/* serialization framework calls */]
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
{
    writer.Write(m_ElectricityNode);
}

public void Deserialize<TReader>(TReader reader) where TReader : IReader
{
    reader.Read(out m_ElectricityNode);
}