1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2025-12-08 22:13:30 +08:00

bug fixes, with TODO added

This commit is contained in:
2024-02-16 21:59:34 +08:00
parent 8a19dfac9f
commit 534d602953
6 changed files with 49 additions and 13 deletions

View File

@@ -347,18 +347,18 @@ public static class FactoryPatch
* ldloc.s V_88 (88)
* ldloc.s V_120 (120)
* brtrue.s 2054 (173A) ldc.i4.s 17
* ldc.i4.s 18
* ldc.i4.s EBuildCondition.JointCannotLift (19)
* br.s 2055 (173C) stfld valuetype EBuildCondition BuildPreview::condition
* ldc.i4.s 17
* ldc.i4.s EBuildCondition.EBuildCondition.JointCannotLift (19) (18)
* stfld valuetype EBuildCondition BuildPreview::condition
*/
matcher.MatchForward(false,
new CodeMatch(OpCodes.Ldloc_S),
new CodeMatch(OpCodes.Ldloc_S),
new CodeMatch(instr => instr.opcode == OpCodes.Brtrue_S || instr.opcode == OpCodes.Brtrue),
new CodeMatch(instr => instr.opcode == OpCodes.Ldc_I4_S && instr.OperandIs(18)),
new CodeMatch(instr => instr.opcode == OpCodes.Ldc_I4_S && instr.OperandIs(19)),
new CodeMatch(instr => instr.opcode == OpCodes.Br_S || instr.opcode == OpCodes.Br),
new CodeMatch(instr => instr.opcode == OpCodes.Ldc_I4_S && instr.OperandIs(17)),
new CodeMatch(instr => instr.opcode == OpCodes.Ldc_I4_S && instr.OperandIs(18)),
new CodeMatch(OpCodes.Stfld, AccessTools.Field(typeof(BuildPreview), nameof(BuildPreview.condition)))
);
if (matcher.IsValid)
@@ -375,12 +375,12 @@ public static class FactoryPatch
/* search for:
* ldloc.s V_88 (88)
* ldc.i4.s 15-19
* ldc.i4.s EBuildCondition.TooSteep(16)-EBuildCondition.InputConflict(20)
* stfld valuetype EBuildCondition BuildPreview::condition
*/
matcher.Start().MatchForward(false,
new CodeMatch(instr => instr.opcode == OpCodes.Ldloc_S || instr.opcode == OpCodes.Ldloc),
new CodeMatch(instr => (instr.opcode == OpCodes.Ldc_I4_S || instr.opcode == OpCodes.Ldc_I4) && Convert.ToInt64(instr.operand) is >= 15 and <= 19),
new CodeMatch(instr => (instr.opcode == OpCodes.Ldc_I4_S || instr.opcode == OpCodes.Ldc_I4) && Convert.ToInt64(instr.operand) is >= 16 and <= 20),
new CodeMatch(OpCodes.Stfld, AccessTools.Field(typeof(BuildPreview), nameof(BuildPreview.condition)))
);
if (matcher.IsValid)

View File

@@ -55,7 +55,7 @@ public static class PlanetFunctions
//planet.data.CalcVerts();
for (var id = factory.entityCursor - 1; id > 0; id--)
{
var ed = factory.entityPool[id];
ref var ed = ref factory.entityPool[id];
if (ed.id != id) continue;
if (ed.colliderId != 0)
{
@@ -77,6 +77,21 @@ public static class PlanetFunctions
planet.audio?.RemoveAudioData(ed.audioId);
}
if (planet.factory.enemyPool != null)
{
for (var i = planet.factory.enemyCursor - 1; i > 0; i--)
{
ref var ptr13 = ref planet.factory.enemyPool[i];
if (ptr13.id != i) continue;
var combatStatId = ptr13.combatStatId;
planet.factory.skillSystem.OnRemovingSkillTarget(combatStatId, planet.factory.skillSystem.combatStats.buffer[combatStatId].originAstroId, ETargetType.CombatStat);
planet.factory.skillSystem.combatStats.Remove(combatStatId);
planet.factory.KillEnemyFinally(player, i, ref CombatStat.empty);
}
planet.factory.enemySystem.Free();
UIRoot.instance.uiGame.dfAssaultTip.ClearAllSpots();
}
var stationPool = factory.transport?.stationPool;
if (stationPool != null)
{
@@ -120,20 +135,34 @@ public static class PlanetFunctions
if (warningPool[i].id == i && warningPool[i].factoryId == index)
warningSystem.RemoveWarningData(warningPool[i].id);
}
var isCombatMode = factory.gameData.gameDesc.isCombatMode;
factory.entityCursor = 1;
factory.entityRecycleCursor = 0;
factory.entityCapacity = 0;
factory.SetEntityCapacity(1024);
factory.craftCursor = 1;
factory.craftRecycleCursor = 0;
factory.craftCapacity = 0;
factory.SetCraftCapacity(128);
factory.prebuildCursor = 1;
factory.prebuildRecycleCursor = 0;
factory.prebuildCapacity = 0;
factory.SetPrebuildCapacity(256);
factory.enemyCursor = 1;
factory.enemyRecycleCursor = 0;
factory.enemyCapacity = 0;
factory.SetEnemyCapacity(isCombatMode ? 1024 : 32);
factory.cargoContainer = new CargoContainer();
factory.cargoTraffic = new CargoTraffic(planet);
factory.blockContainer = new MiniBlockContainer();
factory.factoryStorage = new FactoryStorage(planet);
factory.powerSystem = new PowerSystem(planet);
factory.constructionSystem = new ConstructionSystem(planet);
factory.factorySystem = new FactorySystem(planet);
factory.enemySystem = new EnemyDFGroundSystem(planet);
factory.combatGroundSystem = new CombatGroundSystem(planet);
factory.defenseSystem = new DefenseSystem(planet);
factory.planetATField = new PlanetATField(planet);
factory.transport = new PlanetTransport(GameMain.data, planet);
factory.transport.Init();
factory.digitalSystem = new DigitalSystem(planet);

4
UXAssist/TODO.md Normal file
View File

@@ -0,0 +1,4 @@
#### TODO
* Show coordinates of buildings, on both preview-mode and panel
* Better handling of consuming metadata
* More queued commands