Word Game Builder 2.0.1f2
Reference Manual
Public Member Functions | Static Public Member Functions | Properties | List of all members
WGBEvent Class Reference

A serializable class for event binding. More...

+ Collaboration diagram for WGBEvent:

Public Member Functions

 WGBEvent (MonoBehaviour target, string methodName)
 Creates an event with a target MonoBehaviour and method name. More...
 
 WGBEvent (GameObject target, string methodName)
 Creates an event with a target GameObject and method name (uses SendMessage). More...
 
 WGBEvent (WGBEventDelegate del)
 Creates an event from a delegate. More...
 
 WGBEvent (WGBEventDelegate del, string name)
 Creates an event from a delegate and an optional name. More...
 
void Add (MonoBehaviour target, string methodName)
 Adds a MonoBehaviour and method name to this event. More...
 
void Add (GameObject target, string methodName)
 Adds a GameObject and method name to this event (Uses SendMessage). More...
 
void Add (WGBEventDelegate del)
 Adds a delegate to this event. More...
 
void Add (WGBEventDelegate del, string name)
 Adds a delegate to the event with an optional name. More...
 
WGBEventDelegate GetDelegate ()
 Gets the raw delegate value. More...
 
IList< WGBEventGetInvocationList ()
 Gets all individual events associated with this object. More...
 
void Invoke ()
 Invokes the event directly. This will never run outside of play mode. More...
 
void InvokeUnsafe ()
 Invokes the event directly. This can run in the editor, and therefore corrupt state! Use carefully. More...
 
bool Remove (MonoBehaviour target, string methodName)
 Remove the first instance of an event by MonoBehaviour and method name. More...
 
bool Remove (GameObject target, string methodName)
 Remove the first instance of an event by GameObject and method name. More...
 
bool Remove (WGBEventDelegate del)
 Remove the first instance of an event by a delegate. More...
 
bool Remove (WGBEventDelegate del, string name)
 Remove the first instance of an event by a delegate and name. More...
 
bool Remove (WGBEvent evt)
 Remove the first instance of an event. More...
 
void SetDelegate (MonoBehaviour target, string methodName)
 Sets the event with a MonoBehaviour and method name. More...
 
void SetDelegate (GameObject target, string methodName)
 Sets the event with a GameObject and method name (Uses SendMessage). More...
 
void SetDelegate (WGBEventDelegate del)
 Sets the event with a delegate. More...
 
void SetDelegate (WGBEventDelegate del, string name)
 Sets the event with a delegate and an optional name. More...
 

Static Public Member Functions

static void Invoke (WGBEvent evt, WordGameLanguage currentLanguage, ILetterTile currentLetterTile, ITilePool currentTilePool, IWildcardTileManager currentWildcardTileManager, IWordGamePlayer currentPlayer, IWordGameAgent currentAgent, System.Action additionalPreCallback=null, System.Action additionalPostCallback=null)
 Invoke an event with the current event state. More...
 
static implicit operator bool (WGBEvent e)
 Boolean operator. Returns true if the event is both not null and not empty. More...
 
static WGBEvent operator+ (WGBEvent e, WGBEventDelegate del)
 Add operator. Provides .NET-like syntax for adding delegates to an event (on____ += myDelegate). More...
 
static WGBEvent operator- (WGBEvent e, WGBEventDelegate del)
 Subtract operator. Provides .NET-like syntax for removing delegates from an event (on___ -= myDelegate). More...
 

Properties

static IWordGameAgent currentAgent [get]
 Gets the current agent. This can only be used during event callbacks, for events invoked with the static Invoke method. More...
 
static WordGameLanguage currentLanguage [get]
 Gets the current language. This can only be used during event callbacks, for events invoked with the static Invoke method. More...
 
static ILetterTile currentLetterTile [get]
 Gets the current letter tile. This can only be used during event callbacks, for events invoked with the static Invoke method. More...
 
static IWordGamePlayer currentPlayer [get]
 Gets the current player. This can only be used during event callbacks, for events invoked with the static Invoke method. More...
 
static ITilePool currentTilePool [get]
 Gets the current tile pool. This can only be used during event callbacks, for events invoked with the static Invoke method. More...
 
static IWildcardTileManager currentWildcardTileManager [get]
 Gets the current wildcard tile manager. This can only be used during event callbacks, for events invoked with the static Invoke method. More...
 
bool isDelegate [get]
 If true, this event is a delegate. In the case of multiple events, this is based on the first added value. More...
 
