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,6 +94,7 @@ private func FillWithLiquid()
|
||||||
{
|
{
|
||||||
var intake = this.BarrelIntakeY;
|
var intake = this.BarrelIntakeY;
|
||||||
if (!GBackLiquid(0, intake)) return;
|
if (!GBackLiquid(0, intake)) return;
|
||||||
|
if (GetLiquidAmount() >= GetLiquidContainerMaxFillLevel()) return;
|
||||||
|
|
||||||
var mat = GetMaterial(0, intake);
|
var mat = GetMaterial(0, intake);
|
||||||
var mat_name = MaterialName(mat);
|
var mat_name = MaterialName(mat);
|
||||||
|
@ -107,7 +108,8 @@ private func FillWithLiquid()
|
||||||
ExtractLiquid(0, intake);
|
ExtractLiquid(0, intake);
|
||||||
}
|
}
|
||||||
|
|
||||||
var inserted = PutLiquid(mat_name, extracted);
|
var inserted = 0;
|
||||||
|
if (extracted > 0) inserted = PutLiquid(mat_name, extracted);
|
||||||
|
|
||||||
if (inserted < extracted)
|
if (inserted < extracted)
|
||||||
{
|
{
|
||||||
|
@ -131,6 +133,8 @@ private func EmptyBarrel(int angle, int strength, object clonk)
|
||||||
spray.Angle = angle;
|
spray.Angle = angle;
|
||||||
spray.Clonk = clonk;
|
spray.Clonk = clonk;
|
||||||
AddEffect("ExtinguishingSpray", clonk, 100, 1, this, nil, spray);
|
AddEffect("ExtinguishingSpray", clonk, 100, 1, this, nil, spray);
|
||||||
|
|
||||||
|
UpdateLiquidContainer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,7 +250,7 @@ func GetNameForBarrel()
|
||||||
{
|
{
|
||||||
if (Contents())
|
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;
|
return name;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -99,9 +99,14 @@ func PutLiquid(string liquid_name, int amount, object source)
|
||||||
var type = Library_Liquid->GetLiquidID(liquid_name);
|
var type = Library_Liquid->GetLiquidID(liquid_name);
|
||||||
|
|
||||||
var liquid = CreateObject(type);
|
var liquid = CreateObject(type);
|
||||||
liquid->SetStackCount(amount);
|
if (liquid)
|
||||||
liquid->Enter(this);
|
{
|
||||||
if (liquid && !(liquid->Contained())) liquid->RemoveObject();
|
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);
|
//CreateContents(type, amount);
|
||||||
var after = GetLiquidAmount(liquid_name);
|
var after = GetLiquidAmount(liquid_name);
|
||||||
|
|
Loading…
Reference in New Issue