Barrels function as fuel now.

The steam engine does not remove the barrels, it just empties them. Made power system unit test 19 end if both pumps are pumping, this seems to be the intention of the unit test. Added power system unit test 20: Steam engine fueled by oil barrels.
liquid_container
Mark 2016-02-07 16:36:45 +01:00
parent cce260a9a7
commit a0fb0473b3
3 changed files with 71 additions and 1 deletions

View File

@ -227,6 +227,33 @@ private func GetValueOf(string szMaterial) // 300 px of...
return 0;
}
// When is this considered as fuel for the steam engine?
func IsFuel()
{
return WildcardMatch("Oil", GetLiquidType());
}
// Gets the amount of fuel that is stored in the barrel
func GetFuelAmount(bool partial)
{
if (partial)
{
return SteamEngine->GetFuelValue(GetLiquidType(), GetLiquidFillLevel());
}
return SteamEngine->GetFuelValue(GetLiquidType(), GetLiquidContainerMaxFillLevel());
}
// Callback from the steam engine: if this returns true, then the barrel is not removed
func OnFuelRemoved(int amount)
{
RemoveLiquid(nil, amount);
return true;
}
public func Definition(proplist def)
{
SetProperty("PictureTransformation", Trans_Mul(Trans_Translate(0, 1000, 0), Trans_Rotate(-40, 1, 0, 0), Trans_Rotate(20, 0, 0, 1)), def);

View File

@ -177,6 +177,12 @@ func Smoking()
Smoke(-20 * GetCalcDir() + RandomX(-2, 2), -24, 10);
}
func GetFuelValue(string liquid, int amount)
{
if (liquid == "Oil") return amount;
return 0;
}
/*-- Properties --*/
local ActMap = {

View File

@ -1079,7 +1079,7 @@ global func Test19_OnStart(int plr)
global func Test19_Completed()
{
if (GetMaterial(248, 48) == Material("Water"))
if (GetMaterial(248, 97) == Material("Water") && ObjectCount(Find_ID(Pump), Find_Action("Pump")) == 2)
return true;
return false;
}
@ -1093,6 +1093,43 @@ global func Test19_OnFinished()
return;
}
// Test for steam engine fueled by oil barrels.
global func Test20_OnStart(int plr)
{
// Power source: one steam engine.
var engine = CreateObjectAbove(SteamEngine, 100, 160, plr);
for (var i = 0; i < 3; ++i)
{
var barrel = engine->CreateContents(Barrel, 1);
barrel->SetLiquidContainer("Oil", 10);
}
// Power consumer: armory.
var armory = CreateObjectAbove(Armory, 280, 160, plr);
armory->CreateContents(Firestone, 5);
armory->CreateContents(Metal, 5);
armory->AddToQueue(IronBomb, 5);
// Log what the test is about.
Log("A steam engine fueled by oil barrels.");
return true;
}
global func Test20_Completed()
{
// One wood is being burned as fuel by the steam engine.
if (ObjectCount(Find_ID(Barrel), Find_NoContainer()) >= 3 && ObjectCount(Find_ID(IronBomb)) >= 5)
return true;
return false;
}
global func Test20_OnFinished()
{
// Remove steam engine, barrels, armory.
RemoveAll(Find_Or(Find_ID(SteamEngine), Find_ID(Barrel), Find_ID(Armory)));
return;
}
/*-- Helper Functions --*/