Producers: consume required material (#885)

Instead of just checking whether the material is available, also
consume it.

I'm not quite certain whether we should return the removed material
along with the amount removed (to match the return value of the barrel's
GetLiquid), but since the bucket is not currently accepting wildcards
I don't think it's necessary.
stable-5.3
Nicolas Hake 2012-12-17 01:47:38 +01:00
parent df4275ed0f
commit f53cdfb286
1 changed files with 2 additions and 1 deletions

View File

@ -371,6 +371,7 @@ private func Produce(id product)
CheckComponents(product, true);
CheckFuel(product, true);
CheckLiquids(product, true);
CheckMaterials(product, true);
// Add production effect.
AddEffect("ProcessProduction", this, 100, 2, this, nil, product);
@ -473,7 +474,7 @@ private func CheckMaterials(id product, bool remove)
for (var mat_container in FindObjects(Find_Container(this), Find_Func("IsMaterialContainer")))
{
var val = mat_container->~RemoveContainedMaterial(material, need - extracted);
extracted += val[1];
extracted += val;
if (extracted >= need)
break;
}