public static void SetBlocks(Entities.Map m, List<Tuple<long, long, long, byte>> blocks) { foreach (var b in blocks) { var x = b.Item1; var y = b.Item2; var z = b.Item3; var block = b.Item4; var sBase = GetSectorBase(x, y, z); lock (m.Sectors) { var sector = (from sx in m.Sectors where sx.XOffset == sBase.Item1 && sx.YOffset == sBase.Item2 && sx.ZOffset == sBase.Item3 select sx).FirstOrDefault(); if (sector == null) { sector = new Sector(sBase.Item1, sBase.Item2, sBase.Item3); m.Sectors.Add(sector); } var sOffset = GetSectorOffset(x, y, z); sector.SetSectorBlock( sOffset.Item1, sOffset.Item2, sOffset.Item3, block); } } }
/// <summary> /// /// </summary> /// <param name="s"></param> /// <returns></returns> public Entities.Sector GetHollowSectorFromSector() { var s = this; var ns = new Sector(s.XOffset,s.YOffset, s.ZOffset); for (int x = 0; x < Entities.Sector.Width; x++) { for (int y = 0; y < Entities.Sector.Height; y++) { for (int z = 0; z < Entities.Sector.Depth; z++) { if (s.GetOpenFacesInSector(x, y, z).Count < 6) ns.SetSectorBlock( x, y, z, s.GetBlockFromSector( x, y, z)); } } } return ns; }
public byte GetBlock( long x, long y, long z) { var m = this; var sBase = GetSectorBase(x, y, z); var sector = (from sx in m.Sectors where sx.XOffset == sBase.Item1 && sx.YOffset == sBase.Item2 && sx.ZOffset == sBase.Item3 select sx).FirstOrDefault(); if (sector == null) { sector = new Sector(sBase.Item1, sBase.Item2, sBase.Item3); m.Sectors.Add(sector); } var sOffset = GetSectorOffset(x, y, z); return sector.GetBlockFromSector( sOffset.Item1, sOffset.Item2, sOffset.Item3); }
public void SetBlock(long x, long y, long z, BrickTypeEnum bt) { var sBase = GetSectorBase(x, y, z); lock (Sectors) { var sector = (from sx in Sectors where sx.XOffset == sBase.Item1 && sx.YOffset == sBase.Item2 && sx.ZOffset == sBase.Item3 select sx).FirstOrDefault(); if (sector == null) { sector = new Sector(sBase.Item1, sBase.Item2, sBase.Item3); Sectors.Add(sector); } var sOffset = GetSectorOffset(x, y, z); sector.SetSectorBlock(sOffset.Item1, sOffset.Item2, sOffset.Item3, (byte)bt); } }