From 97da432c35b8c7aaf9dd2c39e2aa4b1f55f36065 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 27 Jan 2021 16:15:06 +0800 Subject: +behaviour designer --- .../Runtime/Basic Tasks/BoxCollider/GetCenter.cs | 45 ++++++++++++++++++++++ .../Basic Tasks/BoxCollider/GetCenter.cs.meta | 8 ++++ .../Runtime/Basic Tasks/BoxCollider/GetSize.cs | 45 ++++++++++++++++++++++ .../Basic Tasks/BoxCollider/GetSize.cs.meta | 8 ++++ .../Runtime/Basic Tasks/BoxCollider/SetCenter.cs | 44 +++++++++++++++++++++ .../Basic Tasks/BoxCollider/SetCenter.cs.meta | 8 ++++ .../Runtime/Basic Tasks/BoxCollider/SetSize.cs | 44 +++++++++++++++++++++ .../Basic Tasks/BoxCollider/SetSize.cs.meta | 8 ++++ 8 files changed, 210 insertions(+) create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/BoxCollider/GetCenter.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/BoxCollider/GetCenter.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/BoxCollider/GetSize.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/BoxCollider/GetSize.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/BoxCollider/SetCenter.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/BoxCollider/SetCenter.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/BoxCollider/SetSize.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/BoxCollider/SetSize.cs.meta (limited to 'Client/Assets/Behavior Designer/Runtime/Basic Tasks/BoxCollider') diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/BoxCollider/GetCenter.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/BoxCollider/GetCenter.cs new file mode 100644 index 00000000..83bf9367 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/BoxCollider/GetCenter.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityBoxCollider +{ + [TaskCategory("Basic/BoxCollider")] + [TaskDescription("Stores the center of the BoxCollider. Returns Success.")] + public class GetCenter : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The center of the BoxCollider")] + [RequiredField] + public SharedVector3 storeValue; + + private BoxCollider boxCollider; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + boxCollider = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (boxCollider == null) { + Debug.LogWarning("BoxCollider is null"); + return TaskStatus.Failure; + } + + storeValue.Value = boxCollider.center; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + storeValue = Vector3.zero; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/BoxCollider/GetCenter.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/BoxCollider/GetCenter.cs.meta new file mode 100644 index 00000000..61b2c34f --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/BoxCollider/GetCenter.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9c3ae13d2bd0e5f4186835c672d9461f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/BoxCollider/GetSize.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/BoxCollider/GetSize.cs new file mode 100644 index 00000000..d358a83b --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/BoxCollider/GetSize.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityBoxCollider +{ + [TaskCategory("Basic/BoxCollider")] + [TaskDescription("Stores the size of the BoxCollider. Returns Success.")] + public class GetSize : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The size of the BoxCollider")] + [RequiredField] + public SharedVector3 storeValue; + + private BoxCollider boxCollider; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + boxCollider = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (boxCollider == null) { + Debug.LogWarning("BoxCollider is null"); + return TaskStatus.Failure; + } + + storeValue.Value = boxCollider.size; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + storeValue = Vector3.zero; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/BoxCollider/GetSize.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/BoxCollider/GetSize.cs.meta new file mode 100644 index 00000000..934ee86c --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/BoxCollider/GetSize.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0afec21454700d3479c4f9767f9382f9 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/BoxCollider/SetCenter.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/BoxCollider/SetCenter.cs new file mode 100644 index 00000000..e24eec2a --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/BoxCollider/SetCenter.cs @@ -0,0 +1,44 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityBoxCollider +{ + [TaskCategory("Basic/BoxCollider")] + [TaskDescription("Sets the center of the BoxCollider. Returns Success.")] + public class SetCenter : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The center of the BoxCollider")] + public SharedVector3 center; + + private BoxCollider boxCollider; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + boxCollider = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (boxCollider == null) { + Debug.LogWarning("BoxCollider is null"); + return TaskStatus.Failure; + } + + boxCollider.center = center.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + center = Vector3.zero; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/BoxCollider/SetCenter.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/BoxCollider/SetCenter.cs.meta new file mode 100644 index 00000000..9787d48f --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/BoxCollider/SetCenter.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 45b3b4dc79247bd46a9c2b11fa9b125c +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/BoxCollider/SetSize.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/BoxCollider/SetSize.cs new file mode 100644 index 00000000..1ee03fa2 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/BoxCollider/SetSize.cs @@ -0,0 +1,44 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityBoxCollider +{ + [TaskCategory("Basic/BoxCollider")] + [TaskDescription("Sets the size of the BoxCollider. Returns Success.")] + public class SetSize : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The size of the BoxCollider")] + public SharedVector3 size; + + private BoxCollider boxCollider; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + boxCollider = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (boxCollider == null) { + Debug.LogWarning("BoxCollider is null"); + return TaskStatus.Failure; + } + + boxCollider.size = size.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + size = Vector3.zero; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/BoxCollider/SetSize.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/BoxCollider/SetSize.cs.meta new file mode 100644 index 00000000..e00c7d4a --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/BoxCollider/SetSize.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d899b6ed83f6e264f8e5867cf68c0cda +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: -- cgit v1.1-26-g67d0