Exemple #1
0
        private void Parse()
        {
            ecfFile.I_12 = BitConverter.ToUInt16(rawBytes, 12);



            if (totalMainEntries > 0)
            {
                ecfFile.Entries = new List <ECF_Entry>();

                for (int i = 0; i < totalMainEntries; i++)
                {
                    ecfFile.Entries.Add(new ECF_Entry());

                    ecfFile.Entries[i].I_52 = (PlayMode)BitConverter.ToInt16(rawBytes, mainEntryOffset + 52);
                    ecfFile.Entries[i].F_00 = BitConverter.ToSingle(rawBytes, mainEntryOffset + 0);
                    ecfFile.Entries[i].F_04 = BitConverter.ToSingle(rawBytes, mainEntryOffset + 4);
                    ecfFile.Entries[i].F_08 = BitConverter.ToSingle(rawBytes, mainEntryOffset + 8);
                    ecfFile.Entries[i].F_12 = BitConverter.ToSingle(rawBytes, mainEntryOffset + 12);
                    ecfFile.Entries[i].F_16 = BitConverter.ToSingle(rawBytes, mainEntryOffset + 16);
                    ecfFile.Entries[i].F_20 = BitConverter.ToSingle(rawBytes, mainEntryOffset + 20);
                    ecfFile.Entries[i].F_24 = BitConverter.ToSingle(rawBytes, mainEntryOffset + 24);
                    ecfFile.Entries[i].F_28 = BitConverter.ToSingle(rawBytes, mainEntryOffset + 28);
                    ecfFile.Entries[i].F_32 = BitConverter.ToSingle(rawBytes, mainEntryOffset + 32);
                    ecfFile.Entries[i].F_36 = BitConverter.ToSingle(rawBytes, mainEntryOffset + 36);
                    ecfFile.Entries[i].F_40 = BitConverter.ToSingle(rawBytes, mainEntryOffset + 40);
                    ecfFile.Entries[i].F_44 = BitConverter.ToSingle(rawBytes, mainEntryOffset + 44);
                    ecfFile.Entries[i].F_48 = BitConverter.ToSingle(rawBytes, mainEntryOffset + 48);
                    ecfFile.Entries[i].I_54 = BitConverter.ToUInt16(rawBytes, mainEntryOffset + 54);
                    ecfFile.Entries[i].I_56 = BitConverter.ToUInt16(rawBytes, mainEntryOffset + 56);
                    ecfFile.Entries[i].I_58 = BitConverter.ToUInt16(rawBytes, mainEntryOffset + 58);
                    ecfFile.Entries[i].I_60 = BitConverter.ToUInt16(rawBytes, mainEntryOffset + 60);
                    ecfFile.Entries[i].I_62 = BitConverter.ToUInt16(rawBytes, mainEntryOffset + 62);
                    ecfFile.Entries[i].I_64 = new UInt16[14];

                    for (int a = 0; a < 28; a += 2)
                    {
                        ecfFile.Entries[i].I_64[a / 2] = BitConverter.ToUInt16(rawBytes, mainEntryOffset + 64 + a);
                    }

                    ecfFile.Entries[i].I_96 = BitConverter.ToUInt16(rawBytes, mainEntryOffset + 96);

                    //Type0 data
                    int Type0_Offset = BitConverter.ToInt32(rawBytes, mainEntryOffset + 100) + 96 + mainEntryOffset;
                    int Type0_Count  = BitConverter.ToInt16(rawBytes, mainEntryOffset + 98);

                    if (Type0_Count > 0)
                    {
                        ecfFile.Entries[i].Type0 = new List <Type0>();

                        for (int a = 0; a < Type0_Count; a++)
                        {
                            int startOffset = BitConverter.ToInt32(rawBytes, Type0_Offset + 8) + Type0_Offset;
                            int floatOffset = BitConverter.ToInt32(rawBytes, Type0_Offset + 12) + Type0_Offset;

                            ecfFile.Entries[i].Type0.Add(new Type0()
                            {
                                I_00      = (ECF.Type0.Parameter)rawBytes[Type0_Offset + 0],
                                I_01_a    = Type0.GetComponent((ECF.Type0.Parameter)rawBytes[Type0_Offset + 0], Int4Converter.ToInt4(rawBytes[Type0_Offset + 1])[0]),
                                I_01_b    = BitConverter_Ex.ToBoolean(Int4Converter.ToInt4(rawBytes[Type0_Offset + 1])[1]),
                                I_02      = (rawBytes[Type0_Offset + 2] == 0)? false : true,
                                I_03      = rawBytes[Type0_Offset + 3],
                                I_04      = BitConverter.ToUInt16(rawBytes, Type0_Offset + 4),
                                Keyframes = ParseKeyframes(BitConverter.ToInt16(rawBytes, Type0_Offset + 6), startOffset, floatOffset)
                            });


                            Type0_Offset += 16;
                        }
                    }

                    //Unk_Str
                    int Str_Offset = BitConverter.ToInt32(rawBytes, mainEntryOffset + 92) + mainEntryOffset;

                    if (Str_Offset != 0)
                    {
                        ecfFile.Entries[i].Unk_Str = Utils.GetString(bytes, Str_Offset);
                    }
                    else
                    {
                        ecfFile.Entries[i].Unk_Str = String.Empty;
                    }

                    mainEntryOffset += 104;
                }
            }
        }