string methodName [get]
 The event method name. In the case of multiple events, this is based on the first added value. More...
 
string rawMethodName [get]
 The event raw method name, without namespace or any other qualifiers. In the case of multiple events, this is based on the first added value. More...
 
MonoBehaviour target [get]
 The event target. In the case of multiple events, this is based on the first added value. More...
 
GameObject targetGameObject [get]
 The event target's GameObject. In the case of multiple events, this is based on the first added value. More...
 

Detailed Description

A serializable class for event binding.

Events can be bound (public MonoBehaviour methods), use SendMessage (GameObject and method name), or use delegates. This class supports multicast events, and is safe (it will not throw exceptions for missing delegates or methods).

Constructor & Destructor Documentation

WGBEvent ( MonoBehaviour  target,
string  methodName 
)
inline

Creates an event with a target MonoBehaviour and method name.

Parameters
targetThe MonoBehaviour with the method to search for.
methodNameThe name of the method to search for.
WGBEvent ( GameObject  target,
string  methodName 
)
inline

Creates an event with a target GameObject and method name (uses SendMessage).

Parameters
targetThe GameObject with the method to search for.
methodNameThe name of the method to search for.
WGBEvent ( WGBEventDelegate  del)
inline

Creates an event from a delegate.

Parameters
delThe delegate to search for.
WGBEvent ( WGBEventDelegate  del,
string  name 
)
inline

Creates an event from a delegate and an optional name.

Parameters
delThe delegate to search for.
nameThe name of the delegate to search for.

Member Function Documentation

void Add ( MonoBehaviour  target,
string  methodName 
)
inline

Adds a MonoBehaviour and method name to this event.

Parameters
targetThe MonoBehaviour with the method to search for.
methodNameThe name of the method to search for.

+ Here is the caller graph for this function:

void Add ( GameObject  target,
string  methodName 
)
inline

Adds a GameObject and method name to this event (Uses SendMessage).

Parameters
targetThe GameObject with the method to search for.
methodNameThe name of the method to search for.
void Add ( WGBEventDelegate  del)
inline

Adds a delegate to this event.

Parameters
delThe delegate to search for.
void Add ( WGBEventDelegate  del,
string  name 
)
inline

Adds a delegate to the event with an optional name.

Parameters
delThe delegate to search for.
nameThe name of the delegate to search for.
WGBEventDelegate GetDelegate ( )
inline

Gets the raw delegate value.

Returns
A .NET delegate for the event, or null if the delegate has not yet been bound, or SendMessage is being used.

+ Here is the call graph for this function:

IList<WGBEvent> GetInvocationList ( )
inline

Gets all individual events associated with this object.

Events are multicast - multiple events can be associated with a single object. This method gets all individual contained events. This allocates a new list.

Returns
A list of each event contained in this object.

+ Here is the caller graph for this function:

void Invoke ( )
inline

Invokes the event directly. This will never run outside of play mode.

When an event is invoked directly, state variables are not set.

+ Here is the caller graph for this function:

static void Invoke ( WGBEvent  evt,
WordGameLanguage  currentLanguage,
ILetterTile  currentLetterTile,
ITilePool  currentTilePool,
IWildcardTileManager  currentWildcardTileManager,
IWordGamePlayer  currentPlayer,
IWordGameAgent  currentAgent,
System.Action  additionalPreCallback = null,
System.Action  additionalPostCallback = null 
)
inlinestatic

Invoke an event with the current event state.

Events that are invoked during other event callbacks are deferred into a queue until the current event is finished.

Parameters
evtThe event to invoke.
currentLanguageThe current language (defaults to Language.current).
currentLetterTileThe current letter tile, if any.
currentTilePoolThe current tile pool, if any.
currentWildcardTileManagerThe current wildcard tile manager, if any.
currentPlayerThe current player, if any.
currentAgentThe current agent, if any.
additionalPreCallbackAn additional action that is run just before the event actually occurs.
additionalPostCallbackAn additional action that is run just after the event actually occurs.

+ Here is the call graph for this function:

void InvokeUnsafe ( )
inline

Invokes the event directly. This can run in the editor, and therefore corrupt state! Use carefully.

When an event is invoked directly, state variables are not set.

static implicit operator bool ( WGBEvent  e)
inlinestatic

Boolean operator. Returns true if the event is both not null and not empty.

