예제 #1
0
            public static Base Parse(Client client, Coob coob)
            {
                int length = client.Reader.ReadInt32();

                byte[] compressedData = client.Reader.ReadBytes(length);
                byte[] maskedData     = ZlibHelper.UncompressBuffer(compressedData);

                using (var ms = new MemoryStream(maskedData))
                    using (var br = new BinaryReader(ms))
                    {
                        ulong id = br.ReadUInt64();

                        if (id != client.Id)
                        {
                            throw new NotImplementedException();
                        }

                        if (client.Entity == null)
                        {
                            Entity entity = new Entity(coob, null);

                            client.Entity = entity;
                            entity.Client = client;
                            entity.ID     = client.Id;
                            coob.World.Entities[client.Id] = client.Entity;

                            entity.ReadByMask(br);

                            return(new EntityUpdate(client.Entity, client.Entity, true, client));
                        }

                        Entity changes = new Entity(coob, client);
                        changes.ReadByMask(br);

                        return(new EntityUpdate(client.Entity, changes, false, client));
                    }
            }