public void SetBlock(BlockInSection blkInSec, byte blkID, bool IfUpdateMesh = true)
 {
     m_Voxel[blkInSec.x, blkInSec.y, blkInSec.z] = blkID;
     if (IfUpdateMesh)
     {
         BuildMesh();
     }
 }
        //Search Block
        //-----------------------------------------------------------------------
        static public IBlock GetBlock(Vector3 Coord, IWorld _World)
        {
            //Try get section
            Section section = GetSection(Coord, _World);

            if (section == null)
            {
                return(null);
            }

            BlockInSection BlockSlot = new BlockInSection(Coord, _World);

            return(section.Voxel.GetBlock(BlockSlot));
        }
        public void Modify(SectionInChunk Loc, BlockInSection slot, byte blockId)
        {
            if (m_Helpers.TryGetValue(Loc.Value, out var SectionHelper))
            {
                SectionHelper.Modify(slot, blockId);
            }
            else
            {
                m_Changes.Add(new SectionChange(Loc.Value));
                SectionHelper = new SaveHelper_Section(m_Changes[m_Changes.Count - 1]);

                m_Helpers.Add(Loc.Value, SectionHelper);
                SectionHelper.Modify(slot, blockId);
            }
        }
        static public int GetGroundHeight(Vector3 Coord, IWorld _World)
        {
            Chunk chk = GetChunk(Coord, _World);

            if (chk == null)
            {
                return(0);
            }

            BlockInSection BlkInSec = new BlockInSection(Coord, _World);

            var hmap = chk.HeightMap;

            return(hmap[BlkInSec.x, BlkInSec.z].Height);
        }
Пример #5
0
 public void Modify(BlockInSection slot, byte blockId)
 {
     if (m_Dic.ContainsKey(slot.Value))
     {
         m_Changes[m_Dic[slot.Value]]
             = new BlockChange(slot.Value, blockId);
         //Debug.Log("Block has Modifid");
     }
     else
     {
         m_Dic.Add(slot.Value, m_Changes.Count);
         m_Changes.Add(new BlockChange(slot.Value, blockId));
         //Debug.Log("Block has Added");
     }
 }
 public byte GetBlockID(BlockInSection blkInSec)
 {
     return(m_Voxel[blkInSec.x, blkInSec.y, blkInSec.z]);
 }
 public IBlock GetBlock(BlockInSection blkInSec)
 {
     return(m_World.BlkPalette[m_Voxel[blkInSec.x, blkInSec.y, blkInSec.z]]);
 }