//Public Function //------------------------------------------------------------------------ public Section GetSection(SectionInChunk slot) { if (slot.Value < 0 || slot.Value >= m_World.Chunk_Height) { return(null); } return(m_arrSections[slot.Value]); }
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); } }
public bool TryGetSection(SectionInChunk slot, out Section Sec) { Sec = default(Section); slot.Value = slot.Value % m_World.Chunk_Height; if (slot.Value < 0 || slot.Value > m_World.Chunk_Height) { return(false); } else { Sec = m_arrSections[slot.Value]; return(true); } }
public Section CreateBlankSection(SectionInChunk slot) { if (slot.Value < 0 || slot.Value >= m_World.Chunk_Height) { return(null); } //make a Section instance m_arrSections[slot.Value] = Instantiate(m_Prefab_Section, transform).GetComponent <Section>(); //Init Section m_arrSections[slot.Value].SetLocation (new SectionInWorld(m_ChunkinWorld.Value.x, slot.Value, m_ChunkinWorld.Value.y)); m_arrSections[slot.Value].CreateEmptyVoxel(); return(m_arrSections[slot.Value]); }
public void ApplyModification(Chunk _chunk, IWorld world) { Section Sec; SectionInChunk SecInchunk; foreach (var helper in m_Helpers) { SecInchunk = new SectionInChunk(helper.Key); Sec = _chunk.GetSection(SecInchunk); if (Sec == null) { Sec = _chunk.CreateBlankSection(SecInchunk); } if (Sec == null) { Debug.LogError("over bound"); continue; } helper.Value.ApplyModification(Sec, world); } }