public Region(Level level,int x1,int y1,int z1,int x2,int y2,int z2) { if (level==null) { throw new ArgumentNullException("level"); } this.level = level; this.x1 = x1; this.y1 = y1; this.z1 = z1; this.x2 = x2; this.y2 = y2; this.z2 = z2; level.regions.Add(this); level.BlockEvent += CheckBlock; }
public static Level Flatgrass(short width,short depth,short height,int grasslevel) { if (!ValidLevelSize(width,depth,height)) { return null; } Level level = new Level(width,depth,height); grasslevel += depth/2-1; if (grasslevel>=depth) { return level; } int x,y=grasslevel,z; for (x=0;x<width;x++) for (z=0;z<height;z++) level[x,y,z] = 0x02; for (y=0;y<grasslevel && y<depth;y++) for (x=0;x<width;x++) for (z=0;z<height;z++) level[x,y,z] = 0x03; for (y=0;y<grasslevel-4 && y<depth;y++) for (x=0;x<width;x++) for (z=0;z<height;z++) level[x,y,z] = 0x01; return level; }
public Body(string name,Level level) { if (name==null) { throw new ArgumentNullException("name"); } if (level==null) { throw new ArgumentNullException("name"); } this.name = name; this.level = level; }
public void Send(Level level,Player except) { foreach (Packet packet in packets) packet.Send(level,except); }
public void Send(Level level) { foreach (Packet packet in packets) packet.Send(level); }
internal void SendLevel(Level level) { if (status!=OnlineStatus.Identified) { return; } this.level = level; status = OnlineStatus.Loading; new Thread( delegate() { Protocol.MapBeginPacket().Send(this); byte[] gzipped = Utility.GZipper.GZip( BitConverter.GetBytes( IPAddress.HostToNetworkOrder(level.Mapdata.Length) ),level.Mapdata); for (int i=0;i<gzipped.Length;i+=1024) { byte progress = (byte)((i/1024+1)/Math.Ceiling(gzipped.Length/1024d)*100); Protocol.MapPartPacket(gzipped,i,progress).Send(this); } Protocol.MapEndPacket(level.Width,level.Depth,level.Height).Send(this); ReadyEvent.Raise(server,this); Spawn(level.Spawn); foreach (Body b in level.Bodies) { Protocol.SpawnPacket(b).Send(this); } Position.Set(level.Spawn); Visible = true; status = OnlineStatus.Ready; level.players.Add(this); }).Start(); }
public void Send(Level level,Player except) { Send(new List<Player>(level.Players),except); }
public void Send(Level level) { Send(new List<Player>(level.Players)); }
public static Level Load(string name) { if (name==null) { throw new ArgumentNullException("name"); } if (name=="") { throw new ArgumentException("Name musn't be an empty string.","name"); } if (!RegexHelper.IsAlphaNumeric(name)) { throw new ArgumentException("Only alphanumerical characters allowed.","name"); } string filename = "levels/"+name+".lvl"; try { Node node = host.Load(filename,out name); if (name!="obsidian-level") { return null; } short width = (short)node["width"].Value; short depth = (short)node["depth"].Value; short height = (short)node["height"].Value; Node spawnNode = node["spawn"]; Position spawn = new Position( (short)spawnNode["x"].Value,(short)spawnNode["y"].Value,(short)spawnNode["z"].Value, (byte)spawnNode["rotx"].Value,(byte)spawnNode["roty"].Value); byte[] mapdata = (byte[])node["mapdata"].Value; byte[] blockdata = (byte[])node["blockdata"].Value; Level level = new Level(width,depth,height); level.spawn.Set(spawn); level.mapdata = mapdata; level.blockdata = blockdata; level.custom = node["custom"]??level.custom; return level; } catch { return null; } }