Beispiel #1
0
        /// <summary>
        /// Creates a new slope. A slope consists of four consective
        /// blocks of railroads. The base parameter specifies the location
        /// of the lowest railroad and the direction parameter
        /// specifies the direction to climb.
        ///
        /// The caller must use the canCreateSlope method to check
        /// if this method can be invoked.
        /// </summary>
        public static void createSlope(Location _base, Direction dir)
        {
            Debug.Assert(canCreateSlope(_base, dir));

            // charge the cost before we alter something
            accounting.AccountGenre.RAIL_SERVICE.spend(calcCostOfNewSlope(_base, dir));

            SlopeEntity entity = new SlopeEntity(_base, dir);

            for (int i = 0; i < 4; i++)
            {
                if (_base.z < World.world.getGroundLevel(_base))
                {
                    new SlopeRailRoad(entity, TrafficVoxel.getOrCreate(
                                          _base.x, _base.y, _base.z + (i / 2)),
                                      RailPattern.getUGSlope(dir, i));
                    if (i < 2)
                    {
                        // space filler
                        new SlopeFillerVoxel(entity, _base.x, _base.y, _base.z + 1, i);
                    }
                    else
                    {
                        new SlopeSupportVoxel(entity, _base.x, _base.y, _base.z, i,
                                              RailPattern.slopeWalls[dir.index + i - 2]);
                    }
                }
                else
                {
                    new SlopeRailRoad(entity, TrafficVoxel.getOrCreate(
                                          _base.x, _base.y, _base.z + (i / 2)),
                                      RailPattern.getSlope(dir, i));
                    if (i < 2)
                    {
                        // space filler
                        new SlopeFillerVoxel(entity, _base.x, _base.y, _base.z + 1, i);
                    }
                    else
                    {
                        new SlopeSupportVoxel(entity, _base.x, _base.y, _base.z, i,
                                              RailPattern.slopeSupports[dir.index + (i - 2)]);
                    }
                }

                Type bridgeStyle;
                if (dir == Direction.NORTH || dir == Direction.EAST)
                {
                    bridgeStyle = typeof(BridgePierVoxel.DefaultImpl);
                }
                else
                {
                    bridgeStyle = typeof(BridgePierVoxel.SlopeNEImpl);
                }
                BridgePierVoxel.electBridgeSupport(_base, bridgeStyle, entity);

                _base += dir;
            }
        }