Example #1
0
        /// <summary>
        /// Removes this platform from the world.
        /// </summary>
        public override void remove()
        {
            WorldDefinition world = WorldDefinition.World;

            onHostDisconnected();


            foreach (YardRailRoad[] yrrs in lanes)
            {
                if (yrrs != null)
                {
                    foreach (YardRailRoad yrr in yrrs)
                    {
                        // canRemove must be true before this method is called.
                        Debug.Assert(yrr.Voxel.car == null);

                        Location loc = yrr.Location;
                        yrr.Voxel.railRoad = null;
                        new SingleRailRoad(
                            TrafficVoxel.getOrCreate(loc),
                            RailPattern.get(direction, direction.opposite));
                        world.OnVoxelUpdated(loc);
                    }
                }
            }

            // remove the platform itself
            foreach (FatPlatformVoxel pv in voxels)
            {
                world.remove(pv.Location);
                world.OnVoxelUpdated(pv.Location);
            }

            base.remove();
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        public override void remove()
        {
            // just remove all the voxels
            WorldDefinition world = WorldDefinition.World;

            foreach (Voxel v in this.cube.Voxels)
            {
                world.remove(v);
            }

            if (onEntityRemoved != null)
            {
                onEntityRemoved(this, null);
            }
        }
Example #3
0
        /// <summary>
        /// Raises the north-eastern corner of the specified voxel
        /// </summary>
        /// <returns>false if the operation was unsuccessful.</returns>
        private bool raise(Location loc)
        {
            WorldDefinition w = WorldDefinition.World;

            // make sure that four surrounding voxels can be raised,
            // and the ground levels of them are the same
            if (!canBeRaised(loc))
            {
                return(false);
            }

            // then actually change the terrain
            for (int x = 0; x <= 1; x++)
            {
                for (int y = -1; y <= 0; y++)
                {
                    Location l = new Location(loc.x + x, loc.y + y, loc.z);

                    Voxel vx = w[l];
                    if (vx is WorldDefinition.OutOfWorldVoxel)
                    {
                        continue;       // this is beyond the border
                    }
                    MountainVoxel v = vx as MountainVoxel;

                    Direction d = Direction.get(1 - x * 2, -y * 2 - 1); // corner to modify

                    if (v == null)
                    {
                        v = new MountainVoxel(l, 0, 0, 0, 0);
                    }

                    // raise the corner
                    v.setHeight(d, v.getHeight(d) + 1);

                    if (v.isSaturated)
                    {
                        // if the voxel is saturated, raise the ground level
                        w.raiseGround(l);
                        w.remove(l);    // remove this voxel
                    }
                }
            }

            return(true);
        }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        public override void remove()
        {
            // just remove the voxels
            WorldDefinition world = WorldDefinition.World;

            world.remove(baseLocation);

            if (onEntityRemoved != null)
            {
                onEntityRemoved(this, null);
            }

            if (stationListener != null)
            {
                stationListener.OnRemoved();
            }
        }
Example #5
0
        /// <summary>
        ///
        /// </summary>
        public override void remove()
        {
            if (stationListener != null)
            {
                stationListener.OnRemoved();
            }
            if (onEntityRemoved != null)
            {
                onEntityRemoved(this, null);
            }

            WorldDefinition world = WorldDefinition.World;

            foreach (VoxelImpl v in voxels)
            {
                world.remove(v);
            }
        }
Example #6
0
        /// <summary>
        /// Lowers the north-eastern corner of the specified voxel.
        /// </summary>
        /// <returns>false if the operation was unsuccessful.</returns>
        private bool lower(Location loc)
        {
            WorldDefinition world = WorldDefinition.World;

            if (!canBeLowered(ref loc))
            {
                return(false);
            }


            // then actually change the terrain
            for (int x = 0; x <= 1; x++)
            {
                for (int y = -1; y <= 0; y++)
                {
                    Location  l = new Location(loc.x + x, loc.y + y, loc.z);
                    Direction d = Direction.get(1 - x * 2, -y * 2 - 1); // corner to modify

                    MountainVoxel mv = MountainVoxel.get(l);
                    if (mv == null)
                    {
                        WorldDefinition.World.lowerGround(l);
                        mv = new MountainVoxel(l, 4, 4, 4, 4);
                    }

                    mv.setHeight(d, mv.getHeight(d) - 1);

                    if (mv.isFlattened) // completely flattened
                    {
                        world.remove(mv);
                    }
                }
            }

            return(true);
        }