Game.Simulation.CollectedCityServiceBudgetData
Assembly:
Assembly-CSharp (game assembly; verify actual assembly in your modding environment)
Namespace:
Game.Simulation
Type:
public struct — implements Unity.Entities.IComponentData, IQueryTypeParameter, Colossal.Serialization.Entities.ISerializable
Base:
System.ValueType (struct); implements IComponentData, IQueryTypeParameter, ISerializable
Summary:
CollectedCityServiceBudgetData is a plain data struct used by the simulation to store aggregated budget-related information for a city service. It contains workplace distribution, counts and several cost/wage values. The struct supports (de)serialization via the game's Colossal.Serialization system and is intended to be used as an ECS component (IComponentData) or as a query-type parameter.
Fields
-
public Unity.Mathematics.int3 m_Workplaces
Holds workplace counts (x/y/z = different workplace categories or tiers). Uses Unity.Mathematics.int3. -
public int m_Count
Total count of the service instances or relevant entities considered in this aggregation. -
public int m_Export
Amount exported (context-specific, e.g., exported goods or service output). -
public int m_BaseCost
Base upkeep/cost for the collected services. Note: during deserialization this field is only read if the serialized data version is new enough (see Deserialize). -
public int m_Wages
Currently paid wages aggregated across the collected services. -
public int m_FullWages
Wages at full staffing (or the theoretical full-wage amount).
Properties
- This struct declares no properties. It only exposes public fields and implements interfaces for ECS and serialization.
Constructors
public CollectedCityServiceBudgetData()
(implicit default)
No explicit constructors are declared. Use the default value-initialized struct or initialize fields via an object initializer.
Methods
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads fields from the provided reader in the following order: m_Workplaces, m_Count, m_Wages, m_FullWages, m_Export. The m_BaseCost field is read only if reader.context.version >= Version.netUpkeepCost. This conditional read preserves backward compatibility with older save/serialization versions.
Notes: - Uses ref locals to read into the struct fields. - The ordering must match the writer's ordering for correct deserialization.
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes fields to the provided writer in the following order: m_Workplaces, m_Count, m_Wages, m_FullWages, m_Export, m_BaseCost. The writer always writes m_BaseCost; readers of older versions that don't expect this value should handle versioning accordingly.
Important compatibility note: - Serialize unconditionally writes m_BaseCost. Deserialize conditionally reads it based on reader.context.version, so older readers will ignore the extra value if they don't expect it (depending on the reader implementation). When changing field order or presence, ensure you manage Version.* checks consistently.
Usage Example
// Add this as an ECS component to an entity
var data = new CollectedCityServiceBudgetData
{
m_Workplaces = new int3(10, 5, 2),
m_Count = 17,
m_Export = 3,
m_BaseCost = 1200,
m_Wages = 800,
m_FullWages = 1000
};
// Assuming `entityManager` and `entity` are available in your system:
entityManager.AddComponentData(entity, data);
// Example: serializing with a writer (pseudocode)
// writer and reader types depend on the game's Colossal.Serialization API
writer.Write(data); // or call data.Serialize(writer) if required
{{ This struct is intended for internal simulation bookkeeping and saving/loading. When modifying or reading these values in a mod, respect ECS threading rules and the serialization versioning to avoid compatibility issues. If you add new fields, follow the existing pattern of guarded reads based on Version.* and make sure writers and readers remain consistent. }}