示例#1
0
 /// <summary>
 /// A method that can play custom/game sounds, and/or shake the bomb. This is a multi-purpose basic enhancement of production value. Null means actions will not be performed.
 /// </summary>
 /// <param name="selectable">The selectable, which is used to call other methods, and use its transform.</param>
 /// <param name="audio">The current instance of KMAudio which is needed to play sound.</param>
 /// <param name="transform">The location of the source, if the selectable isn't being used.</param>
 /// <param name="intensityModifier">Adds bomb movement and controller vibration on interaction, amount is based on the modifier.</param>
 /// <param name="customSound">The custom sound to play, which must be assigned in TestHarness in the editor or mod.bundle in-game for the sound to be heard.</param>
 /// <param name="gameSound">The built-in sound effect to play.</param>
 /// <param name="ignoredCondition">A condition that will cancel this method. The null checks are still performed.</param>
 internal static void Button(this KMSelectable selectable, KMAudio audio = null, Transform transform = null, float?intensityModifier = null, string customSound = null, KMSoundOverride.SoundEffect?gameSound = null, bool ignoredCondition = false)
 {
     if (selectable == null)
     {
         throw new NullReferenceException("Selectable should not be null when calling this method.");
     }
     if (audio == null && (customSound != null || gameSound != null))
     {
         throw new NullReferenceException("Audio should not be null if customSound and gameSound is specified. An instance of KMAudio is required for the sounds to be played.");
     }
     if (ignoredCondition)
     {
         return;
     }
     if (transform == null && selectable != null)
     {
         transform = selectable.transform;
     }
     if (intensityModifier != null)
     {
         selectable.AddInteractionPunch((float)intensityModifier);
     }
     audio.Play(transform, customSound, gameSound);
 }