forked from Mirrors/openclonk
allow pumping liquids from container (foundry and steam engine)
parent
52626fe021
commit
c7afed1aeb
|
@ -10,9 +10,11 @@
|
|||
|
||||
public func GetLiquidType() { return "Concrete"; }
|
||||
|
||||
public func GetLiquidMaterial() { return "Granite"; }
|
||||
|
||||
public func Disperse(int angle, int strength)
|
||||
{
|
||||
DisperseMaterial("Rock", GetLiquidAmount(), strength, angle);
|
||||
DisperseMaterial(GetLiquidMaterial(), GetLiquidAmount(), strength, angle);
|
||||
_inherited(angle, strength, ...);
|
||||
}
|
||||
|
||||
|
@ -25,9 +27,9 @@ public func Construction(object creator)
|
|||
{
|
||||
var res = _inherited(creator, ...);
|
||||
// If the concrete is created by the foundry we can safely assume it has been produced
|
||||
// and set the stack count to 100.
|
||||
if (creator->~IsProducer())
|
||||
SetStackCount(100);
|
||||
// and set the stack count to 100. The only exceptions are CreateContents script calls.
|
||||
if (creator && creator->~IsProducer())
|
||||
SetStackCount(200);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -35,4 +37,4 @@ public func Construction(object creator)
|
|||
|
||||
local Name = "$Name$";
|
||||
local Description = "$Description$";
|
||||
local Components = {Rock = 1, Water = 100};
|
||||
local Components = {Rock = 2, Water = 100};
|
Binary file not shown.
Before Width: | Height: | Size: 141 B |
|
@ -9,10 +9,9 @@
|
|||
*/
|
||||
|
||||
#include Library_Stackable
|
||||
|
||||
static const FX_LIQUID_Dispersion = "IntLiquidDispersion";
|
||||
|
||||
func IsLiquid() { return true;}
|
||||
|
||||
func IsLiquid() { return true; }
|
||||
func InitialStackCount(){ return 1; }
|
||||
func MaxStackCount()
|
||||
{
|
||||
|
@ -46,6 +45,13 @@ func GetLiquidType()
|
|||
return "undefined";
|
||||
}
|
||||
|
||||
// The material maybe different from the type, for example concrete differs from its material granite.
|
||||
public func GetLiquidMaterial()
|
||||
{
|
||||
// Default to the liquid type.
|
||||
return this->GetLiquidType();
|
||||
}
|
||||
|
||||
func GetLiquidAmount()
|
||||
{
|
||||
return GetStackCount();
|
||||
|
@ -61,20 +67,19 @@ func Departure(object container)
|
|||
|
||||
func TriggerDispersion()
|
||||
{
|
||||
var fx = GetEffect(FX_LIQUID_Dispersion, this);
|
||||
var fx = GetEffect("IntLiquidDispersion", this);
|
||||
if (!fx)
|
||||
{
|
||||
AddEffect(FX_LIQUID_Dispersion, this, 1, 1, this);
|
||||
AddEffect("IntLiquidDispersion", this, 1, 1, this);
|
||||
}
|
||||
}
|
||||
|
||||
func FxIntLiquidDispersionTimer(object target, proplist fx, int timer)
|
||||
{
|
||||
if (!(target->Contained()))
|
||||
if (!target->Contained())
|
||||
{
|
||||
target->Disperse();
|
||||
}
|
||||
|
||||
return FX_Execute_Kill;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,25 @@ func GetLiquidContents()
|
|||
//
|
||||
// Interfaces for interaction with other objects
|
||||
|
||||
|
||||
// Returns whether this container has the requested liquid and returns that liquid.
|
||||
// If liquid_name == nil it returns the first liquid found.
|
||||
public func HasLiquid(string liquid_name)
|
||||
{
|
||||
for (var liquid in GetLiquidContents())
|
||||
{
|
||||
if (liquid_name != nil)
|
||||
{
|
||||
if (liquid_name == liquid->GetLiquidType())
|
||||
return liquid;
|
||||
}
|
||||
else
|
||||
return liquid;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Extracts liquid from the container.
|
||||
@param liquid_name: Material to extract; Wildcardsupport
|
||||
|
|
|
@ -47,7 +47,7 @@ public func Construction()
|
|||
_inherited(...);
|
||||
}
|
||||
|
||||
public func IsLiquidTank() { return true;}
|
||||
public func IsLiquidTank() { return true; }
|
||||
|
||||
/* ---------- Menu Entries ---------- */
|
||||
|
||||
|
@ -202,6 +202,7 @@ public func DoCutPipe(object pipe)
|
|||
|
||||
public func DoSwapSourceDrain(object source, object drain)
|
||||
{
|
||||
// TODO: Check if swapping is even allowed.
|
||||
SetDrainPipe(source);
|
||||
SetSourcePipe(drain);
|
||||
source->SetDrainPipe();
|
||||
|
|
|
@ -73,7 +73,6 @@ func Collection()
|
|||
|
||||
public func FxSmeltingTimer(object target, proplist effect, int time)
|
||||
{
|
||||
//Message(Format("Smelting %d",timer));
|
||||
// Fire in the furnace.
|
||||
CreateParticle("Fire", -10 * GetCalcDir() + RandomX(-1, 1), 20 + RandomX(-1, 1), PV_Random(-1, 1), PV_Random(-1, 1), PV_Random(3, 10), Particles_Fire(), 2);
|
||||
|
||||
|
@ -125,37 +124,61 @@ public func OnProductEjection(object product)
|
|||
|
||||
/*-- Pipeline --*/
|
||||
|
||||
func IsLiquidContainerForMaterial(string liquid)
|
||||
public func IsLiquidContainerForMaterial(string liquid)
|
||||
{
|
||||
return WildcardMatch("Oil", liquid) || WildcardMatch("Water", liquid) || WildcardMatch("Concrete", liquid);
|
||||
}
|
||||
|
||||
func QueryConnectPipe(object pipe)
|
||||
// The foundry may have one drain and one source.
|
||||
public func QueryConnectPipe(object pipe)
|
||||
{
|
||||
if (GetNeutralPipe())
|
||||
if (GetDrainPipe() && GetSourcePipe())
|
||||
{
|
||||
pipe->Report("$MsgHasPipes$");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pipe->IsDrainPipe() || pipe->IsNeutralPipe())
|
||||
else if (GetSourcePipe() && pipe->IsSourcePipe())
|
||||
{
|
||||
return false;
|
||||
pipe->Report("$MsgSourcePipeProhibited$");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
else if (GetDrainPipe() && pipe->IsDrainPipe())
|
||||
{
|
||||
pipe->Report("$MsgDrainPipeProhibited$");
|
||||
return true;
|
||||
}
|
||||
else if (pipe->IsAirPipe())
|
||||
{
|
||||
pipe->Report("$MsgPipeProhibited$");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
func OnPipeConnect(object pipe, string specific_pipe_state)
|
||||
// Set to source or drain pipe.
|
||||
public func OnPipeConnect(object pipe, string specific_pipe_state)
|
||||
{
|
||||
SetNeutralPipe(pipe);
|
||||
if (PIPE_STATE_Source == specific_pipe_state)
|
||||
{
|
||||
SetSourcePipe(pipe);
|
||||
pipe->SetSourcePipe();
|
||||
}
|
||||
else if (PIPE_STATE_Drain == specific_pipe_state)
|
||||
{
|
||||
SetDrainPipe(pipe);
|
||||
pipe->SetDrainPipe();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!GetDrainPipe())
|
||||
OnPipeConnect(pipe, PIPE_STATE_Drain);
|
||||
else if (!GetSourcePipe())
|
||||
OnPipeConnect(pipe, PIPE_STATE_Source);
|
||||
}
|
||||
pipe->Report("$MsgConnectedPipe$");
|
||||
}
|
||||
|
||||
func GetLiquidContainerMaxFillLevel()
|
||||
public func GetLiquidContainerMaxFillLevel()
|
||||
{
|
||||
return 300;
|
||||
}
|
||||
|
@ -163,7 +186,6 @@ func GetLiquidContainerMaxFillLevel()
|
|||
|
||||
/*-- Properties --*/
|
||||
|
||||
|
||||
local ActMap = {
|
||||
Default = {
|
||||
Prototype = Action,
|
||||
|
@ -179,8 +201,9 @@ local ActMap = {
|
|||
};
|
||||
|
||||
func Definition(def) {
|
||||
SetProperty("PictureTransformation", Trans_Mul(Trans_Translate(2000,0,7000),Trans_Rotate(-20,1,0,0),Trans_Rotate(30,0,1,0)), def);
|
||||
def.PictureTransformation = Trans_Mul(Trans_Translate(2000,0,7000),Trans_Rotate(-20,1,0,0),Trans_Rotate(30,0,1,0));
|
||||
}
|
||||
|
||||
local Name = "$Name$";
|
||||
local Description = "$Description$";
|
||||
local ContainBlast = true;
|
||||
|
|
|
@ -2,5 +2,7 @@ Name=Hochofen
|
|||
Description=Im Hochofen können Erze zu Barren geschmolzen werden. Dafür wird ein Brennstoff benötigt.
|
||||
|
||||
MsgConnectedPipe=Rohr angeschlossen.
|
||||
MsgPipeProhibited=Zuflussrohre können nicht an den Hochofen angeschlossen werden.
|
||||
MsgHasPipes=Der Hochofen hat schon ein Rohr.
|
||||
MsgPipeProhibited=Dieses Rohr kann nicht an den Hochofen angeschlossen werden.
|
||||
MsgHasPipes=Der Hochofen hat schon ein Zu- und Abflussrohr.
|
||||
MsgSourcePipeProhibited=Zuflussrohre können nicht an den Hochofen angeschlossen werden.
|
||||
MsgDrainPipeProhibited=Abflussrohre können nicht an den Hochofen angeschlossen werden.
|
|
@ -2,5 +2,7 @@ Name=Foundry
|
|||
Description=In the foundry, ore can be smelted into ingots. Fuel, such as coal, is necessary for this.
|
||||
|
||||
MsgConnectedPipe=Connected pipe.
|
||||
MsgPipeProhibited=Source pipes cannot be connected to the foundry.
|
||||
MsgHasPipes=The foundry already has a pipe.
|
||||
MsgPipeProhibited=This pipe cannot be connected to the foundry.
|
||||
MsgHasPipes=Foundry already has a source and a drain pipe.
|
||||
MsgSourcePipeProhibited=Unable to connect source pipe to the foundry.
|
||||
MsgDrainPipeProhibited=Unable to connect drain pipe to the foundry.
|
|
@ -162,8 +162,8 @@ private func SetInfoMessage(string msg)
|
|||
UpdateInteractionMenus(this.GetPumpControlMenuEntries);
|
||||
}
|
||||
|
||||
/*-- Pipe control --*/
|
||||
|
||||
/*-- Pipe control --*/
|
||||
|
||||
func QueryConnectPipe(object pipe)
|
||||
{
|
||||
|
@ -234,7 +234,6 @@ func OnPipeConnect(object pipe, string specific_pipe_state)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
func OnPipeDisconnect(object pipe)
|
||||
{
|
||||
_inherited(pipe);
|
||||
|
@ -409,6 +408,8 @@ func InsertMaterialAtDrain(object drain_obj, string material_name, int amount)
|
|||
{
|
||||
// convert to actual material, and insert remaining
|
||||
var material_index = Material(material_name);
|
||||
if (material_index == -1 && material_name != nil)
|
||||
material_index = Material(GetDefinition(material_name)->GetLiquidMaterial());
|
||||
if (material_index != -1)
|
||||
{
|
||||
while (amount > 0 && drain_obj->InsertMaterial(material_index, drain_obj.ApertureOffsetX, drain_obj.ApertureOffsetY))
|
||||
|
@ -595,10 +596,17 @@ private func PumpHeight2Power(int pump_height)
|
|||
private func GetLiquidSourceMaterial()
|
||||
{
|
||||
// Get the source object and check whether there is liquid.
|
||||
// TODO: If the source is a liquid container check which material will be supplied.
|
||||
var source_obj = GetSourceObject();
|
||||
if (!source_obj)
|
||||
return;
|
||||
// The source is a liquid container: check which material will be supplied.
|
||||
if (source_obj->~IsLiquidContainer())
|
||||
{
|
||||
var liquid = source_obj->HasLiquid();
|
||||
if (liquid)
|
||||
return liquid->GetLiquidType();
|
||||
return;
|
||||
}
|
||||
var is_liquid = source_obj->GBackLiquid(source_obj.ApertureOffsetX, source_obj.ApertureOffsetY);
|
||||
var liquid = MaterialName(source_obj->GetMaterial(source_obj.ApertureOffsetX, source_obj.ApertureOffsetY));
|
||||
if (!is_liquid)
|
||||
|
@ -616,7 +624,10 @@ private func GetLiquidDrainOk(string liquid)
|
|||
var drain_obj = GetDrainObject();
|
||||
if (drain_obj->~HasAperture())
|
||||
{
|
||||
if (!drain_obj->CanInsertMaterial(Material(liquid), drain_obj.ApertureOffsetX, drain_obj.ApertureOffsetY))
|
||||
var material_index = Material(liquid);
|
||||
if (material_index == -1 && liquid != nil)
|
||||
material_index = Material(GetDefinition(liquid)->GetLiquidMaterial());
|
||||
if (!drain_obj->CanInsertMaterial(material_index, drain_obj.ApertureOffsetX, drain_obj.ApertureOffsetY))
|
||||
{
|
||||
drain_obj->~CycleApertureOffset(this); // try different offsets, so we can resume pumping after clog because 1px of earth was dropped on the source pipe
|
||||
return false;
|
||||
|
|
|
@ -187,41 +187,66 @@ func Smoking()
|
|||
}
|
||||
|
||||
|
||||
func IsLiquidContainerForMaterial(string liquid)
|
||||
public func IsLiquidContainerForMaterial(string liquid)
|
||||
{
|
||||
return WildcardMatch("Oil", liquid);
|
||||
}
|
||||
|
||||
func GetLiquidContainerMaxFillLevel()
|
||||
public func GetLiquidContainerMaxFillLevel()
|
||||
{
|
||||
return 300;
|
||||
}
|
||||
|
||||
func QueryConnectPipe(object pipe)
|
||||
// The foundry may have one drain and one source.
|
||||
public func QueryConnectPipe(object pipe)
|
||||
{
|
||||
if (GetNeutralPipe())
|
||||
if (GetDrainPipe() && GetSourcePipe())
|
||||
{
|
||||
pipe->Report("$MsgHasPipes$");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pipe->IsDrainPipe() || pipe->IsNeutralPipe())
|
||||
else if (GetSourcePipe() && pipe->IsSourcePipe())
|
||||
{
|
||||
return false;
|
||||
pipe->Report("$MsgSourcePipeProhibited$");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
else if (GetDrainPipe() && pipe->IsDrainPipe())
|
||||
{
|
||||
pipe->Report("$MsgDrainPipeProhibited$");
|
||||
return true;
|
||||
}
|
||||
else if (pipe->IsAirPipe())
|
||||
{
|
||||
pipe->Report("$MsgPipeProhibited$");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
func OnPipeConnect(object pipe, string specific_pipe_state)
|
||||
// Set to source or drain pipe.
|
||||
public func OnPipeConnect(object pipe, string specific_pipe_state)
|
||||
{
|
||||
SetNeutralPipe(pipe);
|
||||
if (PIPE_STATE_Source == specific_pipe_state)
|
||||
{
|
||||
SetSourcePipe(pipe);
|
||||
pipe->SetSourcePipe();
|
||||
}
|
||||
else if (PIPE_STATE_Drain == specific_pipe_state)
|
||||
{
|
||||
SetDrainPipe(pipe);
|
||||
pipe->SetDrainPipe();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!GetDrainPipe())
|
||||
OnPipeConnect(pipe, PIPE_STATE_Drain);
|
||||
else if (!GetSourcePipe())
|
||||
OnPipeConnect(pipe, PIPE_STATE_Source);
|
||||
}
|
||||
pipe->Report("$MsgConnectedPipe$");
|
||||
}
|
||||
|
||||
|
||||
/*-- Properties --*/
|
||||
|
||||
local ActMap = {
|
||||
|
|
|
@ -2,5 +2,7 @@ Name=Dampfmaschine
|
|||
Description=Die Dampfmaschine erzeugt Strom aus Brennstoffen wie Kohle, Holz oder Öl.
|
||||
|
||||
MsgConnectedPipe=Rohr angeschlossen.
|
||||
MsgPipeProhibited=Zuflussrohre können nicht an die Dampfmaschine angeschlossen werden.
|
||||
MsgHasPipes=Die Dampfmaschine hat schon ein Rohr.
|
||||
MsgPipeProhibited=Dieses Rohr kann nicht an die Dampfmaschine angeschlossen werden.
|
||||
MsgHasPipes=Die Dampfmaschine hat schon ein Zu- und Abflussrohr.
|
||||
MsgSourcePipeProhibited=Zuflussrohre können nicht an die Dampfmaschine angeschlossen werden.
|
||||
MsgDrainPipeProhibited=Abflussrohre können nicht an die Dampfmaschine angeschlossen werden.
|
|
@ -2,5 +2,7 @@ Name=Steam engine
|
|||
Description=The steam engine generates electricity from fuel, such as coal, wood or oil.
|
||||
|
||||
MsgConnectedPipe=Connected pipe.
|
||||
MsgPipeProhibited=Source pipes cannot be connected to the steam engine.
|
||||
MsgHasPipes=The steam engine already has a pipe.
|
||||
MsgPipeProhibited=This pipe cannot be connected to the steam engine.
|
||||
MsgHasPipes=Steam engine already has a source and a drain pipe.
|
||||
MsgSourcePipeProhibited=Unable to connect source pipe to the steam engine.
|
||||
MsgDrainPipeProhibited=Unable to connect drain pipe to the steam engine.
|
Loading…
Reference in New Issue