Skip to content

Game.Pathfind.PathfindWeights

Assembly: Assembly-CSharp.dll
Namespace: Game.Pathfind

Type: struct

Base: System.ValueType

Summary:
Represents a compact set of pathfinding weights stored in a Unity.Mathematics.float4. The components correspond to time, behaviour, money and comfort. This struct is intended for use in pathfinding calculations where multiple cost components are tracked and occasionally scaled together (e.g., when applying a multiplier to all weight components).


Fields

  • public Unity.Mathematics.float4 m_Value
    Backs the weight components. The 4 elements are used as:
  • m_Value.x => time
  • m_Value.y => behaviour
  • m_Value.z => money
  • m_Value.w => comfort
    This uses Unity.Mathematics.float4 to allow SIMD-friendly operations and easy component-wise scaling.

Properties

  • public float time { get; }
    Read-only property that returns the time component (m_Value.x). Useful when only the travel-time portion of the weight is needed.

  • public float money { get; }
    Read-only property that returns the money component (m_Value.z). Useful to inspect or use the monetary cost portion directly.

(Note: behaviour and comfort do not have dedicated properties in this struct but are accessible via m_Value.y and m_Value.w respectively.)

Constructors

  • public PathfindWeights(float time, float behaviour, float money, float comfort)
    Creates a PathfindWeights instance by assigning each provided parameter to the corresponding component in m_Value (x, y, z, w). Use this to construct a full weight vector in one call.

Methods

  • public static PathfindWeights operator *(float x, PathfindWeights w)
    Scales all weight components by the scalar x and returns a new PathfindWeights. The multiplication is performed component-wise on the underlying float4 (x * w.m_Value). This is handy for applying global multipliers (e.g., scaling costs by difficulty or modifiers) in a single, efficient operation.

Usage Example

// Create a weight vector: time=10, behaviour=0.5, money=2, comfort=1
var weights = new PathfindWeights(10f, 0.5f, 2f, 1f);

// Scale all components by 0.8 (e.g., apply a discount or modifier)
var scaled = 0.8f * weights;

// Read specific components
float travelTime = scaled.time;
float costMoney = scaled.money;

// Access behaviour and comfort directly if needed
float behaviour = scaled.m_Value.y;
float comfort = scaled.m_Value.w;