Please disclose if your mod was created primarily 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 Simple New Set and Cape Bonuses v1.0.3
SimpleSetAndCapeBonuses.dll
Decompiled 2 years agousing System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("SimpleSetAndCapeBonuses")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("SimpleSetAndCapeBonuses")] [assembly: AssemblyCopyright("Copyright © 2022")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("afa63da7-d6f9-4ee4-9e3b-842443c3e49d")] [assembly: AssemblyFileVersion("1.0.3.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.3.0")] [module: UnverifiableCode] namespace SimpleSetAndCapeBonuses; [HarmonyPatch] internal class GathererPatch { private static readonly string[] allowedPickables = new string[11] { "Pickable_Branch", "Pickable_Stone", "Pickable_Flint", "Pickable_Mushroom", "Pickable_Mushroom_yellow", "Pickable_Mushroom_blue", "Pickable_Dandelion", "Pickable_Thistle", "RaspberryBush", "BlueberryBush", "CloudberryBush" }; [HarmonyPatch(typeof(Pickable), "RPC_Pick")] public static void Prefix(Pickable __instance, long sender, ref int __state) { __state = __instance.m_amount; if (!__instance.m_nview.IsOwner() || __instance.m_picked) { return; } Player val = Player.GetPlayer(sender); if ((Object)(object)val == (Object)null) { val = Player.m_localPlayer; } if (!((Object)(object)val == (Object)null) && ((Character)val).m_seman.HaveStatusEffect(PatchObjectDB.ragsSetBonusHash) && IsForage(__instance)) { if (SimpleSetAndCapeBonusesPlugin.ForagerSetBonusUsesRandomness.Value) { __instance.m_amount += Random.Range(0, 3); } else { __instance.m_amount++; } } } [HarmonyPatch(typeof(Pickable), "RPC_Pick")] public static void Postfix(Pickable __instance, ref int __state) { __instance.m_amount = __state; } private static bool IsForage(Pickable pickup) { string[] array = allowedPickables; foreach (string text in array) { if (((Object)pickup).name.StartsWith(text + "(Clone")) { return true; } } return false; } } [BepInPlugin("goldenrevolver.SimpleSetAndCapeBonuses", "Simple New Set and Cape Bonuses", "1.0.3")] public class SimpleSetAndCapeBonusesPlugin : BaseUnityPlugin { public const string NAME = "Simple New Set and Cape Bonuses"; public const string VERSION = "1.0.3"; public static ConfigEntry<bool> EnableLeatherArmorSetBonus; public static ConfigEntry<bool> EnableForagerArmorSetBonus; public static ConfigEntry<bool> EnableTrollArmorSetBonusChange; public static ConfigEntry<bool> EnableCapeBuffs; public static ConfigEntry<bool> EnableSetBonusIcons; public static ConfigEntry<bool> AlwaysEnableMidsummerCrownRecipe; public static ConfigEntry<bool> ForagerSetBonusUsesRandomness; public static ConfigEntry<string> LeatherArmorSetBonusLabel; public static ConfigEntry<string> LeatherArmorSetBonusTooltip; public static ConfigEntry<string> ForagerSetBonusLabel; public static ConfigEntry<string> ForagerSetBonusTooltip; protected void Awake() { LoadConfig(); Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); } private void LoadConfig() { string text = "0 - Requires Restart"; EnableTrollArmorSetBonusChange = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "EnableTrollArmorSetBonusChange", true, string.Empty); EnableLeatherArmorSetBonus = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "EnableLeatherArmorSetBonus", true, string.Empty); EnableForagerArmorSetBonus = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "EnableForagerArmorSetBonus", true, string.Empty); EnableCapeBuffs = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "EnableCapeBuffs", true, string.Empty); EnableSetBonusIcons = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "EnableSetBonusIcons", true, string.Empty); AlwaysEnableMidsummerCrownRecipe = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "AlwaysEnableMidsummerCrownRecipe", true, string.Empty); text = "1 - No Restart Required"; ForagerSetBonusUsesRandomness = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "ForagerSetBonusUsesRandomness", true, "Whether Forager always grants 1 more item, or 0 to 2 with an average of 1."); text = "9 - Localization"; LeatherArmorSetBonusLabel = ((BaseUnityPlugin)this).Config.Bind<string>(text, "LeatherArmorSetBonusLabel", "Quick Feet", string.Empty); LeatherArmorSetBonusTooltip = ((BaseUnityPlugin)this).Config.Bind<string>(text, "LeatherArmorSetBonusTooltip", "Your legs carry you faster and further.", string.Empty); ForagerSetBonusLabel = ((BaseUnityPlugin)this).Config.Bind<string>(text, "ForagerSetBonusLabel", "Forager", string.Empty); ForagerSetBonusTooltip = ((BaseUnityPlugin)this).Config.Bind<string>(text, "ForagerSetBonusTooltip", "Your foraging skills are improved.", string.Empty); } } [HarmonyPatch(typeof(Localization))] internal static class PatchLocalization { [HarmonyPatch("Translate")] [HarmonyPostfix] public static void Show_Postfix(string word, ref string __result) { if (word == "GoldensLeatherSetBonus".ToLower()) { __result = SimpleSetAndCapeBonusesPlugin.LeatherArmorSetBonusLabel.Value; } else if (word == "GoldensRagsSetBonus".ToLower()) { __result = SimpleSetAndCapeBonusesPlugin.ForagerSetBonusLabel.Value; } } } [HarmonyPatch(typeof(ObjectDB))] internal static class PatchObjectDB { internal const string leatherSetBonus = "GoldensLeatherSetBonus"; internal const string ragsSetBonus = "GoldensRagsSetBonus"; internal static int ragsSetBonusHash; private static readonly string[] ragsSet = new string[3] { "HelmetMidsummerCrown", "ArmorRagsChest", "ArmorRagsLegs" }; private static readonly string[] leatherSet = new string[3] { "HelmetLeather", "ArmorLeatherChest", "ArmorLeatherLegs" }; private static readonly string[] trollSet = new string[3] { "HelmetTrollLeather", "ArmorTrollLeatherChest", "ArmorTrollLeatherLegs" }; [HarmonyPatch("Awake")] [HarmonyPrefix] public static void Show_Postfix(ObjectDB __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Invalid comparison between Unknown and I4 //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Invalid comparison between Unknown and I4 Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name != "main") { return; } if (SimpleSetAndCapeBonusesPlugin.AlwaysEnableMidsummerCrownRecipe.Value) { foreach (Recipe recipe in __instance.m_recipes) { if (recipe.m_item?.m_itemData.m_shared.m_name == "$item_helmet_midsummercrown" && !recipe.m_enabled) { recipe.m_enabled = true; Debug.Log((object)"Reenabled midsummer crown recipe"); } } } SE_Stats val = ScriptableObject.CreateInstance<SE_Stats>(); val.m_skillLevel = (SkillType)102; val.m_skillLevelModifier = 10f; val.m_runStaminaDrainModifier = -0.15f; ((Object)val).name = "GoldensLeatherSetBonus"; ((StatusEffect)val).m_name = "$" + "GoldensLeatherSetBonus".ToLower(); ((StatusEffect)val).m_tooltip = SimpleSetAndCapeBonusesPlugin.LeatherArmorSetBonusTooltip.Value; __instance.m_StatusEffects.Add((StatusEffect)(object)val); StatusEffect val2 = ScriptableObject.CreateInstance<StatusEffect>(); ((Object)val2).name = "GoldensRagsSetBonus"; val2.m_name = "$" + "GoldensRagsSetBonus".ToLower(); val2.m_tooltip = SimpleSetAndCapeBonusesPlugin.ForagerSetBonusTooltip.Value; ragsSetBonusHash = val2.NameHash(); __instance.m_StatusEffects.Add(val2); foreach (GameObject item in __instance.m_items) { if (SimpleSetAndCapeBonusesPlugin.EnableCapeBuffs.Value) { if (((Object)item).name == "CapeDeerHide") { item.GetComponent<ItemDrop>().m_itemData.m_shared.m_movementModifier = 0.03f; } if (((Object)item).name == "CapeTrollHide") { item.GetComponent<ItemDrop>().m_itemData.m_shared.m_movementModifier = 0.05f; } if (((Object)item).name == "CapeLinen") { item.GetComponent<ItemDrop>().m_itemData.m_shared.m_movementModifier = 0.1f; } } if (SimpleSetAndCapeBonusesPlugin.EnableTrollArmorSetBonusChange.Value) { if (((Object)item).name == "CapeTrollHide") { SharedData shared = item.GetComponent<ItemDrop>().m_itemData.m_shared; shared.m_setName = string.Empty; shared.m_setSize = 0; shared.m_setStatusEffect = null; } if (trollSet.Contains(((Object)item).name)) { item.GetComponent<ItemDrop>().m_itemData.m_shared.m_setSize = 3; } } if (SimpleSetAndCapeBonusesPlugin.EnableLeatherArmorSetBonus.Value && leatherSet.Contains(((Object)item).name)) { SharedData shared2 = item.GetComponent<ItemDrop>().m_itemData.m_shared; shared2.m_setSize = 3; shared2.m_setName = "GoldensLeatherSetBonus"; shared2.m_setStatusEffect = (StatusEffect)(object)val; if (SimpleSetAndCapeBonusesPlugin.EnableSetBonusIcons.Value && (int)shared2.m_itemType == 6) { Sprite[] icons = shared2.m_icons; if (icons != null && icons.Length != 0) { ((StatusEffect)val).m_icon = shared2.m_icons[0]; } } } if (!SimpleSetAndCapeBonusesPlugin.EnableForagerArmorSetBonus.Value || !ragsSet.Contains(((Object)item).name)) { continue; } SharedData shared3 = item.GetComponent<ItemDrop>().m_itemData.m_shared; shared3.m_setSize = 3; shared3.m_setName = "GoldensRagsSetBonus"; shared3.m_setStatusEffect = val2; if (SimpleSetAndCapeBonusesPlugin.EnableSetBonusIcons.Value && (int)shared3.m_itemType == 6) { Sprite[] icons2 = shared3.m_icons; if (icons2 != null && icons2.Length != 0) { val2.m_icon = shared3.m_icons[0]; } } } } }