Skip to content

Game.Prefabs.TransportPathfind

Assembly: Assembly-CSharp (inferred)
Namespace: Game.Prefabs

Type: class

Base: ComponentBase

Summary:
Component used on transport-related prefabs to provide pathfinding cost configuration. The component exposes three PathfindCostInfo fields (ordering, starting and travel costs) that are converted into a PathfindTransportData component on the entity during initialization. The class is decorated with a ComponentMenu attribute ("Pathfind/") so it can be added as a prefab component in the editor.


Fields

  • public PathfindCostInfo m_OrderingCost = new PathfindCostInfo(5f, 0f, 0f, 5f)
    Used to configure the ordering cost portion of transport pathfinding. Default constructed values shown are used when the component is created. The value is converted via ToPathfindCosts() into the PathfindTransportData.m_OrderingCost field during Initialize.

  • public PathfindCostInfo m_StartingCost = new PathfindCostInfo(5f, 0f, 10f, 5f)
    Configures the cost applied when starting a path (e.g., initial penalties). Converted to PathfindTransportData.m_StartingCost in Initialize.

  • public PathfindCostInfo m_TravelCost = new PathfindCostInfo(0f, 0f, 0.02f, 0f)
    Configures the per-travel costs (e.g., distance-based cost). Converted to PathfindTransportData.m_TravelCost in Initialize.

Properties

  • (none)
    This class does not declare any public properties.

Constructors

  • public TransportPathfind()
    No explicit constructor is defined in source — the default parameterless constructor is used. The fields above are initialized inline with the shown default PathfindCostInfo values.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds the runtime component type that this prefab component supplies. Implementation adds ComponentType.ReadWrite(), indicating that entities created from this prefab should have a PathfindTransportData component (read/write).

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Override present but empty — this prefab does not add any additional archetype-only component entries here.

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Called when the prefab component initializes on an entity. Calls base.Initialize(entityManager, entity) then sets the PathfindTransportData component values on the entity by converting the PathfindCostInfo fields with ToPathfindCosts(). Specifically sets:

  • PathfindTransportData.m_OrderingCost = m_OrderingCost.ToPathfindCosts()
  • PathfindTransportData.m_StartingCost = m_StartingCost.ToPathfindCosts()
  • PathfindTransportData.m_TravelCost = m_TravelCost.ToPathfindCosts()

Notes: PathfindCostInfo and PathfindTransportData are types used by the game's pathfinding system. ToPathfindCosts() is expected to convert PathfindCostInfo into the data structure used by the runtime pathfinder (commonly a PathfindCosts or similar struct).

Usage Example

// Typical usage: configure this component on a transport prefab (in editor or by script).
// When the prefab is instantiated, Initialize will write the converted costs into the entity's PathfindTransportData.

var transportPrefab = new TransportPathfind();
transportPrefab.m_OrderingCost = new PathfindCostInfo(6f, 0f, 1f, 4f);
transportPrefab.m_StartingCost = new PathfindCostInfo(5f, 0f, 8f, 5f);
transportPrefab.m_TravelCost = new PathfindCostInfo(0f, 0f, 0.03f, 0f);

// When the game creates the Entity for this prefab, Initialize(...) will be called internally and
// entityManager.SetComponentData(entity, new PathfindTransportData { ... }) will apply the costs.

Additional remarks: This component is intended for modders who want to adjust how transport prefabs affect pathfinding behavior (ordering, startup penalties, and per-distance travel costs). Tweak the PathfindCostInfo values to influence route selection of transport vehicles or agents.