Table of Contents

Class EventData

Namespace
FishMMO.Shared.Core
Assembly
FishMMO.Shared.dll

Container for event-related data in the ECA trigger system.

Carries three first-class fields so triggers, conditions and actions never have to hunt through typed sub-payloads to find the basic identities involved in an event:

  • Initiator — the single character that started the trigger (immutable).
  • Target — the GameObject the trigger is acting on (mutable; set by selectors / collision dispatch).
  • TargetCharacter — the ICharacter on Target, when one exists.
  • RNG — optional deterministic RNG carried alongside hit events.

Phase-specific data (collision, tick, spawn, damage amount, …) is still stored as typed sub-payloads accessible via TryGet<T>(out T).

public class EventData
Inheritance
EventData
Derived
Inherited Members

Constructors

EventData(ICharacter, params EventData[])

Constructs a new EventData with no target, optionally seeded with extra payloads.

public EventData(ICharacter initiator, params EventData[] initialData)

Parameters

initiator ICharacter

The character that initiated the event.

initialData EventData[]

Optional initial sub-payloads to add.

EventData(ICharacter, ICharacter, DeterministicRNG)

Constructs a new EventData targeting an ICharacter. The character's GameObject is also assigned to Target for consumers that want a GameObject reference.

public EventData(ICharacter initiator, ICharacter targetCharacter, DeterministicRNG rng = null)

Parameters

initiator ICharacter

The character that initiated the event.

targetCharacter ICharacter

The character being targeted.

rng DeterministicRNG

Optional deterministic RNG.

EventData(ICharacter, GameObject, DeterministicRNG)

Constructs a new EventData targeting a UnityEngine.GameObject. When the GameObject has an ICharacter component it is auto-assigned to TargetCharacter.

public EventData(ICharacter initiator, GameObject target, DeterministicRNG rng = null)

Parameters

initiator ICharacter

The character that initiated the event.

target GameObject

The GameObject being targeted.

rng DeterministicRNG

Optional deterministic RNG.

Properties

ConditionFilter

Optional ambient filter applied to every condition evaluation occurring within this trigger fire. When non-null, returning false from the filter causes the condition to be skipped (treated as if not present) at every level — top-level Conditions, nested CompositeCondition children, and selector-scoped AreConditionsMet(GameObject, EventData) calls. Carried across Fork(GameObject, ICharacter) so target fan-outs preserve the filter context.

Set by Execute(EventData) from ShouldEvaluateCondition(BaseCondition). Designers and authors of new triggers/selectors generally do not need to touch this.

public Func<BaseCondition, bool> ConditionFilter { get; set; }

Property Value

Func<BaseCondition, bool>

HasExplicitRNG

True when a generator was explicitly threaded onto this event rather than derived from it.

public bool HasExplicitRNG { get; }

Property Value

bool

Remarks

For diagnostics and for the few call sites that genuinely want to know whether an upstream system owns the stream. Reading it does not derive one.

Initiator

The character that initiated the event. Immutable for the lifetime of the EventData — a single trigger has exactly one initiator. To rebind initiator (e.g. reflected damage, summon procs) construct a new EventData.

public ICharacter Initiator { get; }

Property Value

ICharacter

RNG

