Refactoring: Fuel

Added parameter to 'GetFuelAmount' that specified how much fuel is requested from this object. Oil is now fuel and only the needed amount is removed instead of removing the entire stack when a producer requests fuel.
liquid_container
Mark 2016-03-01 17:29:24 +01:00
parent 072f599cdb
commit f78890142c
6 changed files with 22 additions and 7 deletions

View File

@ -14,8 +14,9 @@ protected func Hit(x, y)
}
public func IsFuel() { return true; }
public func GetFuelAmount()
{
public func GetFuelAmount(int requested_amount)
{
// disregard the parameter, because only a complete chunk should be removed
if (this != Coal) return GetCon();
return 100;
}

View File

@ -18,8 +18,9 @@ private func Hit()
}
public func IsFuel() { return true; }
public func GetFuelAmount()
{
public func GetFuelAmount(int requested_amount)
{
// disregard the parameter, because only a complete chunk should be removed
if (this != CottonSeed) return GetCon()/2;
return 50;
}

View File

@ -130,7 +130,7 @@ private func FindNearWater()
/*-- Status --*/
public func IsFuel() { return !wetness; }
public func GetFuelAmount() { return 100; }
public func GetFuelAmount(int requested_amount) { return 100; } // disregard the parameter, because only a complete chunk should be removed
local Collectible = 1;
local Name = "$Name$";

View File

@ -12,8 +12,9 @@ func Incineration()
}
public func IsFuel() { return true; }
public func GetFuelAmount()
public func GetFuelAmount(int requested_amount)
{
// disregard the parameter, because only a complete chunk should be removed
if (this != Wood) return GetCon() / 2;
return 50;
}

View File

@ -16,7 +16,7 @@ public func Incineration()
}
public func IsFuel() { return true; }
public func GetFuelAmount() { return 30; }
public func GetFuelAmount(int requested_amount) { return 30; } // disregard the parameter, because only a complete chunk should be removed
// Main bridge object is saved.
func SaveScenarioObject() { return false; }

View File

@ -8,4 +8,16 @@ func Disperse()
_inherited(...);
}
func IsFuel(){ return true;}
func GetFuelAmount(int requested_amount)
{
return Min(requested_amount, GetLiquidAmount());
}
func OnFuelRemoved(int amount)
{
DoStackCount(-amount);
return true;
}
local Name="$Name$";