Author SHA1 Message Date
soarqin c7fcf31c30 fix(cheatenabler): require UXAssist 1.6.3 before loading
Align the runtime and package minimum with the official release that provides the shared production API. Keep official UXAssist 1.6.3 supported and document the dependency in both languages.

Assisted-by: Cindy (https://cindy.app)
2026-11-05 21:34:35 +08:00
soarqin 64a23e9772 fix(cheatenabler): restore mecha and fleet invincibility
Patch the native mecha damage and shield consumers so an inlined Player.invincible getter cannot bypass protection. Replace the fleet damage matcher with target-type prefixes to cover both space paths.

Synchronize the English and Chinese documentation without changing version 2.4.8.
2026-11-04 20:46:44 +08:00
5 changed files with 40 additions and 21 deletions

No files matched your search

+4
View File
@@ -4,6 +4,8 @@
## Changlog ## Changlog
* 2.4.8 * 2.4.8
* Require UXAssist 1.6.3 or later for the shared production API. Older versions are rejected before initialization instead of failing while loading belt-signal features.
* `Mecha and Drones/Fleets invincible`: Fix mecha HP and energy shield protection failing when enabled after taking damage, and restore protection for space fleets.
* `Finish build immediately`: Fix possible errors when starting a new game. Construction begins after the opening cutscene ends or is skipped. * `Finish build immediately`: Fix possible errors when starting a new game. Construction begins after the opening cutscene ends or is skipped.
* `Belt signal item generation`: * `Belt signal item generation`:
* Improve raw-material, intermediate, by-product and proliferator statistics using current recipes, with production and consumption counted separately. Incomplete recipe data only pauses the affected upstream statistics; item generation continues. * Improve raw-material, intermediate, by-product and proliferator statistics using current recipes, with production and consumption counted separately. Incomplete recipe data only pauses the affected upstream statistics; item generation continues.
@@ -207,6 +209,8 @@
## 更新日志 ## 更新日志
* 2.4.8 * 2.4.8
* 需要 UXAssist 1.6.3 或更高版本提供共享生产计算 API。旧版本会在初始化前被拒绝加载,避免加载传送带信号功能时出错。
* `机甲和战斗无人机无敌`:修复受伤后启用时机甲耐久度和能量护盾保护可能失效的问题,并恢复太空编队的无敌保护。
* `建造秒完成`:修复开始新游戏时可能报错的问题。建造会在开场动画播放结束或跳过后开始。 * `建造秒完成`:修复开始新游戏时可能报错的问题。建造会在开场动画播放结束或跳过后开始。
* `传送带信号物品生成`: * `传送带信号物品生成`:
* 按当前配方完善原料、中间产物、副产物和增产剂的统计,分别记录生产和消耗。配方数据不完整时,仅暂停受影响物品的上游统计,物品仍会正常生成。 * 按当前配方完善原料、中间产物、副产物和增产剂的统计,分别记录生产和消耗。配方数据不完整时,仅暂停受影响物品的上游统计,物品仍会正常生成。
+1 -1
View File
@@ -10,7 +10,7 @@ using UXAssist.Common.ModFeatures;
namespace CheatEnabler; namespace CheatEnabler;
[BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)] [BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
[BepInDependency(UXAssist.PluginInfo.PLUGIN_GUID)] [BepInDependency(UXAssist.PluginInfo.PLUGIN_GUID, "1.6.3")]
public class CheatEnabler : BaseUnityPlugin public class CheatEnabler : BaseUnityPlugin
{ {
public new static readonly BepInEx.Logging.ManualLogSource Logger = public new static readonly BepInEx.Logging.ManualLogSource Logger =
+29 -18
View File
@@ -1,10 +1,11 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Linq;
using System.Reflection.Emit; using System.Reflection.Emit;
using BepInEx.Configuration; using BepInEx.Configuration;
using HarmonyLib; using HarmonyLib;
using UXAssist.Common; using UXAssist.Common;
using UXAssist.Common.ModFeatures; using UXAssist.Common.ModFeatures;
using UXAssist.Common.Patching;
namespace CheatEnabler.Patches; namespace CheatEnabler.Patches;
@@ -48,27 +49,37 @@ public static class CombatPatch
); );
return matcher.InstructionEnumeration(); return matcher.InstructionEnumeration();
} }
// Harmony transpiler: SkillSystem_DamageObject_Transpiler // Harmony transpiler: Mecha_Invincible_Transpiler
// Target: SkillSystem.DamageGroundObjectByLocalCaster, SkillSystem.DamageGroundObjectByRemoteCaster, SkillSystem.DamageObject // Target: Mecha.TakeDamage, Mecha.EnergyShieldResist (both overloads)
// Fallback: None — patch will fail loudly if the target method body changes. // Fallback: Return original instructions if the invincibility check is not found.
[HarmonyTranspiler] [HarmonyTranspiler]
[HarmonyPatch(typeof(Mecha), nameof(Mecha.TakeDamage))]
[HarmonyPatch(typeof(Mecha), nameof(Mecha.EnergyShieldResist), [typeof(int)], [ArgumentType.Ref])]
[HarmonyPatch(typeof(Mecha), nameof(Mecha.EnergyShieldResist), [typeof(int), typeof(int)], [ArgumentType.Ref, ArgumentType.Out])]
private static IEnumerable<CodeInstruction> Mecha_Invincible_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{
// Repatch the consumers too: an already inlined getter bypasses its own Harmony patch.
var original = instructions.ToList();
var matcher = new CodeMatcher(original, generator);
matcher.MatchForward(false, new CodeMatch(ci => ci.Calls(AccessTools.PropertyGetter(typeof(Player), nameof(Player.invincible)))));
if (matcher.IsInvalid) return matcher.Finish(original, CheatEnabler.Logger, nameof(Mecha_Invincible_Transpiler));
matcher.Set(OpCodes.Pop, null).Advance(1).Insert(new CodeInstruction(OpCodes.Ldc_I4_1));
return matcher.InstructionEnumeration();
}
[HarmonyPrefix]
[HarmonyPatch(typeof(SkillSystem), nameof(SkillSystem.DamageGroundObjectByLocalCaster))] [HarmonyPatch(typeof(SkillSystem), nameof(SkillSystem.DamageGroundObjectByLocalCaster))]
[HarmonyPatch(typeof(SkillSystem), nameof(SkillSystem.DamageGroundObjectByRemoteCaster))] [HarmonyPatch(typeof(SkillSystem), nameof(SkillSystem.DamageGroundObjectByRemoteCaster))]
[HarmonyPatch(typeof(SkillSystem), nameof(SkillSystem.DamageObject))] private static void SkillSystem_DamageGroundObject_Prefix(ref int damage, ref SkillTargetLocal target)
private static IEnumerable<CodeInstruction> SkillSystem_DamageObject_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator, MethodBase __originalMethod)
{ {
var matcher = new CodeMatcher(instructions, generator); if (target.type == ETargetType.Craft) damage = 0;
matcher.MatchForward(false, }
new CodeMatch(ci => ci.IsLdarg()),
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(SkillTargetLocal), nameof(SkillTargetLocal.type))), [HarmonyPrefix]
new CodeMatch(OpCodes.Ldc_I4_6), [HarmonyPatch(typeof(SkillSystem), nameof(SkillSystem.DamageObject))]
new CodeMatch(ci => ci.opcode == OpCodes.Bne_Un || ci.opcode == OpCodes.Bne_Un_S) private static void SkillSystem_DamageObject_Prefix(ref int damage, ref SkillTarget target)
); {
matcher.Repeat(m => m.Advance(4).InsertAndAdvance( if (target.type == ETargetType.Craft) damage = 0;
new CodeInstruction(OpCodes.Ldc_I4_0),
new CodeInstruction(OpCodes.Starg_S, __originalMethod.Name == "DamageObject" ? 1 : 2)
));
return matcher.InstructionEnumeration();
} }
} }
+5 -1
View File
@@ -75,7 +75,8 @@
* Keep the highest-production shells and remove the others * Keep the highest-production shells and remove the others
* Duplicate the highest-production shells with a configurable shell count * Duplicate the highest-production shells with a configurable shell count
* Mecha/Combat: * Mecha/Combat:
* Mecha and Drones/Fleets invicible * Mecha and Drones/Fleets invincible
* Protects mecha HP and energy shields, ground combat drones, and space fleets, including when enabled during combat.
* Buildings invicible * Buildings invicible
* Enable warp without space warpers * Enable warp without space warpers
* Teleport to outer space * Teleport to outer space
@@ -92,6 +93,7 @@ The item icon selects the output; no hotkey is needed.
## Notes ## Notes
* Requires UXAssist 1.6.3 or later. When upgrading manually, replace the old UXAssist DLL and remove duplicate copies from the BepInEx plugins folder.
* Please upgrade `BepInEx` 5.4.21 or later if using with [BlueprintTweaks](https://dsp.thunderstore.io/package/kremnev8/BlueprintTweaks/) to avoid possible conflicts. * Please upgrade `BepInEx` 5.4.21 or later if using with [BlueprintTweaks](https://dsp.thunderstore.io/package/kremnev8/BlueprintTweaks/) to avoid possible conflicts.
* You can download [BepInEx here](https://github.com/bepinex/bepinex/releases/latest)(choose x64 edition). * You can download [BepInEx here](https://github.com/bepinex/bepinex/releases/latest)(choose x64 edition).
* If using with r2modman, you can upgrade `BepInEx` by clicking `Settings` -> `Browse profile folder`, then extract downloaded zip to the folder and overwrite existing files. * If using with r2modman, you can upgrade `BepInEx` by clicking `Settings` -> `Browse profile folder`, then extract downloaded zip to the folder and overwrite existing files.
@@ -180,6 +182,7 @@ The item icon selects the output; no hotkey is needed.
* 从发电量最高的壳复制戴森壳,可设置壳面数量 * 从发电量最高的壳复制戴森壳,可设置壳面数量
* 机甲/战斗: * 机甲/战斗:
* 机甲和战斗无人机无敌 * 机甲和战斗无人机无敌
* 保护机甲耐久度和能量护盾、地面战斗无人机和太空编队,战斗中开启同样生效。
* 建筑无敌 * 建筑无敌
* 无需空间翘曲器即可曲速飞行 * 无需空间翘曲器即可曲速飞行
* 传送到外太空 * 传送到外太空
@@ -196,6 +199,7 @@ The item icon selects the output; no hotkey is needed.
## 注意事项 ## 注意事项
* 需要 UXAssist 1.6.3 或更高版本。手动升级时,请替换旧的 UXAssist DLL,并删除 BepInEx 插件目录中的重复副本。
* 如果和[BlueprintTweaks](https://dsp.thunderstore.io/package/kremnev8/BlueprintTweaks/)一起使用,请升级`BepInEx`到5.4.21或更高版本,以避免可能的冲突 * 如果和[BlueprintTweaks](https://dsp.thunderstore.io/package/kremnev8/BlueprintTweaks/)一起使用,请升级`BepInEx`到5.4.21或更高版本,以避免可能的冲突
* 你可以在[这里](https://github.com/bepinex/bepinex/releases/latest)(选择x64版本)下载`BepInEx` * 你可以在[这里](https://github.com/bepinex/bepinex/releases/latest)(选择x64版本)下载`BepInEx`
* 如果使用r2modman,你可以点击`Settings` -> `Browse profile folder`,然后将下载的zip解压到该文件夹并覆盖现有文件 * 如果使用r2modman,你可以点击`Settings` -> `Browse profile folder`,然后将下载的zip解压到该文件夹并覆盖现有文件
+1 -1
View File
@@ -5,6 +5,6 @@
"description": "Add various cheat functions while disabling abnormal determinants / 添加一些作弊功能,同时屏蔽异常检测", "description": "Add various cheat functions while disabling abnormal determinants / 添加一些作弊功能,同时屏蔽异常检测",
"dependencies": [ "dependencies": [
"xiaoye97-BepInEx-5.4.17", "xiaoye97-BepInEx-5.4.17",
"soarqin-UXAssist-1.4.0" "soarqin-UXAssist-1.6.3"
] ]
} }