summaryrefslogtreecommitdiff
path: root/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/InvokableEvent.cs
blob: dd9db655d87f18ae752df69608c88b15ccb7bfac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
using System;

public class InvokableEvent : InvokableEventBase {

	public System.Action action;

	public void Invoke() {
		action();
	}

	public override void Invoke(params object[] args) {
		action();
	}

	/// <summary> Constructor </summary>
	public InvokableEvent(object target, string methodName) {
		if (target == null || string.IsNullOrEmpty(methodName)) {
			action = () => { };
		} else {
			action = (System.Action) System.Delegate.CreateDelegate(typeof(System.Action), target, methodName);
		}
	}
}

public class InvokableEvent<T0> : InvokableEventBase {

	public Action<T0> action;

	public void Invoke(T0 arg0) {
		action(arg0);
	}

	public override void Invoke(params object[] args) {
		action((T0) args[0]);
	}

	/// <summary> Constructor </summary>
	public InvokableEvent(object target, string methodName) {
		if (target == null || string.IsNullOrEmpty(methodName)) {
			action = x => { };
		} else {
			action = (System.Action<T0>) System.Delegate.CreateDelegate(typeof(System.Action<T0>), target, methodName);
		}
	}
}

public class InvokableEvent<T0, T1> : InvokableEventBase {

	public Action<T0, T1> action;

	public void Invoke(T0 arg0, T1 arg1) {
		action(arg0, arg1);
	}

	public override void Invoke(params object[] args) {
		action((T0) args[0], (T1) args[1]);
	}

	/// <summary> Constructor </summary>
	public InvokableEvent(object target, string methodName) {
		if (target == null || string.IsNullOrEmpty(methodName)) {
			action = (x, y) => { };
		} else {
			action = (System.Action<T0, T1>) System.Delegate.CreateDelegate(typeof(System.Action<T0, T1>), target, methodName);
		}
	}
}

public class InvokableEvent<T0, T1, T2> : InvokableEventBase {

	public Action<T0, T1, T2> action;

	public void Invoke(T0 arg0, T1 arg1, T2 arg2) {
		action(arg0, arg1, arg2);
	}

	public override void Invoke(params object[] args) {
		action((T0) args[0], (T1) args[1], (T2) args[2]);
	}

	/// <summary> Constructor </summary>
	public InvokableEvent(object target, string methodName) {
		if (target == null || string.IsNullOrEmpty(methodName)) {
			action = (x, y, z) => { };
		} else {
			action = (System.Action<T0, T1, T2>) System.Delegate.CreateDelegate(typeof(System.Action<T0, T1, T2>), target, methodName);
		}
	}
}

public class InvokableEvent<T0, T1, T2, T3> : InvokableEventBase {

	public Action<T0, T1, T2, T3> action;

	public void Invoke(T0 arg0, T1 arg1, T2 arg2, T3 arg3) {
		action(arg0, arg1, arg2, arg3);
	}

	public override void Invoke(params object[] args) {
		action((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3]);
	}

	/// <summary> Constructor </summary>
	public InvokableEvent(object target, string methodName) {
		if (target == null || string.IsNullOrEmpty(methodName)) {
			action = (x, y, z, w) => { };
		} else {
			action = (System.Action<T0, T1, T2, T3>) System.Delegate.CreateDelegate(typeof(System.Action<T0, T1, T2, T3>), target, methodName);
		}
	}
}