Skip to content

Game.Prefabs.WorkStop

Assembly:
Assembly-CSharp

Namespace:
Game.Prefabs

Type:
public class WorkStop : ComponentBase

Base:
ComponentBase

Summary:
Represents a prefab component used to configure a "work" transport stop for the routing system (e.g., cargo or workplace stops). When the prefab is instantiated this component registers required ECS component types and initializes RouteConnectionData, TransportStopData and WorkStopData on the entity based on the public fields configured on the prefab. Typically used for stops where vehicles pick up or drop off cargo/work-related passengers rather than regular passenger transport.


Fields

  • public RoadTypes m_RouteRoadType
    Specifies the road type used for the route connection created for this stop. Default in the prefab is RoadTypes.Car. This value is mapped into RouteConnectionData.m_RouteRoadType during Initialize.

  • public bool m_WorkLocation
    Flag indicating whether this stop represents a work location. This value is mapped into WorkStopData.m_WorkLocation during Initialize.

Properties

  • None declared on this class.
    This component exposes its configuration via the public fields above and writes ECS component data in Initialize rather than exposing properties.

Constructors

  • public WorkStop()
    Default (implicit) constructor. The class relies on ComponentBase's construction lifecycle and Unity/authoring workflow to configure public fields on the prefab instance.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds the ECS component types the prefab must have at runtime: WorkStopData, TransportStopData and RouteConnectionData (all ReadWrite). These are the component types that will be present on the entity created from the prefab.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Adds additional archetype component types required for entities of this prefab: Game.Objects.Color, Game.Routes.TransportStop, Game.Routes.WorkStop, ConnectedRoute and BoardingVehicle (all ReadWrite). These likely reflect runtime behavior and linking to route/vehicle systems.

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Called during prefab-to-entity initialization. This method:

  • Calls base.Initialize.
  • Constructs and sets a RouteConnectionData with:
    • m_AccessConnectionType = Pedestrian
    • m_RouteConnectionType = Road
    • m_AccessTrackType = None
    • m_RouteTrackType = None
    • m_AccessRoadType = None
    • m_RouteRoadType = m_RouteRoadType (from prefab field)
    • m_RouteSizeClass = Undefined
    • m_StartLaneOffset = 0f
    • m_EndMargin = 0f
  • Constructs and sets a TransportStopData with:
    • m_ComfortFactor = 0f
    • m_LoadingFactor = 0f
    • m_AccessDistance = 0f
    • m_BoardingTime = 0f
    • m_TransportType = TransportType.Work
    • m_PassengerTransport = false
    • m_CargoTransport = true
  • Constructs and sets a WorkStopData with:
    • m_WorkLocation = m_WorkLocation (from prefab field)
  • Writes those component data structs to the entity via entityManager.SetComponentData.

This Initialize implementation configures the stop as a non-passenger (cargo/work) transport stop with a road connection and transfers the prefab settings to ECS component data.

Usage Example

// Example: customizing a WorkStop prefab in code
public class CustomWorkStop : WorkStop
{
    public CustomWorkStop()
    {
        // change default route road type and mark as a work location
        m_RouteRoadType = RoadTypes.Truck;
        m_WorkLocation = true;
    }

    public override void Initialize(EntityManager entityManager, Entity entity)
    {
        // call base to set up the standard ECS components
        base.Initialize(entityManager, entity);

        // optionally tweak TransportStopData after base initialization
        var transportData = entityManager.GetComponentData<TransportStopData>(entity);
        transportData.m_ComfortFactor = 1.0f; // example adjustment
        entityManager.SetComponentData(entity, transportData);
    }
}