Game.UI.InGame.TaxResource
Assembly:
Assembly-CSharp
Namespace:
Game.UI.InGame
Type:
struct
Base:
System.ValueType, Colossal.UI.Binding.IJsonReadable, Colossal.UI.Binding.IJsonWritable
Summary:
Represents a small serializable data container used by the in-game UI to store a tax-related resource identifier and an associated area type. Implements IJsonReadable and IJsonWritable to support JSON (de)serialization via the Colossal.UI.Binding JSON reader/writer interfaces. The JSON representation uses the keys "resource" and "area".
Fields
-
public int m_Resource
Holds the resource identifier (typically an enum/int representing the tax resource or category). -
public int m_AreaType
Holds the area type identifier (an int representing the area/classification associated with the resource).
Properties
- None. This struct exposes plain public fields and no properties.
Constructors
public TaxResource()
The implicit parameterless default constructor for the struct. Initializes integer fields to 0. No explicit constructor is defined in the source.
Methods
public void Read(IJsonReader reader)
Reads data from a JSON reader that follows the expected map structure. Implementation steps:- reader.ReadMapBegin()
- reader.ReadProperty("resource"); reader.Read(out m_Resource);
- reader.ReadProperty("area"); reader.Read(out m_AreaType);
-
reader.ReadMapEnd() The reader must be positioned at the beginning of the map for this object. After calling, m_Resource and m_AreaType are populated from the JSON.
-
public void Write(IJsonWriter writer)
Writes this instance to a JSON writer. Implementation steps: - writer.TypeBegin(GetType().FullName)
- writer.PropertyName("resource"); writer.Write(m_Resource);
- writer.PropertyName("area"); writer.Write(m_AreaType);
- writer.TypeEnd() Produces a typed JSON block containing the "resource" and "area" properties.
Usage Example
using Colossal.UI.Binding;
using Game.UI.InGame;
// Serializing (writing)
TaxResource tax = new TaxResource { m_Resource = 5, m_AreaType = 2 };
IJsonWriter writer = /* obtain writer from your JSON serializer/context */;
tax.Write(writer);
// Deserializing (reading)
IJsonReader reader = /* obtain reader positioned at the TaxResource map */;
TaxResource loaded = new TaxResource();
loaded.Read(reader);
// loaded.m_Resource and loaded.m_AreaType are now populated
Notes: - The JSON format expects property names "resource" and "area". - This struct is a simple POD used for data transfer and persistence within UI-related systems; modify with care to preserve compatibility with existing save/serialization formats.