diff --git a/PacifistAprilFoolsExplosion/PacifistAprilFoolsExplosion.cs b/PacifistAprilFoolsExplosion/PacifistAprilFoolsExplosion.cs index c8b9b31..dcb5793 100644 --- a/PacifistAprilFoolsExplosion/PacifistAprilFoolsExplosion.cs +++ b/PacifistAprilFoolsExplosion/PacifistAprilFoolsExplosion.cs @@ -1,14 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using BaseX; -using CodeX; +using BaseX; using FrooxEngine; -using FrooxEngine.LogiX; -using FrooxEngine.LogiX.Data; -using FrooxEngine.LogiX.ProgramFlow; -using FrooxEngine.UIX; using HarmonyLib; using NeosModLoader; @@ -20,10 +11,6 @@ public class PacifistAprilFoolsExplosion : NeosMod private const string explosionSlotName = "Explosion"; - [AutoRegisterConfigKey] - private static ModConfigurationKey DisableExplosion = new ModConfigurationKey("DisableExplosion", "Disable the Violent Explosion component locally when it's loaded.", () => true); - - /* [AutoRegisterConfigKey] private static ModConfigurationKey HideFlames = new ModConfigurationKey("HideFlames", "Hide the Violent Explosion's flame particles.", () => true); @@ -31,7 +18,7 @@ public class PacifistAprilFoolsExplosion : NeosMod private static ModConfigurationKey MuteBloating = new ModConfigurationKey("MuteBloating", "Mute the Violent Explosion's bloating sound effect.", () => false); [AutoRegisterConfigKey] - private static ModConfigurationKey MuteExplosion = new ModConfigurationKey("MuteExplosion", "Mute the Violent Explosion's explosion sound effect.", () => true);*/ + private static ModConfigurationKey MuteExplosion = new ModConfigurationKey("MuteExplosion", "Mute the Violent Explosion's explosion sound effect.", () => true); public override string Author => "Banane9"; public override string Link => "https://github.com/Banane9/NeosPacifistAprilFoolsExplosion"; @@ -46,63 +33,43 @@ public override void OnEngineInit() harmony.PatchAll(); } - [HarmonyPatch(typeof(ViolentAprilFoolsExplosion))] - private static class ViolentAprilFoolsExplosionPatch - { - [HarmonyPostfix] - [HarmonyPatch("OnAwake")] - private static void OnAwakePostfix(ViolentAprilFoolsExplosion __instance) - { - __instance.RunInUpdates(2, () => ValueUserOverride.OverrideForUser(__instance.EnabledField, __instance.World.LocalUser, !Config.GetValue(DisableExplosion))); - } - } - - /* [HarmonyPatch(typeof(StaticAudioClip))] private static class StaticAudioClipPatch { - [HarmonyPatch("OnAwake")] [HarmonyPostfix] + [HarmonyPatch("OnAwake")] private static void OnAwakePostfix(StaticAudioClip __instance) { - Msg("Muting potential explosion awake"); - - __instance.RunInUpdates(5, () => + __instance.RunInUpdates(1, () => { - Msg("Muting potential explosion pre"); - - if (__instance.Slot.ActiveSelf || __instance.Slot.Name != explosionSlotName) + if (__instance.Slot.PersistentSelf || __instance.Slot.Name != explosionSlotName) return; - Msg("Muting potential explosion"); - if (Config.GetValue(MuteBloating) && __instance.URL == NeosAssets.Common.Sound_Effect.Bloating) - ValueUserOverride.OverrideForUser(__instance.URL, __instance.World.LocalUser, null); - else if (Config.GetValue(MuteExplosion) && __instance.URL == NeosAssets.Common.Sound_Effect.Explosion) - ValueUserOverride.OverrideForUser(__instance.URL, __instance.World.LocalUser, null); + __instance.URL.OverrideForUser(__instance.World.LocalUser, null); + + if (Config.GetValue(MuteExplosion) && __instance.URL == NeosAssets.Common.Sound_Effect.Explosion) + __instance.URL.OverrideForUser(__instance.World.LocalUser, null); }); } } - [HarmonyPatch(typeof(ComponentBase))] + [HarmonyPatch(typeof(UnlitMaterial))] private static class UnlitMaterialPatch { [HarmonyPostfix] - [HarmonyPatch("OnChanges")] - private static void OnChangesPostfix(Component __instance) + [HarmonyPatch("OnAwake")] + private static void OnAwakePostfix(UnlitMaterial __instance) { - if (__instance.Slot.ActiveSelf || !(__instance is UnlitMaterial) || __instance.Slot.Name != explosionSlotName) - return; - - Msg("Hiding potential flames"); - - __instance.RunInUpdates(5, () => + __instance.RunInUpdates(1, () => { - var material = (UnlitMaterial)__instance; - if (Config.GetValue(HideFlames) && (material.Texture.Target.Asset as StaticTexture2D)?.URL == NeosAssets.Common.Particles.Effects.Flame_Atlas8x8) - ValueUserOverride.OverrideForUser(material.TintColor, __instance.World.LocalUser, color.Black); + if (__instance.Slot.PersistentSelf || !Config.GetValue(HideFlames) || __instance.Slot.Name != explosionSlotName) + return; + + if ((__instance.Texture.Target as StaticTexture2D)?.URL == NeosAssets.Common.Particles.Effects.Flame_Atlas8x8) + __instance.TintColor.OverrideForUser(__instance.World.LocalUser, color.Black); }); } - }*/ + } } } \ No newline at end of file