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
| Member | What it is |
|---|
TrackedEvent() | Creates a TrackedEvent with default values. |
Fields
| Member | What it is |
|---|
protected readonly List<T> eventHandlers | The handlers added so far. |
protected readonly List<T> eventHandlersBuffer | Copy of the handlers used during Invoke, so handlers can remove themselves safely. |
1 private and internal field
| Member | What it is |
|---|
private static readonly Logger logger | Shared logger (the AltaEvent logger) for parameter mismatches and handler exceptions. |
Properties
| Member | What it is |
|---|
bool IsInvoked { get; set; } | True once Invoke has run. |
Methods
| Member | What 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<T>: