diff --git a/CheatEnabler/CheatEnabler.cs b/CheatEnabler/CheatEnabler.cs
index b98def5..983aae8 100644
--- a/CheatEnabler/CheatEnabler.cs
+++ b/CheatEnabler/CheatEnabler.cs
@@ -75,7 +75,7 @@ public class CheatEnabler : BaseUnityPlugin
"Skip bullet");
DysonSpherePatch.SkipAbsorbEnabled = Config.Bind("DysonSphere", "SkipAbsorb", false,
"Skip absorption");
- DysonSpherePatch.QuickAbsortEnabled = Config.Bind("DysonSphere", "QuickAbsorb", false,
+ DysonSpherePatch.QuickAbsorbEnabled = Config.Bind("DysonSphere", "QuickAbsorb", false,
"Quick absorb");
DysonSpherePatch.EjectAnywayEnabled = Config.Bind("DysonSphere", "EjectAnyway", false,
"Eject anyway");
diff --git a/CheatEnabler/CheatEnabler.csproj b/CheatEnabler/CheatEnabler.csproj
index eb6aed4..ca73af1 100644
--- a/CheatEnabler/CheatEnabler.csproj
+++ b/CheatEnabler/CheatEnabler.csproj
@@ -5,7 +5,7 @@
net472
org.soardev.cheatenabler
DSP MOD - CheatEnabler
- 2.2.4
+ 2.2.5
true
latest
CheatEnabler
diff --git a/CheatEnabler/DysonSpherePatch.cs b/CheatEnabler/DysonSpherePatch.cs
index 5e61c1f..3f04591 100644
--- a/CheatEnabler/DysonSpherePatch.cs
+++ b/CheatEnabler/DysonSpherePatch.cs
@@ -10,30 +10,31 @@ public static class DysonSpherePatch
{
public static ConfigEntry SkipBulletEnabled;
public static ConfigEntry SkipAbsorbEnabled;
- public static ConfigEntry QuickAbsortEnabled;
+ public static ConfigEntry QuickAbsorbEnabled;
public static ConfigEntry EjectAnywayEnabled;
public static ConfigEntry OverclockEjectorEnabled;
public static ConfigEntry OverclockSiloEnabled;
private static Harmony _skipBulletPatch;
private static Harmony _skipAbsorbPatch;
- private static Harmony _quickAbsortPatch;
+ private static Harmony _quickAbsorbPatch;
private static Harmony _ejectAnywayPatch;
private static Harmony _overclockEjector;
private static Harmony _overclockSilo;
private static Harmony _patch;
-
+ private static bool _instantAbsorb;
+
public static void Init()
{
_patch ??= Harmony.CreateAndPatchAll(typeof(DysonSpherePatch));
SkipBulletEnabled.SettingChanged += (_, _) => SkipBulletValueChanged();
SkipAbsorbEnabled.SettingChanged += (_, _) => SkipAbsorbValueChanged();
- QuickAbsortEnabled.SettingChanged += (_, _) => QuickAbsortValueChanged();
+ QuickAbsorbEnabled.SettingChanged += (_, _) => QuickAbsorbValueChanged();
EjectAnywayEnabled.SettingChanged += (_, _) => EjectAnywayValueChanged();
OverclockEjectorEnabled.SettingChanged += (_, _) => OverclockEjectorValueChanged();
OverclockSiloEnabled.SettingChanged += (_, _) => OverclockSiloValueChanged();
SkipBulletValueChanged();
SkipAbsorbValueChanged();
- QuickAbsortValueChanged();
+ QuickAbsorbValueChanged();
EjectAnywayValueChanged();
OverclockEjectorValueChanged();
OverclockSiloValueChanged();
@@ -45,8 +46,8 @@ public static class DysonSpherePatch
_skipBulletPatch = null;
_skipAbsorbPatch?.UnpatchSelf();
_skipAbsorbPatch = null;
- _quickAbsortPatch?.UnpatchSelf();
- _quickAbsortPatch = null;
+ _quickAbsorbPatch?.UnpatchSelf();
+ _quickAbsorbPatch = null;
_ejectAnywayPatch?.UnpatchSelf();
_ejectAnywayPatch = null;
_overclockEjector?.UnpatchSelf();
@@ -78,6 +79,7 @@ public static class DysonSpherePatch
private static void SkipAbsorbValueChanged()
{
+ _instantAbsorb = SkipAbsorbEnabled.Value && QuickAbsorbEnabled.Value;
if (SkipAbsorbEnabled.Value)
{
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;
}
- _quickAbsortPatch = Harmony.CreateAndPatchAll(typeof(QuickAbsortPatch));
+ _quickAbsorbPatch = Harmony.CreateAndPatchAll(typeof(QuickAbsorbPatch));
}
- else if (_quickAbsortPatch != null)
+ else if (_quickAbsorbPatch != null)
{
- _quickAbsortPatch.UnpatchSelf();
- _quickAbsortPatch = null;
+ _quickAbsorbPatch.UnpatchSelf();
+ _quickAbsorbPatch = null;
}
}
@@ -352,9 +355,50 @@ public static class DysonSpherePatch
_sailsCacheLen[index] = 0;
var cache = _sailsCache[index];
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]
[HarmonyPatch(typeof(DysonSphereLayer), nameof(DysonSphereLayer.GameTick))]
private static IEnumerable DysonSphereLayer_GameTick_Patch(IEnumerable instructions, ILGenerator generator)
@@ -449,7 +479,7 @@ public static class DysonSpherePatch
matcher.Start().InsertAndAdvance(
new CodeInstruction(OpCodes.Ldarg_0),
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,
new CodeMatch(OpCodes.Ldarg_0),
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(DysonSphereLayer), nameof(DysonSphereLayer.dysonSphere))),
diff --git a/CheatEnabler/FactoryPatch.cs b/CheatEnabler/FactoryPatch.cs
index 27a0fb3..b3de3b7 100644
--- a/CheatEnabler/FactoryPatch.cs
+++ b/CheatEnabler/FactoryPatch.cs
@@ -256,7 +256,9 @@ public static class FactoryPatch
{
if (_sunlight == null)
{
- _sunlight = GameMain.universeSimulator.LocalStarSimulator().sunLight;
+ var simu = GameMain.universeSimulator;
+ if (simu)
+ _sunlight = simu.LocalStarSimulator()?.sunLight;
if (_sunlight == null) return;
}
@@ -715,7 +717,9 @@ public static class FactoryPatch
_portalFrom = new Dictionary();
_portalTo = new Dictionary>();
- 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;
if (entitySignPool == null) continue;
diff --git a/CheatEnabler/README.md b/CheatEnabler/README.md
index f396b5e..8b366f5 100644
--- a/CheatEnabler/README.md
+++ b/CheatEnabler/README.md
@@ -4,6 +4,10 @@
#### 添加一些作弊功能,同时屏蔽异常检测
## 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
+ New function: `Enable player actions in globe view`
+ Fix UI bug
@@ -88,6 +92,10 @@
* [LSTM](https://github.com/hetima/DSP_LSTM) & [PlanetFinder](https://github.com/hetima/DSP_PlanetFinder): UI implementations
## 更新日志
+* 2.2.5
+ + 在同时启用`快速吸收`、`跳过子弹阶段`和`跳过吸收阶段`时,所有弹射的太阳帆会跳过所有中间环节立即吸收
+ + 修复了`快速吸收`在大部分节点已满时无法立即吸收所有太阳帆的问题
+ + 修复了与一些mod的兼容性问题
* 2.2.4
+ 新功能:`在行星视图中允许玩家操作`
+ 修复了UI显示问题
diff --git a/CheatEnabler/UIConfigWindow.cs b/CheatEnabler/UIConfigWindow.cs
index 7200490..81577ed 100644
--- a/CheatEnabler/UIConfigWindow.cs
+++ b/CheatEnabler/UIConfigWindow.cs
@@ -207,7 +207,7 @@ public class UIConfigWindow : UI.MyWindowWithTabs
y += 36f;
UI.MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.SkipAbsorbEnabled, "Skip absorption period");
y += 36f;
- UI.MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.QuickAbsortEnabled, "Quick absorb");
+ UI.MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.QuickAbsorbEnabled, "Quick absorb");
y += 36f;
UI.MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.EjectAnywayEnabled, "Eject anyway");
y += 36f;
diff --git a/CheatEnabler/package/manifest.json b/CheatEnabler/package/manifest.json
index 90d57ac..855290a 100644
--- a/CheatEnabler/package/manifest.json
+++ b/CheatEnabler/package/manifest.json
@@ -1,6 +1,6 @@
{
"name": "CheatEnabler",
- "version_number": "2.2.4",
+ "version_number": "2.2.5",
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/CheatEnabler",
"description": "Add various cheat functions while disabling abnormal determinants / 添加一些作弊功能,同时屏蔽异常检测",
"dependencies": [