Esempio n. 1
0
 public static StructProperty ToGuidStructProp(this Guid guid, NameReference propName)
 {
     byte[] guidBytes = guid.ToByteArray();
     return(new StructProperty("Guid", new PropertyCollection
     {
         new IntProperty(BitConverter.ToInt32(guidBytes, 0)),
         new IntProperty(BitConverter.ToInt32(guidBytes, 4)),
         new IntProperty(BitConverter.ToInt32(guidBytes, 8)),
         new IntProperty(BitConverter.ToInt32(guidBytes, 12))
     }, propName, true));
 }
Esempio n. 2
0
        public DelegateProperty(MemoryStream stream, IMEPackage pcc, NameReference?name = null) : base(name)
        {
            unk = stream.ReadValueS32();
            NameReference val = new NameReference
            {
                Name   = pcc.getNameEntry(stream.ReadValueS32()),
                Number = stream.ReadValueS32()
            };

            Value    = val;
            PropType = PropertyType.DelegateProperty;
        }
Esempio n. 3
0
        public NameProperty(MemoryStream stream, IMEPackage pcc, NameReference?name = null) : base(name)
        {
            Offset         = stream.Position;
            NameTableIndex = stream.ReadValueS32();
            NameReference nameRef = new NameReference
            {
                Name   = pcc.getNameEntry(NameTableIndex),
                Number = stream.ReadValueS32()
            };

            Value    = nameRef;
            PropType = PropertyType.NameProperty;
        }
Esempio n. 4
0
        public EnumProperty(MemoryStream stream, IMEPackage pcc, NameReference enumType, NameReference?name = null) : base(name)
        {
            Offset   = stream.Position;
            EnumType = enumType;
            NameReference enumVal = new NameReference
            {
                Name   = pcc.getNameEntry(stream.ReadValueS32()),
                Number = stream.ReadValueS32()
            };

            Value      = enumVal;
            EnumValues = UnrealObjectInfo.GetEnumValues(pcc.Game, enumType, true);
            PropType   = PropertyType.ByteProperty;
        }
        public static void WriteBoolProperty(this Stream stream, IMEPackage pcc, NameReference propName, bool value, int staticArrayIndex)
        {
            //Debug.WriteLine("Writing bool property " + propName + ", value: " + value + " at 0x" + stream.Position.ToString("X6"));

            stream.WritePropHeader(pcc, propName, PropertyType.BoolProperty, 0, staticArrayIndex);
            if (pcc.Game >= MEGame.ME3)
            {
                stream.WriteBoolByte(value);
            }
            else
            {
                stream.WriteBoolInt(value);
            }
        }
        public static void WriteStringProperty(this Stream stream, IMEPackage pcc, NameReference propName, string value, int staticArrayIndex)
        {
            //Debug.WriteLine("Writing string property " + propName + ", value: " + value + " at 0x" + stream.Position.ToString("X6"));
            int strLen = value.Length == 0 ? 0 : value.Length + 1;

            if (pcc.Game == MEGame.ME3)
            {
                stream.WritePropHeader(pcc, propName, PropertyType.StrProperty, (strLen * 2) + 4, staticArrayIndex);
                stream.WriteUnrealStringUnicode(value);
            }
            else
            {
                stream.WritePropHeader(pcc, propName, PropertyType.StrProperty, strLen + 4, staticArrayIndex);
                stream.WriteUnrealStringASCII(value);
            }
        }
Esempio n. 7
0
        private static PropertyValue ReadValue(PCCObject pcc, byte[] raw, int start, int type)
        {
            PropertyValue v = new PropertyValue();

            switch (pcc.Names[type])
            {
            case "IntProperty":
            case "FloatProperty":
            case "ObjectProperty":
            case "StringRefProperty":
                v.IntValue = BitConverter.ToInt32(raw, start);
                v.len      = 4;
                break;

            case "NameProperty":
                v.IntValue = BitConverter.ToInt32(raw, start);
                var nameRef = new NameReference();
                nameRef.index = v.IntValue;
                nameRef.count = BitConverter.ToInt32(raw, start + 4);
                nameRef.Name  = pcc.getNameEntry(nameRef.index);
                if (nameRef.count > 0)
                {
                    nameRef.Name += "_" + (nameRef.count - 1);
                }
                v.NameValue = nameRef;
                v.len       = 8;
                break;

            case "BoolProperty":
                if (start < raw.Length)
                {
                    v.IntValue = raw[start];
                }
                v.len = 1;
                break;
            }
            return(v);
        }
