Skip to content

Game.Prefabs.ConnectionPathfind

Assembly: Assembly-CSharp (game / mod assembly)
Namespace: Game.Prefabs

Type: class

Base: ComponentBase

Summary:
ConnectionPathfind is a prefab component used to configure pathfinding costs for a connection prefab. It exposes multiple PathfindCostInfo fields (for borders, distance, spawn costs, takeoff costs, parking, etc.) and, during Initialize, converts those PathfindCostInfo values into the ECS component PathfindConnectionData (written to the created entity). It is decorated with a ComponentMenu attribute so it appears under the "Pathfind/" category in the prefab menu.


Fields

  • public PathfindCostInfo m_BorderCost
    Cost settings used when crossing a border-type connection. Default initialized to (10f, 0f, 10f, 0f).

  • public PathfindCostInfo m_PedestrianBorderCost
    Cost settings specifically for pedestrian border crossings. Default (10f, 0f, 10f, 0f).

  • public PathfindCostInfo m_DistanceCost
    Per-distance cost component used in routing calculations. Default (0.01f, 0f, 0.01f, 0f).

  • public PathfindCostInfo m_AirwayCost
    Cost settings for airway segments (used by air pathfinding). Default (0f, 0f, 0.02f, 0f).

  • public PathfindCostInfo m_InsideCost
    Cost for inside-area traversal (e.g., internal connection costs). Default (0.01f, 0f, 0.01f, 0f).

  • public PathfindCostInfo m_AreaCost
    Area-specific cost values (default zeros).

  • public PathfindCostInfo m_CarSpawnCost
    Cost applied when spawning a car. Default (5f, 0f, 0f, 0f).

  • public PathfindCostInfo m_PedestrianSpawnCost
    Cost applied when spawning a pedestrian. Default (5f, 0f, 0f, 0f).

  • public PathfindCostInfo m_HelicopterTakeoffCost
    Cost for helicopter takeoff actions. Default (5f, 0f, 0f, 0f).

  • public PathfindCostInfo m_AirplaneTakeoffCost
    Cost for airplane takeoff actions. Default (5f, 0f, 0f, 0f).

  • public PathfindCostInfo m_TaxiStartCost
    Cost for the start of a taxi trip. Default (5f, 0f, 0f, 0f).

  • public PathfindCostInfo m_ParkingCost
    Cost associated with parking. Default (10f, 0f, 0f, 0f).

Properties

  • This class defines no public properties.

Constructors

  • public ConnectionPathfind()
    No explicit constructor is defined in the source file; the default public constructor is used. Instances are normally created/managed by the prefab system in the editor/runtime.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds ComponentType.ReadWrite() to the provided set. This signals that entities created from this prefab will contain the PathfindConnectionData component (written by Initialize).

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Empty override. No additional archetype components are declared by this component.

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Called when the prefab is instantiated into an ECS entity. This override converts each PathfindCostInfo field to the runtime PathfindCosts form (via ToPathfindCosts()) and writes a PathfindConnectionData instance to the entity using entityManager.SetComponentData(...). The mapping includes all the fields listed above (m_BorderCost, m_PedestrianBorderCost, m_DistanceCost, m_AirwayCost, m_InsideCost, m_AreaCost, m_CarSpawnCost, m_PedestrianSpawnCost, m_HelicopterTakeoffCost, m_AirplaneTakeoffCost, m_TaxiStartCost, m_ParkingCost).

Usage Example

// Example: read the produced PathfindConnectionData from the entity created by the prefab
public void ExampleRead(EntityManager entityManager, Entity connectionEntity)
{
    // Ensure the entity has the component (GetPrefabComponents added it)
    if (entityManager.HasComponent<PathfindConnectionData>(connectionEntity))
    {
        var data = entityManager.GetComponentData<PathfindConnectionData>(connectionEntity);
        // Inspect some cost value (field names depend on PathfindConnectionData definition)
        UnityEngine.Debug.Log($"Distance cost base: {data.m_DistanceCost.m_BaseCost}");
    }
}

Additional notes: - PathfindCostInfo.ToPathfindCosts() converts the editable prefab struct into the runtime format expected by PathfindConnectionData; edit the PathfindCostInfo fields on the prefab to tune routing behavior. - ComponentMenu("Pathfind/", ...) places this component under the "Pathfind" category in the prefab/component UI for easier authoring of connection prefabs.