public void WorldMapAddExistingRegionTest() { var map = new WorldMap(_mapName, _serviceProvider); IRegion region = map.AddRegion(0, 0); Assert.Throws <InvalidOperationException>(() => map.AddRegion(0, 0)); }
public void Load(string worldName) { if (_isLoaded) { throw new InvalidOperationException("Maps have been already loded."); } string worldPath = Path.Combine(MapPath, worldName); DirectoryUtilities.CreateDirectoryIfNotExist(MapPath); DirectoryUtilities.CreateDirectoryIfNotExist(worldPath); Overworld = new WorldMap("minecraft:overworld", _serviceProvider); Overworld.StartUpdate(); // DEBUG IRegion region = Overworld.AddRegion(0, 0); IChunk chunk = region.AddChunk(0, 0); for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { chunk.SetBlock(BlockType.Dirt, x, 0, z); } } _isLoaded = true; Name = worldName; }
public void WorldMapGetRegionTest() { var map = new WorldMap(_mapName, _serviceProvider); IRegion region = map.AddRegion(0, 0); IRegion mapRegion = map.GetRegion(0, 0); Assert.Same(region, mapRegion); }
public void WorldMapCheckIfContainsRegionTest() { var map = new WorldMap(_mapName, _serviceProvider); map.AddRegion(0, 0); Assert.True(map.ContainsRegion(0, 0)); }
public void WorldMapAddRegionTest(int regionX, int regionZ) { var map = new WorldMap(_mapName, _serviceProvider); IRegion region = map.AddRegion(regionX, regionZ); Assert.NotNull(region); Assert.IsType <Region>(region); Assert.NotEmpty(map.Regions); Assert.Single(map.Regions); Assert.Equal(regionX, region.X); Assert.Equal(regionZ, region.Z); Assert.NotEmpty(region.Chunks); Assert.Equal(Math.Pow(Region.ChunkAmount, 2), region.Chunks.Count()); }
public void WorldMapGetBlockAtPositionTest(Position position) { var map = new WorldMap(_mapName, _serviceProvider); IRegion region0 = map.AddRegion(0, 0); region0.AddChunk(0, 0); region0.AddChunk(1, 0); region0.AddChunk(0, 1); region0.AddChunk(1, 1); IBlock block = map.GetBlock(position); Assert.NotNull(block); Assert.IsType <Block>(block); Assert.Equal(BlockType.Air, block.Type); Assert.True(block.IsAir); }
public void WorldMapSetBlockTest(int x, int y, int z, BlockType blockType) { var map = new WorldMap(_mapName, _serviceProvider); IRegion region0 = map.AddRegion(0, 0); region0.AddChunk(0, 0); region0.AddChunk(1, 0); region0.AddChunk(0, 1); region0.AddChunk(1, 1); map.SetBlock(blockType, x, y, z); IBlock block = map.GetBlock(x, y, z); Assert.NotNull(block); Assert.IsType <Block>(block); Assert.Equal(blockType, block.Type); Assert.False(block.IsAir); }
public async Task WorldMapDisposeTest() { var minecraftUser = new MinecraftUserMock(Guid.NewGuid()); var worldMock = new WorldMock(); var player = PlayerEntityGenerator.GeneratePlayer(minecraftUser, worldMock); var map = new WorldMap(_mapName, _serviceProvider); map.AddRegion(0, 0); map.AddPlayer(player); map.StartUpdate(); await Task.Delay(500); map.Dispose(); Assert.False(map.IsUpdating); Assert.Empty(map.Regions); Assert.Empty(map.Players); }