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/Transform/Find.cs | 48 ++++++++++++++++ .../Runtime/Basic Tasks/Transform/Find.cs.meta | 8 +++ .../Runtime/Basic Tasks/Transform/FindChild.cs | 48 ++++++++++++++++ .../Basic Tasks/Transform/FindChild.cs.meta | 8 +++ .../Basic Tasks/Transform/GetAngleToTarget.cs | 66 ++++++++++++++++++++++ .../Basic Tasks/Transform/GetAngleToTarget.cs.meta | 8 +++ .../Runtime/Basic Tasks/Transform/GetChild.cs | 48 ++++++++++++++++ .../Runtime/Basic Tasks/Transform/GetChild.cs.meta | 8 +++ .../Runtime/Basic Tasks/Transform/GetChildCount.cs | 45 +++++++++++++++ .../Basic Tasks/Transform/GetChildCount.cs.meta | 8 +++ .../Basic Tasks/Transform/GetEulerAngles.cs | 45 +++++++++++++++ .../Basic Tasks/Transform/GetEulerAngles.cs.meta | 8 +++ .../Basic Tasks/Transform/GetForwardVector.cs | 45 +++++++++++++++ .../Basic Tasks/Transform/GetForwardVector.cs.meta | 8 +++ .../Basic Tasks/Transform/GetLocalEulerAngles.cs | 45 +++++++++++++++ .../Transform/GetLocalEulerAngles.cs.meta | 8 +++ .../Basic Tasks/Transform/GetLocalPosition.cs | 45 +++++++++++++++ .../Basic Tasks/Transform/GetLocalPosition.cs.meta | 8 +++ .../Basic Tasks/Transform/GetLocalRotation.cs | 45 +++++++++++++++ .../Basic Tasks/Transform/GetLocalRotation.cs.meta | 8 +++ .../Runtime/Basic Tasks/Transform/GetLocalScale.cs | 45 +++++++++++++++ .../Basic Tasks/Transform/GetLocalScale.cs.meta | 8 +++ .../Runtime/Basic Tasks/Transform/GetParent.cs | 45 +++++++++++++++ .../Basic Tasks/Transform/GetParent.cs.meta | 8 +++ .../Runtime/Basic Tasks/Transform/GetPosition.cs | 50 ++++++++++++++++ .../Basic Tasks/Transform/GetPosition.cs.meta | 8 +++ .../Basic Tasks/Transform/GetRightVector.cs | 45 +++++++++++++++ .../Basic Tasks/Transform/GetRightVector.cs.meta | 8 +++ .../Runtime/Basic Tasks/Transform/GetRotation.cs | 45 +++++++++++++++ .../Basic Tasks/Transform/GetRotation.cs.meta | 8 +++ .../Runtime/Basic Tasks/Transform/GetUpVector.cs | 45 +++++++++++++++ .../Basic Tasks/Transform/GetUpVector.cs.meta | 8 +++ .../Runtime/Basic Tasks/Transform/IsChildOf.cs | 42 ++++++++++++++ .../Basic Tasks/Transform/IsChildOf.cs.meta | 8 +++ .../Runtime/Basic Tasks/Transform/LookAt.cs | 47 +++++++++++++++ .../Runtime/Basic Tasks/Transform/LookAt.cs.meta | 8 +++ .../Runtime/Basic Tasks/Transform/Rotate.cs | 47 +++++++++++++++ .../Runtime/Basic Tasks/Transform/Rotate.cs.meta | 8 +++ .../Runtime/Basic Tasks/Transform/RotateAround.cs | 50 ++++++++++++++++ .../Basic Tasks/Transform/RotateAround.cs.meta | 8 +++ .../Basic Tasks/Transform/SetEulerAngles.cs | 44 +++++++++++++++ .../Basic Tasks/Transform/SetEulerAngles.cs.meta | 8 +++ .../Basic Tasks/Transform/SetForwardVector.cs | 44 +++++++++++++++ .../Basic Tasks/Transform/SetForwardVector.cs.meta | 8 +++ .../Basic Tasks/Transform/SetLocalEulerAngles.cs | 44 +++++++++++++++ .../Transform/SetLocalEulerAngles.cs.meta | 8 +++ .../Basic Tasks/Transform/SetLocalPosition.cs | 44 +++++++++++++++ .../Basic Tasks/Transform/SetLocalPosition.cs.meta | 8 +++ .../Basic Tasks/Transform/SetLocalRotation.cs | 44 +++++++++++++++ .../Basic Tasks/Transform/SetLocalRotation.cs.meta | 8 +++ .../Runtime/Basic Tasks/Transform/SetLocalScale.cs | 44 +++++++++++++++ .../Basic Tasks/Transform/SetLocalScale.cs.meta | 8 +++ .../Runtime/Basic Tasks/Transform/SetParent.cs | 44 +++++++++++++++ .../Basic Tasks/Transform/SetParent.cs.meta | 8 +++ .../Runtime/Basic Tasks/Transform/SetPosition.cs | 44 +++++++++++++++ .../Basic Tasks/Transform/SetPosition.cs.meta | 8 +++ .../Basic Tasks/Transform/SetRightVector.cs | 44 +++++++++++++++ .../Basic Tasks/Transform/SetRightVector.cs.meta | 8 +++ .../Runtime/Basic Tasks/Transform/SetRotation.cs | 44 +++++++++++++++ .../Basic Tasks/Transform/SetRotation.cs.meta | 8 +++ .../Runtime/Basic Tasks/Transform/SetUpVector.cs | 44 +++++++++++++++ .../Basic Tasks/Transform/SetUpVector.cs.meta | 8 +++ .../Runtime/Basic Tasks/Transform/Translate.cs | 47 +++++++++++++++ .../Basic Tasks/Transform/Translate.cs.meta | 8 +++ 64 files changed, 1728 insertions(+) create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/Find.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/Find.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/FindChild.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/FindChild.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetAngleToTarget.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetAngleToTarget.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetChild.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetChild.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetChildCount.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetChildCount.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetEulerAngles.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetEulerAngles.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetForwardVector.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetForwardVector.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetLocalEulerAngles.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetLocalEulerAngles.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetLocalPosition.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetLocalPosition.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetLocalRotation.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetLocalRotation.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetLocalScale.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetLocalScale.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetParent.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetParent.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetPosition.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetPosition.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetRightVector.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetRightVector.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetRotation.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetRotation.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetUpVector.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetUpVector.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/IsChildOf.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/IsChildOf.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/LookAt.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/LookAt.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/Rotate.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/Rotate.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/RotateAround.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/RotateAround.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetEulerAngles.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetEulerAngles.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetForwardVector.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetForwardVector.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetLocalEulerAngles.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetLocalEulerAngles.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetLocalPosition.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetLocalPosition.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetLocalRotation.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetLocalRotation.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetLocalScale.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetLocalScale.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetParent.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetParent.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetPosition.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetPosition.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetRightVector.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetRightVector.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetRotation.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetRotation.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetUpVector.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetUpVector.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/Translate.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/Translate.cs.meta (limited to 'Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform') diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/Find.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/Find.cs new file mode 100644 index 00000000..8f45f378 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/Find.cs @@ -0,0 +1,48 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityTransform +{ + [TaskCategory("Basic/Transform")] + [TaskDescription("Finds a transform by name. Returns Success.")] + public class Find : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The transform name to find")] + public SharedString transformName; + [Tooltip("The object found by name")] + [RequiredField] + public SharedTransform storeValue; + + private Transform targetTransform; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + targetTransform = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (targetTransform == null) { + Debug.LogWarning("Transform is null"); + return TaskStatus.Failure; + } + + storeValue.Value = targetTransform.Find(transformName.Value); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + transformName = null; + storeValue = null; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/Find.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/Find.cs.meta new file mode 100644 index 00000000..b0220ca3 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/Find.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 387fd22087393ab4e91f0ad4fce4e77f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/FindChild.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/FindChild.cs new file mode 100644 index 00000000..a6c31655 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/FindChild.cs @@ -0,0 +1,48 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityTransform +{ + [TaskCategory("Basic/Transform")] + [TaskDescription("Finds a child transform by name. Returns Success.")] + public class FindChild : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The transform name to find")] + public SharedString transformName; + [Tooltip("The object found by name")] + [RequiredField] + public SharedTransform storeValue; + + private Transform targetTransform; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + targetTransform = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (targetTransform == null) { + Debug.LogWarning("Transform is null"); + return TaskStatus.Failure; + } + + storeValue.Value = targetTransform.Find(transformName.Value); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + transformName = null; + storeValue = null; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/FindChild.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/FindChild.cs.meta new file mode 100644 index 00000000..7f6d7a53 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/FindChild.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 62d28af7da95a12409245b2682550bcc +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetAngleToTarget.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetAngleToTarget.cs new file mode 100644 index 00000000..cee67ccb --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetAngleToTarget.cs @@ -0,0 +1,66 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityTransform +{ + [TaskCategory("Basic/Transform")] + [TaskDescription("Gets the Angle between a GameObject's forward direction and a target. Returns Success.")] + public class GetAngleToTarget : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The target object to measure the angle to. If null the targetPosition will be used.")] + public SharedGameObject targetObject; + [Tooltip("The world position to measure an angle to. If the targetObject is also not null, this value is used as an offset from that object's position.")] + public SharedVector3 targetPosition; + [Tooltip("Ignore height differences when calculating the angle?")] + public SharedBool ignoreHeight = true; + [Tooltip("The angle to the target")] + [RequiredField] + public SharedFloat storeValue; + + private Transform targetTransform; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + targetTransform = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (targetTransform == null) { + Debug.LogWarning("Transform is null"); + return TaskStatus.Failure; + } + + Vector3 targetPos; + if (targetObject.Value != null) { + targetPos = targetObject.Value.transform.InverseTransformPoint(targetPosition.Value); + } else { + targetPos = targetPosition.Value; + } + + if (ignoreHeight.Value) { + targetPos.y = targetTransform.position.y; + } + + var targetDir = targetPos - targetTransform.position; + storeValue.Value = Vector3.Angle(targetDir, targetTransform.forward); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + targetObject = null; + targetPosition = Vector3.zero; + ignoreHeight = true; + storeValue = 0; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetAngleToTarget.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetAngleToTarget.cs.meta new file mode 100644 index 00000000..d34a2704 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetAngleToTarget.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ae176a605fff9a2468198085313c26ad +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetChild.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetChild.cs new file mode 100644 index 00000000..337e2341 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetChild.cs @@ -0,0 +1,48 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityTransform +{ + [TaskCategory("Basic/Transform")] + [TaskDescription("Stores the transform child at the specified index. Returns Success.")] + public class GetChild : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The index of the child")] + public SharedInt index; + [Tooltip("The child of the Transform")] + [RequiredField] + public SharedTransform storeValue; + + private Transform targetTransform; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + targetTransform = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (targetTransform == null) { + Debug.LogWarning("Transform is null"); + return TaskStatus.Failure; + } + + storeValue.Value = targetTransform.GetChild(index.Value); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + index = 0; + storeValue = null; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetChild.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetChild.cs.meta new file mode 100644 index 00000000..a90dba3a --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetChild.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 04ea225bb12181a4daf7f3d6a21eaa5d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetChildCount.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetChildCount.cs new file mode 100644 index 00000000..aca95e80 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetChildCount.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityTransform +{ + [TaskCategory("Basic/Transform")] + [TaskDescription("Stores the number of children a Transform has. Returns Success.")] + public class GetChildCount : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The number of children")] + [RequiredField] + public SharedInt storeValue; + + private Transform targetTransform; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + targetTransform = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (targetTransform == null) { + Debug.LogWarning("Transform is null"); + return TaskStatus.Failure; + } + + storeValue.Value = targetTransform.childCount; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + storeValue = 0; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetChildCount.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetChildCount.cs.meta new file mode 100644 index 00000000..0ff26358 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetChildCount.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8e31c13112e4d334ab9d67feaac94d3f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetEulerAngles.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetEulerAngles.cs new file mode 100644 index 00000000..a7764a8b --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetEulerAngles.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityTransform +{ + [TaskCategory("Basic/Transform")] + [TaskDescription("Stores the euler angles of the Transform. Returns Success.")] + public class GetEulerAngles : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The euler angles of the Transform")] + [RequiredField] + public SharedVector3 storeValue; + + private Transform targetTransform; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + targetTransform = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (targetTransform == null) { + Debug.LogWarning("Transform is null"); + return TaskStatus.Failure; + } + + storeValue.Value = targetTransform.eulerAngles; + + 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/Transform/GetEulerAngles.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetEulerAngles.cs.meta new file mode 100644 index 00000000..0118e3b4 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetEulerAngles.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 43295a23f5d9cb345ae408d5ac843b52 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetForwardVector.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetForwardVector.cs new file mode 100644 index 00000000..0420db5b --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetForwardVector.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityTransform +{ + [TaskCategory("Basic/Transform")] + [TaskDescription("Stores the forward vector of the Transform. Returns Success.")] + public class GetForwardVector : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The position of the Transform")] + [RequiredField] + public SharedVector3 storeValue; + + private Transform targetTransform; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + targetTransform = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (targetTransform == null) { + Debug.LogWarning("Transform is null"); + return TaskStatus.Failure; + } + + storeValue.Value = targetTransform.forward; + + 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/Transform/GetForwardVector.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetForwardVector.cs.meta new file mode 100644 index 00000000..6bda0d73 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetForwardVector.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a5748c07a5ebe54429eb3e9ae032b5e2 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetLocalEulerAngles.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetLocalEulerAngles.cs new file mode 100644 index 00000000..fee24dde --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetLocalEulerAngles.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityTransform +{ + [TaskCategory("Basic/Transform")] + [TaskDescription("Stores the local euler angles of the Transform. Returns Success.")] + public class GetLocalEulerAngles : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The local euler angles of the Transform")] + [RequiredField] + public SharedVector3 storeValue; + + private Transform targetTransform; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + targetTransform = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (targetTransform == null) { + Debug.LogWarning("Transform is null"); + return TaskStatus.Failure; + } + + storeValue.Value = targetTransform.localEulerAngles; + + 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/Transform/GetLocalEulerAngles.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetLocalEulerAngles.cs.meta new file mode 100644 index 00000000..40c781a6 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetLocalEulerAngles.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 459c793e1b836104f901813471414ccc +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetLocalPosition.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetLocalPosition.cs new file mode 100644 index 00000000..56737de6 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetLocalPosition.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityTransform +{ + [TaskCategory("Basic/Transform")] + [TaskDescription("Stores the local position of the Transform. Returns Success.")] + public class GetLocalPosition : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The local position of the Transform")] + [RequiredField] + public SharedVector3 storeValue; + + private Transform targetTransform; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + targetTransform = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (targetTransform == null) { + Debug.LogWarning("Transform is null"); + return TaskStatus.Failure; + } + + storeValue.Value = targetTransform.localPosition; + + 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/Transform/GetLocalPosition.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetLocalPosition.cs.meta new file mode 100644 index 00000000..57d121c8 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetLocalPosition.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4fdc0d751b2c91f438142cf65fcbba34 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetLocalRotation.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetLocalRotation.cs new file mode 100644 index 00000000..e2572ab1 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetLocalRotation.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityTransform +{ + [TaskCategory("Basic/Transform")] + [TaskDescription("Stores the local rotation of the Transform. Returns Success.")] + public class GetLocalRotation : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The local rotation of the Transform")] + [RequiredField] + public SharedQuaternion storeValue; + + private Transform targetTransform; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + targetTransform = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (targetTransform == null) { + Debug.LogWarning("Transform is null"); + return TaskStatus.Failure; + } + + storeValue.Value = targetTransform.localRotation; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + storeValue = Quaternion.identity; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetLocalRotation.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetLocalRotation.cs.meta new file mode 100644 index 00000000..6cc867c3 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetLocalRotation.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2334ddf0e58b67e40ad16e2f63dad8ee +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetLocalScale.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetLocalScale.cs new file mode 100644 index 00000000..bfdc2831 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetLocalScale.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityTransform +{ + [TaskCategory("Basic/Transform")] + [TaskDescription("Stores the local scale of the Transform. Returns Success.")] + public class GetLocalScale : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The local scale of the Transform")] + [RequiredField] + public SharedVector3 storeValue; + + private Transform targetTransform; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + targetTransform = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (targetTransform == null) { + Debug.LogWarning("Transform is null"); + return TaskStatus.Failure; + } + + storeValue.Value = targetTransform.localScale; + + 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/Transform/GetLocalScale.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetLocalScale.cs.meta new file mode 100644 index 00000000..115bef16 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetLocalScale.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e0b10fe3fcda1914fbbdde4a860cd403 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetParent.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetParent.cs new file mode 100644 index 00000000..53f2ee1e --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetParent.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityTransform +{ + [TaskCategory("Basic/Transform")] + [TaskDescription("Stores the parent of the Transform. Returns Success.")] + public class GetParent : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The parent of the Transform")] + [RequiredField] + public SharedTransform storeValue; + + private Transform targetTransform; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + targetTransform = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (targetTransform == null) { + Debug.LogWarning("Transform is null"); + return TaskStatus.Failure; + } + + storeValue.Value = targetTransform.parent; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + storeValue = null; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetParent.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetParent.cs.meta new file mode 100644 index 00000000..2dffa644 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetParent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f149245d8fce789498c301657a7eaf88 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetPosition.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetPosition.cs new file mode 100644 index 00000000..f6977b2e --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetPosition.cs @@ -0,0 +1,50 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityTransform +{ + [TaskCategory("Basic/Transform")] + [TaskDescription("Stores the position of the Transform. Returns Success.")] + public class GetPosition : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("Can the target GameObject be empty?")] + public SharedBool allowEmptyTarget; + [Tooltip("The position of the Transform")] + [RequiredField] + public SharedVector3 storeValue; + + private Transform targetTransform; + private GameObject prevGameObject; + + public override void OnStart() + { + if (!allowEmptyTarget.Value) { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + targetTransform = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + } + + public override TaskStatus OnUpdate() + { + if (targetTransform == null) { + Debug.LogWarning("Transform is null"); + return TaskStatus.Failure; + } + + storeValue.Value = targetTransform.position; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + allowEmptyTarget = false; + storeValue = Vector3.zero; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetPosition.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetPosition.cs.meta new file mode 100644 index 00000000..207a32c8 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetPosition.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9ce1fdc3f652b3043b5116efba12cc48 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetRightVector.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetRightVector.cs new file mode 100644 index 00000000..370d14a9 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetRightVector.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityTransform +{ + [TaskCategory("Basic/Transform")] + [TaskDescription("Stores the right vector of the Transform. Returns Success.")] + public class GetRightVector : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The position of the Transform")] + [RequiredField] + public SharedVector3 storeValue; + + private Transform targetTransform; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + targetTransform = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (targetTransform == null) { + Debug.LogWarning("Transform is null"); + return TaskStatus.Failure; + } + + storeValue.Value = targetTransform.right; + + 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/Transform/GetRightVector.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetRightVector.cs.meta new file mode 100644 index 00000000..202902a1 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetRightVector.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6b5147164f2674547888db24cba68770 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetRotation.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetRotation.cs new file mode 100644 index 00000000..d8a16aec --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetRotation.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityTransform +{ + [TaskCategory("Basic/Transform")] + [TaskDescription("Stores the rotation of the Transform. Returns Success.")] + public class GetRotation : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The rotation of the Transform")] + [RequiredField] + public SharedQuaternion storeValue; + + private Transform targetTransform; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + targetTransform = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (targetTransform == null) { + Debug.LogWarning("Transform is null"); + return TaskStatus.Failure; + } + + storeValue.Value = targetTransform.rotation; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + storeValue = Quaternion.identity; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetRotation.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetRotation.cs.meta new file mode 100644 index 00000000..ca52e97b --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetRotation.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5384b69809f40f5489ca7d7d345471d2 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetUpVector.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetUpVector.cs new file mode 100644 index 00000000..e557b713 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetUpVector.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityTransform +{ + [TaskCategory("Basic/Transform")] + [TaskDescription("Stores the up vector of the Transform. Returns Success.")] + public class GetUpVector : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The position of the Transform")] + [RequiredField] + public SharedVector3 storeValue; + + private Transform targetTransform; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + targetTransform = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (targetTransform == null) { + Debug.LogWarning("Transform is null"); + return TaskStatus.Failure; + } + + storeValue.Value = targetTransform.up; + + 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/Transform/GetUpVector.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetUpVector.cs.meta new file mode 100644 index 00000000..0e6f55a2 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/GetUpVector.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 605a7c93705031042be47bd4a4ab6079 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/IsChildOf.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/IsChildOf.cs new file mode 100644 index 00000000..4e4886b4 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/IsChildOf.cs @@ -0,0 +1,42 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityTransform +{ + [TaskCategory("Basic/Transform")] + [TaskDescription("Returns Success if the transform is a child of the specified GameObject.")] + public class IsChildOf : Conditional + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The interested transform")] + public SharedTransform transformName; + + private Transform targetTransform; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + targetTransform = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (targetTransform == null) { + Debug.LogWarning("Transform is null"); + return TaskStatus.Failure; + } + + return targetTransform.IsChildOf(transformName.Value) ? TaskStatus.Success : TaskStatus.Failure; + } + + public override void OnReset() + { + targetGameObject = null; + transformName = null; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/IsChildOf.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/IsChildOf.cs.meta new file mode 100644 index 00000000..9f93239e --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/IsChildOf.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 304e488eb1caa4f45a8bd903292492ca +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/LookAt.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/LookAt.cs new file mode 100644 index 00000000..bee3c7a9 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/LookAt.cs @@ -0,0 +1,47 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityTransform +{ + [TaskCategory("Basic/Transform")] + [TaskDescription("Rotates the transform so the forward vector points at worldPosition. Returns Success.")] + public class LookAt : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("Point to look at")] + public SharedVector3 worldPosition; + [Tooltip("Vector specifying the upward direction")] + public Vector3 worldUp; + + private Transform targetTransform; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + targetTransform = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (targetTransform == null) { + Debug.LogWarning("Transform is null"); + return TaskStatus.Failure; + } + + targetTransform.LookAt(worldPosition.Value, worldUp); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + worldPosition = Vector3.up; + worldUp = Vector3.up; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/LookAt.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/LookAt.cs.meta new file mode 100644 index 00000000..6e3189ff --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/LookAt.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 64883614392671f438244b3aa5b91c6c +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/Rotate.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/Rotate.cs new file mode 100644 index 00000000..267fe653 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/Rotate.cs @@ -0,0 +1,47 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityTransform +{ + [TaskCategory("Basic/Transform")] + [TaskDescription("Applies a rotation. Returns Success.")] + public class Rotate : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("Amount to rotate")] + public SharedVector3 eulerAngles; + [Tooltip("Specifies which axis the rotation is relative to")] + public Space relativeTo = Space.Self; + + private Transform targetTransform; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + targetTransform = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (targetTransform == null) { + Debug.LogWarning("Transform is null"); + return TaskStatus.Failure; + } + + targetTransform.Rotate(eulerAngles.Value, relativeTo); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + eulerAngles = Vector3.zero; + relativeTo = Space.Self; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/Rotate.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/Rotate.cs.meta new file mode 100644 index 00000000..b4a9c387 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/Rotate.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: db0cba6372babb541a0da57412963760 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/RotateAround.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/RotateAround.cs new file mode 100644 index 00000000..ac3feb57 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/RotateAround.cs @@ -0,0 +1,50 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityTransform +{ + [TaskCategory("Basic/Transform")] + [TaskDescription("Applies a rotation. Returns Success.")] + public class RotateAround : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("Point to rotate around")] + public SharedVector3 point; + [Tooltip("Axis to rotate around")] + public SharedVector3 axis; + [Tooltip("Amount to rotate")] + public SharedFloat angle; + + private Transform targetTransform; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + targetTransform = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (targetTransform == null) { + Debug.LogWarning("Transform is null"); + return TaskStatus.Failure; + } + + targetTransform.RotateAround(point.Value, axis.Value, angle.Value); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + point = Vector3.zero; + axis = Vector3.zero; + angle = 0; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/RotateAround.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/RotateAround.cs.meta new file mode 100644 index 00000000..8bd780cc --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/RotateAround.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 65cef920fcc4ec449a1e6a29fe79c024 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetEulerAngles.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetEulerAngles.cs new file mode 100644 index 00000000..bc509186 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetEulerAngles.cs @@ -0,0 +1,44 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityTransform +{ + [TaskCategory("Basic/Transform")] + [TaskDescription("Sets the euler angles of the Transform. Returns Success.")] + public class SetEulerAngles : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The euler angles of the Transform")] + public SharedVector3 eulerAngles; + + private Transform targetTransform; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + targetTransform = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (targetTransform == null) { + Debug.LogWarning("Transform is null"); + return TaskStatus.Failure; + } + + targetTransform.eulerAngles = eulerAngles.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + eulerAngles = Vector3.zero; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetEulerAngles.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetEulerAngles.cs.meta new file mode 100644 index 00000000..4a20efd1 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetEulerAngles.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: edad3f12ad10ba14aac656b7f431ff31 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetForwardVector.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetForwardVector.cs new file mode 100644 index 00000000..6deec202 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetForwardVector.cs @@ -0,0 +1,44 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityTransform +{ + [TaskCategory("Basic/Transform")] + [TaskDescription("Sets the forward vector of the Transform. Returns Success.")] + public class SetForwardVector : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The position of the Transform")] + public SharedVector3 position; + + private Transform targetTransform; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + targetTransform = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (targetTransform == null) { + Debug.LogWarning("Transform is null"); + return TaskStatus.Failure; + } + + targetTransform.forward = position.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + position = Vector3.zero; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetForwardVector.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetForwardVector.cs.meta new file mode 100644 index 00000000..283c1b33 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetForwardVector.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4cf669b5419d7294cb72c90881267c0c +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetLocalEulerAngles.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetLocalEulerAngles.cs new file mode 100644 index 00000000..fcb72a1a --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetLocalEulerAngles.cs @@ -0,0 +1,44 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityTransform +{ + [TaskCategory("Basic/Transform")] + [TaskDescription("Sets the local euler angles of the Transform. Returns Success.")] + public class SetLocalEulerAngles : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The local euler angles of the Transform")] + public SharedVector3 localEulerAngles; + + private Transform targetTransform; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + targetTransform = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (targetTransform == null) { + Debug.LogWarning("Transform is null"); + return TaskStatus.Failure; + } + + targetTransform.localEulerAngles = localEulerAngles.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + localEulerAngles = Vector3.zero; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetLocalEulerAngles.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetLocalEulerAngles.cs.meta new file mode 100644 index 00000000..644c7104 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetLocalEulerAngles.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2e1ed691ebf9f154e88bb8be7319baad +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetLocalPosition.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetLocalPosition.cs new file mode 100644 index 00000000..9ef9f235 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetLocalPosition.cs @@ -0,0 +1,44 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityTransform +{ + [TaskCategory("Basic/Transform")] + [TaskDescription("Sets the local position of the Transform. Returns Success.")] + public class SetLocalPosition : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The local position of the Transform")] + public SharedVector3 localPosition; + + private Transform targetTransform; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + targetTransform = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (targetTransform == null) { + Debug.LogWarning("Transform is null"); + return TaskStatus.Failure; + } + + targetTransform.localPosition = localPosition.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + localPosition = Vector3.zero; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetLocalPosition.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetLocalPosition.cs.meta new file mode 100644 index 00000000..53cc9193 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetLocalPosition.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5af08673c7a3bb54c974bb23094d4587 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetLocalRotation.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetLocalRotation.cs new file mode 100644 index 00000000..f21d3b5a --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetLocalRotation.cs @@ -0,0 +1,44 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityTransform +{ + [TaskCategory("Basic/Transform")] + [TaskDescription("Sets the local rotation of the Transform. Returns Success.")] + public class SetLocalRotation : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The local rotation of the Transform")] + public SharedQuaternion localRotation; + + private Transform targetTransform; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + targetTransform = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (targetTransform == null) { + Debug.LogWarning("Transform is null"); + return TaskStatus.Failure; + } + + targetTransform.localRotation = localRotation.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + localRotation = Quaternion.identity; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetLocalRotation.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetLocalRotation.cs.meta new file mode 100644 index 00000000..26baaac4 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetLocalRotation.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: de22c6e6826367540b2f25957757a1d4 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetLocalScale.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetLocalScale.cs new file mode 100644 index 00000000..7b0f68ad --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetLocalScale.cs @@ -0,0 +1,44 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityTransform +{ + [TaskCategory("Basic/Transform")] + [TaskDescription("Sets the local scale of the Transform. Returns Success.")] + public class SetLocalScale : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The local scale of the Transform")] + public SharedVector3 localScale; + + private Transform targetTransform; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + targetTransform = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (targetTransform == null) { + Debug.LogWarning("Transform is null"); + return TaskStatus.Failure; + } + + targetTransform.localScale = localScale.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + localScale = Vector3.zero; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetLocalScale.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetLocalScale.cs.meta new file mode 100644 index 00000000..63025bea --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetLocalScale.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 354ce71974ea2b44ab820c8285f72421 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetParent.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetParent.cs new file mode 100644 index 00000000..92673a8a --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetParent.cs @@ -0,0 +1,44 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityTransform +{ + [TaskCategory("Basic/Transform")] + [TaskDescription("Sets the parent of the Transform. Returns Success.")] + public class SetParent : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The parent of the Transform")] + public SharedTransform parent; + + private Transform targetTransform; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + targetTransform = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (targetTransform == null) { + Debug.LogWarning("Transform is null"); + return TaskStatus.Failure; + } + + targetTransform.parent = parent.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + parent = null; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetParent.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetParent.cs.meta new file mode 100644 index 00000000..17981286 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetParent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a19c91d6c31b48d45b2ea97efeae14aa +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetPosition.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetPosition.cs new file mode 100644 index 00000000..28bcf0b1 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetPosition.cs @@ -0,0 +1,44 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityTransform +{ + [TaskCategory("Basic/Transform")] + [TaskDescription("Sets the position of the Transform. Returns Success.")] + public class SetPosition : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The position of the Transform")] + public SharedVector3 position; + + private Transform targetTransform; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + targetTransform = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (targetTransform == null) { + Debug.LogWarning("Transform is null"); + return TaskStatus.Failure; + } + + targetTransform.position = position.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + position = Vector3.zero; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetPosition.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetPosition.cs.meta new file mode 100644 index 00000000..1273580e --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetPosition.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d0586a5078618624398df51fd677a2e0 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetRightVector.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetRightVector.cs new file mode 100644 index 00000000..9479a024 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetRightVector.cs @@ -0,0 +1,44 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityTransform +{ + [TaskCategory("Basic/Transform")] + [TaskDescription("Sets the right vector of the Transform. Returns Success.")] + public class SetRightVector : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The position of the Transform")] + public SharedVector3 position; + + private Transform targetTransform; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + targetTransform = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (targetTransform == null) { + Debug.LogWarning("Transform is null"); + return TaskStatus.Failure; + } + + targetTransform.right = position.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + position = Vector3.zero; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetRightVector.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetRightVector.cs.meta new file mode 100644 index 00000000..a27cf794 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetRightVector.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4629bee77af22ca42a716dfa8ad3e669 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetRotation.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetRotation.cs new file mode 100644 index 00000000..8885fa78 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetRotation.cs @@ -0,0 +1,44 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityTransform +{ + [TaskCategory("Basic/Transform")] + [TaskDescription("Sets the rotation of the Transform. Returns Success.")] + public class SetRotation : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The rotation of the Transform")] + public SharedQuaternion rotation; + + private Transform targetTransform; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + targetTransform = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (targetTransform == null) { + Debug.LogWarning("Transform is null"); + return TaskStatus.Failure; + } + + targetTransform.rotation = rotation.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + rotation = Quaternion.identity; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetRotation.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetRotation.cs.meta new file mode 100644 index 00000000..53f60e32 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetRotation.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fb61cc6175ff14c4d84c3c72541bc30d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetUpVector.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetUpVector.cs new file mode 100644 index 00000000..8edbbc3b --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetUpVector.cs @@ -0,0 +1,44 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityTransform +{ + [TaskCategory("Basic/Transform")] + [TaskDescription("Sets the up vector of the Transform. Returns Success.")] + public class SetUpVector : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The position of the Transform")] + public SharedVector3 position; + + private Transform targetTransform; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + targetTransform = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (targetTransform == null) { + Debug.LogWarning("Transform is null"); + return TaskStatus.Failure; + } + + targetTransform.up = position.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + position = Vector3.zero; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetUpVector.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetUpVector.cs.meta new file mode 100644 index 00000000..4b2cc9fe --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/SetUpVector.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2e65dee462c24694a9835796a770af6e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/Translate.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/Translate.cs new file mode 100644 index 00000000..bc636713 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/Translate.cs @@ -0,0 +1,47 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityTransform +{ + [TaskCategory("Basic/Transform")] + [TaskDescription("Moves the transform in the direction and distance of translation. Returns Success.")] + public class Translate : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("Move direction and distance")] + public SharedVector3 translation; + [Tooltip("Specifies which axis the rotation is relative to")] + public Space relativeTo = Space.Self; + + private Transform targetTransform; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + targetTransform = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (targetTransform == null) { + Debug.LogWarning("Transform is null"); + return TaskStatus.Failure; + } + + targetTransform.Translate(translation.Value, relativeTo); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + translation = Vector3.zero; + relativeTo = Space.Self; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/Translate.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/Translate.cs.meta new file mode 100644 index 00000000..7a7a81b5 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Transform/Translate.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d4a788705b79d3745a26867acf47a63a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: -- cgit v1.1-26-g67d0