KSP API
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
EventData< T > Class Template Reference

A type used to generate GameEvents More...

Public Member Functions

 EventData (string eventName)
 The constructor used to create a new EventData More...
 
void Add (EventData< T >.OnEvent evt)
 Add a method to be run when the EventData is fired. More...
 
void Fire (T data)
 Triggers the EventData More...
 
void Remove (EventData< T >.OnEvent evt)
 Remove a method from the list of methods to be run when the EventData is fired. More...
 
delegate void OnEvent (T data)
 Any methods added to the event must match the delegate's parameters; one parameter of the given type in this case. More...
 

Static Public Member Functions

static bool AddEventScene (string eventName, EventData< T >.OnEvent evt, bool addToAll)
 
static bool AddEventUpwards (Transform transform, string eventName, EventData< T >.OnEvent evt, bool addToAll)
 
static EventData< T > FindEventScene (string eventName)
 
static List< EventData< T > > FindEventsScene (string eventName)
 
static List< EventData< T > > FindEventsUpwards (Transform transform, string eventName)
 
static EventData< T > FindEventUpwards (Transform transform, string eventName)
 
static bool RemoveEventScene (string eventName, EventData< T >.OnEvent evt, bool removeFromAll)
 
static bool RemoveEventUpwards (Transform transform, string eventName, EventData< T >.OnEvent evt, bool removeFromAll)
 

Public Attributes

bool debugEvent
 Generate debug logs if true More...
 

Detailed Description

A type used to generate GameEvents

Use this type with one accompanying type; GameEvents.FromToAction, GameEvents.HostedFromToAction, GameEvents.HostTargetAction are commonly used

See EventVoid for events that require no parameters or EventReport for a different style

Template Parameters
TThe type to be passed through on EventData.Fire()

Constructor & Destructor Documentation

EventData< T >.EventData ( string  eventName)

The constructor used to create a new EventData

EventData<Vessel> myNewEvent = new EventData<Vessel>("myNewEvent");

Parameters
eventNameGive the event a string name, generally the same as the declared name

Member Function Documentation

void EventData< T >.Add ( EventData< T >.OnEvent  evt)

Add a method to be run when the EventData is fired.

This is generally done in an object's Start or Awake method, or a class' constructor.

Can be setup like:

GameEvents.someEventDataEvent.Add(yourMethod);

or

GameEvents.someEventDataEvent.Add(new EventVoid.OnEvent(yourMethod));

Parameters
evtThe method you want to add; must contain a single parameter of the type matching that in the host EventData
static bool EventData< T >.AddEventScene ( string  eventName,
EventData< T >.OnEvent  evt,
bool  addToAll 
)
static
static bool EventData< T >.AddEventUpwards ( Transform  transform,
string  eventName,
EventData< T >.OnEvent  evt,
bool  addToAll 
)
static
static EventData<T> EventData< T >.FindEventScene ( string  eventName)
static
static List<EventData<T> > EventData< T >.FindEventsScene ( string  eventName)
static
static List<EventData<T> > EventData< T >.FindEventsUpwards ( Transform  transform,
string  eventName 
)
static
static EventData<T> EventData< T >.FindEventUpwards ( Transform  transform,
string  eventName 
)
static
void EventData< T >.Fire ( data)

Triggers the EventData

All of the methods added using Add are run after this.

Parameters
dataSingle parameter matching the type of the host EventData Use this to give information relevant to the event
delegate void EventData< T >.OnEvent ( data)

Any methods added to the event must match the delegate's parameters; one parameter of the given type in this case.

Parameters
data
void EventData< T >.Remove ( EventData< T >.OnEvent  evt)

Remove a method from the list of methods to be run when the EventData is fired.

This is generally done in an object's OnDestroy method.

Parameters
evtThe method you want to remove; must contain a single parameter of a type matching that in the host EventData
static bool EventData< T >.RemoveEventScene ( string  eventName,
EventData< T >.OnEvent  evt,
bool  removeFromAll 
)
static
static bool EventData< T >.RemoveEventUpwards ( Transform  transform,
string  eventName,
EventData< T >.OnEvent  evt,
bool  removeFromAll 
)
static

Member Data Documentation

bool EventData< T >.debugEvent

Generate debug logs if true


The documentation for this class was generated from the following file: