diff --git a/QSB/ClientServerStateSync/ClientStateManager.cs b/QSB/ClientServerStateSync/ClientStateManager.cs index 5e7bee77..5abe30e1 100644 --- a/QSB/ClientServerStateSync/ClientStateManager.cs +++ b/QSB/ClientServerStateSync/ClientStateManager.cs @@ -27,12 +27,6 @@ namespace QSB.ClientServerStateSync private void OnDestroy() => QSBSceneManager.OnSceneLoaded -= OnSceneLoaded; - public void SendChangeClientStateMessage(ClientState newState) - { - ChangeClientState(newState); - new ClientStateMessage(newState).Send(); - } - public void ChangeClientState(ClientState newState) { if (PlayerTransformSync.LocalInstance == null || QSBPlayerManager.LocalPlayer.State == newState) @@ -143,7 +137,7 @@ namespace QSB.ClientServerStateSync } } - SendChangeClientStateMessage(newState); + new ClientStateMessage(newState).Send(); } public void OnDeath() @@ -151,7 +145,7 @@ namespace QSB.ClientServerStateSync var currentScene = QSBSceneManager.CurrentScene; if (currentScene == OWScene.SolarSystem) { - SendChangeClientStateMessage(ClientState.DeadInSolarSystem); + new ClientStateMessage(ClientState.DeadInSolarSystem).Send(); } else if (currentScene == OWScene.EyeOfTheUniverse) { @@ -170,7 +164,7 @@ namespace QSB.ClientServerStateSync if (currentScene == OWScene.SolarSystem) { DebugLog.DebugWrite($"RESPAWN!"); - SendChangeClientStateMessage(ClientState.AliveInSolarSystem); + new ClientStateMessage(ClientState.AliveInSolarSystem).Send(); } else { diff --git a/QSB/ClientServerStateSync/Messages/ClientStateMessage.cs b/QSB/ClientServerStateSync/Messages/ClientStateMessage.cs index d3f58043..7ca93108 100644 --- a/QSB/ClientServerStateSync/Messages/ClientStateMessage.cs +++ b/QSB/ClientServerStateSync/Messages/ClientStateMessage.cs @@ -5,6 +5,9 @@ using QSB.Utility; namespace QSB.ClientServerStateSync.Messages { + /// + /// sets the state both locally and remotely + /// internal class ClientStateMessage : QSBMessage { public ClientStateMessage(ClientState state) => Value = state; diff --git a/QSB/ClientServerStateSync/Messages/ServerStateMessage.cs b/QSB/ClientServerStateSync/Messages/ServerStateMessage.cs index 10e478fd..18192cf4 100644 --- a/QSB/ClientServerStateSync/Messages/ServerStateMessage.cs +++ b/QSB/ClientServerStateSync/Messages/ServerStateMessage.cs @@ -2,6 +2,9 @@ namespace QSB.ClientServerStateSync.Messages { + /// + /// sets the state both locally and remotely + /// internal class ServerStateMessage : QSBMessage { public ServerStateMessage(ServerState state) => Value = state; diff --git a/QSB/ClientServerStateSync/ServerStateManager.cs b/QSB/ClientServerStateSync/ServerStateManager.cs index b10e2439..f679a4da 100644 --- a/QSB/ClientServerStateSync/ServerStateManager.cs +++ b/QSB/ClientServerStateSync/ServerStateManager.cs @@ -42,12 +42,6 @@ namespace QSB.ClientServerStateSync GlobalMessenger.RemoveListener("TriggerSupernova", OnTriggerSupernova); } - public void SendChangeServerStateMessage(ServerState newState) - { - ChangeServerState(newState); - new ServerStateMessage(newState).Send(); - } - public void ChangeServerState(ServerState newState) { if (_currentState == newState) @@ -69,34 +63,34 @@ namespace QSB.ClientServerStateSync case OWScene.Credits_Fast: case OWScene.Credits_Final: case OWScene.PostCreditsScene: - SendChangeServerStateMessage(ServerState.Credits); + new ServerStateMessage(ServerState.Credits).Send(); break; case OWScene.TitleScreen: - SendChangeServerStateMessage(ServerState.NotLoaded); + new ServerStateMessage(ServerState.NotLoaded).Send(); break; case OWScene.SolarSystem: if (oldScene == OWScene.SolarSystem) { - SendChangeServerStateMessage(ServerState.WaitingForAllPlayersToReady); + new ServerStateMessage(ServerState.WaitingForAllPlayersToReady).Send(); } else { - SendChangeServerStateMessage(ServerState.InSolarSystem); + new ServerStateMessage(ServerState.InSolarSystem).Send(); } break; case OWScene.EyeOfTheUniverse: - SendChangeServerStateMessage(ServerState.WaitingForAllPlayersToReady); + new ServerStateMessage(ServerState.WaitingForAllPlayersToReady).Send(); break; case OWScene.None: case OWScene.Undefined: default: DebugLog.ToConsole($"Warning - newScene is {newScene}!", OWML.Common.MessageType.Warning); - SendChangeServerStateMessage(ServerState.NotLoaded); + new ServerStateMessage(ServerState.NotLoaded).Send(); break; } } @@ -105,7 +99,7 @@ namespace QSB.ClientServerStateSync { if (QSBSceneManager.CurrentScene == OWScene.SolarSystem) { - SendChangeServerStateMessage(ServerState.WaitingForAllPlayersToDie); + new ServerStateMessage(ServerState.WaitingForAllPlayersToDie).Send(); } } @@ -148,16 +142,16 @@ namespace QSB.ClientServerStateSync new StartLoopMessage().Send(); if (QSBSceneManager.CurrentScene == OWScene.SolarSystem) { - SendChangeServerStateMessage(ServerState.InSolarSystem); + new ServerStateMessage(ServerState.InSolarSystem).Send(); } else if (QSBSceneManager.CurrentScene == OWScene.EyeOfTheUniverse) { - SendChangeServerStateMessage(ServerState.InEye); + new ServerStateMessage(ServerState.InEye).Send(); } else { DebugLog.ToConsole($"Error - All players were ready in non-universe scene!?", OWML.Common.MessageType.Error); - SendChangeServerStateMessage(ServerState.NotLoaded); + new ServerStateMessage(ServerState.NotLoaded).Send(); } _blockNextCheck = true; diff --git a/QSB/DeathSync/Messages/EndLoopMessage.cs b/QSB/DeathSync/Messages/EndLoopMessage.cs index e987ab4c..01aa5fad 100644 --- a/QSB/DeathSync/Messages/EndLoopMessage.cs +++ b/QSB/DeathSync/Messages/EndLoopMessage.cs @@ -1,4 +1,5 @@ using QSB.ClientServerStateSync; +using QSB.ClientServerStateSync.Messages; using QSB.Messaging; using QSB.Patches; using QSB.Utility; @@ -23,7 +24,7 @@ namespace QSB.DeathSync.Messages Locator.GetDeathManager().KillPlayer(DeathType.TimeLoop); if (QSBCore.IsHost) { - ServerStateManager.Instance.SendChangeServerStateMessage(ServerState.WaitingForAllPlayersToDie); + new ServerStateMessage(ServerState.WaitingForAllPlayersToDie).Send(); } } } diff --git a/QSB/DeathSync/Messages/StartLoopMessage.cs b/QSB/DeathSync/Messages/StartLoopMessage.cs index 30f4c6ef..3449058f 100644 --- a/QSB/DeathSync/Messages/StartLoopMessage.cs +++ b/QSB/DeathSync/Messages/StartLoopMessage.cs @@ -1,5 +1,6 @@ using OWML.Common; using QSB.ClientServerStateSync; +using QSB.ClientServerStateSync.Messages; using QSB.Messaging; using QSB.Utility; @@ -14,16 +15,16 @@ namespace QSB.DeathSync.Messages DebugLog.DebugWrite($" ~~~ LOOP START ~~~"); if (QSBSceneManager.CurrentScene == OWScene.SolarSystem) { - ClientStateManager.Instance.SendChangeClientStateMessage(ClientState.AliveInSolarSystem); + new ClientStateMessage(ClientState.AliveInSolarSystem).Send(); } else if (QSBSceneManager.CurrentScene == OWScene.EyeOfTheUniverse) { - ClientStateManager.Instance.SendChangeClientStateMessage(ClientState.AliveInEye); + new ClientStateMessage(ClientState.AliveInEye).Send(); } else { DebugLog.ToConsole($"Error - Got StartLoop event when not in universe!", MessageType.Error); - ClientStateManager.Instance.SendChangeClientStateMessage(ClientState.NotLoaded); + new ClientStateMessage(ClientState.NotLoaded).Send(); } } } diff --git a/QSB/StatueSync/Messages/StartStatueMessage.cs b/QSB/StatueSync/Messages/StartStatueMessage.cs index d82a35b8..81ef4d04 100644 --- a/QSB/StatueSync/Messages/StartStatueMessage.cs +++ b/QSB/StatueSync/Messages/StartStatueMessage.cs @@ -1,5 +1,6 @@ using Mirror; using QSB.ClientServerStateSync; +using QSB.ClientServerStateSync.Messages; using QSB.Messaging; using QSB.WorldSync; using UnityEngine; @@ -41,7 +42,7 @@ namespace QSB.StatueSync.Messages { if (QSBCore.IsHost) { - ServerStateManager.Instance.SendChangeServerStateMessage(ServerState.InStatueCutscene); + new ServerStateMessage(ServerState.InStatueCutscene).Send(); } } @@ -49,7 +50,7 @@ namespace QSB.StatueSync.Messages { if (QSBCore.IsHost) { - ServerStateManager.Instance.SendChangeServerStateMessage(ServerState.InStatueCutscene); + new ServerStateMessage(ServerState.InStatueCutscene).Send(); } StatueManager.Instance.BeginSequence(PlayerPosition, PlayerRotation, CameraDegrees); diff --git a/QSB/TimeSync/WakeUpSync.cs b/QSB/TimeSync/WakeUpSync.cs index bf3b77ec..fb7ae83b 100644 --- a/QSB/TimeSync/WakeUpSync.cs +++ b/QSB/TimeSync/WakeUpSync.cs @@ -1,6 +1,7 @@ using Mirror; using OWML.Common; using QSB.ClientServerStateSync; +using QSB.ClientServerStateSync.Messages; using QSB.DeathSync; using QSB.Inputs; using QSB.Messaging; @@ -297,7 +298,7 @@ namespace QSB.TimeSync { //? DebugLog.ToConsole($"Warning - Server waiting for players to die, but players waiting for ready signal! Assume players correct.", MessageType.Warning); - ServerStateManager.Instance.SendChangeServerStateMessage(ServerState.WaitingForAllPlayersToReady); + new ServerStateMessage(ServerState.WaitingForAllPlayersToReady).Send(); } }