mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2026-11-19 17:05:20 +08:00
fix(cheatenabler): track signal belts by their owning planet
The belt hooks keyed signal belts by the local planet's factory index. Battlefield Analysis Base drones can finish belts on other planets and Dark Fog attacks can destroy them there, so such changes started or stopped generation on a belt of the current planet, or were dropped while in space, and a destroyed remote belt kept its signal entry for any belt later built in its place. Use the factory that owns the CargoTraffic instead.
This commit is contained in:
1 parent
a6225cf750
commit
3ca7b62ec6
2 files changed
+15
-15
No files matched your search
@@ -4,7 +4,7 @@
|
||||
## Changlog
|
||||
|
||||
* 2.4.8 - Unreleased
|
||||
* `Belt signal item generation`: Calculate raw-material, intermediate, and proliferator statistics from the game's current recipe data, counting by-products and consumption separately. If an item's recipe data is incomplete, only its upstream statistics pause, with the reason logged; item generation is unaffected.
|
||||
* `Belt signal item generation`: Calculate raw-material, intermediate, and proliferator statistics from the game's current recipe data, counting by-products and consumption separately. If an item's recipe data is incomplete, only its upstream statistics pause, with the reason logged; item generation is unaffected. Fix signal belts built or destroyed on another planet, for example by Battlefield Analysis Base drones or Dark Fog attacks, affecting a belt on the current planet instead of their own; a destroyed belt could also keep generating items on a belt later built in its place.
|
||||
* 2.4.7
|
||||
* `Dev Shortcuts`: Work immediately when enabled after loading a save, and process each key press once per frame at accelerated game speeds.
|
||||
* Extend `Unlock Tech with Key-Modifiers` with a downgrade mode.
|
||||
@@ -204,7 +204,7 @@
|
||||
## 更新日志
|
||||
|
||||
* 2.4.8 - Unreleased
|
||||
* `传送带信号物品生成`:原料、中间产物和增产剂的统计改为按游戏当前配方数据计算,并分别计入副产物和消耗。某物品的配方数据不完整时,仅暂停该物品的上游统计并在日志中说明原因,不影响物品生成。
|
||||
* `传送带信号物品生成`:原料、中间产物和增产剂的统计改为按游戏当前配方数据计算,并分别计入副产物和消耗。某物品的配方数据不完整时,仅暂停该物品的上游统计并在日志中说明原因,不影响物品生成。修复在其他星球上建造或被摧毁的信号传送带(例如由战场分析基站的无人机建造或被黑雾摧毁)错误影响当前星球上传送带的问题;被摧毁的传送带也可能让之后在原处新建的传送带继续生成物品。
|
||||
* 2.4.7
|
||||
* `开发模式快捷键`:修复载入存档后启用时不生效的问题;加速游戏时每次按键仍只执行一次。
|
||||
* `使用组合键点击解锁科技` 新增降级模式。
|
||||
|
||||
@@ -427,13 +427,15 @@ internal class BeltSignalGenerator : PatchImpl<BeltSignalGenerator>
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(CargoTraffic), nameof(CargoTraffic.RemoveBeltComponent))]
|
||||
public static void CargoTraffic_RemoveBeltComponent_Prefix(int id)
|
||||
public static void CargoTraffic_RemoveBeltComponent_Prefix(CargoTraffic __instance, int id)
|
||||
{
|
||||
if (!_initialized) return;
|
||||
var planet = GameMain.localPlanet;
|
||||
if (planet == null) return;
|
||||
RemoveSignalBeltPortalEnd(planet.factoryIndex, id);
|
||||
RemoveSignalBelt(planet.factoryIndex, id);
|
||||
// Belts also change on planets other than the local one, for example through Battlefield Analysis Base
|
||||
// construction or Dark Fog attacks, so always use the factory that owns the belt.
|
||||
var factory = __instance.factory;
|
||||
if (factory == null) return;
|
||||
RemoveSignalBeltPortalEnd(factory.index, id);
|
||||
RemoveSignalBelt(factory.index, id);
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
@@ -441,9 +443,8 @@ internal class BeltSignalGenerator : PatchImpl<BeltSignalGenerator>
|
||||
public static void CargoTraffic_SetBeltSignalIcon_Postfix(CargoTraffic __instance, int signalId, int entityId)
|
||||
{
|
||||
if (!_initialized) return;
|
||||
var planet = GameMain.localPlanet;
|
||||
if (planet == null) return;
|
||||
var factory = __instance.factory;
|
||||
if (factory == null) return;
|
||||
int number;
|
||||
var needAdd = false;
|
||||
switch (signalId)
|
||||
@@ -460,7 +461,7 @@ internal class BeltSignalGenerator : PatchImpl<BeltSignalGenerator>
|
||||
break;
|
||||
case >= 601 and <= 609:
|
||||
number = Mathf.RoundToInt(factory.entitySignPool[entityId].count0);
|
||||
var factoryIndex = planet.factoryIndex;
|
||||
var factoryIndex = factory.index;
|
||||
var beltId = factory.entityPool[entityId].beltId;
|
||||
if (number > 0)
|
||||
SetSignalBeltPortalTo(factoryIndex, beltId, number);
|
||||
@@ -472,7 +473,7 @@ internal class BeltSignalGenerator : PatchImpl<BeltSignalGenerator>
|
||||
}
|
||||
|
||||
{
|
||||
var factoryIndex = planet.factoryIndex;
|
||||
var factoryIndex = factory.index;
|
||||
var beltId = factory.entityPool[entityId].beltId;
|
||||
if (needAdd)
|
||||
{
|
||||
@@ -492,9 +493,8 @@ internal class BeltSignalGenerator : PatchImpl<BeltSignalGenerator>
|
||||
public static void CargoTraffic_SetBeltSignalNumber_Postfix(CargoTraffic __instance, float number, int entityId)
|
||||
{
|
||||
if (!_initialized) return;
|
||||
var planet = GameMain.localPlanet;
|
||||
if (planet == null) return;
|
||||
var factory = __instance.factory;
|
||||
if (factory == null) return;
|
||||
var entitySignPool = factory.entitySignPool;
|
||||
uint signalId;
|
||||
if (entitySignPool[entityId].iconType == 0U || (signalId = entitySignPool[entityId].iconId0) == 0U) return;
|
||||
@@ -506,7 +506,7 @@ internal class BeltSignalGenerator : PatchImpl<BeltSignalGenerator>
|
||||
case >= 1000 and < 20000:
|
||||
break;
|
||||
case >= 601 and <= 609:
|
||||
var factoryIndex = planet.factoryIndex;
|
||||
var factoryIndex = factory.index;
|
||||
var beltId = factory.entityPool[entityId].beltId;
|
||||
RemoveSignalBeltPortalEnd(factoryIndex, beltId);
|
||||
SetSignalBeltPortalTo(factoryIndex, beltId, Mathf.RoundToInt(number));
|
||||
@@ -516,7 +516,7 @@ internal class BeltSignalGenerator : PatchImpl<BeltSignalGenerator>
|
||||
}
|
||||
|
||||
{
|
||||
var factoryIndex = planet.factoryIndex;
|
||||
var factoryIndex = factory.index;
|
||||
var beltId = factory.entityPool[entityId].beltId;
|
||||
var n = Mathf.RoundToInt(number);
|
||||
if (n == 0)
|
||||
|
||||
Reference in new issue
Block a user