forked from Mirrors/openclonk
Barrel: Fixed barrel getting filled with liquids
Barrels was not updating, and caused an error when getting filled with liquid.liquid_container
parent
8298bc789f
commit
02b8cf8422
|
@ -94,7 +94,8 @@ private func FillWithLiquid()
|
|||
{
|
||||
var intake = this.BarrelIntakeY;
|
||||
if (!GBackLiquid(0, intake)) return;
|
||||
|
||||
if (GetLiquidAmount() >= GetLiquidContainerMaxFillLevel()) return;
|
||||
|
||||
var mat = GetMaterial(0, intake);
|
||||
var mat_name = MaterialName(mat);
|
||||
if (!IsLiquidContainerForMaterial(mat_name)) return;
|
||||
|
@ -107,7 +108,8 @@ private func FillWithLiquid()
|
|||
ExtractLiquid(0, intake);
|
||||
}
|
||||
|
||||
var inserted = PutLiquid(mat_name, extracted);
|
||||
var inserted = 0;
|
||||
if (extracted > 0) inserted = PutLiquid(mat_name, extracted);
|
||||
|
||||
if (inserted < extracted)
|
||||
{
|
||||
|
@ -131,6 +133,8 @@ private func EmptyBarrel(int angle, int strength, object clonk)
|
|||
spray.Angle = angle;
|
||||
spray.Clonk = clonk;
|
||||
AddEffect("ExtinguishingSpray", clonk, 100, 1, this, nil, spray);
|
||||
|
||||
UpdateLiquidContainer();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -246,7 +250,7 @@ func GetNameForBarrel()
|
|||
{
|
||||
if (Contents())
|
||||
{
|
||||
var name = Format("%s $NameWith$ %s", this.Prototype.Name, Contents()->GetName());
|
||||
var name = Format("%s $NameWith$ %s", this.Prototype.Name, Contents().Prototype.Name);
|
||||
return name;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -99,9 +99,14 @@ func PutLiquid(string liquid_name, int amount, object source)
|
|||
var type = Library_Liquid->GetLiquidID(liquid_name);
|
||||
|
||||
var liquid = CreateObject(type);
|
||||
liquid->SetStackCount(amount);
|
||||
liquid->Enter(this);
|
||||
if (liquid && !(liquid->Contained())) liquid->RemoveObject();
|
||||
if (liquid)
|
||||
{
|
||||
liquid->SetStackCount(amount);
|
||||
liquid->Enter(this);
|
||||
// the check is necessary here, because the liquid may get removed if the barrel already
|
||||
// has a stack inside
|
||||
if (liquid && !(liquid->Contained())) liquid->RemoveObject();
|
||||
}
|
||||
|
||||
//CreateContents(type, amount);
|
||||
var after = GetLiquidAmount(liquid_name);
|
||||
|
|
Loading…
Reference in New Issue