Skip to content

Game.Prefabs.JournalEventComponent

Assembly:
Assembly-CSharp

Namespace:
Game.Prefabs

Type:
Class

Base:
ComponentBase

Summary:
JournalEventComponent is a prefab authoring component used during prefab-to-entity conversion. It provides configuration for journal (event) prefabs: an icon and lists of tracked event data and tracked city effects. During initialization it writes a JournalEventPrefabData component onto the entity containing bitmask flags computed from the configured tracked entries. The component also ensures the archetype includes a JournalEvent runtime component.


Fields

  • public string m_Icon
    Human-readable icon identifier or path for the journal event. Typically set in the prefab inspector to point to an icon resource used by the UI.

  • public EventDataTrackingType[] m_TrackedData
    Array of EventDataTrackingType entries that specify which pieces of event data this journal event should track. Used to build a bitmask (data flags) during initialization.

  • public EventCityEffectTrackingType[] m_TrackedCityEffects
    Array of EventCityEffectTrackingType entries that specify which city effects this journal event should track. Used to build a bitmask (effect flags) during initialization.

Properties

  • None

Constructors

  • public JournalEventComponent()
    Default constructor (implicit). Instances are typically created by the Unity editor when adding the component to a prefab.

Methods

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Adds runtime archetype components required by this prefab. Implementation adds ComponentType.ReadWrite<JournalEvent>() so entities created from this prefab will include the JournalEvent component.

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds prefab/component-data types that should be present on the prefab entity. Implementation adds ComponentType.ReadWrite<JournalEventPrefabData>(), which will be filled in during Initialize.

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Called during prefab conversion to entity. This implementation:

  • Calls base.Initialize(...)
  • Writes a JournalEventPrefabData component to the entity, with two integer fields:

    • m_DataFlags — bitmask produced by GetDataFlags()
    • m_EffectFlags — bitmask produced by GetEffectFlags() This stores which tracked data/effects this event wants monitored at runtime.
  • public int GetDataFlags()
    Computes and returns an integer bitmask representing entries in m_TrackedData. For each valid entry (EventJournalUtils.IsValid(...) returns true) the method sets the bit at position (int)entry. The resulting bitmask is suitable for storing or comparing tracked data flags.

  • public int GetEffectFlags()
    Computes and returns an integer bitmask representing entries in m_TrackedCityEffects. For each valid entry the method sets the bit at position (int)entry. The resulting bitmask is stored in JournalEventPrefabData.m_EffectFlags.

Usage Example

// Example: how the prefab conversion/initialization uses this component.
// Typically another conversion pipeline will call Initialize on all prefab components.

[Preserve]
public class ExampleJournalConversion : MonoBehaviour, IConvertGameObjectToEntity
{
    public JournalEventComponent journalComponent; // assigned on the prefab

    public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
    {
        // During conversion, JournalEventComponent.Initialize will add JournalEventPrefabData
        // with data/effect flags computed from the arrays configured on the prefab.
        journalComponent.Initialize(dstManager, entity);

        // You can also inspect the computed flags if needed:
        int dataFlags = journalComponent.GetDataFlags();
        int effectFlags = journalComponent.GetEffectFlags();
        // Use flags for custom logic, logging, or validation during conversion.
    }
}

Notes: - EventJournalUtils.IsValid(...) is used to ignore invalid enum entries when building bitmasks. - The bit positions correspond to the integer values of EventDataTrackingType and EventCityEffectTrackingType enums. Ensure enum values fit within the integer bitmask space.