summaryrefslogtreecommitdiff
path: root/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableEvent.cs
blob: 9a65ef6d6014f4c06c72e34e4d9e706474fffb87 (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
112
113
114
115
116
117
118
119
120
[System.Serializable]
public class SerializableEvent : SerializableEventBase {
	public void Invoke() {
		if (invokable == null) Cache();
		if (_dynamic) {
			InvokableEvent call = invokable as InvokableEvent;
			call.Invoke();
		} else {
			invokable.Invoke(Args);
		}
	}

	protected override void Cache() {
		if (_target == null || string.IsNullOrEmpty(_methodName)) {
			invokable = new InvokableEvent(null, null);
		} else {
			if (_dynamic) {
				invokable = new InvokableEvent(target, methodName);
			} else {
				invokable = GetPersistentMethod();
			}
		}
	}
}

public abstract class SerializableEvent<T0> : SerializableEventBase {
	public void Invoke(T0 arg0) {
		if (invokable == null) Cache();
		if (_dynamic) {
			InvokableEvent<T0> call = invokable as InvokableEvent<T0>;
			call.Invoke(arg0);
		} else {
			invokable.Invoke(Args);
		}
	}

	protected override void Cache() {
		if (_target == null || string.IsNullOrEmpty(_methodName)) {
			invokable = new InvokableEvent<T0>(null, null);
		} else {
			if (_dynamic) {
				invokable = new InvokableEvent<T0>(target, methodName);
			} else {
				invokable = GetPersistentMethod();
			}
		}
	}
}

public abstract class SerializableEvent<T0, T1> : SerializableEventBase {
	public void Invoke(T0 arg0, T1 arg1) {
		if (invokable == null) Cache();
		if (_dynamic) {
			InvokableEvent<T0, T1> call = invokable as InvokableEvent<T0, T1>;
			call.Invoke(arg0, arg1);
		} else {
			invokable.Invoke(Args);
		}
	}

	protected override void Cache() {
		if (_target == null || string.IsNullOrEmpty(_methodName)) {
			invokable = new InvokableEvent<T0, T1>(null, null);
		} else {
			if (_dynamic) {
				invokable = new InvokableEvent<T0, T1>(target, methodName);
			} else {
				invokable = GetPersistentMethod();
			}
		}
	}
}

public abstract class SerializableEvent<T0, T1, T2> : SerializableEventBase {
	public void Invoke(T0 arg0, T1 arg1, T2 arg2) {
		if (invokable == null) Cache();
		if (_dynamic) {
			InvokableEvent<T0, T1, T2> call = invokable as InvokableEvent<T0, T1, T2>;
			call.Invoke(arg0, arg1, arg2);
		} else {
			invokable.Invoke(Args);
		}
	}

	protected override void Cache() {
		if (_target == null || string.IsNullOrEmpty(_methodName)) {
			invokable = new InvokableEvent<T0, T1, T2>(null, null);
		} else {
			if (_dynamic) {
				invokable = new InvokableEvent<T0, T1, T2>(target, methodName);
			} else {
				invokable = GetPersistentMethod();
			}
		}
	}
}

public abstract class SerializableEvent<T0, T1, T2, T3> : SerializableEventBase {
	public void Invoke(T0 arg0, T1 arg1, T2 arg2, T3 arg3) {
		if (invokable == null) Cache();
		if (_dynamic) {
			InvokableEvent<T0, T1, T2, T3> call = invokable as InvokableEvent<T0, T1, T2, T3>;
			call.Invoke(arg0, arg1, arg2, arg3);
		} else {
			invokable.Invoke(Args);
		}
	}

	protected override void Cache() {
		if (_target == null || string.IsNullOrEmpty(_methodName)) {
			invokable = new InvokableEvent<T0, T1, T2, T3>(null, null);
		} else {
			if (_dynamic) {
				invokable = new InvokableEvent<T0, T1, T2, T3>(target, methodName);
			} else {
				invokable = GetPersistentMethod();
			}
		}
	}
}