mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2026-08-05 14:00:16 +08:00
refactor: register static-state resets on game end
This commit is contained in:
@@ -6,10 +6,12 @@ using System.Reflection;
|
||||
using HarmonyLib;
|
||||
using UXAssist.Common;
|
||||
using UXAssist.Common.GameConstants;
|
||||
using UXAssist.Common.ModFeatures;
|
||||
using GameLogicProc = UXAssist.Common.GameLogic;
|
||||
|
||||
namespace UXAssist.Patches.Factory;
|
||||
|
||||
[ModFeature("BeltSignalsForBuyOut")]
|
||||
internal static class BeltSignalPatch
|
||||
{
|
||||
public static void Enable(bool enable)
|
||||
@@ -41,6 +43,16 @@ internal static class BeltSignalPatch
|
||||
storage[i] = r.ReadInt32();
|
||||
}
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
GameLogicProc.OnGameEnd += BeltSignalsForBuyOut.ResetState;
|
||||
}
|
||||
|
||||
public static void Uninit()
|
||||
{
|
||||
GameLogicProc.OnGameEnd -= BeltSignalsForBuyOut.ResetState;
|
||||
}
|
||||
|
||||
internal class BeltSignalsForBuyOut : PatchImpl<BeltSignalsForBuyOut>
|
||||
{
|
||||
private static bool _initialized;
|
||||
@@ -52,6 +64,15 @@ internal static class BeltSignalPatch
|
||||
private static Dictionary<int, uint>[] _signalBelts = new Dictionary<int, uint>[64];
|
||||
private static readonly HashSet<int> SignalBeltFactoryIndices = [];
|
||||
|
||||
internal static void ResetState()
|
||||
{
|
||||
_clusterSeedKey = 0L;
|
||||
_signalBelts = null;
|
||||
SignalBeltFactoryIndices.Clear();
|
||||
for (var i = 0; i < DarkFogItemsInVoid.Length; i++)
|
||||
DarkFogItemsInVoid[i] = 0;
|
||||
}
|
||||
|
||||
public static void InitPersist()
|
||||
{
|
||||
Persist.Enable(true);
|
||||
|
||||
Reference in New Issue
Block a user