Parameters
eThe event to test.
Returns
true if the event is both null and not empty, otherwise false.
static WGBEvent operator+ ( WGBEvent  e,
WGBEventDelegate  del 
)
inlinestatic

Add operator. Provides .NET-like syntax for adding delegates to an event (on____ += myDelegate).

Parameters
eThe event to add to.
delThe delegate to add to the event.
Returns
The event that was added to. This is the same object passed on the left hand side of the expression.

+ Here is the call graph for this function:

static WGBEvent operator- ( WGBEvent  e,
WGBEventDelegate  del 
)
inlinestatic

Subtract operator. Provides .NET-like syntax for removing delegates from an event (on___ -= myDelegate).

Parameters
eThe event to remove from..
delThe delegate to remove from the event.
Returns
The event that was removed from. This is the same object passed on the left hand side of the expression.

+ Here is the call graph for this function:

bool Remove ( MonoBehaviour  target,
string  methodName 
)
inline

Remove the first instance of an event by MonoBehaviour and method name.

Parameters
targetThe MonoBehaviour with the method to search for.
methodNameThe name of the method to search for.
Returns
true if the event was successfully removed, otherwise false.

+ Here is the caller graph for this function:

bool Remove ( GameObject  target,
string  methodName 
)
inline

Remove the first instance of an event by GameObject and method name.

Parameters
targetThe GameObject with the method to search for.
methodNameThe name of the method to search for.
Returns
true if the event was successfully removed, otherwise false.
bool Remove ( WGBEventDelegate  del)
inline

Remove the first instance of an event by a delegate.

Parameters
delThe delegate to search for.
Returns
true if the event was successfully removed, otherwise false.
bool Remove ( WGBEventDelegate  del,
string  name 
)
inline

Remove the first instance of an event by a delegate and name.

Parameters
delThe delegate to search for.
nameThe name of the delegate to search for.
Returns
true if the event was successfully removed, otherwise false.
bool Remove ( WGBEvent  evt)
inline

Remove the first instance of an event.

Parameters
evtThe event to remove.
Returns
true if the event was successfully removed, otherwise false.

+ Here is the call graph for this function:

void SetDelegate ( MonoBehaviour  target,
string  methodName 
)
inline

Sets the event with a MonoBehaviour and method name.

Parameters
targetThe MonoBehaviour with the method to search for.
methodNameThe name of the method to search for.

+ Here is the call graph for this function:

void SetDelegate ( GameObject  target,
string  methodName 
)
inline

Sets the event with a GameObject and method name (Uses SendMessage).

Parameters
targetThe GameObject with the method to search for.
methodNameThe name of the method to search for.
void SetDelegate ( WGBEventDelegate  del)
inline

Sets the event with a delegate.

Parameters
delThe delegate to search for.
void SetDelegate ( WGBEventDelegate  del,
string  name 
)
inline

Sets the event with a delegate and an optional name.

Parameters
delThe delegate to search for.
nameThe name of the delegate to search for.

Property Documentation

IWordGameAgent currentAgent
staticget

Gets the current agent. This can only be used during event callbacks, for events invoked with the static Invoke method.

WordGameLanguage currentLanguage
staticget

Gets the current language. This can only be used during event callbacks, for events invoked with the static Invoke method.

ILetterTile currentLetterTile
staticget

Gets the current letter tile. This can only be used during event callbacks, for events invoked with the static Invoke method.

IWordGamePlayer currentPlayer
staticget

Gets the current player. This can only be used during event callbacks, for events invoked with the static Invoke method.

ITilePool currentTilePool
staticget

Gets the current tile pool. This can only be used during event callbacks, for events invoked with the static Invoke method.

IWildcardTileManager currentWildcardTileManager
staticget

Gets the current wildcard tile manager. This can only be used during event callbacks, for events invoked with the static Invoke method.

bool isDelegate
get

If true, this event is a delegate. In the case of multiple events, this is based on the first added value.

string methodName
get

The event method name. In the case of multiple events, this is based on the first added value.

This value will be in the form of Type.Name or Type.{delegate} for delegates.

string rawMethodName
get

The event raw method name, without namespace or any other qualifiers. In the case of multiple events, this is based on the first added value.

MonoBehaviour target
get

The event target. In the case of multiple events, this is based on the first added value.

This value will be null for delegates not associated with a MonoBehaviour.

GameObject targetGameObject
get

The event target's GameObject. In the case of multiple events, this is based on the first added value.

This value will be null for delegates not associated with a Component.