mirror of
https://github.com/tym1116/BH3.git
synced 2025-12-12 22:44:35 +01:00
47 lines
1.0 KiB
C#
47 lines
1.0 KiB
C#
using BehaviorDesigner.Runtime.Tasks;
|
|
using UnityEngine;
|
|
|
|
namespace MoleMole
|
|
{
|
|
[TaskIcon("{SkinColor}WaitIcon.png")]
|
|
[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.")]
|
|
public class Wait : Action
|
|
{
|
|
public float waitTime = 1f;
|
|
|
|
public float randomAddRange;
|
|
|
|
private float _timer;
|
|
|
|
private IAIEntity _aiEntity;
|
|
|
|
public override void OnAwake()
|
|
{
|
|
BaseMonoAnimatorEntity component = GetComponent<BaseMonoAnimatorEntity>();
|
|
if (component is BaseMonoAvatar)
|
|
{
|
|
_aiEntity = (BaseMonoAvatar)component;
|
|
}
|
|
else if (component is BaseMonoMonster)
|
|
{
|
|
_aiEntity = (BaseMonoMonster)component;
|
|
}
|
|
}
|
|
|
|
public override void OnStart()
|
|
{
|
|
_timer = waitTime + randomAddRange * Random.value;
|
|
}
|
|
|
|
public override TaskStatus OnUpdate()
|
|
{
|
|
if (_timer < 0f)
|
|
{
|
|
return TaskStatus.Success;
|
|
}
|
|
_timer -= Time.deltaTime * _aiEntity.TimeScale;
|
|
return TaskStatus.Running;
|
|
}
|
|
}
|
|
}
|