Skip to content

Game.Prefabs.NetPieceLanes

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class

Base: ComponentBase

Summary:
Component used on network-piece prefabs to declare lane definitions for that piece. Each element in m_Lanes refers to a NetLaneInfo describing a lane (including a reference to a lane prefab). The prefab pipeline uses this component to collect referenced lane prefabs as dependencies and to add the runtime component (NetPieceLane) to the prefab's entity. The class is decorated with a ComponentMenu attribute so it appears under "Net/" in the editor with NetPiecePrefab as the target type.


Fields

  • public NetLaneInfo[] m_Lanes
    Array of lane descriptions for this network piece. Each NetLaneInfo typically holds a reference (m_Lane) to another Prefab (the lane prefab). This array may be null; GetDependencies checks for null before iterating.

Properties

  • public override bool ignoreUnlockDependencies { get; }
    Overrides the base property to return true. Indicates that this component does not require the prefab unlock dependency checks (it will be ignored by whatever unlock-dependency handling the base class or prefab pipeline provides).

Constructors

  • public NetPieceLanes()
    Default constructor (compiler-generated). No custom initialization is present in the source.

Methods

  • public override void GetDependencies(List<PrefabBase> prefabs)
    Adds referenced lane prefabs from m_Lanes to the provided prefabs list. Implementation:
  • Calls base.GetDependencies(prefabs).
  • If m_Lanes is non-null, iterates each NetLaneInfo and adds m_Lanes[i].m_Lane to the prefabs list. This is used by the prefab building pipeline to ensure lane prefabs are loaded/registered before the network piece prefab.

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Registers the ECS component type added to the prefab's entity at conversion time. Specifically, it adds ComponentType.ReadWrite() so that entities created from this prefab include a NetPieceLane component.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Empty implementation. No additional archetype-level components are registered here (component set is handled via GetPrefabComponents).

Notes: - The class is marked with [ComponentMenu("Net/", new Type[] { typeof(NetPiecePrefab) })], which controls how it appears in the Unity component menu for prefabs. - The dependency addition does a simple Add; callers should be aware duplicates may be added unless the caller deduplicates the list.

Usage Example

// Example: a prefab author script or inspector setup might assign lanes like this:
public class ExampleSetup
{
    public void Configure(NetPieceLanes lanesComponent, NetLaneInfo[] laneInfos)
    {
        lanesComponent.m_Lanes = laneInfos;
    }
}

// At prefab conversion time, the prefab pipeline will call:
var dependencies = new List<PrefabBase>();
netPieceLanes.GetDependencies(dependencies); // adds each m_Lane referenced by m_Lanes

// And the prefab pipeline will also register the runtime component:
var components = new HashSet<ComponentType>();
netPieceLanes.GetPrefabComponents(components); // adds ComponentType.ReadWrite<NetPieceLane>()