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 DyrnwynReforged WanderingLordReto v1.0.0
plugins/DyrnwynReforged_WanderingLordReto.dll
Decompiled 2 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.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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyVersion("0.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 LordGrover { [BepInPlugin("com.taylor.dyrnwynreforged.wanderinglordreto", "Dyrnwyn Reforged - Wandering Lord Reto", "1.0.0")] public class LordGroverPlugin : BaseUnityPlugin { public const string ModGuid = "com.taylor.dyrnwynreforged.wanderinglordreto"; public const string ModName = "Dyrnwyn Reforged - Wandering Lord Reto"; public const string ModVersion = "1.0.0"; public const string PrefabName = "LordGrover"; public const string DisplayName = "Lord Grover"; internal static ManualLogSource Log; internal static ConfigEntry<string> SourcePrefab; internal static ConfigEntry<string> FragmentPrefabs; internal static ConfigEntry<float> SpawnChance; internal static ConfigEntry<float> SpawnInterval; internal static ConfigEntry<int> MaxSpawned; internal static ConfigEntry<bool> SpawnAtDay; internal static ConfigEntry<bool> SpawnAtNight; private static GameObject _prefabHolder; internal static GameObject GroverPrefab; private void Awake() { //IL_0100: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; SourcePrefab = ((BaseUnityPlugin)this).Config.Bind<string>("General", "SourcePrefab", "Charred_Melee_Dyrnwyn", "Internal prefab name of the vanilla creature to copy (Lord Reto)."); FragmentPrefabs = ((BaseUnityPlugin)this).Config.Bind<string>("Drops", "FragmentPrefabs", "DyrnwynTipFragment,DyrnwynBladeFragment,DyrnwynHiltFragment", "Comma-separated item prefab names. Exactly one is chosen at random when Lord Grover dies."); SpawnChance = ((BaseUnityPlugin)this).Config.Bind<float>("Spawning", "SpawnChance", 1f, "Percent chance (0-100) per spawn check, per active Ashlands zone."); SpawnInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Spawning", "SpawnInterval", 900f, "Seconds between spawn checks."); MaxSpawned = ((BaseUnityPlugin)this).Config.Bind<int>("Spawning", "MaxSpawned", 1, "Maximum number of Lord Grovers near a player at once."); SpawnAtDay = ((BaseUnityPlugin)this).Config.Bind<bool>("Spawning", "SpawnAtDay", true, "Allow spawning during the day."); SpawnAtNight = ((BaseUnityPlugin)this).Config.Bind<bool>("Spawning", "SpawnAtNight", true, "Allow spawning at night."); new Harmony("com.taylor.dyrnwynreforged.wanderinglordreto").PatchAll(); } internal static GameObject GetPrefabHolder() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if ((Object)(object)_prefabHolder == (Object)null) { _prefabHolder = new GameObject("LordGrover_PrefabHolder"); _prefabHolder.SetActive(false); Object.DontDestroyOnLoad((Object)(object)_prefabHolder); } return _prefabHolder; } internal static IEnumerable<string> FragmentNames() { return from s in FragmentPrefabs.Value.Split(',') select s.Trim() into s where s.Length > 0 select s; } } [HarmonyPatch(typeof(ZNetScene), "Awake")] internal static class ZNetSceneAwakePatch { private static void Postfix(ZNetScene __instance) { Dictionary<int, GameObject> value = Traverse.Create((object)__instance).Field("m_namedPrefabs").GetValue<Dictionary<int, GameObject>>(); if ((Object)(object)LordGroverPlugin.GroverPrefab == (Object)null) { GameObject prefab = __instance.GetPrefab(LordGroverPlugin.SourcePrefab.Value); if ((Object)(object)prefab == (Object)null) { LordGroverPlugin.Log.LogError((object)("Source prefab '" + LordGroverPlugin.SourcePrefab.Value + "' not found. Candidates: " + string.Join(", ", from p in __instance.m_prefabs where (Object)(object)p != (Object)null && ((Object)p).name.StartsWith("Charred") select ((Object)p).name))); return; } GameObject val = Object.Instantiate<GameObject>(prefab, LordGroverPlugin.GetPrefabHolder().transform, false); ((Object)val).name = "LordGrover"; Character component = val.GetComponent<Character>(); if ((Object)(object)component != (Object)null) { component.m_name = "Lord Grover"; component.m_defeatSetGlobalKey = ""; } CharacterDrop component2 = val.GetComponent<CharacterDrop>(); if ((Object)(object)component2 != (Object)null) { component2.m_drops.Clear(); } LordGroverPlugin.GroverPrefab = val; LordGroverPlugin.Log.LogInfo((object)("Created '" + ((Object)val).name + "' from '" + ((Object)prefab).name + "'.")); } GameObject groverPrefab = LordGroverPlugin.GroverPrefab; if (!__instance.m_prefabs.Contains(groverPrefab)) { __instance.m_prefabs.Add(groverPrefab); } value[StringExtensionMethods.GetStableHashCode(((Object)groverPrefab).name)] = groverPrefab; foreach (string item in LordGroverPlugin.FragmentNames()) { if ((Object)(object)__instance.GetPrefab(item) == (Object)null) { LordGroverPlugin.Log.LogWarning((object)("Fragment prefab '" + item + "' not found. Candidates: " + string.Join(", ", from p in __instance.m_prefabs where (Object)(object)p != (Object)null && ((Object)p).name.IndexOf("Dyrnwyn", StringComparison.OrdinalIgnoreCase) >= 0 select ((Object)p).name))); } } } } [HarmonyPatch(typeof(SpawnSystem), "Awake")] internal static class SpawnSystemAwakePatch { private static SpawnSystemList _groverList; private static void Postfix(SpawnSystem __instance) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)LordGroverPlugin.GroverPrefab == (Object)null) { return; } if ((Object)(object)_groverList == (Object)null) { SpawnData val = __instance.m_spawnLists.SelectMany((SpawnSystemList l) => l.m_spawners).FirstOrDefault((Func<SpawnData, bool>)((SpawnData s) => (Object)(object)s.m_prefab != (Object)null && (s.m_biome & 0x20) != 0 && ((Object)s.m_prefab).name.StartsWith("Charred"))); SpawnData val2 = (SpawnData)((val != null) ? ((object)val.Clone()) : ((object)new SpawnData())); val2.m_name = "LordGrover"; val2.m_enabled = true; val2.m_prefab = LordGroverPlugin.GroverPrefab; val2.m_biome = (Biome)32; val2.m_spawnChance = LordGroverPlugin.SpawnChance.Value; val2.m_spawnInterval = LordGroverPlugin.SpawnInterval.Value; val2.m_maxSpawned = LordGroverPlugin.MaxSpawned.Value; val2.m_spawnAtDay = LordGroverPlugin.SpawnAtDay.Value; val2.m_spawnAtNight = LordGroverPlugin.SpawnAtNight.Value; val2.m_groupSizeMin = 1; val2.m_groupSizeMax = 1; val2.m_minLevel = 1; val2.m_maxLevel = 1; val2.m_requiredGlobalKey = ""; val2.m_requiredEnvironments = new List<string>(); _groverList = LordGroverPlugin.GetPrefabHolder().AddComponent<SpawnSystemList>(); _groverList.m_spawners = new List<SpawnData> { val2 }; LordGroverPlugin.Log.LogInfo((object)((val != null) ? ("Spawn entry added (based on '" + ((Object)val.m_prefab).name + "').") : "Spawn entry added (no Ashlands template found; using defaults).")); } if (!__instance.m_spawnLists.Contains(_groverList)) { __instance.m_spawnLists.Add(_groverList); } } } [HarmonyPatch(typeof(CharacterDrop), "GenerateDropList")] internal static class CharacterDropPatch { private static void Postfix(CharacterDrop __instance, ref List<KeyValuePair<GameObject, int>> __result) { if (!(Utils.GetPrefabName(((Component)__instance).gameObject) != "LordGrover")) { List<GameObject> list = (from n in LordGroverPlugin.FragmentNames() select ObjectDB.instance.GetItemPrefab(n) into p where (Object)(object)p != (Object)null select p).ToList(); __result = new List<KeyValuePair<GameObject, int>>(); if (list.Count == 0) { LordGroverPlugin.Log.LogWarning((object)"Lord Grover died but no valid fragment prefabs are configured."); } else { __result.Add(new KeyValuePair<GameObject, int>(list[Random.Range(0, list.Count)], 1)); } } } } }