Esempio n. 1
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;
    }
Esempio n. 2
0
    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);
    }
Esempio n. 3
0
    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);
    }