Ejemplo n.º 1
0
        private static object ReadDataType(RepLayoutCmdType replayout, NetBitReader netBitReader, Type objectType = null)
        {
            object data = null;

            switch (replayout)
            {
            case RepLayoutCmdType.Property:
                data = Activator.CreateInstance(objectType);
                (data as IProperty).Serialize(netBitReader);
                break;

            case RepLayoutCmdType.PropertyBool:
                data = netBitReader.SerializePropertyBool();
                break;

            case RepLayoutCmdType.PropertyName:
                netBitReader.Seek(netBitReader.Position + netBitReader.GetBitsLeft());
                break;

            case RepLayoutCmdType.PropertyFloat:
                data = netBitReader.SerializePropertyFloat();
                break;

            case RepLayoutCmdType.PropertyNativeBool:
                data = netBitReader.SerializePropertyNativeBool();
                break;

            case RepLayoutCmdType.PropertyNetId:
                data = netBitReader.SerializePropertyNetId();
                break;

            case RepLayoutCmdType.PropertyObject:
                data = netBitReader.SerializePropertyObject();
                break;

            case RepLayoutCmdType.PropertyPlane:
                throw new NotImplementedException("Plane RepLayoutCmdType not implemented");

            case RepLayoutCmdType.PropertyRotator:
                data = netBitReader.SerializePropertyRotator();
                break;

            case RepLayoutCmdType.PropertyString:
                data = netBitReader.SerializePropertyString();
                break;

            case RepLayoutCmdType.PropertyVector10:
                data = netBitReader.SerializePropertyVector10();
                break;

            case RepLayoutCmdType.PropertyVector100:
                data = netBitReader.SerializePropertyVector100();
                break;

            case RepLayoutCmdType.PropertyVectorNormal:
                data = netBitReader.SerializePropertyVectorNormal();
                break;

            case RepLayoutCmdType.PropertyVectorQ:
                data = netBitReader.SerializePropertyQuantizeVector();
                break;

            case RepLayoutCmdType.RepMovement:
                data = netBitReader.SerializeRepMovement();
                break;

            case RepLayoutCmdType.Enum:
                data = netBitReader.SerializeEnum();
                break;

            //Auto generation fix to handle 1-8 bits
            case RepLayoutCmdType.PropertyByte:
                data = (byte)netBitReader.ReadBitsToInt(netBitReader.GetBitsLeft());
                break;

            //Auto generation fix to handle 1-32 bits.
            case RepLayoutCmdType.PropertyInt:
                data = netBitReader.ReadBitsToInt(netBitReader.GetBitsLeft());
                break;

            case RepLayoutCmdType.PropertyUInt64:
                data = netBitReader.ReadUInt64();
                break;

            case RepLayoutCmdType.PropertyUInt16:
                data = (ushort)netBitReader.ReadBitsToInt(netBitReader.GetBitsLeft());
                break;

            case RepLayoutCmdType.PropertyUInt32:
                data = netBitReader.ReadUInt32();
                break;

            case RepLayoutCmdType.Pointer:
                switch (netBitReader.GetBitsLeft())
                {
                case 8:
                    data = (uint)netBitReader.ReadByte();
                    break;

                case 16:
                    data = (uint)netBitReader.ReadUInt16();
                    break;

                case 32:
                    data = netBitReader.ReadUInt32();
                    break;
                }
                break;

            case RepLayoutCmdType.PropertyVector:
                data = new FVector(netBitReader.ReadSingle(), netBitReader.ReadSingle(), netBitReader.ReadSingle());
                break;

            case RepLayoutCmdType.Ignore:
                netBitReader.Seek(netBitReader.Position + netBitReader.GetBitsLeft());
                break;
            }

            return(data);
        }
        private object ReadDataType(RepLayoutCmdType replayout, NetBitReader netBitReader, Type objectType = null)
        {
            object data = null;

            switch (replayout)
            {
            case RepLayoutCmdType.Property:
                data = _linqCache.CreateObject(objectType);
                (data as IProperty).Serialize(netBitReader);
                (data as IResolvable)?.Resolve(GuidCache);
                break;

            case RepLayoutCmdType.PropertyBool:
                data = netBitReader.SerializePropertyBool();
                break;

            case RepLayoutCmdType.PropertyName:
                data = netBitReader.SerializePropertyName();
                break;

            case RepLayoutCmdType.PropertyFloat:
                data = netBitReader.SerializePropertyFloat();
                break;

            case RepLayoutCmdType.PropertyNativeBool:
                data = netBitReader.SerializePropertyNativeBool();
                break;

            case RepLayoutCmdType.PropertyNetId:
                data = netBitReader.SerializePropertyNetId();
                break;

            case RepLayoutCmdType.PropertyObject:
                data = netBitReader.SerializePropertyObject();
                break;

            case RepLayoutCmdType.PropertyPlane:
                throw new NotImplementedException("Plane RepLayoutCmdType not implemented");

            case RepLayoutCmdType.PropertyRotator:
                data = netBitReader.SerializePropertyRotator();
                break;

            case RepLayoutCmdType.PropertyString:
                data = netBitReader.SerializePropertyString();
                break;

            case RepLayoutCmdType.PropertyVector10:
                data = netBitReader.SerializePropertyVector10();
                break;

            case RepLayoutCmdType.PropertyVector100:
                data = netBitReader.SerializePropertyVector100();
                break;

            case RepLayoutCmdType.PropertyVectorNormal:
                data = netBitReader.SerializePropertyVectorNormal();
                break;

            case RepLayoutCmdType.PropertyVectorQ:
                data = netBitReader.SerializePropertyQuantizedVector(VectorQuantization.RoundWholeNumber);
                break;

            case RepLayoutCmdType.RepMovement:
                data = netBitReader.SerializeRepMovement();
                break;

            case RepLayoutCmdType.Enum:
                data = netBitReader.SerializePropertyEnum();
                break;

            // TODO Auto generation fix to handle 1-8 bits
            case RepLayoutCmdType.PropertyByte:
                data = (byte)netBitReader.ReadBitsToInt(netBitReader.GetBitsLeft());
                break;

            // TODO Auto generation fix to handle 1-32 bits.
            case RepLayoutCmdType.PropertyInt:
                data = netBitReader.ReadBitsToInt(netBitReader.GetBitsLeft());
                break;

            case RepLayoutCmdType.PropertyInt16:
                data = netBitReader.ReadInt16();
                break;

            case RepLayoutCmdType.PropertyUInt64:
                data = netBitReader.ReadUInt64();
                break;

            case RepLayoutCmdType.PropertyUInt16:
                data = netBitReader.ReadUInt16();
                break;

            case RepLayoutCmdType.PropertyUInt32:
                data = netBitReader.ReadUInt32();
                break;

            case RepLayoutCmdType.PropertyVector:
                data = netBitReader.SerializePropertyVector();
                break;

            case RepLayoutCmdType.PropertyVector2D:
                data = netBitReader.SerializePropertyVector2D();
                break;

            default:
                netBitReader.Seek(netBitReader.GetBitsLeft(), System.IO.SeekOrigin.Current);
                break;
            }

            return(data);
        }