예제 #1
0
        public bool DeserializeValue(PropertyType type, out DefaultPropertyValue value, UInt32 size)
        {
            value = null;
            switch (type) // Adjust size for certain types:
            {
            case PropertyType.BoolProperty:
                value = new BoolPropertyValue(Data, PCC);
                return(value.Deserialize());

            case PropertyType.ByteProperty:
                var enumName = PCC.GetName(Data.ReadNameRef());
                if (size == 8)     // if it's an enum-based byte value
                {
                    value = new EnumPropertyValue(Data, PCC, size, enumName);
                }
                else
                {
                    value = new BytePropertyValue(Data, PCC);
                }
                return(value.Deserialize());

            case PropertyType.IntProperty:
                value = new IntPropertyValue(Data, PCC);
                return(value.Deserialize());

            case PropertyType.FloatProperty:
                value = new FloatPropertyValue(Data, PCC);
                return(value.Deserialize());

            case PropertyType.StrProperty:
                value = new StrPropertyValue(Data, PCC, size);
                return(value.Deserialize());

            case PropertyType.StringRefProperty:
                value = new StringRefPropertyValue(Data, PCC);
                return(value.Deserialize());

            case PropertyType.NameProperty:
                value = new NamePropertyValue(Data, PCC);
                return(value.Deserialize());

            case PropertyType.ObjectProperty:
                value = new ObjectPropertyValue(Data, PCC);
                return(value.Deserialize());

            case PropertyType.InterfaceProperty:
                value = new InterfacePropertyValue(Data, PCC);
                return(value.Deserialize());

            case PropertyType.DelegateProperty:
                value = new DelegatePropertyValue(Data, PCC, Name);
                return(value.Deserialize());

            case PropertyType.StructProperty:
                var structName = PCC.GetName(Data.ReadNameRef());
                // If it's a hardcoded struct type, deserialize it as that.
                if (Enum.GetNames(typeof(PropertyType)).Skip(11).Contains(structName))
                {
                    return(DeserializeValue((PropertyType)Enum.Parse(typeof(PropertyType), structName), out value, size));
                }

                // otherwise use the deserialization of a user-defined struct:
                value = new StructPropertyValue(Data, PCC, size, structName);
                return(value.Deserialize());

            case PropertyType.ArrayProperty:
                value = new ArrayPropertyValue(Data, PCC, size);
                return(value.Deserialize());

                #region BioWare

            case PropertyType.BioMask4Property:
                value = new BioMask4PropertyValue(Data, PCC);
                return(value.Deserialize());

                #endregion


                #region Hardcoded Structs

                #region Standard
            case PropertyType.Vector:
                value = new VectorPropertyValue(Data, PCC);
                return(value.Deserialize());

            case PropertyType.Color:
                value = new ColorPropertyValue(Data, PCC);
                return(value.Deserialize());

            case PropertyType.LinearColor:
                value = new LinearColorPropertyValue(Data, PCC);
                return(value.Deserialize());

            case PropertyType.TwoVectors:
                value = new TwoVectorsPropertyValue(Data, PCC);
                return(value.Deserialize());

            case PropertyType.Vector4:
                value = new Vector4PropertyValue(Data, PCC);
                return(value.Deserialize());

            case PropertyType.Vector2D:
                value = new Vector2DPropertyValue(Data, PCC);
                return(value.Deserialize());

            case PropertyType.Rotator:
                value = new RotatorPropertyValue(Data, PCC);
                return(value.Deserialize());

            case PropertyType.Guid:
                value = new GUIDPropertyValue(Data, PCC);
                return(value.Deserialize());

            case PropertyType.Sphere:
                value = new SpherePropertyValue(Data, PCC);
                return(value.Deserialize());

            case PropertyType.Plane:
                value = new PlanePropertyValue(Data, PCC);
                return(value.Deserialize());

            case PropertyType.Scale:
                value = new ScalePropertyValue(Data, PCC);
                return(value.Deserialize());

            case PropertyType.Box:
                value = new BoxPropertyValue(Data, PCC);
                return(value.Deserialize());

            case PropertyType.Quat:
                value = new QuatPropertyValue(Data, PCC);
                return(value.Deserialize());

            case PropertyType.Matrix:
                value = new MatrixPropertyValue(Data, PCC);
                return(value.Deserialize());

            case PropertyType.IntPoint:
                value = new IntPointPropertyValue(Data, PCC);
                return(value.Deserialize());

                #endregion

                #region BioWare
            case PropertyType.BioRwBox:
                value = new BioRwBoxPropertyValue(Data, PCC);
                return(value.Deserialize());

            case PropertyType.RwVector3:
                value = new RwVector3PropertyValue(Data, PCC);
                return(value.Deserialize());

            case PropertyType.RwVector2:
                value = new RwVector2PropertyValue(Data, PCC);
                return(value.Deserialize());

            case PropertyType.RwVector4:
                value = new RwVector4PropertyValue(Data, PCC);
                return(value.Deserialize());

            case PropertyType.RwPlane:
                value = new RwPlanePropertyValue(Data, PCC);
                return(value.Deserialize());

            case PropertyType.RwQuat:
                value = new RwQuatPropertyValue(Data, PCC);
                return(value.Deserialize());

            case PropertyType.RwMatrix44:
                value = new RwMatrix44PropertyValue(Data, PCC);
                return(value.Deserialize());

                #endregion

                #region UE3Internals

            case PropertyType.ActorReference:
                value = new ActorReferencePropertyValue(Data, PCC);
                return(value.Deserialize());

            case PropertyType.PolyReference:
                value = new PolyReferencePropertyValue(Data, PCC);
                return(value.Deserialize());

            case PropertyType.AimTransform:
                value = new AimTransformPropertyValue(Data, PCC);
                return(value.Deserialize());

            case PropertyType.NavReference:
                value = new NavReferencePropertyValue(Data, PCC);
                return(value.Deserialize());

            case PropertyType.CoverReference:
                value = new CoverReferencePropertyValue(Data, PCC);
                return(value.Deserialize());

            case PropertyType.CoverInfo:
                value = new CoverInfoPropertyValue(Data, PCC);
                return(value.Deserialize());

            case PropertyType.CoverSlot:
                value = new CoverSlotPropertyValue(Data, PCC, size);
                return(value.Deserialize());

                #endregion

                #endregion

            default:
                return(false);
            }
        }
