mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-27 03:35:20 +00:00
cleanup
This commit is contained in:
parent
1d714e46a1
commit
9bb64c40aa
@ -23,7 +23,7 @@ namespace QSB
|
|||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
DebugLog.ToConsole($"* Start of QSB version {ModHelper.Manifest.Version} - authored by {ModHelper.Manifest.Author}");
|
DebugLog.ToConsole($"* Start of QSB version {ModHelper.Manifest.Version} - authored by {ModHelper.Manifest.Author}", MessageType.Info);
|
||||||
|
|
||||||
Helper = ModHelper;
|
Helper = ModHelper;
|
||||||
NetworkAssetBundle = Helper.Assets.LoadBundle("assets/network");
|
NetworkAssetBundle = Helper.Assets.LoadBundle("assets/network");
|
||||||
|
@ -67,7 +67,6 @@ namespace QSB
|
|||||||
|
|
||||||
public override void OnServerAddPlayer(NetworkConnection connection, short playerControllerId) // Called on the server when a client joins
|
public override void OnServerAddPlayer(NetworkConnection connection, short playerControllerId) // Called on the server when a client joins
|
||||||
{
|
{
|
||||||
DebugLog.ToConsole("On server add player " + playerControllerId);
|
|
||||||
base.OnServerAddPlayer(connection, playerControllerId);
|
base.OnServerAddPlayer(connection, playerControllerId);
|
||||||
|
|
||||||
// These have to be in a constant order (for now, until we get a better netId getting system...)
|
// These have to be in a constant order (for now, until we get a better netId getting system...)
|
||||||
@ -121,7 +120,7 @@ namespace QSB
|
|||||||
var playerId = connection.playerControllers[0].gameObject.GetComponent<PlayerTransformSync>().netId.Value;
|
var playerId = connection.playerControllers[0].gameObject.GetComponent<PlayerTransformSync>().netId.Value;
|
||||||
var netIds = connection.clientOwnedObjects.Select(x => x.Value).ToArray();
|
var netIds = connection.clientOwnedObjects.Select(x => x.Value).ToArray();
|
||||||
GlobalMessenger<uint, uint[]>.FireEvent(EventNames.QSBPlayerLeave, playerId, netIds);
|
GlobalMessenger<uint, uint[]>.FireEvent(EventNames.QSBPlayerLeave, playerId, netIds);
|
||||||
PlayerRegistry.GetPlayer(playerId).HudMarker?.Remove();
|
PlayerRegistry.GetPlayer(playerId).HudMarker?.Remove();
|
||||||
CleanupConnection(connection);
|
CleanupConnection(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +138,7 @@ namespace QSB
|
|||||||
DebugLog.ToConsole($"{playerName} disconnected.", OWML.Common.MessageType.Info);
|
DebugLog.ToConsole($"{playerName} disconnected.", OWML.Common.MessageType.Info);
|
||||||
PlayerRegistry.RemovePlayer(playerId);
|
PlayerRegistry.RemovePlayer(playerId);
|
||||||
|
|
||||||
if (playerId != PlayerRegistry.LocalPlayerId)
|
if (playerId != PlayerRegistry.LocalPlayerId) // We don't want to delete the local player!
|
||||||
{
|
{
|
||||||
var netIds = connection.clientOwnedObjects.Select(x => x.Value).ToList();
|
var netIds = connection.clientOwnedObjects.Select(x => x.Value).ToList();
|
||||||
netIds.ForEach(CleanupNetworkBehaviour);
|
netIds.ForEach(CleanupNetworkBehaviour);
|
||||||
@ -149,6 +148,7 @@ namespace QSB
|
|||||||
public void CleanupNetworkBehaviour(uint netId)
|
public void CleanupNetworkBehaviour(uint netId)
|
||||||
{
|
{
|
||||||
DebugLog.ToConsole($"Cleaning up object {netId}");
|
DebugLog.ToConsole($"Cleaning up object {netId}");
|
||||||
|
// Multiple networkbehaviours can use the same networkidentity (same netId), so get all of them
|
||||||
var networkBehaviours = FindObjectsOfType<NetworkBehaviour>()
|
var networkBehaviours = FindObjectsOfType<NetworkBehaviour>()
|
||||||
.Where(x => x != null && x.netId.Value == netId);
|
.Where(x => x != null && x.netId.Value == netId);
|
||||||
foreach (var networkBehaviour in networkBehaviours)
|
foreach (var networkBehaviour in networkBehaviours)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user