From 97da432c35b8c7aaf9dd2c39e2aa4b1f55f36065 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 27 Jan 2021 16:15:06 +0800 Subject: +behaviour designer --- .../Basic Tasks/Rigidbody/AddExplosionForce.cs | 57 ++++++++++++++++++++++ .../Rigidbody/AddExplosionForce.cs.meta | 8 +++ .../Runtime/Basic Tasks/Rigidbody/AddForce.cs | 51 +++++++++++++++++++ .../Runtime/Basic Tasks/Rigidbody/AddForce.cs.meta | 8 +++ .../Basic Tasks/Rigidbody/AddForceAtPosition.cs | 51 +++++++++++++++++++ .../Rigidbody/AddForceAtPosition.cs.meta | 8 +++ .../Basic Tasks/Rigidbody/AddRelativeForce.cs | 48 ++++++++++++++++++ .../Basic Tasks/Rigidbody/AddRelativeForce.cs.meta | 8 +++ .../Basic Tasks/Rigidbody/AddRelativeTorque.cs | 43 ++++++++++++++++ .../Rigidbody/AddRelativeTorque.cs.meta | 8 +++ .../Runtime/Basic Tasks/Rigidbody/AddTorque.cs | 48 ++++++++++++++++++ .../Basic Tasks/Rigidbody/AddTorque.cs.meta | 8 +++ .../Basic Tasks/Rigidbody/GetAngularDrag.cs | 46 +++++++++++++++++ .../Basic Tasks/Rigidbody/GetAngularDrag.cs.meta | 8 +++ .../Basic Tasks/Rigidbody/GetAngularVelocity.cs | 46 +++++++++++++++++ .../Rigidbody/GetAngularVelocity.cs.meta | 8 +++ .../Basic Tasks/Rigidbody/GetCenterOfMass.cs | 46 +++++++++++++++++ .../Basic Tasks/Rigidbody/GetCenterOfMass.cs.meta | 8 +++ .../Runtime/Basic Tasks/Rigidbody/GetDrag.cs | 46 +++++++++++++++++ .../Runtime/Basic Tasks/Rigidbody/GetDrag.cs.meta | 8 +++ .../Basic Tasks/Rigidbody/GetFreezeRotation.cs | 46 +++++++++++++++++ .../Rigidbody/GetFreezeRotation.cs.meta | 8 +++ .../Basic Tasks/Rigidbody/GetIsKinematic.cs | 46 +++++++++++++++++ .../Basic Tasks/Rigidbody/GetIsKinematic.cs.meta | 8 +++ .../Runtime/Basic Tasks/Rigidbody/GetMass.cs | 46 +++++++++++++++++ .../Runtime/Basic Tasks/Rigidbody/GetMass.cs.meta | 8 +++ .../Runtime/Basic Tasks/Rigidbody/GetPosition.cs | 51 +++++++++++++++++++ .../Basic Tasks/Rigidbody/GetPosition.cs.meta | 8 +++ .../Runtime/Basic Tasks/Rigidbody/GetRotation.cs | 46 +++++++++++++++++ .../Basic Tasks/Rigidbody/GetRotation.cs.meta | 8 +++ .../Runtime/Basic Tasks/Rigidbody/GetUseGravity.cs | 46 +++++++++++++++++ .../Basic Tasks/Rigidbody/GetUseGravity.cs.meta | 8 +++ .../Runtime/Basic Tasks/Rigidbody/GetVelocity.cs | 46 +++++++++++++++++ .../Basic Tasks/Rigidbody/GetVelocity.cs.meta | 8 +++ .../Runtime/Basic Tasks/Rigidbody/IsKinematic.cs | 40 +++++++++++++++ .../Basic Tasks/Rigidbody/IsKinematic.cs.meta | 8 +++ .../Runtime/Basic Tasks/Rigidbody/IsSleeping.cs | 40 +++++++++++++++ .../Basic Tasks/Rigidbody/IsSleeping.cs.meta | 8 +++ .../Runtime/Basic Tasks/Rigidbody/MovePosition.cs | 45 +++++++++++++++++ .../Basic Tasks/Rigidbody/MovePosition.cs.meta | 8 +++ .../Runtime/Basic Tasks/Rigidbody/MoveRotation.cs | 45 +++++++++++++++++ .../Basic Tasks/Rigidbody/MoveRotation.cs.meta | 8 +++ .../Basic Tasks/Rigidbody/SetAngularDrag.cs | 45 +++++++++++++++++ .../Basic Tasks/Rigidbody/SetAngularDrag.cs.meta | 8 +++ .../Basic Tasks/Rigidbody/SetAngularVelocity.cs | 45 +++++++++++++++++ .../Rigidbody/SetAngularVelocity.cs.meta | 8 +++ .../Basic Tasks/Rigidbody/SetCenterOfMass.cs | 45 +++++++++++++++++ .../Basic Tasks/Rigidbody/SetCenterOfMass.cs.meta | 8 +++ .../Basic Tasks/Rigidbody/SetConstraints.cs | 45 +++++++++++++++++ .../Basic Tasks/Rigidbody/SetConstraints.cs.meta | 8 +++ .../Runtime/Basic Tasks/Rigidbody/SetDrag.cs | 45 +++++++++++++++++ .../Runtime/Basic Tasks/Rigidbody/SetDrag.cs.meta | 8 +++ .../Basic Tasks/Rigidbody/SetFreezeRotation.cs | 45 +++++++++++++++++ .../Rigidbody/SetFreezeRotation.cs.meta | 8 +++ .../Basic Tasks/Rigidbody/SetIsKinematic.cs | 45 +++++++++++++++++ .../Basic Tasks/Rigidbody/SetIsKinematic.cs.meta | 8 +++ .../Runtime/Basic Tasks/Rigidbody/SetMass.cs | 45 +++++++++++++++++ .../Runtime/Basic Tasks/Rigidbody/SetMass.cs.meta | 8 +++ .../Runtime/Basic Tasks/Rigidbody/SetPosition.cs | 45 +++++++++++++++++ .../Basic Tasks/Rigidbody/SetPosition.cs.meta | 8 +++ .../Runtime/Basic Tasks/Rigidbody/SetRotation.cs | 45 +++++++++++++++++ .../Basic Tasks/Rigidbody/SetRotation.cs.meta | 8 +++ .../Runtime/Basic Tasks/Rigidbody/SetUseGravity.cs | 45 +++++++++++++++++ .../Basic Tasks/Rigidbody/SetUseGravity.cs.meta | 8 +++ .../Runtime/Basic Tasks/Rigidbody/SetVelocity.cs | 45 +++++++++++++++++ .../Basic Tasks/Rigidbody/SetVelocity.cs.meta | 8 +++ .../Runtime/Basic Tasks/Rigidbody/Sleep.cs | 42 ++++++++++++++++ .../Runtime/Basic Tasks/Rigidbody/Sleep.cs.meta | 8 +++ .../Runtime/Basic Tasks/Rigidbody/UseGravity.cs | 40 +++++++++++++++ .../Basic Tasks/Rigidbody/UseGravity.cs.meta | 8 +++ .../Runtime/Basic Tasks/Rigidbody/WakeUp.cs | 42 ++++++++++++++++ .../Runtime/Basic Tasks/Rigidbody/WakeUp.cs.meta | 8 +++ 72 files changed, 1931 insertions(+) create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddExplosionForce.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddExplosionForce.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddForce.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddForce.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddForceAtPosition.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddForceAtPosition.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddRelativeForce.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddRelativeForce.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddRelativeTorque.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddRelativeTorque.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddTorque.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddTorque.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetAngularDrag.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetAngularDrag.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetAngularVelocity.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetAngularVelocity.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetCenterOfMass.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetCenterOfMass.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetDrag.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetDrag.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetFreezeRotation.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetFreezeRotation.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetIsKinematic.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetIsKinematic.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetMass.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetMass.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetPosition.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetPosition.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetRotation.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetRotation.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetUseGravity.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetUseGravity.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetVelocity.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetVelocity.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/IsKinematic.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/IsKinematic.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/IsSleeping.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/IsSleeping.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/MovePosition.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/MovePosition.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/MoveRotation.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/MoveRotation.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetAngularDrag.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetAngularDrag.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetAngularVelocity.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetAngularVelocity.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetCenterOfMass.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetCenterOfMass.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetConstraints.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetConstraints.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetDrag.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetDrag.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetFreezeRotation.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetFreezeRotation.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetIsKinematic.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetIsKinematic.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetMass.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetMass.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetPosition.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetPosition.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetRotation.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetRotation.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetUseGravity.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetUseGravity.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetVelocity.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetVelocity.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/Sleep.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/Sleep.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/UseGravity.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/UseGravity.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/WakeUp.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/WakeUp.cs.meta (limited to 'Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody') diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddExplosionForce.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddExplosionForce.cs new file mode 100644 index 00000000..2d313eb4 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddExplosionForce.cs @@ -0,0 +1,57 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Applies a force to the rigidbody that simulates explosion effects. Returns Success.")] + public class AddExplosionForce : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The force of the explosion")] + public SharedFloat explosionForce; + [Tooltip("The position of the explosion")] + public SharedVector3 explosionPosition; + [Tooltip("The radius of the explosion")] + public SharedFloat explosionRadius; + [Tooltip("Applies the force as if it was applied from beneath the object")] + public float upwardsModifier = 0; + [Tooltip("The type of force")] + public ForceMode forceMode = ForceMode.Force; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + rigidbody.AddExplosionForce(explosionForce.Value, explosionPosition.Value, explosionRadius.Value, upwardsModifier, forceMode); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + explosionForce = 0; + explosionPosition = Vector3.zero; + explosionRadius = 0; + upwardsModifier = 0; + forceMode = ForceMode.Force; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddExplosionForce.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddExplosionForce.cs.meta new file mode 100644 index 00000000..46e4e7f6 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddExplosionForce.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ccb592e850d4c734995a2a1c3f930b62 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddForce.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddForce.cs new file mode 100644 index 00000000..9e7ff1a9 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddForce.cs @@ -0,0 +1,51 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [RequiredComponent(typeof(Rigidbody))] + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Applies a force to the rigidbody. 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 SharedVector3 force; + [Tooltip("The type of force")] + public ForceMode forceMode = ForceMode.Force; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + rigidbody.AddForce(force.Value, forceMode); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + if (force != null) { + force.Value = Vector3.zero; + } + forceMode = ForceMode.Force; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddForce.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddForce.cs.meta new file mode 100644 index 00000000..2ff832db --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddForce.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5748d4214b99b8c49ba67902a8495a30 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddForceAtPosition.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddForceAtPosition.cs new file mode 100644 index 00000000..c76f34c1 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddForceAtPosition.cs @@ -0,0 +1,51 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Applies a force at the specified position to the rigidbody. 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 SharedVector3 force; + [Tooltip("The position of the force")] + public SharedVector3 position; + [Tooltip("The type of force")] + public ForceMode forceMode = ForceMode.Force; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + rigidbody.AddForceAtPosition(force.Value, position.Value, forceMode); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + force = Vector3.zero; + position = Vector3.zero; + forceMode = ForceMode.Force; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddForceAtPosition.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddForceAtPosition.cs.meta new file mode 100644 index 00000000..e299a9ba --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddForceAtPosition.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c3938bcd4e88b45419aa86adee51a2c2 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddRelativeForce.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddRelativeForce.cs new file mode 100644 index 00000000..57e1a9d2 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddRelativeForce.cs @@ -0,0 +1,48 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Applies a force to the rigidbody relative to its coordinate system. Returns Success.")] + public class AddRelativeForce : 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 SharedVector3 force; + [Tooltip("The type of force")] + public ForceMode forceMode = ForceMode.Force; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + rigidbody.AddRelativeForce(force.Value, forceMode); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + force = Vector3.zero; + forceMode = ForceMode.Force; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddRelativeForce.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddRelativeForce.cs.meta new file mode 100644 index 00000000..be56eac2 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddRelativeForce.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1de05a2b6197b2d4b9da1c36bf382649 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddRelativeTorque.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddRelativeTorque.cs new file mode 100644 index 00000000..ec901665 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddRelativeTorque.cs @@ -0,0 +1,43 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Applies a torque to the rigidbody relative to its coordinate system. Returns Success.")] + public class AddRelativeTorque : 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 SharedVector3 torque; + [Tooltip("The type of torque")] + public ForceMode forceMode = ForceMode.Force; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + rigidbody.AddRelativeTorque(torque.Value, forceMode); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + torque = Vector3.zero; + forceMode = ForceMode.Force; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddRelativeTorque.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddRelativeTorque.cs.meta new file mode 100644 index 00000000..3bba15eb --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddRelativeTorque.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 71136c1193309b24c93d450b5f2e47be +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddTorque.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddTorque.cs new file mode 100644 index 00000000..35282d09 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddTorque.cs @@ -0,0 +1,48 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Applies a torque to the rigidbody. 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 SharedVector3 torque; + [Tooltip("The type of torque")] + public ForceMode forceMode = ForceMode.Force; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + rigidbody.AddTorque(torque.Value, forceMode); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + torque = Vector3.zero; + forceMode = ForceMode.Force; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddTorque.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddTorque.cs.meta new file mode 100644 index 00000000..4e6e47c3 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/AddTorque.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 88c726c1cb324e6429637f55d36c3d01 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetAngularDrag.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetAngularDrag.cs new file mode 100644 index 00000000..9aed491c --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetAngularDrag.cs @@ -0,0 +1,46 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Stores the angular drag of the Rigidbody. 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 Rigidbody")] + [RequiredField] + public SharedFloat storeValue; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + storeValue.Value = rigidbody.angularDrag; + + 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/Rigidbody/GetAngularDrag.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetAngularDrag.cs.meta new file mode 100644 index 00000000..f82dda03 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetAngularDrag.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5fb34b334a02db64db2d6a2fb2448be5 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetAngularVelocity.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetAngularVelocity.cs new file mode 100644 index 00000000..556f52e1 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetAngularVelocity.cs @@ -0,0 +1,46 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Stores the angular velocity of the Rigidbody. 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 Rigidbody")] + [RequiredField] + public SharedVector3 storeValue; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + storeValue.Value = rigidbody.angularVelocity; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + storeValue = Vector3.zero; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetAngularVelocity.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetAngularVelocity.cs.meta new file mode 100644 index 00000000..c4f98927 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetAngularVelocity.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 492dc3a13d07ed149bcd19d36e2f7ee7 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetCenterOfMass.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetCenterOfMass.cs new file mode 100644 index 00000000..59c7429c --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetCenterOfMass.cs @@ -0,0 +1,46 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Stores the center of mass of the Rigidbody. Returns Success.")] + public class GetCenterOfMass : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The center of mass of the Rigidbody")] + [RequiredField] + public SharedVector3 storeValue; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + storeValue.Value = rigidbody.centerOfMass; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + storeValue = Vector3.zero; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetCenterOfMass.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetCenterOfMass.cs.meta new file mode 100644 index 00000000..8c175632 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetCenterOfMass.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b993020e1d60f5242a7e3618501f871e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetDrag.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetDrag.cs new file mode 100644 index 00000000..423e79b0 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetDrag.cs @@ -0,0 +1,46 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Stores the drag of the Rigidbody. 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 Rigidbody")] + [RequiredField] + public SharedFloat storeValue; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + storeValue.Value = rigidbody.drag; + + 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/Rigidbody/GetDrag.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetDrag.cs.meta new file mode 100644 index 00000000..ab90b18b --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetDrag.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 69bd087f6899c604f82441b108ead2a8 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetFreezeRotation.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetFreezeRotation.cs new file mode 100644 index 00000000..0a26f2c1 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetFreezeRotation.cs @@ -0,0 +1,46 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Stores the freeze rotation value of the Rigidbody. Returns Success.")] + public class GetFreezeRotation : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The freeze rotation value of the Rigidbody")] + [RequiredField] + public SharedBool storeValue; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + storeValue.Value = rigidbody.freezeRotation; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + storeValue = false; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetFreezeRotation.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetFreezeRotation.cs.meta new file mode 100644 index 00000000..dad7aad7 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetFreezeRotation.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 889065cfad95df04a802761fcccb8359 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetIsKinematic.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetIsKinematic.cs new file mode 100644 index 00000000..ee981ed7 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetIsKinematic.cs @@ -0,0 +1,46 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Stores the is kinematic value of the Rigidbody. 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 Rigidbody")] + [RequiredField] + public SharedBool storeValue; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + storeValue.Value = rigidbody.isKinematic; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + storeValue = false; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetIsKinematic.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetIsKinematic.cs.meta new file mode 100644 index 00000000..0bef7e35 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetIsKinematic.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a531151d14b8a9640be8d499d9db4538 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetMass.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetMass.cs new file mode 100644 index 00000000..62d0138b --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetMass.cs @@ -0,0 +1,46 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Stores the mass of the Rigidbody. 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 Rigidbody")] + [RequiredField] + public SharedFloat storeValue; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + storeValue.Value = rigidbody.mass; + + 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/Rigidbody/GetMass.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetMass.cs.meta new file mode 100644 index 00000000..71b86955 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetMass.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2638ca749ba5a404f84fd72811b16c81 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetPosition.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetPosition.cs new file mode 100644 index 00000000..84fa411d --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetPosition.cs @@ -0,0 +1,51 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Stores the position of the Rigidbody. Returns Success.")] + public class GetPosition : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("Can the target GameObject be empty?")] + public SharedBool allowEmptyTarget; + [Tooltip("The position of the Rigidbody")] + [RequiredField] + public SharedVector3 storeValue; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + if (!allowEmptyTarget.Value) { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + storeValue.Value = rigidbody.position; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + allowEmptyTarget = false; + storeValue = Vector3.zero; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetPosition.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetPosition.cs.meta new file mode 100644 index 00000000..732ae424 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetPosition.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 25f9090c180831b4daaa1a24894681ac +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetRotation.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetRotation.cs new file mode 100644 index 00000000..53d4101f --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetRotation.cs @@ -0,0 +1,46 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Stores the rotation of the Rigidbody. 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 Rigidbody")] + [RequiredField] + public SharedQuaternion storeValue; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + storeValue.Value = rigidbody.rotation; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + storeValue = Quaternion.identity; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetRotation.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetRotation.cs.meta new file mode 100644 index 00000000..539000a1 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetRotation.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 937400bc82220b543aa9b3074f17f4d6 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetUseGravity.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetUseGravity.cs new file mode 100644 index 00000000..dc20ef51 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetUseGravity.cs @@ -0,0 +1,46 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Stores the use gravity value of the Rigidbody. Returns Success.")] + public class GetUseGravity : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The use gravity value of the Rigidbody")] + [RequiredField] + public SharedBool storeValue; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + storeValue.Value = rigidbody.useGravity; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + storeValue = false; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetUseGravity.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetUseGravity.cs.meta new file mode 100644 index 00000000..ab211284 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetUseGravity.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1d7358afc7810ca4aa2ae8a2cd4b9e6e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetVelocity.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetVelocity.cs new file mode 100644 index 00000000..de66c4ad --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetVelocity.cs @@ -0,0 +1,46 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Stores the velocity of the Rigidbody. 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 Rigidbody")] + [RequiredField] + public SharedVector3 storeValue; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + storeValue.Value = rigidbody.velocity; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + storeValue = Vector3.zero; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetVelocity.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetVelocity.cs.meta new file mode 100644 index 00000000..62f5920f --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/GetVelocity.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9c18365eb6865164ebb5b0057dcc6bb4 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/IsKinematic.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/IsKinematic.cs new file mode 100644 index 00000000..1144ea46 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/IsKinematic.cs @@ -0,0 +1,40 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Returns Success if the Rigidbody 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; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + return rigidbody.isKinematic ? TaskStatus.Success : TaskStatus.Failure; + } + + public override void OnReset() + { + targetGameObject = null; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/IsKinematic.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/IsKinematic.cs.meta new file mode 100644 index 00000000..ec59f524 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/IsKinematic.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 30be28b36412643418c2e61640147eac +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/IsSleeping.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/IsSleeping.cs new file mode 100644 index 00000000..1252e643 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/IsSleeping.cs @@ -0,0 +1,40 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Returns Success if the Rigidbody 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; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + return rigidbody.IsSleeping() ? TaskStatus.Success : TaskStatus.Failure; + } + + public override void OnReset() + { + targetGameObject = null; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/IsSleeping.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/IsSleeping.cs.meta new file mode 100644 index 00000000..c0c0a203 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/IsSleeping.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 37e8153613f519240a11c3f6583d1030 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/MovePosition.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/MovePosition.cs new file mode 100644 index 00000000..81ac9191 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/MovePosition.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [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 SharedVector3 position; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + rigidbody.MovePosition(position.Value); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + position = Vector3.zero; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/MovePosition.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/MovePosition.cs.meta new file mode 100644 index 00000000..75fc531c --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/MovePosition.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 87176662744aee049b8af51b01bcb526 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/MoveRotation.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/MoveRotation.cs new file mode 100644 index 00000000..9133cb77 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/MoveRotation.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [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 SharedQuaternion rotation; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + rigidbody.MoveRotation(rotation.Value); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + rotation = Quaternion.identity; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/MoveRotation.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/MoveRotation.cs.meta new file mode 100644 index 00000000..65a02522 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/MoveRotation.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f1ba2e66d5ca98a4ba4020b4eff4da6e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetAngularDrag.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetAngularDrag.cs new file mode 100644 index 00000000..c08194d2 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetAngularDrag.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Sets the angular drag of the Rigidbody. 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 Rigidbody")] + public SharedFloat angularDrag; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + rigidbody.angularDrag = angularDrag.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + angularDrag = 0; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetAngularDrag.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetAngularDrag.cs.meta new file mode 100644 index 00000000..bfa75a99 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetAngularDrag.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2883595af7ee1c649ae45353482beed8 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetAngularVelocity.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetAngularVelocity.cs new file mode 100644 index 00000000..78f35260 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetAngularVelocity.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Sets the angular velocity of the Rigidbody. 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 Rigidbody")] + public SharedVector3 angularVelocity; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + rigidbody.angularVelocity = angularVelocity.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + angularVelocity = Vector3.zero; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetAngularVelocity.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetAngularVelocity.cs.meta new file mode 100644 index 00000000..1c2b78f9 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetAngularVelocity.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8652396368a6dad4eb6e1259e680595c +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetCenterOfMass.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetCenterOfMass.cs new file mode 100644 index 00000000..f57cb25a --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetCenterOfMass.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Sets the center of mass of the Rigidbody. Returns Success.")] + public class SetCenterOfMass : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The center of mass of the Rigidbody")] + public SharedVector3 centerOfMass; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + rigidbody.centerOfMass = centerOfMass.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + centerOfMass = Vector3.zero; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetCenterOfMass.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetCenterOfMass.cs.meta new file mode 100644 index 00000000..3a229ffb --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetCenterOfMass.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 594f2d37fbfc0d545a0377cf63543f41 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetConstraints.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetConstraints.cs new file mode 100644 index 00000000..0b174602 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetConstraints.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Sets the constraints of the Rigidbody. Returns Success.")] + public class SetConstraints : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The constraints of the Rigidbody")] + public RigidbodyConstraints constraints = RigidbodyConstraints.None; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + rigidbody.constraints = constraints; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + constraints = RigidbodyConstraints.None; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetConstraints.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetConstraints.cs.meta new file mode 100644 index 00000000..8affb848 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetConstraints.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: dd098240974b0184ca8c66cb6e450753 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetDrag.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetDrag.cs new file mode 100644 index 00000000..e755cf6e --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetDrag.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Sets the drag of the Rigidbody. 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 Rigidbody")] + public SharedFloat drag; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + rigidbody.drag = drag.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + drag = 0; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetDrag.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetDrag.cs.meta new file mode 100644 index 00000000..370e0d8b --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetDrag.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8984a684f33e6644abbb9cfe6c9068d9 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetFreezeRotation.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetFreezeRotation.cs new file mode 100644 index 00000000..9b6342ba --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetFreezeRotation.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Sets the freeze rotation value of the Rigidbody. Returns Success.")] + public class SetFreezeRotation : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The freeze rotation value of the Rigidbody")] + public SharedBool freezeRotation; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + rigidbody.freezeRotation = freezeRotation.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + freezeRotation = false; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetFreezeRotation.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetFreezeRotation.cs.meta new file mode 100644 index 00000000..67fd3cac --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetFreezeRotation.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4160755a1f5174546b6ccbabff469187 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetIsKinematic.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetIsKinematic.cs new file mode 100644 index 00000000..49ead821 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetIsKinematic.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Sets the is kinematic value of the Rigidbody. 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 Rigidbody")] + public SharedBool isKinematic; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + rigidbody.isKinematic = isKinematic.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + isKinematic = false; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetIsKinematic.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetIsKinematic.cs.meta new file mode 100644 index 00000000..78a73857 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetIsKinematic.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6d93194d82815024cadf3f4f842666d0 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetMass.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetMass.cs new file mode 100644 index 00000000..48c1da8f --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetMass.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Sets the mass of the Rigidbody. 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 Rigidbody")] + public SharedFloat mass; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + rigidbody.mass = mass.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + mass = 0; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetMass.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetMass.cs.meta new file mode 100644 index 00000000..b1ab1a4e --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetMass.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 82f7a92bee3553d49bbb1ebabfaffc12 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetPosition.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetPosition.cs new file mode 100644 index 00000000..86b564a5 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetPosition.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Sets the position of the Rigidbody. Returns Success.")] + public class SetPosition : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The position of the Rigidbody")] + public SharedVector3 position; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + rigidbody.position = position.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + position = Vector3.zero; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetPosition.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetPosition.cs.meta new file mode 100644 index 00000000..62b9cac0 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetPosition.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8a33b86eb94a87c449e1f3344973cc50 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetRotation.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetRotation.cs new file mode 100644 index 00000000..ffa231a8 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetRotation.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Stores the rotation of the Rigidbody. Returns Success.")] + public class SetRotation : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The rotation of the Rigidbody")] + public SharedQuaternion rotation; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + rigidbody.rotation = rotation.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + rotation = Quaternion.identity; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetRotation.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetRotation.cs.meta new file mode 100644 index 00000000..cf104f74 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetRotation.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c5ac2e84278f4a845ba47d1e4469e869 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetUseGravity.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetUseGravity.cs new file mode 100644 index 00000000..a95330a5 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetUseGravity.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Sets the use gravity value of the Rigidbody. Returns Success.")] + public class SetUseGravity : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The use gravity value of the Rigidbody")] + public SharedBool isKinematic; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + rigidbody.useGravity = isKinematic.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + isKinematic = false; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetUseGravity.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetUseGravity.cs.meta new file mode 100644 index 00000000..8e3be08a --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetUseGravity.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 19548f438ad1c684180d41713cbdeb76 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetVelocity.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetVelocity.cs new file mode 100644 index 00000000..e488ebc5 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetVelocity.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Sets the velocity of the Rigidbody. 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 Rigidbody")] + public SharedVector3 velocity; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + rigidbody.velocity = velocity.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + velocity = Vector3.zero; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetVelocity.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetVelocity.cs.meta new file mode 100644 index 00000000..c1756a01 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/SetVelocity.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3e3fc3ca798c87644a42b1c930fff3f0 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/Sleep.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/Sleep.cs new file mode 100644 index 00000000..796f7f29 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/Sleep.cs @@ -0,0 +1,42 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Forces the Rigidbody 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; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + rigidbody.Sleep(); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/Sleep.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/Sleep.cs.meta new file mode 100644 index 00000000..dc6ae392 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/Sleep.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1683ca7168c4ce74db4396c4d3cb65ce +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/UseGravity.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/UseGravity.cs new file mode 100644 index 00000000..1cdcb762 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/UseGravity.cs @@ -0,0 +1,40 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Returns Success if the Rigidbody is using gravity, otherwise Failure.")] + public class UseGravity : Conditional + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + return rigidbody.useGravity ? TaskStatus.Success : TaskStatus.Failure; + } + + public override void OnReset() + { + targetGameObject = null; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/UseGravity.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/UseGravity.cs.meta new file mode 100644 index 00000000..446f7f0d --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/UseGravity.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a0d11b67c4ae058469e7f7b00db7103f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/WakeUp.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/WakeUp.cs new file mode 100644 index 00000000..fcb4fe74 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/WakeUp.cs @@ -0,0 +1,42 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityRigidbody +{ + [TaskCategory("Basic/Rigidbody")] + [TaskDescription("Forces the Rigidbody 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; + + // cache the rigidbody component + private Rigidbody rigidbody; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + rigidbody = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (rigidbody == null) { + Debug.LogWarning("Rigidbody is null"); + return TaskStatus.Failure; + } + + rigidbody.WakeUp(); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/WakeUp.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/WakeUp.cs.meta new file mode 100644 index 00000000..d65620b9 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Rigidbody/WakeUp.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d4314af88b4d86046bdac1f10f6f9a47 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: -- cgit v1.1-26-g67d0