public override void Read(EndianBinaryReader reader, ISection section = null)
        {
            int  count                = reader.ReadInt32();
            long stagesOffset         = reader.ReadOffset();
            long stageEffectsOffset   = reader.ReadOffset();
            long auth3dIdCountsOffset = reader.ReadOffset();
            long auth3dIdsOffset      = reader.ReadOffset();

            if (reader.ReadBoolean())
            {
                Format = ( BinaryFormat )reader.ReadByte();
            }
            else
            {
                long entrySize = (stageEffectsOffset - stagesOffset) / count;
                Format = entrySize == 104 ? BinaryFormat.DT :
                         entrySize == 108 ? BinaryFormat.F :
                         entrySize >= 112 ? BinaryFormat.FT :
                         throw new InvalidDataException();
            }

            reader.ReadAtOffset(stagesOffset, () =>
            {
                Stages.Capacity = count;
                for (int i = 0; i < count; i++)
                {
                    var stageEntry = new StageEntry();
                    {
                        stageEntry.Read(reader, Format);
                    }
                    Stages.Add(stageEntry);
                }
            });

            reader.ReadAtOffset(stageEffectsOffset, () =>
            {
                foreach (var stageEntry in Stages)
                {
                    stageEntry.ReadStageEffects(reader);
                }
            });

            reader.ReadAtOffset(auth3dIdCountsOffset, () =>
            {
                var auth3dIdCounts = reader.ReadInt32s(count);
                reader.ReadAtOffset(auth3dIdsOffset, () =>
                {
                    for (int i = 0; i < count; i++)
                    {
                        Stages[i].ReadAuth3dIds(reader, auth3dIdCounts[i]);
                    }
                });
            });
        }
Exemple #2
0
        public override void Read(EndianBinaryReader reader, ISection section = null)
        {
            int  count          = reader.ReadInt32();
            uint section1Offset = reader.ReadUInt32();
            uint section2Offset = reader.ReadUInt32();
            uint section3Offset = reader.ReadUInt32();
            uint section4Offset = reader.ReadUInt32();

            Format = ((section2Offset - section1Offset) / count) != 108 ? BinaryFormat.FT : BinaryFormat.F;

            reader.ReadAtOffset(section1Offset, () =>
            {
                Stages.Capacity = count;
                for (int i = 0; i < count; i++)
                {
                    var stageEntry = new StageEntry();
                    stageEntry.ReadFirst(reader, Format);
                    Stages.Add(stageEntry);
                }
            });

            reader.ReadAtOffset(section2Offset, () =>
            {
                foreach (var stageEntry in Stages)
                {
                    stageEntry.ReadSecond(reader);
                }
            });

            reader.ReadAtOffset(section3Offset, () =>
            {
                foreach (var stageEntry in Stages)
                {
                    stageEntry.ReadThird(reader);
                }
            });

            reader.ReadAtOffset(section4Offset, () =>
            {
                for (int i = 0; i < Stages.Count; i++)
                {
                    int index = reader.ReadInt32();
                    Debug.Assert(i == index);
                    Stages[index].ReadFourth(reader);
                }
            });
        }