Skip to content

Game.Prefabs.NetPieceObjects

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class

Base: ComponentBase

Summary:
Component used on net (road/rail) prefabs to reference the set of piece objects that make up a net. Holds an array of NetPieceObjectInfo entries and integrates with the prefab system to declare those referenced objects as prefab dependencies and to register required ECS component types. The component is annotated with a ComponentMenu attribute so it appears under "Net/" in the editor inspector.


Fields

  • public NetPieceObjectInfo[] m_PieceObjects
    Holds the list/array of piece object descriptors for this net prefab. Each NetPieceObjectInfo typically contains a reference to a prefab (m_Object) and other metadata about how that piece should be used. GetDependencies iterates this array to add each referenced prefab to the dependency list.

Properties

  • public override bool ignoreUnlockDependencies { get; }
    This override returns true (expression-bodied property in source), indicating that this component should ignore unlock dependencies when the prefab dependency resolution or unlocking system runs. In practice it means the component's referenced objects are treated as always available for loading/registration regardless of unlock state.

Constructors

  • public NetPieceObjects()
    Default parameterless constructor. The class contains no explicit initialization beyond what the base ComponentBase provides; m_PieceObjects is expected to be set in the inspector or by prefab creation code.

Methods

  • public override void GetDependencies(System.Collections.Generic.List<PrefabBase> prefabs)
    Adds each referenced piece object's prefab to the provided prefabs list. Implementation:
  • Calls base.GetDependencies(prefabs).
  • Iterates m_PieceObjects and for each element adds element.m_Object to the prefabs list. This ensures that the piece object prefabs are included as dependencies of the net prefab and will be loaded/processed with it.

  • public override void GetPrefabComponents(System.Collections.Generic.HashSet<Unity.Entities.ComponentType> components)
    Registers ECS component types required by this prefab. Specifically adds ComponentType.ReadWrite() so the prefab archetype will include the NetPieceObject component for entities created from this prefab.

  • public override void GetArchetypeComponents(System.Collections.Generic.HashSet<Unity.Entities.ComponentType> components)
    Empty override in the source. No additional archetype-specific components are added here beyond those registered in GetPrefabComponents.

Usage Example

// Example: iterate referenced piece objects for a given NetPieceObjects component
var netPieceObjects = prefab.GetComponent<Game.Prefabs.NetPieceObjects>();
if (netPieceObjects != null && netPieceObjects.m_PieceObjects != null)
{
    foreach (var pieceInfo in netPieceObjects.m_PieceObjects)
    {
        // pieceInfo.m_Object is a PrefabBase reference that was registered via GetDependencies
        Debug.Log($"Piece object prefab: {pieceInfo.m_Object.name}");
    }
}

Additional notes: - The class is decorated with [ComponentMenu("Net/", new Type[] { typeof(NetPiecePrefab) })], so in the modding/editor UI this component will be found under the "Net/" category and is associated with NetPiecePrefab types. - This component is commonly used by net prefabs (roads, rails, etc.) to ensure all piece sub-prefabs (tunnel entrances, decorative pieces, transitions) are declared as dependencies and that created entities include the NetPieceObject ECS component.