mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2025-12-09 14:13:31 +08:00
Work in progress
This commit is contained in:
@@ -11,14 +11,12 @@ public static class AbnormalDisabler
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
if (_patch != null) return;
|
||||
_patch = Harmony.CreateAndPatchAll(typeof(AbnormalDisabler));
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(AbnormalDisabler));
|
||||
}
|
||||
|
||||
public static void Uninit()
|
||||
{
|
||||
if (_patch == null) return;
|
||||
_patch.UnpatchSelf();
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,13 +72,12 @@ public static class BirthPlanetPatch
|
||||
FlatBirthPlanet.SettingChanged += (_, _) => PatchBirthThemeData();
|
||||
HighLuminosityBirthStar.SettingChanged += (_, _) => PatchBirthThemeData();
|
||||
PatchBirthThemeData();
|
||||
_patch = Harmony.CreateAndPatchAll(typeof(BirthPlanetPatch));
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(BirthPlanetPatch));
|
||||
}
|
||||
|
||||
public static void Uninit()
|
||||
{
|
||||
if (_patch == null) return;
|
||||
_patch.UnpatchSelf();
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,9 +63,9 @@ public class CheatEnabler : BaseUnityPlugin
|
||||
"Boost geothermal power");
|
||||
PlanetFunctions.PlayerActionsInGlobeViewEnabled = Config.Bind("Planet", "PlayerActionsInGlobeView", false,
|
||||
"Enable player actions in globe view");
|
||||
ResourcePatch.InfiniteEnabled = Config.Bind("Planet", "AlwaysInfiniteResource", false,
|
||||
ResourcePatch.InfiniteResourceEnabled = Config.Bind("Planet", "AlwaysInfiniteResource", false,
|
||||
"always infinite natural resource");
|
||||
ResourcePatch.FastEnabled = Config.Bind("Planet", "FastMining", false,
|
||||
ResourcePatch.FastMiningEnabled = Config.Bind("Planet", "FastMining", false,
|
||||
"super-fast mining speed");
|
||||
WaterPumperPatch.Enabled = Config.Bind("Planet", "WaterPumpAnywhere", false,
|
||||
"Can pump water anywhere (while water type is not None)");
|
||||
@@ -109,8 +109,8 @@ public class CheatEnabler : BaseUnityPlugin
|
||||
I18N.Apply();
|
||||
|
||||
// UI Patch
|
||||
_windowPatch = Harmony.CreateAndPatchAll(typeof(UI.MyWindowManager.Patch));
|
||||
_patch = Harmony.CreateAndPatchAll(typeof(CheatEnabler));
|
||||
_windowPatch ??= Harmony.CreateAndPatchAll(typeof(UI.MyWindowManager.Patch));
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(CheatEnabler));
|
||||
|
||||
DevShortcuts.Init();
|
||||
AbnormalDisabler.Init();
|
||||
@@ -272,7 +272,6 @@ public class CheatEnabler : BaseUnityPlugin
|
||||
}
|
||||
else
|
||||
{
|
||||
UIRoot.instance.uiGame.ShutPlayerInventory();
|
||||
_configWin.Open();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ public static class DevShortcuts
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
_patch = Harmony.CreateAndPatchAll(typeof(DevShortcuts));
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(DevShortcuts));
|
||||
Enabled.SettingChanged += (_, _) =>
|
||||
{
|
||||
if (_test != null) _test.active = Enabled.Value;
|
||||
@@ -21,8 +21,7 @@ public static class DevShortcuts
|
||||
|
||||
public static void Uninit()
|
||||
{
|
||||
if (_patch == null) return;
|
||||
_patch.UnpatchSelf();
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace CheatEnabler;
|
||||
|
||||
public static class DysonSpherePatch
|
||||
{
|
||||
public static ConfigEntry<bool> StopEjectOnNodeCompleteEnabled;
|
||||
public static ConfigEntry<bool> SkipBulletEnabled;
|
||||
public static ConfigEntry<bool> SkipAbsorbEnabled;
|
||||
public static ConfigEntry<bool> QuickAbsorbEnabled;
|
||||
@@ -20,18 +21,20 @@ public static class DysonSpherePatch
|
||||
private static Harmony _ejectAnywayPatch;
|
||||
private static Harmony _overclockEjector;
|
||||
private static Harmony _overclockSilo;
|
||||
private static Harmony _patch;
|
||||
private static Harmony _dysonSpherePatch;
|
||||
private static bool _instantAbsorb;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(DysonSpherePatch));
|
||||
_dysonSpherePatch ??= Harmony.CreateAndPatchAll(typeof(DysonSpherePatch));
|
||||
StopEjectOnNodeCompleteEnabled.SettingChanged += (_, _) => StopEjectOnNodeComplete.Enable(StopEjectOnNodeCompleteEnabled.Value);
|
||||
SkipBulletEnabled.SettingChanged += (_, _) => SkipBulletValueChanged();
|
||||
SkipAbsorbEnabled.SettingChanged += (_, _) => SkipAbsorbValueChanged();
|
||||
QuickAbsorbEnabled.SettingChanged += (_, _) => QuickAbsorbValueChanged();
|
||||
EjectAnywayEnabled.SettingChanged += (_, _) => EjectAnywayValueChanged();
|
||||
OverclockEjectorEnabled.SettingChanged += (_, _) => OverclockEjectorValueChanged();
|
||||
OverclockSiloEnabled.SettingChanged += (_, _) => OverclockSiloValueChanged();
|
||||
StopEjectOnNodeComplete.Enable(StopEjectOnNodeCompleteEnabled.Value);
|
||||
SkipBulletValueChanged();
|
||||
SkipAbsorbValueChanged();
|
||||
QuickAbsorbValueChanged();
|
||||
@@ -42,6 +45,7 @@ public static class DysonSpherePatch
|
||||
|
||||
public static void Uninit()
|
||||
{
|
||||
StopEjectOnNodeComplete.Enable(false);
|
||||
_skipBulletPatch?.UnpatchSelf();
|
||||
_skipBulletPatch = null;
|
||||
_skipAbsorbPatch?.UnpatchSelf();
|
||||
@@ -54,8 +58,8 @@ public static class DysonSpherePatch
|
||||
_overclockEjector = null;
|
||||
_overclockSilo?.UnpatchSelf();
|
||||
_overclockSilo = null;
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
_dysonSpherePatch?.UnpatchSelf();
|
||||
_dysonSpherePatch = null;
|
||||
}
|
||||
|
||||
private static void SkipBulletValueChanged()
|
||||
@@ -194,7 +198,7 @@ public static class DysonSpherePatch
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(DysonNode), nameof(DysonNode.ConstructCp))]
|
||||
private static IEnumerable<CodeInstruction> DysonNode_ConstructCp_Patch(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
private static IEnumerable<CodeInstruction> DysonSpherePatch_DysonNode_ConstructCp_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchBack(false,
|
||||
@@ -220,6 +224,136 @@ public static class DysonSpherePatch
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
private static class StopEjectOnNodeComplete
|
||||
{
|
||||
private static Harmony _patch;
|
||||
private static HashSet<int>[] _nodeForAbsorb;
|
||||
|
||||
public static void Enable(bool on)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
InitNodeForAbsorb();
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(StopEjectOnNodeComplete));
|
||||
}
|
||||
else
|
||||
{
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
_nodeForAbsorb = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static void InitNodeForAbsorb()
|
||||
{
|
||||
_nodeForAbsorb = new HashSet<int>[GameMain.data.galaxy.starCount];
|
||||
foreach (var sphere in GameMain.data.dysonSpheres)
|
||||
{
|
||||
if (sphere?.layersSorted == null) continue;
|
||||
var starIndex = sphere.starData.index;
|
||||
foreach (var layer in sphere.layersSorted)
|
||||
{
|
||||
if (layer == null) continue;
|
||||
for (var i = layer.nodeCursor - 1; i > 0; i--)
|
||||
{
|
||||
var node = layer.nodePool[i];
|
||||
if (node == null || node.id != i) continue;
|
||||
SetNodeForAbsorb(starIndex, layer.id, node.id, node.sp == node.spMax && node.cpReqOrder > 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetNodeForAbsorb(int index, int layerId, int nodeId, bool canAbsorb)
|
||||
{
|
||||
ref var comp = ref _nodeForAbsorb[index];
|
||||
comp ??= new HashSet<int>();
|
||||
var idx = nodeId * 10 + layerId;
|
||||
if (canAbsorb)
|
||||
comp.Add(idx);
|
||||
else
|
||||
comp.Remove(idx);
|
||||
}
|
||||
|
||||
private static void UpdateNodeForAbsorb(DysonNode node)
|
||||
{
|
||||
var shells = node.shells;
|
||||
if (shells.Count == 0) return;
|
||||
SetNodeForAbsorb(shells[0].dysonSphere.starData.index, node.layerId, node.id, node.sp == node.spMax && node.cpReqOrder > 0);
|
||||
}
|
||||
|
||||
private static bool AnyNodeForAbsorb(int starIndex)
|
||||
{
|
||||
var comp = _nodeForAbsorb[starIndex];
|
||||
return comp != null && comp.Count > 0;
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(GameMain), nameof(GameMain.Begin))]
|
||||
private static void GameMain_Begin_Postfix()
|
||||
{
|
||||
InitNodeForAbsorb();
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(DysonNode), nameof(DysonNode.RecalcCpReq))]
|
||||
private static void DysonNode_RecalcCpReq_Postfix(DysonNode __instance)
|
||||
{
|
||||
UpdateNodeForAbsorb(__instance);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(DysonSphereLayer), nameof(DysonSphereLayer.RemoveDysonNode))]
|
||||
private static void DysonSphereLayer_RemoveDysonNode_Prefix(DysonSphereLayer __instance, int nodeId)
|
||||
{
|
||||
SetNodeForAbsorb(__instance.starData.index, __instance.id, nodeId, false);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(DysonSphere), nameof(DysonSphere.ResetNew))]
|
||||
private static void DysonSphere_ResetNew_Prefix(DysonSphere __instance)
|
||||
{
|
||||
var starIndex = __instance.starData.index;
|
||||
if (_nodeForAbsorb[starIndex] == null) return;
|
||||
_nodeForAbsorb[starIndex].Clear();
|
||||
_nodeForAbsorb[starIndex] = null;
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(EjectorComponent), nameof(EjectorComponent.InternalUpdate))]
|
||||
private static IEnumerable<CodeInstruction> EjectorComponent_InternalUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
var label1 = generator.DefineLabel();
|
||||
matcher.Start().InsertAndAdvance(
|
||||
new CodeInstruction(OpCodes.Ldarg_2),
|
||||
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(DysonSwarm), nameof(DysonSwarm.starData))),
|
||||
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(StarData), nameof(StarData.index))),
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(StopEjectOnNodeComplete), nameof(StopEjectOnNodeComplete.AnyNodeForAbsorb))),
|
||||
new CodeInstruction(OpCodes.Brtrue, label1)
|
||||
);
|
||||
matcher.Labels.Add(label1);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(DysonNode), nameof(DysonNode.ConstructCp))]
|
||||
private static IEnumerable<CodeInstruction> DysonNode_ConstructCp_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.Start().MatchForward(false,
|
||||
new CodeMatch(OpCodes.Stfld, AccessTools.Field(typeof(DysonNode), nameof(DysonNode.sp)))
|
||||
).Advance(1);
|
||||
var labels = matcher.Labels;
|
||||
matcher.Labels = new List<Label>();
|
||||
matcher.Insert(
|
||||
new CodeInstruction(OpCodes.Ldarg_0).WithLabels(labels),
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(StopEjectOnNodeComplete), nameof(StopEjectOnNodeComplete.UpdateNodeForAbsorb)))
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
|
||||
private static class SkipBulletPatch
|
||||
{
|
||||
private static long _sailLifeTime;
|
||||
@@ -294,7 +428,7 @@ public static class DysonSpherePatch
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(EjectorComponent), nameof(EjectorComponent.InternalUpdate))]
|
||||
private static IEnumerable<CodeInstruction> EjectorComponent_InternalUpdate_Patch(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
private static IEnumerable<CodeInstruction> EjectorComponent_InternalUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
@@ -407,7 +541,7 @@ public static class DysonSpherePatch
|
||||
{
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(DysonNode), nameof(DysonNode.OrderConstructCp))]
|
||||
private static IEnumerable<CodeInstruction> DysonNode_OrderConstructCp_Patch(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
private static IEnumerable<CodeInstruction> DysonNode_OrderConstructCp_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
@@ -422,7 +556,7 @@ public static class DysonSpherePatch
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(DysonSwarm), nameof(DysonSwarm.AbsorbSail))]
|
||||
private static IEnumerable<CodeInstruction> DysonSwarm_AbsorbSail_Patch(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
private static IEnumerable<CodeInstruction> DysonSwarm_AbsorbSail_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
var label1 = generator.DefineLabel();
|
||||
@@ -472,7 +606,7 @@ public static class DysonSpherePatch
|
||||
{
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(DysonSphereLayer), nameof(DysonSphereLayer.GameTick))]
|
||||
private static IEnumerable<CodeInstruction> DysonSphereLayer_GameTick_Patch(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
private static IEnumerable<CodeInstruction> DysonSphereLayer_GameTick_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
/* Insert absorption functions on beginning */
|
||||
@@ -506,7 +640,7 @@ public static class DysonSpherePatch
|
||||
for (var i = layer.nodeCursor - 1; i > 0; i--)
|
||||
{
|
||||
var node = layer.nodePool[i];
|
||||
if (node == null || node.id != i || node.sp != node.spMax) continue;
|
||||
if (node == null || node.id != i || node.sp < node.spMax) continue;
|
||||
var req = node._cpReq;
|
||||
var ordered = node.cpOrdered;
|
||||
if (req <= ordered) continue;
|
||||
@@ -526,7 +660,7 @@ public static class DysonSpherePatch
|
||||
{
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(EjectorComponent), nameof(EjectorComponent.InternalUpdate))]
|
||||
private static IEnumerable<CodeInstruction> EjectorComponent_InternalUpdate_Patch(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
private static IEnumerable<CodeInstruction> EjectorComponent_InternalUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
@@ -557,7 +691,7 @@ public static class DysonSpherePatch
|
||||
{
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(EjectorComponent), nameof(EjectorComponent.InternalUpdate))]
|
||||
private static IEnumerable<CodeInstruction> EjectAndSiloComponent_InternalUpdate_Patch(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
private static IEnumerable<CodeInstruction> EjectAndSiloComponent_InternalUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
/* Add a multiply to ejector speed */
|
||||
@@ -580,7 +714,7 @@ public static class DysonSpherePatch
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(UIEjectorWindow), nameof(UIEjectorWindow._OnUpdate))]
|
||||
private static IEnumerable<CodeInstruction> UIEjectAndSiloWindow__OnUpdate_Patch(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
private static IEnumerable<CodeInstruction> UIEjectAndSiloWindow__OnUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
/* Add a multiply to ejector speed */
|
||||
@@ -610,7 +744,7 @@ public static class DysonSpherePatch
|
||||
{
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(SiloComponent), nameof(SiloComponent.InternalUpdate))]
|
||||
private static IEnumerable<CodeInstruction> EjectAndSiloComponent_InternalUpdate_Patch(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
private static IEnumerable<CodeInstruction> EjectAndSiloComponent_InternalUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
/* Add a multiply to ejector speed */
|
||||
@@ -633,7 +767,7 @@ public static class DysonSpherePatch
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(UISiloWindow), nameof(UISiloWindow._OnUpdate))]
|
||||
private static IEnumerable<CodeInstruction> UIEjectAndSiloWindow__OnUpdate_Patch(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
private static IEnumerable<CodeInstruction> UIEjectAndSiloWindow__OnUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
/* Add a multiply to ejector speed */
|
||||
|
||||
@@ -30,33 +30,33 @@ public static class FactoryPatch
|
||||
public static void Init()
|
||||
{
|
||||
if (_factoryPatch != null) return;
|
||||
ImmediateEnabled.SettingChanged += (_, _) => ImmediateValueChanged();
|
||||
ArchitectModeEnabled.SettingChanged += (_, _) => ArchitectModeValueChanged();
|
||||
UnlimitInteractiveEnabled.SettingChanged += (_, _) => UnlimitInteractiveValueChanged();
|
||||
RemoveSomeConditionEnabled.SettingChanged += (_, _) => RemoveSomeConditionValueChanged();
|
||||
NoConditionEnabled.SettingChanged += (_, _) => NoConditionValueChanged();
|
||||
ImmediateEnabled.SettingChanged += (_, _) => ImmediateBuild.Enable(ImmediateEnabled.Value);
|
||||
ArchitectModeEnabled.SettingChanged += (_, _) => ArchitectMode.Enable(ArchitectModeEnabled.Value);
|
||||
UnlimitInteractiveEnabled.SettingChanged += (_, _) => UnlimitInteractive.Enable(UnlimitInteractiveEnabled.Value);
|
||||
RemoveSomeConditionEnabled.SettingChanged += (_, _) => RemoveSomeConditionBuild.Enable(RemoveSomeConditionEnabled.Value);
|
||||
NoConditionEnabled.SettingChanged += (_, _) => NoConditionBuild.Enable(NoConditionEnabled.Value);
|
||||
NoCollisionEnabled.SettingChanged += (_, _) => NoCollisionValueChanged();
|
||||
BeltSignalGeneratorEnabled.SettingChanged += (_, _) => BeltSignalGeneratorValueChanged();
|
||||
BeltSignalGeneratorEnabled.SettingChanged += (_, _) => BeltSignalGenerator.Enable(BeltSignalGeneratorEnabled.Value);
|
||||
BeltSignalNumberAltFormat.SettingChanged += (_, _) => { BeltSignalGenerator.OnAltFormatChanged(); };
|
||||
NightLightEnabled.SettingChanged += (_, _) => NightLightValueChanged();
|
||||
RemovePowerSpaceLimitEnabled.SettingChanged += (_, _) => RemovePowerSpaceLimitValueChanged();
|
||||
BoostWindPowerEnabled.SettingChanged += (_, _) => BoostWindPowerValueChanged();
|
||||
BoostSolarPowerEnabled.SettingChanged += (_, _) => BoostSolarPowerValueChanged();
|
||||
BoostFuelPowerEnabled.SettingChanged += (_, _) => BoostFuelPowerValueChanged();
|
||||
BoostGeothermalPowerEnabled.SettingChanged += (_, _) => BoostGeothermalPowerValueChanged();
|
||||
ImmediateValueChanged();
|
||||
ArchitectModeValueChanged();
|
||||
UnlimitInteractiveValueChanged();
|
||||
RemoveSomeConditionValueChanged();
|
||||
NoConditionValueChanged();
|
||||
NightLightEnabled.SettingChanged += (_, _) => NightLight.Enable(NightLightEnabled.Value);
|
||||
RemovePowerSpaceLimitEnabled.SettingChanged += (_, _) => RemovePowerSpaceLimit.Enable(RemovePowerSpaceLimitEnabled.Value);
|
||||
BoostWindPowerEnabled.SettingChanged += (_, _) => BoostWindPower.Enable(BoostWindPowerEnabled.Value);
|
||||
BoostSolarPowerEnabled.SettingChanged += (_, _) => BoostSolarPower.Enable(BoostSolarPowerEnabled.Value);
|
||||
BoostFuelPowerEnabled.SettingChanged += (_, _) => BoostFuelPower.Enable(BoostFuelPowerEnabled.Value);
|
||||
BoostGeothermalPowerEnabled.SettingChanged += (_, _) => BoostGeothermalPower.Enable(BoostGeothermalPowerEnabled.Value);
|
||||
ImmediateBuild.Enable(ImmediateEnabled.Value);
|
||||
ArchitectMode.Enable(ArchitectModeEnabled.Value);
|
||||
UnlimitInteractive.Enable(UnlimitInteractiveEnabled.Value);
|
||||
RemoveSomeConditionBuild.Enable(RemoveSomeConditionEnabled.Value);
|
||||
NoConditionBuild.Enable(NoConditionEnabled.Value);
|
||||
NoCollisionValueChanged();
|
||||
BeltSignalGeneratorValueChanged();
|
||||
NightLightValueChanged();
|
||||
RemovePowerSpaceLimitValueChanged();
|
||||
BoostWindPowerValueChanged();
|
||||
BoostSolarPowerValueChanged();
|
||||
BoostFuelPowerValueChanged();
|
||||
BoostGeothermalPowerValueChanged();
|
||||
BeltSignalGenerator.Enable(BeltSignalGeneratorEnabled.Value);
|
||||
NightLight.Enable(NightLightEnabled.Value);
|
||||
RemovePowerSpaceLimit.Enable(RemovePowerSpaceLimitEnabled.Value);
|
||||
BoostWindPower.Enable(BoostWindPowerEnabled.Value);
|
||||
BoostSolarPower.Enable(BoostSolarPowerEnabled.Value);
|
||||
BoostFuelPower.Enable(BoostFuelPowerEnabled.Value);
|
||||
BoostGeothermalPower.Enable(BoostGeothermalPowerEnabled.Value);
|
||||
_factoryPatch = Harmony.CreateAndPatchAll(typeof(FactoryPatch));
|
||||
}
|
||||
|
||||
@@ -78,31 +78,6 @@ public static class FactoryPatch
|
||||
BoostGeothermalPower.Enable(false);
|
||||
}
|
||||
|
||||
private static void ImmediateValueChanged()
|
||||
{
|
||||
ImmediateBuild.Enable(ImmediateEnabled.Value);
|
||||
}
|
||||
|
||||
private static void ArchitectModeValueChanged()
|
||||
{
|
||||
ArchitectMode.Enable(ArchitectModeEnabled.Value);
|
||||
}
|
||||
|
||||
private static void UnlimitInteractiveValueChanged()
|
||||
{
|
||||
UnlimitInteractive.Enable(UnlimitInteractiveEnabled.Value);
|
||||
}
|
||||
|
||||
private static void RemoveSomeConditionValueChanged()
|
||||
{
|
||||
RemoveSomeConditionBuild.Enable(RemoveSomeConditionEnabled.Value);
|
||||
}
|
||||
|
||||
private static void NoConditionValueChanged()
|
||||
{
|
||||
NoConditionBuild.Enable(NoConditionEnabled.Value);
|
||||
}
|
||||
|
||||
private static void NoCollisionValueChanged()
|
||||
{
|
||||
var coll = ColliderPool.instance;
|
||||
@@ -112,41 +87,6 @@ public static class FactoryPatch
|
||||
obj.gameObject.SetActive(!NoCollisionEnabled.Value);
|
||||
}
|
||||
|
||||
private static void BeltSignalGeneratorValueChanged()
|
||||
{
|
||||
BeltSignalGenerator.Enable(BeltSignalGeneratorEnabled.Value);
|
||||
}
|
||||
|
||||
private static void NightLightValueChanged()
|
||||
{
|
||||
NightLight.Enable(NightLightEnabled.Value);
|
||||
}
|
||||
|
||||
private static void RemovePowerSpaceLimitValueChanged()
|
||||
{
|
||||
RemovePowerSpaceLimit.Enable(RemovePowerSpaceLimitEnabled.Value);
|
||||
}
|
||||
|
||||
private static void BoostWindPowerValueChanged()
|
||||
{
|
||||
BoostWindPower.Enable(BoostWindPowerEnabled.Value);
|
||||
}
|
||||
|
||||
private static void BoostSolarPowerValueChanged()
|
||||
{
|
||||
BoostSolarPower.Enable(BoostSolarPowerEnabled.Value);
|
||||
}
|
||||
|
||||
private static void BoostFuelPowerValueChanged()
|
||||
{
|
||||
BoostFuelPower.Enable(BoostFuelPowerEnabled.Value);
|
||||
}
|
||||
|
||||
private static void BoostGeothermalPowerValueChanged()
|
||||
{
|
||||
BoostGeothermalPower.Enable(BoostGeothermalPowerEnabled.Value);
|
||||
}
|
||||
|
||||
public static void ArrivePlanet(PlanetFactory factory)
|
||||
{
|
||||
var imm = ImmediateEnabled.Value;
|
||||
|
||||
@@ -12,21 +12,16 @@ public static class PlanetFunctions
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
PlayerActionsInGlobeViewEnabled.SettingChanged += (_, _) => PlayerActionInGlobeViewValueChanged();
|
||||
PlayerActionInGlobeViewValueChanged();
|
||||
PlayerActionsInGlobeViewEnabled.SettingChanged += (_, _) => PlayerActionsInGlobeView.Enable(PlayerActionsInGlobeViewEnabled.Value);
|
||||
PlayerActionsInGlobeView.Enable(PlayerActionsInGlobeViewEnabled.Value);
|
||||
}
|
||||
|
||||
public static void Uninit()
|
||||
{
|
||||
PlayerActionInGlobeView.Enable(false);
|
||||
PlayerActionsInGlobeView.Enable(false);
|
||||
}
|
||||
|
||||
private static void PlayerActionInGlobeViewValueChanged()
|
||||
{
|
||||
PlayerActionInGlobeView.Enable(PlayerActionsInGlobeViewEnabled.Value);
|
||||
}
|
||||
|
||||
public static class PlayerActionInGlobeView
|
||||
public static class PlayerActionsInGlobeView
|
||||
{
|
||||
private static Harmony _patch;
|
||||
|
||||
@@ -34,7 +29,7 @@ public static class PlanetFunctions
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(PlayerActionInGlobeView));
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(PlayerActionsInGlobeView));
|
||||
return;
|
||||
}
|
||||
_patch?.UnpatchSelf();
|
||||
|
||||
@@ -7,71 +7,40 @@ namespace CheatEnabler;
|
||||
|
||||
public static class ResourcePatch
|
||||
{
|
||||
public static ConfigEntry<bool> InfiniteEnabled;
|
||||
public static ConfigEntry<bool> FastEnabled;
|
||||
private static Harmony _infinitePatch;
|
||||
private static Harmony _fastPatch;
|
||||
public static ConfigEntry<bool> InfiniteResourceEnabled;
|
||||
public static ConfigEntry<bool> FastMiningEnabled;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
InfiniteEnabled.SettingChanged += (_, _) => InfiniteValueChanged();
|
||||
FastEnabled.SettingChanged += (_, _) => FastValueChanged();
|
||||
InfiniteValueChanged();
|
||||
FastValueChanged();
|
||||
InfiniteResourceEnabled.SettingChanged += (_, _) => InfiniteResource.Enable(InfiniteResourceEnabled.Value);
|
||||
FastMiningEnabled.SettingChanged += (_, _) => FastMining.Enable(FastMiningEnabled.Value);
|
||||
InfiniteResource.Enable(InfiniteResourceEnabled.Value);
|
||||
FastMining.Enable(FastMiningEnabled.Value);
|
||||
}
|
||||
|
||||
public static void Uninit()
|
||||
{
|
||||
if (_infinitePatch != null)
|
||||
{
|
||||
_infinitePatch.UnpatchSelf();
|
||||
_infinitePatch = null;
|
||||
}
|
||||
|
||||
if (_fastPatch != null)
|
||||
{
|
||||
_fastPatch.UnpatchSelf();
|
||||
_fastPatch = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static void InfiniteValueChanged()
|
||||
{
|
||||
if (InfiniteEnabled.Value)
|
||||
{
|
||||
if (_infinitePatch != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_infinitePatch = Harmony.CreateAndPatchAll(typeof(InfiniteResource));
|
||||
}
|
||||
else if (_infinitePatch != null)
|
||||
{
|
||||
_infinitePatch.UnpatchSelf();
|
||||
_infinitePatch = null;
|
||||
}
|
||||
}
|
||||
private static void FastValueChanged()
|
||||
{
|
||||
if (FastEnabled.Value)
|
||||
{
|
||||
if (_fastPatch != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_fastPatch = Harmony.CreateAndPatchAll(typeof(FastMining));
|
||||
}
|
||||
else if (_fastPatch != null)
|
||||
{
|
||||
_fastPatch.UnpatchSelf();
|
||||
_fastPatch = null;
|
||||
}
|
||||
InfiniteResource.Enable(false);
|
||||
FastMining.Enable(false);
|
||||
}
|
||||
|
||||
private static class InfiniteResource
|
||||
{
|
||||
private static Harmony _patch;
|
||||
|
||||
public static void Enable(bool on)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(InfiniteResource));
|
||||
}
|
||||
else
|
||||
{
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(FactorySystem), "GameTick", typeof(long), typeof(bool))]
|
||||
[HarmonyPatch(typeof(FactorySystem), "GameTick", typeof(long), typeof(bool), typeof(int), typeof(int),
|
||||
@@ -103,6 +72,21 @@ public static class ResourcePatch
|
||||
|
||||
private static class FastMining
|
||||
{
|
||||
private static Harmony _patch;
|
||||
|
||||
public static void Enable(bool on)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(FastMining));
|
||||
}
|
||||
else
|
||||
{
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(FactorySystem), "GameTick", typeof(long), typeof(bool))]
|
||||
[HarmonyPatch(typeof(FactorySystem), "GameTick", typeof(long), typeof(bool), typeof(int), typeof(int),
|
||||
|
||||
@@ -20,8 +20,7 @@ public static class TechPatch
|
||||
|
||||
public static void Uninit()
|
||||
{
|
||||
if (_patch == null) return;
|
||||
_patch.UnpatchSelf();
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
|
||||
@@ -29,16 +28,11 @@ public static class TechPatch
|
||||
{
|
||||
if (Enabled.Value)
|
||||
{
|
||||
if (_patch != null)
|
||||
{
|
||||
return;
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(TechPatch));
|
||||
}
|
||||
|
||||
_patch = Harmony.CreateAndPatchAll(typeof(TechPatch));
|
||||
}
|
||||
else if (_patch != null)
|
||||
else
|
||||
{
|
||||
_patch.UnpatchSelf();
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,7 @@ public static class TerraformPatch
|
||||
|
||||
public static void Uninit()
|
||||
{
|
||||
if (_patch == null) return;
|
||||
_patch.UnpatchSelf();
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
|
||||
@@ -27,16 +26,11 @@ public static class TerraformPatch
|
||||
{
|
||||
if (Enabled.Value)
|
||||
{
|
||||
if (_patch != null)
|
||||
{
|
||||
return;
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(TerraformPatch));
|
||||
}
|
||||
|
||||
_patch = Harmony.CreateAndPatchAll(typeof(TerraformPatch));
|
||||
}
|
||||
else if (_patch != null)
|
||||
else
|
||||
{
|
||||
_patch.UnpatchSelf();
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,9 +166,9 @@ public class UIConfigWindow : UI.MyWindowWithTabs
|
||||
y = 10f;
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab3, PlanetFunctions.PlayerActionsInGlobeViewEnabled, "Enable player actions in globe view");
|
||||
y += 36f;
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab3, ResourcePatch.InfiniteEnabled, "Infinite Natural Resources");
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab3, ResourcePatch.InfiniteResourceEnabled, "Infinite Natural Resources");
|
||||
y += 36f;
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab3, ResourcePatch.FastEnabled, "Fast Mining");
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab3, ResourcePatch.FastMiningEnabled, "Fast Mining");
|
||||
y += 36f;
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab3, WaterPumperPatch.Enabled, "Pump Anywhere");
|
||||
y += 36f;
|
||||
|
||||
@@ -17,8 +17,7 @@ public static class WaterPumperPatch
|
||||
|
||||
public static void Uninit()
|
||||
{
|
||||
if (_patch == null) return;
|
||||
_patch.UnpatchSelf();
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
|
||||
@@ -26,16 +25,11 @@ public static class WaterPumperPatch
|
||||
{
|
||||
if (Enabled.Value)
|
||||
{
|
||||
if (_patch != null)
|
||||
{
|
||||
return;
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(WaterPumperPatch));
|
||||
}
|
||||
|
||||
_patch = Harmony.CreateAndPatchAll(typeof(WaterPumperPatch));
|
||||
}
|
||||
else if (_patch != null)
|
||||
else
|
||||
{
|
||||
_patch.UnpatchSelf();
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user