getDefaultStructValue() 공개 정적인 메소드

public static getDefaultStructValue ( string className ) : PropertyCollection
className string
리턴 PropertyCollection
        /// <summary>
        /// Gets the default values for a struct
        /// </summary>
        /// <param name="game">Game to pull info from</param>
        /// <param name="typeName">Struct type name</param>
        /// <param name="stripTransients">Strip transients from the struct</param>
        /// <returns></returns>
        internal static PropertyCollection getDefaultStructValue(Mod.MEGame game, string typeName, bool stripTransients)
        {
            switch (game)
            {
            case Mod.MEGame.ME1:
                return(ME1UnrealObjectInfo.getDefaultStructValue(typeName, stripTransients));

            case Mod.MEGame.ME2:
                return(ME2UnrealObjectInfo.getDefaultStructValue(typeName, stripTransients));

            case Mod.MEGame.ME3:
                return(ME3UnrealObjectInfo.getDefaultStructValue(typeName, stripTransients));
            }
            return(null);
        }
예제 #2
0
        public static PropertyCollection ReadSpecialStruct(IMEPackage pcc, MemoryStream stream, string structType, int size)
        {
            PropertyCollection props = new PropertyCollection();

            if (pcc.Game == MEGame.ME3)
            {
                if (ME3UnrealObjectInfo.Structs.ContainsKey(structType))
                {
                    PropertyCollection defaultProps;
                    //memoize
                    if (defaultStructValues.ContainsKey(structType))
                    {
                        defaultProps = defaultStructValues[structType];
                    }
                    else
                    {
                        defaultProps = ME3UnrealObjectInfo.getDefaultStructValue(structType);
                        if (defaultProps == null)
                        {
                            props.Add(new UnknownProperty(stream, size));
                            return(props);
                        }
                        defaultStructValues.Add(structType, defaultProps);
                    }
                    for (int i = 0; i < defaultProps.Count; i++)
                    {
                        UProperty uProperty = ReadSpecialStructProp(pcc, stream, defaultProps[i], structType);
                        if (uProperty.PropType != PropertyType.None)
                        {
                            props.Add(uProperty);
                        }
                    }
                    return(props);
                }
            }
            //TODO: implement getDefaultClassValue() for ME1 and ME2 so this isn't needed
            if (structType == "Rotator")
            {
                string[] labels = { "Pitch", "Yaw", "Roll" };
                for (int i = 0; i < 3; i++)
                {
                    props.Add(new IntProperty(stream, labels[i]));
                }
            }
            else if (structType == "Vector2d" || structType == "RwVector2")
            {
                string[] labels = { "X", "Y" };
                for (int i = 0; i < 2; i++)
                {
                    props.Add(new FloatProperty(stream, labels[i]));
                }
            }
            else if (structType == "Vector" || structType == "RwVector3")
            {
                string[] labels = { "X", "Y", "Z" };
                for (int i = 0; i < 3; i++)
                {
                    props.Add(new FloatProperty(stream, labels[i]));
                }
            }
            else if (structType == "Color")
            {
                string[] labels = { "B", "G", "R", "A" };
                for (int i = 0; i < 4; i++)
                {
                    props.Add(new ByteProperty(stream, labels[i]));
                }
            }
            else if (structType == "LinearColor")
            {
                string[] labels = { "R", "G", "B", "A" };
                for (int i = 0; i < 4; i++)
                {
                    props.Add(new FloatProperty(stream, labels[i]));
                }
            }
            //uses EndsWith to support RwQuat, RwVector4, and RwPlane
            else if (structType.EndsWith("Quat") || structType.EndsWith("Vector4") || structType.EndsWith("Plane"))
            {
                string[] labels = { "X", "Y", "Z", "W" };
                for (int i = 0; i < 4; i++)
                {
                    props.Add(new FloatProperty(stream, labels[i]));
                }
            }
            else if (structType == "TwoVectors")
            {
                string[] labels = { "X", "Y", "Z", "X", "Y", "Z" };
                for (int i = 0; i < 6; i++)
                {
                    props.Add(new FloatProperty(stream, labels[i]));
                }
            }
            else if (structType == "Matrix" || structType == "RwMatrix44")
            {
                string[] labels  = { "X Plane", "Y Plane", "Z Plane", "W Plane" };
                string[] labels2 = { "X", "Y", "Z", "W" };
                for (int i = 0; i < 4; i++)
                {
                    PropertyCollection structProps = new PropertyCollection();
                    for (int j = 0; j < 4; j++)
                    {
                        structProps.Add(new FloatProperty(stream, labels2[j]));
                    }
                    props.Add(new StructProperty("Plane", structProps, labels[i], true));
                }
            }
            else if (structType == "Guid")
            {
                string[] labels = { "A", "B", "C", "D" };
                for (int i = 0; i < 4; i++)
                {
                    props.Add(new IntProperty(stream, labels[i]));
                }
            }
            else if (structType == "IntPoint")
            {
                string[] labels = { "X", "Y" };
                for (int i = 0; i < 2; i++)
                {
                    props.Add(new IntProperty(stream, labels[i]));
                }
            }
            else if (structType == "Box" || structType == "BioRwBox")
            {
                string[] labels  = { "Min", "Max" };
                string[] labels2 = { "X", "Y", "Z" };
                for (int i = 0; i < 2; i++)
                {
                    PropertyCollection structProps = new PropertyCollection();
                    for (int j = 0; j < 3; j++)
                    {
                        structProps.Add(new FloatProperty(stream, labels2[j]));
                    }
                    props.Add(new StructProperty("Vector", structProps, labels[i], true));
                }
                props.Add(new ByteProperty(stream, "IsValid"));
            }
            else
            {
                props.Add(new UnknownProperty(stream, size));
            }
            return(props);
        }