Esempio n. 8
0
 public ArrayProperty(ArrayType type, NameReference name) : base(name)
 {
     PropType  = PropertyType.ArrayProperty;
     arrayType = type;
     Values    = new List <T>();
 }
Esempio n. 9
0
 public ArrayProperty(List <T> values, ArrayType type, NameReference name) : base(name)
 {
     PropType  = PropertyType.ArrayProperty;
     arrayType = type;
     Values    = values;
 }
Esempio n. 10
0
        public void LoadData()
        {
            FaceFXSeqs = new List<FaceFXTrackKey>();
            FaceFXSoundCueKeys = new List<FaceFXSoundCueKey>();
            OverrideAsset = new Override_Asset();
            m_aBioMaleAnimSets = new List<int>();
            m_aBioFemaleAnimSets = new List<int>();

            byte[] buff = pcc.Exports[index].Data;
            BitConverter.IsLittleEndian = true;
            List<PropertyReader.Property> props = PropertyReader.getPropList(pcc, pcc.Exports[index].Data);
            string name;
            foreach (PropertyReader.Property p in props)
            {
                name = pcc.getNameEntry(p.Name);
                if (name == "m_nmSFXFindActor")
                {
                    m_nmSFXFindActor = p.Value.NameValue;
                }
                else if (name == "m_bSFXEnableClipToClipBlending")
                {
                    m_bSFXEnableClipToClipBlending = p.Value.IntValue != 0;
                }
                else if (name == "m_eSFXFindActorMode")
                {
                    m_eSFXFindActorMode = new byteprop(p.raw, "", new string[] { "" });
                }
                else if (name == "m_aBioMaleAnimSets")
                {
                    int count2 = BitConverter.ToInt32(p.raw, 24);
                    for (int k = 0; k < count2; k++)
                    {
                        m_aBioMaleAnimSets.Add(BitConverter.ToInt32(p.raw, 28 + k * 4));
                    }
                }
                else if (name == "m_aBioFemaleAnimSets")
                {
                    int count2 = BitConverter.ToInt32(p.raw, 24);
                    for (int k = 0; k < count2; k++)
                    {
                        m_aBioFemaleAnimSets.Add(BitConverter.ToInt32(p.raw, 28 + k * 4));
                    }
                }
                else if (name == "FaceFXSeqs")
                {
                    FaceFXSeqs = new List<FaceFXTrackKey>();
                    int pos = 28;
                    int count = BitConverter.ToInt32(p.raw, 24);
                    for (int j = 0; j < count; j++)
                    {
                        List<PropertyReader.Property> p2 = PropertyReader.ReadProp(pcc, p.raw, pos);
                        FaceFXTrackKey key = new FaceFXTrackKey();
                        for (int i = 0; i < p2.Count(); i++)
                        {
                            if (pcc.getNameEntry(p2[i].Name) == "FaceFXGroupName")
                                key.FaceFXGroupName = p2[i].Value.StringValue;
                            else if (pcc.getNameEntry(p2[i].Name) == "FaceFXSeqName")
                                key.FaceFXSeqName = p2[i].Value.StringValue;
                            else if (pcc.getNameEntry(p2[i].Name) == "StartTime")
                                key.StartTime = BitConverter.ToSingle(p2[i].raw, 24);
                            pos += p2[i].raw.Length;
                        }
                        FaceFXSeqs.Add(key);
                    }
                }
                else if (name == "FaceFXSoundCueKeys")
                {
                    FaceFXSoundCueKeys = new List<FaceFXSoundCueKey>();
                    int pos = 28;
                    int count = BitConverter.ToInt32(p.raw, 24);
                    for (int j = 0; j < count; j++)
                    {
                        List<PropertyReader.Property> p2 = PropertyReader.ReadProp(pcc, p.raw, pos);
                        FaceFXSoundCueKey key = new FaceFXSoundCueKey();
                        for (int i = 0; i < p2.Count(); i++)
                        {
                            if (pcc.getNameEntry(p2[i].Name) == "FaceFXSoundCue")
                                key.FaceFXSoundCue = p2[i].Value.IntValue;
                            pos += p2[i].raw.Length;
                        }
                        FaceFXSoundCueKeys.Add(key);
                    }
                }
                else if (name == "OverrideAsset")
                {
                    OverrideAsset = new Override_Asset();
                    OverrideAsset.fxAsset = BitConverter.ToInt32(p.raw, 56);
                }
                else if (name == "OverrideAnimSet")
                {
                    OverrideAnimSet = new Override_AnimSet();
                    OverrideAnimSet.aBioFemaleSets = new List<int>();
                    OverrideAnimSet.aBioMaleSets = new List<int>();
                    int pos = 32;
                    List<PropertyReader.Property> p2 = PropertyReader.ReadProp(pcc, p.raw, pos);
                    for (int i = 0; i < p2.Count(); i++)
                    {
                        name = pcc.getNameEntry(p2[i].Name);
                        if (name == "aBioMaleSets")
                        {
                            int count2 = BitConverter.ToInt32(p2[i].raw, 24);
                            OverrideAnimSet.aBioMaleSets = new List<int>();
                            for (int k = 0; k < count2; k++)
                            {
                                OverrideAnimSet.aBioMaleSets.Add(BitConverter.ToInt32(p2[i].raw, 28 + k * 4));
                            }
                        }
                        else if (name == "aBioFemaleSets")
                        {
                            int count2 = BitConverter.ToInt32(p2[i].raw, 24);
                            OverrideAnimSet.aBioFemaleSets = new List<int>();
                            for (int k = 0; k < count2; k++)
                            {
                                OverrideAnimSet.aBioFemaleSets.Add(BitConverter.ToInt32(p2[i].raw, 28 + k * 4));
                            }
                        }
                        else if (name == "eAnimSequence")
                            OverrideAnimSet.eAnimSequence = new byteprop(p2[i].raw, "", new string[] { "" });
                        pos += p2[i].raw.Length;
                    }
                }
            }
        }
