public static new BlockUpdate decode(ref Lidgren.Network.NetIncomingMessage msg) { BlockUpdate bu = new BlockUpdate (Packet.decode (ref msg).ClientId); bu.added = msg.ReadBoolean (); bu.position = new Vector2f(msg.ReadFloat(), msg.ReadFloat()); bu.blockType = msg.ReadByte(); bu.layer = msg.ReadByte(); return bu; }
private void Update(float frameTime) { if (inputManager.Input.LeftMouseButton) { BlockUpdate bu = new BlockUpdate(clientId); bu.Added = true; bu.Position = GetWorldMouse(); bu.BlockType = (byte) blockType; bu.Layer = (byte) player.Layer; SendPacket(bu); } if (inputManager.Input.RightMouseButton) { BlockUpdate bu = new BlockUpdate(clientId); bu.Added = false; bu.Position = GetWorldMouse(); bu.Layer = (byte) player.Layer; SendPacket(bu); } player.LookAt(GetWorldMouse()); player.Update(frameTime, inputManager.Input); UpdateCam(); UserMessage uMsg = new UserMessage(clientId); uMsg.Position = player.Position; uMsg.Ticktime = frameTime; uMsg.EyePosition = GetWorldMouse(); uMsg.FallSpeed = player.FallSpeed; uMsg.Input = inputManager.Input; uMsg.Layer = (byte) player.Layer; uMsg.Nolcip = player.Noclip; SendPacket(uMsg); uMsgBuffer.insert(uMsg); }
private void SendFullWorldUpdate(NetConnection client) { int layer = 0; foreach (List<Cube> cubeList in map.CubeLists) { foreach (Cube c in cubeList) { BlockUpdate bu = new BlockUpdate(0); bu.Added = true; bu.Position = c.Position; bu.BlockType = (byte)c.type; bu.Layer = (byte)layer; SendPkt(bu, client, true); } layer++; } }