示例#1
0
        private void ReadCommands(SoundAudioBinaryFile file, BinaryReader binaryReader, SoundEntry soundEntry)
        {
            uint commandsOffsetInEntry;

            if (Version <= 2)
            {
                commandsOffsetInEntry = binaryReader.ReadUInt16At(Offset + 0x16);
            }
            else
            {
                commandsOffsetInEntry = binaryReader.ReadUInt16At(Offset + 0x06);
            }

            var currentCommandsOffset = Offset + commandsOffsetInEntry;

            while (currentCommandsOffset < file.TrackSectionOffset)
            {
                var command = new SequenceCommand(binaryReader, currentCommandsOffset);
                Commands.Add(command);

                currentCommandsOffset += (uint)(command.Size + command.BodySize);

                if (ShouldStopReadingCommands(soundEntry, command))
                {
                    break;
                }
            }
        }
示例#2
0
        private static bool ShouldStopReadingCommands(SoundEntry sndEntry, SequenceCommand command)
        {
            if (command.Type <= 0 || command.Type >= (byte)SequenceCommandType.Count)
            {
                return(true);
            }

            //named entries typically only have 1 command
            if (sndEntry.NameOffset > 0)
            {
                return(true);
            }

            return(false);
        }
示例#3
0
        private void AddMaterialUser(SequenceCommand command, SoundEntry entry)
        {
            var trackIndex = command.Body?.TrackIndex ?? null;

            if (trackIndex == null)
            {
                return;
            }

            if (trackIndex < 0 || trackIndex >= Tracks.Count)
            {
                return;
            }

            var track = Tracks[(int)trackIndex.Value];

            if (track.HasMaterial)
            {
                MaterialSection.AddUser(entry, track.MaterialIndex);
            }
        }