Esempio n. 11
0
 static PropertyValue ReadValue(IMEPackage pcc, byte[] raw, int start, int type)
 {
     PropertyValue v = new PropertyValue();
     switch (pcc.getNameEntry(type))
     {
         case "IntProperty":
         case "ObjectProperty":
         case "StringRefProperty":
             v.IntValue = BitConverter.ToInt32(raw, start);
             v.len = 4;
             break;
         case "NameProperty":
             v.IntValue = BitConverter.ToInt32(raw, start);
             var nameRef = new NameReference();
             nameRef.Name = pcc.getNameEntry(v.IntValue);
             nameRef.count = BitConverter.ToInt32(raw, start + 4);
             if (nameRef.count > 0)
                 nameRef.Name += "_" + (nameRef.count - 1);
             v.NameValue = nameRef;
             v.StringValue = nameRef.Name;
             v.len = 8;
             break;
     }
     return v;
 }
        public static PropertyCollection ReadProps(IMEPackage pcc, MemoryStream stream, string typeName)
        {
            PropertyCollection props = new PropertyCollection();
            long startPosition       = stream.Position;

            while (stream.Position + 8 <= stream.Length)
            {
                int nameIdx = stream.ReadValueS32();
                if (!pcc.isName(nameIdx))
                {
                    stream.Seek(-4, SeekOrigin.Current);
                    break;
                }
                string name = pcc.getNameEntry(nameIdx);
                if (name == "None")
                {
                    props.Add(new NoneProperty {
                        PropType = PropertyType.None
                    });
                    stream.Seek(4, SeekOrigin.Current);
                    break;
                }
                NameReference nameRef = new NameReference {
                    Name = name, count = stream.ReadValueS32()
                };
                int typeIdx = stream.ReadValueS32();
                stream.Seek(4, SeekOrigin.Current);
                int size = stream.ReadValueS32();
                if (!pcc.isName(typeIdx) || size < 0 || size > stream.Length - stream.Position)
                {
                    stream.Seek(-16, SeekOrigin.Current);
                    break;
                }
                stream.Seek(4, SeekOrigin.Current);
                PropertyType type;
                if (!Enum.TryParse(pcc.getNameEntry(typeIdx), out type))
                {
                    type = PropertyType.Unknown;
                }
                switch (type)
                {
                case PropertyType.StructProperty:
                    string structType = pcc.getNameEntry(stream.ReadValueS32());
                    stream.Seek(4, SeekOrigin.Current);
                    if (ME3UnrealObjectInfo.isImmutable(structType))
                    {
                        PropertyCollection structProps = ReadSpecialStruct(pcc, stream, structType, size);
                        props.Add(new StructProperty(structType, structProps, nameRef, true));
                    }
                    else
                    {
                        PropertyCollection structProps = ReadProps(pcc, stream, structType);
                        props.Add(new StructProperty(structType, structProps, nameRef));
                    }
                    break;

                case PropertyType.IntProperty:
                    props.Add(new IntProperty(stream, nameRef));
                    break;

                case PropertyType.FloatProperty:
                    props.Add(new FloatProperty(stream, nameRef));
                    break;

                case PropertyType.ObjectProperty:
                    props.Add(new ObjectProperty(stream, nameRef));
                    break;

                case PropertyType.NameProperty:
                    props.Add(new NameProperty(stream, pcc, nameRef));
                    break;

                case PropertyType.BoolProperty:
                    props.Add(new BoolProperty(stream, pcc.Game, nameRef));
                    break;

                case PropertyType.BioMask4Property:
                    props.Add(new BioMask4Property(stream, nameRef));
                    break;

                case PropertyType.ByteProperty:
                {
                    if (size != 1)
                    {
                        NameReference enumType = new NameReference();
                        if (pcc.Game == MEGame.ME3)
                        {
                            enumType.Name  = pcc.getNameEntry(stream.ReadValueS32());
                            enumType.count = stream.ReadValueS32();
                        }
                        else
                        {
                            enumType.Name = UnrealObjectInfo.GetEnumType(pcc.Game, name, typeName);
                        }
                        props.Add(new EnumProperty(stream, pcc, enumType, nameRef));
                    }
                    else
                    {
                        if (pcc.Game == MEGame.ME3)
                        {
                            stream.Seek(8, SeekOrigin.Current);
                        }
                        props.Add(new ByteProperty(stream, nameRef));
                    }
                }
                break;

                case PropertyType.ArrayProperty:
                {
                    props.Add(ReadArrayProperty(stream, pcc, typeName, nameRef));
                }
                break;

                case PropertyType.StrProperty:
                {
                    props.Add(new StrProperty(stream, nameRef));
                }
                break;

                case PropertyType.StringRefProperty:
                    props.Add(new StringRefProperty(stream, nameRef));
                    break;

                case PropertyType.DelegateProperty:
                    props.Add(new DelegateProperty(stream, pcc, nameRef));
                    break;

                case PropertyType.Unknown:
                {
                    props.Add(new UnknownProperty(stream, size, pcc.getNameEntry(typeIdx), nameRef));
                }
                break;

                case PropertyType.None:
                default:
                    break;
                }
            }
            if (props.Count > 0)
            {
                if (props[props.Count - 1].PropType != PropertyType.None)
                {
                    stream.Seek(startPosition, SeekOrigin.Begin);
                    return(new PropertyCollection {
                        endOffset = (int)stream.Position
                    });
                }
                //remove None Property
                props.RemoveAt(props.Count - 1);
            }
            props.endOffset = (int)stream.Position;
            return(props);
        }