The deterministic RNG for this event. An explicitly threaded generator (the ability object's, for a hit) is returned as-is; otherwise one is derived on first use from the event's own identity and cached.

public DeterministicRNG RNG { get; set; }

Property Value

DeterministicRNG

Remarks

Never null, and never the shared instance. It used to be null for every event type that was not an ability collision — AbilityEventData, RegionEventData, BuffEventData — and every consumer coped by falling back to Shared, a process-wide stream seeded from Environment.TickCount. That is not a fallback, it is a different answer on every peer and on every run: a random target selector picking out of the same five candidates picked a different one on the client than on the server, and a different one again the next time the same cast happened.

The derived stream is a function of the initiator's network identity and the event's tick, both of which every peer agrees on, so the same event yields the same rolls everywhere. Two events in the same tick from the same initiator share a stream deliberately: they are the same event as far as reproduction is concerned. Where a caller needs an independent reproducible stream — a selector that must not consume the rolls a later action expects — it takes one from DeriveRNG(int) with its own salt.

Target

The GameObject the trigger is currently targeting. Mutable so target selectors can reuse a single EventData while iterating selected candidates. May be null for world-level events.

public GameObject Target { get; set; }

Property Value

GameObject

TargetCharacter

The character on Target, when the target GameObject implements ICharacter. May be null for non-character targets or world events.

public ICharacter TargetCharacter { get; set; }

Property Value

ICharacter

Methods

Add(EventData)

Adds an event data sub-payload, keyed by its concrete type. Refuses to overwrite the self-registration that wires this into the dictionary. To copy sub-payloads from another EventData, use Merge(EventData).

public void Add(EventData data)

Parameters

data EventData

The event data sub-payload to add.

AddRange(EventData[])

Adds multiple sub-payloads, ignoring nulls.

public void AddRange(EventData[] payloads)

Parameters

payloads EventData[]

Sub-payloads to add.

Contains<T>()

Checks if a sub-payload of type T exists. Honors the same inheritance fallback as TryGet<T>(out T).

public bool Contains<T>() where T : EventData

Returns

bool

True if found; otherwise, false.

Type Parameters

T

The type of event data to check for.

DeriveRNG(int)

Builds a reproducible generator for this event, independent of any other stream.

public DeterministicRNG DeriveRNG(int salt)

Parameters

salt int

Distinguishes one consumer from another within the same event. Use a constant per call site; anything derived from local state would defeat the point.

Returns

DeterministicRNG

A generator whose sequence is identical on every peer for the same event.

DeriveSeed(int, uint, int)

The seed mix behind DeriveRNG(int), as a pure function.

public static int DeriveSeed(int identity, uint tick, int salt)

Parameters

identity int

The initiator's network object id, or its character id.

tick uint

The event's tick, or 0 when it carries none.

salt int

Per-call-site constant.

Returns

int

Remarks

FNV-1a over the three inputs. Separated out so the properties that matter — same inputs give the same seed, a different tick gives a different one — are testable without an event, a character or a network.

Fork(GameObject, ICharacter)

Creates a new EventData sharing this instance's Initiator and RNG, with all sub-payloads merged in, but with a new Target (and inferred TargetCharacter). Used by selectors to scope an event to one of several selected targets without losing the original phase-specific payloads.

public EventData Fork(GameObject target, ICharacter targetCharacter = null)

Parameters

target GameObject

The new target GameObject. May be null.

targetCharacter ICharacter

Optional pre-resolved character on target.

Returns

EventData

A new event data scoped to the supplied target.

Merge(EventData)

Copies every sub-payload from source into this event data. Use when wrapping or re-targeting an existing event so downstream conditions/actions continue to see the original phase-specific payloads (e.g. RegionEventData, QuestEventData) carried on the source.

public void Merge(EventData source)

Parameters

source EventData

The event data whose sub-payloads should be merged into this one.

SetTarget(GameObject)

Sets Target and infers TargetCharacter from the GameObject's ICharacter component (if any).

public void SetTarget(GameObject target)

Parameters

target GameObject

The GameObject being targeted, or null to clear.

SetTarget(GameObject, ICharacter)

Sets both Target and TargetCharacter at once when both are already resolved by the caller (avoids a redundant GetComponent).

public void SetTarget(GameObject target, ICharacter targetCharacter)

Parameters

target GameObject

The GameObject being targeted.

targetCharacter ICharacter

The character on target.

ToString()

Returns the type name of this event data instance.

public override string ToString()

Returns

string

TryGet<T>(out T)

Attempts to retrieve a sub-payload of type T. Performs an exact-type lookup first (the fast path); if no payload is registered under that exact key, falls back to a linear scan returning the first stored payload assignable to T. This lets callers request a base type (e.g. TryGet<AbilityCollisionEventData>()) and still receive a designer-authored subclass payload.

public bool TryGet<T>(out T data) where T : EventData

Parameters

data T

The retrieved sub-payload, or default if not found.

Returns

bool

True if found; otherwise, false.

Type Parameters

T

The type of event data to retrieve.