1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2026-03-23 00:13:43 +08:00

release v0.3.3

This commit is contained in:
2023-07-30 16:11:11 +08:00
parent 414b811e7e
commit 08beb04e8c
8 changed files with 117 additions and 25 deletions

View File

@@ -538,4 +538,27 @@ public static class LabOptPatchFunctions
}
return 0;
}
public static int PickFromLab(PlanetFactory factory, int labId, int filter, int[] needs)
{
var factorySystem = factory.factorySystem;
var products = factorySystem.labPool[labId].products;
if (products == null) return 0;
var produced = factorySystem.labPool[labId].produced;
if (produced == null) return 0;
lock (produced)
{
for (var j = 0; j < products.Length; j++)
{
if (produced[j] <= 0 || products[j] <= 0 ||
(filter != 0 && filter != products[j]) ||
(needs != null && needs[0] != products[j] && needs[1] != products[j] &&
needs[2] != products[j] && needs[3] != products[j] &&
needs[4] != products[j] && needs[5] != products[j])) continue;
produced[j]--;
return products[j];
}
}
return 0;
}
}