Esempio n. 13
0
 public static void WriteDelegateProperty(this Stream stream, IMEPackage pcc, string propName, int unk, NameReference value)
 {
     stream.WritePropHeader(pcc, propName, PropertyType.DelegateProperty, 12);
     stream.WriteValueS32(unk);
     stream.WriteValueS32(pcc.FindNameOrAdd(value.Name));
     stream.WriteValueS32(value.Number);
 }
 public static void WriteStructProperty(this Stream stream, IMEPackage pcc, NameReference propName, NameReference structName, Func <Stream> func, int staticArrayIndex)
 {
     stream.WriteStructProperty(pcc, propName, structName, func(), staticArrayIndex);
 }
Esempio n. 15
0
        public void LoadData()
        {
            //default values
            m_nmFindActor = new NameReference();
            m_nmFindActor.index = -1;

            BitConverter.IsLittleEndian = true;
            List<PropertyReader.Property> props = PropertyReader.getPropList(pcc, pcc.Exports[index].Data);
            foreach (PropertyReader.Property p in props)
            {
                if (pcc.getNameEntry(p.Name) == "m_nmFindActor")
                    m_nmFindActor = p.Value.NameValue;
            }
        }
 public static void WriteArrayProperty(this Stream stream, IMEPackage pcc, NameReference propName, int count, Func <Stream> func, int staticArrayIndex)
 {
     stream.WriteArrayProperty(pcc, propName, count, func(), staticArrayIndex);
 }
