1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2026-02-05 03:02:20 +08:00

CheatEnabler v2.2.5

This commit is contained in:
2023-09-27 21:23:23 +08:00
parent d48280c20c
commit c092ae81bb
7 changed files with 80 additions and 38 deletions

View File

@@ -75,7 +75,7 @@ public class CheatEnabler : BaseUnityPlugin
"Skip bullet"); "Skip bullet");
DysonSpherePatch.SkipAbsorbEnabled = Config.Bind("DysonSphere", "SkipAbsorb", false, DysonSpherePatch.SkipAbsorbEnabled = Config.Bind("DysonSphere", "SkipAbsorb", false,
"Skip absorption"); "Skip absorption");
DysonSpherePatch.QuickAbsortEnabled = Config.Bind("DysonSphere", "QuickAbsorb", false, DysonSpherePatch.QuickAbsorbEnabled = Config.Bind("DysonSphere", "QuickAbsorb", false,
"Quick absorb"); "Quick absorb");
DysonSpherePatch.EjectAnywayEnabled = Config.Bind("DysonSphere", "EjectAnyway", false, DysonSpherePatch.EjectAnywayEnabled = Config.Bind("DysonSphere", "EjectAnyway", false,
"Eject anyway"); "Eject anyway");

View File

@@ -5,7 +5,7 @@
<TargetFramework>net472</TargetFramework> <TargetFramework>net472</TargetFramework>
<BepInExPluginGuid>org.soardev.cheatenabler</BepInExPluginGuid> <BepInExPluginGuid>org.soardev.cheatenabler</BepInExPluginGuid>
<Description>DSP MOD - CheatEnabler</Description> <Description>DSP MOD - CheatEnabler</Description>
<Version>2.2.4</Version> <Version>2.2.5</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<PackageId>CheatEnabler</PackageId> <PackageId>CheatEnabler</PackageId>

View File

