diff options
author | chai <chaifix@163.com> | 2019-08-14 22:50:43 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-08-14 22:50:43 +0800 |
commit | 15740faf9fe9fe4be08965098bbf2947e096aeeb (patch) | |
tree | a730ec236656cc8cab5b13f088adfaed6bb218fb /Runtime/Graphs/UnityEngine.Graphs/LogicNodeLibrary/NodeLibrary.cs |
Diffstat (limited to 'Runtime/Graphs/UnityEngine.Graphs/LogicNodeLibrary/NodeLibrary.cs')
-rw-r--r-- | Runtime/Graphs/UnityEngine.Graphs/LogicNodeLibrary/NodeLibrary.cs | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/Runtime/Graphs/UnityEngine.Graphs/LogicNodeLibrary/NodeLibrary.cs b/Runtime/Graphs/UnityEngine.Graphs/LogicNodeLibrary/NodeLibrary.cs new file mode 100644 index 0000000..4723b37 --- /dev/null +++ b/Runtime/Graphs/UnityEngine.Graphs/LogicNodeLibrary/NodeLibrary.cs @@ -0,0 +1,94 @@ +using System.Collections; +using UnityEngine; + +namespace UnityEngine.Graphs.LogicGraph +{ + public class NodeLibrary + { + public enum ToggleEnum { On, Off, Toggle } + + public static string version + { + get { return "0.3a"; } + } + + // this is actually used, leave here when cleaning up this class + public static float Iff(bool a, float t, float f) + { + return a ? t : f; + } + + public static int Iffint(bool a, int t, int f) + { + return a ? t : f; + } + + public static bool IsTrigger(Collider target) + { + return target.isTrigger; + } + + public static bool IsNotTrigger(Collider target) + { + return !target.isTrigger; + } + + [Logic] + [Title("Logic/Log")] + public static void Log (string str) + { + Debug.Log(str); + } + + [Logic] + [Title("Logic/Wait")] + public static IEnumerator Wait (float waitSeconds) + { + yield return new WaitForSeconds(waitSeconds); + } + + [Logic] + [Title("Logic/Timer")] + public static IEnumerator Timer (float waitSeconds, int repeatCount, Action tick, Action done) + { + for (int i = 0; i < repeatCount; i++) + { + yield return new WaitForSeconds(waitSeconds); + if (tick != null) + tick(); + } + + if (done != null) + done(); + } + + [Logic] + [Title("Logic/Nop")] + public static T Nop<T>(T arg) + { + return arg; + } + + [Logic] + [Title("Object/Instantiate")] + [return: Title("Instantiated Object")] + public static Object Instantiate ([Title("Object")] Object obj, Vector3 position, Quaternion rotation) + { + return Object.Instantiate(obj, position, rotation); + } + + [Logic] + [Title("Object/Destroy")] + public static void Destroy ([Title("Object")] Object obj) + { + Object.Destroy(obj); + } + + [Logic] + [Title("Object/Dont Destroy On Load")] + public static void DontDestroyOnLoad([Title("Object")] Object obj) + { + Object.DontDestroyOnLoad (obj); + } + } +} |