Esempio n. 17
0
 protected UProperty(NameReference?name)
 {
     _name = name ?? new NameReference();
 }
 public static void WriteEnumProperty(this Stream stream, IMEPackage pcc, NameReference propName, NameReference enumName, NameReference enumValue, int staticArrayIndex)
 {
     stream.WritePropHeader(pcc, propName, PropertyType.ByteProperty, 8, staticArrayIndex);
     if (pcc.Game >= MEGame.ME3)
     {
         stream.WriteNameReference(enumName, pcc);
     }
     stream.WriteNameReference(enumValue, pcc);
 }
Esempio n. 19
0
 private static PropertyValue ReadValue(PCCObject pcc, byte[] raw, int start, int type)
 {
     PropertyValue v = new PropertyValue();
     switch (pcc.Names[type])
     {
         case "IntProperty":
         case "FloatProperty":
         case "ObjectProperty":
         case "StringRefProperty":
             v.IntValue = BitConverter.ToInt32(raw, start);
             v.len = 4;
             break;
         case "NameProperty":
             v.IntValue = BitConverter.ToInt32(raw, start);
             var nameRef = new NameReference();
             nameRef.index = v.IntValue;
             nameRef.count = BitConverter.ToInt32(raw, start + 4);
             nameRef.Name = pcc.getNameEntry(nameRef.index);
             if (nameRef.count > 0)
                 nameRef.Name += "_" + (nameRef.count - 1);
             v.NameValue = nameRef;
             v.len = 8;
             break;
         case "BoolProperty":
             if(start < raw.Length)
                 v.IntValue = raw[start];
             v.len = 1;
             break;
     }
     return v;
 }
        public static void WriteNameProperty(this Stream stream, IMEPackage pcc, NameReference propName, NameReference value, int staticArrayIndex)
        {
            //Debug.WriteLine("Writing name property " + propName + ", value: " + value + " at 0x" + stream.Position.ToString("X6"));

            stream.WritePropHeader(pcc, propName, PropertyType.NameProperty, 8, staticArrayIndex);
            stream.WriteNameReference(value, pcc);
        }
Esempio n. 21
0
 public void LoadData()
 {   //default values
     FacingController = new NameReference();
     
     
     List<PropertyReader.Property> props = PropertyReader.getPropList(pcc.Exports[index]);
     foreach (PropertyReader.Property p in props)
     {
         if (pcc.getNameEntry(p.Name) == "FacingController")
             FacingController = p.Value.NameValue;
     }
 }
Esempio n. 22
0
        public static void WriteNameProperty(this Stream stream, IMEPackage pcc, string propName, NameReference value)
        {
            //Debug.WriteLine("Writing name property " + propName + ", value: " + value + " at 0x" + stream.Position.ToString("X6"));

            stream.WritePropHeader(pcc, propName, PropertyType.NameProperty, 8);
            stream.WriteValueS32(pcc.FindNameOrAdd(value.Name));
            stream.WriteValueS32(value.Number);
        }
