mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2025-12-08 21:33:28 +08:00
WIP
This commit is contained in:
269
CheatEnabler/BuildPatch.cs
Normal file
269
CheatEnabler/BuildPatch.cs
Normal file
@@ -0,0 +1,269 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection.Emit;
|
||||
using BepInEx.Configuration;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace CheatEnabler;
|
||||
|
||||
public static class BuildPatch
|
||||
{
|
||||
public static ConfigEntry<bool> ImmediateEnabled;
|
||||
public static ConfigEntry<bool> NoCostEnabled;
|
||||
public static ConfigEntry<bool> NoConditionEnabled;
|
||||
public static ConfigEntry<bool> NoCollisionEnabled;
|
||||
|
||||
private static Harmony _patch;
|
||||
private static Harmony _noConditionPatch;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
ImmediateEnabled.SettingChanged += (_, _) => ImmediateValueChanged();
|
||||
NoCostEnabled.SettingChanged += (_, _) => NoCostValueChanged();
|
||||
NoConditionEnabled.SettingChanged += (_, _) => NoConditionValueChanged();
|
||||
NoCollisionEnabled.SettingChanged += (_, _) => NoCollisionValueChanged();
|
||||
ImmediateValueChanged();
|
||||
NoCostValueChanged();
|
||||
NoConditionValueChanged();
|
||||
NoCollisionValueChanged();
|
||||
_patch = Harmony.CreateAndPatchAll(typeof(BuildPatch));
|
||||
}
|
||||
|
||||
public static void Uninit()
|
||||
{
|
||||
if (_patch != null)
|
||||
{
|
||||
_patch.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
if (_noConditionPatch != null)
|
||||
{
|
||||
_noConditionPatch.UnpatchSelf();
|
||||
_noConditionPatch = null;
|
||||
}
|
||||
ImmediateBuild.Enable(false);
|
||||
NoCostBuild.Enable(false);
|
||||
}
|
||||
|
||||
private static void ImmediateValueChanged()
|
||||
{
|
||||
ImmediateBuild.Enable(ImmediateEnabled.Value);
|
||||
}
|
||||
private static void NoCostValueChanged()
|
||||
{
|
||||
NoCostBuild.Enable(NoCostEnabled.Value);
|
||||
}
|
||||
|
||||
private static void NoConditionValueChanged()
|
||||
{
|
||||
if (NoConditionEnabled.Value)
|
||||
{
|
||||
if (_noConditionPatch != null)
|
||||
{
|
||||
_noConditionPatch.UnpatchSelf();
|
||||
_noConditionPatch = null;
|
||||
}
|
||||
|
||||
_noConditionPatch = Harmony.CreateAndPatchAll(typeof(NoConditionBuild));
|
||||
}
|
||||
else if (_noConditionPatch != null)
|
||||
{
|
||||
_noConditionPatch.UnpatchSelf();
|
||||
_noConditionPatch = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static void NoCollisionValueChanged()
|
||||
{
|
||||
var coll = ColliderPool.instance;
|
||||
if (coll == null) return;
|
||||
var obj = coll.gameObject;
|
||||
if (obj == null) return;
|
||||
obj.gameObject.SetActive(!NoCollisionEnabled.Value);
|
||||
}
|
||||
|
||||
public static void ArrivePlanet(PlanetFactory factory)
|
||||
{
|
||||
var imm = ImmediateEnabled.Value;
|
||||
var noCost = NoCostEnabled.Value;
|
||||
if (!imm && !noCost) return;
|
||||
var prebuilds = factory.prebuildPool;
|
||||
if (imm) factory.BeginFlattenTerrain();
|
||||
for (var i = factory.prebuildCursor - 1; i > 0; i--)
|
||||
{
|
||||
if (prebuilds[i].id != i) continue;
|
||||
if (prebuilds[i].itemRequired > 0)
|
||||
{
|
||||
if (!noCost) continue;
|
||||
prebuilds[i].itemRequired = 0;
|
||||
if (imm)
|
||||
factory.BuildFinally(GameMain.mainPlayer, i, false);
|
||||
else
|
||||
factory.AlterPrebuildModelState(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (imm)
|
||||
factory.BuildFinally(GameMain.mainPlayer, i, false);
|
||||
}
|
||||
}
|
||||
if (imm) factory.EndFlattenTerrain();
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(PlanetData), nameof(PlanetData.NotifyFactoryLoaded))]
|
||||
private static void PlanetData_NotifyFactoryLoaded_Postfix(PlanetData __instance)
|
||||
{
|
||||
ArrivePlanet(__instance.factory);
|
||||
}
|
||||
|
||||
private static class ImmediateBuild
|
||||
{
|
||||
private static Harmony _immediatePatch;
|
||||
|
||||
public static void Enable(bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
if (_immediatePatch != null)
|
||||
{
|
||||
_immediatePatch.UnpatchSelf();
|
||||
_immediatePatch = null;
|
||||
}
|
||||
|
||||
var factory = GameMain.mainPlayer?.factory;
|
||||
if (factory != null)
|
||||
{
|
||||
ArrivePlanet(factory);
|
||||
}
|
||||
|
||||
_immediatePatch = Harmony.CreateAndPatchAll(typeof(ImmediateBuild));
|
||||
}
|
||||
else if (_immediatePatch != null)
|
||||
{
|
||||
_immediatePatch.UnpatchSelf();
|
||||
_immediatePatch = null;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(BuildTool_Addon), nameof(BuildTool_Addon.CreatePrebuilds))]
|
||||
[HarmonyPatch(typeof(BuildTool_BlueprintPaste), nameof(BuildTool_BlueprintPaste.CreatePrebuilds))]
|
||||
[HarmonyPatch(typeof(BuildTool_Click), nameof(BuildTool_Click.CreatePrebuilds))]
|
||||
[HarmonyPatch(typeof(BuildTool_Inserter), nameof(BuildTool_Inserter.CreatePrebuilds))]
|
||||
[HarmonyPatch(typeof(BuildTool_Path), nameof(BuildTool_Path.CreatePrebuilds))]
|
||||
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Call, AccessTools.Method(typeof(GC), nameof(GC.Collect)))
|
||||
).Insert(
|
||||
new CodeInstruction(OpCodes.Ldarg_0),
|
||||
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(BuildTool), nameof(BuildTool.factory))),
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(BuildPatch), nameof(BuildPatch.ArrivePlanet)))
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
|
||||
private static class NoCostBuild
|
||||
{
|
||||
private static Harmony _noCostPatch;
|
||||
private static bool[] _canBuildItems;
|
||||
|
||||
public static void Enable(bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
if (_noCostPatch != null)
|
||||
{
|
||||
_noCostPatch.UnpatchSelf();
|
||||
_noCostPatch = null;
|
||||
}
|
||||
|
||||
var factory = GameMain.mainPlayer?.factory;
|
||||
if (factory != null)
|
||||
{
|
||||
ArrivePlanet(factory);
|
||||
}
|
||||
|
||||
_noCostPatch = Harmony.CreateAndPatchAll(typeof(NoCostBuild));
|
||||
}
|
||||
else if (_noCostPatch != null)
|
||||
{
|
||||
_noCostPatch.UnpatchSelf();
|
||||
_noCostPatch = null;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(StorageComponent), nameof(StorageComponent.TakeTailItems), new [] { typeof(int), typeof(int), typeof(int), typeof(bool) }, new[] {ArgumentType.Ref, ArgumentType.Ref, ArgumentType.Out, ArgumentType.Normal})]
|
||||
[HarmonyPatch(typeof(StorageComponent), nameof(StorageComponent.TakeTailItems), new [] { typeof(int), typeof(int), typeof(int[]), typeof(int), typeof(bool) }, new[] {ArgumentType.Ref, ArgumentType.Ref, ArgumentType.Normal, ArgumentType.Out, ArgumentType.Normal})]
|
||||
public static bool TakeTailItemsPatch(StorageComponent __instance, int itemId)
|
||||
{
|
||||
if (__instance == null || __instance.id != GameMain.mainPlayer.package.id) return true;
|
||||
if (itemId <= 0) return true;
|
||||
if (_canBuildItems == null)
|
||||
{
|
||||
DoInit();
|
||||
}
|
||||
return itemId >= 10000 || !_canBuildItems[itemId];
|
||||
}
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(StorageComponent), "GetItemCount", new Type[] { typeof(int) })]
|
||||
public static void GetItemCountPatch(StorageComponent __instance, int itemId, ref int __result)
|
||||
{
|
||||
if (__result > 99) return;
|
||||
if (__instance == null || __instance.id != GameMain.mainPlayer.package.id) return;
|
||||
if (itemId <= 0) return;
|
||||
if (_canBuildItems == null)
|
||||
{
|
||||
DoInit();
|
||||
}
|
||||
if (itemId < 10000 && _canBuildItems[itemId]) __result = 100;
|
||||
}
|
||||
|
||||
private static void DoInit()
|
||||
{
|
||||
_canBuildItems = new bool[10000];
|
||||
foreach (var ip in LDB.items.dataArray)
|
||||
{
|
||||
if (ip.CanBuild && ip.ID < 10000) _canBuildItems[ip.ID] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class NoConditionBuild
|
||||
{
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(BuildTool_Addon), nameof(BuildTool_Addon.CheckBuildConditions))]
|
||||
// [HarmonyPatch(typeof(BuildTool_Click), nameof(BuildTool_Click.CheckBuildConditions))]
|
||||
[HarmonyPatch(typeof(BuildTool_Inserter), nameof(BuildTool_Inserter.CheckBuildConditions))]
|
||||
[HarmonyPatch(typeof(BuildTool_Path), nameof(BuildTool_Path.CheckBuildConditions))]
|
||||
private static IEnumerable<CodeInstruction> BuildTool_CheckBuildConditions_Transpiler(IEnumerable<CodeInstruction> instructions)
|
||||
{
|
||||
yield return new CodeInstruction(OpCodes.Ldc_I4_1);
|
||||
yield return new CodeInstruction(OpCodes.Ret);
|
||||
}
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(BuildTool_Click), nameof(BuildTool_Click.CheckBuildConditions))]
|
||||
private static IEnumerable<CodeInstruction> BuildTool_Click_CheckBuildConditions_Transpiler(IEnumerable<CodeInstruction> instructions)
|
||||
{
|
||||
yield return new CodeInstruction(OpCodes.Ldarg_0);
|
||||
yield return new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(NoConditionBuild), nameof(NoConditionBuild.CheckForMiner)));
|
||||
yield return new CodeInstruction(OpCodes.Ret);
|
||||
}
|
||||
|
||||
public static bool CheckForMiner(BuildTool tool)
|
||||
{
|
||||
var previews = tool.buildPreviews;
|
||||
foreach (var preview in previews)
|
||||
{
|
||||
var desc = preview?.item?.prefabDesc;
|
||||
if (desc == null) continue;
|
||||
if (desc.veinMiner || desc.oilMiner) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,14 @@ public class CheatEnabler : BaseUnityPlugin
|
||||
DevShortcuts.Enabled = Config.Bind("General", "DevShortcuts", true, "enable DevMode shortcuts");
|
||||
AbnormalDisabler.Enabled = Config.Bind("General", "DisableAbnormalChecks", false,
|
||||
"disable all abnormal checks");
|
||||
BuildPatch.ImmediateEnabled = Config.Bind("Build", "ImmediateBuild", false,
|
||||
"Build immediately");
|
||||
BuildPatch.NoCostEnabled = Config.Bind("Build", "InfiniteBuildings", false,
|
||||
"Infinite buildings");
|
||||
BuildPatch.NoConditionEnabled = Config.Bind("Build", "BuildWithoutCondition", false,
|
||||
"Build without condition");
|
||||
BuildPatch.NoCollisionEnabled = Config.Bind("Build", "NoCollision", false,
|
||||
"No collision");
|
||||
ResourcePatch.InfiniteEnabled = Config.Bind("Planet", "AlwaysInfiniteResource", false,
|
||||
"always infinite natural resource");
|
||||
ResourcePatch.FastEnabled = Config.Bind("Planet", "FastMining", false,
|
||||
@@ -40,6 +48,14 @@ public class CheatEnabler : BaseUnityPlugin
|
||||
"Can pump water anywhere (while water type is not None)");
|
||||
TerraformPatch.Enabled = Config.Bind("Planet", "TerraformAnyway", false,
|
||||
"Can do terraform without enough sands");
|
||||
DysonSpherePatch.SkipBulletEnabled = Config.Bind("DysonSphere", "SkipBullet", false,
|
||||
"Skip bullet");
|
||||
DysonSpherePatch.SkipAbsorbEnabled = Config.Bind("DysonSphere", "SkipAbsorb", false,
|
||||
"Skip absorption");
|
||||
DysonSpherePatch.QuickAbsortEnabled = Config.Bind("DysonSphere", "QuickAbsorb", false,
|
||||
"Quick absorb");
|
||||
DysonSpherePatch.EjectAnywayEnabled = Config.Bind("DysonSphere", "EjectAnyway", false,
|
||||
"Eject anyway");
|
||||
BirthPlanetPatch.SitiVeinsOnBirthPlanet = Config.Bind("Birth", "SiTiVeinsOnBirthPlanet", false,
|
||||
"Silicon/Titanium on birth planet");
|
||||
BirthPlanetPatch.FireIceOnBirthPlanet = Config.Bind("Birth", "FireIceOnBirthPlanet", false,
|
||||
@@ -73,9 +89,11 @@ public class CheatEnabler : BaseUnityPlugin
|
||||
|
||||
DevShortcuts.Init();
|
||||
AbnormalDisabler.Init();
|
||||
BuildPatch.Init();
|
||||
ResourcePatch.Init();
|
||||
WaterPumperPatch.Init();
|
||||
TerraformPatch.Init();
|
||||
DysonSpherePatch.Init();
|
||||
BirthPlanetPatch.Init();
|
||||
foreach (var idstr in _unlockTechToMaximumLevel.Split(','))
|
||||
{
|
||||
@@ -93,9 +111,11 @@ public class CheatEnabler : BaseUnityPlugin
|
||||
public void OnDestroy()
|
||||
{
|
||||
BirthPlanetPatch.Uninit();
|
||||
DysonSpherePatch.Uninit();
|
||||
TerraformPatch.Uninit();
|
||||
WaterPumperPatch.Uninit();
|
||||
ResourcePatch.Uninit();
|
||||
BuildPatch.Uninit();
|
||||
AbnormalDisabler.Uninit();
|
||||
DevShortcuts.Uninit();
|
||||
_patch?.UnpatchSelf();
|
||||
|
||||
234
CheatEnabler/DysonSpherePatch.cs
Normal file
234
CheatEnabler/DysonSpherePatch.cs
Normal file
@@ -0,0 +1,234 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection.Emit;
|
||||
using BepInEx.Configuration;
|
||||
using HarmonyLib;
|
||||
using PowerNetworkStructures;
|
||||
|
||||
namespace CheatEnabler;
|
||||
|
||||
public static class DysonSpherePatch
|
||||
{
|
||||
public static ConfigEntry<bool> SkipBulletEnabled;
|
||||
public static ConfigEntry<bool> SkipAbsorbEnabled;
|
||||
public static ConfigEntry<bool> QuickAbsortEnabled;
|
||||
public static ConfigEntry<bool> EjectAnywayEnabled;
|
||||
private static Harmony _skipBulletPatch;
|
||||
private static Harmony _skipAbsorbPatch;
|
||||
private static Harmony _quickAbsortPatch;
|
||||
private static Harmony _ejectAnywayPatch;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
SkipBulletEnabled.SettingChanged += (_, _) => SkipBulletValueChanged();
|
||||
SkipAbsorbEnabled.SettingChanged += (_, _) => SkipAbsorbValueChanged();
|
||||
QuickAbsortEnabled.SettingChanged += (_, _) => QuickAbsortValueChanged();
|
||||
EjectAnywayEnabled.SettingChanged += (_, _) => EjectAnywayValueChanged();
|
||||
SkipBulletValueChanged();
|
||||
SkipAbsorbValueChanged();
|
||||
QuickAbsortValueChanged();
|
||||
EjectAnywayValueChanged();
|
||||
}
|
||||
|
||||
public static void Uninit()
|
||||
{
|
||||
if (_skipBulletPatch != null)
|
||||
{
|
||||
_skipBulletPatch.UnpatchSelf();
|
||||
_skipBulletPatch = null;
|
||||
}
|
||||
if (_skipAbsorbPatch != null)
|
||||
{
|
||||
_skipAbsorbPatch.UnpatchSelf();
|
||||
_skipAbsorbPatch = null;
|
||||
}
|
||||
if (_quickAbsortPatch != null)
|
||||
{
|
||||
_quickAbsortPatch.UnpatchSelf();
|
||||
_quickAbsortPatch = null;
|
||||
}
|
||||
if (_ejectAnywayPatch != null)
|
||||
{
|
||||
_ejectAnywayPatch.UnpatchSelf();
|
||||
_ejectAnywayPatch = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static void SkipBulletValueChanged()
|
||||
{
|
||||
if (SkipBulletEnabled.Value)
|
||||
{
|
||||
if (_skipBulletPatch != null)
|
||||
{
|
||||
_skipBulletPatch.UnpatchSelf();
|
||||
_skipBulletPatch = null;
|
||||
}
|
||||
_skipBulletPatch = Harmony.CreateAndPatchAll(typeof(SkipBulletPatch));
|
||||
}
|
||||
else if (_skipBulletPatch != null)
|
||||
{
|
||||
_skipBulletPatch.UnpatchSelf();
|
||||
_skipBulletPatch = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static void SkipAbsorbValueChanged()
|
||||
{
|
||||
if (SkipAbsorbEnabled.Value)
|
||||
{
|
||||
if (_skipAbsorbPatch != null)
|
||||
{
|
||||
_skipAbsorbPatch.UnpatchSelf();
|
||||
_skipAbsorbPatch = null;
|
||||
}
|
||||
_skipAbsorbPatch = Harmony.CreateAndPatchAll(typeof(SkipAbsorbPatch));
|
||||
}
|
||||
else if (_skipAbsorbPatch != null)
|
||||
{
|
||||
_skipAbsorbPatch.UnpatchSelf();
|
||||
_skipAbsorbPatch = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static void QuickAbsortValueChanged()
|
||||
{
|
||||
if (QuickAbsortEnabled.Value)
|
||||
{
|
||||
if (_quickAbsortPatch != null)
|
||||
{
|
||||
_quickAbsortPatch.UnpatchSelf();
|
||||
_quickAbsortPatch = null;
|
||||
}
|
||||
_quickAbsortPatch = Harmony.CreateAndPatchAll(typeof(QuickAbsortPatch));
|
||||
}
|
||||
else if (_quickAbsortPatch != null)
|
||||
{
|
||||
_quickAbsortPatch.UnpatchSelf();
|
||||
_quickAbsortPatch = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static void EjectAnywayValueChanged()
|
||||
{
|
||||
if (EjectAnywayEnabled.Value)
|
||||
{
|
||||
if (_ejectAnywayPatch != null)
|
||||
{
|
||||
_ejectAnywayPatch.UnpatchSelf();
|
||||
_ejectAnywayPatch = null;
|
||||
}
|
||||
_ejectAnywayPatch = Harmony.CreateAndPatchAll(typeof(EjectAnywayPatch));
|
||||
}
|
||||
else if (_ejectAnywayPatch != null)
|
||||
{
|
||||
_ejectAnywayPatch.UnpatchSelf();
|
||||
_ejectAnywayPatch = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class SkipBulletPatch
|
||||
{
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(EjectorComponent), nameof(EjectorComponent.InternalUpdate))]
|
||||
private static IEnumerable<CodeInstruction> EjectorComponent_InternalUpdate_Patch(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
|
||||
private static class SkipAbsorbPatch
|
||||
{
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(DysonSwarm), nameof(DysonSwarm.AbsorbSail))]
|
||||
private static IEnumerable<CodeInstruction> DysonSwarm_AbsorbSail_Patch(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
var label1 = generator.DefineLabel();
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Stfld, AccessTools.Field(typeof(ExpiryOrder), nameof(ExpiryOrder.index)))
|
||||
).Advance(1).RemoveInstructions(matcher.Length - matcher.Pos).Insert(
|
||||
// node.cpOrdered = node.cpOrdered + 1;
|
||||
new CodeInstruction(OpCodes.Ldarg_1),
|
||||
new CodeInstruction(OpCodes.Ldarg_1),
|
||||
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(DysonNode), nameof(DysonNode.cpOrdered))),
|
||||
new CodeInstruction(OpCodes.Ldc_I4_1),
|
||||
new CodeInstruction(OpCodes.Add),
|
||||
new CodeInstruction(OpCodes.Stfld, AccessTools.Field(typeof(DysonNode), nameof(DysonNode.cpOrdered))),
|
||||
|
||||
// if (node.ConstructCp() != null)
|
||||
// {
|
||||
// this.dysonSphere.productRegister[11903]++;
|
||||
// }
|
||||
new CodeInstruction(OpCodes.Ldarg_1),
|
||||
new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(DysonNode), nameof(DysonNode.ConstructCp))),
|
||||
new CodeInstruction(OpCodes.Brfalse_S, label1),
|
||||
new CodeInstruction(OpCodes.Ldarg_0),
|
||||
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(DysonSwarm), nameof(DysonSwarm.dysonSphere))),
|
||||
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(DysonSphere), nameof(DysonSphere.productRegister))),
|
||||
new CodeInstruction(OpCodes.Ldc_I4, 11903),
|
||||
new CodeInstruction(OpCodes.Ldelema, typeof(int)),
|
||||
new CodeInstruction(OpCodes.Dup),
|
||||
new CodeInstruction(OpCodes.Ldind_I4),
|
||||
new CodeInstruction(OpCodes.Ldc_I4_1),
|
||||
new CodeInstruction(OpCodes.Add),
|
||||
new CodeInstruction(OpCodes.Stind_I4),
|
||||
|
||||
// this.RemoveSolarSail(index);
|
||||
new CodeInstruction(OpCodes.Ldarg_0).WithLabels(label1),
|
||||
new CodeInstruction(OpCodes.Ldloc_1),
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(DysonSwarm), nameof(DysonSwarm.RemoveSolarSail))),
|
||||
|
||||
// return false;
|
||||
new CodeInstruction(OpCodes.Ldc_I4_0),
|
||||
new CodeInstruction(OpCodes.Ret)
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
|
||||
private static class QuickAbsortPatch
|
||||
{
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(DysonSphereLayer), nameof(DysonSphereLayer.GameTick))]
|
||||
private static IEnumerable<CodeInstruction> DysonSphereLayer_GameTick_Patch(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
/* Remove `dysonNode.id % 120 == num` */
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldc_I4_S, 120)
|
||||
).Advance(-2).RemoveInstructions(6);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
|
||||
private static class EjectAnywayPatch
|
||||
{
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(EjectorComponent), nameof(EjectorComponent.InternalUpdate))]
|
||||
private static IEnumerable<CodeInstruction> EjectorComponent_InternalUpdate_Patch(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(EjectorComponent), nameof(EjectorComponent.localRot)))
|
||||
);
|
||||
var start = matcher.Pos - 6;
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.And)
|
||||
).Advance(1).MatchForward(false,
|
||||
new CodeMatch(OpCodes.And)
|
||||
);
|
||||
var end = matcher.Pos - 2;
|
||||
/* Remove angle checking codes, then add:
|
||||
* V_13 = this.bulletCount > 0;
|
||||
*/
|
||||
matcher.Start().Advance(start).RemoveInstructions(end - start).Insert(
|
||||
new CodeInstruction(OpCodes.Ldarg_0),
|
||||
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(EjectorComponent), nameof(EjectorComponent.bulletCount))),
|
||||
new CodeInstruction(OpCodes.Ldc_I4_0),
|
||||
new CodeInstruction(OpCodes.Cgt),
|
||||
new CodeInstruction(OpCodes.Stloc_S, 13)
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,10 +11,20 @@ public class UIConfigWindow : UI.MyWindowWithTabs
|
||||
I18N.Add("General", "General", "常规");
|
||||
I18N.Add("Enable Dev Shortcuts", "Enable Dev Shortcuts", "启用开发模式快捷键");
|
||||
I18N.Add("Disable Abnormal Checks", "Disable Abnormal Checks", "关闭数据异常检查");
|
||||
I18N.Add("Build", "Build", "建造");
|
||||
I18N.Add("Finish build immediately", "Finish build immediately", "建造秒完成");
|
||||
I18N.Add("Infinite buildings", "Infinite buildings", "无限建筑");
|
||||
I18N.Add("Build without condition", "Build without condition", "无条件建造");
|
||||
I18N.Add("No collision", "No collision", "无碰撞");
|
||||
I18N.Add("Planet", "Planet", "行星");
|
||||
I18N.Add("Infinite Natural Resources", "Infinite Natural Resources", "自然资源采集不消耗");
|
||||
I18N.Add("Fast Mining", "Fast Mining", "高速采集");
|
||||
I18N.Add("Pump Anywhere", "Pump Anywhere", "平地抽水");
|
||||
I18N.Add("Dyson Sphere", "Dyson Sphere", "戴森球");
|
||||
I18N.Add("Skip bullet period", "Skip bullet period", "跳过子弹阶段");
|
||||
I18N.Add("Skip absorption period", "Skip absorption period", "跳过吸收阶段");
|
||||
I18N.Add("Quick absorb", "Quick absorb", "快速吸收");
|
||||
I18N.Add("Eject anyway", "Eject anyway", "全球弹射");
|
||||
I18N.Add("Birth", "Birth Sys", "母星系");
|
||||
I18N.Add("Terraform without enought sands", "Terraform without enough sands", "沙土不够时依然可以整改地形");
|
||||
I18N.Add("Silicon/Titanium on birth planet", "Silicon/Titanium on birth planet", "母星有硅和钛");
|
||||
@@ -40,7 +50,7 @@ public class UIConfigWindow : UI.MyWindowWithTabs
|
||||
public override void _OnCreate()
|
||||
{
|
||||
_windowTrans = GetComponent<RectTransform>();
|
||||
_windowTrans.sizeDelta = new Vector2(480f, 331f);
|
||||
_windowTrans.sizeDelta = new Vector2(580f, 331f);
|
||||
|
||||
CreateUI();
|
||||
}
|
||||
@@ -55,30 +65,41 @@ public class UIConfigWindow : UI.MyWindowWithTabs
|
||||
y += 36f;
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab1, AbnormalDisabler.Enabled, "Disable Abnormal Checks".Translate());
|
||||
|
||||
// Planet Tab
|
||||
var tab2 = AddTab(136f, 1, _windowTrans, "Planet".Translate());
|
||||
var tab2 = AddTab(136f, 1, _windowTrans, "Build".Translate());
|
||||
x = 0f;
|
||||
y = 10f;
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab2, ResourcePatch.InfiniteEnabled, "Infinite Natural Resources".Translate());
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab2, BuildPatch.ImmediateEnabled, "Finish build immediately".Translate());
|
||||
y += 36f;
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab2, ResourcePatch.FastEnabled, "Fast Mining".Translate());
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab2, BuildPatch.NoCostEnabled, "Infinite buildings".Translate());
|
||||
y += 36f;
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab2, WaterPumperPatch.Enabled, "Pump Anywhere".Translate());
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab2, BuildPatch.NoConditionEnabled, "Build without condition".Translate());
|
||||
y += 36f;
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab2, TerraformPatch.Enabled, "Terraform without enought sands".Translate());
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab2, BuildPatch.NoCollisionEnabled, "No collision".Translate());
|
||||
|
||||
// Planet Tab
|
||||
var tab3 = AddTab(236f, 2, _windowTrans, "Planet".Translate());
|
||||
x = 0f;
|
||||
y = 10f;
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab3, ResourcePatch.InfiniteEnabled, "Infinite Natural Resources".Translate());
|
||||
y += 36f;
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab3, ResourcePatch.FastEnabled, "Fast Mining".Translate());
|
||||
y += 36f;
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab3, WaterPumperPatch.Enabled, "Pump Anywhere".Translate());
|
||||
y += 36f;
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab3, TerraformPatch.Enabled, "Terraform without enought sands".Translate());
|
||||
x = 300f;
|
||||
y = 10f;
|
||||
AddButton(x, y, tab2, "矿物掩埋标题", 16, "button-bury-all", () =>
|
||||
AddButton(x, y, tab3, "矿物掩埋标题", 16, "button-bury-all", () =>
|
||||
{
|
||||
PlanetFunctions.BuryAllVeins(true);
|
||||
});
|
||||
y += 36f;
|
||||
AddButton(x, y, tab2, "矿物还原标题", 16, "button-bury-restore-all", () =>
|
||||
AddButton(x, y, tab3, "矿物还原标题", 16, "button-bury-restore-all", () =>
|
||||
{
|
||||
PlanetFunctions.BuryAllVeins(false);
|
||||
});
|
||||
y += 36f;
|
||||
AddButton(x, y, tab2, "铺满地基提示", 16, "button-reform-all", () =>
|
||||
AddButton(x, y, tab3, "铺满地基提示", 16, "button-reform-all", () =>
|
||||
{
|
||||
var player = GameMain.mainPlayer;
|
||||
if (player == null) return;
|
||||
@@ -88,46 +109,57 @@ public class UIConfigWindow : UI.MyWindowWithTabs
|
||||
GameMain.localPlanet.factory.PlanetReformAll(reformTool.brushType, reformTool.brushColor, reformTool.buryVeins);
|
||||
});
|
||||
y += 36f;
|
||||
AddButton(x, y, tab2, "还原地形提示", 16, "button-reform-revert-all", () =>
|
||||
AddButton(x, y, tab3, "还原地形提示", 16, "button-reform-revert-all", () =>
|
||||
{
|
||||
var factory = GameMain.localPlanet?.factory;
|
||||
if (factory == null) return;
|
||||
GameMain.localPlanet.factory.PlanetReformRevert();
|
||||
});
|
||||
y += 36f;
|
||||
AddButton(x, y, tab2, "Initialize This Planet", 16, "button-init-planet", () =>
|
||||
AddButton(x, y, tab3, "Initialize This Planet", 16, "button-init-planet", () =>
|
||||
{
|
||||
PlanetFunctions.RecreatePlanet(true);
|
||||
});
|
||||
y += 36f;
|
||||
AddButton(x, y, tab2, "Dismantle All Buildings", 16, "button-dismantle-all", () =>
|
||||
AddButton(x, y, tab3, "Dismantle All Buildings", 16, "button-dismantle-all", () =>
|
||||
{
|
||||
PlanetFunctions.DismantleAll(false);
|
||||
});
|
||||
|
||||
var tab3 = AddTab(236f, 2, _windowTrans, "Birth".Translate());
|
||||
var tab4 = AddTab(336f, 3, _windowTrans, "Dyson Sphere".Translate());
|
||||
x = 0f;
|
||||
y = 10f;
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab3, BirthPlanetPatch.SitiVeinsOnBirthPlanet, "Silicon/Titanium on birth planet".Translate());
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.SkipBulletEnabled, "Skip bullet period".Translate());
|
||||
y += 36f;
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab3, BirthPlanetPatch.FireIceOnBirthPlanet, "Fire ice on birth planet".Translate());
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.SkipAbsorbEnabled, "Skip absorption period".Translate());
|
||||
y += 36f;
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab3, BirthPlanetPatch.KimberliteOnBirthPlanet, "Kimberlite on birth planet".Translate());
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.QuickAbsortEnabled, "Quick absorb".Translate());
|
||||
y += 36f;
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab3, BirthPlanetPatch.FractalOnBirthPlanet, "Fractal silicon on birth planet".Translate());
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.EjectAnywayEnabled, "Eject anyway".Translate());
|
||||
|
||||
var tab5 = AddTab(436f, 4, _windowTrans, "Birth".Translate());
|
||||
x = 0f;
|
||||
y = 10f;
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab5, BirthPlanetPatch.SitiVeinsOnBirthPlanet, "Silicon/Titanium on birth planet".Translate());
|
||||
y += 36f;
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab3, BirthPlanetPatch.OrganicOnBirthPlanet, "Organic crystal on birth planet".Translate());
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab5, BirthPlanetPatch.FireIceOnBirthPlanet, "Fire ice on birth planet".Translate());
|
||||
y += 36f;
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab5, BirthPlanetPatch.KimberliteOnBirthPlanet, "Kimberlite on birth planet".Translate());
|
||||
y += 36f;
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab5, BirthPlanetPatch.FractalOnBirthPlanet, "Fractal silicon on birth planet".Translate());
|
||||
y += 36f;
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab5, BirthPlanetPatch.OrganicOnBirthPlanet, "Organic crystal on birth planet".Translate());
|
||||
x = 200f;
|
||||
y = 10f;
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab3, BirthPlanetPatch.OpticalOnBirthPlanet, "Optical grating crystal on birth planet".Translate());
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab5, BirthPlanetPatch.OpticalOnBirthPlanet, "Optical grating crystal on birth planet".Translate());
|
||||
y += 36f;
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab3, BirthPlanetPatch.SpiniformOnBirthPlanet, "Spiniform stalagmite crystal on birth planet".Translate());
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab5, BirthPlanetPatch.SpiniformOnBirthPlanet, "Spiniform stalagmite crystal on birth planet".Translate());
|
||||
y += 36f;
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab3, BirthPlanetPatch.UnipolarOnBirthPlanet, "Unipolar magnet on birth planet".Translate());
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab5, BirthPlanetPatch.UnipolarOnBirthPlanet, "Unipolar magnet on birth planet".Translate());
|
||||
y += 36f;
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab3, BirthPlanetPatch.FlatBirthPlanet, "Birth planet is solid flat (no water at all)".Translate());
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab5, BirthPlanetPatch.FlatBirthPlanet, "Birth planet is solid flat (no water at all)".Translate());
|
||||
y += 36f;
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab3, BirthPlanetPatch.HighLuminosityBirthStar, "Birth star has high luminosity".Translate());
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab5, BirthPlanetPatch.HighLuminosityBirthStar, "Birth star has high luminosity".Translate());
|
||||
SetCurrentTab(0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user