This commit is contained in:
Mister_Nebula 2020-08-20 13:43:16 +01:00
parent 6f67567f89
commit 80473b232b
2 changed files with 7 additions and 6 deletions

View File

@ -112,7 +112,7 @@ namespace QSB
Destroy(GetComponent<PreventShipDestruction>());
EventList.Reset();
PlayerRegistry.PlayerList.ForEach(player => player.HudMarker?.Remove());
NetworkServer.connections.ToList()Where(x => x.playerControllers[0].gameObject.GetComponent<PlayerTransformSync>().netId.Value != PlayerRegistry.LocalPlayerId).ForEach(CleanupConnection);
NetworkServer.connections.ToList().ForEach(CleanupConnection);
_lobby.CanEditName = true;
}
@ -139,12 +139,16 @@ namespace QSB
DebugLog.ToConsole($"{playerName} disconnected.", OWML.Common.MessageType.Info);
PlayerRegistry.RemovePlayer(playerId);
var netIds = connection.clientOwnedObjects.Select(x => x.Value).ToList();
netIds.ForEach(CleanupNetworkBehaviour);
if (playerId != PlayerRegistry.LocalPlayerId)
{
var netIds = connection.clientOwnedObjects.Select(x => x.Value).ToList();
netIds.ForEach(CleanupNetworkBehaviour);
}
}
public void CleanupNetworkBehaviour(uint netId)
{
DebugLog.ToConsole($"Cleaning up object {netId}");
var networkBehaviours = FindObjectsOfType<NetworkBehaviour>()
.Where(x => x != null && x.netId.Value == netId);
foreach (var networkBehaviour in networkBehaviours)
@ -153,11 +157,9 @@ namespace QSB
if (transformSync != null)
{
DebugLog.ToConsole(" * TS is not null - removing from list");
PlayerRegistry.TransformSyncs.Remove(transformSync);
if (transformSync.SyncedTransform != null)
{
DebugLog.ToConsole(" * TS's ST is not null - destroying");
Destroy(transformSync.SyncedTransform.gameObject);
}
}

View File

@ -42,7 +42,6 @@ namespace QSB.TransformSync
private void SendSector(uint id, QSBSector sector)
{
DebugLog.ToConsole($"Sending sector event for {id}");
GlobalMessenger<uint, QSBSector>.FireEvent(EventNames.QSBSectorChange, id, sector);
}
}