Esempio n. 23
0
        public static UProperty ReadArrayProperty(MemoryStream stream, IMEPackage pcc, string enclosingType, NameReference name, bool IsInImmutable = false)
        {
            long      arrayOffset = IsInImmutable ? stream.Position : stream.Position - 24;
            ArrayType arrayType   = UnrealObjectInfo.GetArrayType(pcc.Game, name, enclosingType);
            int       count       = stream.ReadValueS32();

            switch (arrayType)
            {
            case ArrayType.Object:
            {
                var props = new List <ObjectProperty>();
                for (int i = 0; i < count; i++)
                {
                    props.Add(new ObjectProperty(stream));
                }
                return(new ArrayProperty <ObjectProperty>(arrayOffset, props, arrayType, name));
            }

            case ArrayType.Name:
            {
                var props = new List <NameProperty>();
                for (int i = 0; i < count; i++)
                {
                    props.Add(new NameProperty(stream, pcc));
                }
                return(new ArrayProperty <NameProperty>(arrayOffset, props, arrayType, name));
            }

            case ArrayType.Enum:
            {
                var           props    = new List <EnumProperty>();
                NameReference enumType = new NameReference {
                    Name = UnrealObjectInfo.GetEnumType(pcc.Game, name, enclosingType)
                };
                for (int i = 0; i < count; i++)
                {
                    props.Add(new EnumProperty(stream, pcc, enumType));
                }
                return(new ArrayProperty <EnumProperty>(arrayOffset, props, arrayType, name));
            }

            case ArrayType.Struct:
            {
                var    props           = new List <StructProperty>();
                string arrayStructType = UnrealObjectInfo.GetPropertyInfo(pcc.Game, name, enclosingType)?.reference;
                if (IsInImmutable || ME3UnrealObjectInfo.isImmutable(arrayStructType))
                {
                    int arraySize = 0;
                    if (!IsInImmutable)
                    {
                        stream.Seek(-16, SeekOrigin.Current);
                        arraySize = stream.ReadValueS32();
                        stream.Seek(12, SeekOrigin.Current);
                    }
                    for (int i = 0; i < count; i++)
                    {
                        long offset = stream.Position;
                        PropertyCollection structProps = ReadSpecialStruct(pcc, stream, arrayStructType, arraySize / count);
                        StructProperty     structP     = new StructProperty(arrayStructType, structProps, isImmutable: true);
                        structP.Offset = offset;
                        props.Add(structP);
                    }
                }
                else
                {
                    for (int i = 0; i < count; i++)
                    {
                        long structOffset = stream.Position;
                        PropertyCollection structProps = ReadProps(pcc, stream, arrayStructType);
                        StructProperty     structP     = new StructProperty(arrayStructType, structProps);
                        structP.Offset = structOffset;
                        props.Add(structP);
                    }
                }
                return(new ArrayProperty <StructProperty>(arrayOffset, props, arrayType, name));
            }

            case ArrayType.Bool:
            {
                var props = new List <BoolProperty>();
                for (int i = 0; i < count; i++)
                {
                    props.Add(new BoolProperty(stream, pcc.Game));
                }
                return(new ArrayProperty <BoolProperty>(arrayOffset, props, arrayType, name));
            }

            case ArrayType.String:
            {
                var props = new List <StrProperty>();
                for (int i = 0; i < count; i++)
                {
                    props.Add(new StrProperty(stream));
                }
                return(new ArrayProperty <StrProperty>(arrayOffset, props, arrayType, name));
            }

            case ArrayType.Float:
            {
                var props = new List <FloatProperty>();
                for (int i = 0; i < count; i++)
                {
                    props.Add(new FloatProperty(stream));
                }
                return(new ArrayProperty <FloatProperty>(arrayOffset, props, arrayType, name));
            }

            case ArrayType.Byte:
            {
                var props = new List <ByteProperty>();
                for (int i = 0; i < count; i++)
                {
                    props.Add(new ByteProperty(stream));
                }
                return(new ArrayProperty <ByteProperty>(arrayOffset, props, arrayType, name));
            }

            case ArrayType.Int:
            default:
            {
                var props = new List <IntProperty>();
                for (int i = 0; i < count; i++)
                {
                    props.Add(new IntProperty(stream));
                }
                return(new ArrayProperty <IntProperty>(arrayOffset, props, arrayType, name));
            }
            }
        }
        public static void WriteStructProperty(this Stream stream, IMEPackage pcc, NameReference propName, NameReference structName, Stream value, int staticArrayIndex)
        {
            //Debug.WriteLine("Writing struct property " + propName + ", value: " + value + " at 0x" + stream.Position.ToString("X6"));

            stream.WritePropHeader(pcc, propName, PropertyType.StructProperty, (int)value.Length, staticArrayIndex);
            stream.WriteNameReference(structName, pcc);
            stream.WriteStream(value);
        }
