From 31f2d5ff8ee96e7ad328485f63bfa6d6b74b583a Mon Sep 17 00:00:00 2001 From: starfish <50672801+starfi5h@users.noreply.github.com> Date: Mon, 2 Dec 2024 19:21:37 +0800 Subject: [PATCH] Fix compilation for game 0.10.31.24646 --- .../LCPObjectEntryEntityInfoProcessor.cs | 4 +- .../Patches/Dynamic/SectorModel_Patch.cs | 23 +++++++ .../UIControlPanelAdvancedMinerEntry_Patch.cs | 64 ------------------- .../UIControlPanelPlanetEntry_Patch.cs | 2 +- .../Patches/Dynamic/UIGalaxySelect_Patch.cs | 4 +- .../Dynamic/UIStatisticsWindow_Patch.cs | 4 +- .../UIStatisticsWindow_Transpiler.cs | 4 +- 7 files changed, 32 insertions(+), 73 deletions(-) create mode 100644 NebulaPatcher/Patches/Dynamic/SectorModel_Patch.cs diff --git a/NebulaNetwork/PacketProcessors/Logistics/ControlPanel/LCPObjectEntryEntityInfoProcessor.cs b/NebulaNetwork/PacketProcessors/Logistics/ControlPanel/LCPObjectEntryEntityInfoProcessor.cs index 8818786bd..28a807a01 100644 --- a/NebulaNetwork/PacketProcessors/Logistics/ControlPanel/LCPObjectEntryEntityInfoProcessor.cs +++ b/NebulaNetwork/PacketProcessors/Logistics/ControlPanel/LCPObjectEntryEntityInfoProcessor.cs @@ -62,7 +62,7 @@ private static void UpdateEntry(UIControlPanelObjectEntry objectEntry, LCPObject text = packet.Name; entry.stationNameText.color = entry.masterWindow.renamedColor; } - Utils.UITextTruncateShow(entry.stationNameText, text, entry.stationNameTextWidthLimit, ref entry.stationNameTextSettings); + Utils.UITextTruncateShow(entry.stationNameText, ref text, entry.stationNameTextWidthLimit, ref entry.stationNameTextSettings); } else if (objectEntry is UIControlPanelAdvancedMinerEntry) { @@ -89,7 +89,7 @@ private static void UpdateEntry(UIControlPanelObjectEntry objectEntry, LCPObject text = packet.Name; entry.stationNameText.color = entry.masterWindow.renamedColor; } - Utils.UITextTruncateShow(entry.stationNameText, text, entry.stationNameTextWidthLimit, ref entry.stationNameTextSettings); + Utils.UITextTruncateShow(entry.stationNameText, ref text, entry.stationNameTextWidthLimit, ref entry.stationNameTextSettings); } else if (objectEntry is UIControlPanelDispenserEntry) { diff --git a/NebulaPatcher/Patches/Dynamic/SectorModel_Patch.cs b/NebulaPatcher/Patches/Dynamic/SectorModel_Patch.cs new file mode 100644 index 000000000..7b03ab64e --- /dev/null +++ b/NebulaPatcher/Patches/Dynamic/SectorModel_Patch.cs @@ -0,0 +1,23 @@ +#region + +using HarmonyLib; + +#endregion + +namespace NebulaPatcher.Patches.Dynamic; + +[HarmonyPatch(typeof(SectorModel))] +internal class SectorModel_Patch +{ + [HarmonyPrefix] + [HarmonyPatch(nameof(SectorModel.OnCameraPostRender))] + public static bool OnCameraPostRender_Prefix() + { + if (!GameMain.isPaused && !GameMain.inOtherScene) + { + // Skip if GameMain.mainPlayer is null to prevent NRE when player joining the game + return GameMain.mainPlayer != null; + } + return true; + } +} diff --git a/NebulaPatcher/Patches/Dynamic/UIControlPanelAdvancedMinerEntry_Patch.cs b/NebulaPatcher/Patches/Dynamic/UIControlPanelAdvancedMinerEntry_Patch.cs index 467b58afa..2f29fc28f 100644 --- a/NebulaPatcher/Patches/Dynamic/UIControlPanelAdvancedMinerEntry_Patch.cs +++ b/NebulaPatcher/Patches/Dynamic/UIControlPanelAdvancedMinerEntry_Patch.cs @@ -60,68 +60,4 @@ public static bool IsLocal_Prefix(UIControlPanelAdvancedMinerEntry __instance, r } return true; } - - [HarmonyPrefix] - [HarmonyPatch(nameof(UIControlPanelAdvancedMinerEntry.OnFillNecessaryButtonClick))] - public static bool OnFillNecessaryButtonClick_Prefix(UIControlPanelAdvancedMinerEntry __instance) - { - if (!Multiplayer.IsActive) return true; - if (__instance.factory == null || __instance.station == null) - { - UIRealtimeTip.Popup("Unavailable".Translate()); - return false; - } - - var packet = new StationUI() - { - PlanetId = __instance.factory.planetId, - StationId = __instance.station.id, - StationGId = __instance.station.gid - }; - var text = ""; - if (__instance.station.isStellar) - { - int shortAge, previousCount; - - previousCount = __instance.station.idleDroneCount; - shortAge = __instance.station.workDroneDatas.Length - (__instance.station.idleDroneCount + __instance.station.workDroneCount); - UIControlPanelObjectEntry.ReplenishItems(5001, shortAge, ref __instance.station.idleDroneCount, ref text); - packet.SettingIndex = StationUI.EUISettings.SetDroneCount; - packet.SettingValue = (__instance.station.idleDroneCount + __instance.station.workDroneCount); - Multiplayer.Session.Network.SendPacket(packet); - if (Multiplayer.Session.IsClient) __instance.station.idleDroneCount = previousCount; // Wait for server to authorize - - previousCount = __instance.station.idleShipCount; - shortAge = __instance.station.workShipDatas.Length - (__instance.station.idleShipCount + __instance.station.workShipCount); - UIControlPanelObjectEntry.ReplenishItems(5002, shortAge, ref __instance.station.idleShipCount, ref text); - packet.SettingIndex = StationUI.EUISettings.SetShipCount; - packet.SettingValue = (__instance.station.idleShipCount + __instance.station.workShipCount); - Multiplayer.Session.Network.SendPacket(packet); - if (Multiplayer.Session.IsClient) __instance.station.idleShipCount = previousCount; // Wait for server to authorize - - previousCount = __instance.station.warperCount; - shortAge = __instance.station.warperMaxCount - __instance.station.warperCount; - UIControlPanelObjectEntry.ReplenishItems(1210, shortAge, ref __instance.station.warperCount, ref text); - packet.SettingIndex = StationUI.EUISettings.SetWarperCount; - packet.SettingValue = __instance.station.warperCount; - Multiplayer.Session.Network.SendPacket(packet); - if (Multiplayer.Session.IsClient) __instance.station.warperCount = previousCount; // Wait for server to authorize - } - else - { - var previousCount = __instance.station.idleDroneCount; - var shortAge = __instance.station.workDroneDatas.Length - (__instance.station.idleDroneCount + __instance.station.workDroneCount); - UIControlPanelObjectEntry.ReplenishItems(5001, shortAge, ref __instance.station.idleDroneCount, ref text); - packet.SettingIndex = StationUI.EUISettings.SetDroneCount; - packet.SettingValue = (__instance.station.idleDroneCount + __instance.station.workDroneCount); - Multiplayer.Session.Network.SendPacket(packet); - if (Multiplayer.Session.IsClient) __instance.station.idleDroneCount = previousCount; // Wait for server to authorize - } - if (!string.IsNullOrEmpty(text)) - { - UIRealtimeTip.Popup(text, false, 0); - VFAudio.Create("equip-1", GameMain.mainPlayer.transform, Vector3.zero, true, 4, -1, -1L); - } - return false; - } } diff --git a/NebulaPatcher/Patches/Dynamic/UIControlPanelPlanetEntry_Patch.cs b/NebulaPatcher/Patches/Dynamic/UIControlPanelPlanetEntry_Patch.cs index ea9a2404d..548b65769 100644 --- a/NebulaPatcher/Patches/Dynamic/UIControlPanelPlanetEntry_Patch.cs +++ b/NebulaPatcher/Patches/Dynamic/UIControlPanelPlanetEntry_Patch.cs @@ -45,7 +45,7 @@ public static bool UpdateBanner_Prefix(UIControlPanelPlanetEntry __instance) } __instance.planetTypeText.text = __instance.planet.typeString; var displayName = __instance.planet.displayName; - Utils.UITextTruncateShow(__instance.planetNameText, displayName, __instance.planetNameTextWidthLimit, ref __instance.planetNameTextSettings); + Utils.UITextTruncateShow(__instance.planetNameText, ref displayName, __instance.planetNameTextWidthLimit, ref __instance.planetNameTextSettings); return false; } diff --git a/NebulaPatcher/Patches/Dynamic/UIGalaxySelect_Patch.cs b/NebulaPatcher/Patches/Dynamic/UIGalaxySelect_Patch.cs index 5ecdb7467..c71d41a29 100644 --- a/NebulaPatcher/Patches/Dynamic/UIGalaxySelect_Patch.cs +++ b/NebulaPatcher/Patches/Dynamic/UIGalaxySelect_Patch.cs @@ -81,8 +81,8 @@ public static void _OnOpen_Postfix(UIGalaxySelect __instance) } [HarmonyPrefix] - [HarmonyPatch(nameof(UIGalaxySelect.EnterGame))] - public static bool EnterGame_Prefix(UIGalaxySelect __instance) + [HarmonyPatch(nameof(UIGalaxySelect.ApplySetting))] + public static bool ApplySetting_Prefix(UIGalaxySelect __instance) { if (!Multiplayer.IsInMultiplayerMenu || __instance.uiCombat.active) { diff --git a/NebulaPatcher/Patches/Dynamic/UIStatisticsWindow_Patch.cs b/NebulaPatcher/Patches/Dynamic/UIStatisticsWindow_Patch.cs index 0d80d892d..76d055310 100644 --- a/NebulaPatcher/Patches/Dynamic/UIStatisticsWindow_Patch.cs +++ b/NebulaPatcher/Patches/Dynamic/UIStatisticsWindow_Patch.cs @@ -40,9 +40,9 @@ public static void _OnClose_Postfix() } [HarmonyPrefix] - [HarmonyPatch(nameof(UIStatisticsWindow.AddFactoryStatGroup))] + [HarmonyPatch(nameof(UIStatisticsWindow.AddProductStatGroup))] [SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Original Function Name")] - public static bool AddFactoryStatGroup_Prefix(int _factoryIndex, ProductionStatistics ___productionStat) + public static bool AddProductStatGroup_Prefix(int _factoryIndex, ProductionStatistics ___productionStat) { //Skip when StatisticsDataPacket hasn't arrived yet return _factoryIndex >= 0 && ___productionStat.factoryStatPool[_factoryIndex] != null; diff --git a/NebulaPatcher/Patches/Transpilers/UIStatisticsWindow_Transpiler.cs b/NebulaPatcher/Patches/Transpilers/UIStatisticsWindow_Transpiler.cs index de96d455c..b33d2a4ea 100644 --- a/NebulaPatcher/Patches/Transpilers/UIStatisticsWindow_Transpiler.cs +++ b/NebulaPatcher/Patches/Transpilers/UIStatisticsWindow_Transpiler.cs @@ -48,8 +48,8 @@ private static IEnumerable RefreshAstroBox_Transpiler(IEnumerab } [HarmonyTranspiler] - [HarmonyPatch(nameof(UIStatisticsWindow.ComputeDisplayProductEntries))] - private static IEnumerable ComputeDisplayEntries_Transpiler(IEnumerable instructions) + [HarmonyPatch(nameof(UIStatisticsWindow.DetermineProductEntryList))] + private static IEnumerable DetermineProductEntryList_Transpiler(IEnumerable instructions) { //Change: this.gameData.factoryCount //To: GetFactoryCount()