Game.Prefabs.ParkingFacilityData
Assembly: Game
Namespace: Game.Prefabs
Type: struct
Base: IComponentData, IQueryTypeParameter, ICombineData
Summary:
Represents lightweight, serializable component data for a parking facility prefab used by the game's ECS. Holds two simple fields describing comfort contribution and garage marker capacity. Implements combination logic (to merge values from multiple sources) and (de)serialization for saving/loading or prefab instantiation.
Fields
-
public float m_ComfortFactor
Holds the comfort contribution (float) provided by the parking facility. Used by game systems that accumulate comfort metrics. Serialized first when writing the component. -
public int m_GarageMarkerCapacity
Holds the integer capacity for garage markers (parking spaces/markers). Serialized second when writing the component.
Properties
- None. This struct exposes only public fields; there are no properties.
Constructors
public ParkingFacilityData()
No explicit constructor is defined in the source; as a value type (struct) it has the default parameterless constructor provided by C# which initializes numeric fields to 0 (m_ComfortFactor = 0f, m_GarageMarkerCapacity = 0).
Methods
public void Combine(ParkingFacilityData otherData)
Adds the values from otherData into this instance:- m_ComfortFactor += otherData.m_ComfortFactor
-
m_GarageMarkerCapacity += otherData.m_GarageMarkerCapacity
Used when multiple sources of the same component are combined (for example when aggregating prefab/child data). -
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the component fields to the provided writer in fixed order: - float m_ComfortFactor
-
int m_GarageMarkerCapacity
This deterministic order must be preserved by any matching Deserialize implementation or reader. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads values from reader into the component fields in the same order that Serialize writes them: - float m_ComfortFactor
- int m_GarageMarkerCapacity
Reads are performed by reference into the struct's fields.
Notes: - The Serialize/Deserialize methods use generic writer/reader interfaces from Colossal.Serialization.Entities; ensure you pass compatible implementations. - Combine is a simple additive merge; if other combination semantics are required (clamping, max, averaging), handle them before or after calling Combine.
Usage Example
// Create and combine two ParkingFacilityData instances
var dataA = new ParkingFacilityData { m_ComfortFactor = 1.5f, m_GarageMarkerCapacity = 10 };
var dataB = new ParkingFacilityData { m_ComfortFactor = 0.5f, m_GarageMarkerCapacity = 5 };
dataA.Combine(dataB);
// dataA.m_ComfortFactor == 2.0f
// dataA.m_GarageMarkerCapacity == 15
// Serialization (pseudocode; replace `writer` and `reader` with actual implementations)
dataA.Serialize(writer);
// Deserialization
var readData = new ParkingFacilityData();
readData.Deserialize(reader);
Additional tips: - Because the struct is an ECS IComponentData, avoid large or reference-type fields — this struct follows that guideline by containing only value types. - Keep Serialize/Deserialize ordering stable across versions to maintain save/prefab compatibility.