Electric Locomotive

The Electric Locomotive is a vehicle used to transport cargo and engineers along the Railway. Connected Freight Cars can be loaded or unloaded via Freight Platforms. The Electric Locomotive can be automated, by setting a list of Train Stations for it to stop at.

Multiple cargo freight cars and locomotives can be chained together to form a single train. The train is currently the fastest vehicle in-game, allowing for efficient long-range resource transportation.

Power Consumption
The Electric Locomotive requires a minimum of 25MW to operate at all times, even when stationary or docked at a Train Station. It may draw up to 110MW when accelerating, with the exact amount depending on how much "strain" the engine is under; for example, it will use more power when climbing a hill than on a level track. Likewise, it will automatically dial back the power consumption when under less strain, dropping to its minimum 25MW when going downhill. A locomotive cannot accelerate unless the railway is powered, but it can always use its brakes.

In a multiplayer game, the locomotive will always appear powerless to the client and cannot be controlled or its schedule altered.

Note that the power consumption shown in the HUD is multiplied per engine on that train. For example, when driving a train with four engines and drawing the maximum load of 110MW, you are actually consuming 440MW total.

Construction
A locomotive can only be constructed on a railway. The face with the windshield is the front and the side with 6 motors is the rear. When driving a train manually, you can travel at full speed both forward and backward regardless of the position or direction of the locomotive within the train. However, auto-pilot can only travel in a given direction if there is at least one engine at the front of the train. For example, a train with three engines facing forward can only drive forward with auto-pilot and requires a loop at the end of the line to turn around; a train with the first and last engine facing forward and the middle engine facing backward can still only travel forward; a train with the front two engines facing forward and the last engine facing backward can be automated in both directions and no longer needs to turn around. Every engine always provides full torque regardless of direction of travel.

Locomotives automatically engage the brakes when there is no driver. Thus they can be freely built on a slope and will eventually come to a stop if you jump out of a moving train with no auto-pilot. To add more locomotives or freight cars to the train, simply aim at the railway in front of or behind the train and the blueprint will usually snap in place. Sometimes the blueprint will not look like it is snapping, but building the engine or car anyways will still connect it to the rest of the train if it is close enough that it should snap. There is no way to edit the middle of a train; the only way to edit the middle of a train is to dismantle the whole thing and rebuild it in the new layout. Engines or cars can be added even when the train is moving, but only by the host in multiplayer games.

A locomotive cannot be dismantled while it is moving or on an automatic schedule, only when it is completely stationary and auto-pilot is disabled. However, the railway beneath it can be dismantled and the train will abruptly halt and remain floating in the air.

Usage
Entering a train with auto-pilot disabled will allow you to drive it manually. Holding the forward or backward directional key will begin "revving up" the engines, slowly increasing the power consumption until the motors generate enough torque to overcome its weight and the train begins to accelerate in that direction.

Trains have two different braking systems:
 * Pressing the directional key in the opposite direction of travel will engage the normal brakes. They are quiet and have no outward visual sign of being engaged except the flashing UI element that says "BRAKE" and partially extending the air brake flaps (the panels on top of the locomotive) when traveling forward at very high speed. These brakes are less effective at high speed and reach maximum stopping power below approximately 50 km/h.
 * Pressing the handbrake key (default is space) will engage the emergency brakes. They are loud and engage multiple moving parts across the train, including fully extending the air brake flaps, lowering a large brake pad located between the two sets of wheels on locomotives which presses directly onto the railway itself, and pressing brake pads against every wheel on the entire train, including freight cars, which creates a high pitched squealing sound, make freight car wheels glow red at high enough speeds, and release a jet of air pressure upon reaching a full halt. These brakes have the same stopping power regardless of your current speed.

Either brake system can be engaged separately or both can be engaged together for maximum stopping power. When stopped on an incline, even a very gentle one, releasing both brakes will cause the train to begin rolling downhill. If it is for some reason necessary to remain stopped on an incline and manually holding the brakes is to be avoided, exiting the train will automatically engage the brakes and they will remain "locked" down even after re-entering the train until some input is received or auto-pilot is engaged. Under its own power, a locomotive's top speed is approximately 120 km/h on a flat railway. Its top speed is slower when climbing a steep incline, but should always be capable of reaching at least 54 km/h so long as the train is not too heavy for the engines. When rolling downhill it can rapidly accelerate well beyond its top speed, nearly 500 km/h given a long enough hill (see image).

Currently trains can only collide with wheeled vehicles and will pass freely through everything else, including natural terrain, player-built structures, other trains, and even the player themselves, doing no damage and losing no momentum. The sides of the train do have collision boxes, but only to prevent the engineer from clipping through the sides.

