private void LoadAllBlocks(Stream strm) { int sections = strm.ReadByte(); int bytesToRead = (sections * Section.BYTESIZE) + (sections * 5) + (HALFSIZE * 2); strm.Read(_Buffer, 0, bytesToRead); int i = 0; while(sections > 0) { int sectionId = _Buffer[i++]; Section section = _Sections[sectionId] = new Section(this, sectionId); Buffer.BlockCopy(_Buffer, i, section.Types, 0, Section.SIZE); i += Section.SIZE; Buffer.BlockCopy(_Buffer, i, section.Data.Data, 0, Section.HALFSIZE); i += Section.HALFSIZE; section.NonAirBlocks = BitConverter.ToInt32(_Buffer, i); i += 4; --sections; } Buffer.BlockCopy(_Buffer, i, Light.Data, 0, HALFSIZE); i += HALFSIZE; Buffer.BlockCopy(_Buffer, i, SkyLight.Data, 0, HALFSIZE); }
public Section AddNewSection(int pos) { Section section = new Section(this, pos); _Sections[pos] = section; return section; }
private void LoadAllBlocks(Stream strm) { int sections = strm.ReadByte(); _SectionsNum = sections; strm.Read(_Buffer, 0, (sections * Section.BYTESIZE) + sections); int i = 0; while(sections > 0) { int sectionId = _Buffer[i++]; Section section = _Sections[sectionId] = new Section(this); Buffer.BlockCopy(_Buffer, i, section.Types, 0, Section.SIZE); i += Section.SIZE; Buffer.BlockCopy(_Buffer, i, section.Data.Data, 0, Section.HALFSIZE); i += Section.HALFSIZE; --sections; } Buffer.BlockCopy(_Buffer, i, Light.Data, 0, Section.HALFSIZE); i += HALFSIZE; Buffer.BlockCopy(_Buffer, i, SkyLight.Data, 0, Section.HALFSIZE); /*strm.Read(Types, 0, SIZE); strm.Read(Data.Data, 0, HALFSIZE); strm.Read(Light.Data, 0, HALFSIZE); strm.Read(SkyLight.Data, 0, HALFSIZE);*/ }