/// <summary>
        ///
        /// </summary>
        /// <param name="here"></param>
        /// <param name="to"></param>
        public override void Remove(Location here, Location to)
        {
            if (here == to)
            {
                return;
            }

            Direction d = here.getDirectionTo(to);

            while (true)
            {
                RailImpl rr = RailRoad.get(here) as RailImpl;
                if (rr != null && rr.hasRail(d))
                {
                    // destroy it
                    rr.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.RailService.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(WorldDefinition.World[l] is EmptyVoxel);
                WorldDefinition.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)
        {
            WorldDefinition world = WorldDefinition.World;
            Direction       d     = here.getDirectionTo(there);

            // charge the cost first.
            Accounting.AccountGenre.RailService.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);
            }
        }