Skip to content

Game.Prefabs.NetSubObjects

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class

Base: ComponentBase

Summary:
Component used on net (road/rail) prefabs to declare and manage visual/functional sub-objects that belong to a net segment or node. Holds an array of NetSubObjectInfo entries referencing other PrefabBase objects, exposes that dependency information to the prefab system, and declares the ECS component type required for these sub-objects (SubObject). This component also bypasses unlock-dependency checks by always returning true for ignoreUnlockDependencies.


Fields

  • public NetSubObjectInfo[] m_SubObjects
    Array of sub-object descriptors. Each NetSubObjectInfo typically references a prefab (PrefabBase) that should be treated as a child/sub-object of the net prefab. These referenced prefabs are collected as dependencies by GetDependencies.

Properties

  • public override bool ignoreUnlockDependencies { get; }
    Always returns true. This override indicates that unlock dependencies (e.g., content unlock requirements) should be ignored for this component when resolving prefab dependencies.

Constructors

  • public NetSubObjects()
    No custom constructor is defined in the source — the default parameterless constructor is used by Unity/serialization.

Methods

  • public override void GetDependencies(List<PrefabBase> prefabs)
    Adds referenced sub-object prefabs to the provided list. Implementation details:
  • Calls base.GetDependencies(prefabs) first.
  • Iterates over m_SubObjects and adds each m_Object (the referenced PrefabBase) to the prefabs list.
  • Ensures that all sub-object prefabs will be considered when resolving prefab load order and dependency graphs.

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Registers the ECS component types required by prefabs that include this component. Specifically, adds ComponentType.ReadWrite() to the provided set so that the prefab system knows instances of this prefab need SubObject component storage.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Empty implementation in this class. No additional archetype components are declared here beyond what GetPrefabComponents already registers.

Usage Example

// Collect dependencies referenced by a NetSubObjects component
var netSubObjects = /* reference to NetSubObjects instance */;
var deps = new List<PrefabBase>();
netSubObjects.GetDependencies(deps);
// 'deps' now contains all PrefabBase entries referenced by m_SubObjects

// Note: The prefab system will call GetPrefabComponents during prefab setup,
// so SubObject component storage will be reserved for prefabs using NetSubObjects.