Skip to main content

TrackedEvent<T>

A class in Root.Township, the global namespace.

A delegate list you add to with + and fire with Invoke, which remembers whether it has fired. Used for the client's entity-spawned listeners and as the base of OneTimeEvent<T>.

Constructors​

MemberWhat it is
TrackedEvent()Creates a TrackedEvent with default values.

Fields​

MemberWhat it is
protected readonly List<T> eventHandlersThe handlers added so far.
protected readonly List<T> eventHandlersBufferCopy of the handlers used during Invoke, so handlers can remove themselves safely.
1 private and internal field
MemberWhat it is
private static readonly Logger loggerShared logger (the AltaEvent logger) for parameter mismatches and handler exceptions.

Properties​

MemberWhat it is
bool IsInvoked { get; set; }True once Invoke has run.

Methods​

MemberWhat it is
void Clear()Removes every handler.
virtual void Invoke(params object[] args)Calls every handler with the arguments, last added first, then sets IsInvoked. Logs and skips if the arguments don't match.
static TrackedEvent<T> op_Addition(TrackedEvent<T> altaEvent, T eventHandler)Adds a handler and returns the same event.
static TrackedEvent<T> op_Subtraction(TrackedEvent<T> altaEvent, T eventHandler)Removes a handler and returns the same event.
protected bool HasCorrectParameters(object[] args)Checks the arguments match the first handler's parameter types. True when there are no handlers.
protected void InvokeHandler(T handler, object[] args)Calls one handler, logging any exception instead of throwing it.

Used in​

Members of other types that take, return or hold a TrackedEvent&lt;T>: