diff --git a/QSB/Animation/Player/AnimationSync.cs b/QSB/Animation/Player/AnimationSync.cs index 53204e38..986fd5c0 100644 --- a/QSB/Animation/Player/AnimationSync.cs +++ b/QSB/Animation/Player/AnimationSync.cs @@ -155,7 +155,7 @@ namespace QSB.Animation.Player public void SetSuitState(bool state) { - if (!Player.PlayerStates.IsReady) + if (!Player.IsReady) { return; } diff --git a/QSB/Animation/Player/Events/ChangeAnimTypeEvent.cs b/QSB/Animation/Player/Events/ChangeAnimTypeEvent.cs index d7ec029d..063ffb2e 100644 --- a/QSB/Animation/Player/Events/ChangeAnimTypeEvent.cs +++ b/QSB/Animation/Player/Events/ChangeAnimTypeEvent.cs @@ -22,7 +22,7 @@ namespace QSB.Animation.Player.Events public override void OnReceiveRemote(bool server, EnumMessage message) { - if (!QSBCore.WorldObjectsReady || !QSBPlayerManager.GetPlayer(message.AboutId).PlayerStates.IsReady) + if (!QSBCore.WorldObjectsReady || !QSBPlayerManager.GetPlayer(message.AboutId).IsReady) { return; } diff --git a/QSB/Animation/Player/Events/PlayerSuitEvent.cs b/QSB/Animation/Player/Events/PlayerSuitEvent.cs index 87f2dd1f..7848e515 100644 --- a/QSB/Animation/Player/Events/PlayerSuitEvent.cs +++ b/QSB/Animation/Player/Events/PlayerSuitEvent.cs @@ -32,9 +32,9 @@ namespace QSB.Animation.Player.Events public override void OnReceiveRemote(bool server, ToggleMessage message) { var player = QSBPlayerManager.GetPlayer(message.AboutId); - player.PlayerStates.SuitedUp = message.ToggleValue; + player.SuitedUp = message.ToggleValue; - if (!QSBCore.WorldObjectsReady || !player.PlayerStates.IsReady) + if (!QSBCore.WorldObjectsReady || !player.IsReady) { return; } @@ -46,7 +46,7 @@ namespace QSB.Animation.Player.Events public override void OnReceiveLocal(bool server, ToggleMessage message) { - QSBPlayerManager.LocalPlayer.PlayerStates.SuitedUp = message.ToggleValue; + QSBPlayerManager.LocalPlayer.SuitedUp = message.ToggleValue; var animator = QSBPlayerManager.LocalPlayer.AnimationSync; var type = message.ToggleValue ? AnimationType.PlayerSuited : AnimationType.PlayerUnsuited; animator.CurrentType = type; diff --git a/QSB/Events/EventNames.cs b/QSB/Events/EventNames.cs index 768576e6..5eb65a30 100644 --- a/QSB/Events/EventNames.cs +++ b/QSB/Events/EventNames.cs @@ -24,6 +24,7 @@ public static string ExitFlightConsole = "ExitFlightConsole"; public static string EnterShip = "EnterShip"; public static string ExitShip = "ExitShip"; + public static string LaunchCodes = "LearnLaunchCodes"; // Custom event names -- change if you want! These can be anything, as long as both // sides of the GlobalMessenger (fireevent and addlistener) reference the same thing. diff --git a/QSB/Events/QSBEventManager.cs b/QSB/Events/QSBEventManager.cs index 1336ee66..3431e35a 100644 --- a/QSB/Events/QSBEventManager.cs +++ b/QSB/Events/QSBEventManager.cs @@ -77,6 +77,7 @@ namespace QSB.Events new DebugEvent(), new SatelliteProjectorEvent(), new SatelliteProjectorSnapshotEvent(), + new LaunchCodesEvent(), // World Objects new ElevatorEvent(), new GeyserEvent(), diff --git a/QSB/Player/Events/LaunchCodesEvent.cs b/QSB/Player/Events/LaunchCodesEvent.cs new file mode 100644 index 00000000..d6547bc4 --- /dev/null +++ b/QSB/Player/Events/LaunchCodesEvent.cs @@ -0,0 +1,39 @@ +using QSB.Events; +using QSB.Messaging; + +namespace QSB.Player.Events +{ + internal class LaunchCodesEvent : QSBEvent + { + public override EventType Type => EventType.PlayerInformation; + + public override void SetupListener() => GlobalMessenger.AddListener(EventNames.LaunchCodes, Handler); + public override void CloseListener() => GlobalMessenger.RemoveListener(EventNames.LaunchCodes, Handler); + + private void Handler() => SendEvent(CreateMessage()); + + private PlayerMessage CreateMessage() => new PlayerMessage + { + AboutId = LocalPlayerId + }; + + public override void OnReceiveRemote(bool isHost, PlayerMessage message) + { + var flag = false; + if (!PlayerData._currentGameSave.PersistentConditionExists("LAUNCH_CODES_GIVEN")) + { + flag = true; + } + + else if (PlayerData._currentGameSave.GetPersistentCondition("LAUNCH_CODES_GIVEN")) + { + flag = true; + } + + if (flag) + { + PlayerData._currentGameSave.SetPersistentCondition("LAUNCH_CODES_GIVEN", true); + } + } + } +} diff --git a/QSB/Player/Events/PlayerInformationEvent.cs b/QSB/Player/Events/PlayerInformationEvent.cs index 89e0ba55..03fb8279 100644 --- a/QSB/Player/Events/PlayerInformationEvent.cs +++ b/QSB/Player/Events/PlayerInformationEvent.cs @@ -17,7 +17,13 @@ namespace QSB.Player.Events { AboutId = player.PlayerId, PlayerName = player.Name, - PlayerState = player.PlayerStates, + IsReady = player.IsReady, + FlashlightActive = player.FlashlightActive, + SuitedUp = player.SuitedUp, + ProbeLauncherEquipped = player.ProbeLauncherEquipped, + SignalscopeEquipped = player.SignalscopeEquipped, + TranslatorEquipped = player.TranslatorEquipped, + ProbeActive = player.ProbeActive, ClientState = player.State }; diff --git a/QSB/Player/Events/PlayerInformationMessage.cs b/QSB/Player/Events/PlayerInformationMessage.cs index 851a7b31..a088a33f 100644 --- a/QSB/Player/Events/PlayerInformationMessage.cs +++ b/QSB/Player/Events/PlayerInformationMessage.cs @@ -7,23 +7,26 @@ namespace QSB.Player.Events public class PlayerInformationMessage : PlayerMessage { public string PlayerName { get; set; } - public PlayerState PlayerState { get; set; } + public bool IsReady { get; set; } + public bool FlashlightActive { get; set; } + public bool SuitedUp { get; set; } + public bool ProbeLauncherEquipped { get; set; } + public bool SignalscopeEquipped { get; set; } + public bool TranslatorEquipped { get; set; } + public bool ProbeActive { get; set; } public ClientState ClientState { get; set; } public override void Deserialize(QNetworkReader reader) { base.Deserialize(reader); PlayerName = reader.ReadString(); - PlayerState = new PlayerState - { - IsReady = reader.ReadBoolean(), - FlashlightActive = reader.ReadBoolean(), - SuitedUp = reader.ReadBoolean(), - ProbeLauncherEquipped = reader.ReadBoolean(), - SignalscopeEquipped = reader.ReadBoolean(), - TranslatorEquipped = reader.ReadBoolean(), - ProbeActive = reader.ReadBoolean() - }; + IsReady = reader.ReadBoolean(); + FlashlightActive = reader.ReadBoolean(); + SuitedUp = reader.ReadBoolean(); + ProbeLauncherEquipped = reader.ReadBoolean(); + SignalscopeEquipped = reader.ReadBoolean(); + TranslatorEquipped = reader.ReadBoolean(); + ProbeActive = reader.ReadBoolean(); ClientState = (ClientState)reader.ReadInt32(); } @@ -31,13 +34,13 @@ namespace QSB.Player.Events { base.Serialize(writer); writer.Write(PlayerName); - writer.Write(PlayerState.IsReady); - writer.Write(PlayerState.FlashlightActive); - writer.Write(PlayerState.SuitedUp); - writer.Write(PlayerState.ProbeLauncherEquipped); - writer.Write(PlayerState.SignalscopeEquipped); - writer.Write(PlayerState.TranslatorEquipped); - writer.Write(PlayerState.ProbeActive); + writer.Write(IsReady); + writer.Write(FlashlightActive); + writer.Write(SuitedUp); + writer.Write(ProbeLauncherEquipped); + writer.Write(SignalscopeEquipped); + writer.Write(TranslatorEquipped); + writer.Write(ProbeActive); writer.Write((int)ClientState); } } diff --git a/QSB/Player/Events/PlayerJoinEvent.cs b/QSB/Player/Events/PlayerJoinEvent.cs index 7a3f0149..58384635 100644 --- a/QSB/Player/Events/PlayerJoinEvent.cs +++ b/QSB/Player/Events/PlayerJoinEvent.cs @@ -70,7 +70,7 @@ namespace QSB.Player.Events if (QSBSceneManager.IsInUniverse) { - QSBPlayerManager.LocalPlayer.PlayerStates.IsReady = true; + QSBPlayerManager.LocalPlayer.IsReady = true; QSBEventManager.FireEvent(EventNames.QSBPlayerReady, true); } } diff --git a/QSB/Player/Events/PlayerReadyEvent.cs b/QSB/Player/Events/PlayerReadyEvent.cs index 88b147b9..018d5b96 100644 --- a/QSB/Player/Events/PlayerReadyEvent.cs +++ b/QSB/Player/Events/PlayerReadyEvent.cs @@ -35,7 +35,7 @@ namespace QSB.Player.Events private static void HandleServer(ToggleMessage message) { DebugLog.DebugWrite($"[SERVER] Get ready event from {message.FromId}", MessageType.Success); - QSBPlayerManager.GetPlayer(message.AboutId).PlayerStates.IsReady = message.ToggleValue; + QSBPlayerManager.GetPlayer(message.AboutId).IsReady = message.ToggleValue; QSBEventManager.FireEvent(EventNames.QSBPlayerInformation); } diff --git a/QSB/Player/Patches/PlayerPatches.cs b/QSB/Player/Patches/PlayerPatches.cs index 383ebaba..c4e44fec 100644 --- a/QSB/Player/Patches/PlayerPatches.cs +++ b/QSB/Player/Patches/PlayerPatches.cs @@ -21,6 +21,6 @@ namespace QSB.Player.Patches [HarmonyPrefix] [HarmonyPatch(typeof(PauseMenuManager), nameof(PauseMenuManager.OnExitToMainMenu))] public static void PauseMenuManager_OnExitToMainMenu() - => QSBPlayerManager.LocalPlayer.PlayerStates.IsReady = false; + => QSBPlayerManager.LocalPlayer.IsReady = false; } } diff --git a/QSB/Player/PlayerHUDMarker.cs b/QSB/Player/PlayerHUDMarker.cs index b0818d82..30f4d5a1 100644 --- a/QSB/Player/PlayerHUDMarker.cs +++ b/QSB/Player/PlayerHUDMarker.cs @@ -34,7 +34,7 @@ namespace QSB.Player Initialize(); } - if (!_isReady || !_player.PlayerStates.IsReady) + if (!_isReady || !_player.IsReady) { return; } diff --git a/QSB/Player/PlayerInfo.cs b/QSB/Player/PlayerInfo.cs index 584cd0de..f279ef4b 100644 --- a/QSB/Player/PlayerInfo.cs +++ b/QSB/Player/PlayerInfo.cs @@ -22,7 +22,6 @@ namespace QSB.Player public uint PlayerId { get; } public string Name { get; set; } public PlayerHUDMarker HudMarker { get; set; } - public PlayerState PlayerStates { get; set; } = new PlayerState(); public PlayerTransformSync TransformSync { get; set; } // Body Objects @@ -30,10 +29,11 @@ namespace QSB.Player { get { - if (_camera == null && PlayerStates.IsReady) + if (_camera == null && IsReady) { DebugLog.ToConsole($"Warning - {PlayerId}.Camera is null!", MessageType.Warning); } + return _camera; } set @@ -42,6 +42,7 @@ namespace QSB.Player { DebugLog.ToConsole($"Warning - Setting {PlayerId}.Camera to null.", MessageType.Warning); } + _camera = value; } } @@ -52,7 +53,7 @@ namespace QSB.Player { get { - if (_body == null && PlayerStates.IsReady) + if (_body == null && IsReady) { DebugLog.ToConsole($"Warning - {PlayerId}.Body is null!", MessageType.Warning); } @@ -114,11 +115,18 @@ namespace QSB.Player public JetpackAccelerationSync JetpackAcceleration { get; set; } // Misc + public bool IsReady { get; set; } public bool IsInMoon; // MOVE : move into PlayerStates? public bool IsInShrine; // MOVE : move into PlayerStates? public IQSBQuantumObject EntangledObject; public bool IsDead { get; set; } public ClientState State { get; set; } + public bool FlashlightActive { get; set; } + public bool SuitedUp { get; set; } + public bool ProbeLauncherEquipped { get; set; } + public bool SignalscopeEquipped { get; set; } + public bool TranslatorEquipped { get; set; } + public bool ProbeActive { get; set; } // Local only public PlayerProbeLauncher LocalProbeLauncher @@ -190,12 +198,12 @@ namespace QSB.Player return; } - FlashLight?.UpdateState(PlayerStates.FlashlightActive); - Translator?.ChangeEquipState(PlayerStates.TranslatorEquipped); - ProbeLauncher?.ChangeEquipState(PlayerStates.ProbeLauncherEquipped); - Signalscope?.ChangeEquipState(PlayerStates.SignalscopeEquipped); + FlashLight?.UpdateState(FlashlightActive); + Translator?.ChangeEquipState(TranslatorEquipped); + ProbeLauncher?.ChangeEquipState(ProbeLauncherEquipped); + Signalscope?.ChangeEquipState(SignalscopeEquipped); QSBCore.UnityEvents.RunWhen(() => QSBPlayerManager.GetSyncObject(PlayerId) != null, - () => QSBPlayerManager.GetSyncObject(PlayerId).SetSuitState(PlayerStates.SuitedUp)); + () => QSBPlayerManager.GetSyncObject(PlayerId).SetSuitState(SuitedUp)); } private QSBTool GetToolByType(ToolType type) => CameraBody?.GetComponentsInChildren() diff --git a/QSB/Player/PlayerState.cs b/QSB/Player/PlayerState.cs deleted file mode 100644 index 0d0efb4a..00000000 --- a/QSB/Player/PlayerState.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace QSB.Player -{ - public class PlayerState - { - public bool IsReady { get; set; } - - public bool FlashlightActive { get; set; } - public bool SuitedUp { get; set; } - public bool ProbeLauncherEquipped { get; set; } - public bool SignalscopeEquipped { get; set; } - public bool TranslatorEquipped { get; set; } - public bool ProbeActive { get; set; } - } -} diff --git a/QSB/Player/QSBPlayerManager.cs b/QSB/Player/QSBPlayerManager.cs index 7a5efe55..12997a5c 100644 --- a/QSB/Player/QSBPlayerManager.cs +++ b/QSB/Player/QSBPlayerManager.cs @@ -82,8 +82,14 @@ namespace QSB.Player { var player = GetPlayer(message.AboutId); player.Name = message.PlayerName; - player.PlayerStates = message.PlayerState; - if (LocalPlayer.PlayerStates.IsReady) + player.IsReady = message.IsReady; + player.FlashlightActive = message.FlashlightActive; + player.SuitedUp = message.SuitedUp; + player.ProbeLauncherEquipped = message.ProbeLauncherEquipped; + player.SignalscopeEquipped = message.SignalscopeEquipped; + player.TranslatorEquipped = message.TranslatorEquipped; + player.ProbeActive = message.ProbeActive; + if (LocalPlayer.IsReady) { player.UpdateStateObjects(); } @@ -172,7 +178,7 @@ namespace QSB.Player return null; } - return playerList.Where(x => x.PlayerStates.IsReady).OrderBy(x => Vector3.Distance(x.Body.transform.position, worldPoint)).FirstOrDefault(); + return playerList.Where(x => x.IsReady).OrderBy(x => Vector3.Distance(x.Body.transform.position, worldPoint)).FirstOrDefault(); } public static IEnumerable> GetPlayerCarryItems() diff --git a/QSB/Player/TransformSync/PlayerTransformSync.cs b/QSB/Player/TransformSync/PlayerTransformSync.cs index 6dbd20dc..df277665 100644 --- a/QSB/Player/TransformSync/PlayerTransformSync.cs +++ b/QSB/Player/TransformSync/PlayerTransformSync.cs @@ -60,12 +60,12 @@ namespace QSB.Player.TransformSync if (isInUniverse) { - Player.PlayerStates.IsReady = true; + Player.IsReady = true; QSBEventManager.FireEvent(EventNames.QSBPlayerReady, true); } else { - Player.PlayerStates.IsReady = false; + Player.IsReady = false; QSBEventManager.FireEvent(EventNames.QSBPlayerReady, false); } diff --git a/QSB/QSB.csproj b/QSB/QSB.csproj index 88b5d5b5..ee5ee864 100644 --- a/QSB/QSB.csproj +++ b/QSB/QSB.csproj @@ -88,6 +88,7 @@ + @@ -147,7 +148,6 @@ - diff --git a/QSB/StatueSync/Events/StartStatueEvent.cs b/QSB/StatueSync/Events/StartStatueEvent.cs index 75238b05..0d1ee18e 100644 --- a/QSB/StatueSync/Events/StartStatueEvent.cs +++ b/QSB/StatueSync/Events/StartStatueEvent.cs @@ -1,5 +1,6 @@ using QSB.ClientServerStateSync; using QSB.Events; +using QSB.Utility; using UnityEngine; namespace QSB.StatueSync.Events @@ -27,6 +28,8 @@ namespace QSB.StatueSync.Events public override void OnReceiveLocal(bool server, StartStatueMessage message) { + DebugLog.DebugWrite($"OnReceiveLocal StartStatueEvent"); + if (!QSBCore.IsHost) { return; @@ -36,6 +39,9 @@ namespace QSB.StatueSync.Events } public override void OnReceiveRemote(bool server, StartStatueMessage message) - => StatueManager.Instance.BeginSequence(message.PlayerPosition, message.PlayerRotation, message.CameraDegrees); + { + DebugLog.DebugWrite($"OnReceiveRemote StartStatueEvent"); + StatueManager.Instance.BeginSequence(message.PlayerPosition, message.PlayerRotation, message.CameraDegrees); + } } } diff --git a/QSB/StatueSync/StatueManager.cs b/QSB/StatueSync/StatueManager.cs index c19718c4..207f68e4 100644 --- a/QSB/StatueSync/StatueManager.cs +++ b/QSB/StatueSync/StatueManager.cs @@ -1,4 +1,5 @@ using QSB.Player; +using QSB.Utility; using System.Collections; using UnityEngine; @@ -11,6 +12,7 @@ namespace QSB.StatueSync private void Awake() { + DebugLog.DebugWrite($"Awake"); Instance = this; QSBSceneManager.OnUniverseSceneLoaded += (OWScene oldScene, OWScene newScene) => QSBPlayerManager.ShowAllPlayers(); } @@ -19,10 +21,14 @@ namespace QSB.StatueSync => QSBSceneManager.OnUniverseSceneLoaded -= (OWScene oldScene, OWScene newScene) => QSBPlayerManager.ShowAllPlayers(); public void BeginSequence(Vector3 position, Quaternion rotation, float cameraDegrees) - => StartCoroutine(BeginRemoteUplinkSequence(position, rotation, cameraDegrees)); + { + DebugLog.DebugWrite($"Begin Sequence"); + StartCoroutine(BeginRemoteUplinkSequence(position, rotation, cameraDegrees)); + } private IEnumerator BeginRemoteUplinkSequence(Vector3 position, Quaternion rotation, float cameraDegrees) { + DebugLog.DebugWrite($"Begin Remote Uplink Sequence"); HasStartedStatueLocally = true; var cameraEffectController = Locator.GetPlayerCamera().GetComponent(); cameraEffectController.CloseEyes(0.5f); diff --git a/QSB/Syncs/Sectored/BaseSectoredSync.cs b/QSB/Syncs/Sectored/BaseSectoredSync.cs index 031666b9..846d0804 100644 --- a/QSB/Syncs/Sectored/BaseSectoredSync.cs +++ b/QSB/Syncs/Sectored/BaseSectoredSync.cs @@ -121,7 +121,7 @@ namespace QSB.Syncs.Sectored { writer.Write(-1); } - else if (!Player.PlayerStates.IsReady) + else if (!Player.IsReady) { writer.Write(-1); } diff --git a/QSB/Syncs/SyncBase.cs b/QSB/Syncs/SyncBase.cs index b991ea2f..753c0b1b 100644 --- a/QSB/Syncs/SyncBase.cs +++ b/QSB/Syncs/SyncBase.cs @@ -73,7 +73,7 @@ namespace QSB.Syncs public PlayerInfo Player => QSBPlayerManager.GetPlayer(PlayerId); private bool _baseIsReady => QSBPlayerManager.PlayerExists(PlayerId) && Player != null - && Player.PlayerStates.IsReady + && Player.IsReady && NetId.Value != uint.MaxValue && NetId.Value != 0U && WorldObjectManager.AllReady; diff --git a/QSB/TimeSync/Patches/TimePatches.cs b/QSB/TimeSync/Patches/TimePatches.cs index 7b43dd11..4db5bc36 100644 --- a/QSB/TimeSync/Patches/TimePatches.cs +++ b/QSB/TimeSync/Patches/TimePatches.cs @@ -1,5 +1,6 @@ using HarmonyLib; using QSB.Patches; +using QSB.Utility; namespace QSB.TimeSync.Patches { @@ -11,8 +12,10 @@ namespace QSB.TimeSync.Patches [HarmonyPrefix] [HarmonyPatch(typeof(PlayerCameraEffectController), nameof(PlayerCameraEffectController.OnStartOfTimeLoop))] public static bool PlayerCameraEffectController_OnStartOfTimeLoop() - => false; - + { + DebugLog.DebugWrite($"OnStartOfTimeLoop"); + return false; + } [HarmonyPrefix] [HarmonyPatch(typeof(OWTime), nameof(OWTime.Pause))] public static bool StopPausing() diff --git a/QSB/Tools/FlashlightTool/Events/PlayerFlashlightEvent.cs b/QSB/Tools/FlashlightTool/Events/PlayerFlashlightEvent.cs index 8865a744..0d405bb2 100644 --- a/QSB/Tools/FlashlightTool/Events/PlayerFlashlightEvent.cs +++ b/QSB/Tools/FlashlightTool/Events/PlayerFlashlightEvent.cs @@ -32,11 +32,11 @@ namespace QSB.Tools.FlashlightTool.Events public override void OnReceiveRemote(bool server, ToggleMessage message) { var player = QSBPlayerManager.GetPlayer(message.AboutId); - player.PlayerStates.FlashlightActive = message.ToggleValue; + player.FlashlightActive = message.ToggleValue; player.FlashLight?.UpdateState(message.ToggleValue); } public override void OnReceiveLocal(bool server, ToggleMessage message) => - QSBPlayerManager.LocalPlayer.PlayerStates.FlashlightActive = message.ToggleValue; + QSBPlayerManager.LocalPlayer.FlashlightActive = message.ToggleValue; } } \ No newline at end of file diff --git a/QSB/Tools/ProbeLauncherTool/Events/EquipProbeLauncherEvent.cs b/QSB/Tools/ProbeLauncherTool/Events/EquipProbeLauncherEvent.cs index 378b60e3..1660a705 100644 --- a/QSB/Tools/ProbeLauncherTool/Events/EquipProbeLauncherEvent.cs +++ b/QSB/Tools/ProbeLauncherTool/Events/EquipProbeLauncherEvent.cs @@ -66,11 +66,11 @@ namespace QSB.Tools.ProbeLauncherTool.Events public override void OnReceiveRemote(bool server, ToggleMessage message) { var player = QSBPlayerManager.GetPlayer(message.AboutId); - player.PlayerStates.ProbeLauncherEquipped = message.ToggleValue; + player.ProbeLauncherEquipped = message.ToggleValue; player.ProbeLauncher?.ChangeEquipState(message.ToggleValue); } public override void OnReceiveLocal(bool server, ToggleMessage message) => - QSBPlayerManager.LocalPlayer.PlayerStates.ProbeLauncherEquipped = message.ToggleValue; + QSBPlayerManager.LocalPlayer.ProbeLauncherEquipped = message.ToggleValue; } } \ No newline at end of file diff --git a/QSB/Tools/ProbeTool/Events/PlayerProbeEvent.cs b/QSB/Tools/ProbeTool/Events/PlayerProbeEvent.cs index c63f9dfc..f40c6f00 100644 --- a/QSB/Tools/ProbeTool/Events/PlayerProbeEvent.cs +++ b/QSB/Tools/ProbeTool/Events/PlayerProbeEvent.cs @@ -25,7 +25,7 @@ namespace QSB.Tools.ProbeTool.Events public override void OnReceiveRemote(bool server, EnumMessage message) { var player = QSBPlayerManager.GetPlayer(message.AboutId); - if (!player.PlayerStates.IsReady || player.Probe == null) + if (!player.IsReady || player.Probe == null) { return; } diff --git a/QSB/Tools/ProbeTool/Events/ProbeStartRetrieveEvent.cs b/QSB/Tools/ProbeTool/Events/ProbeStartRetrieveEvent.cs index b0c1cdf8..df98cbcb 100644 --- a/QSB/Tools/ProbeTool/Events/ProbeStartRetrieveEvent.cs +++ b/QSB/Tools/ProbeTool/Events/ProbeStartRetrieveEvent.cs @@ -25,7 +25,7 @@ namespace QSB.Tools.ProbeTool.Events public override void OnReceiveRemote(bool server, FloatMessage message) { var player = QSBPlayerManager.GetPlayer(message.AboutId); - if (!player.PlayerStates.IsReady || player.Probe == null) + if (!player.IsReady || player.Probe == null) { return; } diff --git a/QSB/Tools/SignalscopeTool/Events/PlayerSignalscopeEvent.cs b/QSB/Tools/SignalscopeTool/Events/PlayerSignalscopeEvent.cs index 1463010f..94ce4516 100644 --- a/QSB/Tools/SignalscopeTool/Events/PlayerSignalscopeEvent.cs +++ b/QSB/Tools/SignalscopeTool/Events/PlayerSignalscopeEvent.cs @@ -32,11 +32,11 @@ namespace QSB.Tools.SignalscopeTool.Events public override void OnReceiveRemote(bool server, ToggleMessage message) { var player = QSBPlayerManager.GetPlayer(message.AboutId); - player.PlayerStates.SignalscopeEquipped = message.ToggleValue; + player.SignalscopeEquipped = message.ToggleValue; player.Signalscope?.ChangeEquipState(message.ToggleValue); } public override void OnReceiveLocal(bool server, ToggleMessage message) => - QSBPlayerManager.LocalPlayer.PlayerStates.SignalscopeEquipped = message.ToggleValue; + QSBPlayerManager.LocalPlayer.SignalscopeEquipped = message.ToggleValue; } } \ No newline at end of file diff --git a/QSB/Tools/TranslatorTool/Events/PlayerTranslatorEvent.cs b/QSB/Tools/TranslatorTool/Events/PlayerTranslatorEvent.cs index 82570126..d51398c1 100644 --- a/QSB/Tools/TranslatorTool/Events/PlayerTranslatorEvent.cs +++ b/QSB/Tools/TranslatorTool/Events/PlayerTranslatorEvent.cs @@ -32,11 +32,11 @@ namespace QSB.Tools.TranslatorTool.Events public override void OnReceiveRemote(bool server, ToggleMessage message) { var player = QSBPlayerManager.GetPlayer(message.AboutId); - player.PlayerStates.TranslatorEquipped = message.ToggleValue; + player.TranslatorEquipped = message.ToggleValue; player.Translator?.ChangeEquipState(message.ToggleValue); } public override void OnReceiveLocal(bool server, ToggleMessage message) => - QSBPlayerManager.LocalPlayer.PlayerStates.TranslatorEquipped = message.ToggleValue; + QSBPlayerManager.LocalPlayer.TranslatorEquipped = message.ToggleValue; } } \ No newline at end of file diff --git a/QSB/Utility/DebugGUI.cs b/QSB/Utility/DebugGUI.cs index e5d4e212..65b78a50 100644 --- a/QSB/Utility/DebugGUI.cs +++ b/QSB/Utility/DebugGUI.cs @@ -3,6 +3,9 @@ using QSB.ClientServerStateSync; using QSB.OrbSync.TransformSync; using QSB.Player; using QSB.QuantumSync; +using QSB.ShipSync; +using QSB.ShipSync.TransformSync; +using QSB.ShipSync.WorldObjects; using QSB.Syncs; using QSB.TimeSync; using QSB.WorldSync; @@ -96,8 +99,11 @@ namespace QSB.Utility { WriteLine(1, $"Reason : NULL"); } + WriteLine(1, $"Time Difference : {WakeUpSync.LocalInstance.GetTimeDifference()}"); WriteLine(1, $"Timescale : {OWTime.GetTimeScale()}"); + WriteLine(1, $"Time Remaining : {Mathf.Floor(TimeLoop.GetSecondsRemaining() / 60f)}:{Mathf.Round(TimeLoop.GetSecondsRemaining() % 60f * 100f / 100f)}"); + WriteLine(1, $"Loop Count : {TimeLoop.GetLoopCount()}"); } #endregion @@ -110,35 +116,56 @@ namespace QSB.Utility WriteLine(2, $"State : {player.State}"); WriteLine(2, $"Dead : {player.IsDead}"); WriteLine(2, $"Visible : {player.Visible}"); + WriteLine(2, $"Ready : {player.IsReady}"); - if (player.PlayerStates.IsReady && QSBCore.WorldObjectsReady) + if (player.IsReady && QSBCore.WorldObjectsReady) { var networkTransform = player.TransformSync; var referenceSector = networkTransform.ReferenceSector; var referenceTransform = networkTransform.ReferenceTransform; var parent = networkTransform.AttachedObject?.transform.parent; - var intermediary = networkTransform.GetValue("_intermediaryTransform"); - var interTransform = intermediary.GetReferenceTransform(); - WriteLine(2, $" - L.Pos : {networkTransform.transform.localPosition}"); WriteLine(2, $" - Ref. Sector : {(referenceSector == null ? "NULL" : referenceSector.Name)}"); WriteLine(2, $" - Ref. Transform : {(referenceTransform == null ? "NULL" : referenceTransform.name)}"); - WriteLine(2, $" - Inter. Ref. Transform : {(interTransform == null ? "NULL" : interTransform.name)}"); WriteLine(2, $" - Parent : {(parent == null ? "NULL" : parent.name)}"); - - /* - var probeSync = SyncBase.GetPlayers(player); - if (probeSync != default) - { - var probeSector = probeSync.ReferenceSector; - GUI.Label(new Rect(420, offset2, 400f, 20f), $" - Probe Sector : {(probeSector == null ? "NULL" : probeSector.Name)}", guiStyle); - offset2 += _debugLineSpacing; - } - */ } } #endregion + #region Column3 - Ship data + + WriteLine(3, $"Current Flyer : {ShipManager.Instance.CurrentFlyer}"); + if (ShipTransformSync.LocalInstance != null) + { + var instance = ShipTransformSync.LocalInstance; + if (QSBCore.IsHost) + { + WriteLine(3, $"Current Owner : {instance.NetIdentity.ClientAuthorityOwner.GetPlayerId()}"); + } + var sector = instance.ReferenceSector; + WriteLine(3, $"Ref. Sector : {(sector != null ? sector.Name : "NULL")}"); + var transform = instance.ReferenceTransform; + WriteLine(3, $"Ref. Transform : {(transform != null ? transform.name : "NULL")}"); + } + else + { + WriteLine(3, $"ShipTransformSync.LocalInstance is null."); + } + + WriteLine(3, $"QSBShipComponent"); + foreach (var component in QSBWorldSync.GetWorldObjects()) + { + WriteLine(3, $"- {component.AttachedObject.name} RepairFraction:{component.AttachedObject._repairFraction}"); + } + + WriteLine(3, $"QSBShipHull"); + foreach (var hull in QSBWorldSync.GetWorldObjects()) + { + WriteLine(3, $"- {hull.AttachedObject.name}, Integrity:{hull.AttachedObject.integrity}"); + } + #endregion + + #region Column4 - Quantum Object Possesion foreach (var player in QSBPlayerManager.PlayerList) { WriteLine(4, $"- {player.PlayerId}.{player.Name}"); @@ -151,6 +178,7 @@ namespace QSB.Utility WriteLine(4, $"{qsbObj.Name} ({qsbObj.ObjectId})"); } } + #endregion } } } \ No newline at end of file diff --git a/QSB/WorldSync/WorldObjectManager.cs b/QSB/WorldSync/WorldObjectManager.cs index 8bb38da7..1c157630 100644 --- a/QSB/WorldSync/WorldObjectManager.cs +++ b/QSB/WorldSync/WorldObjectManager.cs @@ -44,13 +44,13 @@ namespace QSB.WorldSync return; } - if (QSBPlayerManager.LocalPlayer.PlayerStates.IsReady) + if (QSBPlayerManager.LocalPlayer.IsReady) { DoRebuild(scene); return; } - QSBCore.UnityEvents.RunWhen(() => QSBPlayerManager.LocalPlayer.PlayerStates.IsReady, () => DoRebuild(scene)); + QSBCore.UnityEvents.RunWhen(() => QSBPlayerManager.LocalPlayer.IsReady, () => DoRebuild(scene)); } private static void DoRebuild(OWScene scene)