From 4ccd4bc6d126e0e0f51a50aa10c85b9bf48b1210 Mon Sep 17 00:00:00 2001
From: chai <215380520@qq.com>
Date: Wed, 18 Oct 2023 10:16:32 +0800
Subject: + init
---
.../SerializableCallback/Runtime/Attributes.meta | 9 ++
.../Attributes/TargetConstraintAttribute.cs | 12 ++
.../Attributes/TargetConstraintAttribute.cs.meta | 12 ++
.../Runtime/InvokableCallback.cs | 128 ++++++++++++++++
.../Runtime/InvokableCallback.cs.meta | 13 ++
.../Runtime/InvokableCallbackBase.cs | 3 +
.../Runtime/InvokableCallbackBase.cs.meta | 13 ++
.../SerializableCallback/Runtime/InvokableEvent.cs | 111 ++++++++++++++
.../Runtime/InvokableEvent.cs.meta | 13 ++
.../Runtime/InvokableEventBase.cs | 3 +
.../Runtime/InvokableEventBase.cs.meta | 13 ++
.../Runtime/SerializableCallback.cs | 124 +++++++++++++++
.../Runtime/SerializableCallback.cs.meta | 13 ++
.../Runtime/SerializableCallbackBase.cs | 167 +++++++++++++++++++++
.../Runtime/SerializableCallbackBase.cs.meta | 13 ++
.../Runtime/SerializableEvent.cs | 120 +++++++++++++++
.../Runtime/SerializableEvent.cs.meta | 13 ++
.../Runtime/SerializableEventBase.cs | 40 +++++
.../Runtime/SerializableEventBase.cs.meta | 13 ++
.../Runtime/Siccity.SerializableCallback.asmdef | 13 ++
.../Siccity.SerializableCallback.asmdef.meta | 7 +
.../SerializableCallback/Runtime/Test.cs | 80 ++++++++++
.../SerializableCallback/Runtime/Test.cs.meta | 13 ++
23 files changed, 946 insertions(+)
create mode 100644 ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/Attributes.meta
create mode 100644 ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/Attributes/TargetConstraintAttribute.cs
create mode 100644 ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/Attributes/TargetConstraintAttribute.cs.meta
create mode 100644 ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/InvokableCallback.cs
create mode 100644 ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/InvokableCallback.cs.meta
create mode 100644 ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/InvokableCallbackBase.cs
create mode 100644 ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/InvokableCallbackBase.cs.meta
create mode 100644 ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/InvokableEvent.cs
create mode 100644 ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/InvokableEvent.cs.meta
create mode 100644 ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/InvokableEventBase.cs
create mode 100644 ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/InvokableEventBase.cs.meta
create mode 100644 ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableCallback.cs
create mode 100644 ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableCallback.cs.meta
create mode 100644 ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableCallbackBase.cs
create mode 100644 ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableCallbackBase.cs.meta
create mode 100644 ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableEvent.cs
create mode 100644 ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableEvent.cs.meta
create mode 100644 ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableEventBase.cs
create mode 100644 ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableEventBase.cs.meta
create mode 100644 ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/Siccity.SerializableCallback.asmdef
create mode 100644 ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/Siccity.SerializableCallback.asmdef.meta
create mode 100644 ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/Test.cs
create mode 100644 ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/Test.cs.meta
(limited to 'ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime')
diff --git a/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/Attributes.meta b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/Attributes.meta
new file mode 100644
index 0000000..384c282
--- /dev/null
+++ b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/Attributes.meta
@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: 4fd350e49301e4445a1cbe580fe9eec7
+folderAsset: yes
+timeCreated: 1536132750
+licenseType: Pro
+DefaultImporter:
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/Attributes/TargetConstraintAttribute.cs b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/Attributes/TargetConstraintAttribute.cs
new file mode 100644
index 0000000..e457e06
--- /dev/null
+++ b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/Attributes/TargetConstraintAttribute.cs
@@ -0,0 +1,12 @@
+using UnityEngine;
+using System;
+
+/// Add to fields of your class extending SerializableCallbackBase to limit which types can be assigned to it.
+public class TargetConstraintAttribute : PropertyAttribute {
+ public Type targetType;
+
+ /// Add to fields of your class extending SerializableCallbackBase to limit which types can be assigned to it.
+ public TargetConstraintAttribute(Type targetType) {
+ this.targetType = targetType;
+ }
+}
diff --git a/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/Attributes/TargetConstraintAttribute.cs.meta b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/Attributes/TargetConstraintAttribute.cs.meta
new file mode 100644
index 0000000..1345b58
--- /dev/null
+++ b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/Attributes/TargetConstraintAttribute.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 4b9b7d20cf54ac6489b84d21c29a4c69
+timeCreated: 1536132736
+licenseType: Pro
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/InvokableCallback.cs b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/InvokableCallback.cs
new file mode 100644
index 0000000..2819874
--- /dev/null
+++ b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/InvokableCallback.cs
@@ -0,0 +1,128 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class InvokableCallback : InvokableCallbackBase {
+
+ public Func func;
+
+ public TReturn Invoke() {
+ return func();
+ }
+
+ public override TReturn Invoke(params object[] args) {
+ return func();
+ }
+
+ /// Constructor
+ public InvokableCallback(object target, string methodName) {
+ if (target == null || string.IsNullOrEmpty(methodName)) {
+ func = () => default(TReturn);
+ } else {
+ func = (System.Func) System.Delegate.CreateDelegate(typeof(System.Func), target, methodName);
+ }
+ }
+}
+
+public class InvokableCallback : InvokableCallbackBase {
+
+ public Func func;
+
+ public TReturn Invoke(T0 arg0) {
+ return func(arg0);
+ }
+
+ public override TReturn Invoke(params object[] args) {
+ // Convert from special "unity-nulls" to true null
+ if (args[0] is UnityEngine.Object && (UnityEngine.Object) args[0] == null) args[0] = null;
+ return func((T0) args[0]);
+ }
+
+ /// Constructor
+ public InvokableCallback(object target, string methodName) {
+ if (target == null || string.IsNullOrEmpty(methodName)) {
+ func = x => default(TReturn);
+ } else {
+ func = (System.Func) System.Delegate.CreateDelegate(typeof(System.Func), target, methodName);
+ }
+ }
+}
+
+public class InvokableCallback : InvokableCallbackBase {
+
+ public Func func;
+
+ public TReturn Invoke(T0 arg0, T1 arg1) {
+ return func(arg0, arg1);
+ }
+
+ public override TReturn Invoke(params object[] args) {
+ // Convert from special "unity-nulls" to true null
+ if (args[0] is UnityEngine.Object && (UnityEngine.Object) args[0] == null) args[0] = null;
+ if (args[1] is UnityEngine.Object && (UnityEngine.Object) args[1] == null) args[1] = null;
+ return func((T0) args[0], (T1) args[1]);
+ }
+
+ /// Constructor
+ public InvokableCallback(object target, string methodName) {
+ if (target == null || string.IsNullOrEmpty(methodName)) {
+ func = (x, y) => default(TReturn);
+ } else {
+ func = (System.Func) System.Delegate.CreateDelegate(typeof(System.Func), target, methodName);
+ }
+ }
+}
+
+public class InvokableCallback : InvokableCallbackBase {
+
+ public Func func;
+
+ public TReturn Invoke(T0 arg0, T1 arg1, T2 arg2) {
+ return func(arg0, arg1, arg2);
+ }
+
+ public override TReturn Invoke(params object[] args) {
+ // Convert from special "unity-nulls" to true null
+ if (args[0] is UnityEngine.Object && (UnityEngine.Object) args[0] == null) args[0] = null;
+ if (args[1] is UnityEngine.Object && (UnityEngine.Object) args[1] == null) args[1] = null;
+ if (args[2] is UnityEngine.Object && (UnityEngine.Object) args[2] == null) args[2] = null;
+ return func((T0) args[0], (T1) args[1], (T2) args[2]);
+ }
+
+ /// Constructor
+ public InvokableCallback(object target, string methodName) {
+ if (target == null || string.IsNullOrEmpty(methodName)) {
+ func = (x, y, z) => default(TReturn);
+ } else {
+ func = (System.Func) System.Delegate.CreateDelegate(typeof(System.Func), target, methodName);
+ }
+ }
+}
+
+public class InvokableCallback : InvokableCallbackBase {
+
+ public Func func;
+
+ public TReturn Invoke(T0 arg0, T1 arg1, T2 arg2, T3 arg3) {
+ return func(arg0, arg1, arg2, arg3);
+ }
+
+ public override TReturn Invoke(params object[] args) {
+ // Convert from special "unity-nulls" to true null
+ if (args[0] is UnityEngine.Object && (UnityEngine.Object) args[0] == null) args[0] = null;
+ if (args[1] is UnityEngine.Object && (UnityEngine.Object) args[1] == null) args[1] = null;
+ if (args[2] is UnityEngine.Object && (UnityEngine.Object) args[2] == null) args[2] = null;
+ if (args[3] is UnityEngine.Object && (UnityEngine.Object) args[3] == null) args[3] = null;
+ return func((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3]);
+ }
+
+ /// Constructor
+ public InvokableCallback(object target, string methodName) {
+ if (target == null || string.IsNullOrEmpty(methodName)) {
+ func = (x, y, z, w) => default(TReturn);
+ } else {
+ func = (System.Func) System.Delegate.CreateDelegate(typeof(System.Func), target, methodName);
+ }
+ }
+}
\ No newline at end of file
diff --git a/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/InvokableCallback.cs.meta b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/InvokableCallback.cs.meta
new file mode 100644
index 0000000..2468e0a
--- /dev/null
+++ b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/InvokableCallback.cs.meta
@@ -0,0 +1,13 @@
+fileFormatVersion: 2
+guid: ca67a6ce15814b743b8e123c175ce649
+timeCreated: 1515587326
+licenseType: Free
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/InvokableCallbackBase.cs b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/InvokableCallbackBase.cs
new file mode 100644
index 0000000..e0cd2d1
--- /dev/null
+++ b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/InvokableCallbackBase.cs
@@ -0,0 +1,3 @@
+public abstract class InvokableCallbackBase {
+ public abstract TReturn Invoke(params object[] args);
+}
\ No newline at end of file
diff --git a/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/InvokableCallbackBase.cs.meta b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/InvokableCallbackBase.cs.meta
new file mode 100644
index 0000000..d5e608c
--- /dev/null
+++ b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/InvokableCallbackBase.cs.meta
@@ -0,0 +1,13 @@
+fileFormatVersion: 2
+guid: 9147523dbcc2f2f46878180063444518
+timeCreated: 1515583421
+licenseType: Free
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/InvokableEvent.cs b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/InvokableEvent.cs
new file mode 100644
index 0000000..dd9db65
--- /dev/null
+++ b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/InvokableEvent.cs
@@ -0,0 +1,111 @@
+using System;
+
+public class InvokableEvent : InvokableEventBase {
+
+ public System.Action action;
+
+ public void Invoke() {
+ action();
+ }
+
+ public override void Invoke(params object[] args) {
+ action();
+ }
+
+ /// Constructor
+ 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 : InvokableEventBase {
+
+ public Action action;
+
+ public void Invoke(T0 arg0) {
+ action(arg0);
+ }
+
+ public override void Invoke(params object[] args) {
+ action((T0) args[0]);
+ }
+
+ /// Constructor
+ public InvokableEvent(object target, string methodName) {
+ if (target == null || string.IsNullOrEmpty(methodName)) {
+ action = x => { };
+ } else {
+ action = (System.Action) System.Delegate.CreateDelegate(typeof(System.Action), target, methodName);
+ }
+ }
+}
+
+public class InvokableEvent : InvokableEventBase {
+
+ public Action 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]);
+ }
+
+ /// Constructor
+ public InvokableEvent(object target, string methodName) {
+ if (target == null || string.IsNullOrEmpty(methodName)) {
+ action = (x, y) => { };
+ } else {
+ action = (System.Action) System.Delegate.CreateDelegate(typeof(System.Action), target, methodName);
+ }
+ }
+}
+
+public class InvokableEvent : InvokableEventBase {
+
+ public Action 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]);
+ }
+
+ /// Constructor
+ public InvokableEvent(object target, string methodName) {
+ if (target == null || string.IsNullOrEmpty(methodName)) {
+ action = (x, y, z) => { };
+ } else {
+ action = (System.Action) System.Delegate.CreateDelegate(typeof(System.Action), target, methodName);
+ }
+ }
+}
+
+public class InvokableEvent : InvokableEventBase {
+
+ public Action 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]);
+ }
+
+ /// Constructor
+ public InvokableEvent(object target, string methodName) {
+ if (target == null || string.IsNullOrEmpty(methodName)) {
+ action = (x, y, z, w) => { };
+ } else {
+ action = (System.Action) System.Delegate.CreateDelegate(typeof(System.Action), target, methodName);
+ }
+ }
+}
diff --git a/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/InvokableEvent.cs.meta b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/InvokableEvent.cs.meta
new file mode 100644
index 0000000..7754aaa
--- /dev/null
+++ b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/InvokableEvent.cs.meta
@@ -0,0 +1,13 @@
+fileFormatVersion: 2
+guid: 51f8a42e6f95b694cb28ca372e32aef3
+timeCreated: 1515748293
+licenseType: Free
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/InvokableEventBase.cs b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/InvokableEventBase.cs
new file mode 100644
index 0000000..003ab7c
--- /dev/null
+++ b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/InvokableEventBase.cs
@@ -0,0 +1,3 @@
+public abstract class InvokableEventBase {
+ public abstract void Invoke(params object[] args);
+}
\ No newline at end of file
diff --git a/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/InvokableEventBase.cs.meta b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/InvokableEventBase.cs.meta
new file mode 100644
index 0000000..9696ff5
--- /dev/null
+++ b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/InvokableEventBase.cs.meta
@@ -0,0 +1,13 @@
+fileFormatVersion: 2
+guid: e958262ec96656d459752d5df5faa52e
+timeCreated: 1515748285
+licenseType: Free
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableCallback.cs b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableCallback.cs
new file mode 100644
index 0000000..e58fa3b
--- /dev/null
+++ b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableCallback.cs
@@ -0,0 +1,124 @@
+using System;
+using System.Linq.Expressions;
+using System.Reflection;
+using UnityEngine;
+
+public abstract class SerializableCallback : SerializableCallbackBase {
+ public TReturn Invoke() {
+ if (func == null) Cache();
+ if (_dynamic) {
+ InvokableCallback call = func as InvokableCallback;
+ return call.Invoke();
+ } else {
+ return func.Invoke(Args);
+ }
+ }
+
+ protected override void Cache() {
+ if (_target == null || string.IsNullOrEmpty(_methodName)) {
+ func = new InvokableCallback(null, null);
+ } else {
+ if (_dynamic) {
+ func = new InvokableCallback(target, methodName);
+ } else {
+ func = GetPersistentMethod();
+ }
+ }
+ }
+}
+
+public abstract class SerializableCallback : SerializableCallbackBase {
+ public TReturn Invoke(T0 arg0) {
+ if (func == null) Cache();
+ if (_dynamic) {
+ InvokableCallback call = func as InvokableCallback;
+ return call.Invoke(arg0);
+ } else {
+ return func.Invoke(Args);
+ }
+ }
+
+ protected override void Cache() {
+ if (_target == null || string.IsNullOrEmpty(_methodName)) {
+ func = new InvokableCallback(null, null);
+ } else {
+ if (_dynamic) {
+ func = new InvokableCallback(target, methodName);
+ } else {
+ func = GetPersistentMethod();
+ }
+ }
+ }
+}
+
+public abstract class SerializableCallback : SerializableCallbackBase {
+ public TReturn Invoke(T0 arg0, T1 arg1) {
+ if (func == null) Cache();
+ if (_dynamic) {
+ InvokableCallback call = func as InvokableCallback;
+ return call.Invoke(arg0, arg1);
+ } else {
+ return func.Invoke(Args);
+ }
+ }
+
+ protected override void Cache() {
+ if (_target == null || string.IsNullOrEmpty(_methodName)) {
+ func = new InvokableCallback(null, null);
+ } else {
+ if (_dynamic) {
+ func = new InvokableCallback(target, methodName);
+ } else {
+ func = GetPersistentMethod();
+ }
+ }
+ }
+}
+
+public abstract class SerializableCallback : SerializableCallbackBase {
+ public TReturn Invoke(T0 arg0, T1 arg1, T2 arg2) {
+ if (func == null) Cache();
+ if (_dynamic) {
+ InvokableCallback call = func as InvokableCallback;
+ return call.Invoke(arg0, arg1, arg2);
+ } else {
+ return func.Invoke(Args);
+ }
+ }
+
+ protected override void Cache() {
+ if (_target == null || string.IsNullOrEmpty(_methodName)) {
+ func = new InvokableCallback(null, null);
+ } else {
+ if (_dynamic) {
+ func = new InvokableCallback(target, methodName);
+ } else {
+ func = GetPersistentMethod();
+ }
+ }
+ }
+}
+
+public abstract class SerializableCallback : SerializableCallbackBase {
+ public TReturn Invoke(T0 arg0, T1 arg1, T2 arg2, T3 arg3) {
+ if (func == null) Cache();
+ if (_dynamic) {
+ InvokableCallback call = func as InvokableCallback;
+ return call.Invoke(arg0, arg1, arg2, arg3);
+ } else {
+ return func.Invoke(Args);
+ }
+ }
+
+ protected override void Cache() {
+ if (_target == null || string.IsNullOrEmpty(_methodName)) {
+ func = new InvokableCallback(null, null);
+ } else {
+ if (_dynamic) {
+ func = new InvokableCallback(target, methodName);
+ } else {
+ func = GetPersistentMethod();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableCallback.cs.meta b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableCallback.cs.meta
new file mode 100644
index 0000000..0969bde
--- /dev/null
+++ b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableCallback.cs.meta
@@ -0,0 +1,13 @@
+fileFormatVersion: 2
+guid: dc926a8278d45964e842b3ee4b9e593b
+timeCreated: 1513845239
+licenseType: Pro
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableCallbackBase.cs b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableCallbackBase.cs
new file mode 100644
index 0000000..34300d7
--- /dev/null
+++ b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableCallbackBase.cs
@@ -0,0 +1,167 @@
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Reflection;
+using UnityEngine;
+using Object = UnityEngine.Object;
+
+public abstract class SerializableCallbackBase : SerializableCallbackBase {
+ public InvokableCallbackBase func;
+
+ public override void ClearCache() {
+ base.ClearCache();
+ func = null;
+ }
+
+ protected InvokableCallbackBase GetPersistentMethod() {
+ Type[] types = new Type[ArgRealTypes.Length + 1];
+ Array.Copy(ArgRealTypes, types, ArgRealTypes.Length);
+ types[types.Length - 1] = typeof(TReturn);
+
+ Type genericType = null;
+ switch (types.Length) {
+ case 1:
+ genericType = typeof(InvokableCallback<>).MakeGenericType(types);
+ break;
+ case 2:
+ genericType = typeof(InvokableCallback<,>).MakeGenericType(types);
+ break;
+ case 3:
+ genericType = typeof(InvokableCallback<, ,>).MakeGenericType(types);
+ break;
+ case 4:
+ genericType = typeof(InvokableCallback<, , ,>).MakeGenericType(types);
+ break;
+ case 5:
+ genericType = typeof(InvokableCallback<, , , ,>).MakeGenericType(types);
+ break;
+ default:
+ throw new ArgumentException(types.Length + "args");
+ }
+ return Activator.CreateInstance(genericType, new object[] { target, methodName }) as InvokableCallbackBase;
+ }
+}
+
+/// An inspector-friendly serializable function
+[System.Serializable]
+public abstract class SerializableCallbackBase : ISerializationCallbackReceiver {
+
+ /// Target object
+ public Object target { get { return _target; } set { _target = value; ClearCache(); } }
+ /// Target method name
+ public string methodName { get { return _methodName; } set { _methodName = value; ClearCache(); } }
+ public object[] Args { get { return args != null ? args : args = _args.Select(x => x.GetValue()).ToArray(); } }
+ public object[] args;
+ public Type[] ArgTypes { get { return argTypes != null ? argTypes : argTypes = _args.Select(x => Arg.RealType(x.argType)).ToArray(); } }
+ public Type[] argTypes;
+ public Type[] ArgRealTypes { get { return argRealTypes != null ? argRealTypes : argRealTypes = _args.Select(x => Type.GetType(x._typeName)).ToArray(); } }
+ public Type[] argRealTypes;
+ public bool dynamic { get { return _dynamic; } set { _dynamic = value; ClearCache(); } }
+
+ [SerializeField] protected Object _target;
+ [SerializeField] protected string _methodName;
+ [SerializeField] protected Arg[] _args;
+ [SerializeField] protected bool _dynamic;
+#pragma warning disable 0414
+ [SerializeField] private string _typeName;
+#pragma warning restore 0414
+
+ [SerializeField] private bool dirty;
+
+#if UNITY_EDITOR
+ protected SerializableCallbackBase() {
+ _typeName = base.GetType().AssemblyQualifiedName;
+ }
+#endif
+
+ public virtual void ClearCache() {
+ argTypes = null;
+ args = null;
+ }
+
+ public void SetMethod(Object target, string methodName, bool dynamic, params Arg[] args) {
+ _target = target;
+ _methodName = methodName;
+ _dynamic = dynamic;
+ _args = args;
+ ClearCache();
+ }
+
+ protected abstract void Cache();
+
+ public void OnBeforeSerialize() {
+#if UNITY_EDITOR
+ if (dirty) { ClearCache(); dirty = false; }
+#endif
+ }
+
+ public void OnAfterDeserialize() {
+#if UNITY_EDITOR
+ _typeName = base.GetType().AssemblyQualifiedName;
+#endif
+ }
+}
+
+[System.Serializable]
+public struct Arg {
+ public enum ArgType { Unsupported, Bool, Int, Float, String, Object }
+ public bool boolValue;
+ public int intValue;
+ public float floatValue;
+ public string stringValue;
+ public Object objectValue;
+ public ArgType argType;
+ public string _typeName;
+
+ public object GetValue() {
+ return GetValue(argType);
+ }
+
+ public object GetValue(ArgType type) {
+ switch (type) {
+ case ArgType.Bool:
+ return boolValue;
+ case ArgType.Int:
+ return intValue;
+ case ArgType.Float:
+ return floatValue;
+ case ArgType.String:
+ return stringValue;
+ case ArgType.Object:
+ return objectValue;
+ default:
+ return null;
+ }
+ }
+
+ public static Type RealType(ArgType type) {
+ switch (type) {
+ case ArgType.Bool:
+ return typeof(bool);
+ case ArgType.Int:
+ return typeof(int);
+ case ArgType.Float:
+ return typeof(float);
+ case ArgType.String:
+ return typeof(string);
+ case ArgType.Object:
+ return typeof(Object);
+ default:
+ return null;
+ }
+ }
+
+ public static ArgType FromRealType(Type type) {
+ if (type == typeof(bool)) return ArgType.Bool;
+ else if (type == typeof(int)) return ArgType.Int;
+ else if (type == typeof(float)) return ArgType.Float;
+ else if (type == typeof(String)) return ArgType.String;
+ else if (typeof(Object).IsAssignableFrom(type)) return ArgType.Object;
+ else return ArgType.Unsupported;
+ }
+
+ public static bool IsSupported(Type type) {
+ return FromRealType(type) != ArgType.Unsupported;
+ }
+}
\ No newline at end of file
diff --git a/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableCallbackBase.cs.meta b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableCallbackBase.cs.meta
new file mode 100644
index 0000000..8d7d1db
--- /dev/null
+++ b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableCallbackBase.cs.meta
@@ -0,0 +1,13 @@
+fileFormatVersion: 2
+guid: 7281861ef496a34429213165496d8cf3
+timeCreated: 1513845239
+licenseType: Pro
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableEvent.cs b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableEvent.cs
new file mode 100644
index 0000000..9a65ef6
--- /dev/null
+++ b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableEvent.cs
@@ -0,0 +1,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 : SerializableEventBase {
+ public void Invoke(T0 arg0) {
+ if (invokable == null) Cache();
+ if (_dynamic) {
+ InvokableEvent call = invokable as InvokableEvent;
+ call.Invoke(arg0);
+ } 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 : SerializableEventBase {
+ public void Invoke(T0 arg0, T1 arg1) {
+ if (invokable == null) Cache();
+ if (_dynamic) {
+ InvokableEvent call = invokable as InvokableEvent;
+ call.Invoke(arg0, arg1);
+ } 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 : SerializableEventBase {
+ public void Invoke(T0 arg0, T1 arg1, T2 arg2) {
+ if (invokable == null) Cache();
+ if (_dynamic) {
+ InvokableEvent call = invokable as InvokableEvent;
+ call.Invoke(arg0, arg1, arg2);
+ } 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 : SerializableEventBase {
+ public void Invoke(T0 arg0, T1 arg1, T2 arg2, T3 arg3) {
+ if (invokable == null) Cache();
+ if (_dynamic) {
+ InvokableEvent call = invokable as InvokableEvent;
+ call.Invoke(arg0, arg1, arg2, arg3);
+ } 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();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableEvent.cs.meta b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableEvent.cs.meta
new file mode 100644
index 0000000..5c5bdca
--- /dev/null
+++ b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableEvent.cs.meta
@@ -0,0 +1,13 @@
+fileFormatVersion: 2
+guid: 874a1a13ec4740a4387fe34d59931868
+timeCreated: 1515747693
+licenseType: Free
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableEventBase.cs b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableEventBase.cs
new file mode 100644
index 0000000..916d553
--- /dev/null
+++ b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableEventBase.cs
@@ -0,0 +1,40 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using System;
+
+public abstract class SerializableEventBase : SerializableCallbackBase {
+ public InvokableEventBase invokable;
+
+ public override void ClearCache() {
+ base.ClearCache();
+ invokable = null;
+ }
+
+ protected InvokableEventBase GetPersistentMethod() {
+ Type[] types = new Type[ArgTypes.Length];
+ Array.Copy(ArgTypes, types, ArgTypes.Length);
+
+ Type genericType = null;
+ switch (types.Length) {
+ case 0:
+ genericType = typeof(InvokableEvent);
+ break;
+ case 1:
+ genericType = typeof(InvokableEvent<>).MakeGenericType(types);
+ break;
+ case 2:
+ genericType = typeof(InvokableEvent<,>).MakeGenericType(types);
+ break;
+ case 3:
+ genericType = typeof(InvokableEvent<, ,>).MakeGenericType(types);
+ break;
+ case 4:
+ genericType = typeof(InvokableEvent<, , ,>).MakeGenericType(types);
+ break;
+ default:
+ throw new ArgumentException(types.Length + "args");
+ }
+ return Activator.CreateInstance(genericType, new object[] { target, methodName }) as InvokableEventBase;
+ }
+}
\ No newline at end of file
diff --git a/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableEventBase.cs.meta b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableEventBase.cs.meta
new file mode 100644
index 0000000..0f5e8ab
--- /dev/null
+++ b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/SerializableEventBase.cs.meta
@@ -0,0 +1,13 @@
+fileFormatVersion: 2
+guid: e5856b88cee94a64c95101c3f3de4754
+timeCreated: 1515747887
+licenseType: Free
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/Siccity.SerializableCallback.asmdef b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/Siccity.SerializableCallback.asmdef
new file mode 100644
index 0000000..209a051
--- /dev/null
+++ b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/Siccity.SerializableCallback.asmdef
@@ -0,0 +1,13 @@
+{
+ "name": "Siccity.SerializableCallback",
+ "references": [],
+ "includePlatforms": [],
+ "excludePlatforms": [],
+ "allowUnsafeCode": false,
+ "overrideReferences": false,
+ "precompiledReferences": [],
+ "autoReferenced": true,
+ "defineConstraints": [],
+ "versionDefines": [],
+ "noEngineReferences": false
+}
\ No newline at end of file
diff --git a/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/Siccity.SerializableCallback.asmdef.meta b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/Siccity.SerializableCallback.asmdef.meta
new file mode 100644
index 0000000..373b011
--- /dev/null
+++ b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/Siccity.SerializableCallback.asmdef.meta
@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 11a2306c728a4b843a652ec6c2f142bc
+AssemblyDefinitionImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/Test.cs b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/Test.cs
new file mode 100644
index 0000000..2c258ba
--- /dev/null
+++ b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/Test.cs
@@ -0,0 +1,80 @@
+using System;
+using System.Diagnostics;
+using UnityEngine;
+
+public class Test : MonoBehaviour {
+ const int ITERATIONS = 100000;
+ public float f = 0.5f;
+ public string s;
+ public System.Func RegularDelegate;
+ public System.Func DynamicDelegate;
+ public Condition condition;
+ public SerializableEvent ev;
+
+ void Start() {
+ RegularDelegate = TestMethod;
+ DynamicDelegate = (System.Func) System.Delegate.CreateDelegate(typeof(System.Func), this, "TestMethod");
+ condition.Invoke(f);
+ }
+
+ void Update() {
+ var method = Stopwatch.StartNew();
+ bool methodb = false;
+ for (int i = 0; i < ITERATIONS; ++i) {
+ methodb = TestMethod(f);
+ }
+ method.Stop();
+
+ var regularDelegate = Stopwatch.StartNew();
+ bool regularDelegateb = false;
+ for (int i = 0; i < ITERATIONS; ++i) {
+ regularDelegateb = RegularDelegate(f);
+ }
+ regularDelegate.Stop();
+
+ var dynamicDelegate = Stopwatch.StartNew();
+ bool dynamicDelegateb = false;
+ for (int i = 0; i < ITERATIONS; ++i) {
+ dynamicDelegateb = DynamicDelegate(f);
+ }
+ dynamicDelegate.Stop();
+
+ var serializedDelegate = Stopwatch.StartNew();
+ bool serializedDelegateb = false;
+ for (int i = 0; i < ITERATIONS; ++i) {
+ serializedDelegateb = condition.Invoke(f);
+ }
+ serializedDelegate.Stop();
+
+ var serializedEvent = Stopwatch.StartNew();
+ for (int i = 0; i < ITERATIONS; ++i) {
+ ev.Invoke();
+ }
+ serializedEvent.Stop();
+
+ UnityEngine.Debug.Log("Method: " + methodb + method.Elapsed);
+ UnityEngine.Debug.Log("RegularDelegate: " + regularDelegateb + regularDelegate.Elapsed);
+ UnityEngine.Debug.Log("DynamicDelegate: " + dynamicDelegateb + dynamicDelegate.Elapsed);
+ UnityEngine.Debug.Log("SerializedCallback: " + serializedDelegateb + serializedDelegate.Elapsed);
+ UnityEngine.Debug.Log("SerializedEvent: " + serializedEvent.Elapsed);
+ }
+
+ public bool TestMethod(float f) {
+ return f > 0.5f;
+ }
+
+ public bool TestMethod(string a) {
+ return string.IsNullOrEmpty(a);
+ }
+
+ public bool TestMethod2(float f, string a) {
+ return f > 0.5f && string.IsNullOrEmpty(a);
+ }
+
+ public void TestMethod2(string a) {
+ s = a;
+ }
+}
+
+[Serializable]
+public class Condition : SerializableCallback { }
\ No newline at end of file
diff --git a/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/Test.cs.meta b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/Test.cs.meta
new file mode 100644
index 0000000..273d481
--- /dev/null
+++ b/ActiveRagdoll/Assets/ThirdParty/SerializableCallback/Runtime/Test.cs.meta
@@ -0,0 +1,13 @@
+fileFormatVersion: 2
+guid: 933cfc79696bbd74ca51c70a8d61ae8d
+timeCreated: 1514107717
+licenseType: Free
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
--
cgit v1.1-26-g67d0