forked from Mirrors/openclonk
Catapult and cannon: Add functions to rotate instantly.
Useful for scenario designers.liquid_container
parent
439b1f481c
commit
775533a8da
|
@ -214,15 +214,25 @@ func ControlRight(object clonk)
|
|||
}
|
||||
}
|
||||
|
||||
func TurnCannon(int dir)
|
||||
public func TurnCannon(int dir, bool instant)
|
||||
{
|
||||
turnDir = dir;
|
||||
//Remove any old effect
|
||||
if(GetEffect("IntTurnCannon", this)) RemoveEffect("IntTurnCannon", this);
|
||||
//Add a new one
|
||||
return AddEffect("IntTurnCannon", this, 1, 1, this);
|
||||
// Instant turn?
|
||||
if (instant)
|
||||
{
|
||||
// Simply set anim position to desired side
|
||||
var target = 0;
|
||||
if (dir == DIR_Left) target = GetAnimationLength("TurnRight");
|
||||
SetAnimationPosition(animTurn, Anim_Const(target));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Non-instant turn: Add timer to adjust animation (I wonder why it's not just using Anim_Linear?)
|
||||
return AddEffect("IntTurnCannon", this, 1, 1, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func FxIntTurnCannonTimer(object cannon, proplist effect, int timer)
|
||||
{
|
||||
|
|
|
@ -77,6 +77,15 @@ func ControlRight(object clonk)
|
|||
}
|
||||
}
|
||||
|
||||
public func TurnLeft()
|
||||
{
|
||||
// Instantly set catapult orientation to face left
|
||||
var len = GetAnimationLength("TurnLeft");
|
||||
turn_anim = PlayAnimation("TurnLeft", 5, Anim_Linear(len, 0, len, 1, ANIM_Hold));
|
||||
dir = olddir = DIR_Left;
|
||||
return true;
|
||||
}
|
||||
|
||||
public func HoldingEnabled() { return true; }
|
||||
|
||||
public func ControlUseStart(object clonk)
|
||||
|
|
Loading…
Reference in New Issue