🐛Exiting fight happening when one side wins
This commit is contained in:
@@ -50,4 +50,13 @@ public partial class FightSceneSwitcher : Node
|
||||
};
|
||||
LoadNext();
|
||||
}
|
||||
|
||||
public void ExitFight()
|
||||
{
|
||||
if (FightWorld.Instance.fightHappeningData == null)
|
||||
throw new Exception("Trying to exit a fight while not in a fight");
|
||||
|
||||
FightWorld.Instance.fightHappeningData = null;
|
||||
LoadNext();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://2f7rqk50gtdg
|
||||
Reference in New Issue
Block a user