mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-21 09:39:56 +00:00
Revert "fix singularity NRE when player connection blocked"
This reverts commit 159dc2c1624d04f26626e80e3a05e3a29864f775.
This commit is contained in:
parent
159dc2c162
commit
e28d9ea7ad
@ -35,8 +35,6 @@ public static class JoinLeaveSingularity
|
||||
|
||||
var go = new GameObject($"player {player} JoinLeaveSingularity");
|
||||
var ct = go.GetCancellationTokenOnDestroy();
|
||||
QSBPlayerManager.OnRemovePlayer += (PlayerInfo removedPlayer) => OnPlayerRemoved(removedPlayer, player, go);
|
||||
|
||||
UniTask.Create(async () =>
|
||||
{
|
||||
DebugLog.DebugWrite($"{go.name}: WARP TASK");
|
||||
@ -44,21 +42,11 @@ public static class JoinLeaveSingularity
|
||||
await go.name.Try("running warp task",
|
||||
() => Run(go.transform, player, joining, ct));
|
||||
Object.Destroy(go);
|
||||
QSBPlayerManager.OnRemovePlayer -= (PlayerInfo removedPlayer) => OnPlayerRemoved(removedPlayer, player, go);
|
||||
|
||||
DebugLog.DebugWrite($"{go.name}: WARP TASK DONE");
|
||||
});
|
||||
}
|
||||
|
||||
private static void OnPlayerRemoved(PlayerInfo playerRemoved, PlayerInfo currentPlayer, GameObject cancellationGo)
|
||||
{
|
||||
if (playerRemoved.PlayerId == currentPlayer.PlayerId)
|
||||
{
|
||||
DebugLog.DebugWrite($"{currentPlayer.PlayerId} left - cancel task");
|
||||
Object.Destroy(cancellationGo);
|
||||
}
|
||||
}
|
||||
|
||||
private static async UniTask Run(Transform transform, PlayerInfo player, bool joining, CancellationToken ct)
|
||||
{
|
||||
if (joining)
|
||||
@ -77,8 +65,6 @@ public static class JoinLeaveSingularity
|
||||
GameObject fakePlayer = null;
|
||||
if (!joining)
|
||||
{
|
||||
await UniTask.WaitUntil(() => player.Body, cancellationToken: ct);
|
||||
|
||||
player.Body.SetActive(false);
|
||||
|
||||
fakePlayer = player.Body.transform.Find("REMOTE_Traveller_HEA_Player_v2").gameObject.InstantiateInactive();
|
||||
|
@ -1,6 +1,5 @@
|
||||
using OWML.Common;
|
||||
using QSB.Utility;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.Player;
|
||||
@ -39,13 +38,6 @@ public partial class PlayerInfo
|
||||
if (_body == null && IsReady)
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - {PlayerId}.Body is null!", MessageType.Warning);
|
||||
|
||||
if (!QSBPlayerManager.PlayerExists(PlayerId))
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - Tried to get {PlayerId}.Body, but this player no longer exists in QSBPlayerManager!" +
|
||||
$"\r\nThere was most likely a PlayerInfo object still being referenced after the player had left." +
|
||||
$"\r\nStacktrace: {Environment.StackTrace}", MessageType.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
return _body;
|
||||
|
Loading…
x
Reference in New Issue
Block a user