예제 #2
0
        public bool DeserializeValue(PropertyType type, out DefaultPropertyValue value, UInt32 size)
        {
            value = null;
            switch (type) // Adjust size for certain types:
            {
                case PropertyType.BoolProperty:
                    value = new BoolPropertyValue(Data, PCC);
                    return value.Deserialize();

                case PropertyType.ByteProperty:
                    var enumName = PCC.GetName(Data.ReadNameRef());
                    if (size == 8) // if it's an enum-based byte value
                        value = new EnumPropertyValue(Data, PCC, size, enumName);
                    else
                        value = new BytePropertyValue(Data, PCC);
                    return value.Deserialize();

                case PropertyType.IntProperty:
                    value = new IntPropertyValue(Data, PCC);
                    return value.Deserialize();

                case PropertyType.FloatProperty:
                    value = new FloatPropertyValue(Data, PCC);
                    return value.Deserialize();

                case PropertyType.StrProperty:
                    value = new StrPropertyValue(Data, PCC, size);
                    return value.Deserialize();

                case PropertyType.StringRefProperty:
                    value = new StringRefPropertyValue(Data, PCC);
                    return value.Deserialize();

                case PropertyType.NameProperty:
                    value = new NamePropertyValue(Data, PCC);
                    return value.Deserialize();

                case PropertyType.ObjectProperty:
                    value = new ObjectPropertyValue(Data, PCC);
                    return value.Deserialize();

                case PropertyType.InterfaceProperty:
                    value = new InterfacePropertyValue(Data, PCC);
                    return value.Deserialize();

                case PropertyType.DelegateProperty:
                    value = new DelegatePropertyValue(Data, PCC, Name);
                    return value.Deserialize();

                case PropertyType.StructProperty:
                    var structName = PCC.GetName(Data.ReadNameRef());
                    // If it's a hardcoded struct type, deserialize it as that.
                    if (Enum.GetNames(typeof(PropertyType)).Skip(11).Contains(structName))
                        return DeserializeValue((PropertyType)Enum.Parse(typeof(PropertyType), structName), out value, size);

                    // otherwise use the deserialization of a user-defined struct:
                    value = new StructPropertyValue(Data, PCC, size, structName);
                    return value.Deserialize();

                case PropertyType.ArrayProperty:
                    value = new ArrayPropertyValue(Data, PCC, size);
                    return value.Deserialize();

                #region BioWare

                case PropertyType.BioMask4Property:
                    value = new BioMask4PropertyValue(Data, PCC);
                    return value.Deserialize();
                #endregion

                #region Hardcoded Structs

                #region Standard
                case PropertyType.Vector:
                    value = new VectorPropertyValue(Data, PCC);
                    return value.Deserialize();

                case PropertyType.Color:
                    value = new ColorPropertyValue(Data, PCC);
                    return value.Deserialize();

                case PropertyType.LinearColor:
                    value = new LinearColorPropertyValue(Data, PCC);
                    return value.Deserialize();

                case PropertyType.TwoVectors:
                    value = new TwoVectorsPropertyValue(Data, PCC);
                    return value.Deserialize();

                case PropertyType.Vector4:
                    value = new Vector4PropertyValue(Data, PCC);
                    return value.Deserialize();

                case PropertyType.Vector2D:
                    value = new Vector2DPropertyValue(Data, PCC);
                    return value.Deserialize();

                case PropertyType.Rotator:
                    value = new RotatorPropertyValue(Data, PCC);
                    return value.Deserialize();

                case PropertyType.Guid:
                    value = new GUIDPropertyValue(Data, PCC);
                    return value.Deserialize();

                case PropertyType.Sphere:
                    value = new SpherePropertyValue(Data, PCC);
                    return value.Deserialize();

                case PropertyType.Plane:
                    value = new PlanePropertyValue(Data, PCC);
                    return value.Deserialize();

                case PropertyType.Scale:
                    value = new ScalePropertyValue(Data, PCC);
                    return value.Deserialize();

                case PropertyType.Box:
                    value = new BoxPropertyValue(Data, PCC);
                    return value.Deserialize();

                case PropertyType.Quat:
                    value = new QuatPropertyValue(Data, PCC);
                    return value.Deserialize();

                case PropertyType.Matrix:
                    value = new MatrixPropertyValue(Data, PCC);
                    return value.Deserialize();

                case PropertyType.IntPoint:
                    value = new IntPointPropertyValue(Data, PCC);
                    return value.Deserialize();
                #endregion

                #region BioWare
                case PropertyType.BioRwBox:
                    value = new BioRwBoxPropertyValue(Data, PCC);
                    return value.Deserialize();

                case PropertyType.RwVector3:
                    value = new RwVector3PropertyValue(Data, PCC);
                    return value.Deserialize();

                case PropertyType.RwVector2:
                    value = new RwVector2PropertyValue(Data, PCC);
                    return value.Deserialize();

                case PropertyType.RwVector4:
                    value = new RwVector4PropertyValue(Data, PCC);
                    return value.Deserialize();

                case PropertyType.RwPlane:
                    value = new RwPlanePropertyValue(Data, PCC);
                    return value.Deserialize();

                case PropertyType.RwQuat:
                    value = new RwQuatPropertyValue(Data, PCC);
                    return value.Deserialize();

                case PropertyType.RwMatrix44:
                    value = new RwMatrix44PropertyValue(Data, PCC);
                    return value.Deserialize();

                #endregion

                #region UE3Internals

                case PropertyType.ActorReference:
                    value = new ActorReferencePropertyValue(Data, PCC);
                    return value.Deserialize();

                case PropertyType.PolyReference:
                    value = new PolyReferencePropertyValue(Data, PCC);
                    return value.Deserialize();

                case PropertyType.AimTransform:
                    value = new AimTransformPropertyValue(Data, PCC);
                    return value.Deserialize();

                case PropertyType.NavReference:
                    value = new NavReferencePropertyValue(Data, PCC);
                    return value.Deserialize();

                case PropertyType.CoverReference:
                    value = new CoverReferencePropertyValue(Data, PCC);
                    return value.Deserialize();

                case PropertyType.CoverInfo:
                    value = new CoverInfoPropertyValue(Data, PCC);
                    return value.Deserialize();

                case PropertyType.CoverSlot:
                    value = new CoverSlotPropertyValue(Data, PCC, size);
                    return value.Deserialize();

                #endregion

                #endregion

                default:
                    return false;
            }
        }