Skip to content

Game.Prefabs.NavigationArea

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class NavigationArea

Base: ComponentBase

Summary:
NavigationArea is a prefab component used by the game's prefab system to define navigation/connectivity settings for area prefabs (for example lot and space prefabs). It exposes connection type(s) and allowed track/road types in the inspector and, when the prefab is instantiated, writes those settings into the ECS world by populating a NavigationAreaData component on the created entity. The class is annotated with ComponentMenu so it appears under the Areas menu in the editor alongside LotPrefab and SpacePrefab.


Fields

  • public RouteConnectionType m_ConnectionType
    Main connection type used for this navigation area. Typical values come from RouteConnectionType (for example Pedestrian, RoadVehicle, etc.). This value is written into NavigationAreaData during initialization and determines how this area connects to the network.

  • public RouteConnectionType m_SecondaryType
    Optional secondary connection type. Can be used to allow multiple connection modes for the same area (for example both pedestrian and service vehicle access). Also copied into NavigationAreaData at initialization.

  • public TrackTypes m_TrackTypes
    Flags/enum indicating which track types (rail, tram, etc.) are allowed or relevant for this area. Written into the NavigationAreaData so systems that build navigation lanes can read allowed track types.

  • public RoadTypes m_RoadTypes
    Flags/enum indicating which road types are allowed or relevant for this area. This is stored into NavigationAreaData for later use by navigation and lane generation systems.

Properties

  • None declared by this class. (The component exposes public fields rather than C# properties; the data is transferred into ECS component data in Initialize.)

Constructors

  • public NavigationArea()
    Default parameterless constructor (inherited/implicit). No custom construction logic is required because initialization of runtime ECS data happens in Initialize(EntityManager, Entity).

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds the ECS component types required on prefab entities for this prefab. NavigationArea adds ComponentType.ReadWrite() so that prefab entities will include the navigation area data component.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Adds archetype-time components required when creating entities from this prefab. NavigationArea adds:

  • ComponentType.ReadWrite()
  • ComponentType.ReadWrite() These indicate that navigation and sub-lane data will be present on instantiated entities and help shape the entity archetype.

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Copies the inspector-exposed fields (m_ConnectionType, m_SecondaryType, m_TrackTypes, m_RoadTypes) into a NavigationAreaData struct and sets that struct as component data on the created entity via entityManager.SetComponentData. This is the key step that transfers authoring-time settings into the runtime ECS world.

Notes: - The class relies on the NavigationAreaData struct and the Navigation / SubLane components to already be defined in the ECS codebase. - ComponentMenu attribute places this component under Areas/ in the Add Component menu and lists LotPrefab and SpacePrefab types in the attribute arguments.

Usage Example

// Typical pattern: configure this component in the prefab inspector.
// When the prefab is converted to an entity, Initialize will be called
// and the values below will be copied to the ECS NavigationAreaData.

// Example showing what Initialize does internally (simplified):
public override void Initialize(EntityManager entityManager, Entity entity)
{
    base.Initialize(entityManager, entity);

    NavigationAreaData data = default;
    data.m_ConnectionType = m_ConnectionType;
    data.m_SecondaryType = m_SecondaryType;
    data.m_TrackTypes = m_TrackTypes;
    data.m_RoadTypes = m_RoadTypes;

    entityManager.SetComponentData(entity, data);
}

Additional notes for modders: - If you need to extend or alter how navigation areas are created, you can subclass this prefab component and override GetPrefabComponents / GetArchetypeComponents / Initialize, but be sure to include the same ECS components or the systems that expect them may break. - Use the inspector to set m_ConnectionType / m_SecondaryType and track/road type flags to control how the game will generate lanes and connections for the area.