Skip to content

Game.UtilityLane

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class

Base: ComponentBase

Summary:
UtilityLane is a prefab component used to define utility-type lanes (for example water pipes, stormwater, fences, catenary) in the game's net system. It exposes configuration fields for the utility type, visual/physical parameters (width, visual capacity, hanging offset, underground flag) and references to lane/ node prefabs used for local connections. The class contributes required component types to entity archetypes so the ECS systems can process utility lanes at runtime. It also reports prefab dependencies so referenced prefabs are included when loading.


Fields

  • public UtilityTypes m_UtilityType
    Specifies the kind of utility this lane represents (e.g. WaterPipe, StormwaterPipe, Fence, Catenary). The value is used by GetArchetypeComponents to determine which extra ECS components (EdgeMapping, SubFlow) are required for most utility types.

  • public NetLanePrefab m_LocalConnectionLane
    Reference to a NetLanePrefab used for local connections (first connection lane). If set, this prefab will be listed as a dependency by GetDependencies.

  • public NetLanePrefab m_LocalConnectionLane2
    Reference to a second NetLanePrefab used for local connections. Also added to dependencies if set.

  • public ObjectPrefab m_NodeObject
    Reference to a node object prefab associated with this utility lane (for example a valve or junction object). Added to dependencies if set.

  • public float m_Width
    Visual/physical width of the utility lane. Used by rendering/placement code to size the lane.

  • public float m_VisualCapacity
    A visual capacity parameter (used by lane visuals or capacity calculations). Exact use depends on systems that read this value.

  • public float m_Hanging
    If non-zero, indicates the lane is "hanging" (has a vertical offset). When non-zero, GetArchetypeComponents adds the HangingLane component type to the archetype.

  • public bool m_Underground
    Flag indicating whether the utility lane is placed underground. Systems that render or route utilities can use this to alter behavior/appearance.

Properties

  • None declared on this type.

Constructors

  • public UtilityLane()
    Implicit default constructor. No custom initialization is defined in the source.

Methods

  • public override void GetDependencies(List<PrefabBase> prefabs)
    Adds referenced prefabs (m_LocalConnectionLane, m_LocalConnectionLane2, m_NodeObject) to the provided prefabs list if they are not null. Ensures those prefabs are available when this prefab is loaded.

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Registers the prefab-level component types required by this prefab. Adds a read/write UtilityLaneData component type to the set. This ties the prefab to the data component used by systems at runtime.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Adds per-entity ECS component types to the archetype for this prefab:

  • Always adds Game.Net.UtilityLane and LaneColor (read/write).
  • For utility types other than StormwaterPipe, Fence, and Catenary, it also adds EdgeMapping and SubFlow (read/write). This is controlled by the expression: (m_UtilityType & ~(UtilityTypes.StormwaterPipe | UtilityTypes.Fence | UtilityTypes.Catenary)) != UtilityTypes.None
  • If m_Hanging != 0f, it also adds HangingLane (read/write).

This method controls which ECS components entities instantiated from this prefab will carry, allowing runtime systems to process flows, edge mappings, colors, and hanging behavior only when appropriate.

Usage Example

// Example of configuring a UtilityLane prefab in code (typical usage is via the editor inspector)
var utilLane = ScriptableObject.CreateInstance<Game.Prefabs.UtilityLane>();
utilLane.m_UtilityType = UtilityTypes.WaterPipe;
utilLane.m_Width = 1.2f;
utilLane.m_VisualCapacity = 50f;
utilLane.m_Hanging = 0.0f; // no hanging offset
utilLane.m_Underground = false;
utilLane.m_LocalConnectionLane = someNetLanePrefab;
utilLane.m_NodeObject = someNodeObjectPrefab;

// When the prefab system processes this prefab, GetDependencies will add the referenced prefabs,
// and GetArchetypeComponents will add the appropriate ECS components based on m_UtilityType and m_Hanging.