Esempio n. 1
0
        /// <summary>
        /// Creates an instance of a <see cref="Region"/> for a given set of coordinates.
        /// </summary>
        /// <param name="rm">The <see cref="RegionManager"/> that should be managing this region.</param>
        /// <param name="cache">A shared cache for holding chunks.</param>
        /// <param name="rx">The global X-coordinate of the region.</param>
        /// <param name="rz">The global Z-coordinate of the region.</param>
        /// <remarks><para>The constructor will not actually open or parse any region files.  Given just the region coordinates, the
        /// region will be able to determien the correct region file to look for based on the naming pattern for regions:
        /// r.x.z.mcr, given x and z are integers representing the region's coordinates.</para>
        /// <para>Regions require a <see cref="ChunkCache"/> to be provided because they do not actually store any chunks or references
        /// to chunks on their own.  This allows regions to easily pass off requests outside of their bounds, if necessary.</para></remarks>
        public Region(RegionManager rm, ChunkCache cache, int rx, int rz)
        {
            _regionMan = rm;
            _cache = cache;
            _regionFile = new WeakReference(null);
            _rx = rx;
            _rz = rz;

            if (!File.Exists(GetFilePath())) {
                throw new FileNotFoundException();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Creates an instance of a <see cref="Region"/> for the given region file.
        /// </summary>
        /// <param name="rm">The <see cref="RegionManager"/> that should be managing this region.</param>
        /// <param name="cache">A shared cache for holding chunks.</param>
        /// <param name="filename">The region file to derive the region from.</param>
        /// <remarks><para>The constructor will not actually open or parse the region file.  It will only read the file's name in order
        /// to derive the region's coordinates, based on a strict naming pattern for regions: r.x.z.mcr, given x and z are integers
        /// representing the region's coordinates.</para>
        /// <para>Regions require a <see cref="ChunkCache"/> to be provided because they do not actually store any chunks or references
        /// to chunks on their own.  This allows regions to easily pass off requests outside of their bounds, if necessary.</para></remarks>
        public Region(RegionManager rm, ChunkCache cache, string filename)
        {
            _regionMan = rm;
            _cache = cache;
            _regionFile = new WeakReference(null);

            ParseFileName(filename, out _rx, out _rz);

            if (!File.Exists(Path.Combine(_regionMan.GetRegionPath(), filename))) {
                throw new FileNotFoundException();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Creates an instance of a <see cref="Region"/> for a given set of coordinates.
        /// </summary>
        /// <param name="rm">The <see cref="RegionManager"/> that should be managing this region.</param>
        /// <param name="cache">A shared cache for holding chunks.</param>
        /// <param name="rx">The global X-coordinate of the region.</param>
        /// <param name="rz">The global Z-coordinate of the region.</param>
        /// <remarks><para>The constructor will not actually open or parse any region files.  Given just the region coordinates, the
        /// region will be able to determien the correct region file to look for based on the naming pattern for regions:
        /// r.x.z.mcr, given x and z are integers representing the region's coordinates.</para>
        /// <para>Regions require a <see cref="ChunkCache"/> to be provided because they do not actually store any chunks or references
        /// to chunks on their own.  This allows regions to easily pass off requests outside of their bounds, if necessary.</para></remarks>
        public Region(RegionManager rm, ChunkCache cache, int rx, int rz)
        {
            _regionMan  = rm;
            _cache      = cache;
            _regionFile = new WeakReference(null);
            _rx         = rx;
            _rz         = rz;

            if (!File.Exists(GetFilePath()))
            {
                throw new FileNotFoundException();
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Creates an instance of a <see cref="Region"/> for the given region file.
        /// </summary>
        /// <param name="rm">The <see cref="RegionManager"/> that should be managing this region.</param>
        /// <param name="cache">A shared cache for holding chunks.</param>
        /// <param name="filename">The region file to derive the region from.</param>
        /// <remarks><para>The constructor will not actually open or parse the region file.  It will only read the file's name in order
        /// to derive the region's coordinates, based on a strict naming pattern for regions: r.x.z.mcr, given x and z are integers
        /// representing the region's coordinates.</para>
        /// <para>Regions require a <see cref="ChunkCache"/> to be provided because they do not actually store any chunks or references
        /// to chunks on their own.  This allows regions to easily pass off requests outside of their bounds, if necessary.</para></remarks>
        public Region(RegionManager rm, ChunkCache cache, string filename)
        {
            _regionMan  = rm;
            _cache      = cache;
            _regionFile = new WeakReference(null);

            ParseFileNameCore(filename, out _rx, out _rz);

            if (!File.Exists(Path.Combine(_regionMan.GetRegionPath(), filename)))
            {
                throw new FileNotFoundException();
            }
        }
Esempio n. 5
0
        private void OpenDimension (string dim)
        {
            string path = Path;
            if (String.IsNullOrEmpty(dim)) {
                path = IO.Path.Combine(path, _REGION_DIR);
            }
            else {
                path = IO.Path.Combine(path, dim);
                path = IO.Path.Combine(path, _REGION_DIR);
            }

            if (!Directory.Exists(path)) {
                Directory.CreateDirectory(path);
            }

            ChunkCache cc = new ChunkCache(_prefCacheSize);

            AnvilRegionManager rm = new AnvilRegionManager(path, cc);
            RegionChunkManager cm = new RegionChunkManager(rm, cc);
            BlockManager bm = new AnvilBlockManager(cm);

            _regionMgrs[dim] = rm;
            _chunkMgrs[dim] = cm;
            _blockMgrs[dim] = bm;

            _caches[dim] = cc;
        }
Esempio n. 6
0
 /// <summary>
 /// Creates a new instance of a <see cref="RegionManager"/> for the given region directory and chunk cache.
 /// </summary>
 /// <param name="regionDir">The path to a directory containing region files.</param>
 /// <param name="cache">The shared chunk cache to hold chunk data in.</param>
 public RegionManager(string regionDir, ChunkCache cache)
 {
     _regionPath = regionDir;
     _chunkCache = cache;
     _cache      = new Dictionary <RegionKey, IRegion>();
 }
Esempio n. 7
0
        private void OpenDimension(int dim)
        {
            string path = Path;
            if (dim == Dimension.DEFAULT) {
                path = IO.Path.Combine(path, _REGION_DIR);
            }
            else {
                path = IO.Path.Combine(path, "DIM" + dim);
                path = IO.Path.Combine(path, _REGION_DIR);
            }

            if (!Directory.Exists(path)) {
                Directory.CreateDirectory(path);
            }

            ChunkCache cc = new ChunkCache();

            RegionManager rm = new RegionManager(path, cc);
            BetaChunkManager cm = new BetaChunkManager(rm, cc);
            BlockManager bm = new BlockManager(cm);

            _regionMgrs[dim] = rm;
            _chunkMgrs[dim] = cm;
            _blockMgrs[dim] = bm;
        }
Esempio n. 8
0
 public BetaRegion(BetaRegionManager rm, ChunkCache cache, int rx, int rz)
     : base(rm, cache, rx, rz)
 {
 }
Esempio n. 9
0
 public AnvilRegion(AnvilRegionManager rm, ChunkCache cache, int rx, int rz)
     : base(rm, cache, rx, rz)
 {
 }
Esempio n. 10
0
 public BetaRegionManager (string regionDir, ChunkCache cache)
     : base(regionDir, cache)
 {
 }
Esempio n. 11
0
        private void OpenMystDimension(int dim)
        {
            string path = Path;
            if (dim == Dimension.DEFAULT) {
                path = IO.Path.Combine(path, _REGION_DIR);
            }
            else {
                path = IO.Path.Combine(path, "DIM_MYST" + dim);
                path = IO.Path.Combine(path, _REGION_DIR);
            }

            if (!Directory.Exists(path)) {
                Directory.CreateDirectory(path);
            }

            ChunkCache cc = new ChunkCache(_prefCacheSize);

            AnvilRegionManager rm = new AnvilRegionManager(path, cc);
            RegionChunkManager cm = new RegionChunkManager(rm, cc);
            BlockManager bm = new AnvilBlockManager(cm);

            _regionMgrs[dim] = rm;
            _chunkMgrs[dim] = cm;
            _blockMgrs[dim] = bm;

            _caches[dim] = cc;
        }