コード例 #1
0
ファイル: RegionManager.cs プロジェクト: whatupdave/Substrate
        // XXX: Exceptions
        /// <summary>
        /// Deletes a region at the given coordinates.
        /// </summary>
        /// <param name="rx">The global X-coordinate of a region.</param>
        /// <param name="rz">The global Z-coordinate of a region.</param>
        /// <returns>True if a region was deleted; false otherwise.</returns>
        public bool DeleteRegion(int rx, int rz)
        {
            Region r = GetRegion(rx, rz);

            if (r == null)
            {
                return(false);
            }

            RegionKey k = new RegionKey(rx, rz);

            _cache.Remove(k);

            r.Dispose();

            try {
                File.Delete(r.GetFilePath());
            }
            catch (Exception e) {
                Console.WriteLine("NOTICE: " + e.Message);
                return(false);
            }

            return(true);
        }
コード例 #2
0
        /// <summary> 转换成SWGF </summary>
        public List <SWGF> ConvertTo()
        {
            List <SWGF> swgfs = new List <SWGF>();

            foreach (var items in this.Regions)
            {
                SWGF        swgf = new SWGF("SWGF");
                SWGF.Region r    = new RegionKey <SWGF.Item> .Region(items.RegionIndex);

                swgf.Regions.Add(r);

                for (int i = 0; i < items.Count; i++)
                {
                    var item = items[items.Count - i - 1];

                    SWGF.Item it = new SWGF.Item();
                    it.sbhd0     = (1 - item.hqbhd0.ToDouble()).ToString();
                    it.sdxdstl1  = item.sxxdstl2;
                    it.qxdxdstl2 = item.qxxdstl1;
                    it.mgyl3     = item.mgyl;
                    r.Add(it);
                }



                swgfs.Add(swgf);
            }

            return(swgfs);
        }
コード例 #3
0
        public AlignedCubeZone(RegionKey region, ZoneKey key, Vector3 center, Vector3 width) : base(region, key, center)
        {
            Width = width;

            _min = new Vector3(center.X - width.X / 2, center.Y - width.Y / 2, center.Z - width.Z / 2);
            _max = new Vector3(center.X + width.X / 2, center.Y + width.Y / 2, center.Z + width.Z / 2);
        }
コード例 #4
0
        public void QueueDeleteChunk(int rx, int rz)
        {
            RegionKey key = new RegionKey(rx, rz);

            if (!_deleteQueue.Contains(key))
            {
                _deleteQueue.Add(key);
            }
        }
コード例 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InternalSegmentStream"/> class.
 /// </summary>
 /// <param name="objectCache">The object cache.</param>
 /// <param name="key">The key.</param>
 /// <param name="segmentSize">Size of the segment.</param>
 /// <param name="region">The region.</param>
 public InternalSegmentStream(ObjectCache objectCache, string key, int segmentSize, string region)
 {
     _segmentSize = segmentSize;
     _cache = objectCache;
     _regionKey = new RegionKey { Key = key, Region = region };
     _canRead = true;
     _canWrite = true;
     _canSeek = true;
 }
コード例 #6
0
 public static string GetRegionName(RegionKey region)
 {
     switch (region)
     {
         case RegionKey.MainRegion:
             return MainRegion;
         default:
             return string.Empty;
     }
 }
コード例 #7
0
 public static IDictionary<string, Type> GetViewTypePairs(RegionKey regionName)
 {
     var dic = new Dictionary<string, Type>();
     switch (regionName)
     {
         case RegionKey.MainRegion:
             dic.Add(ViewKey.DndTree, typeof(IDndTreeView));
             break;
         default:
             break;
     }
     return dic;
 }
コード例 #8
0
 public static IReadOnlyList<string> GetViewKeys(RegionKey region)
 {
     var list = new List<string>();
     switch (region)
     {
         case RegionKey.MainRegion:
             list.Add(ViewKey.DndTree);
             break;
         default:
             break;
     }
     return list;
 }
コード例 #9
0
ファイル: RegionManager.cs プロジェクト: whatupdave/Substrate
        /// <summary>
        /// Creates a new empty region at the given coordinates, if no region exists.
        /// </summary>
        /// <param name="rx">The global X-coordinate of a region.</param>
        /// <param name="rz">The global Z-coordinate of a region.</param>
        /// <returns>A new empty <see cref="Region"/> object for the given coordinates, or an existing <see cref="Region"/> if one exists.</returns>
        public Region CreateRegion(int rx, int rz)
        {
            Region r = GetRegion(rx, rz);

            if (r == null)
            {
                string fp = "r." + rx + "." + rz + ".mcr";
                using (RegionFile rf = new RegionFile(Path.Combine(_regionPath, fp))) {
                }

                r = new Region(this, _chunkCache, rx, rz);

                RegionKey k = new RegionKey(rx, rz);
                _cache[k] = r;
            }

            return(r);
        }
コード例 #10
0
ファイル: RegionManager.cs プロジェクト: whatupdave/Substrate
        /// <summary>
        /// Gets a <see cref="Region"/> at the given coordinates.
        /// </summary>
        /// <param name="rx">The global X-coordinate of a region.</param>
        /// <param name="rz">The global Z-coordinate of a region.</param>
        /// <returns>A <see cref="Region"/> representing a region at the given coordinates, or null if the region does not exist.</returns>
        public Region GetRegion(int rx, int rz)
        {
            RegionKey k = new RegionKey(rx, rz);
            Region    r;

            try {
                if (_cache.TryGetValue(k, out r) == false)
                {
                    r = new Region(this, _chunkCache, rx, rz);
                    _cache.Add(k, r);
                }
                return(r);
            }
            catch (FileNotFoundException) {
                _cache.Add(k, null);
                return(null);
            }
        }
コード例 #11
0
ファイル: Zone.cs プロジェクト: tickleBritches/palibot
 public Zone(RegionKey region, ZoneKey key, Vector3 center)
 {
     Region = region;
     Key    = key;
     Center = center;
 }
コード例 #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InternalBlobStream"/> class.
 /// </summary>
 /// <param name="objectCache">The object cache.</param>
 /// <param name="key">The key.</param>
 /// <param name="region">The region.</param>
 public InternalBlobStream(ObjectCache objectCache, string key, string region = DefaultRegion)
 {
     _cache = objectCache;
     _regionKey = new RegionKey { Key = key, Region = region };
     Initialize();
 }
コード例 #13
0
 public SphericalZone(RegionKey region, ZoneKey key, float x, float y, float z, float radius) : this(region, key, new Vector3(x, y, z), radius)
 {
 }
コード例 #14
0
 public SphericalZone(RegionKey region, ZoneKey key, Vector3 center, float radius) : base(region, key, center)
 {
     Radius = radius;
 }
コード例 #15
0
 public AlignedCubeZone(RegionKey region, ZoneKey key, float x, float y, float z, float wx, float wy, float wz) : this(region, key, new Vector3(x, y, z), new Vector3(wx, wy, wz))
 {
 }
コード例 #16
0
 public void QueueDeleteChunk (int rx, int rz)
 {
     RegionKey key = new RegionKey(rx, rz);
     if (!_deleteQueue.Contains(key))
         _deleteQueue.Add(key);
 }