1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2025-12-09 03:33:29 +08:00
This commit is contained in:
2024-09-18 01:41:08 +08:00
parent fb916b3813
commit bd512a6b78
17 changed files with 232 additions and 207 deletions

View File

@@ -7,19 +7,18 @@ using UXAssist.Common;
namespace UXAssist.Patches;
public static class DysonSpherePatch
public class DysonSpherePatch: PatchImpl<DysonSpherePatch>
{
public static ConfigEntry<bool> StopEjectOnNodeCompleteEnabled;
public static ConfigEntry<bool> OnlyConstructNodesEnabled;
public static ConfigEntry<int> AutoConstructMultiplier;
private static Harmony _dysonSpherePatch;
private static FieldInfo _totalNodeSpInfo, _totalFrameSpInfo, _totalCpInfo;
public static void Init()
{
I18N.Add("[UXAssist] No node to fill", "[UXAssist] No node to fill", "[UXAssist] 无可建造节点");
_dysonSpherePatch ??= Harmony.CreateAndPatchAll(typeof(DysonSpherePatch));
Enable(true);
StopEjectOnNodeCompleteEnabled.SettingChanged += (_, _) => StopEjectOnNodeComplete.Enable(StopEjectOnNodeCompleteEnabled.Value);
OnlyConstructNodesEnabled.SettingChanged += (_, _) => OnlyConstructNodes.Enable(OnlyConstructNodesEnabled.Value);
StopEjectOnNodeComplete.Enable(StopEjectOnNodeCompleteEnabled.Value);
@@ -33,8 +32,7 @@ public static class DysonSpherePatch
{
StopEjectOnNodeComplete.Enable(false);
OnlyConstructNodes.Enable(false);
_dysonSpherePatch?.UnpatchSelf();
_dysonSpherePatch = null;
Enable(false);
}
public static void InitCurrentDysonSphere(int index)

View File

@@ -12,7 +12,7 @@ using UXAssist.Common;
namespace UXAssist.Patches;
public static class FactoryPatch
public class FactoryPatch: PatchImpl<FactoryPatch>
{
public static ConfigEntry<bool> UnlimitInteractiveEnabled;
public static ConfigEntry<bool> RemoveSomeConditionEnabled;
@@ -29,8 +29,6 @@ public static class FactoryPatch
public static ConfigEntry<bool> BeltSignalsForBuyOutEnabled;
private static PressKeyBind _doNotRenderEntitiesKey;
private static Harmony _factoryPatch;
public static void Init()
{
_doNotRenderEntitiesKey = KeyBindings.RegisterKeyBinding(new BuiltinKey
@@ -71,11 +69,13 @@ public static class FactoryPatch
DragBuildPowerPoles.Enable(DragBuildPowerPolesEnabled.Value);
BeltSignalsForBuyOut.Enable(BeltSignalsForBuyOutEnabled.Value);
_factoryPatch ??= Harmony.CreateAndPatchAll(typeof(FactoryPatch));
Enable(true);
}
public static void Uninit()
{
Enable(false);
RemoveSomeConditionBuild.Enable(false);
UnlimitInteractive.Enable(false);
NightLight.Enable(false);
@@ -90,9 +90,6 @@ public static class FactoryPatch
DragBuildPowerPoles.Enable(false);
BeltSignalsForBuyOut.Enable(false);
BeltSignalsForBuyOut.UninitPersist();
_factoryPatch?.UnpatchSelf();
_factoryPatch = null;
}
public static void OnUpdate()
@@ -1324,7 +1321,7 @@ public static class FactoryPatch
private static void UnfixProto()
{
if (GetPatch() == null || OldDragBuild.Count < 3 || DSPGame.IsMenuDemo) return;
if (GetHarmony() == null || OldDragBuild.Count < 3 || DSPGame.IsMenuDemo) return;
var i = 0;
foreach (var id in PowerPoleIds)
{

View File

@@ -9,7 +9,7 @@ using UXAssist.Common;
namespace UXAssist.Patches;
public static class GamePatch
public class GamePatch: PatchImpl<GamePatch>
{
private const string GameWindowClass = "UnityWndClass";
private static string _gameWindowTitle = "Dyson Sphere Program";
@@ -50,8 +50,6 @@ public static class GamePatch
}
}
private static Harmony _gamePatch;
public static void Init()
{
// Get profile name from command line arguments, and set window title accordingly
@@ -104,19 +102,18 @@ public static class GamePatch
MouseCursorScaleUp.Enable(MouseCursorScaleUpMultiplier.Value > 1);
// AutoSaveOpt.Enable(AutoSaveOptEnabled.Value);
ConvertSavesFromPeace.Enable(ConvertSavesFromPeaceEnabled.Value);
_gamePatch ??= Harmony.CreateAndPatchAll(typeof(GamePatch));
Enable(true);
}
public static void Uninit()
{
Enable(false);
LoadLastWindowRect.Enable(false);
EnableWindowResize.Enable(false);
MouseCursorScaleUp.reload = false;
MouseCursorScaleUp.Enable(false);
// AutoSaveOpt.Enable(false);
ConvertSavesFromPeace.Enable(false);
_gamePatch?.UnpatchSelf();
_gamePatch = null;
}
private static void RefreshSavePath()
@@ -341,21 +338,11 @@ public static class GamePatch
}
/*
private static class AutoSaveOpt
private class AutoSaveOpt: PatchImpl<AutoSaveOpt>
{
private static Harmony _patch;
public static void Enable(bool on)
protected override void OnEnable()
{
if (on)
{
Directory.CreateDirectory(GameConfig.gameSaveFolder + "AutoSaves/");
_patch ??= Harmony.CreateAndPatchAll(typeof(AutoSaveOpt));
return;
}
_patch?.UnpatchSelf();
_patch = null;
Directory.CreateDirectory(GameConfig.gameSaveFolder + "AutoSaves/");
}
[HarmonyPrefix]