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/Rigidbody2D/AddForce.cs | 44 +++++++++++++++++++ .../Basic Tasks/Rigidbody2D/AddForce.cs.meta | 8 ++++ .../Basic Tasks/Rigidbody2D/AddForceAtPosition.cs | 47 ++++++++++++++++++++ .../Rigidbody2D/AddForceAtPosition.cs.meta | 8 ++++ .../Runtime/Basic Tasks/Rigidbody2D/AddTorque.cs | 44 +++++++++++++++++++ .../Basic Tasks/Rigidbody2D/AddTorque.cs.meta | 8 ++++ .../Basic Tasks/Rigidbody2D/GetAngularDrag.cs | 45 +++++++++++++++++++ .../Basic Tasks/Rigidbody2D/GetAngularDrag.cs.meta | 8 ++++ .../Basic Tasks/Rigidbody2D/GetAngularVelocity.cs | 45 +++++++++++++++++++ .../Rigidbody2D/GetAngularVelocity.cs.meta | 8 ++++ .../Runtime/Basic Tasks/Rigidbody2D/GetDrag.cs | 45 +++++++++++++++++++ .../Basic Tasks/Rigidbody2D/GetDrag.cs.meta | 8 ++++ .../Basic Tasks/Rigidbody2D/GetFixedAngle.cs | 47 ++++++++++++++++++++ .../Basic Tasks/Rigidbody2D/GetFixedAngle.cs.meta | 8 ++++ .../Basic Tasks/Rigidbody2D/GetGravtyScale.cs | 45 +++++++++++++++++++ .../Basic Tasks/Rigidbody2D/GetGravtyScale.cs.meta | 8 ++++ .../Basic Tasks/Rigidbody2D/GetIsKinematic.cs | 45 +++++++++++++++++++ .../Basic Tasks/Rigidbody2D/GetIsKinematic.cs.meta | 8 ++++ .../Runtime/Basic Tasks/Rigidbody2D/GetMass.cs | 45 +++++++++++++++++++ .../Basic Tasks/Rigidbody2D/GetMass.cs.meta | 8 ++++ .../Runtime/Basic Tasks/Rigidbody2D/GetPosition.cs | 50 ++++++++++++++++++++++ .../Basic Tasks/Rigidbody2D/GetPosition.cs.meta | 8 ++++ .../Runtime/Basic Tasks/Rigidbody2D/GetRotation.cs | 45 +++++++++++++++++++ .../Basic Tasks/Rigidbody2D/GetRotation.cs.meta | 8 ++++ .../Runtime/Basic Tasks/Rigidbody2D/GetVelocity.cs | 45 +++++++++++++++++++ .../Basic Tasks/Rigidbody2D/GetVelocity.cs.meta | 8 ++++ .../Runtime/Basic Tasks/Rigidbody2D/IsKinematic.cs | 39 +++++++++++++++++ .../Basic Tasks/Rigidbody2D/IsKinematic.cs.meta | 8 ++++ .../Runtime/Basic Tasks/Rigidbody2D/IsSleeping.cs | 39 +++++++++++++++++ .../Basic Tasks/Rigidbody2D/IsSleeping.cs.meta | 8 ++++ .../Basic Tasks/Rigidbody2D/MovePosition.cs | 45 +++++++++++++++++++ .../Basic Tasks/Rigidbody2D/MovePosition.cs.meta | 8 ++++ .../Basic Tasks/Rigidbody2D/MoveRotation.cs | 45 +++++++++++++++++++ .../Basic Tasks/Rigidbody2D/MoveRotation.cs.meta | 8 ++++ .../Basic Tasks/Rigidbody2D/SetAngularDrag.cs | 44 +++++++++++++++++++ .../Basic Tasks/Rigidbody2D/SetAngularDrag.cs.meta | 8 ++++ .../Basic Tasks/Rigidbody2D/SetAngularVelocity.cs | 44 +++++++++++++++++++ .../Rigidbody2D/SetAngularVelocity.cs.meta | 8 ++++ .../Runtime/Basic Tasks/Rigidbody2D/SetDrag.cs | 44 +++++++++++++++++++ .../Basic Tasks/Rigidbody2D/SetDrag.cs.meta | 8 ++++ .../Basic Tasks/Rigidbody2D/SetFixedAngle.cs | 46 ++++++++++++++++++++ .../Basic Tasks/Rigidbody2D/SetFixedAngle.cs.meta | 8 ++++ .../Basic Tasks/Rigidbody2D/SetGravityScale.cs | 44 +++++++++++++++++++ .../Rigidbody2D/SetGravityScale.cs.meta | 8 ++++ .../Basic Tasks/Rigidbody2D/SetIsKinematic.cs | 44 +++++++++++++++++++ .../Basic Tasks/Rigidbody2D/SetIsKinematic.cs.meta | 8 ++++ .../Runtime/Basic Tasks/Rigidbody2D/SetMass.cs | 44 +++++++++++++++++++ .../Basic Tasks/Rigidbody2D/SetMass.cs.meta | 8 ++++ .../Runtime/Basic Tasks/Rigidbody2D/SetVelocity.cs | 44 +++++++++++++++++++ .../Basic Tasks/Rigidbody2D/SetVelocity.cs.meta | 8 ++++ .../Runtime/Basic Tasks/Rigidbody2D/Sleep.cs | 41 ++++++++++++++++++ .../Runtime/Basic Tasks/Rigidbody2D/Sleep.cs.meta | 8 ++++ .../Runtime/Basic Tasks/Rigidbody2D/WakeUp.cs | 41 ++++++++++++++++++ .../Runtime/Basic Tasks/Rigidbody2D/WakeUp.cs.meta | 8 ++++ 54 files changed, 1412 insertions(+) create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/AddForce.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/AddForce.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/AddForceAtPosition.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/AddForceAtPosition.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/AddTorque.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/AddTorque.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetAngularDrag.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetAngularDrag.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetAngularVelocity.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetAngularVelocity.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetDrag.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetDrag.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetFixedAngle.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetFixedAngle.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetGravtyScale.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetGravtyScale.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetIsKinematic.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetIsKinematic.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetMass.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetMass.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetPosition.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetPosition.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetRotation.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetRotation.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetVelocity.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetVelocity.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/IsKinematic.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/IsKinematic.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/IsSleeping.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/IsSleeping.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/MovePosition.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/MovePosition.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/MoveRotation.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/MoveRotation.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetAngularDrag.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetAngularDrag.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetAngularVelocity.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetAngularVelocity.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetDrag.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetDrag.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetFixedAngle.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetFixedAngle.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetGravityScale.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetGravityScale.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetIsKinematic.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetIsKinematic.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetMass.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetMass.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetVelocity.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetVelocity.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/Sleep.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/Sleep.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/WakeUp.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/WakeUp.cs.meta (limited to 'Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D') diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/AddForce.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/AddForce.cs new file mode 100644 index 00000000..bc084e41 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/AddForce.cs @@ -0,0 +1,44 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody2D +{ + [TaskCategory("Basic/Rigidbody2D")] + [TaskDescription("Applies a force to the Rigidbody2D. Returns Success.")] + public class AddForce : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The amount of force to apply")] + public SharedVector2 force; + + private Rigidbody2D rigidbody2D; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody2D = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody2D == null) { + Debug.LogWarning("Rigidbody2D is null"); + return TaskStatus.Failure; + } + + rigidbody2D.AddForce(force.Value); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + force = Vector2.zero; + } + } +} diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/AddForce.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/AddForce.cs.meta new file mode 100644 index 00000000..3f52d151 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/AddForce.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9ea79154ee01cf441a9744c877542a1f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/AddForceAtPosition.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/AddForceAtPosition.cs new file mode 100644 index 00000000..c1a187c6 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/AddForceAtPosition.cs @@ -0,0 +1,47 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody2D +{ + [TaskCategory("Basic/Rigidbody2D")] + [TaskDescription("Applies a force at the specified position to the Rigidbody2D. Returns Success.")] + public class AddForceAtPosition : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The amount of force to apply")] + public SharedVector2 force; + [Tooltip("The position of the force")] + public SharedVector2 position; + + private Rigidbody2D rigidbody2D; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody2D = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody2D == null) { + Debug.LogWarning("Rigidbody2D is null"); + return TaskStatus.Failure; + } + + rigidbody2D.AddForceAtPosition(force.Value, position.Value); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + force = Vector2.zero; + position = Vector2.zero; + } + } +} diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/AddForceAtPosition.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/AddForceAtPosition.cs.meta new file mode 100644 index 00000000..e1edb20c --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/AddForceAtPosition.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: dd82f0f77306bad46bae7944a5c66664 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/AddTorque.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/AddTorque.cs new file mode 100644 index 00000000..9f065e34 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/AddTorque.cs @@ -0,0 +1,44 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody2D +{ + [TaskCategory("Basic/Rigidbody2D")] + [TaskDescription("Applies a torque to the Rigidbody2D. Returns Success.")] + public class AddTorque : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The amount of torque to apply")] + public SharedFloat torque; + + private Rigidbody2D rigidbody2D; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody2D = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody2D == null) { + Debug.LogWarning("Rigidbody2D is null"); + return TaskStatus.Failure; + } + + rigidbody2D.AddTorque(torque.Value); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + torque = 0; + } + } +} diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/AddTorque.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/AddTorque.cs.meta new file mode 100644 index 00000000..d79e4975 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/AddTorque.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cc561d806d4518044becff628e148424 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetAngularDrag.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetAngularDrag.cs new file mode 100644 index 00000000..17080d53 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetAngularDrag.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody2D +{ + [TaskCategory("Basic/Rigidbody2D")] + [TaskDescription("Stores the angular drag of the Rigidbody2D. Returns Success.")] + public class GetAngularDrag : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The angular drag of the Rigidbody2D")] + [RequiredField] + public SharedFloat storeValue; + + private Rigidbody2D rigidbody2D; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody2D = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody2D == null) { + Debug.LogWarning("Rigidbody2D is null"); + return TaskStatus.Failure; + } + + storeValue.Value = rigidbody2D.angularDrag; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + storeValue = 0; + } + } +} diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetAngularDrag.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetAngularDrag.cs.meta new file mode 100644 index 00000000..4aefa782 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetAngularDrag.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 10833270578d69041b561c5126bb31f2 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetAngularVelocity.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetAngularVelocity.cs new file mode 100644 index 00000000..17be28db --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetAngularVelocity.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody2D +{ + [TaskCategory("Basic/Rigidbody2D")] + [TaskDescription("Stores the angular velocity of the Rigidbody2D. Returns Success.")] + public class GetAngularVelocity : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The angular velocity of the Rigidbody2D")] + [RequiredField] + public SharedFloat storeValue; + + private Rigidbody2D rigidbody2D; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody2D = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody2D == null) { + Debug.LogWarning("Rigidbody2D is null"); + return TaskStatus.Failure; + } + + storeValue.Value = rigidbody2D.angularVelocity; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + storeValue = 0; + } + } +} diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetAngularVelocity.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetAngularVelocity.cs.meta new file mode 100644 index 00000000..15cae45b --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetAngularVelocity.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 68ac62a9384c11245a850220f1bc72b8 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetDrag.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetDrag.cs new file mode 100644 index 00000000..b01bf9a2 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetDrag.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody2D +{ + [TaskCategory("Basic/Rigidbody2D")] + [TaskDescription("Stores the drag of the Rigidbody2D. Returns Success.")] + public class GetDrag : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The drag of the Rigidbody2D")] + [RequiredField] + public SharedFloat storeValue; + + private Rigidbody2D rigidbody2D; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody2D = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody2D == null) { + Debug.LogWarning("Rigidbody2D is null"); + return TaskStatus.Failure; + } + + storeValue.Value = rigidbody2D.drag; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + storeValue = 0; + } + } +} diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetDrag.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetDrag.cs.meta new file mode 100644 index 00000000..872fb557 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetDrag.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6e39198e5d65d514185f2816cced7c7b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetFixedAngle.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetFixedAngle.cs new file mode 100644 index 00000000..95a994f3 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetFixedAngle.cs @@ -0,0 +1,47 @@ +#if UNITY_4_6 || UNITY_4_7 || UNITY_5_0 +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody2D +{ + [TaskCategory("Basic/Rigidbody2D")] + [TaskDescription("Stores the fixed angle value of the Rigidbody2D. Returns Success.")] + public class GetFixedAngle : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The fixed angle value of the Rigidbody2D")] + [RequiredField] + public SharedBool storeValue; + + private Rigidbody2D rigidbody2D; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody2D = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody2D == null) { + Debug.LogWarning("Rigidbody2D is null"); + return TaskStatus.Failure; + } + + storeValue.Value = rigidbody2D.fixedAngle; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + storeValue = false; + } + } +} +#endif \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetFixedAngle.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetFixedAngle.cs.meta new file mode 100644 index 00000000..c33cff34 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetFixedAngle.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: eea4c9e433bd63540abef9f91e4c57fb +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetGravtyScale.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetGravtyScale.cs new file mode 100644 index 00000000..9b1ef3a0 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetGravtyScale.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody2D +{ + [TaskCategory("Basic/Rigidbody2D")] + [TaskDescription("Stores the gravity scale of the Rigidbody2D. Returns Success.")] + public class GetGravityScale : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The gravity scale of the Rigidbody2D")] + [RequiredField] + public SharedFloat storeValue; + + private Rigidbody2D rigidbody2D; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody2D = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody2D == null) { + Debug.LogWarning("Rigidbody2D is null"); + return TaskStatus.Failure; + } + + storeValue.Value = rigidbody2D.gravityScale; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + storeValue = 0; + } + } +} diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetGravtyScale.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetGravtyScale.cs.meta new file mode 100644 index 00000000..ee205b51 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetGravtyScale.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e2d17fb9baea6554082f2edc46483e8c +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetIsKinematic.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetIsKinematic.cs new file mode 100644 index 00000000..94221a04 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetIsKinematic.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody2D +{ + [TaskCategory("Basic/Rigidbody2D")] + [TaskDescription("Stores the is kinematic value of the Rigidbody2D. Returns Success.")] + public class GetIsKinematic : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The is kinematic value of the Rigidbody2D")] + [RequiredField] + public SharedBool storeValue; + + private Rigidbody2D rigidbody2D; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody2D = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody2D == null) { + Debug.LogWarning("Rigidbody2D is null"); + return TaskStatus.Failure; + } + + storeValue.Value = rigidbody2D.isKinematic; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + storeValue = false; + } + } +} diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetIsKinematic.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetIsKinematic.cs.meta new file mode 100644 index 00000000..10f9161a --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetIsKinematic.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 66c6175d42bd49e48be458378e0a7875 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetMass.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetMass.cs new file mode 100644 index 00000000..245f2b9e --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetMass.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody2D +{ + [TaskCategory("Basic/Rigidbody2D")] + [TaskDescription("Stores the mass of the Rigidbody2D. Returns Success.")] + public class GetMass : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The mass of the Rigidbody2D")] + [RequiredField] + public SharedFloat storeValue; + + private Rigidbody2D rigidbody2D; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody2D = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody2D == null) { + Debug.LogWarning("Rigidbody2D is null"); + return TaskStatus.Failure; + } + + storeValue.Value = rigidbody2D.mass; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + storeValue = 0; + } + } +} diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetMass.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetMass.cs.meta new file mode 100644 index 00000000..d9588541 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetMass.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72d52ef5efe5e974994c91279536555e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetPosition.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetPosition.cs new file mode 100644 index 00000000..6b1c1c53 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetPosition.cs @@ -0,0 +1,50 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody2D +{ + [TaskCategory("Basic/Rigidbody2D")] + [TaskDescription("Stores the position of the Rigidbody2D. 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 velocity of the Rigidbody2D")] + [RequiredField] + public SharedVector2 storeValue; + + private Rigidbody2D rigidbody2D; + private GameObject prevGameObject; + + public override void OnStart() + { + if (!allowEmptyTarget.Value) { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody2D = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody2D == null) { + Debug.LogWarning("Rigidbody2D is null"); + return TaskStatus.Failure; + } + + storeValue.Value = rigidbody2D.position; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + allowEmptyTarget = false; + storeValue = Vector2.zero; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetPosition.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetPosition.cs.meta new file mode 100644 index 00000000..00083e0e --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetPosition.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 98dff23734f3a834cbf5ccf87c9904f7 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetRotation.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetRotation.cs new file mode 100644 index 00000000..061646e0 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetRotation.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody2D +{ + [TaskCategory("Basic/Rigidbody2D")] + [TaskDescription("Stores the rotation of the Rigidbody2D. 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 Rigidbody2D")] + [RequiredField] + public SharedFloat storeValue; + + private Rigidbody2D rigidbody2D; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody2D = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody2D == null) { + Debug.LogWarning("Rigidbody2D is null"); + return TaskStatus.Failure; + } + + storeValue.Value = rigidbody2D.rotation; + + 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/Rigidbody2D/GetRotation.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetRotation.cs.meta new file mode 100644 index 00000000..6be4219c --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetRotation.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a7d82ab7ef780f34cb5df06366b0bdbf +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetVelocity.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetVelocity.cs new file mode 100644 index 00000000..bbba8a51 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetVelocity.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody2D +{ + [TaskCategory("Basic/Rigidbody2D")] + [TaskDescription("Stores the velocity of the Rigidbody2D. Returns Success.")] + public class GetVelocity : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The velocity of the Rigidbody2D")] + [RequiredField] + public SharedVector2 storeValue; + + private Rigidbody2D rigidbody2D; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody2D = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody2D == null) { + Debug.LogWarning("Rigidbody2D is null"); + return TaskStatus.Failure; + } + + storeValue.Value = rigidbody2D.velocity; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + storeValue = Vector2.zero; + } + } +} diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetVelocity.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetVelocity.cs.meta new file mode 100644 index 00000000..d92cc9fd --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/GetVelocity.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 13009f7b6ee1bc04884442484a065cc3 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/IsKinematic.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/IsKinematic.cs new file mode 100644 index 00000000..9bccbaef --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/IsKinematic.cs @@ -0,0 +1,39 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody2D +{ + [TaskCategory("Basic/Rigidbody2D")] + [TaskDescription("Returns Success if the Rigidbody2D is kinematic, otherwise Failure.")] + public class IsKinematic : Conditional + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + + private Rigidbody2D rigidbody2D; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody2D = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody2D == null) { + Debug.LogWarning("Rigidbody2D is null"); + return TaskStatus.Failure; + } + + return rigidbody2D.isKinematic ? TaskStatus.Success : TaskStatus.Failure; + } + + public override void OnReset() + { + targetGameObject = null; + } + } +} diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/IsKinematic.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/IsKinematic.cs.meta new file mode 100644 index 00000000..edf168f7 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/IsKinematic.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 47d2e6e60a2251c41a2c548dc9a8c922 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/IsSleeping.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/IsSleeping.cs new file mode 100644 index 00000000..d010d1cc --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/IsSleeping.cs @@ -0,0 +1,39 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody2D +{ + [TaskCategory("Basic/Rigidbody2D")] + [TaskDescription("Returns Success if the Rigidbody2D is sleeping, otherwise Failure.")] + public class IsSleeping : Conditional + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + + private Rigidbody2D rigidbody2D; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody2D = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody2D == null) { + Debug.LogWarning("Rigidbody2D is null"); + return TaskStatus.Failure; + } + + return rigidbody2D.IsSleeping() ? TaskStatus.Success : TaskStatus.Failure; + } + + public override void OnReset() + { + targetGameObject = null; + } + } +} diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/IsSleeping.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/IsSleeping.cs.meta new file mode 100644 index 00000000..3b38a447 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/IsSleeping.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 52859810158277a4a917e70a834a82a5 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/MovePosition.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/MovePosition.cs new file mode 100644 index 00000000..56623639 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/MovePosition.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody2D +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Moves the Rigidbody to the specified position. Returns Success.")] + public class MovePosition : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The new position of the Rigidbody")] + public SharedVector2 position; + + // cache the rigidbody component + private Rigidbody2D rigidbody2D; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody2D = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody2D == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + rigidbody2D.MovePosition(position.Value); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + position = Vector2.zero; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/MovePosition.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/MovePosition.cs.meta new file mode 100644 index 00000000..79762af7 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/MovePosition.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3e72fab171287194ea2d8eb2aa239cd4 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/MoveRotation.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/MoveRotation.cs new file mode 100644 index 00000000..c8e58e3d --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/MoveRotation.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody2D +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Rotates the Rigidbody to the specified rotation. Returns Success.")] + public class MoveRotation : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The new rotation of the Rigidbody")] + public SharedFloat rotation; + + // cache the rigidbody component + private Rigidbody2D rigidbody2D; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody2D = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody2D == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + rigidbody2D.MoveRotation(rotation.Value); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + rotation = 0; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/MoveRotation.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/MoveRotation.cs.meta new file mode 100644 index 00000000..09bb16a9 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/MoveRotation.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 38b0095c420511f4b9ed263b1b5c6054 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetAngularDrag.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetAngularDrag.cs new file mode 100644 index 00000000..3bb17e07 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetAngularDrag.cs @@ -0,0 +1,44 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody2D +{ + [TaskCategory("Basic/Rigidbody2D")] + [TaskDescription("Sets the angular drag of the Rigidbody2D. Returns Success.")] + public class SetAngularDrag : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The angular drag of the Rigidbody2D")] + public SharedFloat angularDrag; + + private Rigidbody2D rigidbody2D; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody2D = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody2D == null) { + Debug.LogWarning("Rigidbody2D is null"); + return TaskStatus.Failure; + } + + rigidbody2D.angularDrag = angularDrag.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + angularDrag = 0; + } + } +} diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetAngularDrag.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetAngularDrag.cs.meta new file mode 100644 index 00000000..1ec92fe3 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetAngularDrag.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1717a737318274e4caa244f86c908851 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetAngularVelocity.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetAngularVelocity.cs new file mode 100644 index 00000000..9fc45f3d --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetAngularVelocity.cs @@ -0,0 +1,44 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody2D +{ + [TaskCategory("Basic/Rigidbody2D")] + [TaskDescription("Sets the angular velocity of the Rigidbody2D. Returns Success.")] + public class SetAngularVelocity : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The angular velocity of the Rigidbody2D")] + public SharedFloat angularVelocity; + + private Rigidbody2D rigidbody2D; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody2D = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody2D == null) { + Debug.LogWarning("Rigidbody2D is null"); + return TaskStatus.Failure; + } + + rigidbody2D.angularVelocity = angularVelocity.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + angularVelocity = 0; + } + } +} diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetAngularVelocity.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetAngularVelocity.cs.meta new file mode 100644 index 00000000..a559685e --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetAngularVelocity.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c73dfb332d90cbe4280c21fafa59e2fa +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetDrag.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetDrag.cs new file mode 100644 index 00000000..1530cc07 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetDrag.cs @@ -0,0 +1,44 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody2D +{ + [TaskCategory("Basic/Rigidbody2D")] + [TaskDescription("Sets the drag of the Rigidbody2D. Returns Success.")] + public class SetDrag : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The drag of the Rigidbody2D")] + public SharedFloat drag; + + private Rigidbody2D rigidbody2D; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody2D = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody2D == null) { + Debug.LogWarning("Rigidbody2D is null"); + return TaskStatus.Failure; + } + + rigidbody2D.drag = drag.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + drag = 0; + } + } +} diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetDrag.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetDrag.cs.meta new file mode 100644 index 00000000..96d06ce2 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetDrag.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3148efd94c23d634a9f02cc9c808de80 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetFixedAngle.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetFixedAngle.cs new file mode 100644 index 00000000..fdd75d2e --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetFixedAngle.cs @@ -0,0 +1,46 @@ +#if UNITY_4_6 || UNITY_4_7 || UNITY_5_0 +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody2D +{ + [TaskCategory("Basic/Rigidbody2D")] + [TaskDescription("Sets the fixed angle value of the Rigidbody2D. Returns Success.")] + public class SetFixedAngle : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The fixed angle value of the Rigidbody2D")] + public SharedBool fixedAngle; + + private Rigidbody2D rigidbody2D; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody2D = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody2D == null) { + Debug.LogWarning("Rigidbody2D is null"); + return TaskStatus.Failure; + } + + rigidbody2D.fixedAngle = fixedAngle.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + fixedAngle = false; + } + } +} +#endif \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetFixedAngle.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetFixedAngle.cs.meta new file mode 100644 index 00000000..5a97e4fc --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetFixedAngle.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0bc5b6a279943ff459ed27083e6bdbb0 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetGravityScale.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetGravityScale.cs new file mode 100644 index 00000000..a6ce28a4 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetGravityScale.cs @@ -0,0 +1,44 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody2D +{ + [TaskCategory("Basic/Rigidbody2D")] + [TaskDescription("Sets the gravity scale of the Rigidbody2D. Returns Success.")] + public class SetGravityScale : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The gravity scale of the Rigidbody2D")] + public SharedFloat gravityScale; + + private Rigidbody2D rigidbody2D; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody2D = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody2D == null) { + Debug.LogWarning("Rigidbody2D is null"); + return TaskStatus.Failure; + } + + rigidbody2D.gravityScale = gravityScale.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + gravityScale = 0; + } + } +} diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetGravityScale.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetGravityScale.cs.meta new file mode 100644 index 00000000..516e6ac5 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetGravityScale.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ac896135858701649bcaffc7ef00637f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetIsKinematic.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetIsKinematic.cs new file mode 100644 index 00000000..c8e2563e --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetIsKinematic.cs @@ -0,0 +1,44 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody2D +{ + [TaskCategory("Basic/Rigidbody2D")] + [TaskDescription("Sets the is kinematic value of the Rigidbody2D. Returns Success.")] + public class SetIsKinematic : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The is kinematic value of the Rigidbody2D")] + public SharedBool isKinematic; + + private Rigidbody2D rigidbody2D; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody2D = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody2D == null) { + Debug.LogWarning("Rigidbody2D is null"); + return TaskStatus.Failure; + } + + rigidbody2D.isKinematic = isKinematic.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + isKinematic = false; + } + } +} diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetIsKinematic.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetIsKinematic.cs.meta new file mode 100644 index 00000000..ff7f5f2c --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetIsKinematic.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b7c96d64d821e304a8c67c031565d902 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetMass.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetMass.cs new file mode 100644 index 00000000..c218e087 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetMass.cs @@ -0,0 +1,44 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody2D +{ + [TaskCategory("Basic/Rigidbody2D")] + [TaskDescription("Sets the mass of the Rigidbody2D. Returns Success.")] + public class SetMass : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The mass of the Rigidbody2D")] + public SharedFloat mass; + + private Rigidbody2D rigidbody2D; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody2D = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody2D == null) { + Debug.LogWarning("Rigidbody2D is null"); + return TaskStatus.Failure; + } + + rigidbody2D.mass = mass.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + mass = 0; + } + } +} diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetMass.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetMass.cs.meta new file mode 100644 index 00000000..042c36e0 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetMass.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: facbfd14ece02214889d587f06215105 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetVelocity.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetVelocity.cs new file mode 100644 index 00000000..7f1f782a --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetVelocity.cs @@ -0,0 +1,44 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody2D +{ + [TaskCategory("Basic/Rigidbody2D")] + [TaskDescription("Sets the velocity of the Rigidbody2D. Returns Success.")] + public class SetVelocity : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The velocity of the Rigidbody2D")] + public SharedVector2 velocity; + + private Rigidbody2D rigidbody2D; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody2D = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody2D == null) { + Debug.LogWarning("Rigidbody2D is null"); + return TaskStatus.Failure; + } + + rigidbody2D.velocity = velocity.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + velocity = Vector2.zero; + } + } +} diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetVelocity.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetVelocity.cs.meta new file mode 100644 index 00000000..a78bc24c --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/SetVelocity.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5830960da4f9a3148ba5d8cd87228748 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/Sleep.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/Sleep.cs new file mode 100644 index 00000000..9357826c --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/Sleep.cs @@ -0,0 +1,41 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody2D +{ + [TaskCategory("Basic/Rigidbody2D")] + [TaskDescription("Forces the Rigidbody2D to sleep at least one frame. Returns Success.")] + public class Sleep : Conditional + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + + private Rigidbody2D rigidbody2D; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody2D = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody2D == null) { + Debug.LogWarning("Rigidbody2D is null"); + return TaskStatus.Failure; + } + + rigidbody2D.Sleep(); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + } + } +} diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/Sleep.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/Sleep.cs.meta new file mode 100644 index 00000000..9e50b4e1 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/Sleep.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7e24fd00ca72fda48a132dc9bfa71070 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/WakeUp.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/WakeUp.cs new file mode 100644 index 00000000..66a3318d --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/WakeUp.cs @@ -0,0 +1,41 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody2D +{ + [TaskCategory("Basic/Rigidbody2D")] + [TaskDescription("Forces the Rigidbody2D to wake up. Returns Success.")] + public class WakeUp : Conditional + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + + private Rigidbody2D rigidbody2D; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody2D = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody2D == null) { + Debug.LogWarning("Rigidbody2D is null"); + return TaskStatus.Failure; + } + + rigidbody2D.WakeUp(); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + } + } +} diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/WakeUp.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/WakeUp.cs.meta new file mode 100644 index 00000000..ce6821bb --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody2D/WakeUp.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 954f1f9c196c39345b2fd389516ad613 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: -- cgit v1.1-26-g67d0