Skip to content

Game.Prefabs.ElectricityConnection

Assembly: Assembly-CSharp.dll
Namespace: Game.Prefabs

Type: class

Base: ComponentBase

Summary:
ElectricityConnection is a prefab component used by net prefabs to describe how electricity flows through a net piece. It encodes the connection's voltage level, allowed flow direction, capacity (throughput) and sets of requirements that control which other net pieces can or cannot connect. This component influences the conversion of the prefab into ECS entities by declaring the corresponding ElectricityConnectionData component on the generated entity.


Fields

  • public enum Voltage : byte { Low = 0, High = 1, Invalid = byte.MaxValue }
    Defines the supported voltage categories for the connection. Low and High are valid classification values; Invalid can be used to mark an uninitialized or non-applicable voltage.

  • public Voltage m_Voltage
    Specifies the voltage level for this connection. Default (when unset) is the enum's default value (Low / 0). The voltage is used by the electrical simulation to determine compatibility and behavior between connected net pieces.

  • public FlowDirection m_Direction = FlowDirection.Both
    Controls permitted flow direction for this connection (for example Both, In, Out — defined by the FlowDirection enum in the codebase). Defaults to Both. The direction restricts how electricity can be transferred across this connection.

  • public int m_Capacity
    An integer representing the capacity or throughput limit for this connection. The capacity is used by the simulation to cap the amount of electricity that can flow through the net piece.

  • public NetPieceRequirements[] m_RequireAll
    An array of requirements where every entry must be satisfied for this connection to be considered valid. Used to express mandatory compatibility constraints with neighboring net pieces.

  • public NetPieceRequirements[] m_RequireAny
    An array of requirements where at least one entry must be satisfied for the connection to be valid. Useful for expressing alternative acceptable neighbor types or properties.

  • public NetPieceRequirements[] m_RequireNone
    An array of requirements that must not be present on adjacent net pieces for the connection to be valid. Useful to prevent connections to specific piece types or configurations.

Properties

  • No public properties are declared directly on this class. The class does override component lifecycle methods (below) that influence prefab -> ECS conversion. ComponentBase (the base class) may expose additional properties inherited by this class.

Constructors

  • public ElectricityConnection()
    Default parameterless constructor (compiler-provided if not declared explicitly). Field defaults:
  • m_Direction initialized to FlowDirection.Both (as declared).
  • m_Voltage defaults to Voltage.Low (enum default 0) unless set in the inspector or by code.
  • m_Capacity defaults to 0.
  • m_RequireAll / m_RequireAny / m_RequireNone default to null until assigned.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds the ECS component type that represents this prefab component to the prefab's component set. Implementation in the source calls: components.Add(ComponentType.ReadWrite()); This ensures that when the prefab is converted to an entity, an ElectricityConnectionData component (ECS struct) is included on the entity so the runtime systems can use the connection data in simulation.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Empty override in this class. The method is provided to allow adding additional component types to an archetype, but here it does nothing — meaning no extra archetype-level components are declared beyond the prefab components.

Usage Example

// Example: Configure an ElectricityConnection on a NetPrefab (editor or runtime script)
var electricity = prefab.GetComponent<ElectricityConnection>();
if (electricity != null)
{
    electricity.m_Voltage = ElectricityConnection.Voltage.High;
    electricity.m_Direction = FlowDirection.Both;
    electricity.m_Capacity = 200; // set throughput limit
    electricity.m_RequireAny = new[] { new NetPieceRequirements(/* ... */) };
    // When the prefab is converted to an ECS entity, ElectricityConnectionData will be added
}