1- using System ;
1+ using Bolt . Addons . Community . DefinedEvents . Units ;
2+ using System ;
23using System . Collections . Generic ;
34using System . Linq ;
45using System . Text ;
@@ -17,7 +18,7 @@ public static class DefinedEvent
1718 /// <param name="eventData">This is a filled object of the type of event you want to trigger.</param>
1819 public static void Trigger ( GameObject target , object eventData )
1920 {
20- Bolt . Addons . Community . DefinedEvents . Units . DefinedEvent . Trigger ( target , eventData ) ;
21+ DefinedEventUnit . Trigger ( target , eventData ) ;
2122 }
2223
2324 /// <summary>
@@ -28,7 +29,37 @@ public static void Trigger(GameObject target, object eventData)
2829 /// <param name="eventData">This is a filled object of the type of event you want to trigger.</param>
2930 public static void TriggerGlobal ( object eventData )
3031 {
31- Bolt . Addons . Community . DefinedEvents . Units . GlobalDefinedEvent . Trigger ( eventData ) ;
32+ GlobalDefinedEventUnit . Trigger ( eventData ) ;
33+ }
34+
35+ /// <summary>
36+ /// Registers a C# listener for an event on the target object. This is the scripting
37+ /// equivalent to the Defined Event unit. Notice the IDisposable return value, which allows you
38+ /// to end the subscription for the event (via calling the .Dispose() method).
39+ /// </summary>
40+ /// <typeparam name="T">The type to listen for.</typeparam>
41+ /// <param name="target">The game object to listen on to receive the event.</param>
42+ /// <param name="onEvent">The action or method to call when the event occurs</param>
43+ /// <returns>A disposable that, when .Dispose is called, will unsubscribe from the
44+ /// event, essentially cancelling the call to RegisterListener.</returns>
45+ public static IDisposable RegisterListener < T > ( GameObject target , Action < T > onEvent )
46+ {
47+ return DefinedEventUnit . RegisterListener < T > ( target , onEvent ) ;
48+ }
49+
50+ /// <summary>
51+ /// Registers a C# listener for an event globally. This is the scripting
52+ /// equivalent to the Global Defined Event unit. Notice the IDisposable return
53+ /// value, which allows you to end the subscription for the event (via calling
54+ /// the .Dispose() method).
55+ /// </summary>
56+ /// <typeparam name="T">The type to listen for.</typeparam>
57+ /// <param name="onEvent">The action or method to call when the event occurs</param>
58+ /// <returns>A disposable that, when .Dispose is called, will unsubscribe from the
59+ /// event, essentially cancelling the call to RegisterListener.</returns>
60+ public static IDisposable RegisterGlobalListener < T > ( Action < T > onEvent )
61+ {
62+ return GlobalDefinedEventUnit . RegisterListener < T > ( onEvent ) ;
3263 }
3364 }
34- }
65+ }
0 commit comments