Train length
If used on a very flat railway, a single locomotive can pull dozens of freight cars, possibly with no limit if the railway is perfectly flat, only with progressively slower acceleration.

However, even a slight incline will cause the weight of the cars to quickly overcome the engine and it will begin to roll backwards. Using natural hills or building a mixture of 2m and 4m ramps it is possible to achieve the steepest possible incline (see railway for more details), but a chain of 2m ramps or double ramps is the steepest incline that can support a railway and can be quickly and easily built. Using such an incline as a testing area, a single locomotive is just barely capable of pulling 5 freight cars without losing speed and can even start from a full stop on such an incline, but it is very slow and is unlikely to work in any rail system with hills, and six cars causes the train to slowly lose speed and eventually start rolling backwards given a long enough climb. Therefore it is recommended to maintain a ratio of no more than 4 cars per locomotive, but the flatter the railway, the fewer locomotives are required.

Tips for item transportation
The speed at which a train can transport items is dependent on a few factors:
 * Total round-trip time of the train
 * Number of freight cars
 * Inventory of each freight car (currently 32 Stacks)
 * Stack size of the transported items
 * (Input to the train station / should be handled by conveyors)

Most likely a certain transport speed is needed by the Engineer, similar to the speed of the conveyor belt in the unit items/minute. Therefore the following formula can be applied to calculate the needed amount of freight cars for the desired item speed (DS):

Number of freight cars = (DS [items/min] * RoundTripTime [min]) / (StackSize * 32)

For each item with different stack sizes, this calculation needs to be done. The round trip time depends on the speed of the train (number of locomotives), the length of the train (number of cars), the length and incline of the track as well as loading/unloading time (both combined are 50 seconds). One full cycle should be measured with a stopwatch to determine the RoundTripTime.


 * For higher throughput, it is advantageous to extend the current train length instead of adding more trains. This also saves power.
 * The train average speed reduces as the distance reduces. Thus it could be disadvantageous to use trains for short-distance transportation.

Round trip time
Two end-to-end stations with a fixed length of railway in between are built, and the time taken for a round trip is measured: The train is configured as a 1-n-1 double-headed train, where n is the number of freight cars attached in-between.

First test: Distance = 8km (approx. diagonal length of the map)

Second test: Distance = 800m (approx. the distance from grass field to coal) (Further testing is required)

A double-headed train with no freight car and manual drive is measured as a reference. Where a freight car is present, the loading and unloading time of 25 seconds at each station is included.

Automation
Pressing the vehicle menu while inside the train or interacting with any connected train station will bring up the train schedule menu. This allows you to toggle auto-pilot on or off and to edit the automation route. Name the train, then select it and set at least two different stations and a schedule will be created, which can be edited later. Train stations will only accept trains from one direction, but a train can depart in either direction. If a train does not begin moving once a route is set, check that the railway is connected properly, that all train stations are facing the correct direction, and check that the line has power.

Automated trains accelerate and brake slower, brake around sharp turns, and attempt to slow down as they approach a station on their schedule. However, if a train is unable to stop itself before reaching its scheduled stop (such as a station at the bottom of a steep hill), it will instantly halt exactly as if it had reached the end of a railway.

All connected locomotives are treated as a single train and share the same train schedule. Modifying a train's length in any way will completely reset its name and existing schedule.

Current issues

 * Trains currently have multiple issues when playing as the client in a multiplayer server:
 * Moving trains appear to lag.
 * Clients cannot manually drive trains or edit the automation schedule.
 * Trains always appear to have no power.
 * Clients cannot add additional engines or cars to a moving train.
 * Attempting to 'ride' a train by standing on top of it will crash the game and may kill the client upon attempting to re-join the server.
 * There is no train collision detection (resulting in the ability for two trains on the same track to phase through each other). Likewise, the player can phase through a moving train when standing in its path instead of being killed.
 * Sometime after exiting a train, the build menu is locked. The issue can be resolved by Saving and loading the game, or by entering and exiting a Hypertube.

Trivia

 * When using the horn (by pressing the left mouse button), there is a very slight chance that a steam locomotive horn will be heard instead of the normal one.
 * Unlike wheeled vehicles, automated trains continue to function when submerged under water. Manually driven trains, however will disembark the engineer upon entering the water.
 * Engineers inside a train are immune to Poison Gas and Radiation damage.
 * The train leans slightly when turning.
 * If a player is standing on a moving train and another train passes through it going the opposite direction, the player will be carried away by the second train

History

 * Patch 0.2.1.14: Second (inversed) locomotive at the other end of a train now allows it to run without turning around
 * Patch 0.2.1: Made available
 * Several patches prior: model changed twice, pathfinding logic changes, power consumption increase
 * Patch 0.1.17: Can be ridden now
 * Patch 0.1.16: Is now unlockable in game