Skip to content

Commit 36eaf09

Browse files
fix Countdown method being interrupted by script ending
1 parent d4449ae commit 36eaf09

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

Code/Helpers/BetterCoros.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public static class BetterCoros
1111
{
1212
public static CoroutineHandle Run(
1313
this IEnumerator<float> coro,
14-
Script scr,
14+
Script? scr,
1515
Action<Exception>? onException = null,
1616
Action? onFinish = null
1717
)
@@ -26,7 +26,7 @@ public static void Kill(this CoroutineHandle coro)
2626

2727
private static IEnumerator<float> Wrapper(
2828
IEnumerator<float> routine,
29-
Script scr,
29+
Script? scr,
3030
Action<Exception>? onException = null,
3131
Action? onFinish = null
3232
)
@@ -49,29 +49,29 @@ private static IEnumerator<float> Wrapper(
4949
catch (ScriptCompileError compErr)
5050
{
5151
onException?.Invoke(compErr);
52-
scr.Error(compErr.Message);
52+
scr?.Error(compErr.Message);
5353
goto End;
5454
}
5555
catch (ScriptRuntimeError runErr)
5656
{
5757
onException?.Invoke(runErr);
58-
scr.Error(runErr.Message);
58+
scr?.Error(runErr.Message);
5959
goto End;
6060
}
6161
catch (DeveloperFuckedUpException devErr)
6262
{
6363
onException?.Invoke(devErr);
64-
scr.Error(devErr.Message + "\n" + devErr.StackTrace);
64+
scr?.Error(devErr.Message + "\n" + devErr.StackTrace);
6565
goto End;
6666
}
6767
catch (Exception ex)
6868
{
6969
onException?.Invoke(ex);
70-
scr.Error($"Coroutine failed with {ex.GetType().AccurateName}: {ex.Message}\n{ex.StackTrace}");
70+
scr?.Error($"Coroutine failed with {ex.GetType().AccurateName}: {ex.Message}\n{ex.StackTrace}");
7171
goto End;
7272
}
7373

74-
if (scr.Killed)
74+
if (scr?.Killed is true)
7575
{
7676
goto End;
7777
}

Code/MethodSystem/Methods/BroadcastMethods/CountdownMethod.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public override void Execute()
3232

3333
foreach (var plr in players)
3434
{
35-
var coro = RunCoroutine(Countdown(plr, duration, title));
35+
var coro = Countdown(plr, duration, title).Run(null);
3636
if (Coroutines.TryGetValue(plr, out var coroutine))
3737
coroutine.Kill();
3838

0 commit comments

Comments
 (0)