2018-01-28 11:47:36 +00:00
|
|
|
/**
|
2011-03-09 23:21:38 +00:00
|
|
|
Cable Crossing
|
2016-03-25 23:14:20 +00:00
|
|
|
The standard crossing for the cable network.
|
|
|
|
The crossing will automatically be a station if it is at the end of the cable line (i.e. only one cable connected).
|
|
|
|
But the crossing can also manually be set to function as a station.
|
|
|
|
|
2018-01-28 11:47:36 +00:00
|
|
|
@author Clonkonaut
|
|
|
|
*/
|
2011-03-09 23:21:38 +00:00
|
|
|
|
2011-03-29 16:51:30 +00:00
|
|
|
#include Library_CableStation
|
2018-04-02 14:03:52 +00:00
|
|
|
#include Library_Structure
|
|
|
|
#include Library_Ownable
|
2011-03-21 17:49:49 +00:00
|
|
|
|
2017-10-03 23:19:46 +00:00
|
|
|
// Animation
|
2016-03-29 22:55:49 +00:00
|
|
|
local turn_anim;
|
|
|
|
|
2017-10-03 23:19:46 +00:00
|
|
|
// Settings
|
|
|
|
local setting_dropoff = false;
|
|
|
|
|
|
|
|
// Combined building
|
|
|
|
local connected_building;
|
|
|
|
|
|
|
|
// Array of all cable cars currently idling at this station
|
|
|
|
local arrived_cars;
|
|
|
|
|
2018-04-02 14:03:52 +00:00
|
|
|
// Whether this crossing accepts resources.
|
|
|
|
local has_resource_chute;
|
|
|
|
|
|
|
|
|
2018-04-10 12:04:38 +00:00
|
|
|
public func Construction()
|
|
|
|
{
|
|
|
|
SetAction("Default");
|
|
|
|
return _inherited(...);
|
|
|
|
}
|
|
|
|
|
2018-03-31 09:00:24 +00:00
|
|
|
public func Initialize()
|
2016-03-29 22:55:49 +00:00
|
|
|
{
|
|
|
|
turn_anim = PlayAnimation("Engine", 1, Anim_Const(0), Anim_Const(1000));
|
2017-10-03 23:19:46 +00:00
|
|
|
arrived_cars = [];
|
|
|
|
SetCategory(GetCategory() | C4D_StaticBack);
|
2016-03-29 22:55:49 +00:00
|
|
|
return _inherited(...);
|
|
|
|
}
|
|
|
|
|
2016-03-25 23:14:20 +00:00
|
|
|
// Prevents the automatic change of the station status when manually set to station mode
|
|
|
|
local manual_setting = false;
|
2011-03-23 02:09:09 +00:00
|
|
|
|
2018-01-28 11:47:36 +00:00
|
|
|
|
|
|
|
/*-- Library functions: Cable Station --*/
|
2017-10-03 23:19:46 +00:00
|
|
|
|
2016-03-25 23:14:20 +00:00
|
|
|
public func DestinationsUpdated()
|
2011-04-05 15:56:53 +00:00
|
|
|
{
|
2016-03-25 23:14:20 +00:00
|
|
|
// Do nothing if set manually
|
|
|
|
if (manual_setting) return;
|
2018-04-01 18:53:50 +00:00
|
|
|
|
|
|
|
var is_endpoint = GetLength(FindObjects(Find_Func("IsConnectedTo", this))) == 1;
|
|
|
|
if (is_endpoint || connected_building)
|
2016-03-25 23:14:20 +00:00
|
|
|
SetCableStation(true);
|
|
|
|
else
|
|
|
|
SetCableStation(false);
|
|
|
|
CheckStationStatus();
|
2018-01-28 11:47:36 +00:00
|
|
|
|
|
|
|
// Inform all cars at station about the update.
|
|
|
|
for (var car in arrived_cars)
|
|
|
|
if (car)
|
|
|
|
car->~OnRailNetworkUpdate();
|
2018-04-12 07:19:55 +00:00
|
|
|
// Also inform all cars on adjacent cables.
|
|
|
|
for (var cable in FindObjects(Find_Func("IsConnectedTo", this)))
|
|
|
|
cable->OnRailNetworkUpdate();
|
2011-04-05 15:56:53 +00:00
|
|
|
}
|
|
|
|
|
2018-04-14 16:01:50 +00:00
|
|
|
public func IsAvailable(proplist order)
|
2017-10-03 23:19:46 +00:00
|
|
|
{
|
2018-04-12 07:19:55 +00:00
|
|
|
// Check resource chute for contents.
|
2018-04-14 16:01:50 +00:00
|
|
|
if (has_resource_chute && ContentsCount(order.type) >= order.min_amount)
|
2017-10-03 23:19:46 +00:00
|
|
|
return true;
|
2018-04-12 07:19:55 +00:00
|
|
|
// Check cable cars idling at this station.
|
2017-10-03 23:19:46 +00:00
|
|
|
if (GetLength(arrived_cars))
|
|
|
|
{
|
|
|
|
for (var car in arrived_cars)
|
|
|
|
{
|
2018-04-14 16:01:50 +00:00
|
|
|
if (car->~IsAvailable(order))
|
2017-10-03 23:19:46 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2018-04-12 07:19:55 +00:00
|
|
|
// TODO: check connected building.
|
2017-10-03 23:19:46 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-04-14 16:01:50 +00:00
|
|
|
public func GetAvailableCableCar(proplist order, object requesting_station)
|
2017-10-03 23:19:46 +00:00
|
|
|
{
|
|
|
|
// Check cars that are idling at this station
|
|
|
|
var best;
|
|
|
|
for (var car in arrived_cars)
|
|
|
|
{
|
2018-04-14 16:01:50 +00:00
|
|
|
if (!car->~IsReadyForDelivery(order, requesting_station))
|
2017-10-03 23:19:46 +00:00
|
|
|
continue;
|
|
|
|
if (!best)
|
|
|
|
best = car;
|
|
|
|
// A car might want to override the search for an available car, mainly because it holds the container
|
|
|
|
// which holds the requested items
|
2018-04-14 16:01:50 +00:00
|
|
|
else if (car->~OverridePriority(order, requesting_station, best))
|
2017-10-03 23:19:46 +00:00
|
|
|
best = car;
|
|
|
|
}
|
|
|
|
if (best)
|
|
|
|
return best;
|
|
|
|
|
2018-04-14 16:01:50 +00:00
|
|
|
// Check cars that are idling at other crossings in the network.
|
2017-10-03 23:19:46 +00:00
|
|
|
if (requesting_station != this)
|
2018-04-12 07:19:55 +00:00
|
|
|
{
|
2018-04-14 16:01:50 +00:00
|
|
|
// Find closest cars first.
|
|
|
|
var destinations = GetDestinations();
|
|
|
|
SortArrayByArrayElement(destinations, this.const_distance, false);
|
2018-04-15 17:57:57 +00:00
|
|
|
for (var dest in destinations)
|
2018-04-14 16:01:50 +00:00
|
|
|
{
|
|
|
|
var station = dest[this.const_finaldestination];
|
|
|
|
var best = station->~GetAvailableCableCar(order, station);
|
|
|
|
if (best)
|
|
|
|
return best;
|
|
|
|
}
|
2018-04-12 07:19:55 +00:00
|
|
|
}
|
2017-10-03 23:19:46 +00:00
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2018-04-14 16:01:50 +00:00
|
|
|
public func OnCableCarPickUp(object car, proplist order)
|
2018-04-12 07:19:55 +00:00
|
|
|
{
|
|
|
|
car = car->~GetAttachedVehicle() ?? car;
|
|
|
|
|
|
|
|
// Take from resource chute if available.
|
|
|
|
if (has_resource_chute)
|
|
|
|
{
|
2018-04-14 16:01:50 +00:00
|
|
|
var amount = Max(order.min_amount, order.max_amount);
|
2018-04-12 07:19:55 +00:00
|
|
|
while (amount > 0)
|
|
|
|
{
|
2018-04-14 16:01:50 +00:00
|
|
|
var item = FindContents(order.type);
|
2018-04-12 07:19:55 +00:00
|
|
|
if (!item)
|
|
|
|
break;
|
|
|
|
item->Enter(car);
|
|
|
|
amount--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Take from connected building alternatively.
|
|
|
|
if (connected_building)
|
|
|
|
{
|
|
|
|
// TODO: Do we even want this?
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-04-14 16:01:50 +00:00
|
|
|
public func OnCableCarDelivery(object car, proplist order)
|
2017-10-03 23:19:46 +00:00
|
|
|
{
|
|
|
|
// Transfer the requested material to the connected producer
|
|
|
|
if (!connected_building)
|
|
|
|
return;
|
|
|
|
|
|
|
|
car = car->~GetAttachedVehicle() ?? car;
|
2018-04-14 16:01:50 +00:00
|
|
|
var amount = Max(order.min_amount, order.max_amount);
|
|
|
|
while (amount > 0)
|
2017-10-03 23:19:46 +00:00
|
|
|
{
|
2018-04-14 16:01:50 +00:00
|
|
|
var item = car->FindContents(order.type);
|
2017-10-03 23:19:46 +00:00
|
|
|
if (!item)
|
|
|
|
break;
|
|
|
|
item->Enter(connected_building);
|
2018-04-14 16:01:50 +00:00
|
|
|
amount--;
|
2017-10-03 23:19:46 +00:00
|
|
|
}
|
2018-04-14 16:01:50 +00:00
|
|
|
return;
|
2017-10-03 23:19:46 +00:00
|
|
|
}
|
|
|
|
|
2018-01-28 11:47:36 +00:00
|
|
|
|
|
|
|
/*-- Construction --*/
|
2017-10-03 23:19:46 +00:00
|
|
|
|
|
|
|
public func IsHammerBuildable() { return true; }
|
|
|
|
|
2018-04-10 12:04:38 +00:00
|
|
|
public func SetDir(int dir)
|
|
|
|
{
|
|
|
|
if (GetDir() != dir)
|
|
|
|
this.LineAttach = [-this.LineAttach[0], this.LineAttach[1]];
|
|
|
|
return _inherited(dir, ...);
|
|
|
|
}
|
|
|
|
|
2017-10-03 23:19:46 +00:00
|
|
|
public func ConstructionCombineWith() { return "IsNoCableStationConnected"; }
|
|
|
|
|
|
|
|
public func ConstructionCombineDirection(object other)
|
|
|
|
{
|
|
|
|
return CONSTRUCTION_STICK_Left | CONSTRUCTION_STICK_Right;
|
|
|
|
}
|
|
|
|
|
|
|
|
public func ConstructionCombineOffset(proplist other)
|
|
|
|
{
|
|
|
|
if (!other)
|
|
|
|
return;
|
|
|
|
// Make sure the station preview is on the same ground level than the other building
|
2018-04-10 12:04:38 +00:00
|
|
|
return [0, other->GetObjHeight() / 2 - this->GetDefHeight() / 2];
|
2017-10-03 23:19:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public func CombineWith(object stick_to)
|
|
|
|
{
|
|
|
|
if (!stick_to) return;
|
|
|
|
|
2018-04-01 18:53:50 +00:00
|
|
|
if (stick_to->~AcceptsCableStationConnection())
|
2017-10-03 23:19:46 +00:00
|
|
|
{
|
|
|
|
connected_building = stick_to;
|
|
|
|
stick_to->ConnectCableStation(this);
|
2018-04-01 18:53:50 +00:00
|
|
|
SetCableStation(true);
|
|
|
|
CheckStationStatus();
|
2017-10-03 23:19:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-31 09:00:24 +00:00
|
|
|
/*-- Interaction --*/
|
2016-03-25 23:14:20 +00:00
|
|
|
|
|
|
|
// Provides an own interaction menu.
|
|
|
|
public func HasInteractionMenu() { return true; }
|
|
|
|
|
|
|
|
// Show settings in interaction menu
|
|
|
|
public func GetInteractionMenus(object clonk)
|
2011-03-09 23:21:38 +00:00
|
|
|
{
|
2016-11-26 17:57:31 +00:00
|
|
|
var menus = _inherited(clonk, ...) ?? [];
|
2018-04-02 14:03:52 +00:00
|
|
|
// Crossing settings.
|
2016-03-25 23:14:20 +00:00
|
|
|
var crossing_menu =
|
|
|
|
{
|
|
|
|
title = "$StationSettings$",
|
|
|
|
entries_callback = this.GetSettingsMenuEntries,
|
|
|
|
callback = nil,
|
|
|
|
callback_hover = "OnSettingsHover",
|
|
|
|
callback_target = this,
|
|
|
|
BackgroundColor = RGB(0, 0, 50),
|
|
|
|
Priority = 20
|
|
|
|
};
|
|
|
|
PushBack(menus, crossing_menu);
|
2018-04-02 14:03:52 +00:00
|
|
|
// Upgrade options.
|
|
|
|
if (!has_resource_chute)
|
|
|
|
{
|
|
|
|
var upgrade_menu =
|
|
|
|
{
|
|
|
|
title = "$StationUpgrades$",
|
|
|
|
entries_callback = this.GetUpgradeMenuEntries,
|
|
|
|
callback = "OnUpgradeSelected",
|
|
|
|
callback_hover = "OnUpgradeHover",
|
|
|
|
callback_target = this,
|
|
|
|
BackgroundColor = RGB(0, 50, 0),
|
|
|
|
Priority = 40
|
|
|
|
};
|
|
|
|
PushBack(menus, upgrade_menu);
|
|
|
|
}
|
2016-03-25 23:14:20 +00:00
|
|
|
return menus;
|
2011-03-21 17:49:49 +00:00
|
|
|
}
|
|
|
|
|
2016-03-25 23:14:20 +00:00
|
|
|
public func GetSettingsMenuEntries()
|
2011-08-30 23:24:57 +00:00
|
|
|
{
|
2016-03-25 23:14:20 +00:00
|
|
|
var control_prototype =
|
2011-08-30 23:24:57 +00:00
|
|
|
{
|
2016-03-25 23:14:20 +00:00
|
|
|
BackgroundColor = { Std = 0, Selected = RGB(100, 30, 30) },
|
|
|
|
OnMouseIn = GuiAction_SetTag("Selected"),
|
|
|
|
OnMouseOut = GuiAction_SetTag("Std")
|
|
|
|
};
|
|
|
|
|
|
|
|
var custom_entry =
|
2011-08-30 23:24:57 +00:00
|
|
|
{
|
2016-03-25 23:14:20 +00:00
|
|
|
Right = "3em", Bottom = "2em",
|
|
|
|
image = { Prototype = control_prototype }
|
|
|
|
};
|
|
|
|
|
|
|
|
var menu_entries = [];
|
|
|
|
|
2018-03-31 09:00:24 +00:00
|
|
|
// Clickable buttons.
|
2018-04-01 18:53:50 +00:00
|
|
|
var station = new custom_entry
|
|
|
|
{
|
2016-03-25 23:14:20 +00:00
|
|
|
Priority = 1000,
|
|
|
|
Tooltip = "$TooltipToggleStation$",
|
2017-10-03 23:19:46 +00:00
|
|
|
OnClick = GuiAction_Call(this, "ToggleStation", false),
|
|
|
|
image = { Prototype = custom_entry.image }
|
2016-03-25 23:14:20 +00:00
|
|
|
};
|
|
|
|
station.image.Symbol = CableCrossing_Icons;
|
|
|
|
station.image.GraphicsName = "Station";
|
|
|
|
PushBack(menu_entries, { symbol = CableCrossing_Icons, extra_data = "Station", custom = station });
|
|
|
|
|
2018-04-01 18:53:50 +00:00
|
|
|
var drop_off = new custom_entry
|
|
|
|
{
|
2017-10-03 23:19:46 +00:00
|
|
|
Priority = 1001,
|
|
|
|
Tooltip = "$TooltipToggleDropOff$",
|
|
|
|
OnClick = GuiAction_Call(this, "ToggleDropOff", false),
|
|
|
|
image = { Prototype = custom_entry.image }
|
|
|
|
};
|
|
|
|
drop_off.image.Symbol = CableCrossing_Icons;
|
|
|
|
drop_off.image.GraphicsName = "DropOff";
|
|
|
|
PushBack(menu_entries, { symbol = CableCrossing_Icons, extra_data = "DropOff", custom = drop_off });
|
2016-03-25 23:14:20 +00:00
|
|
|
return menu_entries;
|
2011-08-30 23:24:57 +00:00
|
|
|
}
|
|
|
|
|
2016-03-25 23:14:20 +00:00
|
|
|
public func OnSettingsHover(symbol, extra_data, desc_menu_target, menu_id)
|
|
|
|
{
|
|
|
|
if (symbol == nil) return;
|
|
|
|
|
|
|
|
var text = "";
|
|
|
|
if (extra_data == "Station")
|
|
|
|
text = "$DescToggleStation$";
|
2017-10-03 23:19:46 +00:00
|
|
|
if (extra_data == "DropOff")
|
|
|
|
text = "$DescToggleDropOff$";
|
2016-03-25 23:14:20 +00:00
|
|
|
|
2018-04-02 14:03:52 +00:00
|
|
|
GuiUpdate({Text = text}, menu_id, 1, desc_menu_target);
|
|
|
|
}
|
|
|
|
|
|
|
|
public func GetUpgradeMenuEntries()
|
|
|
|
{
|
|
|
|
var menu =
|
|
|
|
{
|
|
|
|
Bottom = "2em",
|
|
|
|
entry =
|
|
|
|
{
|
|
|
|
Bottom = "2em",
|
|
|
|
BackgroundColor = { Std = 0, Selected = RGB(100, 30, 30) },
|
|
|
|
OnMouseIn = GuiAction_SetTag("Selected"),
|
|
|
|
OnMouseOut = GuiAction_SetTag("Std"),
|
|
|
|
right =
|
|
|
|
{
|
|
|
|
Left = "2em + 0.2em",
|
|
|
|
Right = "100% - 0.2em",
|
|
|
|
Text = "$UpgradeChute$",
|
|
|
|
Style = GUI_TextVCenter
|
|
|
|
},
|
|
|
|
symbol =
|
|
|
|
{
|
|
|
|
Right = "2em",
|
|
|
|
Symbol = CableCrossing_Icons
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
return [{symbol = CableCrossing_Icons, extra_data = "upgrade", custom = menu}];
|
|
|
|
}
|
|
|
|
|
|
|
|
public func OnUpgradeHover(id symbol, string action, desc_menu_target, menu_id)
|
|
|
|
{
|
|
|
|
var text = "$DescUpgradeChute$";
|
|
|
|
GuiUpdate({Text = text}, menu_id, 1, desc_menu_target);
|
|
|
|
}
|
|
|
|
|
|
|
|
public func OnUpgradeSelected(id symbol, string action, object cursor)
|
|
|
|
{
|
|
|
|
var hammer = FindObject(Find_Container(cursor), Find_Func("IsConstructor"));
|
|
|
|
|
|
|
|
if (!hammer)
|
|
|
|
{
|
|
|
|
PlayerMessage(cursor->GetOwner(), "$YouNeedAHammer$");
|
|
|
|
Sound("UI::Click2", {player = cursor->GetOwner()});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var metal = FindObject(Find_Container(cursor), Find_ID(Metal));
|
|
|
|
if (!metal)
|
|
|
|
{
|
|
|
|
PlayerMessage(cursor->GetOwner(), "$YouNeedMetal$");
|
|
|
|
Sound("UI::Click2", {player = cursor->GetOwner()});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
metal->RemoveObject();
|
|
|
|
AddResourceChute();
|
|
|
|
Sound("Structures::Repair");
|
|
|
|
UpdateInteractionMenus();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*-- Resource Chute --*/
|
|
|
|
|
|
|
|
public func AddResourceChute()
|
|
|
|
{
|
|
|
|
// TODO: graphics.
|
|
|
|
has_resource_chute = true;
|
|
|
|
AddTimer("CheckResourceChute", 1);
|
|
|
|
return;
|
2016-03-25 23:14:20 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 14:03:52 +00:00
|
|
|
public func CheckResourceChute()
|
|
|
|
{
|
|
|
|
if (GetCon() < 100)
|
|
|
|
return;
|
2018-04-10 12:04:38 +00:00
|
|
|
for (var obj in FindObjects(Find_InRect(-13 + 13 * GetDir(), 3, 13, 13), Find_OCF(OCF_Collectible), Find_NoContainer(), Find_Layer(GetObjectLayer())))
|
2018-04-02 14:03:52 +00:00
|
|
|
Collect(obj, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public func Collection(object obj, bool put)
|
|
|
|
{
|
|
|
|
Sound("Objects::Clonk");
|
|
|
|
}
|
|
|
|
|
|
|
|
public func IsContainer() { return has_resource_chute; }
|
|
|
|
|
2018-04-12 07:19:55 +00:00
|
|
|
public func IsStorage() { return has_resource_chute; }
|
|
|
|
|
2018-04-02 14:03:52 +00:00
|
|
|
local MaxContentsCount = 100;
|
|
|
|
|
|
|
|
public func RejectCollect()
|
|
|
|
{
|
|
|
|
if (ContentsCount() >= this.MaxContentsCount)
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-31 09:00:24 +00:00
|
|
|
/*-- Settings --*/
|
2016-03-25 23:14:20 +00:00
|
|
|
|
|
|
|
public func ToggleStation(bool silent)
|
|
|
|
{
|
|
|
|
SetCableStation(!IsCableStation());
|
|
|
|
if (!manual_setting)
|
|
|
|
manual_setting = true;
|
|
|
|
if (!silent)
|
|
|
|
Sound("UI::Click2");
|
|
|
|
CheckStationStatus();
|
|
|
|
}
|
|
|
|
|
2017-10-03 23:19:46 +00:00
|
|
|
public func ToggleDropOff(bool silent)
|
|
|
|
{
|
|
|
|
if (!setting_dropoff)
|
|
|
|
{
|
|
|
|
if (!IsCableStation())
|
|
|
|
ToggleStation(true);
|
|
|
|
setting_dropoff = true;
|
2018-01-28 11:47:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-10-03 23:19:46 +00:00
|
|
|
setting_dropoff = false;
|
|
|
|
}
|
|
|
|
if (!silent)
|
|
|
|
Sound("UI::Click2");
|
|
|
|
CheckStationStatus();
|
|
|
|
}
|
|
|
|
|
2018-01-28 11:47:36 +00:00
|
|
|
|
|
|
|
/*-- Cable Car Management --*/
|
2017-10-03 23:19:46 +00:00
|
|
|
|
|
|
|
public func OnCableCarArrival(object car)
|
|
|
|
{
|
|
|
|
// Apply all settings to the arriving car
|
|
|
|
if (setting_dropoff)
|
|
|
|
if (car)
|
|
|
|
car->~DropContents(this);
|
|
|
|
|
|
|
|
// Save the car
|
|
|
|
PushBack(arrived_cars, car);
|
|
|
|
}
|
|
|
|
|
2018-01-28 11:47:36 +00:00
|
|
|
public func OnCableCarStopped(object car)
|
|
|
|
{
|
|
|
|
PushBack(arrived_cars, car);
|
|
|
|
}
|
|
|
|
|
2017-10-03 23:19:46 +00:00
|
|
|
public func OnCableCarDeparture(object car)
|
|
|
|
{
|
|
|
|
RemoveArrayValue(arrived_cars, car, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public func OnCableCarEngaged(object car)
|
|
|
|
{
|
|
|
|
PushBack(arrived_cars, car);
|
|
|
|
}
|
|
|
|
|
|
|
|
public func OnCableCarDisengaged(object car)
|
|
|
|
{
|
|
|
|
RemoveArrayValue(arrived_cars, car, true);
|
|
|
|
}
|
|
|
|
|
2018-01-28 11:47:36 +00:00
|
|
|
public func OnCableCarDestruction(object car)
|
|
|
|
{
|
|
|
|
RemoveArrayValue(arrived_cars, car, true);
|
|
|
|
}
|
|
|
|
|
2018-04-15 17:57:57 +00:00
|
|
|
public func GetIdleCars() { return arrived_cars; }
|
|
|
|
|
2016-03-25 23:14:20 +00:00
|
|
|
|
2018-01-28 11:47:36 +00:00
|
|
|
/*-- Visuals --*/
|
|
|
|
|
|
|
|
public func CheckStationStatus()
|
2016-03-25 23:14:20 +00:00
|
|
|
{
|
|
|
|
if (IsCableStation())
|
2017-10-03 23:19:46 +00:00
|
|
|
{
|
|
|
|
// In order of priority
|
|
|
|
if (setting_dropoff)
|
|
|
|
SetMeshMaterial("CableCarStation_SignDropOff", 1);
|
2018-01-28 11:47:36 +00:00
|
|
|
else
|
2017-10-03 23:19:46 +00:00
|
|
|
SetMeshMaterial("CableCarStation_SignStation", 1);
|
|
|
|
}
|
2016-03-25 23:14:20 +00:00
|
|
|
else
|
|
|
|
SetMeshMaterial("CableCarStation_Sign", 1);
|
|
|
|
}
|
|
|
|
|
2016-03-29 22:55:49 +00:00
|
|
|
local activations = 0;
|
|
|
|
|
2018-01-28 11:47:36 +00:00
|
|
|
public func CableActivation(int count)
|
2016-03-29 22:55:49 +00:00
|
|
|
{
|
|
|
|
if (activations <= 0)
|
|
|
|
SetAnimationPosition(turn_anim, Anim_Linear(GetAnimationPosition(turn_anim), 0, GetAnimationLength("Engine"), 175, ANIM_Loop));
|
|
|
|
activations += count;
|
|
|
|
}
|
|
|
|
|
2018-01-28 11:47:36 +00:00
|
|
|
public func CableDeactivation(int count)
|
2016-03-29 22:55:49 +00:00
|
|
|
{
|
|
|
|
activations -= count;
|
|
|
|
if (activations <= 0)
|
|
|
|
SetAnimationPosition(turn_anim, Anim_Const(GetAnimationPosition(turn_anim)));
|
|
|
|
}
|
|
|
|
|
2016-03-25 23:14:20 +00:00
|
|
|
|
2018-01-28 11:47:36 +00:00
|
|
|
/*-- Saving --*/
|
|
|
|
|
|
|
|
public func SaveScenarioObject(props)
|
2011-08-30 23:24:57 +00:00
|
|
|
{
|
2016-03-25 23:14:20 +00:00
|
|
|
if (!inherited(props, ...)) return false;
|
|
|
|
if (IsCableStation() && manual_setting)
|
|
|
|
props->AddCall("StationSetting", this, "ToggleStation", true);
|
|
|
|
if (!IsCableStation() && manual_setting)
|
|
|
|
props->AddCall("ManualSetting", this, "SetManual");
|
2017-10-03 23:19:46 +00:00
|
|
|
if (connected_building)
|
|
|
|
props->AddCall("Combination", this, "CombineWith", connected_building);
|
2011-08-30 23:24:57 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-03-25 23:14:20 +00:00
|
|
|
public func SetManual() { manual_setting = true; return true; }
|
2011-04-05 15:56:53 +00:00
|
|
|
|
2018-01-28 11:47:36 +00:00
|
|
|
|
|
|
|
/*-- Properties --*/
|
2017-10-03 23:19:46 +00:00
|
|
|
|
2018-04-10 12:04:38 +00:00
|
|
|
local ActMap = {
|
|
|
|
Default = {
|
|
|
|
Prototype = Action,
|
|
|
|
Name = "Default",
|
|
|
|
Procedure = DFA_NONE,
|
|
|
|
Directions = 2,
|
|
|
|
FlipDir = 1,
|
|
|
|
Length = 1,
|
|
|
|
Delay = 0,
|
|
|
|
FacetBase = 1,
|
|
|
|
NextAction = "Default",
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-04-28 14:17:38 +00:00
|
|
|
local Name = "$Name$";
|
2018-04-02 14:03:52 +00:00
|
|
|
local BlastIncinerate = 90;
|
|
|
|
local HitPoints = 80;
|
2018-04-10 12:04:38 +00:00
|
|
|
local LineAttach = [8, -9];
|
2018-01-26 07:32:25 +00:00
|
|
|
local Components = {Metal = 1, Wood = 1};
|
2018-04-02 14:03:52 +00:00
|
|
|
local ContainBlast = true;
|
|
|
|
local FireproofContainer = true;
|