Skip to content

Game.Pathfind.PathfindCosts

Assembly: Assembly-CSharp
Namespace: Game.Pathfind

Type: struct

Base: System.ValueType

Summary:
PathfindCosts is a lightweight value-type container that stores four cost components used by the pathfinding system: time, behaviour, money and comfort. It wraps a Unity.Mathematics.float4 for compact storage and SIMD-friendly math operations, making it suitable for use in performance-sensitive code and Unity Jobs.


Fields

  • public Unity.Mathematics.float4 m_Value
    Holds the four cost components in a single float4 vector. Component mapping is: .x = time, .y = behaviour, .z = money, .w = comfort. Using float4 allows vectorized arithmetic (addition, scaling) and efficient memory layout for jobified pathfinding data.

Properties

  • None
    This struct exposes its data via the public m_Value field; there are no properties or computed accessors provided.

Constructors

  • public PathfindCosts(float time, float behaviour, float money, float comfort)
    Initializes m_Value with the provided component values in the (time, behaviour, money, comfort) order. Use this constructor to create cost vectors succinctly when assembling pathfinding cost metrics.

Methods

  • None
    PathfindCosts is a plain data container and does not declare methods. All operations are expected to be performed via float4 arithmetic or external helper functions.

Usage Example

using Unity.Mathematics;
using Game.Pathfind;

// Create a cost instance
var costs = new PathfindCosts(10f, 2f, 5f, 1f);

// Read individual components
float timeCost = costs.m_Value.x;
float behaviourCost = costs.m_Value.y;
float moneyCost = costs.m_Value.z;
float comfortCost = costs.m_Value.w;

// Combine costs (example: add penalty)
costs.m_Value += new float4(1f, 0f, 0f, 0f);

// Use in vector math (scaling)
float4 scaled = costs.m_Value * 0.5f;

// Example in a job-friendly context (pseudo)
public struct PathCostJob : Unity.Jobs.IJob
{
    public float4 globalMultiplier;
    public PathfindCosts input;

    public void Execute()
    {
        // operate on the float4 directly for performance
        var adjusted = input.m_Value * globalMultiplier;
        // ... use adjusted for path scoring ...
    }
}

Additional notes: - Because it is a struct containing a Unity.Mathematics.float4, PathfindCosts is blittable and well-suited for use in Unity Jobs and Native containers. - There are no safeguards / immutability guarantees; modify m_Value in-place only when safe for your threading model.