summaryrefslogtreecommitdiff
path: root/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Vector2/Operator.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Client/Assets/Behavior Designer/Runtime/Basic Tasks/Vector2/Operator.cs')
-rw-r--r--Client/Assets/Behavior Designer/Runtime/Basic Tasks/Vector2/Operator.cs47
1 files changed, 47 insertions, 0 deletions
diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Vector2/Operator.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Vector2/Operator.cs
new file mode 100644
index 00000000..36d9a29f
--- /dev/null
+++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Vector2/Operator.cs
@@ -0,0 +1,47 @@
+using UnityEngine;
+
+namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityVector2
+{
+ [TaskCategory("Basic/Vector2")]
+ [TaskDescription("Performs a math operation on two Vector2s: 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 Vector2")]
+ public SharedVector2 firstVector2;
+ [Tooltip("The second Vector2")]
+ public SharedVector2 secondVector2;
+ [Tooltip("The variable to store the result")]
+ public SharedVector2 storeResult;
+
+ public override TaskStatus OnUpdate()
+ {
+ switch (operation) {
+ case Operation.Add:
+ storeResult.Value = firstVector2.Value + secondVector2.Value;
+ break;
+ case Operation.Subtract:
+ storeResult.Value = firstVector2.Value - secondVector2.Value;
+ break;
+ case Operation.Scale:
+ storeResult.Value = Vector2.Scale(firstVector2.Value, secondVector2.Value);
+ break;
+ }
+ return TaskStatus.Success;
+ }
+
+ public override void OnReset()
+ {
+ operation = Operation.Add;
+ firstVector2 = secondVector2 = storeResult = Vector2.zero;
+ }
+ }
+} \ No newline at end of file