Skip to content

Game.EducationStatistic

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

Type: class

Base: ParametricStatistic

Summary:
EducationStatistic is a parametric statistic prefab component that maps game education levels to statistic parameters. It exposes an array of EducationLevelInfo entries (m_Levels) and yields StatisticParameterData items (an integer parameter and a Color) for each defined education level. It also provides a parameter name lookup that returns the enum name for a given CitizenEducationLevel value.


Fields

  • public EducationLevelInfo[] m_Levels
    Holds the configuration for each education level that should be exposed as a statistic parameter. Each EducationLevelInfo is expected to contain an education level identifier (m_EducationLevel) and a color (m_Color). The GetParameters() implementation iterates this array to produce StatisticParameterData values.

Properties

  • This class does not declare any public properties.

Constructors

  • public EducationStatistic()
    No explicit constructor is defined in the source; the default parameterless constructor is used. Initialization of m_Levels is expected to be done via the Unity inspector or by code.

Methods

  • public override IEnumerable<StatisticParameterData> GetParameters()
    Iterates the m_Levels array (if not null) and yields a StatisticParameterData for each entry. The yielded StatisticParameterData uses the integer value of the entry's m_EducationLevel (cast to int) as the parameter id and the entry's m_Color as the parameter color. The method uses yield return, so the enumeration is lazy and safe for foreach usage.

  • public override string GetParameterName(int parameter)
    Returns the enum name corresponding to the provided parameter integer by calling Enum.GetName(typeof(CitizenEducationLevel), parameter). This maps parameter ids back to the readable CitizenEducationLevel enum names.

Usage Example

// Example: iterating parameters exposed by an EducationStatistic instance
EducationStatistic stat = /* obtain component from a prefab or GameObject */;
if (stat != null)
{
    foreach (StatisticParameterData param in stat.GetParameters())
    {
        int id = param.parameter;      // integer representation of CitizenEducationLevel
        UnityEngine.Color color = param.color;
        string name = stat.GetParameterName(id); // e.g. "Primary", "Secondary", etc.

        // Use id, name, color for display in UI, legend, etc.
        Debug.Log($"Education level: {name} ({id}), color: {color}");
    }
}

Additional notes: - The GetParameters method yields values only when m_Levels is non-null; ensure m_Levels is initialized (via inspector or code) before using the statistic. - The mapping relies on the CitizenEducationLevel enum; ensure enum values line up with the indices or integer values you expect when reading/using parameter ids. - EducationLevelInfo must provide at least m_EducationLevel (type CitizenEducationLevel) and m_Color (UnityEngine.Color) for the produced StatisticParameterData to be meaningful.