示例#1
0
        public override void Load(Stream fileStream)
        {
            // Header
            var reader = new BINAReader(fileStream);

            Header = reader.ReadHeader();

            string sig = reader.ReadSignature(4);

            if (sig != Signature)
            {
                throw new InvalidSignatureException(Signature, sig);
            }

            uint unknown1 = reader.ReadUInt32(); //Probably Flags according to Rad's Spec

            if (unknown1 != 537265920)
            {
                Console.WriteLine($"unknown1 does not equal 537265920! Actually equals {unknown1}!");
            }

            uint bankNameOffset    = reader.ReadUInt32(); //Offset to the Scene Bank name
            uint cueNameOffset     = reader.ReadUInt32(); //Offset of the first entry in the Scene Bank
            uint cueIndiciesOffset = reader.ReadUInt32(); //Offset to the number list for non stream indexs
            uint streamOffset      = reader.ReadUInt32(); //Offset to the table for xma names

            Name = reader.ReadChars(64);                  //Scene Bank's name
            uint cueCount       = reader.ReadUInt32();    //Total Number of Cues in this Scene Bank
            uint csbCueCount    = reader.ReadUInt32();    //Amount of Cues in this Scene Bank which pull their data from a corrosponding CSB file
            uint streamCueCount = reader.ReadUInt32();    //Amount of Cues in this Scene Bank which use XMA files

            int streams = 0;

            for (uint i = 0; i < cueCount; i++)
            {
                Cue cue = new Cue()
                {
                    Name = reader.ReadChars(32)
                };
                uint cueType  = reader.ReadUInt32();
                uint cueIndex = reader.ReadUInt32();
                cue.Category = reader.ReadUInt32();
                cue.Unknown1 = reader.ReadSingle();
                cue.Unknown2 = reader.ReadSingle();

                if (cueType == 1)
                {
                    long pos = reader.BaseStream.Position;          //Save position
                    reader.JumpTo(streamOffset, false);
                    reader.JumpAhead(4 * streams);                  //Jump ahead to the right offset for our Cue's XMA
                    reader.JumpTo(reader.ReadUInt32(), false);
                    cue.Stream = reader.ReadNullTerminatedString(); //Read the XMA's name for this Cue
                    reader.JumpTo(pos, true);                       //Jump back to where we were
                    streams++;
                }
                Cues.Add(cue); //Save Cue to list
            }
        }