1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2026-06-21 03:21:10 +08:00

fix: logistic storage overflow reset when switching stations in panel

This commit is contained in:
2026-06-20 15:20:59 +08:00
parent cc783937e6
commit 64f9aee06b
+32 -2
View File
@@ -487,6 +487,8 @@ public static class LogisticsPatch
private static long _nextKeyTick;
private static bool _skipNextUIStationStorageEvent;
private static bool _skipNextUIControlPanelStationStorageEvent;
private static bool _refreshingUIStationStorage;
private static bool _refreshingUIControlPanelStationStorage;
private static bool UpdateKeyPressed(KeyCode code)
{
@@ -627,11 +629,39 @@ public static class LogisticsPatch
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(UIStationStorage), "RefreshValues")]
private static void UIStationStorage_RefreshValues_Prefix()
{
_refreshingUIStationStorage = true;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(UIStationStorage), "RefreshValues")]
private static void UIStationStorage_RefreshValues_Postfix()
{
_refreshingUIStationStorage = false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(UIControlPanelStationStorage), "RefreshValues")]
private static void UIControlPanelStationStorage_RefreshValues_Prefix()
{
_refreshingUIControlPanelStationStorage = true;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(UIControlPanelStationStorage), "RefreshValues")]
private static void UIControlPanelStationStorage_RefreshValues_Postfix()
{
_refreshingUIControlPanelStationStorage = false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(UIStationStorage), nameof(UIStationStorage.OnMaxSliderValueChange))]
private static bool UIStationStorage_OnMaxSliderValueChange_Prefix()
{
if (!_skipNextUIStationStorageEvent) return true;
if (!_refreshingUIStationStorage && !_skipNextUIStationStorageEvent) return true;
_skipNextUIStationStorageEvent = false;
return false;
}
@@ -640,7 +670,7 @@ public static class LogisticsPatch
[HarmonyPatch(typeof(UIControlPanelStationStorage), nameof(UIControlPanelStationStorage.OnMaxSliderValueChange))]
private static bool UIControlPanelStationStorage_OnMaxSliderValueChange_Prefix()
{
if (!_skipNextUIControlPanelStationStorageEvent) return true;
if (!_refreshingUIControlPanelStationStorage && !_skipNextUIControlPanelStationStorageEvent) return true;
_skipNextUIControlPanelStationStorageEvent = false;
return false;
}