Ejemplo n.º 1
0
 private void SetMapBlocks(WorldSpaceType type, MapBlock[] block_array)
 {
     if (type > WorldSpaceType.NONE && type < WorldSpaceType.TYPE_COUNT)
     {
         m_Blocks[(int)type] = block_array;
     }
 }
Ejemplo n.º 2
0
    public MapBlock CreateOrGetBlock(WorldSpaceType type, ShapeIndex block_index)
    {
        MapBlock block       = null;
        var      block_array = GetMapBlocks(type);

        if (block_array != null)
        {
            int array_index = GetBlockArrayIndex(block_index);
            if (block_array.Length <= array_index)
            {
                int        len = (block_index.z + EXPAND_BLOCK_SIZE) * BLOCKMAP_SIZE * BLOCKMAP_SIZE;
                MapBlock[] bs  = new MapBlock[len];
                Array.Copy(block_array, bs, block_array.Length);
                SetMapBlocks(type, bs);
                block_array = bs;
            }

            block = block_array[array_index];
            if (block == null)
            {
                block           = new MapBlock();
                block.SpaceType = type;
                block.Index     = block_index;
                block.Init();
                block_array[array_index] = block;
            }
        }
        return(block);
    }
Ejemplo n.º 3
0
 private MapBlock[] GetMapBlocks(WorldSpaceType type)
 {
     if (type > WorldSpaceType.NONE && type < WorldSpaceType.TYPE_COUNT)
     {
         return(m_Blocks[(int)type]);
     }
     return(null);
 }
Ejemplo n.º 4
0
    public MapBlock GetMapBlock(WorldSpaceType type, ShapeIndex index)
    {
        var block_array = GetMapBlocks(type);

        if (block_array != null)
        {
            int array_index = GetBlockArrayIndex(index);
            if (array_index >= 0 && array_index < block_array.Length)
            {
                return(block_array[array_index]);
            }
        }
        return(null);
    }