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/Animator/CrossFade.cs | 53 ++++++++++++++++++ .../Runtime/Basic Tasks/Animator/CrossFade.cs.meta | 8 +++ .../Basic Tasks/Animator/GetApplyRootMotion.cs | 45 ++++++++++++++++ .../Animator/GetApplyRootMotion.cs.meta | 8 +++ .../Basic Tasks/Animator/GetBoolParameter.cs | 48 +++++++++++++++++ .../Basic Tasks/Animator/GetBoolParameter.cs.meta | 8 +++ .../Animator/GetCurrentAnimatorStateNameHash.cs | 50 +++++++++++++++++ .../GetCurrentAnimatorStateNameHash.cs.meta | 8 +++ .../Basic Tasks/Animator/GetDeltaPosition.cs | 45 ++++++++++++++++ .../Basic Tasks/Animator/GetDeltaPosition.cs.meta | 8 +++ .../Basic Tasks/Animator/GetDeltaRotation.cs | 46 ++++++++++++++++ .../Basic Tasks/Animator/GetDeltaRotation.cs.meta | 8 +++ .../Basic Tasks/Animator/GetFloatParameter.cs | 48 +++++++++++++++++ .../Basic Tasks/Animator/GetFloatParameter.cs.meta | 8 +++ .../Basic Tasks/Animator/GetGravityWeight.cs | 45 ++++++++++++++++ .../Basic Tasks/Animator/GetGravityWeight.cs.meta | 8 +++ .../Basic Tasks/Animator/GetIntegerParameter.cs | 48 +++++++++++++++++ .../Animator/GetIntegerParameter.cs.meta | 8 +++ .../Runtime/Basic Tasks/Animator/GetLayerWeight.cs | 48 +++++++++++++++++ .../Basic Tasks/Animator/GetLayerWeight.cs.meta | 8 +++ .../Runtime/Basic Tasks/Animator/GetSpeed.cs | 45 ++++++++++++++++ .../Runtime/Basic Tasks/Animator/GetSpeed.cs.meta | 8 +++ .../Basic Tasks/Animator/GetStringToHash.cs | 28 ++++++++++ .../Basic Tasks/Animator/GetStringToHash.cs.meta | 8 +++ .../Basic Tasks/Animator/InterruptMatchTarget.cs | 44 +++++++++++++++ .../Animator/InterruptMatchTarget.cs.meta | 8 +++ .../Runtime/Basic Tasks/Animator/IsInTransition.cs | 42 +++++++++++++++ .../Basic Tasks/Animator/IsInTransition.cs.meta | 8 +++ .../Runtime/Basic Tasks/Animator/IsName.cs | 45 ++++++++++++++++ .../Runtime/Basic Tasks/Animator/IsName.cs.meta | 8 +++ .../Animator/IsParameterControlledByCurve.cs | 42 +++++++++++++++ .../Animator/IsParameterControlledByCurve.cs.meta | 8 +++ .../Runtime/Basic Tasks/Animator/MatchTarget.cs | 62 +++++++++++++++++++++ .../Basic Tasks/Animator/MatchTarget.cs.meta | 8 +++ .../Runtime/Basic Tasks/Animator/Play.cs | 50 +++++++++++++++++ .../Runtime/Basic Tasks/Animator/Play.cs.meta | 8 +++ .../Basic Tasks/Animator/SetApplyRootMotion.cs | 44 +++++++++++++++ .../Animator/SetApplyRootMotion.cs.meta | 8 +++ .../Basic Tasks/Animator/SetBoolParameter.cs | 62 +++++++++++++++++++++ .../Basic Tasks/Animator/SetBoolParameter.cs.meta | 8 +++ .../Basic Tasks/Animator/SetFloatParameter.cs | 63 ++++++++++++++++++++++ .../Basic Tasks/Animator/SetFloatParameter.cs.meta | 8 +++ .../Basic Tasks/Animator/SetIntegerParameter.cs | 63 ++++++++++++++++++++++ .../Animator/SetIntegerParameter.cs.meta | 8 +++ .../Runtime/Basic Tasks/Animator/SetLayerWeight.cs | 47 ++++++++++++++++ .../Basic Tasks/Animator/SetLayerWeight.cs.meta | 8 +++ .../Basic Tasks/Animator/SetLookAtPosition.cs | 44 +++++++++++++++ .../Basic Tasks/Animator/SetLookAtPosition.cs.meta | 8 +++ .../Basic Tasks/Animator/SetLookAtWeight.cs | 57 ++++++++++++++++++++ .../Basic Tasks/Animator/SetLookAtWeight.cs.meta | 8 +++ .../Runtime/Basic Tasks/Animator/SetSpeed.cs | 44 +++++++++++++++ .../Runtime/Basic Tasks/Animator/SetSpeed.cs.meta | 8 +++ .../Runtime/Basic Tasks/Animator/SetTrigger.cs | 44 +++++++++++++++ .../Basic Tasks/Animator/SetTrigger.cs.meta | 8 +++ .../Runtime/Basic Tasks/Animator/StartPlayback.cs | 41 ++++++++++++++ .../Basic Tasks/Animator/StartPlayback.cs.meta | 8 +++ .../Runtime/Basic Tasks/Animator/StartRecording.cs | 44 +++++++++++++++ .../Basic Tasks/Animator/StartRecording.cs.meta | 8 +++ .../Runtime/Basic Tasks/Animator/StopPlayback.cs | 41 ++++++++++++++ .../Basic Tasks/Animator/StopPlayback.cs.meta | 8 +++ .../Runtime/Basic Tasks/Animator/StopRecording.cs | 41 ++++++++++++++ .../Basic Tasks/Animator/StopRecording.cs.meta | 8 +++ 62 files changed, 1717 insertions(+) create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/CrossFade.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/CrossFade.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetApplyRootMotion.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetApplyRootMotion.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetBoolParameter.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetBoolParameter.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetCurrentAnimatorStateNameHash.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetCurrentAnimatorStateNameHash.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetDeltaPosition.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetDeltaPosition.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetDeltaRotation.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetDeltaRotation.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetFloatParameter.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetFloatParameter.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetGravityWeight.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetGravityWeight.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetIntegerParameter.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetIntegerParameter.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetLayerWeight.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetLayerWeight.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetSpeed.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetSpeed.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetStringToHash.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetStringToHash.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/InterruptMatchTarget.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/InterruptMatchTarget.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/IsInTransition.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/IsInTransition.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/IsName.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/IsName.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/IsParameterControlledByCurve.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/IsParameterControlledByCurve.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/MatchTarget.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/MatchTarget.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/Play.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/Play.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetApplyRootMotion.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetApplyRootMotion.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetBoolParameter.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetBoolParameter.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetFloatParameter.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetFloatParameter.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetIntegerParameter.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetIntegerParameter.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetLayerWeight.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetLayerWeight.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetLookAtPosition.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetLookAtPosition.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetLookAtWeight.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetLookAtWeight.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetSpeed.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetSpeed.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetTrigger.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetTrigger.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/StartPlayback.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/StartPlayback.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/StartRecording.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/StartRecording.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/StopPlayback.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/StopPlayback.cs.meta create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/StopRecording.cs create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/StopRecording.cs.meta (limited to 'Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator') diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/CrossFade.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/CrossFade.cs new file mode 100644 index 00000000..0e2e3eb7 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/CrossFade.cs @@ -0,0 +1,53 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityAnimator +{ + [TaskCategory("Basic/Animator")] + [TaskDescription("Creates a dynamic transition between the current state and the destination state. Returns Success.")] + public class CrossFade : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The name of the state")] + public SharedString stateName; + [Tooltip("The duration of the transition. Value is in source state normalized time")] + public SharedFloat transitionDuration; + [Tooltip("The layer where the state is")] + public int layer = -1; + [Tooltip("The normalized time at which the state will play")] + public float normalizedTime = float.NegativeInfinity; + + private Animator animator; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + animator = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (animator == null) { + //Debug.LogWarning("Animator is null"); + return TaskStatus.Failure; + } + + animator.CrossFade(stateName.Value, transitionDuration.Value, layer, normalizedTime); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + stateName = ""; + transitionDuration = 0; + layer = -1; + normalizedTime = float.NegativeInfinity; + } + } +} diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/CrossFade.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/CrossFade.cs.meta new file mode 100644 index 00000000..d67ad7da --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/CrossFade.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 09e5aba2adc719f42876293bcbea7819 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetApplyRootMotion.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetApplyRootMotion.cs new file mode 100644 index 00000000..610a4b4e --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetApplyRootMotion.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityAnimator +{ + [TaskCategory("Basic/Animator")] + [TaskDescription("Stores if root motion is applied. Returns Success.")] + public class GetApplyRootMotion : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("Is root motion applied?")] + [RequiredField] + public SharedBool storeValue; + + private Animator animator; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + animator = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (animator == null) { + //Debug.LogWarning("Animator is null"); + return TaskStatus.Failure; + } + + storeValue.Value = animator.applyRootMotion; + + 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/Animator/GetApplyRootMotion.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetApplyRootMotion.cs.meta new file mode 100644 index 00000000..de18f15c --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetApplyRootMotion.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 872c96b3950799546863110b7e54d0c8 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetBoolParameter.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetBoolParameter.cs new file mode 100644 index 00000000..5aeef328 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetBoolParameter.cs @@ -0,0 +1,48 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityAnimator +{ + [TaskCategory("Basic/Animator")] + [TaskDescription("Stores the bool parameter on an animator. Returns Success.")] + public class GetBoolParameter : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The name of the parameter")] + public SharedString paramaterName; + [Tooltip("The value of the bool parameter")] + [RequiredField] + public SharedBool storeValue; + + private Animator animator; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + animator = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (animator == null) { + //Debug.LogWarning("Animator is null"); + return TaskStatus.Failure; + } + + storeValue.Value = animator.GetBool(paramaterName.Value); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + paramaterName = ""; + storeValue = false; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetBoolParameter.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetBoolParameter.cs.meta new file mode 100644 index 00000000..daf50ea0 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetBoolParameter.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2aeb7ebc08541794aa3ed0343c49c9f9 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetCurrentAnimatorStateNameHash.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetCurrentAnimatorStateNameHash.cs new file mode 100644 index 00000000..df97d7ca --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetCurrentAnimatorStateNameHash.cs @@ -0,0 +1,50 @@ +#if UNITY_4_6 || UNITY_4_7 +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityAnimator +{ + [TaskCategory("Basic/Animator")] + [TaskDescription("Gets the current state hash. Returns Success.")] + public class GetCurrentAnimatorStateNameHash : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The layer to operate on")] + public SharedInt layerIndex; + [Tooltip("The current state hash")] + [RequiredField] + public SharedInt storeValue; + + private Animator animator; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + animator = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (animator == null) { + //Debug.LogWarning("Animator is null"); + return TaskStatus.Failure; + } + + storeValue.Value = animator.GetCurrentAnimatorStateInfo(layerIndex.Value).nameHash; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + layerIndex = 0; + storeValue = 0; + } + } +} +#endif \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetCurrentAnimatorStateNameHash.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetCurrentAnimatorStateNameHash.cs.meta new file mode 100644 index 00000000..206d8fd2 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetCurrentAnimatorStateNameHash.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2c0de75c64a6b6f4b8ef18423f1dc36d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetDeltaPosition.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetDeltaPosition.cs new file mode 100644 index 00000000..7d39667f --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetDeltaPosition.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityAnimator +{ + [TaskCategory("Basic/Animator")] + [TaskDescription("Gets the avatar delta position for the last evaluated frame. Returns Success.")] + public class GetDeltaPosition : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The avatar delta position")] + [RequiredField] + public SharedVector3 storeValue; + + private Animator animator; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + animator = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (animator == null) { + //Debug.LogWarning("Animator is null"); + return TaskStatus.Failure; + } + + storeValue.Value = animator.deltaPosition; + + 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/Animator/GetDeltaPosition.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetDeltaPosition.cs.meta new file mode 100644 index 00000000..472f73da --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetDeltaPosition.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9c44c26d5d6b3484397b8aa6ed658b1e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetDeltaRotation.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetDeltaRotation.cs new file mode 100644 index 00000000..023e1c3b --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetDeltaRotation.cs @@ -0,0 +1,46 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityAnimator +{ + [TaskCategory("Basic/Animator")] + [TaskDescription("Gets the avatar delta rotation for the last evaluated frame. Returns Success.")] + public class GetDeltaRotation : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The avatar delta rotation")] + [RequiredField] + public SharedQuaternion storeValue; + + private Animator animator; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + animator = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (animator == null) { + //Debug.LogWarning("Animator is null"); + return TaskStatus.Failure; + } + + storeValue.Value = animator.deltaRotation; + + return TaskStatus.Success; + } + + public override void OnReset() + { + if (storeValue != null) { + storeValue.Value = Quaternion.identity; + } + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetDeltaRotation.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetDeltaRotation.cs.meta new file mode 100644 index 00000000..a26ba42a --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetDeltaRotation.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f120073dca714344495aa139eea16e2b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetFloatParameter.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetFloatParameter.cs new file mode 100644 index 00000000..63182145 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetFloatParameter.cs @@ -0,0 +1,48 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityAnimator +{ + [TaskCategory("Basic/Animator")] + [TaskDescription("Stores the float parameter on an animator. Returns Success.")] + public class GetFloatParameter : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The name of the parameter")] + public SharedString paramaterName; + [Tooltip("The value of the float parameter")] + [RequiredField] + public SharedFloat storeValue; + + private Animator animator; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + animator = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (animator == null) { + //Debug.LogWarning("Animator is null"); + return TaskStatus.Failure; + } + + storeValue.Value = animator.GetFloat(paramaterName.Value); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + paramaterName = ""; + storeValue = 0; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetFloatParameter.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetFloatParameter.cs.meta new file mode 100644 index 00000000..3dcbccc5 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetFloatParameter.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d33dbb5444b5bbe44bb200e39823cfe1 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetGravityWeight.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetGravityWeight.cs new file mode 100644 index 00000000..a9cd172a --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetGravityWeight.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityAnimator +{ + [TaskCategory("Basic/Animator")] + [TaskDescription("Stores the current gravity weight based on current animations that are played. Returns Success.")] + public class GetGravityWeight : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The value of the gravity weight")] + [RequiredField] + public SharedFloat storeValue; + + private Animator animator; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + animator = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (animator == null) { + //Debug.LogWarning("Animator is null"); + return TaskStatus.Failure; + } + + storeValue.Value = animator.gravityWeight; + + 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/Animator/GetGravityWeight.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetGravityWeight.cs.meta new file mode 100644 index 00000000..21b687ce --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetGravityWeight.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 945593329da80b44898e7e1ae1883d07 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetIntegerParameter.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetIntegerParameter.cs new file mode 100644 index 00000000..920d5bc4 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetIntegerParameter.cs @@ -0,0 +1,48 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityAnimator +{ + [TaskCategory("Basic/Animator")] + [TaskDescription("Stores the integer parameter on an animator. Returns Success.")] + public class GetIntegerParameter : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The name of the parameter")] + public SharedString paramaterName; + [Tooltip("The value of the integer parameter")] + [RequiredField] + public SharedInt storeValue; + + private Animator animator; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + animator = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (animator == null) { + //Debug.LogWarning("Animator is null"); + return TaskStatus.Failure; + } + + storeValue.Value = animator.GetInteger(paramaterName.Value); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + paramaterName = ""; + storeValue = 0; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetIntegerParameter.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetIntegerParameter.cs.meta new file mode 100644 index 00000000..6834594b --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetIntegerParameter.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c8640eaeae64c2e48ba85336474d59d8 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetLayerWeight.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetLayerWeight.cs new file mode 100644 index 00000000..0d3a8e69 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetLayerWeight.cs @@ -0,0 +1,48 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityAnimator +{ + [TaskCategory("Basic/Animator")] + [TaskDescription("Stores the layer's weight. Returns Success.")] + public class GetLayerWeight : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The index of the layer")] + public SharedInt index; + [Tooltip("The value of the float parameter")] + [RequiredField] + public SharedFloat storeValue; + + private Animator animator; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + animator = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (animator == null) { + //Debug.LogWarning("Animator is null"); + return TaskStatus.Failure; + } + + storeValue.Value = animator.GetLayerWeight(index.Value); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + index = 0; + storeValue = 0; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetLayerWeight.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetLayerWeight.cs.meta new file mode 100644 index 00000000..4c0e6cab --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetLayerWeight.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 346c4295a827d9e4c8029cd29a8e18ca +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetSpeed.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetSpeed.cs new file mode 100644 index 00000000..5adc55e6 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetSpeed.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityAnimator +{ + [TaskCategory("Basic/Animator")] + [TaskDescription("Stores the playback speed of the animator. 1 is normal playback speed. Returns Success.")] + public class GetSpeed : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The playback speed of the Animator")] + [RequiredField] + public SharedFloat storeValue; + + private Animator animator; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + animator = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (animator == null) { + //Debug.LogWarning("Animator is null"); + return TaskStatus.Failure; + } + + storeValue.Value = animator.speed; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + storeValue = 0; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetSpeed.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetSpeed.cs.meta new file mode 100644 index 00000000..c4d6ee6b --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetSpeed.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f87648f776ab12c45883b01e9bebc6a3 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetStringToHash.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetStringToHash.cs new file mode 100644 index 00000000..a7a9843b --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetStringToHash.cs @@ -0,0 +1,28 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityAnimator +{ + [TaskCategory("Basic/Animator")] + [TaskDescription("Converts the state name to its corresponding hash code. Returns Success.")] + public class GetStringToHash : Action + { + [Tooltip("The name of the state to convert to a hash code")] + public SharedString stateName; + [Tooltip("The hash value")] + [RequiredField] + public SharedInt storeValue; + + public override TaskStatus OnUpdate() + { + storeValue.Value = Animator.StringToHash(stateName.Value); + + return TaskStatus.Success; + } + + public override void OnReset() + { + stateName = ""; + storeValue = 0; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetStringToHash.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetStringToHash.cs.meta new file mode 100644 index 00000000..f0f50384 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/GetStringToHash.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 234dcf26bcb550043b3b5de33f0e6a11 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/InterruptMatchTarget.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/InterruptMatchTarget.cs new file mode 100644 index 00000000..d958848e --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/InterruptMatchTarget.cs @@ -0,0 +1,44 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityAnimator +{ + [TaskCategory("Basic/Animator")] + [TaskDescription("Interrupts the automatic target matching. Returns Success.")] + public class InterruptMatchTarget : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("CompleteMatch will make the gameobject match the target completely at the next frame")] + public bool completeMatch = true; + + private Animator animator; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + animator = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (animator == null) { + Debug.LogWarning("Animator is null"); + return TaskStatus.Failure; + } + + animator.InterruptMatchTarget(completeMatch); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + completeMatch = true; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/InterruptMatchTarget.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/InterruptMatchTarget.cs.meta new file mode 100644 index 00000000..0753ae2d --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/InterruptMatchTarget.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 766d802f8842a2945b11253f60d431bb +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/IsInTransition.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/IsInTransition.cs new file mode 100644 index 00000000..e9366eaa --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/IsInTransition.cs @@ -0,0 +1,42 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityAnimator +{ + [TaskCategory("Basic/Animator")] + [TaskDescription("Returns success if the specified AnimatorController layer in a transition.")] + public class IsInTransition : Conditional + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The layer's index")] + public SharedInt index; + + private Animator animator; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + animator = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (animator == null) { + Debug.LogWarning("Animator is null"); + return TaskStatus.Failure; + } + + return animator.IsInTransition(index.Value) ? TaskStatus.Success : TaskStatus.Failure; + } + + public override void OnReset() + { + targetGameObject = null; + index = 0; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/IsInTransition.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/IsInTransition.cs.meta new file mode 100644 index 00000000..39c1452c --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/IsInTransition.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 48c086aaf693a604d8b83eabac3b568e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/IsName.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/IsName.cs new file mode 100644 index 00000000..38869983 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/IsName.cs @@ -0,0 +1,45 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityAnimator +{ + [TaskCategory("Basic/Animator")] + [TaskDescription("Returns success if the specified name matches the name of the active state.")] + public class IsName : Conditional + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The layer's index")] + public SharedInt index; + [Tooltip("The state name to compare")] + public SharedString name; + + private Animator animator; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + animator = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (animator == null) { + Debug.LogWarning("Animator is null"); + return TaskStatus.Failure; + } + + return animator.GetCurrentAnimatorStateInfo(index.Value).IsName(name.Value) ? TaskStatus.Success : TaskStatus.Failure; + } + + public override void OnReset() + { + targetGameObject = null; + index = 0; + name = ""; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/IsName.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/IsName.cs.meta new file mode 100644 index 00000000..7f8263ae --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/IsName.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 96051e2f6a0e7ea42a493e6245e4ccde +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/IsParameterControlledByCurve.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/IsParameterControlledByCurve.cs new file mode 100644 index 00000000..84664930 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/IsParameterControlledByCurve.cs @@ -0,0 +1,42 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityAnimator +{ + [TaskCategory("Basic/Animator")] + [TaskDescription("Returns success if the specified parameter is controlled by an additional curve on an animation.")] + public class IsParameterControlledByCurve : Conditional + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The name of the parameter")] + public SharedString paramaterName; + + private Animator animator; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + animator = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (animator == null) { + Debug.LogWarning("Animator is null"); + return TaskStatus.Failure; + } + + return animator.IsParameterControlledByCurve(paramaterName.Value) ? TaskStatus.Success : TaskStatus.Failure; + } + + public override void OnReset() + { + targetGameObject = null; + paramaterName = ""; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/IsParameterControlledByCurve.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/IsParameterControlledByCurve.cs.meta new file mode 100644 index 00000000..80412d1a --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/IsParameterControlledByCurve.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c5eb4141402ab7c4abb1d4a5c687a757 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/MatchTarget.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/MatchTarget.cs new file mode 100644 index 00000000..c0137247 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/MatchTarget.cs @@ -0,0 +1,62 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityAnimator +{ + [TaskCategory("Basic/Animator")] + [TaskDescription("Automatically adjust the gameobject position and rotation so that the AvatarTarget reaches the matchPosition when the current state is at the specified progress. Returns Success.")] + public class MatchTarget : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The position we want the body part to reach")] + public SharedVector3 matchPosition; + [Tooltip("The rotation in which we want the body part to be")] + public SharedQuaternion matchRotation; + [Tooltip("The body part that is involved in the match")] + public AvatarTarget targetBodyPart; + [Tooltip("Weights for matching position")] + public Vector3 weightMaskPosition; + [Tooltip("Weights for matching rotation")] + public float weightMaskRotation; + [Tooltip("Start time within the animation clip")] + public float startNormalizedTime; + [Tooltip("End time within the animation clip")] + public float targetNormalizedTime = 1; + + private Animator animator; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + animator = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (animator == null) { + Debug.LogWarning("Animator is null"); + return TaskStatus.Failure; + } + + animator.MatchTarget(matchPosition.Value, matchRotation.Value, targetBodyPart, new MatchTargetWeightMask(weightMaskPosition, weightMaskRotation), startNormalizedTime, targetNormalizedTime); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + matchPosition = Vector3.zero; + matchRotation = Quaternion.identity; + targetBodyPart = AvatarTarget.Root; + weightMaskPosition = Vector3.zero; + weightMaskRotation = 0; + startNormalizedTime = 0; + targetNormalizedTime = 1; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/MatchTarget.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/MatchTarget.cs.meta new file mode 100644 index 00000000..d4cfe707 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/MatchTarget.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e0e788b711539ed4dad258780be29de6 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/Play.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/Play.cs new file mode 100644 index 00000000..e76934df --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/Play.cs @@ -0,0 +1,50 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityAnimator +{ + [TaskCategory("Basic/Animator")] + [TaskDescription("Plays an animator state. Returns Success.")] + public class Play : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The name of the state")] + public SharedString stateName; + [Tooltip("The layer where the state is")] + public int layer = -1; + [Tooltip("The normalized time at which the state will play")] + public float normalizedTime = float.NegativeInfinity; + + private Animator animator; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + animator = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (animator == null) { + Debug.LogWarning("Animator is null"); + return TaskStatus.Failure; + } + + animator.Play(stateName.Value, layer, normalizedTime); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + stateName = ""; + layer = -1; + normalizedTime = float.NegativeInfinity; + } + } +} diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/Play.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/Play.cs.meta new file mode 100644 index 00000000..5d05a683 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/Play.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a62df911d37cd8349b0168f875cd58ea +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetApplyRootMotion.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetApplyRootMotion.cs new file mode 100644 index 00000000..c6c81be8 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetApplyRootMotion.cs @@ -0,0 +1,44 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityAnimator +{ + [TaskCategory("Basic/Animator")] + [TaskDescription("Sets if root motion is applied. Returns Success.")] + public class SetApplyRootMotion : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("Is root motion applied?")] + public SharedBool rootMotion; + + private Animator animator; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + animator = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (animator == null) { + Debug.LogWarning("Animator is null"); + return TaskStatus.Failure; + } + + animator.applyRootMotion = rootMotion.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + rootMotion = false; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetApplyRootMotion.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetApplyRootMotion.cs.meta new file mode 100644 index 00000000..dac11abd --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetApplyRootMotion.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f10479b97efcbb94a8089a12bf891b5b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetBoolParameter.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetBoolParameter.cs new file mode 100644 index 00000000..2f8a93c5 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetBoolParameter.cs @@ -0,0 +1,62 @@ +using UnityEngine; +using System.Collections; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityAnimator +{ + [TaskCategory("Basic/Animator")] + [TaskDescription("Sets the bool parameter on an animator. Returns Success.")] + public class SetBoolParameter : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The name of the parameter")] + public SharedString paramaterName; + [Tooltip("The value of the bool parameter")] + public SharedBool boolValue; + [Tooltip("Should the value be reverted back to its original value after it has been set?")] + public bool setOnce; + + private int hashID; + private Animator animator; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + animator = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (animator == null) { + Debug.LogWarning("Animator is null"); + return TaskStatus.Failure; + } + + hashID = UnityEngine.Animator.StringToHash(paramaterName.Value); + + bool prevValue = animator.GetBool(hashID); + animator.SetBool(hashID, boolValue.Value); + if (setOnce) { + StartCoroutine(ResetValue(prevValue)); + } + return TaskStatus.Success; + } + + public IEnumerator ResetValue(bool origVale) + { + yield return null; + animator.SetBool(hashID, origVale); + } + + public override void OnReset() + { + targetGameObject = null; + paramaterName = ""; + boolValue = false; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetBoolParameter.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetBoolParameter.cs.meta new file mode 100644 index 00000000..7bd49fa8 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetBoolParameter.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 04e0905e87bf90a408551067942c08c7 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetFloatParameter.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetFloatParameter.cs new file mode 100644 index 00000000..77093432 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetFloatParameter.cs @@ -0,0 +1,63 @@ +using UnityEngine; +using System.Collections; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityAnimator +{ + [TaskCategory("Basic/Animator")] + [TaskDescription("Sets the float parameter on an animator. Returns Success.")] + public class SetFloatParameter : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The name of the parameter")] + public SharedString paramaterName; + [Tooltip("The value of the float parameter")] + public SharedFloat floatValue; + [Tooltip("Should the value be reverted back to its original value after it has been set?")] + public bool setOnce; + + private int hashID; + private Animator animator; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + animator = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (animator == null) { + Debug.LogWarning("Animator is null"); + return TaskStatus.Failure; + } + + hashID = UnityEngine.Animator.StringToHash(paramaterName.Value); + + float prevValue = animator.GetFloat(hashID); + animator.SetFloat(hashID, floatValue.Value); + if (setOnce) { + StartCoroutine(ResetValue(prevValue)); + } + + return TaskStatus.Success; + } + + public IEnumerator ResetValue(float origVale) + { + yield return null; + animator.SetFloat(hashID, origVale); + } + + public override void OnReset() + { + targetGameObject = null; + paramaterName = ""; + floatValue = 0; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetFloatParameter.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetFloatParameter.cs.meta new file mode 100644 index 00000000..9e216986 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetFloatParameter.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b601abdc989d2ce4f8dc0d3434705814 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetIntegerParameter.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetIntegerParameter.cs new file mode 100644 index 00000000..39fdcca7 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetIntegerParameter.cs @@ -0,0 +1,63 @@ +using UnityEngine; +using System.Collections; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityAnimator +{ + [TaskCategory("Basic/Animator")] + [TaskDescription("Sets the int parameter on an animator. Returns Success.")] + public class SetIntegerParameter : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The name of the parameter")] + public SharedString paramaterName; + [Tooltip("The value of the int parameter")] + public SharedInt intValue; + [Tooltip("Should the value be reverted back to its original value after it has been set?")] + public bool setOnce; + + private int hashID; + private Animator animator; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + animator = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (animator == null) { + Debug.LogWarning("Animator is null"); + return TaskStatus.Failure; + } + + hashID = UnityEngine.Animator.StringToHash(paramaterName.Value); + + int prevValue = animator.GetInteger(hashID); + animator.SetInteger(hashID, intValue.Value); + if (setOnce) { + StartCoroutine(ResetValue(prevValue)); + } + + return TaskStatus.Success; + } + + public IEnumerator ResetValue(int origVale) + { + yield return null; + animator.SetInteger(hashID, origVale); + } + + public override void OnReset() + { + targetGameObject = null; + paramaterName = ""; + intValue = 0; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetIntegerParameter.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetIntegerParameter.cs.meta new file mode 100644 index 00000000..ded6b0ed --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetIntegerParameter.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 07345b9144172a74892b176413bf9ac3 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetLayerWeight.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetLayerWeight.cs new file mode 100644 index 00000000..ae5b529f --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetLayerWeight.cs @@ -0,0 +1,47 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityAnimator +{ + [TaskCategory("Basic/Animator")] + [TaskDescription("Sets the layer's current weight. Returns Success.")] + public class SetLayerWeight : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The layer's index")] + public SharedInt index; + [Tooltip("The weight of the layer")] + public SharedFloat weight; + + private Animator animator; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + animator = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (animator == null) { + Debug.LogWarning("Animator is null"); + return TaskStatus.Failure; + } + + animator.SetLayerWeight(index.Value, weight.Value); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + index = 0; + weight = 0; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetLayerWeight.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetLayerWeight.cs.meta new file mode 100644 index 00000000..6ee4ea45 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetLayerWeight.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 979ffd79261d4bb499331ba9fa80ed7d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetLookAtPosition.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetLookAtPosition.cs new file mode 100644 index 00000000..2f3ece3e --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetLookAtPosition.cs @@ -0,0 +1,44 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityAnimator +{ + [TaskCategory("Basic/Animator")] + [TaskDescription("Sets the look at position. Returns Success.")] + public class SetLookAtPosition : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The position to lookAt")] + public SharedVector3 position; + + private Animator animator; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + animator = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (animator == null) { + Debug.LogWarning("Animator is null"); + return TaskStatus.Failure; + } + + animator.SetLookAtPosition(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/Animator/SetLookAtPosition.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetLookAtPosition.cs.meta new file mode 100644 index 00000000..9cca866d --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetLookAtPosition.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 31c4894aafa2b7f40984915713cff50b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetLookAtWeight.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetLookAtWeight.cs new file mode 100644 index 00000000..e8881e5c --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetLookAtWeight.cs @@ -0,0 +1,57 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityAnimator +{ + [TaskCategory("Basic/Animator")] + [TaskDescription("Sets the look at weight. Returns success immediately after.")] + public class SetLookAtWeight : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("(0-1) the global weight of the LookAt, multiplier for other parameters.")] + public SharedFloat weight; + [Tooltip("(0-1) determines how much the body is involved in the LookAt.")] + public float bodyWeight; + [Tooltip("(0-1) determines how much the head is involved in the LookAt.")] + public float headWeight = 1; + [Tooltip("(0-1) determines how much the eyes are involved in the LookAt.")] + public float eyesWeight; + [Tooltip("(0-1) 0.0 means the character is completely unrestrained in motion, 1.0 means he's completely clamped " + + "(look at becomes impossible), and 0.5 means he'll be able to move on half of the possible range (180 degrees).")] + public float clampWeight = 0.5f; + + private Animator animator; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + animator = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (animator == null) { + Debug.LogWarning("Animator is null"); + return TaskStatus.Failure; + } + + animator.SetLookAtWeight(weight.Value, bodyWeight, headWeight, eyesWeight, clampWeight); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + weight = 0; + bodyWeight = 0; + headWeight = 1; + eyesWeight = 0; + clampWeight = 0.5f; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetLookAtWeight.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetLookAtWeight.cs.meta new file mode 100644 index 00000000..f69692c9 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetLookAtWeight.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1d700204dde35cd4c9e5a8553089127e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetSpeed.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetSpeed.cs new file mode 100644 index 00000000..e38f45ba --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetSpeed.cs @@ -0,0 +1,44 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityAnimator +{ + [TaskCategory("Basic/Animator")] + [TaskDescription("Sets the playback speed of the Animator. 1 is normal playback speed. Returns Success.")] + public class SetSpeed : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The playback speed of the Animator")] + public SharedFloat speed; + + private Animator animator; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + animator = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (animator == null) { + Debug.LogWarning("Animator is null"); + return TaskStatus.Failure; + } + + animator.speed = speed.Value; + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + speed = 0; + } + } +} \ No newline at end of file diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetSpeed.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetSpeed.cs.meta new file mode 100644 index 00000000..f30c47bd --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetSpeed.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b5cd3c9afb48ee541afcce2dade6bc6a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetTrigger.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetTrigger.cs new file mode 100644 index 00000000..085fe89b --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetTrigger.cs @@ -0,0 +1,44 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityAnimator +{ + [TaskCategory("Basic/Animator")] + [TaskDescription("Sets a trigger parameter to active or inactive. Returns Success.")] + public class SetTrigger : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The name of the parameter")] + public SharedString paramaterName; + + private Animator animator; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + animator = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (animator == null) { + Debug.LogWarning("Animator is null"); + return TaskStatus.Failure; + } + + animator.SetTrigger(paramaterName.Value); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + paramaterName.Value = ""; + } + } +} diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetTrigger.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetTrigger.cs.meta new file mode 100644 index 00000000..fc5f8f1e --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/SetTrigger.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 004807d2b68cad7459f6d84ce1274c16 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/StartPlayback.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/StartPlayback.cs new file mode 100644 index 00000000..6c35b0e9 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/StartPlayback.cs @@ -0,0 +1,41 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityAnimator +{ + [TaskCategory("Basic/Animator")] + [TaskDescription("Sets the animator in playback mode.")] + public class StartPlayback : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + + private Animator animator; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + animator = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (animator == null) { + Debug.LogWarning("Animator is null"); + return TaskStatus.Failure; + } + + animator.StartPlayback(); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + } + } +} diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/StartPlayback.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/StartPlayback.cs.meta new file mode 100644 index 00000000..7332f68e --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/StartPlayback.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 46d4b19160ba8774ea6100dda4288753 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/StartRecording.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/StartRecording.cs new file mode 100644 index 00000000..f9ebf502 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/StartRecording.cs @@ -0,0 +1,44 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityAnimator +{ + [TaskCategory("Basic/Animator")] + [TaskDescription("Sets the animator in recording mode. Returns Success.")] + public class StartRecording : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + [Tooltip("The number of frames (updates) that will be recorded")] + public int frameCount; + + private Animator animator; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + animator = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (animator == null) { + Debug.LogWarning("Animator is null"); + return TaskStatus.Failure; + } + + animator.StartRecording(frameCount); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + frameCount = 0; + } + } +} diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/StartRecording.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/StartRecording.cs.meta new file mode 100644 index 00000000..87f0ddb2 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/StartRecording.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d6f14b502ed889444a0e44e8cb06e767 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/StopPlayback.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/StopPlayback.cs new file mode 100644 index 00000000..8096b930 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/StopPlayback.cs @@ -0,0 +1,41 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityAnimator +{ + [TaskCategory("Basic/Animator")] + [TaskDescription("Stops the animator playback mode. Returns Success.")] + public class StopPlayback : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + + private Animator animator; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + animator = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (animator == null) { + Debug.LogWarning("Animator is null"); + return TaskStatus.Failure; + } + + animator.StopPlayback(); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + } + } +} diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/StopPlayback.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/StopPlayback.cs.meta new file mode 100644 index 00000000..eb10c87f --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/StopPlayback.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7daa3c083e51ad44a8c8b05bb4e70689 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/StopRecording.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/StopRecording.cs new file mode 100644 index 00000000..cd531c7f --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/StopRecording.cs @@ -0,0 +1,41 @@ +using UnityEngine; + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityAnimator +{ + [TaskCategory("Basic/Animator")] + [TaskDescription("Stops animator record mode. Returns Success.")] + public class StopRecording : Action + { + [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] + public SharedGameObject targetGameObject; + + private Animator animator; + private GameObject prevGameObject; + + public override void OnStart() + { + var currentGameObject = GetDefaultGameObject(targetGameObject.Value); + if (currentGameObject != prevGameObject) { + animator = currentGameObject.GetComponent(); + prevGameObject = currentGameObject; + } + } + + public override TaskStatus OnUpdate() + { + if (animator == null) { + Debug.LogWarning("Animator is null"); + return TaskStatus.Failure; + } + + animator.StopRecording(); + + return TaskStatus.Success; + } + + public override void OnReset() + { + targetGameObject = null; + } + } +} diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/StopRecording.cs.meta b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/StopRecording.cs.meta new file mode 100644 index 00000000..d8001590 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Animator/StopRecording.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c62c2817a5d72054caebff852d50ef17 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: -- cgit v1.1-26-g67d0