From 21e186f75b504d832d9c7bef0456edd7d5d3155e Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 8 Sep 2021 10:52:35 +0800 Subject: +behavior design --- .../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 | 49 ++++++++++++++++++++++ .../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 | 49 ++++++++++++++++++++++ .../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, 787 insertions(+) create mode 100644 Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetAcceleration.cs create mode 100644 Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetAcceleration.cs.meta create mode 100644 Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetAngularSpeed.cs create mode 100644 Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetAngularSpeed.cs.meta create mode 100644 Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetDestination.cs create mode 100644 Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetDestination.cs.meta create mode 100644 Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetRemainingDistance.cs create mode 100644 Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetRemainingDistance.cs.meta create mode 100644 Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetSpeed.cs create mode 100644 Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetSpeed.cs.meta create mode 100644 Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Move.cs create mode 100644 Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Move.cs.meta create mode 100644 Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/ResetPath.cs create mode 100644 Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/ResetPath.cs.meta create mode 100644 Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Resume.cs create mode 100644 Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Resume.cs.meta create mode 100644 Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetAcceleration.cs create mode 100644 Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetAcceleration.cs.meta create mode 100644 Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetAngularSpeed.cs create mode 100644 Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetAngularSpeed.cs.meta create mode 100644 Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetDestination.cs create mode 100644 Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetDestination.cs.meta create mode 100644 Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetSpeed.cs create mode 100644 Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetSpeed.cs.meta create mode 100644 Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Stop.cs create mode 100644 Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Stop.cs.meta create mode 100644 Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Warp.cs create mode 100644 Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Warp.cs.meta (limited to 'Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent') diff --git a/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetAcceleration.cs b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetAcceleration.cs new file mode 100644 index 00000000..050f35e4 --- /dev/null +++ b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetAcceleration.cs @@ -0,0 +1,49 @@ +using UnityEngine; +#if !(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/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetAcceleration.cs.meta b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetAcceleration.cs.meta new file mode 100644 index 00000000..8640a76e --- /dev/null +++ b/Assets/ThirdParty/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/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetAngularSpeed.cs b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetAngularSpeed.cs new file mode 100644 index 00000000..f5378f2d --- /dev/null +++ b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetAngularSpeed.cs @@ -0,0 +1,49 @@ +using UnityEngine; +#if !(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/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetAngularSpeed.cs.meta b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetAngularSpeed.cs.meta new file mode 100644 index 00000000..6fd470cc --- /dev/null +++ b/Assets/ThirdParty/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/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetDestination.cs b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetDestination.cs new file mode 100644 index 00000000..c85ef613 --- /dev/null +++ b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetDestination.cs @@ -0,0 +1,49 @@ +using UnityEngine; +#if !(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/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetDestination.cs.meta b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetDestination.cs.meta new file mode 100644 index 00000000..e6090098 --- /dev/null +++ b/Assets/ThirdParty/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/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetRemainingDistance.cs b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetRemainingDistance.cs new file mode 100644 index 00000000..e2f49731 --- /dev/null +++ b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetRemainingDistance.cs @@ -0,0 +1,49 @@ +using UnityEngine; +#if !(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/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetRemainingDistance.cs.meta b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetRemainingDistance.cs.meta new file mode 100644 index 00000000..8ac9d355 --- /dev/null +++ b/Assets/ThirdParty/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/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetSpeed.cs b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetSpeed.cs new file mode 100644 index 00000000..1969545f --- /dev/null +++ b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetSpeed.cs @@ -0,0 +1,49 @@ +using UnityEngine; +#if !(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/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetSpeed.cs.meta b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/GetSpeed.cs.meta new file mode 100644 index 00000000..d395eea4 --- /dev/null +++ b/Assets/ThirdParty/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/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Move.cs b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Move.cs new file mode 100644 index 00000000..c3ad27fb --- /dev/null +++ b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Move.cs @@ -0,0 +1,48 @@ +using UnityEngine; +#if !(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/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Move.cs.meta b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Move.cs.meta new file mode 100644 index 00000000..4217e2de --- /dev/null +++ b/Assets/ThirdParty/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/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/ResetPath.cs b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/ResetPath.cs new file mode 100644 index 00000000..3aa1a4bc --- /dev/null +++ b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/ResetPath.cs @@ -0,0 +1,45 @@ +using UnityEngine; +#if !(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/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/ResetPath.cs.meta b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/ResetPath.cs.meta new file mode 100644 index 00000000..2e95416c --- /dev/null +++ b/Assets/ThirdParty/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/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Resume.cs b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Resume.cs new file mode 100644 index 00000000..bf62cb97 --- /dev/null +++ b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Resume.cs @@ -0,0 +1,49 @@ +using UnityEngine; +#if !(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; + } + +#if UNITY_5_1 || UNITY_5_2 || UNITY_5_3 || UNITY_5_4 || UNITY_5_5 + navMeshAgent.Resume(); +#else + navMeshAgent.isStopped = false; +#endif + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + } + } +} \ No newline at end of file diff --git a/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Resume.cs.meta b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Resume.cs.meta new file mode 100644 index 00000000..16e07057 --- /dev/null +++ b/Assets/ThirdParty/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/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetAcceleration.cs b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetAcceleration.cs new file mode 100644 index 00000000..9473466d --- /dev/null +++ b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetAcceleration.cs @@ -0,0 +1,48 @@ +using UnityEngine; +#if !(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/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetAcceleration.cs.meta b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetAcceleration.cs.meta new file mode 100644 index 00000000..e3090bce --- /dev/null +++ b/Assets/ThirdParty/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/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetAngularSpeed.cs b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetAngularSpeed.cs new file mode 100644 index 00000000..3c7c7721 --- /dev/null +++ b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetAngularSpeed.cs @@ -0,0 +1,48 @@ +using UnityEngine; +#if !(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/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetAngularSpeed.cs.meta b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetAngularSpeed.cs.meta new file mode 100644 index 00000000..0b1d44a5 --- /dev/null +++ b/Assets/ThirdParty/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/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetDestination.cs b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetDestination.cs new file mode 100644 index 00000000..0efa0dba --- /dev/null +++ b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetDestination.cs @@ -0,0 +1,47 @@ +using UnityEngine; +#if !(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/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetDestination.cs.meta b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetDestination.cs.meta new file mode 100644 index 00000000..d5f1bde8 --- /dev/null +++ b/Assets/ThirdParty/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/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetSpeed.cs b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetSpeed.cs new file mode 100644 index 00000000..a1a4a51b --- /dev/null +++ b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetSpeed.cs @@ -0,0 +1,48 @@ +using UnityEngine; +#if !(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/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetSpeed.cs.meta b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/SetSpeed.cs.meta new file mode 100644 index 00000000..79a97d26 --- /dev/null +++ b/Assets/ThirdParty/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/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Stop.cs b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Stop.cs new file mode 100644 index 00000000..0af7d480 --- /dev/null +++ b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Stop.cs @@ -0,0 +1,49 @@ +using UnityEngine; +#if !(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; + } + +#if UNITY_5_1 || UNITY_5_2 || UNITY_5_3 || UNITY_5_4 || UNITY_5_5 + navMeshAgent.Stop(); +#else + navMeshAgent.isStopped = true; +#endif + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + } + } +} \ No newline at end of file diff --git a/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Stop.cs.meta b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Stop.cs.meta new file mode 100644 index 00000000..7a6ada0c --- /dev/null +++ b/Assets/ThirdParty/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/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Warp.cs b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Warp.cs new file mode 100644 index 00000000..d8107173 --- /dev/null +++ b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Warp.cs @@ -0,0 +1,48 @@ +using UnityEngine; +#if !(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/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Warp.cs.meta b/Assets/ThirdParty/Behavior Designer/Runtime/Basic Tasks/NavMeshAgent/Warp.cs.meta new file mode 100644 index 00000000..8a6d4812 --- /dev/null +++ b/Assets/ThirdParty/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