// 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); }
/// <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); }
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); }
public void QueueDeleteChunk(int rx, int rz) { RegionKey key = new RegionKey(rx, rz); if (!_deleteQueue.Contains(key)) { _deleteQueue.Add(key); } }
/// <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; }
public static string GetRegionName(RegionKey region) { switch (region) { case RegionKey.MainRegion: return MainRegion; default: return string.Empty; } }
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; }
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; }
/// <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); }
/// <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); } }
public Zone(RegionKey region, ZoneKey key, Vector3 center) { Region = region; Key = key; Center = center; }
/// <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(); }
public SphericalZone(RegionKey region, ZoneKey key, float x, float y, float z, float radius) : this(region, key, new Vector3(x, y, z), radius) { }
public SphericalZone(RegionKey region, ZoneKey key, Vector3 center, float radius) : base(region, key, center) { Radius = radius; }
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)) { }
public void QueueDeleteChunk (int rx, int rz) { RegionKey key = new RegionKey(rx, rz); if (!_deleteQueue.Contains(key)) _deleteQueue.Add(key); }