1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
/**
Status Symbol
Shows a certain state of an object.
@author Zapper, Maikel
*/
local symbol;
public func Init(object to)
{
SetAction("Be", to);
// Above the object.
var hgt = to->GetDefCoreVal("Height", "DefCore") / 2;
SetVertex(0, VTX_Y, hgt);
var x = to->GetVertex(0, VTX_X);
SetVertex(0, VTX_X, x);
// Set plane to be higher than the object attached to.
this.Plane = Max(to.Plane + 1, 1000);
return;
}
public func GetStatusSymbolHelper(object to)
{
var obj = FindObject(Find_ID(StatusSymbol), Find_ActionTarget(to));
if (obj)
return obj;
obj = CreateObject(StatusSymbol, 0, 0, to->GetOwner());
obj->Init(to);
return obj;
}
global func ShowStatusSymbol(id symbol)
{
if (!this)
return false;
var h = StatusSymbol->GetStatusSymbolHelper(this);
if(!h)
return false;
h->AddSymbol(symbol);
return true;
}
global func RemoveStatusSymbol(id symbol)
{
if (!this)
return false;
var h = StatusSymbol->GetStatusSymbolHelper(this);
if (!h)
return false;
h->RemoveSymbol(symbol);
return true;
}
public func AddSymbol(id symbol_id)
{
symbol = symbol_id;
Update();
}
public func RemoveSymbol(id symbol_id)
{
if (symbol != symbol_id)
return;
symbol = nil;
Update();
}
public func Update()
{
if (!symbol)
{
SetGraphics();
this.Visibility = VIS_None;
return;
}
SetShape(symbol->GetDefOffset(0), symbol->GetDefOffset(1), symbol->GetDefWidth(), symbol->GetDefHeight());
SetGraphics(nil, symbol);
Blink();
return;
}
public func Blink()
{
if (GetEffect("Blinking", this))
RemoveEffect("Blinking", this);
AddEffect("Blinking", this, 1, 16, this);
return;
}
protected func FxBlinkingStart(object target, proplist effect, int temp)
{
if (temp)
return FX_OK;
// Set interval to a fixed number of frames.
effect.Interval = 16;
// Set initial visibility to visible.
this.Visibility = this->GetActionTarget().Visibility;
effect.visible = true;
return FX_OK;
}
protected func FxBlinkingTimer(object target, proplist effect)
{
if (effect.visible)
{
effect.visible = false;
this.Visibility = VIS_None;
}
else
{
effect.visible = true;
this.Visibility = this->GetActionTarget().Visibility;
}
return FX_OK;
}
// Callback from the engine: this symbol has lost its parent.
protected func AttachTargetLost()
{
return RemoveObject();
}
public func SaveScenarioObject() { return false; }
/*-- Properties --*/
local Name = "$Name$";
local Description = "$Description$";
local Plane = 1000;
local ActMap =
{
Be =
{
Prototype = Action,
Name = "Be",
Procedure = DFA_ATTACH,
NextAction = "Be",
Length = 1,
FacetBase = 1,
AbortCall = "AttachTargetLost"
}
};
|