Skip to content

Game.UI.InGame.EducationData

Assembly: Assembly-CSharp
Namespace: Game.UI.InGame

Type: readonly struct

Base: Colossal.UI.Binding.IJsonWritable

Summary:
Represents population counts by education level for UI/charting purposes. The struct is immutable: it exposes read-only integer properties for five education tiers and a precomputed total. It supports addition (to combine counts) and implements IJsonWritable to serialize itself in the format expected by the UI ("selectedInfo.ChartData" with a "values" array and a "total" property).


Fields

  • No explicit fields declared.
    This struct exposes read-only auto-properties; any backing fields are compiler-generated.

Properties

  • public int uneducated { get; }
    Count of uneducated citizens (lowest education level).

  • public int poorlyEducated { get; }
    Count of poorly educated citizens.

  • public int educated { get; }
    Count of educated citizens.

  • public int wellEducated { get; }
    Count of well-educated citizens.

  • public int highlyEducated { get; }
    Count of highly educated citizens (highest education level).

  • public int total { get; }
    Sum of all five education-tier counts. Computed once in the constructor.

Constructors

  • public EducationData(int uneducated, int poorlyEducated, int educated, int wellEducated, int highlyEducated)
    Initializes the five education-tier properties and computes the total as the sum of those values. Because the struct is readonly, values cannot be changed after construction.

Methods

  • public static EducationData operator +(EducationData left, EducationData right)
    Returns a new EducationData whose tier counts are the element-wise sums of the operands' counts. The returned total is computed as the sum of the summed tiers.

  • public void Write(IJsonWriter writer)
    Implements IJsonWritable to serialize the data for UI consumption. The method writes a type block "selectedInfo.ChartData" containing:

  • a "values" array with five integers in this order: uneducated, poorlyEducated, educated, wellEducated, highlyEducated
  • a "total" property with the total count

Example JSON structure produced (conceptually): { "selectedInfo.ChartData": { "values": [ uneducated, poorlyEducated, educated, wellEducated, highlyEducated ], "total": total } }

Usage Example

using Colossal.UI.Binding;
using Game.UI.InGame;

// create two data snapshots and combine them
var morning = new EducationData(100, 200, 300, 150, 50);
var evening = new EducationData(80, 160, 240, 120, 40);
var combined = morning + evening; // sums each tier, total computed automatically

// serialize to an IJsonWriter (writer assumed to be provided by the calling UI code)
combined.Write(writer);