From 828aeac36134722f07bece5bc8e127bfef85cd62 Mon Sep 17 00:00:00 2001 From: Mister_Nebula <41904486+misternebula@users.noreply.github.com> Date: Thu, 18 Aug 2022 18:41:36 +0100 Subject: [PATCH 01/17] GDK patch --- QSB/SaveSync/Patches/GdkPatches.cs | 37 ++++++++++++++++++++++++ QSB/SaveSync/QSBMSStoreProfileManager.cs | 20 +++++++------ 2 files changed, 48 insertions(+), 9 deletions(-) create mode 100644 QSB/SaveSync/Patches/GdkPatches.cs diff --git a/QSB/SaveSync/Patches/GdkPatches.cs b/QSB/SaveSync/Patches/GdkPatches.cs new file mode 100644 index 000000000..f134f2a64 --- /dev/null +++ b/QSB/SaveSync/Patches/GdkPatches.cs @@ -0,0 +1,37 @@ +using HarmonyLib; +using Microsoft.Xbox; +using QSB.Patches; +using QSB.Utility; +using System.Collections.Generic; +using UnityEngine; + +namespace QSB.SaveSync.Patches; + +[HarmonyPatch(typeof(Gdk))] +internal class GdkPatches : QSBPatch +{ + public override QSBPatchTypes Type => QSBPatchTypes.OnModStart; + public override GameVendor PatchVendor => GameVendor.Gamepass; + + [HarmonyPrefix] + [HarmonyPatch("QueryBlobsCompleted")] + public static bool QueryBlobsCompleted(int hresult, Dictionary blobs) + { + if (!Gdk.Succeeded(hresult, "Query blobs")) + { + DebugLog.DebugWrite("[GDK] Query blobs failed!"); + return false; + } + + Debug.Log(string.Format("[GDK] Save system setup complete. Blobs returned: {0}", blobs.Count)); + foreach (var keyValuePair in blobs) + { + DebugLog.DebugWrite(keyValuePair.Key); + } + + QSBMSStoreProfileManager.SharedInstance.InvokeProfileSignInComplete(); + QSBMSStoreProfileManager.SharedInstance.InvokeSaveSetupComplete(); + SpinnerUI.Hide(); + return false; + } +} diff --git a/QSB/SaveSync/QSBMSStoreProfileManager.cs b/QSB/SaveSync/QSBMSStoreProfileManager.cs index 3780b4d74..bfd15dae5 100644 --- a/QSB/SaveSync/QSBMSStoreProfileManager.cs +++ b/QSB/SaveSync/QSBMSStoreProfileManager.cs @@ -1,5 +1,6 @@ using Microsoft.Xbox; using Newtonsoft.Json; +using QSB.Utility; using System; using System.IO; using System.Runtime.Serialization; @@ -135,7 +136,7 @@ public void InitializeForEditor() public void SaveGame(GameSave gameSave, SettingsSave settSave, GraphicSettings gfxSettings, string inputJSON) { - Debug.Log("MSStoreProfileManager.SaveGame"); + DebugLog.DebugWrite("MSStoreProfileManager.SaveGame"); if (isBusyWithFileOps || LoadManager.IsBusy()) { _pendingGameSave = gameSave; @@ -215,13 +216,14 @@ public void SaveGame(GameSave gameSave, SettingsSave settSave, GraphicSettings g private void LoadGame(string blobName) { + DebugLog.DebugWrite($"LoadGame blobName:{blobName}"); _fileOpsBusyLocks++; Gdk.Helpers.LoadSaveData(blobName); } private void WriteSaveToStorage(QSBX1SaveData saveData, string blobName) { - Debug.Log("Saving to storage: " + blobName); + DebugLog.DebugWrite("Saving to storage: " + blobName); _fileOpsBusyLocks++; var memoryStream = new MemoryStream(); using (JsonWriter jsonWriter = new JsonTextWriter(new StreamWriter(memoryStream))) @@ -248,19 +250,19 @@ public void PerformPendingSaveOperation() private void OnGameSaveComplete(object sender, string blobName) { _fileOpsBusyLocks--; - Debug.Log("[GDK] save to blob " + blobName + " complete"); + DebugLog.DebugWrite("[GDK] save to blob " + blobName + " complete"); } private void OnGameSaveFailed(object sender, string blobName) { _fileOpsBusyLocks--; - Debug.Log("[GDK] save to blob " + blobName + " failed"); + DebugLog.DebugWrite("[GDK] save to blob " + blobName + " failed"); } private void OnGameSaveLoaded(object sender, string blobName, GameSaveLoadedArgs saveData) { _fileOpsBusyLocks--; - Debug.Log("[GDK] save file load complete! blob name: " + blobName); + DebugLog.DebugWrite("[GDK] save file load complete! blob name: " + blobName); var memoryStream = new MemoryStream(saveData.Data); memoryStream.Seek(0L, SeekOrigin.Begin); using (var jsonTextReader = new JsonTextReader(new StreamReader(memoryStream))) @@ -272,14 +274,14 @@ private void OnGameSaveLoaded(object sender, string blobName, GameSaveLoadedArgs { if (x1SaveData.gameSave == null) { - Debug.Log("[GDK] tempSaveData.gameSave is null (oh no)"); + DebugLog.DebugWrite("[GDK] tempSaveData.gameSave is null (oh no)"); } _saveData.gameSave = x1SaveData.gameSave ?? new GameSave(); } else { - Debug.Log("[GDK] tempSaveData is null (oh no)"); + DebugLog.DebugWrite("[GDK] tempSaveData is null (oh no)"); _saveData.gameSave = new GameSave(); } } @@ -298,8 +300,8 @@ private void OnGameSaveLoaded(object sender, string blobName, GameSaveLoadedArgs _saveData.inputActionsJson = ((InputManager)OWInput.SharedInputManager).commandManager.DefaultInputActions.ToJson(); } - Debug.Log(string.Format("after settings load, _saveData.gameSave is null: {0}", _saveData.gameSave == null)); - Debug.Log(string.Format("_saveData loopCount: {0}", _saveData.gameSave.loopCount)); + DebugLog.DebugWrite(string.Format("after settings load, _saveData.gameSave is null: {0}", _saveData.gameSave == null)); + DebugLog.DebugWrite(string.Format("_saveData loopCount: {0}", _saveData.gameSave.loopCount)); } } From 7d9e086eb8da1d05609a9a2898f543676203f131 Mon Sep 17 00:00:00 2001 From: Mister_Nebula <41904486+misternebula@users.noreply.github.com> Date: Thu, 18 Aug 2022 18:56:40 +0100 Subject: [PATCH 02/17] Update QSBMSStoreProfileManager.cs --- QSB/SaveSync/QSBMSStoreProfileManager.cs | 28 ++++++------------------ 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/QSB/SaveSync/QSBMSStoreProfileManager.cs b/QSB/SaveSync/QSBMSStoreProfileManager.cs index bfd15dae5..1a101a7b2 100644 --- a/QSB/SaveSync/QSBMSStoreProfileManager.cs +++ b/QSB/SaveSync/QSBMSStoreProfileManager.cs @@ -86,14 +86,9 @@ public void Initialize() } OnProfileSignInComplete?.Invoke(ProfileManagerSignInResult.COMPLETE); + OnProfileReadDone?.Invoke(); - var onProfileReadDone = OnProfileReadDone; - if (onProfileReadDone == null) - { - return; - } - - onProfileReadDone(); + DebugLog.DebugWrite($"INITIALIZED"); } public void PreInitialize() @@ -316,18 +311,14 @@ private void OnGameSaveLoaded(object sender, string blobName, GameSaveLoadedArgs if (_isLoadingSettingsBlob) { _isLoadingSettingsBlob = false; - var onProfileReadDone = OnProfileReadDone; - if (onProfileReadDone == null) - { - return; - } - - onProfileReadDone(); + OnProfileReadDone?.Invoke(); + DebugLog.DebugWrite($"LOADED SETTINGS BLOB"); } } private void OnGameSaveLoadFailed(object sender, string blobName) { + DebugLog.DebugWrite($"OnGameSaveLoadFailed"); _fileOpsBusyLocks--; if (_isLoadingGameBlob) { @@ -346,13 +337,8 @@ private void OnGameSaveLoadFailed(object sender, string blobName) _saveData.inputActionsJson = ((InputManager)OWInput.SharedInputManager).commandManager.DefaultInputActions.ToJson(); SaveGame(null, _saveData.settings, _saveData.gfxSettings, _saveData.inputActionsJson); _isLoadingSettingsBlob = false; - var onProfileReadDone = OnProfileReadDone; - if (onProfileReadDone == null) - { - return; - } - - onProfileReadDone(); + OnProfileReadDone?.Invoke(); + DebugLog.DebugWrite($"LOADING SETTINGS BLOB - FROM FAILED GAME LOAD"); } } From fa4b3299c940197775340a078b03d280217cdccf Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Thu, 18 Aug 2022 11:01:47 -0700 Subject: [PATCH 03/17] gooba --- .../Patches/LightSensorPatches.cs | 141 ++++++++++++- .../Patches/PlayerLightSensorPatches.cs | 197 ------------------ 2 files changed, 130 insertions(+), 208 deletions(-) delete mode 100644 QSB/EchoesOfTheEye/LightSensorSync/Patches/PlayerLightSensorPatches.cs diff --git a/QSB/EchoesOfTheEye/LightSensorSync/Patches/LightSensorPatches.cs b/QSB/EchoesOfTheEye/LightSensorSync/Patches/LightSensorPatches.cs index 783e7d166..e5e2586e1 100644 --- a/QSB/EchoesOfTheEye/LightSensorSync/Patches/LightSensorPatches.cs +++ b/QSB/EchoesOfTheEye/LightSensorSync/Patches/LightSensorPatches.cs @@ -143,9 +143,51 @@ private static bool ManagedFixedUpdate(SingleLightSensor __instance) return false; } + + #region player light sensor + [HarmonyPrefix] - [HarmonyPatch(nameof(SingleLightSensor.UpdateIllumination))] - private static bool UpdateIllumination(SingleLightSensor __instance) + [HarmonyPatch(nameof(SingleLightSensor.ManagedFixedUpdate))] + private static bool Player_ManagedFixedUpdate(SingleLightSensor __instance) + { + if (!LightSensorManager.IsPlayerLightSensor(__instance)) + { + return true; + } + + if (__instance._fixedUpdateFrameDelayCount > 0) + { + __instance._fixedUpdateFrameDelayCount--; + return false; + } + var illuminated = __instance._illuminated; + if (__instance._illuminatingDreamLanternList != null) + { + _illuminatingDreamLanternList.Clear(); + _illuminatingDreamLanternList.AddRange(__instance._illuminatingDreamLanternList); + } + __instance.UpdateIllumination(); + if (!illuminated && __instance._illuminated) + { + __instance.OnDetectLight.Invoke(); + new PlayerSetIlluminatedMessage(QSBPlayerManager.LocalPlayerId, true).Send(); + } + else if (illuminated && !__instance._illuminated) + { + __instance.OnDetectDarkness.Invoke(); + new PlayerSetIlluminatedMessage(QSBPlayerManager.LocalPlayerId, false).Send(); + } + if (__instance._illuminatingDreamLanternList != null && + !__instance._illuminatingDreamLanternList.SequenceEqual(_illuminatingDreamLanternList)) + { + new PlayerIlluminatingLanternsMessage(QSBPlayerManager.LocalPlayerId, __instance._illuminatingDreamLanternList).Send(); + } + return false; + } + + #endregion + + private static bool UpdateLocalIllumination(SingleLightSensor __instance) { if (LightSensorManager.IsPlayerLightSensor(__instance)) { @@ -157,8 +199,93 @@ private static bool UpdateIllumination(SingleLightSensor __instance) } var qsbLightSensor = __instance.GetWorldObject(); - __instance._illuminated = false; qsbLightSensor._locallyIlluminated = false; + if (__instance._lightSources == null || __instance._lightSources.Count == 0) + { + return false; + } + var sensorWorldPos = __instance.transform.TransformPoint(__instance._localSensorOffset); + var sensorWorldDir = Vector3.zero; + if (__instance._directionalSensor) + { + sensorWorldDir = __instance.transform.TransformDirection(__instance._localDirection).normalized; + } + foreach (var lightSource in __instance._lightSources) + { + if ((__instance._lightSourceMask & lightSource.GetLightSourceType()) == lightSource.GetLightSourceType() && + lightSource.CheckIlluminationAtPoint(sensorWorldPos, __instance._sensorRadius, __instance._maxDistance)) + { + switch (lightSource.GetLightSourceType()) + { + case LightSourceType.FLASHLIGHT: + { + if (lightSource is not QSBFlashlight) + { + var position = Locator.GetPlayerCamera().transform.position; + var vector3 = __instance.transform.position - position; + if (Vector3.Angle(Locator.GetPlayerCamera().transform.forward, vector3) <= __instance._maxSpotHalfAngle && + !__instance.CheckOcclusion(position, sensorWorldPos, sensorWorldDir)) + { + qsbLightSensor._locallyIlluminated = true; + } + } + break; + } + case LightSourceType.PROBE: + { + if (lightSource is not QSBProbe qsbProbe) + { + var probe = Locator.GetProbe(); + if (probe != null && + probe.IsLaunched() && + !probe.IsRetrieving() && + probe.CheckIlluminationAtPoint(sensorWorldPos, __instance._sensorRadius, __instance._maxDistance) && + !__instance.CheckOcclusion(probe.GetLightSourcePosition(), sensorWorldPos, sensorWorldDir)) + { + qsbLightSensor._locallyIlluminated = true; + } + } + break; + } + case LightSourceType.DREAM_LANTERN: + { + var dreamLanternController = lightSource as DreamLanternController; + if (dreamLanternController.IsLit() && + dreamLanternController.IsFocused(__instance._lanternFocusThreshold) && + dreamLanternController.CheckIlluminationAtPoint(sensorWorldPos, __instance._sensorRadius, __instance._maxDistance) && + !__instance.CheckOcclusion(dreamLanternController.GetLightPosition(), sensorWorldPos, sensorWorldDir)) + { + var dreamLanternItem = dreamLanternController.GetComponent(); + qsbLightSensor._locallyIlluminated |= QSBPlayerManager.LocalPlayer.HeldItem?.AttachedObject == dreamLanternItem; + } + break; + } + case LightSourceType.SIMPLE_LANTERN: + foreach (var owlight in lightSource.GetLights()) + { + var occludableLight = owlight.GetLight().shadows != LightShadows.None && + owlight.GetLight().shadowStrength > 0.5f; + var maxDistance = Mathf.Min(__instance._maxSimpleLanternDistance, __instance._maxDistance); + if (owlight.CheckIlluminationAtPoint(sensorWorldPos, __instance._sensorRadius, maxDistance) && + !__instance.CheckOcclusion(owlight.transform.position, sensorWorldPos, sensorWorldDir, occludableLight)) + { + var simpleLanternItem = (SimpleLanternItem)lightSource; + qsbLightSensor._locallyIlluminated |= QSBPlayerManager.LocalPlayer.HeldItem?.AttachedObject == simpleLanternItem; + } + } + break; + } + } + } + return false; + } + + + [HarmonyPrefix] + [HarmonyPatch(nameof(SingleLightSensor.UpdateIllumination))] + private static bool UpdateIllumination(SingleLightSensor __instance) + { + __instance._illuminated = false; __instance._illuminatingDreamLanternList?.Clear(); if (__instance._lightSources == null || __instance._lightSources.Count == 0) { @@ -209,7 +336,6 @@ private static bool UpdateIllumination(SingleLightSensor __instance) !__instance.CheckOcclusion(position, sensorWorldPos, sensorWorldDir)) { __instance._illuminated = true; - qsbLightSensor._locallyIlluminated = true; } } break; @@ -238,7 +364,6 @@ private static bool UpdateIllumination(SingleLightSensor __instance) !__instance.CheckOcclusion(probe.GetLightSourcePosition(), sensorWorldPos, sensorWorldDir)) { __instance._illuminated = true; - qsbLightSensor._locallyIlluminated = true; } } break; @@ -253,9 +378,6 @@ private static bool UpdateIllumination(SingleLightSensor __instance) { __instance._illuminatingDreamLanternList.Add(dreamLanternController); __instance._illuminated = true; - - var dreamLanternItem = dreamLanternController.GetComponent(); - qsbLightSensor._locallyIlluminated |= QSBPlayerManager.LocalPlayer.HeldItem?.AttachedObject == dreamLanternItem; } break; } @@ -269,9 +391,6 @@ private static bool UpdateIllumination(SingleLightSensor __instance) !__instance.CheckOcclusion(owlight.transform.position, sensorWorldPos, sensorWorldDir, occludableLight)) { __instance._illuminated = true; - - var simpleLanternItem = (SimpleLanternItem)lightSource; - qsbLightSensor._locallyIlluminated |= QSBPlayerManager.LocalPlayer.HeldItem?.AttachedObject == simpleLanternItem; } } break; diff --git a/QSB/EchoesOfTheEye/LightSensorSync/Patches/PlayerLightSensorPatches.cs b/QSB/EchoesOfTheEye/LightSensorSync/Patches/PlayerLightSensorPatches.cs deleted file mode 100644 index 1260ce501..000000000 --- a/QSB/EchoesOfTheEye/LightSensorSync/Patches/PlayerLightSensorPatches.cs +++ /dev/null @@ -1,197 +0,0 @@ -using HarmonyLib; -using QSB.EchoesOfTheEye.LightSensorSync.Messages; -using QSB.Messaging; -using QSB.Patches; -using QSB.Player; -using QSB.Tools.FlashlightTool; -using QSB.Tools.ProbeTool; -using System.Collections.Generic; -using System.Linq; -using UnityEngine; - -/* - * For those who come here, - * leave while you still can. - */ - -namespace QSB.EchoesOfTheEye.LightSensorSync.Patches; - -/// -/// remote player light sensors are disabled, so these will only run for the local player light sensor -/// -[HarmonyPatch(typeof(SingleLightSensor))] -internal class PlayerLightSensorPatches : QSBPatch -{ - public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect; - - /// - /// to prevent allocating a new list every frame - /// - private static readonly List _illuminatingDreamLanternList = new(); - - [HarmonyPrefix] - [HarmonyPatch(nameof(SingleLightSensor.ManagedFixedUpdate))] - private static bool ManagedFixedUpdate(SingleLightSensor __instance) - { - if (!LightSensorManager.IsPlayerLightSensor(__instance)) - { - return true; - } - - if (__instance._fixedUpdateFrameDelayCount > 0) - { - __instance._fixedUpdateFrameDelayCount--; - return false; - } - var illuminated = __instance._illuminated; - if (__instance._illuminatingDreamLanternList != null) - { - _illuminatingDreamLanternList.Clear(); - _illuminatingDreamLanternList.AddRange(__instance._illuminatingDreamLanternList); - } - __instance.UpdateIllumination(); - if (!illuminated && __instance._illuminated) - { - __instance.OnDetectLight.Invoke(); - new PlayerSetIlluminatedMessage(QSBPlayerManager.LocalPlayerId, true).Send(); - } - else if (illuminated && !__instance._illuminated) - { - __instance.OnDetectDarkness.Invoke(); - new PlayerSetIlluminatedMessage(QSBPlayerManager.LocalPlayerId, false).Send(); - } - if (__instance._illuminatingDreamLanternList != null && - !__instance._illuminatingDreamLanternList.SequenceEqual(_illuminatingDreamLanternList)) - { - new PlayerIlluminatingLanternsMessage(QSBPlayerManager.LocalPlayerId, __instance._illuminatingDreamLanternList).Send(); - } - return false; - } - - [HarmonyPrefix] - [HarmonyPatch(nameof(SingleLightSensor.UpdateIllumination))] - private static bool UpdateIllumination(SingleLightSensor __instance) - { - if (!LightSensorManager.IsPlayerLightSensor(__instance)) - { - return true; - } - - __instance._illuminated = false; - __instance._illuminatingDreamLanternList?.Clear(); - if (__instance._lightSources == null || __instance._lightSources.Count == 0) - { - return false; - } - var sensorWorldPos = __instance.transform.TransformPoint(__instance._localSensorOffset); - var sensorWorldDir = Vector3.zero; - if (__instance._directionalSensor) - { - sensorWorldDir = __instance.transform.TransformDirection(__instance._localDirection).normalized; - } - foreach (var lightSource in __instance._lightSources) - { - if ((__instance._lightSourceMask & lightSource.GetLightSourceType()) == lightSource.GetLightSourceType() && - lightSource.CheckIlluminationAtPoint(sensorWorldPos, __instance._sensorRadius, __instance._maxDistance)) - { - switch (lightSource.GetLightSourceType()) - { - case LightSourceType.UNDEFINED: - { - var owlight = lightSource as OWLight2; - var occludableLight = owlight.GetLight().shadows != LightShadows.None && - owlight.GetLight().shadowStrength > 0.5f; - if (owlight.CheckIlluminationAtPoint(sensorWorldPos, __instance._sensorRadius, __instance._maxDistance) && - !__instance.CheckOcclusion(owlight.transform.position, sensorWorldPos, sensorWorldDir, occludableLight)) - { - __instance._illuminated = true; - } - break; - } - case LightSourceType.FLASHLIGHT: - { - if (lightSource is QSBFlashlight qsbFlashlight) - { - var position = qsbFlashlight.Player.Camera.transform.position; - var vector3 = __instance.transform.position - position; - if (Vector3.Angle(qsbFlashlight.Player.Camera.transform.forward, vector3) <= __instance._maxSpotHalfAngle && - !__instance.CheckOcclusion(position, sensorWorldPos, sensorWorldDir)) - { - __instance._illuminated = true; - } - } - else - { - var position = Locator.GetPlayerCamera().transform.position; - var vector3 = __instance.transform.position - position; - if (Vector3.Angle(Locator.GetPlayerCamera().transform.forward, vector3) <= __instance._maxSpotHalfAngle && - !__instance.CheckOcclusion(position, sensorWorldPos, sensorWorldDir)) - { - __instance._illuminated = true; - } - } - break; - } - case LightSourceType.PROBE: - { - if (lightSource is QSBProbe qsbProbe) - { - var probe = qsbProbe; - if (probe != null && - probe.IsLaunched() && - !probe.IsRetrieving() && - probe.CheckIlluminationAtPoint(sensorWorldPos, __instance._sensorRadius, __instance._maxDistance) && - !__instance.CheckOcclusion(probe.GetLightSourcePosition(), sensorWorldPos, sensorWorldDir)) - { - __instance._illuminated = true; - } - } - else - { - var probe = Locator.GetProbe(); - if (probe != null && - probe.IsLaunched() && - !probe.IsRetrieving() && - probe.CheckIlluminationAtPoint(sensorWorldPos, __instance._sensorRadius, __instance._maxDistance) && - !__instance.CheckOcclusion(probe.GetLightSourcePosition(), sensorWorldPos, sensorWorldDir)) - { - __instance._illuminated = true; - } - } - break; - } - case LightSourceType.DREAM_LANTERN: - { - var dreamLanternController = lightSource as DreamLanternController; - if (dreamLanternController.IsLit() && - dreamLanternController.IsFocused(__instance._lanternFocusThreshold) && - dreamLanternController.CheckIlluminationAtPoint(sensorWorldPos, __instance._sensorRadius, __instance._maxDistance) && - !__instance.CheckOcclusion(dreamLanternController.GetLightPosition(), sensorWorldPos, sensorWorldDir)) - { - __instance._illuminatingDreamLanternList.Add(dreamLanternController); - __instance._illuminated = true; - } - break; - } - case LightSourceType.SIMPLE_LANTERN: - foreach (var owlight in lightSource.GetLights()) - { - var occludableLight = owlight.GetLight().shadows != LightShadows.None && - owlight.GetLight().shadowStrength > 0.5f; - var maxDistance = Mathf.Min(__instance._maxSimpleLanternDistance, __instance._maxDistance); - if (owlight.CheckIlluminationAtPoint(sensorWorldPos, __instance._sensorRadius, maxDistance) && - !__instance.CheckOcclusion(owlight.transform.position, sensorWorldPos, sensorWorldDir, occludableLight)) - { - __instance._illuminated = true; - } - } - break; - case LightSourceType.VOLUME_ONLY: - __instance._illuminated = true; - break; - } - } - } - return false; - } -} From 8ac9c3df7b23ff85088b4f8994193a65635bb68a Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Thu, 18 Aug 2022 11:03:18 -0700 Subject: [PATCH 04/17] gooba 2 --- .../LightSensorSync/Patches/LightSensorPatches.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/QSB/EchoesOfTheEye/LightSensorSync/Patches/LightSensorPatches.cs b/QSB/EchoesOfTheEye/LightSensorSync/Patches/LightSensorPatches.cs index e5e2586e1..fa7985772 100644 --- a/QSB/EchoesOfTheEye/LightSensorSync/Patches/LightSensorPatches.cs +++ b/QSB/EchoesOfTheEye/LightSensorSync/Patches/LightSensorPatches.cs @@ -29,10 +29,6 @@ internal class LightSensorPatches : QSBPatch [HarmonyPatch(nameof(SingleLightSensor.OnSectorOccupantsUpdated))] private static bool OnSectorOccupantsUpdated(SingleLightSensor __instance) { - if (LightSensorManager.IsPlayerLightSensor(__instance)) - { - return true; - } if (!QSBWorldSync.AllObjectsReady) { return true; @@ -187,12 +183,9 @@ private static bool Player_ManagedFixedUpdate(SingleLightSensor __instance) #endregion + private static bool UpdateLocalIllumination(SingleLightSensor __instance) { - if (LightSensorManager.IsPlayerLightSensor(__instance)) - { - return true; - } if (!QSBWorldSync.AllObjectsReady) { return true; From f86bf56a1db4f19a4b633c91cd2f3dab31fbfad9 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Thu, 18 Aug 2022 11:05:08 -0700 Subject: [PATCH 05/17] separate local and regular illumination --- .../Patches/LightSensorPatches.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/QSB/EchoesOfTheEye/LightSensorSync/Patches/LightSensorPatches.cs b/QSB/EchoesOfTheEye/LightSensorSync/Patches/LightSensorPatches.cs index fa7985772..5ac849bb5 100644 --- a/QSB/EchoesOfTheEye/LightSensorSync/Patches/LightSensorPatches.cs +++ b/QSB/EchoesOfTheEye/LightSensorSync/Patches/LightSensorPatches.cs @@ -102,16 +102,15 @@ private static bool ManagedFixedUpdate(SingleLightSensor __instance) __instance._fixedUpdateFrameDelayCount--; return false; } - var illuminated = __instance._illuminated; - var locallyIlluminated = qsbLightSensor._locallyIlluminated; - if (__instance._illuminatingDreamLanternList != null) - { - _illuminatingDreamLanternList.Clear(); - _illuminatingDreamLanternList.AddRange(__instance._illuminatingDreamLanternList); - } - __instance.UpdateIllumination(); if (qsbLightSensor.Owner == QSBPlayerManager.LocalPlayerId) { + var illuminated = __instance._illuminated; + if (__instance._illuminatingDreamLanternList != null) + { + _illuminatingDreamLanternList.Clear(); + _illuminatingDreamLanternList.AddRange(__instance._illuminatingDreamLanternList); + } + __instance.UpdateIllumination(); if (!illuminated && __instance._illuminated) { __instance.OnDetectLight.Invoke(); @@ -128,6 +127,9 @@ private static bool ManagedFixedUpdate(SingleLightSensor __instance) qsbLightSensor.SendMessage(new IlluminatingLanternsMessage(__instance._illuminatingDreamLanternList)); } } + + var locallyIlluminated = qsbLightSensor._locallyIlluminated; + UpdateLocalIllumination(__instance); if (!locallyIlluminated && qsbLightSensor._locallyIlluminated) { qsbLightSensor.OnDetectLocalLight?.Invoke(); From 14393aff646658ef39cfde335604b315ad8ee249 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Thu, 18 Aug 2022 11:05:33 -0700 Subject: [PATCH 06/17] void return type --- .../LightSensorSync/Patches/LightSensorPatches.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/QSB/EchoesOfTheEye/LightSensorSync/Patches/LightSensorPatches.cs b/QSB/EchoesOfTheEye/LightSensorSync/Patches/LightSensorPatches.cs index 5ac849bb5..a76cb1575 100644 --- a/QSB/EchoesOfTheEye/LightSensorSync/Patches/LightSensorPatches.cs +++ b/QSB/EchoesOfTheEye/LightSensorSync/Patches/LightSensorPatches.cs @@ -186,18 +186,18 @@ private static bool Player_ManagedFixedUpdate(SingleLightSensor __instance) #endregion - private static bool UpdateLocalIllumination(SingleLightSensor __instance) + private static void UpdateLocalIllumination(SingleLightSensor __instance) { if (!QSBWorldSync.AllObjectsReady) { - return true; + return; } var qsbLightSensor = __instance.GetWorldObject(); qsbLightSensor._locallyIlluminated = false; if (__instance._lightSources == null || __instance._lightSources.Count == 0) { - return false; + return; } var sensorWorldPos = __instance.transform.TransformPoint(__instance._localSensorOffset); var sensorWorldDir = Vector3.zero; @@ -272,7 +272,6 @@ private static bool UpdateLocalIllumination(SingleLightSensor __instance) } } } - return false; } From ac87cb715318afb5550cf550b95d4de5389b4361 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Thu, 18 Aug 2022 11:06:01 -0700 Subject: [PATCH 07/17] move --- .../Patches/LightSensorPatches.cs | 137 +++++++++--------- 1 file changed, 68 insertions(+), 69 deletions(-) diff --git a/QSB/EchoesOfTheEye/LightSensorSync/Patches/LightSensorPatches.cs b/QSB/EchoesOfTheEye/LightSensorSync/Patches/LightSensorPatches.cs index a76cb1575..2187c99cf 100644 --- a/QSB/EchoesOfTheEye/LightSensorSync/Patches/LightSensorPatches.cs +++ b/QSB/EchoesOfTheEye/LightSensorSync/Patches/LightSensorPatches.cs @@ -186,18 +186,15 @@ private static bool Player_ManagedFixedUpdate(SingleLightSensor __instance) #endregion - private static void UpdateLocalIllumination(SingleLightSensor __instance) + [HarmonyPrefix] + [HarmonyPatch(nameof(SingleLightSensor.UpdateIllumination))] + private static bool UpdateIllumination(SingleLightSensor __instance) { - if (!QSBWorldSync.AllObjectsReady) - { - return; - } - var qsbLightSensor = __instance.GetWorldObject(); - - qsbLightSensor._locallyIlluminated = false; + __instance._illuminated = false; + __instance._illuminatingDreamLanternList?.Clear(); if (__instance._lightSources == null || __instance._lightSources.Count == 0) { - return; + return false; } var sensorWorldPos = __instance.transform.TransformPoint(__instance._localSensorOffset); var sensorWorldDir = Vector3.zero; @@ -212,23 +209,57 @@ private static void UpdateLocalIllumination(SingleLightSensor __instance) { switch (lightSource.GetLightSourceType()) { + case LightSourceType.UNDEFINED: + { + var owlight = lightSource as OWLight2; + var occludableLight = owlight.GetLight().shadows != LightShadows.None && + owlight.GetLight().shadowStrength > 0.5f; + if (owlight.CheckIlluminationAtPoint(sensorWorldPos, __instance._sensorRadius, __instance._maxDistance) && + !__instance.CheckOcclusion(owlight.transform.position, sensorWorldPos, sensorWorldDir, occludableLight)) + { + __instance._illuminated = true; + } + break; + } case LightSourceType.FLASHLIGHT: { - if (lightSource is not QSBFlashlight) + if (lightSource is QSBFlashlight qsbFlashlight) + { + var position = qsbFlashlight.Player.Camera.transform.position; + var vector3 = __instance.transform.position - position; + if (Vector3.Angle(qsbFlashlight.Player.Camera.transform.forward, vector3) <= __instance._maxSpotHalfAngle && + !__instance.CheckOcclusion(position, sensorWorldPos, sensorWorldDir)) + { + __instance._illuminated = true; + } + } + else { var position = Locator.GetPlayerCamera().transform.position; var vector3 = __instance.transform.position - position; if (Vector3.Angle(Locator.GetPlayerCamera().transform.forward, vector3) <= __instance._maxSpotHalfAngle && !__instance.CheckOcclusion(position, sensorWorldPos, sensorWorldDir)) { - qsbLightSensor._locallyIlluminated = true; + __instance._illuminated = true; } } break; } case LightSourceType.PROBE: { - if (lightSource is not QSBProbe qsbProbe) + if (lightSource is QSBProbe qsbProbe) + { + var probe = qsbProbe; + if (probe != null && + probe.IsLaunched() && + !probe.IsRetrieving() && + probe.CheckIlluminationAtPoint(sensorWorldPos, __instance._sensorRadius, __instance._maxDistance) && + !__instance.CheckOcclusion(probe.GetLightSourcePosition(), sensorWorldPos, sensorWorldDir)) + { + __instance._illuminated = true; + } + } + else { var probe = Locator.GetProbe(); if (probe != null && @@ -237,7 +268,7 @@ private static void UpdateLocalIllumination(SingleLightSensor __instance) probe.CheckIlluminationAtPoint(sensorWorldPos, __instance._sensorRadius, __instance._maxDistance) && !__instance.CheckOcclusion(probe.GetLightSourcePosition(), sensorWorldPos, sensorWorldDir)) { - qsbLightSensor._locallyIlluminated = true; + __instance._illuminated = true; } } break; @@ -250,8 +281,8 @@ private static void UpdateLocalIllumination(SingleLightSensor __instance) dreamLanternController.CheckIlluminationAtPoint(sensorWorldPos, __instance._sensorRadius, __instance._maxDistance) && !__instance.CheckOcclusion(dreamLanternController.GetLightPosition(), sensorWorldPos, sensorWorldDir)) { - var dreamLanternItem = dreamLanternController.GetComponent(); - qsbLightSensor._locallyIlluminated |= QSBPlayerManager.LocalPlayer.HeldItem?.AttachedObject == dreamLanternItem; + __instance._illuminatingDreamLanternList.Add(dreamLanternController); + __instance._illuminated = true; } break; } @@ -264,26 +295,31 @@ private static void UpdateLocalIllumination(SingleLightSensor __instance) if (owlight.CheckIlluminationAtPoint(sensorWorldPos, __instance._sensorRadius, maxDistance) && !__instance.CheckOcclusion(owlight.transform.position, sensorWorldPos, sensorWorldDir, occludableLight)) { - var simpleLanternItem = (SimpleLanternItem)lightSource; - qsbLightSensor._locallyIlluminated |= QSBPlayerManager.LocalPlayer.HeldItem?.AttachedObject == simpleLanternItem; + __instance._illuminated = true; } } break; + case LightSourceType.VOLUME_ONLY: + __instance._illuminated = true; + break; } } } + return false; } - - [HarmonyPrefix] - [HarmonyPatch(nameof(SingleLightSensor.UpdateIllumination))] - private static bool UpdateIllumination(SingleLightSensor __instance) + private static void UpdateLocalIllumination(SingleLightSensor __instance) { - __instance._illuminated = false; - __instance._illuminatingDreamLanternList?.Clear(); + if (!QSBWorldSync.AllObjectsReady) + { + return; + } + var qsbLightSensor = __instance.GetWorldObject(); + + qsbLightSensor._locallyIlluminated = false; if (__instance._lightSources == null || __instance._lightSources.Count == 0) { - return false; + return; } var sensorWorldPos = __instance.transform.TransformPoint(__instance._localSensorOffset); var sensorWorldDir = Vector3.zero; @@ -298,57 +334,23 @@ private static bool UpdateIllumination(SingleLightSensor __instance) { switch (lightSource.GetLightSourceType()) { - case LightSourceType.UNDEFINED: - { - var owlight = lightSource as OWLight2; - var occludableLight = owlight.GetLight().shadows != LightShadows.None && - owlight.GetLight().shadowStrength > 0.5f; - if (owlight.CheckIlluminationAtPoint(sensorWorldPos, __instance._sensorRadius, __instance._maxDistance) && - !__instance.CheckOcclusion(owlight.transform.position, sensorWorldPos, sensorWorldDir, occludableLight)) - { - __instance._illuminated = true; - } - break; - } case LightSourceType.FLASHLIGHT: { - if (lightSource is QSBFlashlight qsbFlashlight) - { - var position = qsbFlashlight.Player.Camera.transform.position; - var vector3 = __instance.transform.position - position; - if (Vector3.Angle(qsbFlashlight.Player.Camera.transform.forward, vector3) <= __instance._maxSpotHalfAngle && - !__instance.CheckOcclusion(position, sensorWorldPos, sensorWorldDir)) - { - __instance._illuminated = true; - } - } - else + if (lightSource is not QSBFlashlight) { var position = Locator.GetPlayerCamera().transform.position; var vector3 = __instance.transform.position - position; if (Vector3.Angle(Locator.GetPlayerCamera().transform.forward, vector3) <= __instance._maxSpotHalfAngle && !__instance.CheckOcclusion(position, sensorWorldPos, sensorWorldDir)) { - __instance._illuminated = true; + qsbLightSensor._locallyIlluminated = true; } } break; } case LightSourceType.PROBE: { - if (lightSource is QSBProbe qsbProbe) - { - var probe = qsbProbe; - if (probe != null && - probe.IsLaunched() && - !probe.IsRetrieving() && - probe.CheckIlluminationAtPoint(sensorWorldPos, __instance._sensorRadius, __instance._maxDistance) && - !__instance.CheckOcclusion(probe.GetLightSourcePosition(), sensorWorldPos, sensorWorldDir)) - { - __instance._illuminated = true; - } - } - else + if (lightSource is not QSBProbe qsbProbe) { var probe = Locator.GetProbe(); if (probe != null && @@ -357,7 +359,7 @@ private static bool UpdateIllumination(SingleLightSensor __instance) probe.CheckIlluminationAtPoint(sensorWorldPos, __instance._sensorRadius, __instance._maxDistance) && !__instance.CheckOcclusion(probe.GetLightSourcePosition(), sensorWorldPos, sensorWorldDir)) { - __instance._illuminated = true; + qsbLightSensor._locallyIlluminated = true; } } break; @@ -370,8 +372,8 @@ private static bool UpdateIllumination(SingleLightSensor __instance) dreamLanternController.CheckIlluminationAtPoint(sensorWorldPos, __instance._sensorRadius, __instance._maxDistance) && !__instance.CheckOcclusion(dreamLanternController.GetLightPosition(), sensorWorldPos, sensorWorldDir)) { - __instance._illuminatingDreamLanternList.Add(dreamLanternController); - __instance._illuminated = true; + var dreamLanternItem = dreamLanternController.GetComponent(); + qsbLightSensor._locallyIlluminated |= QSBPlayerManager.LocalPlayer.HeldItem?.AttachedObject == dreamLanternItem; } break; } @@ -384,16 +386,13 @@ private static bool UpdateIllumination(SingleLightSensor __instance) if (owlight.CheckIlluminationAtPoint(sensorWorldPos, __instance._sensorRadius, maxDistance) && !__instance.CheckOcclusion(owlight.transform.position, sensorWorldPos, sensorWorldDir, occludableLight)) { - __instance._illuminated = true; + var simpleLanternItem = (SimpleLanternItem)lightSource; + qsbLightSensor._locallyIlluminated |= QSBPlayerManager.LocalPlayer.HeldItem?.AttachedObject == simpleLanternItem; } } break; - case LightSourceType.VOLUME_ONLY: - __instance._illuminated = true; - break; } } } - return false; } } From 457b42c225121b7b826f9747ce5389c7efe0295d Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Thu, 18 Aug 2022 11:12:21 -0700 Subject: [PATCH 08/17] bruh moment --- .../LightSensorSync/Patches/LightSensorPatches.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/QSB/EchoesOfTheEye/LightSensorSync/Patches/LightSensorPatches.cs b/QSB/EchoesOfTheEye/LightSensorSync/Patches/LightSensorPatches.cs index 2187c99cf..20ffaf748 100644 --- a/QSB/EchoesOfTheEye/LightSensorSync/Patches/LightSensorPatches.cs +++ b/QSB/EchoesOfTheEye/LightSensorSync/Patches/LightSensorPatches.cs @@ -350,7 +350,7 @@ private static void UpdateLocalIllumination(SingleLightSensor __instance) } case LightSourceType.PROBE: { - if (lightSource is not QSBProbe qsbProbe) + if (lightSource is not QSBProbe) { var probe = Locator.GetProbe(); if (probe != null && From 6827d937aaf08aaa128fbdb1250106d23224fa57 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Thu, 18 Aug 2022 12:04:51 -0700 Subject: [PATCH 09/17] meesa --- QSB/SaveSync/QSBMSStoreProfileManager.cs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/QSB/SaveSync/QSBMSStoreProfileManager.cs b/QSB/SaveSync/QSBMSStoreProfileManager.cs index 1a101a7b2..4a12cc71c 100644 --- a/QSB/SaveSync/QSBMSStoreProfileManager.cs +++ b/QSB/SaveSync/QSBMSStoreProfileManager.cs @@ -106,16 +106,8 @@ public void PreInitialize() _preInitialized = true; } - public void InvokeProfileSignInComplete() - { - var onProfileSignInComplete = OnProfileSignInComplete; - if (onProfileSignInComplete == null) - { - return; - } - - onProfileSignInComplete(ProfileManagerSignInResult.COMPLETE); - } + public void InvokeProfileSignInComplete() => + OnProfileSignInComplete?.Invoke(ProfileManagerSignInResult.COMPLETE); public void InvokeSaveSetupComplete() { From 24634cf423c589746663596687b037946350bd9e Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Thu, 18 Aug 2022 12:06:01 -0700 Subject: [PATCH 10/17] meesa 2 --- QSB/SaveSync/QSBStandaloneProfileManager.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/QSB/SaveSync/QSBStandaloneProfileManager.cs b/QSB/SaveSync/QSBStandaloneProfileManager.cs index 5c91f1b07..06ef63f6f 100644 --- a/QSB/SaveSync/QSBStandaloneProfileManager.cs +++ b/QSB/SaveSync/QSBStandaloneProfileManager.cs @@ -218,13 +218,7 @@ private void InitializeProfileData() return; } - var onNoProfilesExist = OnNoProfilesExist; - if (onNoProfilesExist == null) - { - return; - } - - onNoProfilesExist(); + OnNoProfilesExist?.Invoke(); } private void LoadSaveFilesFromProfiles() From 9d15185c9600be0c8c1d03f3bd74186bde79387a Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Thu, 18 Aug 2022 12:46:21 -0700 Subject: [PATCH 11/17] note bug --- QSB/ItemSync/ItemState.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/QSB/ItemSync/ItemState.cs b/QSB/ItemSync/ItemState.cs index db974f6aa..9a2465c38 100644 --- a/QSB/ItemSync/ItemState.cs +++ b/QSB/ItemSync/ItemState.cs @@ -6,6 +6,8 @@ namespace QSB.ItemSync; /// /// used for initial state sync. /// we have to store this separately because it's not saved in the item itself, unfortunately. +/// +/// BUG: there are some cases (like remote unsocket) where HasBeenInteractedWith or other state isn't set. /// public class ItemState { From 4df107f866c2b55c73d8d8d994f92b578c43fe75 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Fri, 19 Aug 2022 16:00:57 -0700 Subject: [PATCH 12/17] actually implement isInitialized --- QSB/SaveSync/QSBMSStoreProfileManager.cs | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/QSB/SaveSync/QSBMSStoreProfileManager.cs b/QSB/SaveSync/QSBMSStoreProfileManager.cs index 4a12cc71c..98f272ef7 100644 --- a/QSB/SaveSync/QSBMSStoreProfileManager.cs +++ b/QSB/SaveSync/QSBMSStoreProfileManager.cs @@ -24,7 +24,6 @@ internal class QSBMSStoreProfileManager : IProfileManager private GraphicSettings _pendingGfxSettingsSave; private string _pendingInputActionsSave = ""; private JsonSerializer _jsonSerializer; - private bool _initialized; private int _fileOpsBusyLocks; private bool _preInitialized; private bool _isLoadingGameBlob; @@ -48,7 +47,7 @@ public static QSBMSStoreProfileManager SharedInstance public SettingsSave currentProfileGameSettings => _saveData.settings; public GraphicSettings currentProfileGraphicsSettings => _saveData.gfxSettings; public string currentProfileInputJSON => _saveData.inputActionsJson; - public bool isInitialized { get; } + public bool isInitialized { get; private set; } public bool isBusyWithFileOps => _fileOpsBusyLocks > 0; public bool hasPendingSaveOperation => _pendingGameSave != null || _pendingSettingsSave != null || _pendingGfxSettingsSave != null || _pendingInputActionsSave != null; public bool saveSystemAvailable { get; private set; } @@ -66,7 +65,7 @@ public static QSBMSStoreProfileManager SharedInstance public void Initialize() { - if (!_initialized) + if (!isInitialized) { Gdk.Helpers.SignIn(); SpinnerUI.Show(); @@ -81,14 +80,14 @@ public void Initialize() { SerializationBinder = serializationBinder }; - _initialized = true; + isInitialized = true; return; } OnProfileSignInComplete?.Invoke(ProfileManagerSignInResult.COMPLETE); OnProfileReadDone?.Invoke(); - DebugLog.DebugWrite($"INITIALIZED"); + DebugLog.DebugWrite("INITIALIZED"); } public void PreInitialize() @@ -106,7 +105,7 @@ public void PreInitialize() _preInitialized = true; } - public void InvokeProfileSignInComplete() => + public void InvokeProfileSignInComplete() => OnProfileSignInComplete?.Invoke(ProfileManagerSignInResult.COMPLETE); public void InvokeSaveSetupComplete() @@ -117,9 +116,7 @@ public void InvokeSaveSetupComplete() LoadGame(OW_GAME_SAVE_BLOB_NAME); } - public void InitializeForEditor() - { - } + public void InitializeForEditor() { } public void SaveGame(GameSave gameSave, SettingsSave settSave, GraphicSettings gfxSettings, string inputJSON) { @@ -304,13 +301,13 @@ private void OnGameSaveLoaded(object sender, string blobName, GameSaveLoadedArgs { _isLoadingSettingsBlob = false; OnProfileReadDone?.Invoke(); - DebugLog.DebugWrite($"LOADED SETTINGS BLOB"); + DebugLog.DebugWrite("LOADED SETTINGS BLOB"); } } private void OnGameSaveLoadFailed(object sender, string blobName) { - DebugLog.DebugWrite($"OnGameSaveLoadFailed"); + DebugLog.DebugWrite("OnGameSaveLoadFailed"); _fileOpsBusyLocks--; if (_isLoadingGameBlob) { @@ -330,7 +327,7 @@ private void OnGameSaveLoadFailed(object sender, string blobName) SaveGame(null, _saveData.settings, _saveData.gfxSettings, _saveData.inputActionsJson); _isLoadingSettingsBlob = false; OnProfileReadDone?.Invoke(); - DebugLog.DebugWrite($"LOADING SETTINGS BLOB - FROM FAILED GAME LOAD"); + DebugLog.DebugWrite("LOADING SETTINGS BLOB - FROM FAILED GAME LOAD"); } } From e8995a13648643009e22be0b18edd141342018ef Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Fri, 19 Aug 2022 16:14:51 -0700 Subject: [PATCH 13/17] note a small bug --- QSB/ConversationSync/Patches/ConversationPatches.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/QSB/ConversationSync/Patches/ConversationPatches.cs b/QSB/ConversationSync/Patches/ConversationPatches.cs index 7b835540c..bb882ff38 100644 --- a/QSB/ConversationSync/Patches/ConversationPatches.cs +++ b/QSB/ConversationSync/Patches/ConversationPatches.cs @@ -64,6 +64,7 @@ public static bool CharacterDialogueTree_InputDialogueOption(CharacterDialogueTr } var selectedOption = __instance._currentDialogueBox.OptionFromUIIndex(optionIndex); + // BUG: uses translated value instead of key ConversationManager.Instance.SendPlayerOption(selectedOption.Text); return true; } From a6966065fec6e7c1f10c6ed08f33f01e494f2d12 Mon Sep 17 00:00:00 2001 From: Mister_Nebula <41904486+misternebula@users.noreply.github.com> Date: Sat, 20 Aug 2022 14:04:25 +0100 Subject: [PATCH 14/17] Update QSBMSStoreProfileManager.cs --- QSB/SaveSync/QSBMSStoreProfileManager.cs | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/QSB/SaveSync/QSBMSStoreProfileManager.cs b/QSB/SaveSync/QSBMSStoreProfileManager.cs index 98f272ef7..89befeaa6 100644 --- a/QSB/SaveSync/QSBMSStoreProfileManager.cs +++ b/QSB/SaveSync/QSBMSStoreProfileManager.cs @@ -251,31 +251,38 @@ private void OnGameSaveLoaded(object sender, string blobName, GameSaveLoadedArgs memoryStream.Seek(0L, SeekOrigin.Begin); using (var jsonTextReader = new JsonTextReader(new StreamReader(memoryStream))) { - var x1SaveData = _jsonSerializer.Deserialize(jsonTextReader); + var tempSaveData = _jsonSerializer.Deserialize(jsonTextReader); if (_isLoadingGameBlob) { - if (x1SaveData != null) + if (tempSaveData != null) { - if (x1SaveData.gameSave == null) + if (tempSaveData.gameSave == null) { DebugLog.DebugWrite("[GDK] tempSaveData.gameSave is null (oh no)"); } - _saveData.gameSave = x1SaveData.gameSave ?? new GameSave(); + if (tempSaveData.gameMultSave == null) + { + DebugLog.DebugWrite("[GDK] tempSaveData.gameMultSave is null (oh no)"); + } + + _saveData.gameSave = tempSaveData.gameSave ?? new GameSave(); + _saveData.gameMultSave = tempSaveData.gameMultSave ?? new GameSave(); } else { DebugLog.DebugWrite("[GDK] tempSaveData is null (oh no)"); _saveData.gameSave = new GameSave(); + _saveData.gameMultSave = new GameSave(); } } else { - if (x1SaveData != null) + if (tempSaveData != null) { - _saveData.gfxSettings = x1SaveData.gfxSettings ?? new GraphicSettings(true); - _saveData.settings = x1SaveData.settings ?? new SettingsSave(); - _saveData.inputActionsJson = x1SaveData.inputActionsJson ?? ((InputManager)OWInput.SharedInputManager).commandManager.DefaultInputActions.ToJson(); + _saveData.gfxSettings = tempSaveData.gfxSettings ?? new GraphicSettings(true); + _saveData.settings = tempSaveData.settings ?? new SettingsSave(); + _saveData.inputActionsJson = tempSaveData.inputActionsJson ?? ((InputManager)OWInput.SharedInputManager).commandManager.DefaultInputActions.ToJson(); } else { From b6c446af9acd0b86308de92430a41f090291db9c Mon Sep 17 00:00:00 2001 From: Mister_Nebula <41904486+misternebula@users.noreply.github.com> Date: Sat, 20 Aug 2022 14:27:18 +0100 Subject: [PATCH 15/17] bump version --- QSB/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/QSB/manifest.json b/QSB/manifest.json index 256b8626e..053552817 100644 --- a/QSB/manifest.json +++ b/QSB/manifest.json @@ -7,7 +7,7 @@ "body": "- Disable *all* other mods. (Can heavily affect performance)\n- Make sure you are not running any other network-intensive applications." }, "uniqueName": "Raicuparta.QuantumSpaceBuddies", - "version": "0.21.0", + "version": "0.21.1", "owmlVersion": "2.5.2", "dependencies": [ "_nebula.MenuFramework", "JohnCorby.VanillaFix" ], "pathsToPreserve": [ "debugsettings.json", "storage.json" ] From 55028442446503dd5153f6aa5e7c318cc8f57ed6 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Sat, 20 Aug 2022 11:18:42 -0700 Subject: [PATCH 16/17] UpdateChangelog --- QSB/Menus/MenuManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/QSB/Menus/MenuManager.cs b/QSB/Menus/MenuManager.cs index d01787968..9a555d1b8 100644 --- a/QSB/Menus/MenuManager.cs +++ b/QSB/Menus/MenuManager.cs @@ -42,7 +42,7 @@ internal class MenuManager : MonoBehaviour, IAddComponentOnStart private const int _titleButtonIndex = 2; private float _connectPopupOpenTime; - private const string UpdateChangelog = "QSB Version 0.21.0\r\nMultiplayer saves are now seperate from singleplayer, and items got an overhaul. A lot of bug fixes too."; + private const string UpdateChangelog = "QSB Version 0.21.1\r\nFixed gamepass not working with qsb and the last small light sensor bug."; private Action PopupClose; From 3a33795570c43a20eb8a68d0d899be9473c13777 Mon Sep 17 00:00:00 2001 From: Mister_Nebula <41904486+misternebula@users.noreply.github.com> Date: Sat, 20 Aug 2022 19:31:20 +0100 Subject: [PATCH 17/17] Update MenuManager.cs --- QSB/Menus/MenuManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/QSB/Menus/MenuManager.cs b/QSB/Menus/MenuManager.cs index 9a555d1b8..d98290ca6 100644 --- a/QSB/Menus/MenuManager.cs +++ b/QSB/Menus/MenuManager.cs @@ -42,7 +42,7 @@ internal class MenuManager : MonoBehaviour, IAddComponentOnStart private const int _titleButtonIndex = 2; private float _connectPopupOpenTime; - private const string UpdateChangelog = "QSB Version 0.21.1\r\nFixed gamepass not working with qsb and the last small light sensor bug."; + private const string UpdateChangelog = "QSB Version 0.21.1\r\nFixed gamepass not working, and fixed a small bug with light sensors."; private Action PopupClose;