mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2025-12-09 12:53:34 +08:00
UXAssist and CheatEnabler release
This commit is contained in:
@@ -48,6 +48,8 @@ public class CheatEnabler : BaseUnityPlugin
|
||||
"Can pump water anywhere (while water type is not None)");
|
||||
PlanetPatch.TerraformAnywayEnabled = Config.Bind("Planet", "TerraformAnyway", false,
|
||||
"Can do terraform without enough soil piless");
|
||||
PlayerPatch.InstantTeleportEnabled = Config.Bind("Player", "InstantTeleport", false,
|
||||
"Enable instant teleport (like that in Sandbox mode)");
|
||||
DysonSpherePatch.SkipBulletEnabled = Config.Bind("DysonSphere", "SkipBullet", false,
|
||||
"Skip bullet");
|
||||
DysonSpherePatch.SkipAbsorbEnabled = Config.Bind("DysonSphere", "SkipAbsorb", false,
|
||||
@@ -60,7 +62,11 @@ public class CheatEnabler : BaseUnityPlugin
|
||||
"Overclock ejector");
|
||||
DysonSpherePatch.OverclockSiloEnabled = Config.Bind("DysonSphere", "OverclockSilo", false,
|
||||
"Overclock silo");
|
||||
|
||||
CombatPatch.MechaInvincibleEnabled = Config.Bind("Battle", "MechaInvincible", false,
|
||||
"Mecha and Drones/Fleets invincible");
|
||||
CombatPatch.BuildingsInvincibleEnabled = Config.Bind("Battle", "BuildingsInvincible", false,
|
||||
"Buildings invincible");
|
||||
|
||||
UIConfigWindow.Init();
|
||||
|
||||
DevShortcuts.Init();
|
||||
@@ -69,12 +75,16 @@ public class CheatEnabler : BaseUnityPlugin
|
||||
FactoryPatch.Init();
|
||||
ResourcePatch.Init();
|
||||
PlanetPatch.Init();
|
||||
PlayerPatch.Init();
|
||||
DysonSpherePatch.Init();
|
||||
CombatPatch.Init();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
CombatPatch.Uninit();
|
||||
DysonSpherePatch.Uninit();
|
||||
PlayerPatch.Uninit();
|
||||
PlanetPatch.Uninit();
|
||||
ResourcePatch.Uninit();
|
||||
FactoryPatch.Uninit();
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
<BepInExPluginGuid>org.soardev.cheatenabler</BepInExPluginGuid>
|
||||
<Description>DSP MOD - CheatEnabler</Description>
|
||||
<Version>2.3.14</Version>
|
||||
<Version>2.3.15</Version>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<PackageId>CheatEnabler</PackageId>
|
||||
|
||||
113
CheatEnabler/CombatPatch.cs
Normal file
113
CheatEnabler/CombatPatch.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using BepInEx.Configuration;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace CheatEnabler;
|
||||
|
||||
public static class CombatPatch
|
||||
{
|
||||
public static ConfigEntry<bool> MechaInvincibleEnabled;
|
||||
public static ConfigEntry<bool> BuildingsInvincibleEnabled;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
MechaInvincibleEnabled.SettingChanged += (_, _) => MechaInvincible.Enable(MechaInvincibleEnabled.Value);
|
||||
BuildingsInvincibleEnabled.SettingChanged += (_, _) => BuildingsInvincible.Enable(BuildingsInvincibleEnabled.Value);
|
||||
MechaInvincible.Enable(MechaInvincibleEnabled.Value);
|
||||
BuildingsInvincible.Enable(BuildingsInvincibleEnabled.Value);
|
||||
}
|
||||
|
||||
public static void Uninit()
|
||||
{
|
||||
BuildingsInvincible.Enable(false);
|
||||
MechaInvincible.Enable(false);
|
||||
}
|
||||
|
||||
private static class MechaInvincible
|
||||
{
|
||||
private static Harmony _patch;
|
||||
|
||||
public static void Enable(bool on)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(MechaInvincible));
|
||||
}
|
||||
else
|
||||
{
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(Player), nameof(Player.invincible), MethodType.Getter)]
|
||||
private static IEnumerable<CodeInstruction> Player_get_invincible_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.Start().RemoveInstructions(matcher.Length).Insert(
|
||||
new CodeInstruction(OpCodes.Ldc_I4_1),
|
||||
new CodeInstruction(OpCodes.Ret)
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(SkillSystem), nameof(SkillSystem.DamageGroundObjectByLocalCaster))]
|
||||
[HarmonyPatch(typeof(SkillSystem), nameof(SkillSystem.DamageGroundObjectByRemoteCaster))]
|
||||
[HarmonyPatch(typeof(SkillSystem), nameof(SkillSystem.DamageObject))]
|
||||
private static IEnumerable<CodeInstruction> SkillSystem_DamageObject_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator, MethodBase __originalMethod)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(ci => ci.IsLdarg()),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(SkillTargetLocal), nameof(SkillTargetLocal.type))),
|
||||
new CodeMatch(OpCodes.Ldc_I4_6),
|
||||
new CodeMatch(ci => ci.opcode == OpCodes.Bne_Un || ci.opcode == OpCodes.Bne_Un_S)
|
||||
);
|
||||
matcher.Repeat(m => m.Advance(4).InsertAndAdvance(
|
||||
new CodeInstruction(OpCodes.Ldc_I4_0),
|
||||
new CodeInstruction(OpCodes.Starg_S, __originalMethod.Name == "DamageObject" ? 1 : 2)
|
||||
));
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
|
||||
private static class BuildingsInvincible
|
||||
{
|
||||
private static Harmony _patch;
|
||||
|
||||
public static void Enable(bool on)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(BuildingsInvincible));
|
||||
}
|
||||
else
|
||||
{
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(SkillSystem), nameof(SkillSystem.DamageGroundObjectByLocalCaster))]
|
||||
[HarmonyPatch(typeof(SkillSystem), nameof(SkillSystem.DamageGroundObjectByRemoteCaster))]
|
||||
private static IEnumerable<CodeInstruction> SkillSystem_DamageObject_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(ci => ci.IsLdarg()),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(SkillTargetLocal), nameof(SkillTargetLocal.type))),
|
||||
new CodeMatch(ci => ci.opcode == OpCodes.Brtrue || ci.opcode == OpCodes.Brtrue_S),
|
||||
new CodeMatch(OpCodes.Ldarg_1)
|
||||
).Advance(3).Insert(
|
||||
new CodeInstruction(OpCodes.Ldc_I4_0),
|
||||
new CodeInstruction(OpCodes.Starg_S, 2)
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -390,6 +390,7 @@ public static class FactoryPatch
|
||||
}
|
||||
|
||||
[HarmonyTranspiler, HarmonyPriority(Priority.Last)]
|
||||
[HarmonyPatch(typeof(BuildTool_BlueprintPaste), nameof(BuildTool_BlueprintPaste.CheckBuildConditions))]
|
||||
[HarmonyPatch(typeof(BuildTool_Click), nameof(BuildTool_Click.CheckBuildConditions))]
|
||||
private static IEnumerable<CodeInstruction> BuildTool_Click_CheckBuildConditions_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
|
||||
@@ -42,8 +42,8 @@ public static class PlanetPatch
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(BuildTool_BlueprintPaste), "CheckBuildConditions")]
|
||||
[HarmonyPatch(typeof(BuildTool_Click), "CheckBuildConditions")]
|
||||
[HarmonyPatch(typeof(BuildTool_BlueprintPaste), nameof(BuildTool_BlueprintPaste.CheckBuildConditions))]
|
||||
[HarmonyPatch(typeof(BuildTool_Click), nameof(BuildTool_Click.CheckBuildConditions))]
|
||||
private static IEnumerable<CodeInstruction> BuildTool_CheckBuildConditions_Transpiler(
|
||||
IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
|
||||
60
CheatEnabler/PlayerPatch.cs
Normal file
60
CheatEnabler/PlayerPatch.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection.Emit;
|
||||
using BepInEx.Configuration;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace CheatEnabler;
|
||||
|
||||
public static class PlayerPatch
|
||||
{
|
||||
public static ConfigEntry<bool> InstantTeleportEnabled;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
InstantTeleportEnabled.SettingChanged += (_, _) => InstantTeleport.Enable(InstantTeleportEnabled.Value);
|
||||
InstantTeleport.Enable(InstantTeleportEnabled.Value);
|
||||
}
|
||||
|
||||
public static void Uninit()
|
||||
{
|
||||
InstantTeleport.Enable(false);
|
||||
}
|
||||
|
||||
private static class InstantTeleport
|
||||
{
|
||||
private static Harmony _patch;
|
||||
|
||||
public static void Enable(bool on)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
_patch ??= Harmony.CreateAndPatchAll(typeof(InstantTeleport));
|
||||
}
|
||||
else
|
||||
{
|
||||
_patch?.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(UIGlobemap), nameof(UIGlobemap._OnUpdate))]
|
||||
[HarmonyPatch(typeof(UIStarmap), nameof(UIStarmap.DoRightClickFastTravel))]
|
||||
[HarmonyPatch(typeof(UIStarmap), nameof(UIStarmap.OnFastTravelButtonClick))]
|
||||
[HarmonyPatch(typeof(UIStarmap), nameof(UIStarmap.OnScreenClick))]
|
||||
[HarmonyPatch(typeof(UIStarmap), nameof(UIStarmap.SandboxRightClickFastTravelLogic))]
|
||||
[HarmonyPatch(typeof(UIStarmap), nameof(UIStarmap.StartFastTravelToPlanet))]
|
||||
[HarmonyPatch(typeof(UIStarmap), nameof(UIStarmap.StartFastTravelToUPosition))]
|
||||
[HarmonyPatch(typeof(UIStarmap), nameof(UIStarmap.UpdateCursorView))]
|
||||
[HarmonyPatch(typeof(UIStarmap), nameof(UIStarmap._OnUpdate))]
|
||||
private static IEnumerable<CodeInstruction> UIGlobemap__OnUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Call, AccessTools.PropertyGetter(typeof(GameMain), nameof(GameMain.sandboxToolsEnabled)))
|
||||
);
|
||||
matcher.Repeat(cm => cm.SetAndAdvance(OpCodes.Ldc_I4_1, null));
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,11 @@
|
||||
#### 添加一些作弊功能,同时屏蔽异常检测
|
||||
|
||||
## Changlog
|
||||
* 2.3.15
|
||||
+ New features:
|
||||
- `Instant teleport (like that in Sandbox mode)`
|
||||
- `Mecha and Drones/Fleets invicible`
|
||||
- `Buildings invicible`
|
||||
* 2.3.14
|
||||
+ Remove default shortcut key for `No condition build` and `No collision`, to avoid misoperation. You can still set them in system settings window manually if needed.
|
||||
+ Fix translation issue.
|
||||
@@ -117,11 +122,15 @@
|
||||
+ Fast Mining
|
||||
+ Pump Anywhere
|
||||
+ Terraform without enought soil piles
|
||||
+ Instant teleport (like that in Sandbox mode)
|
||||
+ Dyson Sphere:
|
||||
+ Skip bullet period
|
||||
+ Skip absorption period
|
||||
+ Quick absorb
|
||||
+ Eject anyway
|
||||
+ Combat:
|
||||
+ Mecha and Drones/Fleets invicible
|
||||
+ Buildings invicible
|
||||
|
||||
## Notes
|
||||
* Please upgrade `BepInEx` 5.4.21 or later if using with [BlueprintTweaks](https://dsp.thunderstore.io/package/kremnev8/BlueprintTweaks/) to avoid possible conflicts.
|
||||
@@ -134,6 +143,11 @@
|
||||
* [Multifunction_mod](https://github.com/blacksnipebiu/Multifunction_mod): Some cheat functions
|
||||
|
||||
## 更新日志
|
||||
* 2.3.15
|
||||
+ 新功能:
|
||||
- `快速传送(和沙盒模式一样)`
|
||||
- `机甲和战斗无人机无敌`
|
||||
- `建筑无敌`
|
||||
* 2.3.14
|
||||
+ 移除了`无条件建造`和`无碰撞`的默认快捷键,以避免误操作。如有需要请手动在系统选项窗口中设置。
|
||||
+ 修复了翻译问题。
|
||||
@@ -247,11 +261,15 @@
|
||||
+ 高速采集
|
||||
+ 平地抽水
|
||||
+ 沙土不够时依然可以整改地形
|
||||
+ 快速传送(和沙盒模式一样)
|
||||
+ 戴森球:
|
||||
+ 跳过子弹阶段
|
||||
+ 跳过吸收阶段
|
||||
+ 快速吸收
|
||||
+ 全球弹射
|
||||
+ 战斗:
|
||||
+ 机甲和战斗无人机无敌
|
||||
+ 建筑无敌
|
||||
|
||||
## 注意事项
|
||||
* 如果和[BlueprintTweaks](https://dsp.thunderstore.io/package/kremnev8/BlueprintTweaks/)一起使用,请升级`BepInEx`到5.4.21或更高版本,以避免可能的冲突
|
||||
|
||||
@@ -53,6 +53,9 @@ public static class UIConfigWindow
|
||||
I18N.Add("Overclock Ejectors", "Overclock Ejectors (10x)", "高速弹射器(10倍射速)");
|
||||
I18N.Add("Overclock Silos", "Overclock Silos (10x)", "高速发射井(10倍射速)");
|
||||
I18N.Add("Terraform without enough soil piles", "Terraform without enough soil piles", "沙土不够时依然可以整改地形");
|
||||
I18N.Add("Instant teleport (like that in Sandbox mode)", "Instant teleport (like that in Sandbox mode)", "快速传送(和沙盒模式一样)");
|
||||
I18N.Add("Mecha and Drones/Fleets invicible", "Mecha and Drones/Fleets invicible", "机甲和战斗无人机无敌");
|
||||
I18N.Add("Buildings invicible", "Buildings invincible", "建筑无敌");
|
||||
I18N.Apply();
|
||||
MyConfigWindow.OnUICreated += CreateUI;
|
||||
MyConfigWindow.OnUpdateUI += UpdateUI;
|
||||
@@ -134,6 +137,8 @@ public static class UIConfigWindow
|
||||
MyCheckBox.CreateCheckBox(x, y, tab3, PlanetPatch.WaterPumpAnywhereEnabled, "Pump Anywhere");
|
||||
y += 36f;
|
||||
MyCheckBox.CreateCheckBox(x, y, tab3, PlanetPatch.TerraformAnywayEnabled, "Terraform without enough soil piles");
|
||||
y += 36f;
|
||||
MyCheckBox.CreateCheckBox(x, y, tab3, PlayerPatch.InstantTeleportEnabled, "Instant teleport (like that in Sandbox mode)");
|
||||
x = 400f;
|
||||
y = 10f;
|
||||
wnd.AddButton(x, y, 200f, tab3, "矿物掩埋标题", 16, "button-bury-all", () => { PlanetFunctions.BuryAllVeins(true); });
|
||||
@@ -171,6 +176,13 @@ public static class UIConfigWindow
|
||||
MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.OverclockEjectorEnabled, "Overclock Ejectors");
|
||||
y += 36f;
|
||||
MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.OverclockSiloEnabled, "Overclock Silos");
|
||||
|
||||
var tab5 = wnd.AddTab(_windowTrans, "Combat");
|
||||
x = 0f;
|
||||
y = 10f;
|
||||
MyCheckBox.CreateCheckBox(x, y, tab5, CombatPatch.MechaInvincibleEnabled, "Mecha and Drones/Fleets invicible");
|
||||
y += 36f;
|
||||
MyCheckBox.CreateCheckBox(x, y, tab5, CombatPatch.BuildingsInvincibleEnabled, "Buildings invicible");
|
||||
return;
|
||||
|
||||
void OnBeltSignalChanged()
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"name": "CheatEnabler",
|
||||
"version_number": "2.3.14",
|
||||
"version_number": "2.3.15",
|
||||
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/CheatEnabler",
|
||||
"description": "Add various cheat functions while disabling abnormal determinants / 添加一些作弊功能,同时屏蔽异常检测",
|
||||
"dependencies": [
|
||||
"xiaoye97-BepInEx-5.4.17",
|
||||
"soarqin-UXAssist-1.0.15"
|
||||
"soarqin-UXAssist-1.0.23"
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user