Skip to content

Game.Prefabs.PathfindCostInfo

Assembly:
Namespace: Game.Prefabs

Type: struct

Base: System.ValueType

Summary:
A small, serializable data container used by prefabs to store the cost components used by the pathfinding system. It holds four float components—time, behaviour, money and comfort—that influence path selection. The struct provides a convenience method to convert itself into the runtime PathfindCosts type used by the pathfinding subsystem (Game.Pathfind.PathfindCosts).


Fields

  • public float m_Time
    Represents the time component of the pathfinding cost (in whatever time units the pathfinding system expects). Higher values increase the penalty for time when computing path costs.

  • public float m_Behaviour
    Represents a behavioural cost modifier (used to bias routes according to behaviour-related preferences). Interpretation depends on game logic that consumes PathfindCosts.

  • public float m_Money
    Represents the monetary cost component (e.g., tolls, fares). Higher values increase the financial penalty for a route.

  • public float m_Comfort
    Represents the comfort component (used to prefer or penalize routes based on comfort). Higher values increase the comfort penalty.

Properties

  • None (this struct exposes public fields directly).

Constructors

  • public PathfindCostInfo(float time, float behaviour, float money, float comfort)
    Initializes a new PathfindCostInfo with the given cost components.
  • time: value for m_Time
  • behaviour: value for m_Behaviour
  • money: value for m_Money
  • comfort: value for m_Comfort

Methods

  • public PathfindCosts ToPathfindCosts()
    Converts this PathfindCostInfo into a Game.Pathfind.PathfindCosts instance by passing the four float components to the PathfindCosts constructor. Use this when you need the runtime pathfinding representation rather than the serializable prefab form.

Usage Example

// Create a prefab-friendly cost struct
var prefabCosts = new Game.Prefabs.PathfindCostInfo(
    time: 12.5f,
    behaviour: 1.0f,
    money: 0.75f,
    comfort: 2.0f
);

// Convert to the runtime pathfinding type
Game.Pathfind.PathfindCosts runtimeCosts = prefabCosts.ToPathfindCosts();

// runtimeCosts can now be passed to pathfinding routines that expect PathfindCosts