private bool SpawnVehicle(TrafficVolume.VehicleSpawnedEventArgs e)
        {
            LineNode start = e.tv.startNodes.nodes[GlobalRandom.Instance.Next(e.tv.startNodes.nodes.Count)];

            if (start.nextConnections.Count > 0)
            {
                int            foo = GlobalRandom.Instance.Next(start.nextConnections.Count);
                NodeConnection nc  = start.nextConnections[foo];

                e.vehicleToSpawn.state = new IVehicle.State(nc, 0);
                if (e.vehicleToSpawn.GetType() == typeof(Car))
                {
                    e.vehicleToSpawn.physics = new IVehicle.Physics(carTargetVelocity + ((GlobalRandom.Instance.NextDouble() - 0.5) * 4), Math.Min(nc.targetVelocity, carTargetVelocity), 0);
                }
                else if (e.vehicleToSpawn.GetType() == typeof(Truck))
                {
                    e.vehicleToSpawn.physics = new IVehicle.Physics(truckTargetVelocity + ((GlobalRandom.Instance.NextDouble() - 0.5) * 4), Math.Min(nc.targetVelocity, truckTargetVelocity), 0);
                }
                else if (e.vehicleToSpawn.GetType() == typeof(Tram))
                {
                    e.vehicleToSpawn.physics = new IVehicle.Physics(tramTargetVelocity + ((GlobalRandom.Instance.NextDouble() - 0.5) * 4), Math.Min(nc.targetVelocity, tramTargetVelocity), 0);
                }
                else if (e.vehicleToSpawn.GetType() == typeof(Bus))
                {
                    e.vehicleToSpawn.physics = new IVehicle.Physics(busTargetVelocity + ((GlobalRandom.Instance.NextDouble() - 0.5) * 4), Math.Min(nc.targetVelocity, busTargetVelocity), 0);
                }

                if (start.nextConnections[foo].AddVehicle(e.vehicleToSpawn))
                {
                    e.vehicleToSpawn.targetNodes  = e.tv.destinationNodes.nodes;
                    e.vehicleToSpawn.VehicleDied += new IVehicle.VehicleDiedEventHandler(e.tv.SpawnedVehicleDied);
                    return(true);
                }
            }

            return(false);
        }
 private void newTV_VehicleSpawned(object sender, TrafficVolume.VehicleSpawnedEventArgs e)
 {
     _vehiclesToSpawn.Add(e);
 }