forked from Mirrors/openclonk
cable hoist: new type effect, prevent interactions when attached, complete menu texts
parent
85f1c714f7
commit
330e275b3d
|
@ -60,6 +60,9 @@ public func SetCableSpeed(int value)
|
||||||
lib_ccar_speed = value;
|
lib_ccar_speed = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns the speed of this cable car.
|
||||||
|
public func GetCableSpeed() { return lib_ccar_speed; }
|
||||||
|
|
||||||
// Positioning of the car along the cable
|
// Positioning of the car along the cable
|
||||||
// This should be called regularly, see header comment!
|
// This should be called regularly, see header comment!
|
||||||
public func DoMovement()
|
public func DoMovement()
|
||||||
|
@ -104,6 +107,8 @@ public func DoMovement()
|
||||||
|
|
||||||
public func IsCableCar() { return true; }
|
public func IsCableCar() { return true; }
|
||||||
|
|
||||||
|
public func RejectCableCarPickup() { return true; }
|
||||||
|
|
||||||
public func GetRailTarget() { return lib_ccar_rail; }
|
public func GetRailTarget() { return lib_ccar_rail; }
|
||||||
|
|
||||||
public func IsTravelling() { return lib_ccar_destination; }
|
public func IsTravelling() { return lib_ccar_destination; }
|
||||||
|
|
|
@ -40,11 +40,13 @@ func GetCableOffset(array position, int prec)
|
||||||
|
|
||||||
func Engaged()
|
func Engaged()
|
||||||
{
|
{
|
||||||
|
this.Touchable = 0;
|
||||||
SetAction("OnRail");
|
SetAction("OnRail");
|
||||||
}
|
}
|
||||||
|
|
||||||
func Disengaged()
|
func Disengaged()
|
||||||
{
|
{
|
||||||
|
this.Touchable = 1;
|
||||||
SetAction("Idle");
|
SetAction("Idle");
|
||||||
if (pickup)
|
if (pickup)
|
||||||
DropVehicle();
|
DropVehicle();
|
||||||
|
@ -57,11 +59,11 @@ func GetCableCarExtraMenuEntries(array menu_entries, proplist custom_entry, obje
|
||||||
if (!pickup && GetRailTarget())
|
if (!pickup && GetRailTarget())
|
||||||
{
|
{
|
||||||
// Picking up vehicles
|
// Picking up vehicles
|
||||||
var vehicles = FindObjects(Find_AtPoint(), Find_Category(C4D_Vehicle), Find_Not(Find_Func("RejectCableHoistPickup", this)), Find_Exclude(this), Find_Func(pickup));
|
var vehicles = FindObjects(Find_AtPoint(), Find_Category(C4D_Vehicle), Find_Not(Find_Func("RejectCableCarPickup", this)), Find_Exclude(this));
|
||||||
var i = 0;
|
var i = 0;
|
||||||
for (var vehicle in vehicles)
|
for (var vehicle in vehicles)
|
||||||
{
|
{
|
||||||
if (GetEffect("CableHoistPickup", vehicle)) continue;
|
if (GetEffect("FxCableHoistPickup", vehicle)) continue;
|
||||||
|
|
||||||
var to_pickup = new custom_entry {
|
var to_pickup = new custom_entry {
|
||||||
Priority = 2000 + i,
|
Priority = 2000 + i,
|
||||||
|
@ -86,49 +88,72 @@ func GetCableCarExtraMenuEntries(array menu_entries, proplist custom_entry, obje
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func OnCableCarHover(symbol, extra_data, desc_menu_target, menu_id)
|
||||||
|
{
|
||||||
|
if (symbol && extra_data == "Pickup")
|
||||||
|
{
|
||||||
|
GuiUpdate({ Text = Format("$DescPickup$", symbol->GetName()) }, menu_id, 1, desc_menu_target);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (symbol && extra_data == "Drop")
|
||||||
|
{
|
||||||
|
GuiUpdate({ Text = Format("$DescDrop$", symbol->GetName()) }, menu_id, 1, desc_menu_target);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return _inherited(symbol, extra_data, desc_menu_target, menu_id, ...);
|
||||||
|
}
|
||||||
|
|
||||||
/* Picking up vehicles */
|
/* Picking up vehicles */
|
||||||
|
|
||||||
public func PickupVehicle(object vehicle)
|
public func PickupVehicle(object vehicle)
|
||||||
{
|
{
|
||||||
if (!vehicle) return;
|
if (!vehicle) return;
|
||||||
if (GetEffect("CableHoistPickup", vehicle)) return;
|
if (GetEffect("FxCableHoistPickup", vehicle)) return;
|
||||||
var width = vehicle->GetObjWidth() / 2;
|
var width = vehicle->GetObjWidth() / 2;
|
||||||
var height = vehicle->GetObjHeight() / 2;
|
var height = vehicle->GetObjHeight() / 2;
|
||||||
if (!Inside(GetX(), vehicle->GetX() - width, vehicle->GetX() + width))
|
if (!Inside(GetX(), vehicle->GetX() - width, vehicle->GetX() + width))
|
||||||
if (!Inside(GetY(), vehicle->GetY() - height, vehicle->GetY() + height))
|
if (!Inside(GetY(), vehicle->GetY() - height, vehicle->GetY() + height))
|
||||||
return;
|
return;
|
||||||
|
vehicle->CreateEffect(FxCableHoistPickup, 1, 1, this);
|
||||||
AddEffect("CableHoistPickup", vehicle, 1, 1, this);
|
pickup = vehicle;
|
||||||
UpdateInteractionMenus(this.GetCableCarMenuEntries);
|
UpdateInteractionMenus(this.GetCableCarMenuEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
public func DropVehicle()
|
public func DropVehicle()
|
||||||
{
|
{
|
||||||
if (!pickup) return;
|
if (!pickup) return;
|
||||||
RemoveEffect("CableHoistPickup", pickup);
|
RemoveEffect("FxCableHoistPickup", pickup);
|
||||||
|
pickup = nil;
|
||||||
UpdateInteractionMenus(this.GetCableCarMenuEntries);
|
UpdateInteractionMenus(this.GetCableCarMenuEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
func FxCableHoistPickupStart(object vehicle, proplist effect)
|
local FxCableHoistPickup = new Effect
|
||||||
{
|
{
|
||||||
vehicle->SetPosition(GetX(), GetY()+4);
|
Construction = func(object hoist)
|
||||||
vehicle->SetSpeed(0,0);
|
{
|
||||||
vehicle->SetR(GetR());
|
|
||||||
vehicle->SetRDir(0);
|
this.hoist = hoist;
|
||||||
|
this.vehicle_touchable = Target.Touchable;
|
||||||
pickup = vehicle;
|
Target.Touchable = 0;
|
||||||
}
|
// Follow motion of hoist.
|
||||||
|
Target->SetPosition(this.hoist->GetX(), this.hoist->GetY() + 4);
|
||||||
func FxCableHoistPickupTimer(object vehicle, proplist effect)
|
Target->SetSpeed(0, 0);
|
||||||
{
|
Target->SetR(this.hoist->GetR());
|
||||||
vehicle->SetPosition(GetX(), GetY()+4);
|
Target->SetRDir(0);
|
||||||
vehicle->SetSpeed(0,0);
|
},
|
||||||
}
|
|
||||||
|
Timer = func(int time)
|
||||||
func FxCableHoistPickupStop(object vehicle, proplist effect)
|
{
|
||||||
{
|
// Follow motion of hoist.
|
||||||
pickup = nil;
|
Target->SetPosition(this.hoist->GetX(), this.hoist->GetY() + 4);
|
||||||
}
|
Target->SetSpeed(0, 0);
|
||||||
|
},
|
||||||
|
|
||||||
|
Destruction = func()
|
||||||
|
{
|
||||||
|
Target.Touchable = this.vehicle_touchable;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/* Actions */
|
/* Actions */
|
||||||
|
|
||||||
|
|
|
@ -2,4 +2,6 @@ Name=Schlitten
|
||||||
Description=Zum Aufsatz auf Kabel. Transportiert Fahrzeuge.
|
Description=Zum Aufsatz auf Kabel. Transportiert Fahrzeuge.
|
||||||
|
|
||||||
TooltipPickup=Dieses Fahrzeug an den Schlitten anhängen.
|
TooltipPickup=Dieses Fahrzeug an den Schlitten anhängen.
|
||||||
TooltipDrop=Dieses Fahrzeug vom Schlitten abnehmen.
|
TooltipDrop=Dieses Fahrzeug vom Schlitten abnehmen.
|
||||||
|
DescPickup=%s an den Schlitten anhängen.
|
||||||
|
DescDrop=%s vom Schlitten abnehmen.
|
|
@ -2,4 +2,6 @@ Name=Hoist
|
||||||
Description=To use on a cable. Transports vehicles.
|
Description=To use on a cable. Transports vehicles.
|
||||||
|
|
||||||
TooltipPickup=Attach this vehicle to the hoist.
|
TooltipPickup=Attach this vehicle to the hoist.
|
||||||
TooltipDrop=Drop this vehicle from the hoist.
|
TooltipDrop=Drop this vehicle from the hoist.
|
||||||
|
DescPickup=Attach %s to the hoist.
|
||||||
|
DescDrop=Drop %s from the hoist.
|
Loading…
Reference in New Issue