diff --git a/CheatEnabler/CHANGELOG.md b/CheatEnabler/CHANGELOG.md
index 88b734d..6c02a01 100644
--- a/CheatEnabler/CHANGELOG.md
+++ b/CheatEnabler/CHANGELOG.md
@@ -3,6 +3,10 @@
## Changlog
+* 2.4.2
+ * Fix critical bugs:
+ * Dyson Power is not updated actively when `Skip bullet period` or `Skip absorption period` is enabled and no rocket is in fire.
+ * Dyson Power is not updated actively on clicking `Complete Dyson Sphere Shells instantly` or `Remove all frames on Dyson Sphere`.
* 2.4.1
* New feature: `Remove all frames on Dyson Sphere`
* Can save rockets with very little power generation impact.
@@ -171,6 +175,10 @@
## 更新日志
+* 2.4.2
+ * 修复了严重的系列BUG:
+ * 在启用`跳过子弹阶段`或`跳过吸收阶段`并且没有火箭发射时,戴森球的发电量未实时更新
+ * 点击`立即完成戴森壳建造`或`移除戴森球上的所有框架`时,戴森球的发电量未实时更新
* 2.4.1
* 新增功能:`移除戴森球上的所有框架`
* 可以节省火箭,且几乎不影响发电效率
diff --git a/CheatEnabler/CheatEnabler.csproj b/CheatEnabler/CheatEnabler.csproj
index 5a445c4..3e011f6 100644
--- a/CheatEnabler/CheatEnabler.csproj
+++ b/CheatEnabler/CheatEnabler.csproj
@@ -5,7 +5,7 @@
net472
org.soardev.cheatenabler
DSP MOD - CheatEnabler
- 2.4.1
+ 2.4.2
true
latest
CheatEnabler
diff --git a/CheatEnabler/Functions/DysonSphereFunctions.cs b/CheatEnabler/Functions/DysonSphereFunctions.cs
index b707465..88797b2 100644
--- a/CheatEnabler/Functions/DysonSphereFunctions.cs
+++ b/CheatEnabler/Functions/DysonSphereFunctions.cs
@@ -217,6 +217,7 @@ public static class DysonSphereFunctions
if (count > 0L) consumeRegister[ProductionStatistics.SOLAR_SAIL_ID] += (int)count;
}
}
+ dysonSphere.needRecalculatePower = true;
});
}
@@ -281,6 +282,7 @@ public static class DysonSphereFunctions
dysonSphere.CheckAutoNodes();
dysonSphere.PickAutoNode();
dysonSphere.modelRenderer.RebuildModels();
+ dysonSphere.needRecalculatePower = true;
});
}
diff --git a/CheatEnabler/Patches/DysonSpherePatch.cs b/CheatEnabler/Patches/DysonSpherePatch.cs
index c4db0ab..1bb3627 100644
--- a/CheatEnabler/Patches/DysonSpherePatch.cs
+++ b/CheatEnabler/Patches/DysonSpherePatch.cs
@@ -337,6 +337,7 @@ public class DysonSpherePatch : PatchImpl
sphereProductRegister[ProductionStatistics.SOLAR_SAIL_ID] += len;
sphereConsumeRegister[ProductionStatistics.SOLAR_SAIL_ID] += len;
sphereProductRegister[ProductionStatistics.DYSON_CELL_ID] += len;
+ __instance.dysonSphere.needRecalculatePower = true;
return;
}
idx--;
@@ -350,6 +351,7 @@ public class DysonSpherePatch : PatchImpl
sphereProductRegister[ProductionStatistics.SOLAR_SAIL_ID] += absorbCnt;
sphereConsumeRegister[ProductionStatistics.SOLAR_SAIL_ID] += absorbCnt;
sphereProductRegister[ProductionStatistics.DYSON_CELL_ID] += absorbCnt;
+ __instance.dysonSphere.needRecalculatePower = true;
}
}
for (; idx >= 0; idx--)
@@ -380,31 +382,19 @@ public class DysonSpherePatch : PatchImpl
matcher.MatchForward(false,
new CodeMatch(OpCodes.Stfld, AccessTools.Field(typeof(ExpiryOrder), nameof(ExpiryOrder.index)))
).Advance(1).RemoveInstructions(matcher.Length - matcher.Pos).Insert(
- // if (node.ConstructCp() != null)
- // {
- // this.dysonSphere.productRegister[ProductionStatistics.DYSON_CELL_ID]++;
- // }
- 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.Call, AccessTools.PropertyGetter(typeof(DysonSphere), nameof(DysonSphere.productRegister))),
- new CodeInstruction(OpCodes.Ldc_I4, ProductionStatistics.DYSON_CELL_ID),
- 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.Ldarg_1),
new CodeInstruction(OpCodes.Ldloc_1),
- new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(DysonSwarm), nameof(DysonSwarm.RemoveSolarSail))),
-
+ Transpilers.EmitDelegate((DysonSwarm swarm, DysonNode node, int index) => {
+ if (node.ConstructCp() != null)
+ {
+ swarm.dysonSphere.productRegister[ProductionStatistics.DYSON_CELL_ID]++;
+ swarm.dysonSphere.needRecalculatePower = true;
+ }
+ swarm.RemoveSolarSail(index);
+ }),
// return false;
- new CodeInstruction(OpCodes.Ldc_I4_1),
+ new CodeInstruction(OpCodes.Ldc_I4_0),
new CodeInstruction(OpCodes.Ret)
);
return matcher.InstructionEnumeration();
diff --git a/CheatEnabler/package/manifest.json b/CheatEnabler/package/manifest.json
index c9f273a..eb566e0 100644
--- a/CheatEnabler/package/manifest.json
+++ b/CheatEnabler/package/manifest.json
@@ -1,6 +1,6 @@
{
"name": "CheatEnabler",
- "version_number": "2.4.1",
+ "version_number": "2.4.2",
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/CheatEnabler",
"description": "Add various cheat functions while disabling abnormal determinants / 添加一些作弊功能,同时屏蔽异常检测",
"dependencies": [