summaryrefslogtreecommitdiff
path: root/Assets/ThirdParty/Behavior Designer/Runtime/Actions/Wait.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2022-03-10 14:07:40 +0800
committerchai <chaifix@163.com>2022-03-10 14:07:40 +0800
commit22891bf59032ba88262824255a706d652031384b (patch)
tree7595439ba9966c9402d37e37cee5e8cf098757d5 /Assets/ThirdParty/Behavior Designer/Runtime/Actions/Wait.cs
parent8b04ea73e540067f83870b61d89db4868fea5e8a (diff)
* move folder
Diffstat (limited to 'Assets/ThirdParty/Behavior Designer/Runtime/Actions/Wait.cs')
-rw-r--r--Assets/ThirdParty/Behavior Designer/Runtime/Actions/Wait.cs67
1 files changed, 0 insertions, 67 deletions
diff --git a/Assets/ThirdParty/Behavior Designer/Runtime/Actions/Wait.cs b/Assets/ThirdParty/Behavior Designer/Runtime/Actions/Wait.cs
deleted file mode 100644
index 41f77a21..00000000
--- a/Assets/ThirdParty/Behavior Designer/Runtime/Actions/Wait.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-using UnityEngine;
-
-namespace BehaviorDesigner.Runtime.Tasks
-{
- [TaskDescription("Wait a specified amount of time. The task will return running until the task is done waiting. It will return success after the wait time has elapsed.")]
- [HelpURL("http://www.opsive.com/assets/BehaviorDesigner/documentation.php?id=22")]
- [TaskIcon("{SkinColor}WaitIcon.png")]
- public class Wait : Action
- {
- [Tooltip("The amount of time to wait")]
- public SharedFloat waitTime = 1;
- [Tooltip("Should the wait be randomized?")]
- public SharedBool randomWait = false;
- [Tooltip("The minimum wait time if random wait is enabled")]
- public SharedFloat randomWaitMin = 1;
- [Tooltip("The maximum wait time if random wait is enabled")]
- public SharedFloat randomWaitMax = 1;
-
- // The time to wait
- private float waitDuration;
- // The time that the task started to wait.
- private float startTime;
- // Remember the time that the task is paused so the time paused doesn't contribute to the wait time.
- private float pauseTime;
-
- public override void OnStart()
- {
- // Remember the start time.
- startTime = Time.time;
- if (randomWait.Value) {
- waitDuration = Random.Range(randomWaitMin.Value, randomWaitMax.Value);
- } else {
- waitDuration = waitTime.Value;
- }
- }
-
- public override TaskStatus OnUpdate()
- {
- // The task is done waiting if the time waitDuration has elapsed since the task was started.
- if (startTime + waitDuration < Time.time) {
- return TaskStatus.Success;
- }
- // Otherwise we are still waiting.
- return TaskStatus.Running;
- }
-
- public override void OnPause(bool paused)
- {
- if (paused) {
- // Remember the time that the behavior was paused.
- pauseTime = Time.time;
- } else {
- // Add the difference between Time.time and pauseTime to figure out a new start time.
- startTime += (Time.time - pauseTime);
- }
- }
-
- public override void OnReset()
- {
- // Reset the public properties back to their original values
- waitTime = 1;
- randomWait = false;
- randomWaitMin = 1;
- randomWaitMax = 1;
- }
- }
-} \ No newline at end of file