mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-04-15 20:42:33 +00:00
more fixey fixey
This commit is contained in:
parent
91fc9b12ca
commit
f5bb68553a
@ -116,6 +116,7 @@ namespace QSB
|
||||
|
||||
public override void OnClientConnect(NetworkConnection connection) // Called on the client when connecting to a server
|
||||
{
|
||||
DebugLog.ToConsole("Connecting to server...", OWML.Common.MessageType.Info);
|
||||
base.OnClientConnect(connection);
|
||||
|
||||
gameObject.AddComponent<SectorSync>();
|
||||
@ -142,13 +143,25 @@ namespace QSB
|
||||
|
||||
public override void OnStopClient() // Called on the client when closing connection
|
||||
{
|
||||
DebugLog.ToConsole("Disconnecting from server...", OWML.Common.MessageType.Info);
|
||||
Destroy(GetComponent<SectorSync>());
|
||||
Destroy(GetComponent<RespawnOnDeath>());
|
||||
Destroy(GetComponent<PreventShipDestruction>());
|
||||
EventList.Reset();
|
||||
if (IsClientConnected())
|
||||
{
|
||||
PlayerTransformSync.LocalInstance.gameObject.GetComponent<AnimationSync>().Reset();
|
||||
PlayerTransformSync.LocalInstance?.gameObject.GetComponent<AnimationSync>().Reset();
|
||||
}
|
||||
foreach (var player in PlayerRegistry.PlayerList)
|
||||
{
|
||||
if (player.HudMarker != null)
|
||||
{
|
||||
Destroy(player.HudMarker.transform.parent.gameObject);
|
||||
}
|
||||
}
|
||||
foreach (var connection in NetworkServer.connections)
|
||||
{
|
||||
CleanupConnection(connection);
|
||||
}
|
||||
_canEditName = true;
|
||||
}
|
||||
@ -176,20 +189,6 @@ namespace QSB
|
||||
base.OnStopServer();
|
||||
}
|
||||
|
||||
public override void OnClientDisconnect(NetworkConnection conn)
|
||||
{
|
||||
DebugLog.ToConsole("Disconnected from server.", OWML.Common.MessageType.Info);
|
||||
foreach (var player in PlayerRegistry.PlayerList)
|
||||
{
|
||||
Destroy(player.HudMarker.transform.parent.gameObject);
|
||||
}
|
||||
foreach (var connection in NetworkServer.connections.Where(x => x != conn))
|
||||
{
|
||||
CleanupConnection(connection);
|
||||
}
|
||||
base.OnClientDisconnect(conn);
|
||||
}
|
||||
|
||||
private void CleanupConnection(NetworkConnection connection)
|
||||
{
|
||||
var playerId = connection.playerControllers[0].gameObject.GetComponent<PlayerTransformSync>().netId.Value;
|
||||
|
@ -49,6 +49,12 @@ namespace QSB.TimeSync
|
||||
GlobalMessenger.AddListener(EventNames.RestartTimeLoop, OnLoopStart);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
QSBSceneManager.OnSceneLoaded -= OnSceneLoaded;
|
||||
GlobalMessenger.RemoveListener(EventNames.RestartTimeLoop, OnLoopStart);
|
||||
}
|
||||
|
||||
private void OnSceneLoaded(OWScene scene, bool isInUniverse)
|
||||
{
|
||||
if (isInUniverse)
|
||||
|
@ -1,5 +1,7 @@
|
||||
using QSB.Events;
|
||||
using QSB.Tools;
|
||||
using QSB.Utility;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.TransformSync
|
||||
@ -13,7 +15,25 @@ namespace QSB.TransformSync
|
||||
LocalInstance = this;
|
||||
}
|
||||
|
||||
public override uint PlayerId => netId.Value - 2;
|
||||
public override uint PlayerId
|
||||
{
|
||||
get
|
||||
{
|
||||
uint id = uint.MaxValue;
|
||||
try
|
||||
{
|
||||
id = netId.Value - 2;
|
||||
}
|
||||
catch
|
||||
{
|
||||
DebugLog.ToConsole($"Error while geting netId of {GetType().Name}! " +
|
||||
$"{Environment.NewLine} - Did you destroy the TransformSync without destroying the {GetType().Name}?" +
|
||||
$"{Environment.NewLine} - Did a destroyed TransformSync/{GetType().Name} still have an active action/event listener?" +
|
||||
$"{Environment.NewLine} If you are a user seeing this, please report this error.", OWML.Common.MessageType.Error);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
protected override Transform InitLocalTransform()
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
using QSB.Tools;
|
||||
using QSB.Utility;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.TransformSync
|
||||
@ -14,7 +16,25 @@ namespace QSB.TransformSync
|
||||
LocalInstance = this;
|
||||
}
|
||||
|
||||
public override uint PlayerId => netId.Value - 3;
|
||||
public override uint PlayerId
|
||||
{
|
||||
get
|
||||
{
|
||||
uint id = uint.MaxValue;
|
||||
try
|
||||
{
|
||||
id = netId.Value - 3;
|
||||
}
|
||||
catch
|
||||
{
|
||||
DebugLog.ToConsole($"Error while geting netId of {GetType().Name}! " +
|
||||
$"{Environment.NewLine} - Did you destroy the TransformSync without destroying the {GetType().Name}?" +
|
||||
$"{Environment.NewLine} - Did a destroyed TransformSync/{GetType().Name} still have an active action/event listener?" +
|
||||
$"{Environment.NewLine} If you are a user seeing this, please report this error.", OWML.Common.MessageType.Error);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
private Transform GetProbe()
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
using QSB.Animation;
|
||||
using QSB.Utility;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.TransformSync
|
||||
@ -17,7 +19,25 @@ namespace QSB.TransformSync
|
||||
LocalInstance = this;
|
||||
}
|
||||
|
||||
public override uint PlayerId => netId.Value - 0;
|
||||
public override uint PlayerId
|
||||
{
|
||||
get
|
||||
{
|
||||
uint id = uint.MaxValue;
|
||||
try
|
||||
{
|
||||
id = netId.Value - 0;
|
||||
}
|
||||
catch
|
||||
{
|
||||
DebugLog.ToConsole($"Error while geting netId of {GetType().Name}! " +
|
||||
$"{Environment.NewLine} - Did you destroy the TransformSync without destroying the {GetType().Name}?" +
|
||||
$"{Environment.NewLine} - Did a destroyed TransformSync/{GetType().Name} still have an active action/event listener?" +
|
||||
$"{Environment.NewLine} If you are a user seeing this, please report this error.", OWML.Common.MessageType.Error);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
private Transform GetPlayerModel()
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
using UnityEngine;
|
||||
using QSB.Utility;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.TransformSync
|
||||
{
|
||||
@ -11,7 +13,25 @@ namespace QSB.TransformSync
|
||||
LocalInstance = this;
|
||||
}
|
||||
|
||||
public override uint PlayerId => netId.Value - 1;
|
||||
public override uint PlayerId
|
||||
{
|
||||
get
|
||||
{
|
||||
uint id = uint.MaxValue;
|
||||
try
|
||||
{
|
||||
id = netId.Value - 1;
|
||||
}
|
||||
catch
|
||||
{
|
||||
DebugLog.ToConsole($"Error while geting netId of {GetType().Name}! " +
|
||||
$"{Environment.NewLine} - Did you destroy the TransformSync without destroying the {GetType().Name}?" +
|
||||
$"{Environment.NewLine} - Did a destroyed TransformSync/{GetType().Name} still have an active action/event listener?" +
|
||||
$"{Environment.NewLine} If you are a user seeing this, please report this error.", OWML.Common.MessageType.Error);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
private Transform GetShipModel()
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user