diff options
author | chai <chaifix@163.com> | 2021-01-27 16:15:06 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-01-27 16:15:06 +0800 |
commit | 97da432c35b8c7aaf9dd2c39e2aa4b1f55f36065 (patch) | |
tree | d9b1db5908a3a030c529e230386fe01062923b09 /Client/Assets/Behavior Designer/Runtime/Basic Tasks/Vector3/Operator.cs | |
parent | 1fe4ffba72f56ccc6a89d1896142425c666887d4 (diff) |
+behaviour designer
Diffstat (limited to 'Client/Assets/Behavior Designer/Runtime/Basic Tasks/Vector3/Operator.cs')
-rw-r--r-- | Client/Assets/Behavior Designer/Runtime/Basic Tasks/Vector3/Operator.cs | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Vector3/Operator.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Vector3/Operator.cs new file mode 100644 index 00000000..fbb467ef --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Vector3/Operator.cs @@ -0,0 +1,47 @@ +using UnityEngine;
+
+namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityVector3
+{
+ [TaskCategory("Basic/Vector3")]
+ [TaskDescription("Performs a math operation on two Vector3s: Add, Subtract, Multiply, Divide, Min, or Max.")]
+ public class Operator : Action
+ {
+ public enum Operation
+ {
+ Add,
+ Subtract,
+ Scale
+ }
+
+ [Tooltip("The operation to perform")]
+ public Operation operation;
+ [Tooltip("The first Vector3")]
+ public SharedVector3 firstVector3;
+ [Tooltip("The second Vector3")]
+ public SharedVector3 secondVector3;
+ [Tooltip("The variable to store the result")]
+ public SharedVector3 storeResult;
+
+ public override TaskStatus OnUpdate()
+ {
+ switch (operation) {
+ case Operation.Add:
+ storeResult.Value = firstVector3.Value + secondVector3.Value;
+ break;
+ case Operation.Subtract:
+ storeResult.Value = firstVector3.Value - secondVector3.Value;
+ break;
+ case Operation.Scale:
+ storeResult.Value = Vector3.Scale(firstVector3.Value, secondVector3.Value);
+ break;
+ }
+ return TaskStatus.Success;
+ }
+
+ public override void OnReset()
+ {
+ operation = Operation.Add;
+ firstVector3 = secondVector3 = storeResult = Vector3.zero;
+ }
+ }
+}
\ No newline at end of file |