using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using MonoMod.RuntimeDetour; using UnityEngine; namespace AllExplosionsAreFartSounds { public class FartModule : ETGModule { public override void Start() { FartModule.ZipFilePath = this.Metadata.Archive; FartModule.FilePathAudio = this.Metadata.Directory; AudioResourceLoader.InitAudio(); new Hook(typeof(AkSoundEngine).GetMethods().Single((MethodInfo m) => m.Name == "PostEvent" && m.GetParameters().Length == 2 && m.GetParameters()[0].ParameterType == typeof(string)), typeof(FartModule).GetMethod("PostEventHook", BindingFlags.Static | BindingFlags.Public)); FartModule.Log(FartModule.MOD_NAME + " v" + FartModule.VERSION + " started successfully.", FartModule.TEXT_COLOR); } public static uint PostEventHook(Func orig, string in_pszEventName, GameObject in_gameObjectID) { bool flag = in_pszEventName != null; if (flag) { bool flag2 = FartModule.SoundKeys.ContainsKey(in_pszEventName); if (flag2) { string text = "Play_Fart1"; FartModule.SoundKeys.TryGetValue(in_pszEventName, out text); in_pszEventName = text; } } return orig(in_pszEventName, in_gameObjectID); } public static void Log(string text, string color = "#FFFFFF") { ETGModConsole.Log(string.Concat(new string[] { "", text, "" }), false); } public override void Exit() { } public override void Init() { } public static readonly string MOD_NAME = "All Explosions Are Fart Sounds"; public static readonly string VERSION = "1.0"; public static readonly string TEXT_COLOR = "#ce8a13"; public static string ZipFilePath; public static string FilePathAudio; public static Dictionary SoundKeys = new Dictionary { { "Play_WPN_grenade_blast_01", "Play_Fart1" }, { "Play_OBJ_nuke_blast_01", "Play_ultraFart" }, { "Play_BOSS_queenship_explode_01", "Play_ultraFart" }, { "Play_obj_cell_explode_01", "Play_anotherFart" }, { "Play_ENM_kali_explode_01", "Play_quickFart" }, { "Play_BOSS_spacebaby_explode_01", "Play_omegaFart_01" }, { "Play_BOSS_dragun_explode_01", "Play_ultraFart" }, { "Play_WPN_smallrocket_impact_01", "Play_quickFart" }, { "Play_OBJ_silenceblank_use_01", "Play_omegaFart_01" }, { "Play_OBJ_lightning_flash_01", "Play_anotherFart" }, { "Play_ENM_blobulord_splash_01", "Play_ultraFart" } }; } }