Game.Prefabs.NetSectionPrefab
Assembly:
Assembly-CSharp (game runtime assembly)
Namespace:
Game.Prefabs
Type:
class
Base:
PrefabBase
Summary:
Represents a network section prefab that groups sub-sections and pieces for a road/rail network asset. Provides logic to collect prefab dependencies (other PrefabBase instances referenced by the subsections and pieces) and to declare the ECS component types this prefab requires (NetSectionData, NetSubSection, NetSectionPiece). Intended for use by the game's prefab loading/registration system.
Fields
-
public NetSubSectionInfo[] m_SubSections
Array of NetSubSectionInfo entries that belong to this section. Each NetSubSectionInfo contains a reference to another PrefabBase (m_Section) which will be added to dependency lists when GetDependencies is called. May be null. -
public NetPieceInfo[] m_Pieces
Array of NetPieceInfo entries that belong to this section. Each NetPieceInfo contains a reference to another PrefabBase (m_Piece) which will be added to dependency lists when GetDependencies is called. May be null.
Properties
- This class does not declare any public properties. All relevant data is exposed via fields and overridden methods inherited from PrefabBase.
Constructors
public NetSectionPrefab()
Implicit default constructor. No special initialization is performed in the compiled source; initialization of arrays/fields occurs via Unity/serialization or external creators.
Methods
public override void GetDependencies(List<PrefabBase> prefabs)
Collects referenced prefab dependencies into the provided list. Implementation details:- Calls base.GetDependencies(prefabs) first.
- If m_SubSections is non-null, iterates through each element and adds each element's m_Section (a PrefabBase) to the prefabs list.
- If m_Pieces is non-null, iterates through each element and adds each element's m_Piece (a PrefabBase) to the prefabs list.
-
Notes: The method assumes that entries in m_SubSections and m_Pieces may be null-checked externally; the implementation in source does not guard against null elements inside the arrays (only against the arrays themselves). The order of additions follows array order.
-
public override void GetPrefabComponents(HashSet<ComponentType> components)
Registers the ECS component types required by this prefab into the provided HashSet: - Calls base.GetPrefabComponents(components) first.
- Adds ComponentType.ReadWrite
(). - Adds ComponentType.ReadWrite
(). - Adds ComponentType.ReadWrite
(). - Purpose: informs the prefab/entity creation pipeline which ECS component archetypes to include when instantiating entities for this prefab.
Usage Example
// Example: collecting dependencies from an existing NetSectionPrefab instance
NetSectionPrefab sectionPrefab = /* obtained from prefab manager / serialized data */;
List<PrefabBase> deps = new List<PrefabBase>();
sectionPrefab.GetDependencies(deps);
// 'deps' now contains referenced section and piece prefabs (order preserved).
// Example: getting required ECS components for registration
HashSet<ComponentType> components = new HashSet<ComponentType>();
sectionPrefab.GetPrefabComponents(components);
// components now contains NetSectionData, NetSubSection, NetSectionPiece (ReadWrite).
{{ Additional notes: - This prefab is intended to be created/serialized by the game's asset pipeline; modders typically modify or extend NetSubSectionInfo / NetPieceInfo references in the prefab asset rather than instantiate this class manually at runtime. - ComponentType.ReadWrite usage signals the prefab system that entities created from this prefab need read/write access to those components. - If you extend or subclass PrefabBase behavior, be sure to call base implementations of GetDependencies and GetPrefabComponents to preserve existing behavior. }}