Skip to content

Game.Prefabs.PathfindTrackData

Assembly:
Assembly-CSharp.dll

Namespace:
Game.Prefabs

Type:
struct

Base:
IComponentData, IQueryTypeParameter

Summary:
Component data struct used by the game's ECS to hold pathfinding cost parameters for track (rail/road track) prefabs. Each field is a PathfindCosts instance (defined in Game.Pathfind) representing different cost factors the pathfinder uses when evaluating track segments (driving cost, two‑way penalty, switch cost, diamond crossing cost, curve angle penalty and spawn cost). This component is intended to be attached to track prefab entities to customize pathfinding behavior for that prefab.


Fields

  • public PathfindCosts m_DrivingCost
    Cost configuration used for normal driving traversal of the track segment (base movement cost).

  • public PathfindCosts m_TwowayCost
    Additional or alternative costs applied when the track is used in a two‑way configuration (penalties or modifiers for two‑way traffic).

  • public PathfindCosts m_SwitchCost
    Costs associated with switches (turnouts) in the track network; used when pathfinding routes through switches.

  • public PathfindCosts m_DiamondCrossingCost
    Costs applied when traversing a diamond crossing or intersection between tracks.

  • public PathfindCosts m_CurveAngleCost
    Penalty or cost adjustments dependent on curve angle — used to discourage sharp turns or to model angle-dependent speed penalties.

  • public PathfindCosts m_SpawnCost
    Costs applied for spawn/entry behavior (for example when vehicles are spawned onto the track or enter from a spawn point).

Properties

  • None. This is a plain component struct with public fields.

Constructors

  • public PathfindTrackData()
    Implicit parameterless struct constructor. Instances are typically created and initialized when authoring prefab data or when adding the component to an entity; no explicit constructor logic is defined in the source.

Methods

  • None. This struct contains only data; behavior is provided by pathfinding systems that read these fields.

Usage Example

// Example: adding and initializing the component in an authoring or conversion step
using Unity.Entities;
using Game.Prefabs;
using Game.Pathfind;

public class TrackAuthoringConversion : IConvertGameObjectToEntity
{
    public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
    {
        var costs = new PathfindTrackData
        {
            m_DrivingCost = new PathfindCosts { /* set fields as appropriate */ },
            m_TwowayCost = new PathfindCosts { /* ... */ },
            m_SwitchCost = new PathfindCosts { /* ... */ },
            m_DiamondCrossingCost = new PathfindCosts { /* ... */ },
            m_CurveAngleCost = new PathfindCosts { /* ... */ },
            m_SpawnCost = new PathfindCosts { /* ... */ }
        };

        dstManager.AddComponentData(entity, costs);
    }
}

Notes and tips: - PathfindCosts is defined in the Game.Pathfind namespace; inspect it to see available fields (e.g., base cost, multipliers, speed penalties) and how to configure them. - This component is consumed by the game's pathfinding systems — changing costs affects route selection, vehicle behavior, and priority at intersections/switches. Test changes thoroughly to ensure desired behavior. - Because this is IComponentData, it is safe and efficient to use in DOTS systems and queries. As it also implements IQueryTypeParameter, it can be used directly in query type parameters where supported.