Esempio n. 25
0
        public static PropertyCollection ReadProps(IMEPackage pcc, MemoryStream stream, string typeName, bool includeNoneProperty = false)
        {
            //Uncomment this for debugging property engine

            /*DebugOutput.StartDebugger("Property Engine ReadProps() for "+typeName);
             * if (pcc.FileName == "C:\\Users\\Dev\\Downloads\\ME2_Placeables.upk")
             * {
             * //Debugger.Break();
             * }*/
            PropertyCollection props = new PropertyCollection();
            long startPosition       = stream.Position;

            while (stream.Position + 8 <= stream.Length)
            {
                int nameIdx = stream.ReadValueS32();
                if (!pcc.isName(nameIdx))
                {
                    stream.Seek(-4, SeekOrigin.Current);
                    break;
                }
                string name = pcc.getNameEntry(nameIdx);
                if (name == "None")
                {
                    props.Add(new NoneProperty(stream, "None"));
                    stream.Seek(4, SeekOrigin.Current);
                    break;
                }
                NameReference nameRef = new NameReference {
                    Name = name, Number = stream.ReadValueS32()
                };
                int typeIdx = stream.ReadValueS32();
                stream.Seek(4, SeekOrigin.Current);
                int size = stream.ReadValueS32();
                if (!pcc.isName(typeIdx) || size < 0 || size > stream.Length - stream.Position)
                {
                    stream.Seek(-16, SeekOrigin.Current);
                    break;
                }
                stream.Seek(4, SeekOrigin.Current);
                PropertyType type;
                string       namev = pcc.getNameEntry(typeIdx);
                if (Enum.IsDefined(typeof(PropertyType), namev))
                {
                    Enum.TryParse(namev, out type);
                }
                else
                {
                    type = PropertyType.Unknown;
                }
                switch (type)
                {
                case PropertyType.StructProperty:
                    string structType = pcc.getNameEntry(stream.ReadValueS32());
                    stream.Seek(4, SeekOrigin.Current);
                    if (ME3UnrealObjectInfo.isImmutable(structType))
                    {
                        PropertyCollection structProps = ReadSpecialStruct(pcc, stream, structType, size);
                        var structprop = new StructProperty(structType, structProps, nameRef, true);
                        structprop.Offset = stream.Position - 4;
                        props.Add(structprop);
                    }
                    else
                    {
                        PropertyCollection structProps = ReadProps(pcc, stream, structType, includeNoneProperty);
                        var structprop = new StructProperty(structType, structProps, nameRef);
                        structprop.Offset = stream.Position - 4;
                        props.Add(structprop);
                    }
                    break;

                case PropertyType.IntProperty:
                    props.Add(new IntProperty(stream, nameRef));
                    break;

                case PropertyType.FloatProperty:
                    props.Add(new FloatProperty(stream, nameRef));
                    break;

                case PropertyType.ObjectProperty:
                    props.Add(new ObjectProperty(stream, nameRef));
                    break;

                case PropertyType.NameProperty:
                    props.Add(new NameProperty(stream, pcc, nameRef));
                    break;

                case PropertyType.BoolProperty:
                    props.Add(new BoolProperty(stream, pcc.Game, nameRef));
                    break;

                case PropertyType.BioMask4Property:
                    props.Add(new BioMask4Property(stream, nameRef));
                    break;

                case PropertyType.ByteProperty:
                {
                    if (size != 1)
                    {
                        NameReference enumType = new NameReference();
                        if (pcc.Game == MEGame.ME3)
                        {
                            enumType.Name   = pcc.getNameEntry(stream.ReadValueS32());
                            enumType.Number = stream.ReadValueS32();
                        }
                        else
                        {
                            enumType.Name = UnrealObjectInfo.GetEnumType(pcc.Game, name, typeName);
                        }
                        props.Add(new EnumProperty(stream, pcc, enumType, nameRef));
                    }
                    else
                    {
                        if (pcc.Game == MEGame.ME3)
                        {
                            stream.Seek(8, SeekOrigin.Current);
                        }
                        props.Add(new ByteProperty(stream, nameRef));
                    }
                }
                break;

                case PropertyType.ArrayProperty:
                {
                    props.Add(ReadArrayProperty(stream, pcc, typeName, nameRef));
                }
                break;

                case PropertyType.StrProperty:
                {
                    props.Add(new StrProperty(stream, nameRef));
                }
                break;

                case PropertyType.StringRefProperty:
                    props.Add(new StringRefProperty(stream, nameRef));
                    break;

                case PropertyType.DelegateProperty:
                    props.Add(new DelegateProperty(stream, pcc, nameRef));
                    break;

                case PropertyType.Unknown:
                {
                    props.Add(new UnknownProperty(stream, size, pcc.getNameEntry(typeIdx), nameRef));
                }
                break;

                case PropertyType.None:
                    if (includeNoneProperty)
                    {
                        props.Add(new NoneProperty(stream, "None"));
                    }
                    break;

                default:
                    break;
                }
            }
            if (props.Count > 0)
            {
                //error reading props.
                if (props[props.Count - 1].PropType != PropertyType.None)
                {
                    stream.Seek(startPosition, SeekOrigin.Begin);
                    return(new PropertyCollection {
                        endOffset = (int)stream.Position
                    });
                }
                //remove None Property
                if (!includeNoneProperty)
                {
                    props.RemoveAt(props.Count - 1);
                }
            }
            props.endOffset = (int)stream.Position;
            return(props);
        }
        public static void WriteStringRefProperty(this Stream stream, IMEPackage pcc, NameReference propName, int value, int staticArrayIndex)
        {
            //Debug.WriteLine("Writing stringref property " + propName + ", value: " + value + " at 0x" + stream.Position.ToString("X6"));

            stream.WritePropHeader(pcc, propName, PropertyType.StringRefProperty, 4, staticArrayIndex);
            stream.WriteInt32(value);
        }
