com.pakforge.eventcontainers 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Runtime/BoolEventChannel.cs +7 -0
- package/Runtime/BoolEventChannel.cs.meta +3 -0
- package/Runtime/EmptyEventChannel.cs +7 -0
- package/Runtime/EmptyEventChannel.cs.meta +3 -0
- package/Runtime/EventChannel.cs +78 -0
- package/Runtime/EventChannel.cs.meta +2 -0
- package/Runtime/FloatEventChannel.cs +7 -0
- package/Runtime/FloatEventChannel.cs.meta +3 -0
- package/Runtime/IntEventChannel.cs +7 -0
- package/Runtime/IntEventChannel.cs.meta +3 -0
- package/Runtime/StringEventChannel.cs +7 -0
- package/Runtime/StringEventChannel.cs.meta +3 -0
- package/Runtime/com.pakforge.eventcontainers.asmdef +14 -0
- package/Runtime/com.pakforge.eventcontainers.asmdef.meta +7 -0
- package/Runtime.meta +8 -0
- package/package.json +14 -0
- package/package.json.meta +7 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
using UnityEngine;
|
|
2
|
+
|
|
3
|
+
namespace PakForge.EventContainers
|
|
4
|
+
{
|
|
5
|
+
/// <summary>
|
|
6
|
+
/// Base class to maintain and raise events with no arguments
|
|
7
|
+
/// </summary>
|
|
8
|
+
public abstract class EventChannel : ScriptableObject
|
|
9
|
+
{
|
|
10
|
+
public delegate void ChannelEvent();
|
|
11
|
+
private event ChannelEvent EventRaised;
|
|
12
|
+
|
|
13
|
+
private void OnEnable() => EventRaised = null;
|
|
14
|
+
private void OnDisable() => EventRaised = null;
|
|
15
|
+
|
|
16
|
+
public void RaiseEvent() => EventRaised?.Invoke();
|
|
17
|
+
|
|
18
|
+
public void Add(ChannelEvent channelEvent) => EventRaised += channelEvent;
|
|
19
|
+
public void Remove(ChannelEvent channelEvent) => EventRaised -= channelEvent;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/// <summary>
|
|
23
|
+
/// Base class to maintain and raise events with one argument
|
|
24
|
+
/// </summary>
|
|
25
|
+
/// <typeparam name="T">Value argument to pass</typeparam>
|
|
26
|
+
public abstract class EventChannel<T> : ScriptableObject
|
|
27
|
+
{
|
|
28
|
+
public delegate void ChannelEvent(T arg);
|
|
29
|
+
private event ChannelEvent EventRaised;
|
|
30
|
+
|
|
31
|
+
private void OnEnable() => EventRaised = null;
|
|
32
|
+
private void OnDisable() => EventRaised = null;
|
|
33
|
+
|
|
34
|
+
public void RaiseEvent(T arg) => EventRaised?.Invoke(arg);
|
|
35
|
+
|
|
36
|
+
public void Add(ChannelEvent channelEvent) => EventRaised += channelEvent;
|
|
37
|
+
public void Remove(ChannelEvent channelEvent) => EventRaised -= channelEvent;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/// <summary>
|
|
41
|
+
/// Base class to maintain and raise events with one argument
|
|
42
|
+
/// </summary>
|
|
43
|
+
/// <typeparam name="T1">First value argument to pass</typeparam>
|
|
44
|
+
/// <typeparam name="T2">Second value argument to pass</typeparam>
|
|
45
|
+
public abstract class EventChannel<T1, T2> : ScriptableObject
|
|
46
|
+
{
|
|
47
|
+
public delegate void ChannelEvent(T1 arg1, T2 arg2);
|
|
48
|
+
private event ChannelEvent EventRaised;
|
|
49
|
+
|
|
50
|
+
private void OnEnable() => EventRaised = null;
|
|
51
|
+
private void OnDisable() => EventRaised = null;
|
|
52
|
+
|
|
53
|
+
public void RaiseEvent(T1 arg1, T2 arg2) => EventRaised?.Invoke(arg1, arg2);
|
|
54
|
+
|
|
55
|
+
public void Add(ChannelEvent channelEvent) => EventRaised += channelEvent;
|
|
56
|
+
public void Remove(ChannelEvent channelEvent) => EventRaised -= channelEvent;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/// <summary>
|
|
60
|
+
/// Base class to maintain and raise events with one argument
|
|
61
|
+
/// </summary>
|
|
62
|
+
/// <typeparam name="T1">First value argument to pass</typeparam>
|
|
63
|
+
/// <typeparam name="T2">Second value argument to pass</typeparam>
|
|
64
|
+
/// <typeparam name="T3">Third value argument to pass</typeparam>
|
|
65
|
+
public abstract class EventChannel<T1, T2, T3> : ScriptableObject
|
|
66
|
+
{
|
|
67
|
+
public delegate void ChannelEvent(T1 arg1, T2 arg2, T3 arg3);
|
|
68
|
+
private event ChannelEvent EventRaised;
|
|
69
|
+
|
|
70
|
+
private void OnEnable() => EventRaised = null;
|
|
71
|
+
private void OnDisable() => EventRaised = null;
|
|
72
|
+
|
|
73
|
+
public void RaiseEvent(T1 arg1, T2 arg2, T3 arg3) => EventRaised?.Invoke(arg1, arg2, arg3);
|
|
74
|
+
|
|
75
|
+
public void Add(ChannelEvent channelEvent) => EventRaised += channelEvent;
|
|
76
|
+
public void Remove(ChannelEvent channelEvent) => EventRaised -= channelEvent;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "com.pakforge.eventcontainers",
|
|
3
|
+
"rootNamespace": "PakForge.EventContainers",
|
|
4
|
+
"references": [],
|
|
5
|
+
"includePlatforms": [],
|
|
6
|
+
"excludePlatforms": [],
|
|
7
|
+
"allowUnsafeCode": false,
|
|
8
|
+
"overrideReferences": false,
|
|
9
|
+
"precompiledReferences": [],
|
|
10
|
+
"autoReferenced": true,
|
|
11
|
+
"defineConstraints": [],
|
|
12
|
+
"versionDefines": [],
|
|
13
|
+
"noEngineReferences": false
|
|
14
|
+
}
|
package/Runtime.meta
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "com.pakforge.eventcontainers",
|
|
3
|
+
"displayName": "PakForge EventContainers",
|
|
4
|
+
"description": "Event bus system through ScriptableObjects",
|
|
5
|
+
"version": "0.0.2",
|
|
6
|
+
"unity": "6000.3",
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "Marc Robbins",
|
|
9
|
+
"email": "marccrobbins@gmail.com"
|
|
10
|
+
},
|
|
11
|
+
"hideInEditor": false,
|
|
12
|
+
"type": "library",
|
|
13
|
+
"dependencies": {}
|
|
14
|
+
}
|