Game.Events.EventJournalUtils
Assembly: Assembly-CSharp
Namespace: Game.Events
Type: static class
Base: System.Object
Summary:
Utility helpers for reading and interpreting event journal buffers used by the game's event system. Provides simple validation helpers for tracking enums and methods to extract tracked values from DynamicBuffer
Fields
- This static class defines no instance or static fields.
{{ No internal state; methods operate only on input parameters (buffers and enum values). }}
Properties
- This class exposes no properties.
{{ No getters/setters; purely functional helpers. }}
Constructors
- No public constructors (static class).
{{ The class has no instance lifecycle; the CLR static type initializer is implicit and not used. }}
Methods
-
public static bool IsValid(EventDataTrackingType type)
{{ Returns true if the supplied EventDataTrackingType value lies within the valid tracked range (>= EventDataTrackingType.Damages and < EventDataTrackingType.Count). Use this to guard lookups on buffers containing EventJournalData. }} -
public static bool IsValid(EventCityEffectTrackingType type)
{{ Returns true if the supplied EventCityEffectTrackingType value lies within the valid tracked range (>= EventCityEffectTrackingType.Crime and < EventCityEffectTrackingType.Count). Use this to validate lookups on buffers containing EventJournalCityEffect. }} -
public static int GetValue(DynamicBuffer<EventJournalData> data, EventDataTrackingType type)
{{ Iterates the provided DynamicBufferand returns the m_Value for the first entry whose m_Type matches the requested EventDataTrackingType. Returns 0 if the type is invalid or no matching entry is found. Complexity: O(n) in buffer length. }} -
public static int GetValue(DynamicBuffer<EventJournalCityEffect> effects, EventCityEffectTrackingType type)
{{ Iterates the provided DynamicBufferand returns the percentile change computed for the first entry whose m_Type matches the requested EventCityEffectTrackingType. Uses GetPercentileChange to produce the returned integer. Returns 0 if the type is invalid or no matching entry is found. Complexity: O(n) in buffer length. }} -
public static int GetPercentileChange(EventJournalCityEffect effect)
{{ Computes and returns the percent change between effect.m_StartValue and effect.m_Value, rounded to the nearest integer. Returns 0 if m_StartValue is zero to avoid division by zero. Implementation uses UnityEngine.Mathf.RoundToInt. }}
Usage Example
// Example usage from a system or other code that has access to DynamicBuffer<T>:
// (Using Unity.Entities and the event data types defined elsewhere in the game.)
// Read a simple tracked integer value (e.g., Damages)
DynamicBuffer<EventJournalData> journalData = entityManager.GetBuffer<EventJournalData>(someEntity);
if (EventJournalUtils.IsValid(EventDataTrackingType.Damages))
{
int damages = EventJournalUtils.GetValue(journalData, EventDataTrackingType.Damages);
// use damages...
}
// Read a city-effect percent change (e.g., Crime)
DynamicBuffer<EventJournalCityEffect> effects = entityManager.GetBuffer<EventJournalCityEffect>(someEntity);
if (EventJournalUtils.IsValid(EventCityEffectTrackingType.Crime))
{
int crimePercentChange = EventJournalUtils.GetValue(effects, EventCityEffectTrackingType.Crime);
// use crimePercentChange...
}
// Directly compute percentile change for a single effect record:
EventJournalCityEffect someEffect = effects[0];
int percent = EventJournalUtils.GetPercentileChange(someEffect);
{{ Notes:
- The utility expects the buffer element types to expose fields named m_Type, m_Value, and for city effects m_StartValue (as used by the implementations).
- All GetValue methods return 0 if the requested type is invalid or not present in the buffer.
- Methods perform linear scans; if you frequently query many types, consider caching or organizing buffer content for faster lookups.
- Uses Unity.Entities.DynamicBuffer