Skip to content

Game.Prefabs.TakeoffLocation

Assembly: Game
Namespace: Game.Prefabs

Type: class

Base: ComponentBase

Summary:
Prefab component used to define a route "takeoff" location (a connection point between an access network and a route network). The prefab exposes connection-type fields that are used at entity initialization to create and populate a RouteConnectionData component. It is exposed in the Unity component menu under "Routes/" and linked to MarkerObjectPrefab via the ComponentMenu attribute. Typical use is for locations where vehicles transition from an access network (e.g., road) to a route network (e.g., air routes).


Fields

  • public RouteConnectionType m_ConnectionType1 = RouteConnectionType.Road
    Used to set the access connection type (m_AccessConnectionType) on the generated RouteConnectionData. Defaults to Road.

  • public RouteConnectionType m_ConnectionType2 = RouteConnectionType.Air
    Used to set the route connection type (m_RouteConnectionType) on the generated RouteConnectionData. Defaults to Air.

  • public RoadTypes m_RoadType
    Specifies the RoadTypes value used for both access and route road type fields (m_AccessRoadType and m_RouteRoadType) on the generated RouteConnectionData.

Properties

  • None (this class exposes public fields and overrides methods; it does not declare properties).

Constructors

  • public TakeoffLocation()
    Default parameterless constructor (implicit). Initialization logic is performed in Initialize when the prefab is converted into an Entity.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds components required for the prefab when creating the prefab entity. This class adds:
  • RouteConnectionData (ReadWrite)

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Specifies the archetype components to include on instantiated entities from this prefab. Adds:

  • Game.Routes.TakeoffLocation (ReadWrite) — an ECS tag/struct representing the takeoff location
  • AccessLane (ReadWrite)
  • RouteLane (ReadWrite)

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Called during prefab → entity conversion. Creates and populates a RouteConnectionData struct with values sourced from the prefab fields:

  • m_AccessConnectionType <- m_ConnectionType1
  • m_RouteConnectionType <- m_ConnectionType2
  • m_AccessTrackType, m_RouteTrackType <- TrackTypes.None
  • m_AccessRoadType, m_RouteRoadType <- m_RoadType
  • m_RouteSizeClass <- SizeClass.Undefined
  • m_StartLaneOffset <- 0f
  • m_EndMargin <- 0f Then writes the RouteConnectionData to the entity via entityManager.SetComponentData(entity, componentData).

Usage Example

// Example: configuring a TakeoffLocation prefab in code (e.g. editor script)
var takeoffPrefab = /* obtain reference to prefab GameObject or Component */;
takeoffPrefab.m_ConnectionType1 = RouteConnectionType.Road;
takeoffPrefab.m_ConnectionType2 = RouteConnectionType.Air;
takeoffPrefab.m_RoadType = RoadTypes.MainRoad;

// After conversion to an entity (runtime), RouteConnectionData will be set on the entity.
// You can read it back via the EntityManager:
EntityManager em = World.DefaultGameObjectInjectionWorld.EntityManager;
RouteConnectionData data = em.GetComponentData<RouteConnectionData>(entity);
// data.m_AccessConnectionType == RouteConnectionType.Road
// data.m_RouteConnectionType  == RouteConnectionType.Air

{{ Additional notes: - The ComponentMenu attribute places this prefab under "Routes/" in the component add menu and ties it to MarkerObjectPrefab in the editor. - Ensure the prefab conversion pipeline includes the components added in GetPrefabComponents/GetArchetypeComponents before Initialize is called, otherwise SetComponentData will fail. - RouteConnectionData fields like TrackTypes and SizeClass are set to None/Undefined by default here; adjust in prefab fields or via custom initialization if a different configuration is required. }}