@@ -10,30 +10,31 @@ public static class DysonSpherePatch
{ {
public static ConfigEntry<bool> SkipBulletEnabled; public static ConfigEntry<bool> SkipBulletEnabled;
public static ConfigEntry<bool> SkipAbsorbEnabled; public static ConfigEntry<bool> SkipAbsorbEnabled;
public static ConfigEntry<bool> QuickAbsortEnabled; public static ConfigEntry<bool> QuickAbsorbEnabled;
public static ConfigEntry<bool> EjectAnywayEnabled; public static ConfigEntry<bool> EjectAnywayEnabled;
public static ConfigEntry<bool> OverclockEjectorEnabled; public static ConfigEntry<bool> OverclockEjectorEnabled;
public static ConfigEntry<bool> OverclockSiloEnabled; public static ConfigEntry<bool> OverclockSiloEnabled;
private static Harmony _skipBulletPatch; private static Harmony _skipBulletPatch;
private static Harmony _skipAbsorbPatch; private static Harmony _skipAbsorbPatch;
private static Harmony _quickAbsortPatch; private static Harmony _quickAbsorbPatch;
private static Harmony _ejectAnywayPatch; private static Harmony _ejectAnywayPatch;
private static Harmony _overclockEjector; private static Harmony _overclockEjector;
private static Harmony _overclockSilo; private static Harmony _overclockSilo;
private static Harmony _patch; private static Harmony _patch;
private static bool _instantAbsorb;
public static void Init() public static void Init()
{ {
_patch ??= Harmony.CreateAndPatchAll(typeof(DysonSpherePatch)); _patch ??= Harmony.CreateAndPatchAll(typeof(DysonSpherePatch));
SkipBulletEnabled.SettingChanged += (_, _) => SkipBulletValueChanged(); SkipBulletEnabled.SettingChanged += (_, _) => SkipBulletValueChanged();
SkipAbsorbEnabled.SettingChanged += (_, _) => SkipAbsorbValueChanged(); SkipAbsorbEnabled.SettingChanged += (_, _) => SkipAbsorbValueChanged();
QuickAbsortEnabled.SettingChanged += (_, _) => QuickAbsortValueChanged(); QuickAbsorbEnabled.SettingChanged += (_, _) => QuickAbsorbValueChanged();
EjectAnywayEnabled.SettingChanged += (_, _) => EjectAnywayValueChanged(); EjectAnywayEnabled.SettingChanged += (_, _) => EjectAnywayValueChanged();
OverclockEjectorEnabled.SettingChanged += (_, _) => OverclockEjectorValueChanged(); OverclockEjectorEnabled.SettingChanged += (_, _) => OverclockEjectorValueChanged();
OverclockSiloEnabled.SettingChanged += (_, _) => OverclockSiloValueChanged(); OverclockSiloEnabled.SettingChanged += (_, _) => OverclockSiloValueChanged();
SkipBulletValueChanged(); SkipBulletValueChanged();
SkipAbsorbValueChanged(); SkipAbsorbValueChanged();
QuickAbsortValueChanged(); QuickAbsorbValueChanged();
EjectAnywayValueChanged(); EjectAnywayValueChanged();
OverclockEjectorValueChanged(); OverclockEjectorValueChanged();
OverclockSiloValueChanged(); OverclockSiloValueChanged();
@@ -45,8 +46,8 @@ public static class DysonSpherePatch
_skipBulletPatch = null; _skipBulletPatch = null;
_skipAbsorbPatch?.UnpatchSelf(); _skipAbsorbPatch?.UnpatchSelf();
_skipAbsorbPatch = null; _skipAbsorbPatch = null;
_quickAbsortPatch?.UnpatchSelf(); _quickAbsorbPatch?.UnpatchSelf();
_quickAbsortPatch = null; _quickAbsorbPatch = null;
_ejectAnywayPatch?.UnpatchSelf(); _ejectAnywayPatch?.UnpatchSelf();
_ejectAnywayPatch = null; _ejectAnywayPatch = null;
_overclockEjector?.UnpatchSelf(); _overclockEjector?.UnpatchSelf();
@@ -78,6 +79,7 @@ public static class DysonSpherePatch
private static void SkipAbsorbValueChanged() private static void SkipAbsorbValueChanged()
{ {
_instantAbsorb = SkipAbsorbEnabled.Value && QuickAbsorbEnabled.Value;
if (SkipAbsorbEnabled.Value) if (SkipAbsorbEnabled.Value)
{ {
if (_skipAbsorbPatch != null) if (_skipAbsorbPatch != null)
@@ -93,20 +95,21 @@ public static class DysonSpherePatch
} }
} }
private static void QuickAbsortValueChanged() private static void QuickAbsorbValueChanged()
{ {
if (QuickAbsortEnabled.Value) _instantAbsorb = SkipAbsorbEnabled.Value && QuickAbsorbEnabled.Value;
if (QuickAbsorbEnabled.Value)
{ {
if (_quickAbsortPatch != null) if (_quickAbsorbPatch != null)
{ {
return; return;
} }
_quickAbsortPatch = Harmony.CreateAndPatchAll(typeof(QuickAbsortPatch)); _quickAbsorbPatch = Harmony.CreateAndPatchAll(typeof(QuickAbsorbPatch));
} }
else if (_quickAbsortPatch != null) else if (_quickAbsorbPatch != null)
{ {
_quickAbsortPatch.UnpatchSelf(); _quickAbsorbPatch.UnpatchSelf();
_quickAbsortPatch = null; _quickAbsorbPatch = null;
} }
} }
@@ -352,9 +355,50 @@ public static class DysonSpherePatch
_sailsCacheLen[index] = 0; _sailsCacheLen[index] = 0;
var cache = _sailsCache[index]; var cache = _sailsCache[index];
var deadline = time + _sailLifeTime; var deadline = time + _sailLifeTime;
for (var i = len - 1; i >= 0; i--) var idx = len - 1;
if (_instantAbsorb)
{ {
__instance.AddSolarSail(cache[i].Sail, cache[i].OrbitId, deadline); var sphere = __instance.dysonSphere;
var layers = sphere.layersSorted;
var llen = sphere.layerCount;
if (llen > 0)
{
var lidx = time / 16 % llen;
for (var i = llen - 1; i >= 0; i--)
{
var layer = layers[(lidx + i) % llen];
var nodes = layer.nodePool;
var nlen = layer.nodeCursor;
var nidx = time % nlen;
for (var j = nlen - 1; j > 0; j--)
{
var nodeIdx = (nidx + j) % nlen;
var node = nodes[nodeIdx];
if (node == null || node.id != nodeIdx || node.sp < node.spMax) continue;
while (node.cpReqOrder > 0)
{
node.cpOrdered++;
if (node.ConstructCp() == null) break;
if (idx == 0)
{
sphere.productRegister[11901] += len;
sphere.consumeRegister[11901] += len;
sphere.productRegister[11903] += len;
return;
}
idx--;
}
}
}
}
var absorbCnt = len - 1 - idx;
sphere.productRegister[11901] += absorbCnt;
sphere.consumeRegister[11901] += absorbCnt;
sphere.productRegister[11903] += absorbCnt;
}
for (; idx >= 0; idx--)
{
__instance.AddSolarSail(cache[idx].Sail, cache[idx].OrbitId, deadline);
} }
} }
} }
@@ -424,22 +468,8 @@ public static class DysonSpherePatch
} }
} }
private static class QuickAbsortPatch private static class QuickAbsorbPatch
{ {
// [HarmonyPrefix]
// [HarmonyPatch(typeof(DysonSphereLayer), "GameTick")]
// public static void DysonSphereLayerGameTick(ref DysonSphereLayer __instance, long gameTick)
// {
// DysonSwarm swarm = __instance.dysonSphere.swarm;
// for (int i = __instance.nodeCursor - 1; i > 0; i--)
// {
// DysonNode dysonNode = __instance.nodePool[i];
// if (dysonNode != null && dysonNode.id == i && dysonNode.sp == dysonNode.spMax)
// {
// dysonNode.OrderConstructCp(gameTick, swarm);
// }
// }
// }
[HarmonyTranspiler] [HarmonyTranspiler]
[HarmonyPatch(typeof(DysonSphereLayer), nameof(DysonSphereLayer.GameTick))] [HarmonyPatch(typeof(DysonSphereLayer), nameof(DysonSphereLayer.GameTick))]
private static IEnumerable<CodeInstruction> DysonSphereLayer_GameTick_Patch(IEnumerable<CodeInstruction> instructions, ILGenerator generator) private static IEnumerable<CodeInstruction> DysonSphereLayer_GameTick_Patch(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
@@ -449,7 +479,7 @@ public static class DysonSpherePatch
matcher.Start().InsertAndAdvance( matcher.Start().InsertAndAdvance(
new CodeInstruction(OpCodes.Ldarg_0), new CodeInstruction(OpCodes.Ldarg_0),
new CodeInstruction(OpCodes.Ldarg_1), new CodeInstruction(OpCodes.Ldarg_1),
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(QuickAbsortPatch), nameof(QuickAbsortPatch.DoAbsorb))) new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(QuickAbsorbPatch), nameof(QuickAbsorbPatch.DoAbsorb)))
).MatchForward(false, ).MatchForward(false,
new CodeMatch(OpCodes.Ldarg_0), new CodeMatch(OpCodes.Ldarg_0),
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(DysonSphereLayer), nameof(DysonSphereLayer.dysonSphere))), new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(DysonSphereLayer), nameof(DysonSphereLayer.dysonSphere))),

