Different graphics for drain and source pipe (#1230).

shapetextures
Clonkonaut 2015-10-06 01:34:28 +02:00
parent 77e5cf6263
commit 0d969e8c7a
4 changed files with 40 additions and 5 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@ -14,7 +14,7 @@ local ActMap = {
}
};
protected func Initialize()
private func Initialize()
{
SetAction("Connect");
SetVertexXY(0, GetX(), GetY());
@ -23,6 +23,18 @@ protected func Initialize()
return;
}
// Reddish colour
public func SetDrain()
{
SetProperty("LineColors", [RGB(110, 80, 80), RGB(110, 80, 80)]);
}
// Greenish colour
public func SetSource()
{
SetProperty("LineColors", [RGB(80, 110, 80), RGB(80, 110, 80)]);
}
/** Returns true if this object is a functioning pipe. */
public func IsPipeLine()
{
@ -45,14 +57,28 @@ public func GetConnectedObject(object obj)
return;
}
protected func LineBreak(bool no_msg)
private func LineBreak(bool no_msg)
{
Sound("LineBreak");
if (!no_msg)
BreakMessage();
var line_end = GetActionTarget(0);
if (line_end->GetID() != Pipe)
line_end = GetActionTarget(1);
if (line_end) line_end->~ResetPicture();
return;
}
private func Destruction()
{
var line_end = GetActionTarget(0);
if (line_end->GetID() != Pipe)
line_end = GetActionTarget(1);
if (line_end) line_end->~ResetPicture();
}
private func BreakMessage()
{
var line_end = GetActionTarget(0);
@ -63,9 +89,9 @@ private func BreakMessage()
return;
}
func SaveScenarioObject(props)
public func SaveScenarioObject(props)
{
if (!inherited(props, ...)) return false;
SaveScenarioObjectAction(props);
return true;
}
}

View File

@ -51,16 +51,26 @@ protected func ControlUse(object clonk, int x, int y)
{
liquid_pump->SetSource(pipe);
clonk->Message("$MsgCreatedSource$");
SetGraphics("Source", Pipe, GFX_Overlay, GFXOV_MODE_Picture);
pipe->SetSource();
}
// Otherwise if liquid pump has no drain, create one.
else
{
liquid_pump->SetDrain(pipe);
clonk->Message("$MsgCreatedDrain$");
SetGraphics("Drain", Pipe, GFX_Overlay, GFXOV_MODE_Picture);
pipe->SetDrain();
}
return true;
}
// Line broke or something
public func ResetPicture()
{
SetGraphics("", nil, GFX_Overlay, GFXOV_MODE_Picture);
}
/* Cycling through several aperture offset indices to prevent easy clogging */
// default: pump from bottom vertex
@ -76,7 +86,6 @@ public func CycleApertureOffset()
return true;
}
/* Container dies: Drop connected pipes so they don't draw huge lines over the landscape */
public func IsDroppedOnDeath(object clonk)