Skip to content

Game.Events.EventJournalCityEffect

Assembly: Assembly-CSharp
Namespace: Game.Events

Type: public struct

Base: IBufferElementData, ISerializable

Summary:
A buffer element used by the game's ECS to record a tracked city-effect entry for the event journal. Stores the effect tracking type, the value at the start of tracking, and the current value. Implements Colossal's serialization interfaces so individual entries can be written to/read from the game's persistent/transfer streams.


Fields

  • public EventCityEffectTrackingType m_Type
    Stores the tracked effect type as an enum (serialized as an int).

  • public int m_StartValue
    The tracked value when the effect tracking started.

  • public int m_Value
    The current tracked value.

Properties

  • None. (This is a simple POD-style struct with public fields.)

Constructors

  • public EventJournalCityEffect()
    Default value-type constructor (compiler-provided). Fields will be default-initialized (m_Type == default, m_StartValue == 0, m_Value == 0) unless explicitly set.

Methods

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads serialized data from a Colossal.Serialization.IReader implementation in the following order:
  • An int representing EventCityEffectTrackingType (assigned to m_Type).
  • An int assigned to m_StartValue.
  • An int assigned to m_Value. The method uses reader.Read to fill each field.

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the struct's data to a Colossal.Serialization.IWriter implementation in the following order:

  • m_Type cast to int
  • m_StartValue
  • m_Value

Usage Example

// Add an entry to an entity's buffer (requires an EntityManager and an entity)
var buffer = entityManager.GetBuffer<EventJournalCityEffect>(entity);
buffer.Add(new EventJournalCityEffect {
    m_Type = EventCityEffectTrackingType.SomeEffect,
    m_StartValue = 100,
    m_Value = 120
});

// Serialize a single element using a Colossal IWriter implementation
var element = buffer[0];
// assume 'writer' implements Colossal.Serialization.Entities.IWriter
element.Serialize(writer);

// Deserialize into a local struct (then add to a buffer or use directly)
EventJournalCityEffect deserialized = default;
deserialized.Deserialize(reader); // 'reader' implements IReader
buffer.Add(deserialized);

{{ Additional notes: - This struct is intended to be used with Unity.Entities dynamic buffers (IBufferElementData). - Serialization order is important and must match for reader/writer compatibility (type, startValue, value). - The EventCityEffectTrackingType enum is serialized as an int; ensure enum definitions are consistent across save/load contexts. - Because this is a simple value-type (ints and an enum), it is inexpensive to copy and safe to use in ECS job contexts where blittable types are required. }}