mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2026-11-19 17:05:20 +08:00
fix(dustbin): dispose splitter cargo above dustbin storages
Handle native AddCargo separately from sorter AddItem and reset cached full-storage flags when toggling dustbin mode. Refs #63, #31
This commit is contained in:
1 parent
d7783679af
commit
063daff08d
2 files changed
+13
No files matched your search
@@ -116,6 +116,7 @@ public static class StoragePatch
|
||||
if (storagePool[storageId].id != storageId) return;
|
||||
var enabled = _storageDustbinCheckBox.Checked;
|
||||
storagePool[storageId].IsDustbin = enabled;
|
||||
storagePool[storageId].ResetOptimizationFlags();
|
||||
if (!NebulaModAPI.IsMultiplayerActive) return;
|
||||
var planetId = window.factory.planetId;
|
||||
NebulaModAPI.MultiplayerSession.Network.SendPacketToLocalStar(new NebulaSupport.Packet.ToggleEvent(planetId, storageId, enabled));
|
||||
@@ -210,6 +211,16 @@ public static class StoragePatch
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(StorageComponent), nameof(StorageComponent.AddCargo))]
|
||||
private static bool StorageComponent_AddCargo_Prefix(StorageComponent __instance, ref Cargo cargo, ref bool __result)
|
||||
{
|
||||
if (!__instance.IsDustbin) return true;
|
||||
__result = cargo.item > 0 && cargo.stack > 0;
|
||||
if (__result) Dustbin.CalcGetSands(cargo.item, cargo.stack, cargo.inc);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* We keep this to make MOD compatible with older version */
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(StorageComponent), nameof(StorageComponent.Import))]
|
||||
|
||||
Reference in new issue
Block a user