public override void Import() { if (Definitions == null) { throw new Exception(); } foreach (TRModelDefinition definition in Definitions) { if (definition.HardcodedSound != null) { _soundUnpacker.Unpack(definition.HardcodedSound, Level, true); } } }
/** * SampleIndices has to remain in numerical order, but rather than dealing with it after inserting * each new sample, ImportAnimations will handle reorganising the list and remapping SoundDetails * as necessary. */ private void UnpackAnimSounds(PackedAnimation packedAnimation) { _soundUnpacker.Unpack(packedAnimation.Sound, Level, false); IReadOnlyDictionary <int, int> soundIndexMap = _soundUnpacker.SoundIndexMap; // Change the Params[1] value of each PlaySound AnimCommand to point to the // new index in SoundMap. foreach (PackedAnimationCommand cmd in packedAnimation.Commands.Values) { if (cmd.Command == TR2AnimCommand.PlaySound) { int oldSoundMapIndex = cmd.Params[1] & 0x3fff; int newSoundMapIndex = soundIndexMap[oldSoundMapIndex]; int param = cmd.Params[1] & ~oldSoundMapIndex; param |= newSoundMapIndex; cmd.Params[1] = (short)param; } } }