Game.EventJournalData
Assembly: Assembly-CSharp (game assembly)
Namespace: Game.Events
Type: struct
Base: System.ValueType, Unity.Entities.IBufferElementData, Colossal.Serialization.Entities.ISerializable
Summary: EventJournalData is a lightweight buffer element used to record a single piece of event-related tracking data for Cities: Skylines 2. It stores the kind of tracked data (m_Type) and an associated integer value (m_Value). The struct implements IBufferElementData so it can be stored in an entity's dynamic buffer and ISerializable so it can be written to/read from the game's serialization streams. Serialization writes m_Type as an int followed by m_Value as an int; deserialization reads them in the same order.
Fields
-
public EventDataTrackingType m_Type
This enum field identifies what kind of event data is being tracked (the concrete EventDataTrackingType enum is defined elsewhere). When serialized, the enum is cast to an int. -
public int m_Value
Integer payload associated with the tracked data. Depending on the tracking type this may represent a count, an identifier, or another numeric metric. Written/read as a plain int in Serialize/Deserialize.
Properties
- None. This struct exposes public fields and does not provide properties.
Constructors
public EventJournalData()
Implicit default constructor provided by the value type. Instances are typically created with an object initializer (e.g., new EventJournalData { m_Type = ..., m_Value = ... }) or added directly to an entity buffer.
Methods
-
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads serialized data in the same order as Serialize. First reads an int and casts it to EventDataTrackingType to populate m_Type, then reads an int into m_Value. Ensure the reader's stream matches the format (enum-as-int then int) for compatibility. -
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes m_Type (cast to int) followed by m_Value to the provided writer. Keep the ordering stable to ensure proper deserialization.
Usage Example
// Add entries into an entity's dynamic buffer
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
var e = entityManager.CreateEntity();
var buffer = entityManager.AddBuffer<Game.Events.EventJournalData>(e);
buffer.Add(new Game.Events.EventJournalData {
m_Type = EventDataTrackingType.SomeType,
m_Value = 42
});
// Serializing an instance (writer is provided by the game's serialization system)
var entry = new Game.Events.EventJournalData { m_Type = EventDataTrackingType.SomeType, m_Value = 42 };
entry.Serialize(writer);
// Deserializing (reader provided by the game's serialization system)
var loaded = new Game.Events.EventJournalData();
loaded.Deserialize(reader);