Exemple #1
0
        public Lvb(DataBuffer data)
        {
            int length = data.ReadInt32(4);

            data.Position = 0x20;

            while (data.Position + 0x20 < length)
            {
                int sectionStart = data.Position;
                var section      = new LvlbSection(data);
                Sections.Add(section);
                data.Position += 8;

                switch (section.Id)
                {
                case "XFRM":
                    Xfrm = new Transform[section.ItemCount];

                    for (int i = 0; i < Xfrm.Length; i++)
                    {
                        Xfrm[i] = new Transform(data);
                    }
                    break;

                case "INFO":
                    Info = new InfoEntry[section.ItemCount];

                    for (int i = 0; i < Info.Length; i++)
                    {
                        Info[i] = new InfoEntry(data);
                    }
                    break;

                case "CLCT":
                    Clct = new ClctEntry[section.ItemCount];

                    for (int i = 0; i < Clct.Length; i++)
                    {
                        Clct[i] = new ClctEntry(data);
                    }
                    break;

                case "BTLC":
                    Btlc = new BtlcEntry[section.ItemCount];

                    for (int i = 0; i < Btlc.Length; i++)
                    {
                        Btlc[i] = new BtlcEntry(data);
                    }
                    break;

                case "STRG":
                    Strings = new byte[section.SectionLength - 0x20];
                    Strings = data.ReadBytes(section.SectionLength - 0x20);
                    break;
                }

                data.Position = sectionStart + section.SectionLength;
            }

            foreach (InfoEntry info in Info)
            {
                info.Name = Stuff.GetUTF8Z(Strings, info.StringOffset);
                info.Xfrm = Xfrm[info.XfrmId];
            }

            for (int i = 2; i < Sections.Count; i++)
            {
                if (Sections[i].Id == "STRG")
                {
                    continue;
                }
                int    start   = Sections[i].BaseId;
                int    end     = Sections[i].BaseId + Sections[i].ItemCount;
                string gmkType = Types.GimmickIds[Sections[i].Id];

                for (int j = start, k = 0; j < end; j++, k++)
                {
                    if (j < Info.Length)
                    {
                        Info[j].Id       = k;
                        Info[j].IdInFile = j;
                        Info[j].GmkType  = gmkType;
                    }
                }
            }
        }