Merge branch 'dev' into message-manager

This commit is contained in:
JohnCorby 2021-12-12 03:21:59 -08:00
commit 2c117f6635
8 changed files with 51 additions and 29 deletions

View File

@ -176,7 +176,7 @@ namespace QSB.Menus
DisconnectButton = MenuApi.PauseMenu_MakeMenuOpenButton("DISCONNECT", DisconnectPopup);
QuitButton = Locator.GetSceneMenuManager().pauseMenu._exitToMainMenuAction.gameObject;
QuitButton = FindObjectOfType<PauseMenuManager>()._exitToMainMenuAction.gameObject;
if (QSBCore.IsInMultiplayer)
{

View File

@ -17,13 +17,18 @@ namespace QSB.Player
return;
}
if (!WorldObjectManager.AllObjectsReady)
{
return;
}
var controller = Locator.GetPlayerController();
if (controller == null)
{
return;
}
var collidingQuantumObject = controller.GetValue<QuantumObject>("_collidingQuantumObject");
var collidingQuantumObject = controller._collidingQuantumObject;
if (_previousCollidingQuantumObject != collidingQuantumObject)
{
var objectIndex = (collidingQuantumObject != null)

View File

@ -51,22 +51,21 @@ namespace QSB.Player
}
var player = PlayerList.FirstOrDefault(x => x.PlayerId == id);
if (player != null)
if (player == null)
{
return player;
}
if (!QSBCore.IsInMultiplayer)
{
DebugLog.ToConsole($"Error - Tried to create player id:{id} when not in multiplayer! Stacktrace : {Environment.StackTrace}", MessageType.Error);
DebugLog.ToConsole($"Error - Player with id {id} does not exist! Stacktrace : {Environment.StackTrace}", MessageType.Error);
return default;
}
return player;
}
public static void AddPlayer(uint id)
{
DebugLog.DebugWrite($"Create Player : id<{id}>", MessageType.Info);
player = new PlayerInfo(id);
var player = new PlayerInfo(id);
PlayerList.Add(player);
OnAddPlayer?.Invoke(id);
return player;
}
public static void RemovePlayer(uint id)

View File

@ -50,6 +50,7 @@ namespace QSB.Player.TransformSync
public override void Start()
{
base.Start();
QSBPlayerManager.AddPlayer(PlayerId);
Player.TransformSync = this;
}

View File

