forked from Mirrors/openclonk
Prototype: Liquid objects as menu icon
It seems that real objects would be nicer.liquid_container
parent
bb74e69fa4
commit
c73993d442
|
@ -102,4 +102,14 @@ func RemoveLiquid(string liquid_name, int amount, object destination)
|
|||
amount = Min(amount, GetLiquidAmount());
|
||||
DoStackCount(-amount);
|
||||
return [liquid_name, amount];
|
||||
}
|
||||
|
||||
|
||||
func GetLiquidID(string liquid_name)
|
||||
{
|
||||
if (liquid_name == "Acid") return Liquid_Acid;
|
||||
if (liquid_name == "Lava") return Liquid_Lava;
|
||||
if (liquid_name == "Oil") return Liquid_Oil;
|
||||
if (liquid_name == "Water") return Liquid_Water;
|
||||
return nil;
|
||||
}
|
|
@ -169,8 +169,9 @@ func Construction()
|
|||
{
|
||||
// use proplist to avoid name clashes
|
||||
lib_liquid_container = {
|
||||
liquid = nil, // the liquid - this should be a string, so that the container may contain liquids that are not materials
|
||||
volume = 0}; // the stored amount
|
||||
liquid = nil, // the liquid - this should be a string, so that the container may contain liquids that are not materials
|
||||
volume = 0, // the stored amount
|
||||
icon = nil}; // the display object
|
||||
|
||||
_inherited(...);
|
||||
}
|
||||
|
@ -193,5 +194,28 @@ func SetLiquidContainer(string liquid_name, int amount)
|
|||
// interface for updating graphics, etc
|
||||
func UpdateLiquidContainer()
|
||||
{
|
||||
// do nothing by default
|
||||
if (this->HasLiquidDisplay())
|
||||
{
|
||||
var liquid_id = Library_Liquid->GetLiquidID(GetLiquidType());
|
||||
if (liquid_id)
|
||||
{
|
||||
if (lib_liquid_container.icon
|
||||
&& lib_liquid_container.icon->GetID() != liquid_id)
|
||||
lib_liquid_container.icon->RemoveObject();
|
||||
|
||||
if (!lib_liquid_container.icon)
|
||||
lib_liquid_container.icon = CreateContents(liquid_id);
|
||||
|
||||
lib_liquid_container.icon->~SetStackCount(GetLiquidFillLevel());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (lib_liquid_container.icon)
|
||||
{
|
||||
lib_liquid_container.icon->RemoveObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func HasLiquidDisplay(){ return true;}
|
||||
|
|
|
@ -33,6 +33,8 @@ local max_clog_count = 5; // note that even when max_clog_count is reached, the
|
|||
public func IsLiquidPump() { return true; }
|
||||
public func IsLiquidContainer() { return false; }
|
||||
public func IsLiquidTank() { return false; }
|
||||
public func HasLiquidDisplay(){ return false;}
|
||||
|
||||
|
||||
// The pump is rather complex for players. If anything happened, tell it to the player via the interaction menu.
|
||||
local last_status_message;
|
||||
|
|
|
@ -38,6 +38,7 @@ public func IsContainer() { return true; }
|
|||
|
||||
protected func RejectCollect(id item, object obj)
|
||||
{
|
||||
if (item == lib_liquid_container.icon) return false;
|
||||
if (obj->~IsFuel())
|
||||
return false;
|
||||
return true;
|
||||
|
@ -52,9 +53,9 @@ public func ContentsCheck()
|
|||
{
|
||||
// Ejects non fuel items immediately
|
||||
var fuel;
|
||||
if(fuel = FindObject(Find_Container(this), Find_Not(Find_Func("IsFuel"))))
|
||||
if(fuel = FindObject(Find_Container(this), Find_Not(Find_Func("IsFuel")), Find_Exclude(lib_liquid_container.icon)))
|
||||
{
|
||||
fuel->Exit(-53, 21, -20, -1, -1, -30);
|
||||
fuel->Exit(-45, 21, -20, -1, -1, -30);
|
||||
Sound("Chuff");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue