Skip to content

Game.Prefabs.PassengerStatistic

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

Type: class

Base: ParametricStatistic

Summary:
PassengerStatistic is a ParametricStatistic prefab component that exposes one statistic parameter per configured passenger type. It reads an array of PassengerTypeInfo (m_PassengerTypes) and yields StatisticParameterData entries (integer parameter id + color) for each configured passenger type. It also resolves a parameter's display name from the PassengerType enum.


Fields

  • public PassengerTypeInfo[] m_PassengerTypes
    Array of configured passenger types and associated colors. Each element supplies the enum value (PassengerType) and a color used to create a StatisticParameterData. If this array is null or empty, GetParameters yields no values.

Properties

  • None (no public properties declared in this class)

Constructors

  • public PassengerStatistic()
    Default parameterless constructor (implicitly provided). The class contains no custom construction logic.

Methods

  • public override IEnumerable<StatisticParameterData> GetParameters()
    Returns an IEnumerable that yields a StatisticParameterData for each entry in m_PassengerTypes. For each element i, it yields a new StatisticParameterData where the parameter integer is (int)m_PassengerTypes[i].m_PassengerType and the color is m_PassengerTypes[i].m_Color. If m_PassengerTypes is null, the method yields nothing. Implementation uses a yield return loop.

  • public override string GetParameterName(int parameter)
    Resolves the display name for a parameter integer by calling Enum.GetName(typeof(PassengerType), parameter). If the integer does not map to a defined PassengerType enum value, Enum.GetName may return null.

Additional notes: - The class is annotated with [ComponentMenu("Statistics/", new Type[] { typeof(StatisticsPrefab) })], which places it under the Statistics menu in the Unity component menu used by the game's editor tools. - Dependent types referenced: - PassengerTypeInfo (contains m_PassengerType : PassengerType and m_Color) - PassengerType (enum) - StatisticParameterData (structure/class holding a parameter id and color) - ParametricStatistic (base class providing the statistics framework)

Usage Example

// Example: iterate parameters produced by PassengerStatistic and print their names and colors
PassengerStatistic stat = /* obtain component from prefab or GameObject */;
foreach (var paramData in stat.GetParameters())
{
    int id = paramData.parameter;
    string name = stat.GetParameterName(id) ?? $"Unknown({id})";
    var color = paramData.color;
    Debug.Log($"Passenger parameter {id}: {name}, color={color}");
}