Exemple #2
0
        private ParticleEffect ParseEffect(int mainEntryOffset)
        {
            ParticleEffect newEffect = ParticleEffect.GetNew((parserMode == ParserMode.Tool) ? true : false);

            //Flags and Offsets for extra data
            int FLAG_36      = rawBytes[mainEntryOffset + 36];
            int FLAG_37      = rawBytes[mainEntryOffset + 37];
            int Type0_Count  = BitConverter.ToInt16(rawBytes, mainEntryOffset + 138);
            int Type0_Offset = BitConverter.ToInt32(rawBytes, mainEntryOffset + 140) + 136 + mainEntryOffset;
            int Type1_Count  = BitConverter.ToInt16(rawBytes, mainEntryOffset + 144);
            int Type1_Offset = BitConverter.ToInt32(rawBytes, mainEntryOffset + 148) + mainEntryOffset;

            //Main Entry values
            newEffect.Component_Type = ParticleEffect.GetComponentType(new int[2] {
                FLAG_36, FLAG_37
            });
            newEffect.Name = Utils.GetString(rawBytes.ToList(), mainEntryOffset, 32);

            BitArray compositeBits_I_32 = new BitArray(new byte[1] {
                rawBytes[mainEntryOffset + 32]
            });
            BitArray compositeBits_I_33 = new BitArray(new byte[1] {
                rawBytes[mainEntryOffset + 33]
            });
            BitArray compositeBits_I_34 = new BitArray(new byte[1] {
                rawBytes[mainEntryOffset + 34]
            });


            newEffect.I_32_0 = compositeBits_I_32[0];
            newEffect.I_32_1 = compositeBits_I_32[1];
            newEffect.I_32_2 = compositeBits_I_32[2];
            newEffect.I_32_3 = compositeBits_I_32[3];
            newEffect.I_32_4 = compositeBits_I_32[4];
            newEffect.I_32_5 = compositeBits_I_32[5];
            newEffect.I_32_6 = compositeBits_I_32[6];
            newEffect.I_32_7 = compositeBits_I_32[7];
            newEffect.I_33_0 = compositeBits_I_33[0];
            newEffect.I_33_1 = compositeBits_I_33[1];
            newEffect.I_33_2 = compositeBits_I_33[2];
            newEffect.I_33_3 = compositeBits_I_33[3];
            newEffect.I_33_4 = compositeBits_I_33[4];
            newEffect.I_33_5 = compositeBits_I_33[5];
            newEffect.I_33_6 = compositeBits_I_33[6];
            newEffect.I_33_7 = compositeBits_I_33[7];
            newEffect.I_34_0 = compositeBits_I_34[0];
            newEffect.I_34_1 = compositeBits_I_34[1];
            newEffect.I_34_2 = compositeBits_I_34[2];
            newEffect.I_34_3 = compositeBits_I_34[3];
            newEffect.I_34_4 = compositeBits_I_34[4];
            newEffect.I_34_5 = compositeBits_I_34[5];
            newEffect.I_34_6 = compositeBits_I_34[6];
            newEffect.I_34_7 = compositeBits_I_34[7];
            newEffect.I_35   = (ParticleEffect.AutoOrientationType)rawBytes[mainEntryOffset + 35];
            newEffect.I_38   = BitConverter.ToInt16(rawBytes, mainEntryOffset + 38);
            newEffect.I_40   = BitConverter.ToInt16(rawBytes, mainEntryOffset + 40);
            newEffect.I_42   = BitConverter.ToUInt16(rawBytes, mainEntryOffset + 42);
            newEffect.I_44   = rawBytes[mainEntryOffset + 44];
            newEffect.I_45   = rawBytes[mainEntryOffset + 45];
            newEffect.I_46   = rawBytes[mainEntryOffset + 46];
            newEffect.I_47   = rawBytes[mainEntryOffset + 47];
            newEffect.I_48   = BitConverter.ToUInt16(rawBytes, mainEntryOffset + 48);
            newEffect.I_50   = BitConverter.ToUInt16(rawBytes, mainEntryOffset + 50);
            newEffect.I_52   = BitConverter.ToUInt16(rawBytes, mainEntryOffset + 52);
            newEffect.I_54   = BitConverter.ToUInt16(rawBytes, mainEntryOffset + 54);
            newEffect.I_56   = BitConverter.ToUInt16(rawBytes, mainEntryOffset + 56);
            newEffect.I_58   = BitConverter.ToUInt16(rawBytes, mainEntryOffset + 58);
            newEffect.I_60   = BitConverter.ToUInt16(rawBytes, mainEntryOffset + 60);
            newEffect.I_62   = BitConverter.ToUInt16(rawBytes, mainEntryOffset + 62);

            newEffect.F_64  = BitConverter.ToSingle(rawBytes, mainEntryOffset + 64);
            newEffect.F_68  = BitConverter.ToSingle(rawBytes, mainEntryOffset + 68);
            newEffect.F_72  = BitConverter.ToSingle(rawBytes, mainEntryOffset + 72);
            newEffect.F_76  = BitConverter.ToSingle(rawBytes, mainEntryOffset + 76);
            newEffect.F_80  = BitConverter.ToSingle(rawBytes, mainEntryOffset + 80);
            newEffect.F_84  = BitConverter.ToSingle(rawBytes, mainEntryOffset + 84);
            newEffect.F_88  = BitConverter.ToSingle(rawBytes, mainEntryOffset + 88);
            newEffect.F_92  = BitConverter.ToSingle(rawBytes, mainEntryOffset + 92);
            newEffect.F_96  = BitConverter.ToSingle(rawBytes, mainEntryOffset + 96);
            newEffect.F_100 = BitConverter.ToSingle(rawBytes, mainEntryOffset + 100);
            newEffect.F_104 = BitConverter.ToSingle(rawBytes, mainEntryOffset + 104);
            newEffect.F_108 = BitConverter.ToSingle(rawBytes, mainEntryOffset + 108);
            newEffect.F_112 = BitConverter.ToSingle(rawBytes, mainEntryOffset + 112);
            newEffect.F_116 = BitConverter.ToSingle(rawBytes, mainEntryOffset + 116);
            newEffect.F_120 = BitConverter.ToSingle(rawBytes, mainEntryOffset + 120);
            newEffect.F_124 = BitConverter.ToSingle(rawBytes, mainEntryOffset + 124);
            newEffect.F_128 = BitConverter.ToSingle(rawBytes, mainEntryOffset + 128);
            newEffect.F_132 = BitConverter.ToSingle(rawBytes, mainEntryOffset + 132);

            newEffect.I_136 = BitConverter.ToUInt16(rawBytes, mainEntryOffset + 136);

            if (Type0_Count > 0 || Type1_Count > 0)
            {
                //Type0
                if (Type0_Count > 0)
                {
                    newEffect.Type_0 = new ObservableCollection <Type0>();

                    for (int a = 0; a < Type0_Count; a++)
                    {
                        int idx = newEffect.Type_0.Count();

                        newEffect.Type_0.Add(new Type0()
                        {
                            I_01_b    = BitConverter_Ex.ToBoolean(Int4Converter.ToInt4(rawBytes[Type0_Offset + 1])[1]),
                            I_02      = BitConverter_Ex.ToBoolean(rawBytes, Type0_Offset + 2),
                            I_03      = rawBytes[Type0_Offset + 3],
                            F_04      = BitConverter.ToSingle(rawBytes, Type0_Offset + 4),
                            I_08      = BitConverter.ToInt16(rawBytes, Type0_Offset + 8),
                            Keyframes = ParseKeyframes <Type0_Keyframe>(BitConverter.ToInt16(rawBytes, Type0_Offset + 10), BitConverter.ToInt32(rawBytes, Type0_Offset + 12) + Type0_Offset)
                        });

                        newEffect.Type_0[idx].SetParameters(rawBytes[Type0_Offset + 0], Int4Converter.ToInt4(rawBytes[Type0_Offset + 1])[0], newEffect.IsScale2Enabled());

                        Type0_Offset += 16;
                    }
                }

                //Type1
                if (Type1_Count > 0)
                {
                    newEffect.Type_1 = new ObservableCollection <Type1_Header>();

                    for (int a = 0; a < Type1_Count; a++)
                    {
                        int entryCount  = BitConverter.ToInt16(rawBytes, Type1_Offset + 2);
                        int entryOffset = BitConverter.ToInt32(rawBytes, Type1_Offset + 4) + Type1_Offset;

                        newEffect.Type_1.Add(new Type1_Header());
                        newEffect.Type_1[a].I_00    = rawBytes[Type1_Offset];
                        newEffect.Type_1[a].I_01    = rawBytes[Type1_Offset + 1];
                        newEffect.Type_1[a].Entries = new ObservableCollection <Type0>();

                        for (int d = 0; d < entryCount; d++)
                        {
                            int subEntryCount = BitConverter.ToInt16(rawBytes, entryOffset + 10);

                            newEffect.Type_1[a].Entries.Add(new Type0());

                            newEffect.Type_1[a].Entries[d].SetParameters(rawBytes[entryOffset + 0], Int4Converter.ToInt4(rawBytes[entryOffset + 1])[0], newEffect.IsScale2Enabled());
                            newEffect.Type_1[a].Entries[d].I_01_b = BitConverter_Ex.ToBoolean(Int4Converter.ToInt4(rawBytes[entryOffset + 1])[1]);
                            newEffect.Type_1[a].Entries[d].I_02   = BitConverter_Ex.ToBoolean(rawBytes, entryOffset + 2);
                            newEffect.Type_1[a].Entries[d].I_03   = rawBytes[entryOffset + 3];
                            newEffect.Type_1[a].Entries[d].F_04   = BitConverter.ToSingle(rawBytes, entryOffset + 4);

                            newEffect.Type_1[a].Entries[d].I_08      = BitConverter.ToInt16(rawBytes, entryOffset + 8);
                            newEffect.Type_1[a].Entries[d].Keyframes = ParseKeyframes <Type0_Keyframe>(BitConverter.ToInt16(rawBytes, entryOffset + 10), BitConverter.ToInt32(rawBytes, entryOffset + 12) + entryOffset);

                            entryOffset += 16;
                        }

                        Type1_Offset += 8;
                    }
                }
            }
            //Extra Parts
            //If no extra parts exist, this code wont execute
            if (FLAG_37 != 0)
            {
                switch (FLAG_37)
                {
                case 1:
                    switch (FLAG_36)
                    {
                    case 0:
                        newEffect.FloatPart_00_01 = ParseFloatPart8 <FloatPart_0_1>(mainEntryOffset + 160);
                        break;

                    case 1:
                        newEffect.FloatPart_01_01 = ParseFloatPart4 <FloatPart_1_1>(mainEntryOffset + 160);
                        break;

                    case 2:
                        newEffect.FloatPart_02_01 = ParseFloatPart_2_1(mainEntryOffset + 160);
                        break;

                    case 3:
                        newEffect.FloatPart_03_01 = ParseFloatPart_3_1(mainEntryOffset + 160);
                        break;
                    }
                    break;

                case 2:
                    switch (FLAG_36)
                    {
                    case 0:
                        newEffect.Type_Texture    = ParseTexturePart(mainEntryOffset + 160, mainEntryOffset, textureEntryOffset);
                        newEffect.FloatPart_00_02 = ParseFloatPart4 <FloatPart_0_2>(mainEntryOffset + 160 + 112);
                        break;

                    case 1:
                        newEffect.Type_Texture = ParseTexturePart(mainEntryOffset + 160, mainEntryOffset, textureEntryOffset);
                        break;

                    case 2:
                        newEffect.Type_Texture    = ParseTexturePart(mainEntryOffset + 160, mainEntryOffset, textureEntryOffset);
                        newEffect.FloatPart_02_02 = ParseFloatPart8 <FloatPart_2_2>(mainEntryOffset + 160 + 112);
                        break;

                    case 3:
                        newEffect.Type_Texture = ParseTexturePart(mainEntryOffset + 160, mainEntryOffset, textureEntryOffset);
                        newEffect.Type_Struct3 = ParseStruct3(mainEntryOffset + 160 + 112, mainEntryOffset);
                        break;

                    case 4:
                        newEffect.Type_Texture = ParseTexturePart(mainEntryOffset + 160, mainEntryOffset, textureEntryOffset);
                        newEffect.Type_Model   = ParseModelStruct(mainEntryOffset + 160 + 112, mainEntryOffset);
                        break;

                    case 5:
                        newEffect.Type_Texture = ParseTexturePart(mainEntryOffset + 160, mainEntryOffset, textureEntryOffset);
                        newEffect.Type_Struct5 = ParseStruct5(mainEntryOffset + 160 + 112, mainEntryOffset);
                        break;
                    }
                    break;
                }
            }


            return(newEffect);
        }