Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Less Loud Sconces v1.0.0
LessLoudSconces.dll
Decompiled 15 hours agousing System.Reflection; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; [assembly: AssemblyVersion("1.0.0.0")] namespace LessLoudSconces; [BepInPlugin("doom_hamster.lessloudsconces", "Less Loud Sconces", "1.0.0")] public class LessLoudSconcesPlugin : BaseUnityPlugin { public static ConfigEntry<float> TorchesVolumeMultiplier; public static ConfigEntry<float> TorchesDistanceMultiplier; public static ConfigEntry<float> BonfireVolumeMultiplier; public static ConfigEntry<float> RefuelVolumeMultiplier; public static ConfigEntry<float> RepairForgeVolumeMultiplier; public static ConfigEntry<float> RepairWorkbenchVolumeMultiplier; public static ConfigEntry<float> BraziersVolumeMultiplier; public static ConfigEntry<float> BraziersDistanceMultiplier; public static ConfigEntry<float> CampfireVolumeMultiplier; public static ConfigEntry<float> CauldronVolumeMultiplier; public static ConfigEntry<float> PortalVolumeMultiplier; public static ConfigEntry<float> MeadKetillVolumeMultiplier; public static ConfigEntry<float> CookingVolumeMultiplier; public static ConfigEntry<float> FermenterVolumeMultiplier; public static ConfigEntry<float> FermenterUseVolumeMultiplier; public static ConfigEntry<float> ProcessedSpawnVolumeMultiplier; private void Awake() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Expected O, but got Unknown //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Expected O, but got Unknown //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Expected O, but got Unknown //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Expected O, but got Unknown //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Expected O, but got Unknown //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Expected O, but got Unknown //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Expected O, but got Unknown //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Expected O, but got Unknown //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Expected O, but got Unknown //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Expected O, but got Unknown //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Expected O, but got Unknown //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Expected O, but got Unknown //IL_03e5: Unknown result type (might be due to invalid IL or missing references) TorchesVolumeMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("1. Torches", "TorchesVolumeMultiplier", 1.2f, new ConfigDescription("Multiplier for the fireloop audio volume.\nAffected pieces: Sconce, Standing Iron Torch, Standing Blue-burning Iron Torch, Standing Green-burning Iron Torch, Jack-O-Turnip.\n1.0 is the same volume setting as on Standing Wood Torch, 0.9 is a 10% reduction, 0.0 is completely silent.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), new object[0])); TorchesDistanceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("1. Torches", "TorchesDistanceMultiplier", 1.15f, new ConfigDescription("Multiplier for the fireloop audio distance.\nAffected pieces: same as TorchesVolumeMultiplier.\n1.0 is the same min & max distances as on Standing Wood Torch.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), new object[0])); BraziersVolumeMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("2. Braziers", "BraziersVolumeMultiplier", 1.2f, new ConfigDescription("Multiplier for the fireloop audio volume.\nAffected pieces: Iron Fire Pit, Standing Brazier, Blue Standing Brazier, Hanging Brazier.\n1.0 is the same volume setting as on Standing Wood Torch, 0.9 is a 10% reduction, 0.0 is completely silent.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), new object[0])); BraziersDistanceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("2. Braziers", "BraziersDistanceMultiplier", 1.3f, new ConfigDescription("Multiplier for the fireloop audio distance.\nAffected pieces: same as BraziersVolumeMultiplier.\n1.0 is the same min & max distances as on Standing Wood Torch.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), new object[0])); BonfireVolumeMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("3. Other", "BonfireVolumeMultiplier", 0.75f, new ConfigDescription("Multiplier for the fireloop volume of the Bonfire.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), new object[0])); CampfireVolumeMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("3. Other", "CampfireVolumeMultiplier", 0.8f, new ConfigDescription("Multiplier for the fireloop volume of the Campfire.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), new object[0])); PortalVolumeMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("3. Other", "PortalVolumeMultiplier", 0.8f, new ConfigDescription("Multiplier for the loop volume on a connected Portal.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), new object[0])); CauldronVolumeMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("4. Stations", "CauldronVolumeMultiplier", 0.65f, new ConfigDescription("Multiplier for the ambient loop volume of the Cauldron.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), new object[0])); MeadKetillVolumeMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("4. Stations", "MeadKetillVolumeMultiplier", 0.65f, new ConfigDescription("Multiplier for the ambient loop volume of the Mead Ketill.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), new object[0])); FermenterVolumeMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("4. Stations", "FermenterVolumeMultiplier", 0.85f, new ConfigDescription("Multiplier for the ambient loop volume of the working Fermenter.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), new object[0])); RefuelVolumeMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("5. Interactions", "RefuelVolumeMultiplier", 0.6f, new ConfigDescription("Multiplier for the refuel action on torches, braziers and fires.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), new object[0])); RepairForgeVolumeMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("5. Interactions", "RepairForgeVolumeMultiplier", 0.8f, new ConfigDescription("Multiplier for the repair action inside Forge.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), new object[0])); RepairWorkbenchVolumeMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("5. Interactions", "RepairWorkbenchVolumeMultiplier", 0.88f, new ConfigDescription("Multiplier for the repair action inside Workbench.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), new object[0])); CookingVolumeMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("5. Interactions", "CookingVolumeMultiplier", 0.72f, new ConfigDescription("Multiplier for the crafting loop and crafting end inside Cauldron, Mead Ketill.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), new object[0])); FermenterUseVolumeMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("5. Interactions", "FermenterUseVolumeMultiplier", 0.7f, new ConfigDescription("Multiplier for the loading and unloading the Fermenter.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), new object[0])); ProcessedSpawnVolumeMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("5. Interactions", "ProcessedSpawnVolumeMultiplier", 0.7f, new ConfigDescription("Multiplier for the sound volume when the items are spawned from Fermenter, and maybe from a few other stations. Target prefab name: sfx_lootspawn; Fermenter plays the sub-clip: Magic_Poof3", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), new object[0])); new Harmony("doom_hamster.lessloudsconces").PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"LessLoudSconces is loaded"); } } [HarmonyPatch(typeof(ZNetScene), "Awake")] public static class SconceAudioPatch { public class SconceAudioProcessedTag : MonoBehaviour { } private static readonly string[] PrefabsToQuietTorches = new string[5] { "piece_walltorch", "piece_groundtorch", "piece_groundtorch_blue", "piece_groundtorch_green", "piece_jackoturnip" }; private static readonly string[] PrefabsToQuietBraziers = new string[4] { "fire_pit_iron", "piece_brazierfloor01", "piece_brazierfloor02", "piece_brazierceiling01" }; public static void Postfix(ZNetScene __instance) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) GameObject prefab = __instance.GetPrefab("piece_groundtorch_wood"); ZSFX[] array; if ((Object)(object)prefab != (Object)null) { ZSFX componentInChildren = prefab.GetComponentInChildren<ZSFX>(true); if ((Object)(object)componentInChildren != (Object)null) { float value = LessLoudSconcesPlugin.TorchesVolumeMultiplier.Value; float value2 = LessLoudSconcesPlugin.TorchesDistanceMultiplier.Value; float minVol = componentInChildren.m_minVol * value; float maxVol = componentInChildren.m_maxVol * value; AudioSource component = ((Component)componentInChildren).GetComponent<AudioSource>(); AudioRolloffMode rolloffMode = (AudioRolloffMode)(((Object)(object)component != (Object)null) ? ((int)component.rolloffMode) : 0); float minDistance = (((Object)(object)component != (Object)null) ? (component.minDistance * value2) : 0f); float maxDistance = (((Object)(object)component != (Object)null) ? (component.maxDistance * value2) : 0f); string[] prefabsToQuietTorches = PrefabsToQuietTorches; foreach (string text in prefabsToQuietTorches) { GameObject prefab2 = __instance.GetPrefab(text); if (!((Object)(object)prefab2 != (Object)null)) { continue; } ZSFX[] componentsInChildren = prefab2.GetComponentsInChildren<ZSFX>(true); if (componentsInChildren == null) { continue; } array = componentsInChildren; foreach (ZSFX obj in array) { obj.m_minVol = minVol; obj.m_maxVol = maxVol; AudioSource component2 = ((Component)obj).GetComponent<AudioSource>(); if ((Object)(object)component2 != (Object)null) { component2.minDistance = minDistance; component2.maxDistance = maxDistance; component2.rolloffMode = rolloffMode; } } } float value3 = LessLoudSconcesPlugin.BraziersVolumeMultiplier.Value; float value4 = LessLoudSconcesPlugin.BraziersDistanceMultiplier.Value; float minVol2 = componentInChildren.m_minVol * value3; float maxVol2 = componentInChildren.m_maxVol * value3; float minDistance2 = (((Object)(object)component != (Object)null) ? (component.minDistance * value4) : 0f); float maxDistance2 = (((Object)(object)component != (Object)null) ? (component.maxDistance * value4) : 0f); prefabsToQuietTorches = PrefabsToQuietBraziers; foreach (string text2 in prefabsToQuietTorches) { GameObject prefab3 = __instance.GetPrefab(text2); if (!((Object)(object)prefab3 != (Object)null)) { continue; } ZSFX[] componentsInChildren2 = prefab3.GetComponentsInChildren<ZSFX>(true); if (componentsInChildren2 == null) { continue; } array = componentsInChildren2; foreach (ZSFX obj2 in array) { obj2.m_minVol = minVol2; obj2.m_maxVol = maxVol2; AudioSource component3 = ((Component)obj2).GetComponent<AudioSource>(); if ((Object)(object)component3 != (Object)null) { component3.minDistance = minDistance2; component3.maxDistance = maxDistance2; component3.rolloffMode = rolloffMode; } } } } } GameObject prefab4 = __instance.GetPrefab("bonfire"); if ((Object)(object)prefab4 != (Object)null) { ZSFX[] componentsInChildren3 = prefab4.GetComponentsInChildren<ZSFX>(true); if (componentsInChildren3 != null) { float value5 = LessLoudSconcesPlugin.BonfireVolumeMultiplier.Value; array = componentsInChildren3; foreach (ZSFX val in array) { if ((Object)(object)((Component)val).GetComponent<SconceAudioProcessedTag>() == (Object)null) { val.m_minVol *= value5; val.m_maxVol *= value5; ((Component)val).gameObject.AddComponent<SconceAudioProcessedTag>(); } } } } GameObject prefab5 = __instance.GetPrefab("fire_pit"); if ((Object)(object)prefab5 != (Object)null) { ZSFX[] componentsInChildren4 = prefab5.GetComponentsInChildren<ZSFX>(true); if (componentsInChildren4 != null) { float value6 = LessLoudSconcesPlugin.CampfireVolumeMultiplier.Value; array = componentsInChildren4; foreach (ZSFX val2 in array) { if ((Object)(object)((Component)val2).GetComponent<SconceAudioProcessedTag>() == (Object)null) { val2.m_minVol *= value6; val2.m_maxVol *= value6; ((Component)val2).gameObject.AddComponent<SconceAudioProcessedTag>(); } } } } GameObject prefab6 = __instance.GetPrefab("portal_wood"); if ((Object)(object)prefab6 != (Object)null) { AudioSource[] componentsInChildren5 = prefab6.GetComponentsInChildren<AudioSource>(true); if (componentsInChildren5 != null) { float value7 = LessLoudSconcesPlugin.PortalVolumeMultiplier.Value; AudioSource[] array2 = componentsInChildren5; foreach (AudioSource val3 in array2) { if ((Object)(object)((Component)val3).GetComponent<SconceAudioProcessedTag>() == (Object)null) { val3.volume *= value7; ((Component)val3).gameObject.AddComponent<SconceAudioProcessedTag>(); } } } } GameObject prefab7 = __instance.GetPrefab("piece_cauldron"); if ((Object)(object)prefab7 != (Object)null) { ZSFX[] componentsInChildren6 = prefab7.GetComponentsInChildren<ZSFX>(true); if (componentsInChildren6 != null) { float value8 = LessLoudSconcesPlugin.CauldronVolumeMultiplier.Value; array = componentsInChildren6; foreach (ZSFX val4 in array) { if ((Object)(object)((Component)val4).GetComponent<SconceAudioProcessedTag>() == (Object)null) { val4.m_minVol *= value8; val4.m_maxVol *= value8; ((Component)val4).gameObject.AddComponent<SconceAudioProcessedTag>(); } } } } GameObject prefab8 = __instance.GetPrefab("piece_MeadCauldron"); if ((Object)(object)prefab8 != (Object)null) { ZSFX[] componentsInChildren7 = prefab8.GetComponentsInChildren<ZSFX>(true); if (componentsInChildren7 != null) { float value9 = LessLoudSconcesPlugin.MeadKetillVolumeMultiplier.Value; array = componentsInChildren7; foreach (ZSFX val5 in array) { if ((Object)(object)((Component)val5).GetComponent<SconceAudioProcessedTag>() == (Object)null) { val5.m_minVol *= value9; val5.m_maxVol *= value9; ((Component)val5).gameObject.AddComponent<SconceAudioProcessedTag>(); } } } } GameObject prefab9 = __instance.GetPrefab("fermenter"); if ((Object)(object)prefab9 != (Object)null) { ZSFX[] componentsInChildren8 = prefab9.GetComponentsInChildren<ZSFX>(true); if (componentsInChildren8 != null) { float value10 = LessLoudSconcesPlugin.FermenterVolumeMultiplier.Value; array = componentsInChildren8; foreach (ZSFX val6 in array) { if ((Object)(object)((Component)val6).GetComponent<SconceAudioProcessedTag>() == (Object)null) { val6.m_minVol *= value10; val6.m_maxVol *= value10; ((Component)val6).gameObject.AddComponent<SconceAudioProcessedTag>(); } } } } float value11 = LessLoudSconcesPlugin.RefuelVolumeMultiplier.Value; float value12 = LessLoudSconcesPlugin.RepairForgeVolumeMultiplier.Value; float value13 = LessLoudSconcesPlugin.RepairWorkbenchVolumeMultiplier.Value; float value14 = LessLoudSconcesPlugin.CookingVolumeMultiplier.Value; float value15 = LessLoudSconcesPlugin.FermenterUseVolumeMultiplier.Value; float value16 = LessLoudSconcesPlugin.ProcessedSpawnVolumeMultiplier.Value; GameObject prefab10 = __instance.GetPrefab("sfx_FireAddFuel"); if ((Object)(object)prefab10 != (Object)null) { ZSFX[] componentsInChildren9 = prefab10.GetComponentsInChildren<ZSFX>(true); if (componentsInChildren9 != null) { array = componentsInChildren9; foreach (ZSFX val7 in array) { if ((Object)(object)((Component)val7).GetComponent<SconceAudioProcessedTag>() == (Object)null) { val7.m_minVol *= value11; val7.m_maxVol *= value11; ((Component)val7).gameObject.AddComponent<SconceAudioProcessedTag>(); } } } } GameObject prefab11 = __instance.GetPrefab("sfx_gui_repairitem_forge"); if ((Object)(object)prefab11 != (Object)null) { ZSFX[] componentsInChildren10 = prefab11.GetComponentsInChildren<ZSFX>(true); if (componentsInChildren10 != null) { array = componentsInChildren10; foreach (ZSFX val8 in array) { if ((Object)(object)((Component)val8).GetComponent<SconceAudioProcessedTag>() == (Object)null) { val8.m_minVol *= value12; val8.m_maxVol *= value12; ((Component)val8).gameObject.AddComponent<SconceAudioProcessedTag>(); } } } } GameObject prefab12 = __instance.GetPrefab("sfx_gui_repairitem_workbench"); if ((Object)(object)prefab12 != (Object)null) { ZSFX[] componentsInChildren11 = prefab12.GetComponentsInChildren<ZSFX>(true); if (componentsInChildren11 != null) { array = componentsInChildren11; foreach (ZSFX val9 in array) { if ((Object)(object)((Component)val9).GetComponent<SconceAudioProcessedTag>() == (Object)null) { val9.m_minVol *= value13; val9.m_maxVol *= value13; ((Component)val9).gameObject.AddComponent<SconceAudioProcessedTag>(); } } } } GameObject prefab13 = __instance.GetPrefab("sfx_gui_craftitem_cauldron"); if ((Object)(object)prefab13 != (Object)null) { ZSFX[] componentsInChildren12 = prefab13.GetComponentsInChildren<ZSFX>(true); if (componentsInChildren12 != null) { array = componentsInChildren12; foreach (ZSFX val10 in array) { if ((Object)(object)((Component)val10).GetComponent<SconceAudioProcessedTag>() == (Object)null) { val10.m_minVol *= value14; val10.m_maxVol *= value14; ((Component)val10).gameObject.AddComponent<SconceAudioProcessedTag>(); } } } } GameObject prefab14 = __instance.GetPrefab("sfx_gui_craftitem_cauldron_end"); if ((Object)(object)prefab14 != (Object)null) { ZSFX[] componentsInChildren13 = prefab14.GetComponentsInChildren<ZSFX>(true); if (componentsInChildren13 != null) { array = componentsInChildren13; foreach (ZSFX val11 in array) { if ((Object)(object)((Component)val11).GetComponent<SconceAudioProcessedTag>() == (Object)null) { val11.m_minVol *= value14; val11.m_maxVol *= value14; ((Component)val11).gameObject.AddComponent<SconceAudioProcessedTag>(); } } } } GameObject prefab15 = __instance.GetPrefab("sfx_fermenter_add"); if ((Object)(object)prefab15 != (Object)null) { ZSFX[] componentsInChildren14 = prefab15.GetComponentsInChildren<ZSFX>(true); if (componentsInChildren14 != null) { array = componentsInChildren14; foreach (ZSFX val12 in array) { if ((Object)(object)((Component)val12).GetComponent<SconceAudioProcessedTag>() == (Object)null) { val12.m_minVol *= value15; val12.m_maxVol *= value15; ((Component)val12).gameObject.AddComponent<SconceAudioProcessedTag>(); } } } } GameObject prefab16 = __instance.GetPrefab("sfx_fermenter_tap"); if ((Object)(object)prefab16 != (Object)null) { ZSFX[] componentsInChildren15 = prefab16.GetComponentsInChildren<ZSFX>(true); if (componentsInChildren15 != null) { array = componentsInChildren15; foreach (ZSFX val13 in array) { if ((Object)(object)((Component)val13).GetComponent<SconceAudioProcessedTag>() == (Object)null) { val13.m_minVol *= value15; val13.m_maxVol *= value15; ((Component)val13).gameObject.AddComponent<SconceAudioProcessedTag>(); } } } } GameObject prefab17 = __instance.GetPrefab("sfx_lootspawn"); if (!((Object)(object)prefab17 != (Object)null)) { return; } ZSFX[] componentsInChildren16 = prefab17.GetComponentsInChildren<ZSFX>(true); if (componentsInChildren16 == null) { return; } array = componentsInChildren16; foreach (ZSFX val14 in array) { if ((Object)(object)((Component)val14).GetComponent<SconceAudioProcessedTag>() == (Object)null) { val14.m_minVol *= value16; val14.m_maxVol *= value16; ((Component)val14).gameObject.AddComponent<SconceAudioProcessedTag>(); } } } }