forked from mirrors/NBTExplorer
World classes now support string dimension specifiers.
This commit is contained in:
parent
e20a1277c3
commit
5852184855
4 changed files with 146 additions and 32 deletions
|
@ -19,15 +19,15 @@ namespace Substrate
|
||||||
|
|
||||||
private Level _level;
|
private Level _level;
|
||||||
|
|
||||||
private Dictionary<int, AlphaChunkManager> _chunkMgrs;
|
private Dictionary<string, AlphaChunkManager> _chunkMgrs;
|
||||||
private Dictionary<int, BlockManager> _blockMgrs;
|
private Dictionary<string, BlockManager> _blockMgrs;
|
||||||
|
|
||||||
private PlayerManager _playerMan;
|
private PlayerManager _playerMan;
|
||||||
|
|
||||||
private AlphaWorld ()
|
private AlphaWorld ()
|
||||||
{
|
{
|
||||||
_chunkMgrs = new Dictionary<int, AlphaChunkManager>();
|
_chunkMgrs = new Dictionary<string, AlphaChunkManager>();
|
||||||
_blockMgrs = new Dictionary<int, BlockManager>();
|
_blockMgrs = new Dictionary<string, BlockManager>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -99,7 +99,7 @@ namespace Substrate
|
||||||
{
|
{
|
||||||
_level.Save();
|
_level.Save();
|
||||||
|
|
||||||
foreach (KeyValuePair<int, AlphaChunkManager> cm in _chunkMgrs) {
|
foreach (KeyValuePair<string, AlphaChunkManager> cm in _chunkMgrs) {
|
||||||
cm.Value.Save();
|
cm.Value.Save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,6 +128,11 @@ namespace Substrate
|
||||||
|
|
||||||
/// <exclude/>
|
/// <exclude/>
|
||||||
protected override IBlockManager GetBlockManagerVirt (int dim)
|
protected override IBlockManager GetBlockManagerVirt (int dim)
|
||||||
|
{
|
||||||
|
return GetBlockManagerVirt(DimensionFromInt(dim));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override IBlockManager GetBlockManagerVirt (string dim)
|
||||||
{
|
{
|
||||||
BlockManager rm;
|
BlockManager rm;
|
||||||
if (_blockMgrs.TryGetValue(dim, out rm)) {
|
if (_blockMgrs.TryGetValue(dim, out rm)) {
|
||||||
|
@ -140,6 +145,11 @@ namespace Substrate
|
||||||
|
|
||||||
/// <exclude/>
|
/// <exclude/>
|
||||||
protected override IChunkManager GetChunkManagerVirt (int dim)
|
protected override IChunkManager GetChunkManagerVirt (int dim)
|
||||||
|
{
|
||||||
|
return GetChunkManagerVirt(DimensionFromInt(dim));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override IChunkManager GetChunkManagerVirt (string dim)
|
||||||
{
|
{
|
||||||
AlphaChunkManager rm;
|
AlphaChunkManager rm;
|
||||||
if (_chunkMgrs.TryGetValue(dim, out rm)) {
|
if (_chunkMgrs.TryGetValue(dim, out rm)) {
|
||||||
|
@ -163,11 +173,19 @@ namespace Substrate
|
||||||
return _playerMan;
|
return _playerMan;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OpenDimension (int dim)
|
private string DimensionFromInt (int dim)
|
||||||
|
{
|
||||||
|
if (dim == Dimension.DEFAULT)
|
||||||
|
return "";
|
||||||
|
else
|
||||||
|
return "DIM" + dim;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OpenDimension (string dim)
|
||||||
{
|
{
|
||||||
string path = Path;
|
string path = Path;
|
||||||
if (dim != Dimension.DEFAULT) {
|
if (!String.IsNullOrEmpty(dim)) {
|
||||||
path = IO.Path.Combine(path, "DIM" + dim);
|
path = IO.Path.Combine(path, dim);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Directory.Exists(path)) {
|
if (!Directory.Exists(path)) {
|
||||||
|
|
|
@ -22,11 +22,11 @@ namespace Substrate
|
||||||
|
|
||||||
private Level _level;
|
private Level _level;
|
||||||
|
|
||||||
private Dictionary<int, AnvilRegionManager> _regionMgrs;
|
private Dictionary<string, AnvilRegionManager> _regionMgrs;
|
||||||
private Dictionary<int, RegionChunkManager> _chunkMgrs;
|
private Dictionary<string, RegionChunkManager> _chunkMgrs;
|
||||||
private Dictionary<int, BlockManager> _blockMgrs;
|
private Dictionary<string, BlockManager> _blockMgrs;
|
||||||
|
|
||||||
private Dictionary<int, ChunkCache> _caches;
|
private Dictionary<string, ChunkCache> _caches;
|
||||||
|
|
||||||
private PlayerManager _playerMan;
|
private PlayerManager _playerMan;
|
||||||
private BetaDataManager _dataMan;
|
private BetaDataManager _dataMan;
|
||||||
|
@ -35,11 +35,11 @@ namespace Substrate
|
||||||
|
|
||||||
private AnvilWorld ()
|
private AnvilWorld ()
|
||||||
{
|
{
|
||||||
_regionMgrs = new Dictionary<int, AnvilRegionManager>();
|
_regionMgrs = new Dictionary<string, AnvilRegionManager>();
|
||||||
_chunkMgrs = new Dictionary<int, RegionChunkManager>();
|
_chunkMgrs = new Dictionary<string, RegionChunkManager>();
|
||||||
_blockMgrs = new Dictionary<int, BlockManager>();
|
_blockMgrs = new Dictionary<string, BlockManager>();
|
||||||
|
|
||||||
_caches = new Dictionary<int, ChunkCache>();
|
_caches = new Dictionary<string, ChunkCache>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -75,6 +75,11 @@ namespace Substrate
|
||||||
return GetBlockManagerVirt(dim) as BlockManager;
|
return GetBlockManagerVirt(dim) as BlockManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public new BlockManager GetBlockManager (string dim)
|
||||||
|
{
|
||||||
|
return GetBlockManagerVirt(dim) as BlockManager;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a <see cref="RegionChunkManager"/> for the default dimension.
|
/// Gets a <see cref="RegionChunkManager"/> for the default dimension.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -96,6 +101,11 @@ namespace Substrate
|
||||||
return GetChunkManagerVirt(dim) as RegionChunkManager;
|
return GetChunkManagerVirt(dim) as RegionChunkManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public new RegionChunkManager GetChunkManager (string dim)
|
||||||
|
{
|
||||||
|
return GetChunkManagerVirt(dim) as RegionChunkManager;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a <see cref="RegionManager"/> for the default dimension.
|
/// Gets a <see cref="RegionManager"/> for the default dimension.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -115,6 +125,11 @@ namespace Substrate
|
||||||
/// <remarks>Regions are a higher-level unit of organization for blocks unique to worlds created in Beta 1.3 and beyond.
|
/// <remarks>Regions are a higher-level unit of organization for blocks unique to worlds created in Beta 1.3 and beyond.
|
||||||
/// Consider using the <see cref="RegionChunkManager"/> if you are interested in working with blocks.</remarks>
|
/// Consider using the <see cref="RegionChunkManager"/> if you are interested in working with blocks.</remarks>
|
||||||
public AnvilRegionManager GetRegionManager (int dim)
|
public AnvilRegionManager GetRegionManager (int dim)
|
||||||
|
{
|
||||||
|
return GetRegionManager(DimensionFromInt(dim));
|
||||||
|
}
|
||||||
|
|
||||||
|
public AnvilRegionManager GetRegionManager (string dim)
|
||||||
{
|
{
|
||||||
AnvilRegionManager rm;
|
AnvilRegionManager rm;
|
||||||
if (_regionMgrs.TryGetValue(dim, out rm)) {
|
if (_regionMgrs.TryGetValue(dim, out rm)) {
|
||||||
|
@ -149,7 +164,7 @@ namespace Substrate
|
||||||
{
|
{
|
||||||
_level.Save();
|
_level.Save();
|
||||||
|
|
||||||
foreach (KeyValuePair<int, RegionChunkManager> cm in _chunkMgrs) {
|
foreach (KeyValuePair<string, RegionChunkManager> cm in _chunkMgrs) {
|
||||||
cm.Value.Save();
|
cm.Value.Save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,6 +184,11 @@ namespace Substrate
|
||||||
/// <param name="dim">The id of a dimension to look up.</param>
|
/// <param name="dim">The id of a dimension to look up.</param>
|
||||||
/// <returns>The <see cref="ChunkCache"/> for the given dimension, or null if the dimension was not found.</returns>
|
/// <returns>The <see cref="ChunkCache"/> for the given dimension, or null if the dimension was not found.</returns>
|
||||||
public ChunkCache GetChunkCache (int dim)
|
public ChunkCache GetChunkCache (int dim)
|
||||||
|
{
|
||||||
|
return GetChunkCache(DimensionFromInt(dim));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChunkCache GetChunkCache (string dim)
|
||||||
{
|
{
|
||||||
if (_caches.ContainsKey(dim)) {
|
if (_caches.ContainsKey(dim)) {
|
||||||
return _caches[dim];
|
return _caches[dim];
|
||||||
|
@ -230,6 +250,11 @@ namespace Substrate
|
||||||
|
|
||||||
/// <exclude/>
|
/// <exclude/>
|
||||||
protected override IBlockManager GetBlockManagerVirt (int dim)
|
protected override IBlockManager GetBlockManagerVirt (int dim)
|
||||||
|
{
|
||||||
|
return GetBlockManagerVirt(DimensionFromInt(dim));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override IBlockManager GetBlockManagerVirt(string dim)
|
||||||
{
|
{
|
||||||
BlockManager rm;
|
BlockManager rm;
|
||||||
if (_blockMgrs.TryGetValue(dim, out rm)) {
|
if (_blockMgrs.TryGetValue(dim, out rm)) {
|
||||||
|
@ -242,6 +267,11 @@ namespace Substrate
|
||||||
|
|
||||||
/// <exclude/>
|
/// <exclude/>
|
||||||
protected override IChunkManager GetChunkManagerVirt (int dim)
|
protected override IChunkManager GetChunkManagerVirt (int dim)
|
||||||
|
{
|
||||||
|
return GetChunkManagerVirt(DimensionFromInt(dim));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override IChunkManager GetChunkManagerVirt (string dim)
|
||||||
{
|
{
|
||||||
RegionChunkManager rm;
|
RegionChunkManager rm;
|
||||||
if (_chunkMgrs.TryGetValue(dim, out rm)) {
|
if (_chunkMgrs.TryGetValue(dim, out rm)) {
|
||||||
|
@ -276,14 +306,22 @@ namespace Substrate
|
||||||
return _dataMan;
|
return _dataMan;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OpenDimension (int dim)
|
private string DimensionFromInt (int dim)
|
||||||
|
{
|
||||||
|
if (dim == Dimension.DEFAULT)
|
||||||
|
return "";
|
||||||
|
else
|
||||||
|
return "DIM" + dim;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OpenDimension (string dim)
|
||||||
{
|
{
|
||||||
string path = Path;
|
string path = Path;
|
||||||
if (dim == Dimension.DEFAULT) {
|
if (String.IsNullOrEmpty(dim)) {
|
||||||
path = IO.Path.Combine(path, _REGION_DIR);
|
path = IO.Path.Combine(path, _REGION_DIR);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
path = IO.Path.Combine(path, "DIM" + dim);
|
path = IO.Path.Combine(path, dim);
|
||||||
path = IO.Path.Combine(path, _REGION_DIR);
|
path = IO.Path.Combine(path, _REGION_DIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,11 +22,11 @@ namespace Substrate
|
||||||
|
|
||||||
private Level _level;
|
private Level _level;
|
||||||
|
|
||||||
private Dictionary<int, BetaRegionManager> _regionMgrs;
|
private Dictionary<string, BetaRegionManager> _regionMgrs;
|
||||||
private Dictionary<int, RegionChunkManager> _chunkMgrs;
|
private Dictionary<string, RegionChunkManager> _chunkMgrs;
|
||||||
private Dictionary<int, BlockManager> _blockMgrs;
|
private Dictionary<string, BlockManager> _blockMgrs;
|
||||||
|
|
||||||
private Dictionary<int, ChunkCache> _caches;
|
private Dictionary<string, ChunkCache> _caches;
|
||||||
|
|
||||||
private PlayerManager _playerMan;
|
private PlayerManager _playerMan;
|
||||||
private BetaDataManager _dataMan;
|
private BetaDataManager _dataMan;
|
||||||
|
@ -35,11 +35,11 @@ namespace Substrate
|
||||||
|
|
||||||
private BetaWorld ()
|
private BetaWorld ()
|
||||||
{
|
{
|
||||||
_regionMgrs = new Dictionary<int, BetaRegionManager>();
|
_regionMgrs = new Dictionary<string, BetaRegionManager>();
|
||||||
_chunkMgrs = new Dictionary<int, RegionChunkManager>();
|
_chunkMgrs = new Dictionary<string, RegionChunkManager>();
|
||||||
_blockMgrs = new Dictionary<int, BlockManager>();
|
_blockMgrs = new Dictionary<string, BlockManager>();
|
||||||
|
|
||||||
_caches = new Dictionary<int, ChunkCache>();
|
_caches = new Dictionary<string, ChunkCache>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -75,6 +75,11 @@ namespace Substrate
|
||||||
return GetBlockManagerVirt(dim) as BlockManager;
|
return GetBlockManagerVirt(dim) as BlockManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public new BlockManager GetBlockManager (string dim)
|
||||||
|
{
|
||||||
|
return GetBlockManagerVirt(dim) as BlockManager;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a <see cref="RegionChunkManager"/> for the default dimension.
|
/// Gets a <see cref="RegionChunkManager"/> for the default dimension.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -96,6 +101,11 @@ namespace Substrate
|
||||||
return GetChunkManagerVirt(dim) as RegionChunkManager;
|
return GetChunkManagerVirt(dim) as RegionChunkManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public new RegionChunkManager GetChunkManager (string dim)
|
||||||
|
{
|
||||||
|
return GetChunkManagerVirt(dim) as RegionChunkManager;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a <see cref="RegionManager"/> for the default dimension.
|
/// Gets a <see cref="RegionManager"/> for the default dimension.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -115,6 +125,11 @@ namespace Substrate
|
||||||
/// <remarks>Regions are a higher-level unit of organization for blocks unique to worlds created in Beta 1.3 and beyond.
|
/// <remarks>Regions are a higher-level unit of organization for blocks unique to worlds created in Beta 1.3 and beyond.
|
||||||
/// Consider using the <see cref="RegionChunkManager"/> if you are interested in working with blocks.</remarks>
|
/// Consider using the <see cref="RegionChunkManager"/> if you are interested in working with blocks.</remarks>
|
||||||
public BetaRegionManager GetRegionManager (int dim)
|
public BetaRegionManager GetRegionManager (int dim)
|
||||||
|
{
|
||||||
|
return GetRegionManager(DimensionFromInt(dim));
|
||||||
|
}
|
||||||
|
|
||||||
|
public BetaRegionManager GetRegionManager (string dim)
|
||||||
{
|
{
|
||||||
BetaRegionManager rm;
|
BetaRegionManager rm;
|
||||||
if (_regionMgrs.TryGetValue(dim, out rm)) {
|
if (_regionMgrs.TryGetValue(dim, out rm)) {
|
||||||
|
@ -149,7 +164,7 @@ namespace Substrate
|
||||||
{
|
{
|
||||||
_level.Save();
|
_level.Save();
|
||||||
|
|
||||||
foreach (KeyValuePair<int, RegionChunkManager> cm in _chunkMgrs) {
|
foreach (KeyValuePair<string, RegionChunkManager> cm in _chunkMgrs) {
|
||||||
cm.Value.Save();
|
cm.Value.Save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,6 +184,11 @@ namespace Substrate
|
||||||
/// <param name="dim">The id of a dimension to look up.</param>
|
/// <param name="dim">The id of a dimension to look up.</param>
|
||||||
/// <returns>The <see cref="ChunkCache"/> for the given dimension, or null if the dimension was not found.</returns>
|
/// <returns>The <see cref="ChunkCache"/> for the given dimension, or null if the dimension was not found.</returns>
|
||||||
public ChunkCache GetChunkCache (int dim)
|
public ChunkCache GetChunkCache (int dim)
|
||||||
|
{
|
||||||
|
return GetChunkCache(DimensionFromInt(dim));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChunkCache GetChunkCache (string dim)
|
||||||
{
|
{
|
||||||
if (_caches.ContainsKey(dim)) {
|
if (_caches.ContainsKey(dim)) {
|
||||||
return _caches[dim];
|
return _caches[dim];
|
||||||
|
@ -230,6 +250,11 @@ namespace Substrate
|
||||||
|
|
||||||
/// <exclude/>
|
/// <exclude/>
|
||||||
protected override IBlockManager GetBlockManagerVirt (int dim)
|
protected override IBlockManager GetBlockManagerVirt (int dim)
|
||||||
|
{
|
||||||
|
return GetBlockManagerVirt(DimensionFromInt(dim));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override IBlockManager GetBlockManagerVirt (string dim)
|
||||||
{
|
{
|
||||||
BlockManager rm;
|
BlockManager rm;
|
||||||
if (_blockMgrs.TryGetValue(dim, out rm)) {
|
if (_blockMgrs.TryGetValue(dim, out rm)) {
|
||||||
|
@ -242,6 +267,11 @@ namespace Substrate
|
||||||
|
|
||||||
/// <exclude/>
|
/// <exclude/>
|
||||||
protected override IChunkManager GetChunkManagerVirt (int dim)
|
protected override IChunkManager GetChunkManagerVirt (int dim)
|
||||||
|
{
|
||||||
|
return GetChunkManagerVirt(DimensionFromInt(dim));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override IChunkManager GetChunkManagerVirt (string dim)
|
||||||
{
|
{
|
||||||
RegionChunkManager rm;
|
RegionChunkManager rm;
|
||||||
if (_chunkMgrs.TryGetValue(dim, out rm)) {
|
if (_chunkMgrs.TryGetValue(dim, out rm)) {
|
||||||
|
@ -276,14 +306,22 @@ namespace Substrate
|
||||||
return _dataMan;
|
return _dataMan;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OpenDimension (int dim)
|
private string DimensionFromInt (int dim)
|
||||||
|
{
|
||||||
|
if (dim == Dimension.DEFAULT)
|
||||||
|
return "";
|
||||||
|
else
|
||||||
|
return "DIM" + dim;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OpenDimension (string dim)
|
||||||
{
|
{
|
||||||
string path = Path;
|
string path = Path;
|
||||||
if (dim == Dimension.DEFAULT) {
|
if (String.IsNullOrEmpty(dim)) {
|
||||||
path = IO.Path.Combine(path, _REGION_DIR);
|
path = IO.Path.Combine(path, _REGION_DIR);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
path = IO.Path.Combine(path, "DIM" + dim);
|
path = IO.Path.Combine(path, dim);
|
||||||
path = IO.Path.Combine(path, _REGION_DIR);
|
path = IO.Path.Combine(path, _REGION_DIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,11 @@ namespace Substrate
|
||||||
return GetBlockManagerVirt(dim);
|
return GetBlockManagerVirt(dim);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IBlockManager GetBlockManager (string dim)
|
||||||
|
{
|
||||||
|
return GetBlockManagerVirt(dim);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets an <see cref="IChunkManager"/> for the default dimension.
|
/// Gets an <see cref="IChunkManager"/> for the default dimension.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -92,6 +97,11 @@ namespace Substrate
|
||||||
return GetChunkManagerVirt(dim);
|
return GetChunkManagerVirt(dim);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IChunkManager GetChunkManager (string dim)
|
||||||
|
{
|
||||||
|
return GetChunkManagerVirt(dim);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets an <see cref="IPlayerManager"/> for maanging players on multiplayer worlds.
|
/// Gets an <see cref="IPlayerManager"/> for maanging players on multiplayer worlds.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -162,6 +172,16 @@ namespace Substrate
|
||||||
/// <returns>An <see cref="IChunkManager"/> for the given dimension in the world.</returns>
|
/// <returns>An <see cref="IChunkManager"/> for the given dimension in the world.</returns>
|
||||||
protected abstract IChunkManager GetChunkManagerVirt (int dim);
|
protected abstract IChunkManager GetChunkManagerVirt (int dim);
|
||||||
|
|
||||||
|
protected virtual IBlockManager GetBlockManagerVirt (string dim)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual IChunkManager GetChunkManagerVirt (string dim)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Virtual implementor of <see cref="GetPlayerManager"/>.
|
/// Virtual implementor of <see cref="GetPlayerManager"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in a new issue