From 6ee18886c8af3858de5e97599b23086823d9f320 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 27 Jan 2021 16:30:19 +0800 Subject: =?UTF-8?q?*=E6=9B=B4=E6=96=B0Behaviour=20Designer=E7=89=88?= =?UTF-8?q?=E6=9C=AC=EF=BC=8C=E5=9C=A8=E6=9C=80=E4=B8=8B=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E6=9C=89BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Basic Tasks/NavMeshAgent/GetAcceleration.cs | 49 ++++++++++++++++++++++ .../NavMeshAgent/GetAcceleration.cs.meta | 8 ++++ .../Basic Tasks/NavMeshAgent/GetAngularSpeed.cs | 49 ++++++++++++++++++++++ .../NavMeshAgent/GetAngularSpeed.cs.meta | 8 ++++ .../Basic Tasks/NavMeshAgent/GetDestination.cs | 49 ++++++++++++++++++++++ .../NavMeshAgent/GetDestination.cs.meta | 8 ++++ .../NavMeshAgent/GetRemainingDistance.cs | 49 ++++++++++++++++++++++ .../NavMeshAgent/GetRemainingDistance.cs.meta | 8 ++++ .../Runtime/Basic Tasks/NavMeshAgent/GetSpeed.cs | 49 ++++++++++++++++++++++ .../Basic Tasks/NavMeshAgent/GetSpeed.cs.meta | 8 ++++ .../Runtime/Basic Tasks/NavMeshAgent/Move.cs | 48 +++++++++++++++++++++ .../Runtime/Basic Tasks/NavMeshAgent/Move.cs.meta | 8 ++++ .../Runtime/Basic Tasks/NavMeshAgent/ResetPath.cs | 45 ++++++++++++++++++++ .../Basic Tasks/NavMeshAgent/ResetPath.cs.meta | 8 ++++ .../Runtime/Basic Tasks/NavMeshAgent/Resume.cs | 45 ++++++++++++++++++++ .../Basic Tasks/NavMeshAgent/Resume.cs.meta | 8 ++++ .../Basic Tasks/NavMeshAgent/SetAcceleration.cs | 48 +++++++++++++++++++++ .../NavMeshAgent/SetAcceleration.cs.meta | 8 ++++ .../Basic Tasks/NavMeshAgent/SetAngularSpeed.cs | 48 +++++++++++++++++++++ .../NavMeshAgent/SetAngularSpeed.cs.meta | 8 ++++ .../Basic Tasks/NavMeshAgent/SetDestination.cs | 47 +++++++++++++++++++++ .../NavMeshAgent/SetDestination.cs.meta | 8 ++++ .../Runtime/Basic Tasks/NavMeshAgent/SetSpeed.cs | 48 +++++++++++++++++++++ .../Basic Tasks/NavMeshAgent/SetSpeed.cs.meta | 8 ++++ .../Runtime/Basic Tasks/NavMeshAgent/Stop.cs | 45 ++++++++++++++++++++ .../Runtime/Basic Tasks/NavMeshAgent/Stop.cs.meta | 8 ++++ .../Runtime/Basic Tasks/NavMeshAgent/Warp.cs | 48 +++++++++++++++++++++ .../Runtime/Basic Tasks/NavMeshAgent/Warp.cs.meta | 8 ++++ 28 files changed, 779 insertions(+) create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetAcceleration.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetAcceleration.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetAngularSpeed.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetAngularSpeed.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetDestination.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetDestination.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetRemainingDistance.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetRemainingDistance.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetSpeed.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetSpeed.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Move.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Move.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/ResetPath.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/ResetPath.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Resume.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Resume.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetAcceleration.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetAcceleration.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetAngularSpeed.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetAngularSpeed.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetDestination.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetDestination.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetSpeed.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetSpeed.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Stop.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Stop.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Warp.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Warp.cs.meta (limited to 'Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent') diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetAcceleration.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetAcceleration.cs new file mode 100644 index 00000000..6b4e63aa --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetAcceleration.cs @@ -0,0 +1,49 @@ +using UnityEngine; +#if !(UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_5_3 || UNITY_5_4) +using UnityEngine.AI; +#endif + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityNavMeshAgent +{ + [TaskCategory("Basic/NavMeshAgent")] + [TaskDescription("Gets the maximum acceleration of an agent as it follows a path, given in units / sec^2.. Returns Success.")] + public class GetAcceleration : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [SharedRequired] + [Tooltip("The NavMeshAgent acceleration")] + public SharedFloat storeValue; + + // cache the navmeshagent component + private NavMeshAgent navMeshAgent; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + navMeshAgent = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (navMeshAgent == null) { + Debug.LogWarning("NavMeshAgent is null"); + return TaskStatus.Failure; + } + + storeValue.Value = navMeshAgent.acceleration; + + 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/NavMeshAgent/GetAcceleration.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetAcceleration.cs.meta new file mode 100644 index 00000000..82d8c438 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetAcceleration.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7e00211632663cc43bc88ab068ab5d44 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetAngularSpeed.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetAngularSpeed.cs new file mode 100644 index 00000000..cb12518e --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetAngularSpeed.cs @@ -0,0 +1,49 @@ +using UnityEngine; +#if !(UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_5_3 || UNITY_5_4) +using UnityEngine.AI; +#endif + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityNavMeshAgent +{ + [TaskCategory("Basic/NavMeshAgent")] + [TaskDescription("Gets the maximum turning speed in (deg/s) while following a path.. Returns Success.")] + public class GetAngularSpeed : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [SharedRequired] + [Tooltip("The NavMeshAgent angular speed")] + public SharedFloat storeValue; + + // cache the navmeshagent component + private NavMeshAgent navMeshAgent; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + navMeshAgent = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (navMeshAgent == null) { + Debug.LogWarning("NavMeshAgent is null"); + return TaskStatus.Failure; + } + + storeValue.Value = navMeshAgent.angularSpeed; + + 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/NavMeshAgent/GetAngularSpeed.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetAngularSpeed.cs.meta new file mode 100644 index 00000000..655ec1a6 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetAngularSpeed.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 110bcd7b4d1baae4096b5da6737c1e16 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetDestination.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetDestination.cs new file mode 100644 index 00000000..ce30de68 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetDestination.cs @@ -0,0 +1,49 @@ +using UnityEngine; +#if !(UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_5_3 || UNITY_5_4) +using UnityEngine.AI; +#endif + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityNavMeshAgent +{ + [TaskCategory("Basic/NavMeshAgent")] + [TaskDescription("Gets the destination of the agent in world-space units. Returns Success.")] + public class GetDestination : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [SharedRequired] + [Tooltip("The NavMeshAgent destination")] + public SharedVector3 storeValue; + + // cache the navmeshagent component + private NavMeshAgent navMeshAgent; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + navMeshAgent = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (navMeshAgent == null) { + Debug.LogWarning("NavMeshAgent is null"); + return TaskStatus.Failure; + } + + storeValue.Value = navMeshAgent.destination; + + 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/NavMeshAgent/GetDestination.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetDestination.cs.meta new file mode 100644 index 00000000..6909e8a0 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetDestination.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4368ae3e22d36604697d420dff004cbe +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetRemainingDistance.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetRemainingDistance.cs new file mode 100644 index 00000000..e7704400 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetRemainingDistance.cs @@ -0,0 +1,49 @@ +using UnityEngine; +#if !(UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_5_3 || UNITY_5_4) +using UnityEngine.AI; +#endif + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityNavMeshAgent +{ + [TaskCategory("Basic/NavMeshAgent")] + [TaskDescription("Gets the distance between the agent's position and the destination on the current path. Returns Success.")] + public class GetRemainingDistance : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [SharedRequired] + [Tooltip("The remaining distance")] + public SharedFloat storeValue; + + // cache the navmeshagent component + private NavMeshAgent navMeshAgent; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + navMeshAgent = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (navMeshAgent == null) { + Debug.LogWarning("NavMeshAgent is null"); + return TaskStatus.Failure; + } + + storeValue.Value = navMeshAgent.remainingDistance; + + 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/NavMeshAgent/GetRemainingDistance.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetRemainingDistance.cs.meta new file mode 100644 index 00000000..f07ba122 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetRemainingDistance.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ab046b37543b6744aa440cd708a93b81 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetSpeed.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetSpeed.cs new file mode 100644 index 00000000..595a9538 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetSpeed.cs @@ -0,0 +1,49 @@ +using UnityEngine; +#if !(UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_5_3 || UNITY_5_4) +using UnityEngine.AI; +#endif + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityNavMeshAgent +{ + [TaskCategory("Basic/NavMeshAgent")] + [TaskDescription("Gets the maximum movement speed when following a path. Returns Success.")] + public class GetSpeed : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [SharedRequired] + [Tooltip("The NavMeshAgent speed")] + public SharedFloat storeValue; + + // cache the navmeshagent component + private NavMeshAgent navMeshAgent; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + navMeshAgent = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (navMeshAgent == null) { + Debug.LogWarning("NavMeshAgent is null"); + return TaskStatus.Failure; + } + + storeValue.Value = navMeshAgent.speed; + + 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/NavMeshAgent/GetSpeed.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetSpeed.cs.meta new file mode 100644 index 00000000..5d4defe0 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetSpeed.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b6397854a3aea4b44a5ab4ccf98d082d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Move.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Move.cs new file mode 100644 index 00000000..0c29e44a --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Move.cs @@ -0,0 +1,48 @@ +using UnityEngine; +#if !(UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_5_3 || UNITY_5_4) +using UnityEngine.AI; +#endif + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityNavMeshAgent +{ + [TaskCategory("Basic/NavMeshAgent")] + [TaskDescription("Apply relative movement to the current position. Returns Success.")] + public class Move : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The relative movement vector")] + public SharedVector3 offset; + + // cache the navmeshagent component + private NavMeshAgent navMeshAgent; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + navMeshAgent = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (navMeshAgent == null) { + Debug.LogWarning("NavMeshAgent is null"); + return TaskStatus.Failure; + } + + navMeshAgent.Move(offset.Value); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + offset = Vector3.zero; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Move.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Move.cs.meta new file mode 100644 index 00000000..4217e2de --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Move.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 55ea16e678f6fae47a46affd3d22b883 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/ResetPath.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/ResetPath.cs new file mode 100644 index 00000000..0f8ed1ae --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/ResetPath.cs @@ -0,0 +1,45 @@ +using UnityEngine; +#if !(UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_5_3 || UNITY_5_4) +using UnityEngine.AI; +#endif + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityNavMeshAgent +{ + [TaskCategory("Basic/NavMeshAgent")] + [TaskDescription("Clears the current path. Returns Success.")] + public class ResetPath : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + + // cache the navmeshagent component + private NavMeshAgent navMeshAgent; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + navMeshAgent = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (navMeshAgent == null) { + Debug.LogWarning("NavMeshAgent is null"); + return TaskStatus.Failure; + } + + navMeshAgent.ResetPath(); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/ResetPath.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/ResetPath.cs.meta new file mode 100644 index 00000000..579ffdc5 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/ResetPath.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e90973887b9e7d04aafc5d13ecdfc8b9 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Resume.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Resume.cs new file mode 100644 index 00000000..169c657d --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Resume.cs @@ -0,0 +1,45 @@ +using UnityEngine; +#if !(UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_5_3 || UNITY_5_4) +using UnityEngine.AI; +#endif + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityNavMeshAgent +{ + [TaskCategory("Basic/NavMeshAgent")] + [TaskDescription("Resumes the movement along the current path after a pause. Returns Success.")] + public class Resume : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + + // cache the navmeshagent component + private NavMeshAgent navMeshAgent; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + navMeshAgent = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (navMeshAgent == null) { + Debug.LogWarning("NavMeshAgent is null"); + return TaskStatus.Failure; + } + + navMeshAgent.Resume(); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Resume.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Resume.cs.meta new file mode 100644 index 00000000..94fe5b40 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Resume.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2c87e343e0ec23041b0cf7d8090d4814 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetAcceleration.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetAcceleration.cs new file mode 100644 index 00000000..88bfc208 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetAcceleration.cs @@ -0,0 +1,48 @@ +using UnityEngine; +#if !(UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_5_3 || UNITY_5_4) +using UnityEngine.AI; +#endif + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityNavMeshAgent +{ + [TaskCategory("Basic/NavMeshAgent")] + [TaskDescription("Sets the maximum acceleration of an agent as it follows a path, given in units / sec^2. Returns Success.")] + public class SetAcceleration : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The NavMeshAgent acceleration")] + public SharedFloat acceleration; + + // cache the navmeshagent component + private NavMeshAgent navMeshAgent; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + navMeshAgent = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (navMeshAgent == null) { + Debug.LogWarning("NavMeshAgent is null"); + return TaskStatus.Failure; + } + + navMeshAgent.acceleration = acceleration.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + acceleration = 0; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetAcceleration.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetAcceleration.cs.meta new file mode 100644 index 00000000..31d7d122 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetAcceleration.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a8357209bccc16442b549c580872bb05 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetAngularSpeed.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetAngularSpeed.cs new file mode 100644 index 00000000..c28f3fec --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetAngularSpeed.cs @@ -0,0 +1,48 @@ +using UnityEngine; +#if !(UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_5_3 || UNITY_5_4) +using UnityEngine.AI; +#endif + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityNavMeshAgent +{ + [TaskCategory("Basic/NavMeshAgent")] + [TaskDescription("Sets the maximum turning speed in (deg/s) while following a path. Returns Success.")] + public class SetAngularSpeed : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The NavMeshAgent angular speed")] + public SharedFloat angularSpeed; + + // cache the navmeshagent component + private NavMeshAgent navMeshAgent; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + navMeshAgent = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (navMeshAgent == null) { + Debug.LogWarning("NavMeshAgent is null"); + return TaskStatus.Failure; + } + + navMeshAgent.angularSpeed = angularSpeed.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + angularSpeed = 0; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetAngularSpeed.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetAngularSpeed.cs.meta new file mode 100644 index 00000000..a19eb41c --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetAngularSpeed.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0d8e213aa17540848b83b17ba1609c74 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetDestination.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetDestination.cs new file mode 100644 index 00000000..7cec4f90 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetDestination.cs @@ -0,0 +1,47 @@ +using UnityEngine; +#if !(UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_5_3 || UNITY_5_4) +using UnityEngine.AI; +#endif + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityNavMeshAgent +{ + [TaskCategory("Basic/NavMeshAgent")] + [TaskDescription("Sets the destination of the agent in world-space units. Returns Success if the destination is valid.")] + public class SetDestination: Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [SharedRequired] + [Tooltip("The NavMeshAgent destination")] + public SharedVector3 destination; + + // cache the navmeshagent component + private NavMeshAgent navMeshAgent; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + navMeshAgent = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (navMeshAgent == null) { + Debug.LogWarning("NavMeshAgent is null"); + return TaskStatus.Failure; + } + + return navMeshAgent.SetDestination(destination.Value) ? TaskStatus.Success : TaskStatus.Failure; + } + + public override void OnReset() + { + targetGameObject = null; + destination = Vector3.zero; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetDestination.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetDestination.cs.meta new file mode 100644 index 00000000..5f6feda6 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetDestination.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 55d9c2d20e895104181ae1b484868ead +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetSpeed.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetSpeed.cs new file mode 100644 index 00000000..f39b6ce4 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetSpeed.cs @@ -0,0 +1,48 @@ +using UnityEngine; +#if !(UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_5_3 || UNITY_5_4) +using UnityEngine.AI; +#endif + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityNavMeshAgent +{ + [TaskCategory("Basic/NavMeshAgent")] + [TaskDescription("Sets the maximum movement speed when following a path. Returns Success.")] + public class SetSpeed : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The NavMeshAgent speed")] + public SharedFloat speed; + + // cache the navmeshagent component + private NavMeshAgent navMeshAgent; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + navMeshAgent = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (navMeshAgent == null) { + Debug.LogWarning("NavMeshAgent is null"); + return TaskStatus.Failure; + } + + navMeshAgent.speed = speed.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + speed = 0; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetSpeed.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetSpeed.cs.meta new file mode 100644 index 00000000..3173ef55 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetSpeed.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 34372b45870504b419f34165fb1fa4fb +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Stop.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Stop.cs new file mode 100644 index 00000000..56d4edd2 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Stop.cs @@ -0,0 +1,45 @@ +using UnityEngine; +#if !(UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_5_3 || UNITY_5_4) +using UnityEngine.AI; +#endif + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityNavMeshAgent +{ + [TaskCategory("Basic/NavMeshAgent")] + [TaskDescription("Stop movement of this agent along its current path. Returns Success.")] + public class Stop : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + + // cache the navmeshagent component + private NavMeshAgent navMeshAgent; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + navMeshAgent = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (navMeshAgent == null) { + Debug.LogWarning("NavMeshAgent is null"); + return TaskStatus.Failure; + } + + navMeshAgent.Stop(); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Stop.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Stop.cs.meta new file mode 100644 index 00000000..67e0d39c --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Stop.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b20958b8b92e47f40ba3178c99576182 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Warp.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Warp.cs new file mode 100644 index 00000000..a26cf64f --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Warp.cs @@ -0,0 +1,48 @@ +using UnityEngine; +#if !(UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_5_3 || UNITY_5_4) +using UnityEngine.AI; +#endif + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityNavMeshAgent +{ + [TaskCategory("Basic/NavMeshAgent")] + [TaskDescription("Warps agent to the provided position. Returns Success.")] + public class Warp : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The position to warp to")] + public SharedVector3 newPosition; + + // cache the navmeshagent component + private NavMeshAgent navMeshAgent; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + navMeshAgent = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (navMeshAgent == null) { + Debug.LogWarning("NavMeshAgent is null"); + return TaskStatus.Failure; + } + + navMeshAgent.Warp(newPosition.Value); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + newPosition = Vector3.zero; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Warp.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Warp.cs.meta new file mode 100644 index 00000000..9b175914 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Warp.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9d2356bfaf0a64b4d9d65d32708630db +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: -- cgit v1.1-26-g67d0