View File

@@ -256,7 +256,9 @@ public static class FactoryPatch
{ {
if (_sunlight == null) if (_sunlight == null)
{ {
_sunlight = GameMain.universeSimulator.LocalStarSimulator().sunLight; var simu = GameMain.universeSimulator;
if (simu)
_sunlight = simu.LocalStarSimulator()?.sunLight;
if (_sunlight == null) return; if (_sunlight == null) return;
} }
@@ -715,7 +717,9 @@ public static class FactoryPatch
_portalFrom = new Dictionary<long, int>(); _portalFrom = new Dictionary<long, int>();
_portalTo = new Dictionary<int, HashSet<long>>(); _portalTo = new Dictionary<int, HashSet<long>>();
foreach (var factory in GameMain.data.factories) var factories = GameMain.data?.factories;
if (factories == null) return;
foreach (var factory in factories)
{ {
var entitySignPool = factory?.entitySignPool; var entitySignPool = factory?.entitySignPool;
if (entitySignPool == null) continue; if (entitySignPool == null) continue;

View File

@@ -4,6 +4,10 @@
#### 添加一些作弊功能,同时屏蔽异常检测 #### 添加一些作弊功能,同时屏蔽异常检测
## Changlog ## Changlog
* 2.2.5
+ Skip all intermediate states and absorb solar sails instantly while enable `Quick absorb`, `Skip bullet period` and `Skip absorption period` at the same time.
+ Fix a problem that `Quick absorb` does not absorb all solar sails instantly when most nodes are full.
+ Fix crash while using with some mods
* 2.2.4 * 2.2.4
+ New function: `Enable player actions in globe view` + New function: `Enable player actions in globe view`
+ Fix UI bug + Fix UI bug
@@ -88,6 +92,10 @@
* [LSTM](https://github.com/hetima/DSP_LSTM) & [PlanetFinder](https://github.com/hetima/DSP_PlanetFinder): UI implementations * [LSTM](https://github.com/hetima/DSP_LSTM) & [PlanetFinder](https://github.com/hetima/DSP_PlanetFinder): UI implementations
## 更新日志 ## 更新日志
* 2.2.5
+ 在同时启用`快速吸收``跳过子弹阶段``跳过吸收阶段`时,所有弹射的太阳帆会跳过所有中间环节立即吸收
+ 修复了`快速吸收`在大部分节点已满时无法立即吸收所有太阳帆的问题
+ 修复了与一些mod的兼容性问题
* 2.2.4 * 2.2.4
+ 新功能:`在行星视图中允许玩家操作` + 新功能:`在行星视图中允许玩家操作`
+ 修复了UI显示问题 + 修复了UI显示问题

View File

@@ -207,7 +207,7 @@ public class UIConfigWindow : UI.MyWindowWithTabs
y += 36f; y += 36f;
UI.MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.SkipAbsorbEnabled, "Skip absorption period"); UI.MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.SkipAbsorbEnabled, "Skip absorption period");
y += 36f; y += 36f;
UI.MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.QuickAbsortEnabled, "Quick absorb"); UI.MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.QuickAbsorbEnabled, "Quick absorb");
y += 36f; y += 36f;
UI.MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.EjectAnywayEnabled, "Eject anyway"); UI.MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.EjectAnywayEnabled, "Eject anyway");
y += 36f; y += 36f;

View File

@@ -1,6 +1,6 @@
{ {
"name": "CheatEnabler", "name": "CheatEnabler",
"version_number": "2.2.4", "version_number": "2.2.5",
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/CheatEnabler", "website_url": "https://github.com/soarqin/DSP_Mods/tree/master/CheatEnabler",
"description": "Add various cheat functions while disabling abnormal determinants / 添加一些作弊功能,同时屏蔽异常检测", "description": "Add various cheat functions while disabling abnormal determinants / 添加一些作弊功能,同时屏蔽异常检测",
"dependencies": [ "dependencies": [