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 ArrowEffects v1.0.0
ArrowEffects.dll
Decompiled 2 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: AssemblyCompany("ArrowEffects")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ArrowEffects")] [assembly: AssemblyTitle("ArrowEffects")] [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 ArrowEffects { [BepInPlugin("pieter.valheim.arroweffects", "Arrow Effects", "1.0.0")] public class Plugin : BaseUnityPlugin { private enum Element { Fire, Poison, Frost } private sealed class Original { public float Size; public float Rate; public float Distance; public int MaxParticles; public bool Emission; public float Intensity; public float Range; public Vector3 Scale; } public const string Guid = "pieter.valheim.arroweffects"; public const string Name = "Arrow Effects"; public const string Version = "1.0.0"; private static readonly Dictionary<Element, ConfigEntry<int>> Strength = new Dictionary<Element, ConfigEntry<int>>(); private static readonly Dictionary<GameObject, Element> Prefabs = new Dictionary<GameObject, Element>(); private static readonly Dictionary<Component, Original> Originals = new Dictionary<Component, Original>(); private static ManualLogSource _log; private void Awake() { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_00be: Unknown result type (might be due to invalid IL or missing references) _log = ((BaseUnityPlugin)this).Logger; Element[] array = new Element[3] { Element.Fire, Element.Poison, Element.Frost }; for (int i = 0; i < array.Length; i++) { Element element = array[i]; ConfigEntry<int> val = ((BaseUnityPlugin)this).Config.Bind<int>("Arrow effects", $"{element} arrows (%)", 100, new ConfigDescription("Size of particles, lights and glow on " + element.ToString().ToLower() + " arrows: the arrow on your bow, arrows on the ground and arrows in flight. 100 = vanilla, 0 = off.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); val.SettingChanged += delegate { ApplyAll(); }; Strength[element] = val; } new Harmony("pieter.valheim.arroweffects").PatchAll(typeof(Plugin)); } [HarmonyPatch(typeof(ObjectDB), "Awake")] [HarmonyPostfix] [HarmonyPriority(0)] private static void ObjectDBAwake(ObjectDB __instance) { Collect(__instance); } [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] [HarmonyPostfix] [HarmonyPriority(0)] private static void ObjectDBCopy(ObjectDB __instance) { Collect(__instance); } private static void Collect(ObjectDB db) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Invalid comparison between Unknown and I4 //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) if (db?.m_items == null) { return; } int count = Prefabs.Count; foreach (GameObject item in db.m_items) { SharedData val = ((!Object.op_Implicit((Object)(object)item)) ? null : item.GetComponent<ItemDrop>()?.m_itemData?.m_shared); if (val == null || (int)val.m_itemType != 9) { continue; } DamageTypes damages = val.m_damages; Element value; if (damages.m_poison > 0f && damages.m_poison >= damages.m_fire && damages.m_poison >= damages.m_frost) { value = Element.Poison; } else if (damages.m_fire > 0f && damages.m_fire >= damages.m_frost) { value = Element.Fire; } else { if (!(damages.m_frost > 0f)) { continue; } value = Element.Frost; } Prefabs[item] = value; GameObject val2 = val.m_attack?.m_attackProjectile; if (Object.op_Implicit((Object)(object)val2)) { Prefabs[val2] = value; } } if (Prefabs.Count != count) { _log.LogInfo((object)$"Arrow effects: {Prefabs.Count} arrow and projectile prefabs found."); } ApplyAll(); } private static void ApplyAll() { foreach (KeyValuePair<GameObject, Element> prefab in Prefabs) { if (Object.op_Implicit((Object)(object)prefab.Key)) { Apply(prefab.Key, (float)Strength[prefab.Value].Value / 100f); } } } private static void Apply(GameObject prefab, float k) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) ParticleSystem[] componentsInChildren = prefab.GetComponentsInChildren<ParticleSystem>(true); foreach (ParticleSystem val in componentsInChildren) { MainModule main = val.main; EmissionModule emission = val.emission; if (!Originals.TryGetValue((Component)(object)val, out var value)) { value = new Original { Size = ((MainModule)(ref main)).startSizeMultiplier, MaxParticles = ((MainModule)(ref main)).maxParticles, Emission = ((EmissionModule)(ref emission)).enabled, Rate = ((EmissionModule)(ref emission)).rateOverTimeMultiplier, Distance = ((EmissionModule)(ref emission)).rateOverDistanceMultiplier }; Originals[(Component)(object)val] = value; } ((MainModule)(ref main)).startSizeMultiplier = value.Size * k; ((MainModule)(ref main)).maxParticles = Mathf.Max((k > 0f) ? 1 : 0, Mathf.RoundToInt((float)value.MaxParticles * k)); ((EmissionModule)(ref emission)).rateOverTimeMultiplier = value.Rate * k; ((EmissionModule)(ref emission)).rateOverDistanceMultiplier = value.Distance * k; ((EmissionModule)(ref emission)).enabled = value.Emission && k > 0f; } Light[] componentsInChildren2 = prefab.GetComponentsInChildren<Light>(true); foreach (Light val2 in componentsInChildren2) { if (!Originals.TryGetValue((Component)(object)val2, out var value2)) { value2 = new Original { Intensity = val2.intensity, Range = val2.range }; Originals[(Component)(object)val2] = value2; } val2.intensity = value2.Intensity * k; val2.range = value2.Range * Mathf.Max(k, 0.01f); ((Behaviour)val2).enabled = k > 0f; } MeshRenderer[] componentsInChildren3 = prefab.GetComponentsInChildren<MeshRenderer>(true); foreach (MeshRenderer val3 in componentsInChildren3) { Transform transform = ((Component)val3).transform; if (!(((Object)transform).name != "Sphere")) { if (!Originals.TryGetValue((Component)(object)transform, out var value3)) { value3 = new Original { Scale = transform.localScale }; Originals[(Component)(object)transform] = value3; } transform.localScale = value3.Scale * k; ((Renderer)val3).enabled = k > 0f; } } } } }