Exemple #1
0
        public bool Deserialize(Stream stream)
        {
            // item type
            ushort typeAsUShort;

            stream.PacketReadUShort(out typeAsUShort);

            if (!Enum.IsDefined(typeof(TypeEnum), (ushort)Type))
            {
                return(false);
            }

            Type = (TypeEnum)typeAsUShort;

            HasFields = new BitField();

            byte fieldCount;

            stream.PacketReadByte(out fieldCount);

            switch ((TypeEnum)Type)
            {
            case TypeEnum.Transform:

                Transform.Deserialize(fieldCount, ref HasFields, stream);
                break;

            case TypeEnum.Movement:

                Movement.Deserialize(fieldCount, ref HasFields, stream);
                break;

            case TypeEnum.Player:

                Player.Deserialize(fieldCount, ref HasFields, stream);
                break;

            default:

                return(false);
            }

            return(true);
        }