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 NoMeadGlow v1.0.1
MeadVfxToggle.dll
Decompiled 3 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("MeadVfxToggle")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("MeadVfxToggle")] [assembly: AssemblyTitle("MeadVfxToggle")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace NoMeadGlow { [BepInPlugin("yourname.valheim.nomeadglow", "NoMeadGlow", "1.0.1")] public class NoMeadGlowPlugin : BaseUnityPlugin { public const string PluginGUID = "yourname.valheim.nomeadglow"; public const string PluginName = "NoMeadGlow"; public const string PluginVersion = "1.0.1"; private readonly Harmony _harmony = new Harmony("yourname.valheim.nomeadglow"); internal static NoMeadGlowPlugin Instance; internal static ManualLogSource Log; internal static string CurrentSEName; private const string MeadPatterns = "Potion_health;Potion_stamina;Potion_eitr;TrollPheromones;bzerker;BugRepellent;swimmer;hasty;Potion_Strength;Tamer;LightFoot"; internal static bool IsMeadStatusEffect(string seName) { if (string.IsNullOrEmpty(seName)) { return false; } string[] array = "Potion_health;Potion_stamina;Potion_eitr;TrollPheromones;bzerker;BugRepellent;swimmer;hasty;Potion_Strength;Tamer;LightFoot".Split(new char[1] { ';' }); string[] array2 = array; foreach (string text in array2) { string text2 = text.Trim(); if (text2.Length != 0 && seName.IndexOf(text2, StringComparison.OrdinalIgnoreCase) >= 0) { return true; } } return false; } private void Awake() { Instance = this; Log = ((BaseUnityPlugin)this).Logger; _harmony.PatchAll(); EffectList_Create_Patch.Apply(_harmony); ((BaseUnityPlugin)this).Logger.LogInfo((object)"NoMeadGlow 1.0.1 loaded."); } private void OnDestroy() { _harmony.UnpatchSelf(); } } [HarmonyPatch(typeof(StatusEffect))] internal static class StatusEffect_Patches { [HarmonyPatch("Setup")] [HarmonyPrefix] private static void Setup_Prefix(StatusEffect __instance) { TrackEnter(__instance); } [HarmonyPatch("Setup")] [HarmonyPostfix] private static void Setup_Postfix() { TrackExit(); } [HarmonyPatch("Stop")] [HarmonyPrefix] private static void Stop_Prefix(StatusEffect __instance) { TrackEnter(__instance); } [HarmonyPatch("Stop")] [HarmonyPostfix] private static void Stop_Postfix() { TrackExit(); } [HarmonyPatch("UpdateStatusEffect")] [HarmonyPrefix] private static void Update_Prefix(StatusEffect __instance) { TrackEnter(__instance); } [HarmonyPatch("UpdateStatusEffect")] [HarmonyPostfix] private static void Update_Postfix() { TrackExit(); } private static void TrackEnter(StatusEffect se) { if (!((Object)(object)se == (Object)null)) { NoMeadGlowPlugin.CurrentSEName = ((Object)se).name; } } private static void TrackExit() { NoMeadGlowPlugin.CurrentSEName = null; } } internal static class EffectList_Create_Patch { private static readonly Dictionary<GameObject, GameObject> StrippedPrefabCache = new Dictionary<GameObject, GameObject>(); private static GameObject _cacheRoot; internal static void Apply(Harmony harmony) { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown //IL_0097: Expected O, but got Unknown MethodBase methodBase = TargetMethod(); MethodInfo method = typeof(EffectList_Create_Patch).GetMethod("Prefix", BindingFlags.Static | BindingFlags.NonPublic); MethodInfo method2 = typeof(EffectList_Create_Patch).GetMethod("Postfix", BindingFlags.Static | BindingFlags.NonPublic); if (method == null) { throw new MissingMethodException(typeof(EffectList_Create_Patch).FullName, "Prefix"); } if (method2 == null) { throw new MissingMethodException(typeof(EffectList_Create_Patch).FullName, "Postfix"); } harmony.Patch(methodBase, new HarmonyMethod(method), new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static MethodBase TargetMethod() { MethodInfo[] array = (from m in typeof(EffectList).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) where m.Name == "Create" select m).Where(delegate(MethodInfo m) { ParameterInfo[] parameters = m.GetParameters(); return parameters.Length >= 5 && parameters[0].ParameterType == typeof(Vector3) && parameters[1].ParameterType == typeof(Quaternion) && parameters[2].ParameterType == typeof(Transform) && parameters[3].ParameterType == typeof(float) && parameters[4].ParameterType == typeof(int); }).ToArray(); if (array.Length == 0) { throw new MissingMethodException(typeof(EffectList).FullName, "Create(Vector3, Quaternion, Transform, float, int, ...)"); } if (array.Length > 1) { throw new AmbiguousMatchException($"Found {array.Length} compatible EffectList.Create overloads."); } return array[0]; } private static bool Prefix(EffectList __instance, out (EffectData data, GameObject originalPrefab)[] __state) { __state = null; string currentSEName = NoMeadGlowPlugin.CurrentSEName; if (currentSEName == null || !NoMeadGlowPlugin.IsMeadStatusEffect(currentSEName)) { return true; } EffectData[] effectPrefabs = __instance.m_effectPrefabs; if (effectPrefabs == null || effectPrefabs.Length == 0) { return true; } List<(EffectData, GameObject)> list = new List<(EffectData, GameObject)>(); EffectData[] array = effectPrefabs; foreach (EffectData val in array) { if (val != null && !((Object)(object)val.m_prefab == (Object)null) && IsVisualVfx(val.m_prefab)) { GameObject orCreateStrippedPrefab = GetOrCreateStrippedPrefab(val.m_prefab); if (!((Object)(object)orCreateStrippedPrefab == (Object)null)) { list.Add((val, val.m_prefab)); val.m_prefab = orCreateStrippedPrefab; } } } __state = list.ToArray(); return true; } [HarmonyPostfix] private static void Postfix((EffectData data, GameObject originalPrefab)[] __state) { if (__state == null) { return; } for (int i = 0; i < __state.Length; i++) { var (val, prefab) = __state[i]; if (val != null) { val.m_prefab = prefab; } } } private static GameObject GetOrCreateStrippedPrefab(GameObject original) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)original == (Object)null) { return null; } if (StrippedPrefabCache.TryGetValue(original, out var value) && (Object)(object)value != (Object)null) { return value; } if ((Object)(object)_cacheRoot == (Object)null) { _cacheRoot = new GameObject("NoMeadGlow_StrippedPrefabCache") { hideFlags = (HideFlags)61 }; _cacheRoot.SetActive(false); Object.DontDestroyOnLoad((Object)(object)_cacheRoot); } GameObject val = Object.Instantiate<GameObject>(original, _cacheRoot.transform); ((Object)val).name = ((Object)original).name + "_NoGlow"; ParticleSystem[] componentsInChildren = val.GetComponentsInChildren<ParticleSystem>(true); foreach (ParticleSystem val2 in componentsInChildren) { EmissionModule emission = val2.emission; ((EmissionModule)(ref emission)).enabled = false; ParticleSystemRenderer component = ((Component)val2).GetComponent<ParticleSystemRenderer>(); if ((Object)(object)component != (Object)null) { ((Renderer)component).enabled = false; } } Light[] componentsInChildren2 = val.GetComponentsInChildren<Light>(true); foreach (Light val3 in componentsInChildren2) { ((Behaviour)val3).enabled = false; } Renderer[] componentsInChildren3 = val.GetComponentsInChildren<Renderer>(true); foreach (Renderer val4 in componentsInChildren3) { val4.enabled = false; } StrippedPrefabCache[original] = val; return val; } private static bool IsVisualVfx(GameObject prefab) { if ((Object)(object)prefab == (Object)null) { return false; } string name = ((Object)prefab).name; if (!string.IsNullOrEmpty(name) && name.IndexOf("vfx", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } if (prefab.GetComponentsInChildren<ParticleSystem>(true).Length != 0) { return true; } if (prefab.GetComponentsInChildren<Light>(true).Length != 0) { return true; } return false; } } }