Game.Prefabs.NetGeometryPrefab
Assembly: Game (assembly name not specified in source)
Namespace: Game.Prefabs
Type: class
Base: NetPrefab
Summary:
NetGeometryPrefab is a NetPrefab that describes network (road/rail/etc.) geometry composition used by the ECS runtime. It contains section definitions, edge/node state presets, optional aggregate/style prefabs and logic to register the ECS component types and create archetypes used for node and edge composition entities during LateInitialize. This prefab is used to prepare the required component archetypes and dependencies for instancing network geometry at runtime.
Fields
-
public NetSectionInfo[] m_Sections
Holds the array of section definitions that make up the net. Each NetSectionInfo references a section prefab (m_Section) which is added to the prefab dependency list. -
public NetEdgeStateInfo[] m_EdgeStates
Edge state presets used by this net prefab (e.g., different road states/configurations). Used to populate edge-state data for geometry. -
public NetNodeStateInfo[] m_NodeStates
Node state presets used by this net prefab (e.g., intersection node variants). Used to populate node-state data for geometry. -
public float m_MaxSlopeSteepness = 0.2f
Maximum allowed slope steepness for this net's geometry. Used by net geometry generation logic to constrain slopes. -
public AggregateNetPrefab m_AggregateType
Optional aggregate prefab reference. If present, archetypes for edges will include the Aggregated component (used for aggregated rendering/instancing). -
public GroupPrefab m_StyleType
Optional group/style prefab reference associated with this net (e.g., style assets or group-level settings). Added to dependencies if present. -
public CompositionInvertMode m_InvertMode
Mode controlling composition inversion behavior for this net (how composition orientation/ordering is handled).
Properties
- None declared on this class.
This prefab exposes no public properties; configuration is done via public fields and overrides.
Constructors
public NetGeometryPrefab()
Default parameterless constructor (implicitly provided). Typical usage is via the Unity inspector or asset creation; no custom construction logic is defined in source.
Methods
public override void GetDependencies(List<PrefabBase> prefabs)
Adds referenced prefabs to the provided dependency list:- Adds each section's m_Section from m_Sections.
-
Adds m_AggregateType and m_StyleType if they are not null. Callers use this to gather all prefab references required before loading/initializing.
-
public override void GetPrefabComponents(HashSet<ComponentType> components)
Registers the component types that this prefab requires on its root prefab entity: -
Adds NetGeometryData, NetGeometryComposition, NetGeometrySection, NetGeometryEdgeState, NetGeometryNodeState (all read/write). This lets the ECS know which components will be present on instances of this prefab.
-
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Augments the supplied component set according to context (node, edge or composition) to enumerate archetype component requirements: - If Node component is present: adds SubLane, SubObject, NodeGeometry, CullingInfo, MeshBatch, PseudoRandomSeed.
- Else if Edge component is present: adds Aggregated (if m_AggregateType != null), SubLane, SubObject, Curve, Composition, EdgeGeometry, StartNodeGeometry, EndNodeGeometry, BuildOrder, CullingInfo, MeshBatch, PseudoRandomSeed.
-
Else if NetCompositionData component is present: adds NetCompositionPiece, NetCompositionMeshRef, NetCompositionArea, NetCompositionObject, NetCompositionCarriageway. This method is used when constructing archetypes for entities derived from the prefab.
-
public override void LateInitialize(EntityManager entityManager, Entity entity)
Performs late initialization on the prefab entity and creates the composition archetypes used at runtime: - Retrieves NetGeometryData component on the prefab entity.
- Gathers components from child/contained component prefabs via GetComponents(list) and collects their archetype components.
- Builds a HashSet of component types including NetCompositionData and additional flags (Created, Updated) and composition-specific markers (NetCompositionCrosswalk / NetCompositionLane).
- Creates two archetypes:
- m_NodeCompositionArchetype: built with NetCompositionCrosswalk included.
- m_EdgeCompositionArchetype: built with NetCompositionLane instead of crosswalk.
- Stores created archetypes back into the NetGeometryData on the prefab entity via entityManager.SetComponentData. This sets up ready-to-instantiate ECS archetypes for node and edge composition pieces.
Notes about implementation details: - LateInitialize depends on GetComponents(...) from the prefab base to collect child component prefabs and their archetype requirements. - The method temporarily toggles NetCompositionCrosswalk / NetCompositionLane to produce separate archetypes for crosswalk vs lane composition entities. - The Created and Updated components are added to the archetypes so composition pieces are correctly recognized by systems on spawn.
Usage Example
// Example: ensure dependencies are reported so the prefab loader knows to load section, aggregate and style prefabs
public override void GetDependencies(List<PrefabBase> prefabs)
{
base.GetDependencies(prefabs);
for (int i = 0; i < m_Sections.Length; i++)
{
prefabs.Add(m_Sections[i].m_Section);
}
if (m_AggregateType != null)
{
prefabs.Add(m_AggregateType);
}
if (m_StyleType != null)
{
prefabs.Add(m_StyleType);
}
}
Additional tips for modders: - Ensure m_Sections is populated (in the inspector or asset authoring) — LateInitialize expects section references to exist so it can collect dependencies. - If you provide an AggregateNetPrefab via m_AggregateType, the edge archetype will include the Aggregated component (used by aggregation systems and renderers). - If you extend or provide custom component prefabs referenced by this prefab, implement their GetArchetypeComponents correctly so LateInitialize will include required component types in the composition archetypes. - Test in a development build to ensure archetypes are created without missing component type errors.