@ -28,6 +28,14 @@ namespace QSB.SaveSync.Events
public override void OnReceiveRemote(bool isHost, GameStateMessage message)
{
if (QSBSceneManager.CurrentScene != OWScene.TitleScreen)
{
DebugLog.ToConsole($"Error - Treid to handle GameStateEvent when not in TitleScreen!", OWML.Common.MessageType.Error);
return;
}
PlayerData.ResetGame();
var gameSave = StandaloneProfileManager.SharedInstance.currentProfileGameSave;
gameSave.loopCount = message.LoopCount;
gameSave.knownFrequencies = message.KnownFrequencies;

View File

@ -5,6 +5,7 @@ using QSB.Patches;
using QSB.Utility;
using QSB.WorldSync;
using System;
using QSB.ShipSync.TransformSync;
using UnityEngine;
namespace QSB.ShipSync.Patches
@ -206,7 +207,7 @@ namespace QSB.ShipSync.Patches
[HarmonyPrefix]
[HarmonyPatch(typeof(ShipDamageController), nameof(ShipDamageController.OnImpact))]
public static bool ShipDamageController_OnImpact()
=> ShipManager.Instance.HasAuthority;
=> ShipTransformSync.LocalInstance == null || ShipManager.Instance.HasAuthority;
[HarmonyPostfix]
[HarmonyPatch(typeof(ShipComponent), nameof(ShipComponent.RepairTick))]

View File

@ -1,4 +1,5 @@
using QSB.Player;
using OWML.Common;
using QSB.Player;
using QSB.SectorSync;
using QSB.SectorSync.WorldObjects;
using QSB.Utility;
@ -65,7 +66,7 @@ namespace QSB.Syncs.Sectored
}
else
{
DebugLog.ToConsole($"Warning - {LogName}'s initial sector was null.", OWML.Common.MessageType.Warning);
DebugLog.ToConsole($"Warning - {LogName}'s initial sector was null.", MessageType.Warning);
}
}
@ -75,7 +76,7 @@ namespace QSB.Syncs.Sectored
{
if (ReferenceSector != null && ReferenceSector.Transform != ReferenceTransform)
{
DebugLog.ToConsole($"Warning - {LogName} : ReferenceSector.Transform was different to ReferenceTransform. Correcting...", OWML.Common.MessageType.Warning);
DebugLog.ToConsole($"Warning - {LogName} : ReferenceSector.Transform was different to ReferenceTransform. Correcting...", MessageType.Warning);
SetReferenceTransform(ReferenceSector.Transform);
}
@ -97,7 +98,7 @@ namespace QSB.Syncs.Sectored
{
if (sector == null)
{
DebugLog.ToConsole($"Error - {PlayerId}.{GetType().Name} got sector of ID -1.", OWML.Common.MessageType.Error);
DebugLog.ToConsole($"Error - {LogName} got sector of ID -1. (From waiting slot.)", MessageType.Error);
base.Update();
return;
}
@ -112,15 +113,21 @@ namespace QSB.Syncs.Sectored
public override void SerializeTransform(QNetworkWriter writer, bool initialState)
{
if (!QSBPlayerManager.PlayerExists(PlayerId))
if (IsPlayerObject)
{
writer.Write(-1);
if (!QSBPlayerManager.PlayerExists(PlayerId))
{
writer.Write(-1);
return;
}
else if (!Player.IsReady)
{
writer.Write(-1);
return;
}
}
else if (!Player.IsReady)
{
writer.Write(-1);
}
else if (ReferenceSector != null)
if (ReferenceSector != null)
{
writer.Write(ReferenceSector.ObjectId);
}
@ -128,7 +135,7 @@ namespace QSB.Syncs.Sectored
{
if (_isInitialized)
{
DebugLog.ToConsole($"Warning - ReferenceSector of {PlayerId}.{GetType().Name} is null.", OWML.Common.MessageType.Warning);
DebugLog.ToConsole($"Warning - ReferenceSector of {LogName} is null.", MessageType.Warning);
}
writer.Write(-1);
@ -143,7 +150,6 @@ namespace QSB.Syncs.Sectored
sectorId = reader.ReadInt32();
if (initialState && sectorId != -1)
{
DebugLog.DebugWrite($"{LogName} set waiting sector id:{sectorId}");
_sectorIdWaitingSlot = sectorId;
}
@ -159,7 +165,7 @@ namespace QSB.Syncs.Sectored
{
if (sector == null)
{
DebugLog.ToConsole($"Error - {PlayerId}.{GetType().Name} got sector of ID -1.", OWML.Common.MessageType.Error);
DebugLog.ToConsole($"Error - {LogName} got sector of ID -1. (From deserializing transform.)", MessageType.Error);
return;
}
@ -178,7 +184,7 @@ namespace QSB.Syncs.Sectored
{
DebugLog.ToConsole($"Warning - Reference was null, but sector manager wasn't ready. " +
$"Transform:{ReferenceTransform == null}, Sector:{ReferenceSector == null}",
OWML.Common.MessageType.Warning);
MessageType.Warning);
}
DebugLog.DebugWrite($"{LogName} : Sector Manager not ready.");
@ -202,7 +208,7 @@ namespace QSB.Syncs.Sectored
}
else
{
DebugLog.ToConsole($"Error - No closest sector found to {PlayerId}.{GetType().Name}!", OWML.Common.MessageType.Error);
DebugLog.ToConsole($"Error - No closest sector found to {LogName}!", MessageType.Error);
return false;
}
}

View File

@ -13,7 +13,9 @@ namespace QSB.TornadoSync.TransformSync
{
public class OccasionalTransformSync : UnsectoredRigidbodySync
{
public override bool IsReady => WorldObjectManager.AllObjectsReady;
public override bool IsReady => WorldObjectManager.AllObjectsReady
&& _bodyIndex >= 0 && _bodyIndex < CenterOfTheUniverse.s_rigidbodies.Count
&& _refBodyIndex >= 0 && _refBodyIndex < CenterOfTheUniverse.s_rigidbodies.Count;
public override bool UseInterpolation => false;
public override bool IsPlayerObject => false;