Beispiel #1
0
        public BNK(string fileName)
        {
            using (BinaryReader br = new BinaryReader(new FileStream(fileName, FileMode.Open), Encoding.ASCII))
            {
                int Magic = br.ReadInt32();
                Header = new BKHD(br);
                int BKHDDataCount = (Header.Length / 4) - 5;

                for (int i = 0; i < BKHDDataCount; i++)
                {
                    Header.Data.Add(br.ReadInt32());
                }

                Header.Offset = br.BaseStream.Position;
                ExtraData     = new Dictionary <uint, byte[]>();

                while (br.BaseStream.Position < br.BaseStream.Length)
                {
                    uint TypeString = br.ReadUInt32();

                    switch (TypeString)
                    {
                    case 1480870212:
                        ReadDidX(br);
                        ExtraData.Add(TypeString, new byte[0]);
                        break;

                    case 1129466184:
                        ReadHIRC(br);
                        ExtraData.Add(TypeString, new byte[0]);
                        break;

                    default:
                        int    sectionLength = br.ReadInt32();
                        byte[] Data          = br.ReadBytes(sectionLength);
                        ExtraData.Add(TypeString, Data);
                        break;
                    }
                }

                if (WemList != null && Objects != null)
                {
                    foreach (Wem wem in WemList)
                    {
                        if (Objects.SoundSFX.ContainsKey((uint)wem.ID))
                        {
                            wem.AssignedHirc.SoundSFX = Objects.SoundSFX[(uint)wem.ID];
                        }

                        if (Objects.MusicTrack.ContainsKey((int)wem.ID))
                        {
                            wem.AssignedHirc.MusicTrack = Objects.MusicTrack[(int)wem.ID];
                        }
                    }
                }
            }
        }
Beispiel #2
0
 public BNK()
 {
     Header    = new BKHD();
     ExtraData = new Dictionary <uint, byte[]>();
 }