You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Babushka/scripts/CSharp/Common/Fight/SwitchSceneOnFightEnd.cs

22 lines
621 B

using System.Threading.Tasks;
using Godot;
namespace Babushka.scripts.CSharp.Common.Fight;
public partial class SwitchSceneOnFightEnd : Node
{
[Export] private FightSceneSwitcher _fightSceneSwitcher = null!;
public void OnFightStateEnter(FightHappening.FightState to)
{
if (to is FightHappening.FightState.PlayerWin
or FightHappening.FightState.EnemyWin)
_ = SwitchSceneAfterTime(2.0f);
}
private async Task SwitchSceneAfterTime(float seconds)
{
await ToSignal(GetTree().CreateTimer(seconds), "timeout");
_fightSceneSwitcher.ExitFight();
}
}