mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-29 09:32:38 +00:00
JoinLeaveSingularity: also cancel task if transform sync or player body gets destroyed
This commit is contained in:
parent
6d8d3ea9ff
commit
e125258fde
@ -19,7 +19,7 @@ public static class JoinLeaveSingularity
|
||||
if (joining)
|
||||
{
|
||||
if (PlayerTransformSync.LocalInstance == null ||
|
||||
player.PlayerId < QSBPlayerManager.LocalPlayerId)
|
||||
player.PlayerId < QSBPlayerManager.LocalPlayerId)
|
||||
{
|
||||
// player was here before we joined
|
||||
return;
|
||||
@ -34,7 +34,11 @@ public static class JoinLeaveSingularity
|
||||
}
|
||||
|
||||
var go = new GameObject($"player {player} JoinLeaveSingularity");
|
||||
var ct = go.GetCancellationTokenOnDestroy();
|
||||
var ct = CancellationTokenSource.CreateLinkedTokenSource(
|
||||
go.GetCancellationTokenOnDestroy(),
|
||||
player.TransformSync.GetCancellationTokenOnDestroy(),
|
||||
player.Body.GetCancellationTokenOnDestroy()
|
||||
).Token;
|
||||
UniTask.Create(async () =>
|
||||
{
|
||||
DebugLog.DebugWrite($"{go.name}: WARP TASK");
|
||||
@ -142,4 +146,4 @@ public static class JoinLeaveSingularity
|
||||
};
|
||||
await UniTask.WaitUntil(() => !effect.enabled && !singularity._owOneShotSource.isPlaying, cancellationToken: ct);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user