Game.Prefabs.TransportStopMarker
Assembly:
Assembly-CSharp (game runtime assembly containing game prefab components)
Namespace: Game.Prefabs
Type:
class
Base:
ComponentBase
Summary:
TransportStopMarker is a prefab component used to mark transport stop prefabs. It exposes inspector fields that describe what kind of transport stop the prefab represents (passenger/cargo/work) and, during entity initialization, writes a TransportStopMarkerData component to the entity based on those settings. The class is annotated with a ComponentMenu attribute so it appears under the Notifications menu (with NotificationIconPrefab as a related type).
Fields
-
public TransportType m_TransportType
The transport type for this stop prefab (e.g., bus, tram, train, Work). Determines how the boolean stop flags are interpreted when filling TransportStopMarkerData. -
public bool m_PassengerTransport
When m_TransportType is not TransportType.Work, this flag becomes m_StopTypeA on the TransportStopMarkerData and indicates whether the stop handles passenger transport. -
public bool m_CargoTransport
When m_TransportType is not TransportType.Work, this flag becomes m_StopTypeB on the TransportStopMarkerData and indicates whether the stop handles cargo transport. -
public bool m_WorkStop
When m_TransportType == TransportType.Work, this flag becomes m_StopTypeA on the TransportStopMarkerData and indicates the prefab is a work stop. -
public bool m_WorkLocation
When m_TransportType == TransportType.Work, this flag becomes m_StopTypeB on the TransportStopMarkerData and indicates the prefab is a work location.
Properties
- None.
Constructors
public TransportStopMarker()
Default constructor. No custom construction logic is defined in the class — Unity/Mono will create and populate the component from the prefab/inspector.
Methods
-
public override void GetPrefabComponents(System.Collections.Generic.HashSet<Unity.Entities.ComponentType> components)
Adds the component types that should be present on the prefab entity. Implementation adds ComponentType.ReadWrite() so that the runtime entity will have writable TransportStopMarkerData when the prefab is instantiated. -
public override void GetArchetypeComponents(System.Collections.Generic.HashSet<Unity.Entities.ComponentType> components)
Empty in this implementation. Intended hook for adding components to an archetype when creating entity archetypes, but this prefab component does not add archetype components here. -
public override void Initialize(Unity.Entities.EntityManager entityManager, Unity.Entities.Entity entity)
Called during prefab entity initialization. Creates a TransportStopMarkerData instance, sets its m_TransportType from the component's m_TransportType, and maps the boolean inspector flags into the component data fields m_StopTypeA and m_StopTypeB. If m_TransportType == TransportType.Work, the mapping is: - m_StopTypeA = m_WorkStop
- m_StopTypeB = m_WorkLocation Otherwise:
- m_StopTypeA = m_PassengerTransport
- m_StopTypeB = m_CargoTransport Finally, it writes the data to the entity with entityManager.SetComponentData(entity, componentData).
Usage Example
// Prefab author sets the inspector fields on the TransportStopMarker component.
// When the prefab is converted to an entity, TransportStopMarker.Initialize runs
// and writes TransportStopMarkerData onto the entity.
protected void Example_ReadMarkerData(EntityManager entityManager, Entity entity)
{
if (entityManager.HasComponent<TransportStopMarkerData>(entity))
{
var data = entityManager.GetComponentData<TransportStopMarkerData>(entity);
UnityEngine.Debug.Log($"TransportType: {data.m_TransportType}, StopA: {data.m_StopTypeA}, StopB: {data.m_StopTypeB}");
}
}