Game.Events.JournalEvent
Assembly: Game (assembly name may vary by project; commonly part of the game's Game.dll)
Namespace: Game.Events
Type: struct
Base: System.ValueType, Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter, Colossal.Serialization.Entities.ISerializable
Summary:
JournalEvent is a small ECS component used to carry a reference to a "journal" Entity. It implements IComponentData so it can be attached to entities in the DOTS/ECS world, IQueryTypeParameter to be used in queries, and ISerializable so its value can be read/written during serialization (save/load or network operations). The component simply stores an Entity handle that identifies the journal-related entity.
Fields
public Unity.Entities.Entity m_JournalEntity
Holds the Entity reference for the journal. This is the primary data for the component and is read/written by the Serialize/Deserialize methods. It can be used by systems to locate the journal entity or to associate events with a journal entry.
Properties
- This type has no properties.
All data is exposed through the public field m_JournalEntity.
Constructors
public JournalEvent()
The struct uses the default (parameterless) constructor automatically provided by C#. You can create an instance directly and set m_JournalEntity, for example: new JournalEvent { m_JournalEntity = someEntity };
Methods
-
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads the stored Entity from the reader into m_JournalEntity. Implementation: reader.Read(out m_JournalEntity); -
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes m_JournalEntity to the writer for serialization. Implementation: writer.Write(m_JournalEntity);
Both methods are generic to work with the game's serialization reader/writer abstractions and ensure the component can be saved/loaded.
Usage Example
// Create and attach the component to an entity (EntityManager example)
var journalEvent = new Game.Events.JournalEvent { m_JournalEntity = someJournalEntity };
entityManager.AddComponentData(targetEntity, journalEvent);
// Read in a system
Entities.ForEach((ref Game.Events.JournalEvent je) =>
{
Entity journal = je.m_JournalEntity;
// operate on journal entity...
});
// Serialization example (pseudocode showing intent)
void SaveComponent<TWriter>(ref Game.Events.JournalEvent ev, TWriter writer) where TWriter : IWriter
{
ev.Serialize(writer); // writes the m_JournalEntity to the writer
}
void LoadComponent<TReader>(out Game.Events.JournalEvent ev, TReader reader) where TReader : IReader
{
ev = new Game.Events.JournalEvent();
ev.Deserialize(reader); // reads m_JournalEntity from the reader
}