/// <summary> /// Retrieves the <see cref="SoundEntriesEntry{TStringType}"/> id from the <see cref="entry"/> for /// the <see cref="soundType"/>. /// </summary> /// <param name="entry">The entry.</param> /// <param name="soundType">The sound type.</param> /// <returns></returns> public static int GetSoundEntryId([NotNull] this NPCSoundsEntry entry, NpcSounds soundType) { if (!HasSoundType(entry, soundType)) { throw new InvalidOperationException($"{nameof(NPCSoundsEntry)} does not contain SoundType: {soundType}. Check {nameof(HasSoundType)} first."); } switch (soundType) { case NpcSounds.HELLO: return(entry.GreetingsSoundId); case NpcSounds.GOODBYE: return(entry.GoodbyeSoundId); case NpcSounds.PISSED: return(entry.AnnoyedSoundId); case NpcSounds.ACK: return(entry.UnknownSoundId); default: throw new ArgumentOutOfRangeException(nameof(soundType), soundType, null); } }
/// <summary> /// Indicates if <see cref="NPCSoundsEntry"/> <see cref="entry"/> contains the requested <see cref="soundType"/>. /// </summary> /// <param name="entry">Entry to check.</param> /// <param name="soundType">Sound type.</param> /// <returns></returns> public static bool HasSoundType([NotNull] this NPCSoundsEntry entry, NpcSounds soundType) { if (entry == null) { throw new ArgumentNullException(nameof(entry)); } if (!Enum.IsDefined(typeof(NpcSounds), soundType)) { throw new InvalidEnumArgumentException(nameof(soundType), (int)soundType, typeof(NpcSounds)); } switch (soundType) { case NpcSounds.HELLO: return(entry.GreetingsSoundId > 0); case NpcSounds.GOODBYE: return(entry.GoodbyeSoundId > 0); case NpcSounds.PISSED: return(entry.AnnoyedSoundId > 0); case NpcSounds.ACK: return(false); //TODO: Unused default: throw new ArgumentOutOfRangeException(nameof(soundType), soundType, null); } }