Esempio n. 27
0
 public static void WriteNameProperty(this Stream stream, IMEPackage pcc, string propName, NameReference value)
 {
     stream.WritePropHeader(pcc, propName, PropertyType.NameProperty, 8);
     stream.WriteValueS32(pcc.FindNameOrAdd(value.Name));
     stream.WriteValueS32(value.count);
 }
 public static void WriteDelegateProperty(this Stream stream, IMEPackage pcc, NameReference propName, ScriptDelegate value, int staticArrayIndex)
 {
     stream.WritePropHeader(pcc, propName, PropertyType.DelegateProperty, 12, staticArrayIndex);
     stream.WriteInt32(value.Object);
     stream.WriteNameReference(value.FunctionName, pcc);
 }
 public ScriptDelegate(int _object, NameReference functionName)
 {
     Object       = _object;
     FunctionName = functionName;
 }
 public static StructProperty ToGuidStructProp(this Guid guid, NameReference propName) => CommonStructs.Guid(guid, propName);
Esempio n. 31
0
 public static void WriteEnumProperty(this Stream stream, IMEPackage pcc, string propName, NameReference enumName, NameReference enumValue)
 {
     stream.WritePropHeader(pcc, propName, PropertyType.ByteProperty, 8);
     if (pcc.Game == MEGame.ME3)
     {
         stream.WriteValueS32(pcc.FindNameOrAdd(enumName.Name));
         stream.WriteValueS32(enumName.Number);
     }
     stream.WriteValueS32(pcc.FindNameOrAdd(enumValue.Name));
     stream.WriteValueS32(enumValue.Number);
 }
Esempio n. 32
0
 public static void WriteEnumProperty(this Stream stream, IMEPackage pcc, string propName, NameReference enumName, NameReference enumValue)
 {
     stream.WritePropHeader(pcc, propName, PropertyType.ByteProperty, 8);
     if (pcc.Game == MEGame.ME3)
     {
         stream.WriteValueS32(pcc.FindNameOrAdd(enumName.Name));
         stream.WriteValueS32(enumName.count);
     }
     stream.WriteValueS32(pcc.FindNameOrAdd(enumValue.Name));
     stream.WriteValueS32(enumValue.count);
 }
Esempio n. 33
0
 public bool Equals(NameReference other)
 {
     return(string.Equals(Name, other.Name) && Number == other.Number);
 }
Esempio n. 34
0
 public static void WriteDelegateProperty(this Stream stream, IMEPackage pcc, string propName, int unk, NameReference value)
 {
     stream.WritePropHeader(pcc, propName, PropertyType.DelegateProperty, 12);
     stream.WriteValueS32(unk);
     stream.WriteValueS32(pcc.FindNameOrAdd(value.Name));
     stream.WriteValueS32(value.count);
 }