Ejemplo n.º 1
0
        public override void remove(Location here, Location to)
        {
            if (here == to)
            {
                return;
            }

            Direction d = here.getDirectionTo(to);

            while (true)
            {
                BridgeRail brr = RailRoad.get(here) as BridgeRail;
                if (brr != null && brr.hasRail(d))
                {
                    // destroy it
                    brr.voxel.railRoad = null;
                    // TODO: delete piers

                    BridgePierVoxel.teardownBridgeSupport(here, TrafficVoxel.get(here));
                }

                if (here == to)
                {
                    return;
                }
                here = here.toward(to);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Removes a slope. The format of the parameters are the same
        /// as the createSlope method. Ut us
        /// </summary>
        public static void removeSlope(Location loc, Direction dir)
        {
            Debug.Assert(canRemoveSlope(loc, dir));

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

            for (int i = 0; i < 4; i++)
            {
                TrafficVoxel v = TrafficVoxel.get(loc.x, loc.y, loc.z + (i / 2));
                v.railRoad = null;

                Location l = loc;
                l.z += -(i / 2) + 1;
                Debug.Assert(World.world[l] is EmptyVoxel);
                World.world.remove(l);

                BridgePierVoxel.teardownBridgeSupport(loc, v);

                loc += dir;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Removes normal RR between two specified locations
        /// </summary>
        /// <returns>false if the operation was unsuccessful</returns>
        public static void remove(Location here, Location there)
        {
            World     world = World.world;
            Direction d     = here.getDirectionTo(there);

            // charge the cost first.
            accounting.AccountGenre.RAIL_SERVICE.spend(calcCostOfRemoving(here, there));

            while (true)
            {
                Direction dd;
                if (here != there)
                {
                    dd = here.getDirectionTo(there);
                }
                else
                {
                    dd = d;
                }

                TrafficVoxel v = TrafficVoxel.get(here);
                if (v != null && v.railRoad != null && !v.isOccupied)
                {
                    v.railRoad.detach(d.opposite, dd);
                }

                BridgePierVoxel.teardownBridgeSupport(here, v);

                if (here == there)
                {
                    break;
                }

                d    = dd;
                here = here.toward(there);
            }
        }