Skip to content

Game.EventJournalEntry

Assembly:
Assembly-CSharp

Namespace: Game.Events

Type: struct

Base: IComponentData, IQueryTypeParameter, ISerializable

Summary: EventJournalEntry is a small ECS component used to record a reference to an in-game event and the frame when that event started. It implements IComponentData so it can be attached to Entities, IQueryTypeParameter to be used conveniently in queries, and ISerializable to support the Colossal.Serialization pipeline used for saving/loading or network transfer. The Serialize/Deserialize implementations write/read fields in a fixed order (m_Event then m_StartFrame), so that serialized data is consistent across save/load.


Fields

  • public Unity.Entities.Entity m_Event Holds the Entity handle (identifier) for the event being journaled. This is the primary reference to the event instance stored in the world.

  • public uint m_StartFrame The simulation frame (unsigned 32-bit integer) when the event started. Useful for replaying, timing, or determining event age.

Properties

  • No public properties. The struct exposes its data via public fields.

Constructors

  • public EventJournalEntry() Structs in C# have an implicit parameterless constructor that zero-initializes fields. Use object initializer syntax to populate values when creating an instance:
  • m_Event defaults to Entity.Null
  • m_StartFrame defaults to 0

Methods

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader Reads component data from the provided reader. The implementation reads the Entity first into m_Event, then reads the start frame into m_StartFrame. The reader must provide the matching read order and types.

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter Writes component data to the provided writer. The implementation writes m_Event first, then m_StartFrame. The writer must write in the same order that Deserialize expects.

Notes: - The order of Serialize and Deserialize is important: they must match to ensure correct round-trip serialization. - The generic constraints (IReader/IWriter) are from the Colossal.Serialization.Entities namespace and used by the game's serialization system.

Usage Example

// Example: attaching an EventJournalEntry to an entity in an ECS world
using Unity.Entities;
using Game.Events;

// create an EventJournalEntry and add it to an entity
var entry = new EventJournalEntry
{
    m_Event = eventEntity,                  // a previously-created Entity representing the event
    m_StartFrame = (uint)UnityEngine.Time.frameCount
};

entityManager.AddComponentData(myEntity, entry);

// Example: reading back in a system
Entities.ForEach((ref EventJournalEntry journal) =>
{
    Unity.Entities.Entity eventEntity = journal.m_Event;
    uint startedAt = journal.m_StartFrame;
    // ... process ...
}).Schedule();