cirnogodot/Scripts/AttackPatterns/WaitPattern.cs
2025-06-30 17:28:19 +02:00

47 lines
No EOL
1 KiB
C#

using System.Threading.Tasks;
using Cirno.Scripts.Resources;
using Godot;
namespace Cirno.Scripts.AttackPatterns;
[GlobalClass]
[Tool]
public partial class WaitPattern : AttackPattern
{
[Export] public float SecondsToWait = 1f;
public override IPatternMachine MakeMachine(Node parent)
{
return new WaitPatternMachine(this, parent);
}
public class WaitPatternMachine(WaitPattern pattern, Node parent) : IPatternMachine
{
public Node Parent => parent;
private bool _isComplete = false;
protected IScriptHost3D Boss;
public void Start()
{
_isComplete = false;
_ = WaitAsync(pattern.SecondsToWait);
}
public void UpdatePattern(double delta)
{
}
private async Task WaitAsync(float time)
{
await Task.Delay((int)time * 1000);
_isComplete = true;
}
public bool IsComplete()
{
return _isComplete;
}
}
}