* @param nodeIdAtBack node id the back of the train is looking at
*/
// TODO: change nodeIdAtBack by nodeItAtFront - where the front looks at
public void putTrain( Train train, long trackId, long nodeIdAtBack ) {
Track track = Game.trackManager.getTrack( trackId );
Node node = Game.nodeManager.getNode( nodeIdAtBack );
try {
// TODO: remove this in final release and handle correct
if ( train.getLength() > track.getLength() ) {
throw new Exception( "train too long" );
}
// TODO: remove this in final release and handle correct
if ( train.getTrainGroup() != null ) {
throw new Exception( "train already in traingroup" );
}
} catch( Exception e ) {
e.printStackTrace();
System.exit( 2 );
}
TrainGroup trainGroup = allocateNewTrainGroup();
trainGroup.add( train );
Node headsNode = null;
try {
headsNode = track.getOutgoingNode( node );
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();