1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2025-12-08 21:33:28 +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

@@ -49,9 +49,9 @@ public static class PlanetPatch
{
var matcher = new CodeMatcher(instructions, generator);
matcher.MatchForward(false,
new CodeMatch(instr => instr.opcode == OpCodes.Ldc_I4_S && instr.OperandIs(22))
new CodeMatch(instr => instr.opcode == OpCodes.Ldc_I4_S && instr.OperandIs(23))
).Advance(1).MatchForward(false,
new CodeMatch(instr => instr.opcode == OpCodes.Ldc_I4_S && instr.OperandIs(22))
new CodeMatch(instr => instr.opcode == OpCodes.Ldc_I4_S && instr.OperandIs(23))
);
matcher.Repeat(codeMatcher =>
{

View File

@@ -20,7 +20,7 @@ public class HideTips : BaseUnityPlugin
private static bool _noResearchCompletionPopups = true;
private static bool _noResearchCompletionTips;
private static bool _skipPrologue = true;
private static bool _hideMenuDemo;
// private static bool _hideMenuDemo;
private static Harmony _patch;
@@ -34,13 +34,15 @@ public class HideTips : BaseUnityPlugin
_noResearchCompletionPopups = Config.Bind("General", "NoResearchCompletionPopups", _noResearchCompletionPopups, "Disable Research Completion Popup Windows").Value;
_noResearchCompletionTips = Config.Bind("General", "NoResearchCompletionTips", _noResearchCompletionTips, "Disable Research Completion Tips").Value;
_skipPrologue = Config.Bind("General", "SkipPrologue", _skipPrologue, "Skip prologue for new game").Value;
_hideMenuDemo = Config.Bind("General", "HideMenuDemo", _hideMenuDemo, "Disable title screen demo scene loading").Value;
// _hideMenuDemo = Config.Bind("General", "HideMenuDemo", _hideMenuDemo, "Disable title screen demo scene loading").Value;
if (!_cfgEnabled) return;
Harmony.CreateAndPatchAll(typeof(HideTips));
/*
if (_hideMenuDemo)
{
_patch = Harmony.CreateAndPatchAll(typeof(HideMenuDemo));
}
*/
}
private void OnDestroy()
@@ -141,6 +143,7 @@ public class HideTips : BaseUnityPlugin
}
}
/*
[HarmonyPatch]
class HideMenuDemo
{
@@ -208,4 +211,5 @@ class HideMenuDemo
DSPGame.Game._running = true;
return false;
}
}
}
*/

View File

@@ -73,7 +73,6 @@ public static class MechaDronesTweaks
public static float EnergyMultiplier = 0.1f;
[HarmonyTranspiler]
[HarmonyPatch(typeof(ConstructionModuleComponent), nameof(ConstructionModuleComponent.SearchForNewTargets))]
[HarmonyPatch(typeof(ConstructionSystem), nameof(ConstructionSystem.UpdateDrones))]
[HarmonyPatch(typeof(UIMechaWindow), nameof(UIMechaWindow.UpdateProps))]
[HarmonyPatch(typeof(UITechTree), nameof(UITechTree.RefreshDataValueText))]

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