Game.PathwayPrefab
Assembly: Game
Namespace: Game.Prefabs
Type: class
Base: NetGeometryPrefab
Summary:
PathwayPrefab defines a network geometry prefab used for pathway-type nets (e.g., pedestrian paths) within the game's ECS-based prefab system. It exposes a configurable speed limit and declares which ECS components the prefab requires or should include on created entities. The class primarily customizes component requirements by overriding GetPrefabComponents and GetArchetypeComponents and otherwise defers dependency resolution to its base class.
Fields
public float m_SpeedLimit = 40f
This field sets the default speed limit for the pathway (units consistent with game convention). It is public and can be adjusted in code or via the Unity inspector for the prefab. Default value is 40f.
Properties
- None
Constructors
public PathwayPrefab()
No explicit constructor is declared in the source; the type uses the default parameterless constructor and inherits any construction behavior from NetGeometryPrefab.
Methods
-
public override void GetDependencies(System.Collections.Generic.List<PrefabBase> prefabs)
Overrides the base implementation to collect prefab dependencies. In the current implementation it simply calls the base class implementation and does not add additional dependencies. -
public override void GetPrefabComponents(System.Collections.Generic.HashSet<Unity.Entities.ComponentType> components)
Adds components required by instances of this prefab. Calls the base implementation then adds: - ComponentType.ReadWrite
() -
ComponentType.ReadWrite
() These components indicate that entities spawned from this prefab should include PathwayData and LocalConnectData with read/write access. -
public override void GetArchetypeComponents(System.Collections.Generic.HashSet<Unity.Entities.ComponentType> components)
Called to determine components that should be present on entity archetypes. It first calls the base implementation, then inspects which component markers are already present and adds additional components accordingly: - If the archetype contains Edge, it adds UpdateFrame and EdgeColor.
- Else if the archetype contains Node, it adds UpdateFrame and NodeColor.
- Else if the archetype contains NetCompositionData, it adds PathwayComposition. This conditional logic ensures appropriate coloring and update-frame bookkeeping are present for edge/node entities, and composition data is added where relevant.
Usage Example
// Example: Adjusting the pathway speed limit on a prefab instance
var pathwayPrefab = /* obtain PathwayPrefab instance from prefab registry or inspector */;
pathwayPrefab.m_SpeedLimit = 20f; // lower speed limit for this pathway variant
// The prefab will automatically include the required ECS components when creating entities:
// - PathwayData, LocalConnectData, and conditionally UpdateFrame, EdgeColor / NodeColor, PathwayComposition
Notes and tips: - ComponentType refers to Unity.Entities.ComponentType and ReadWrite indicates the entity systems will expect write access. - The class relies on the base NetGeometryPrefab for most behavior; override methods only extend component lists or defer to base implementations. - If you need custom behavior (e.g., additional components or dependencies), override GetPrefabComponents / GetArchetypeComponents and call base first as shown in this prefab.