mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-01 03:32:38 +00:00
JoinLeaveSingularity: make static instead of using MonoBehaviour
This commit is contained in:
parent
a85efa403c
commit
709cc4c905
@ -8,7 +8,7 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace QSB.Player
|
namespace QSB.Player
|
||||||
{
|
{
|
||||||
public class JoinLeaveSingularity : MonoBehaviour
|
public static class JoinLeaveSingularity
|
||||||
{
|
{
|
||||||
public static void Create(PlayerInfo player, bool joining)
|
public static void Create(PlayerInfo player, bool joining)
|
||||||
{
|
{
|
||||||
@ -27,18 +27,18 @@ namespace QSB.Player
|
|||||||
|
|
||||||
DebugLog.DebugWrite($"WARP TASK {player.PlayerId}");
|
DebugLog.DebugWrite($"WARP TASK {player.PlayerId}");
|
||||||
|
|
||||||
var joinLeaveSingularity = new GameObject(nameof(JoinLeaveSingularity)).AddComponent<JoinLeaveSingularity>();
|
var go = new GameObject(nameof(JoinLeaveSingularity));
|
||||||
var ct = joinLeaveSingularity.GetCancellationTokenOnDestroy();
|
var ct = go.GetCancellationTokenOnDestroy();
|
||||||
UniTask.Create(async () =>
|
UniTask.Create(async () =>
|
||||||
{
|
{
|
||||||
await joinLeaveSingularity.Run(player, joining, ct).SuppressCancellationThrow();
|
await Run(go.transform, player, joining, ct).SuppressCancellationThrow();
|
||||||
Destroy(joinLeaveSingularity.gameObject);
|
Object.Destroy(go);
|
||||||
|
|
||||||
DebugLog.DebugWrite($"WARP TASK DONE {player.PlayerId}");
|
DebugLog.DebugWrite($"WARP TASK DONE {player.PlayerId}");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private async UniTask Run(PlayerInfo player, bool joining, CancellationToken ct)
|
private static async UniTask Run(Transform transform, PlayerInfo player, bool joining, CancellationToken ct)
|
||||||
{
|
{
|
||||||
if (joining)
|
if (joining)
|
||||||
{
|
{
|
||||||
@ -71,7 +71,7 @@ namespace QSB.Player
|
|||||||
}
|
}
|
||||||
else if (component is not (Transform or Renderer))
|
else if (component is not (Transform or Renderer))
|
||||||
{
|
{
|
||||||
Destroy(component);
|
Object.Destroy(component);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ namespace QSB.Player
|
|||||||
|
|
||||||
if (!joining)
|
if (!joining)
|
||||||
{
|
{
|
||||||
Destroy(fakePlayer);
|
Object.Destroy(fakePlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
await UniTask.WaitUntil(() => !singularity._owOneShotSource.isPlaying, cancellationToken: ct);
|
await UniTask.WaitUntil(() => !singularity._owOneShotSource.isPlaying, cancellationToken: ct);
|
||||||
|
Loading…
Reference in New Issue
Block a user