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 MTMCore v0.1.1
plugins\MTMCore.dll
Decompiled 13 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using More_World_Locations_AIO.Traders; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("MTMCore")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("MTMCore")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")] [assembly: AssemblyFileVersion("0.1.1")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.1.0")] namespace MTM; [HarmonyPatch(typeof(Player), "AddAdrenaline")] internal static class AdrenalinePatches { private static void Prefix(Player __instance, ref float v) { if (v > 0f) { v *= Plugin.AdrenalineMultiplier.Value; } else { v *= Plugin.AdrenalineDecayMultiplier.Value; } if (Plugin.VerboseLogging.Value) { Plugin.Log.LogInfo((object)$"[Adrenaline] Prefix adjusted v to {v}"); } } private static void Postfix(Player __instance, ref float ___m_adrenalineDegenTimer, ref float v) { float maxAdrenaline = ((Character)__instance).GetMaxAdrenaline(); if (v > 0f && maxAdrenaline > 0f) { ___m_adrenalineDegenTimer *= Plugin.AdrenalineDecayDelayMultiplier.Value; if (Plugin.VerboseLogging.Value) { Plugin.Log.LogInfo((object)$"[Adrenaline] Postfix degen timer scaled to {___m_adrenalineDegenTimer}"); } } } } [HarmonyPatch(typeof(Minimap), "Start")] public static class Minimap_Start_TextClockPatch { private class TimeOfDayLabelUpdater : MonoBehaviour { private Text _label; private float _timer; private string _lastText = string.Empty; public void Bind(Text label) { _label = label; } private void Update() { _timer -= Time.deltaTime; if (!(_timer > 0f)) { _timer = 2f; string label = TimeOfDay.GetLabel(EnvMan.instance.GetDayFraction()); if (label != _lastText) { _label.text = label; _lastText = label; } } } } private const float OffsetX = -5f; private const float OffsetY = 0f; private const int FontSize = 16; private static readonly Color TextColor = new Color(1f, 1f, 1f, 0.9f); private const float UpdateIntervalSeconds = 2f; private static void Postfix(Minimap __instance) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) Transform transform = __instance.m_smallRoot.transform; object obj; if (__instance == null) { obj = null; } else { TMP_Text biomeNameLarge = __instance.m_biomeNameLarge; obj = ((biomeNameLarge != null) ? biomeNameLarge.font : null); } TMP_FontAsset val = (TMP_FontAsset)obj; if (val != null) { Plugin.Log.LogDebug((object)((Object)val).name); } GameObject obj2 = GUIManager.Instance.CreateText("", transform, new Vector2(1f, 0f), new Vector2(1f, 0f), new Vector2(-5f, 0f), GUIManager.Instance.AveriaSerifBold, 16, TextColor, true, Color.black, 200f, 30f, true); obj2.GetComponent<RectTransform>().pivot = new Vector2(1f, 1f); Text component = obj2.GetComponent<Text>(); component.alignment = (TextAnchor)8; obj2.AddComponent<TimeOfDayLabelUpdater>().Bind(component); } } public static class TimeOfDay { private const float WeeHoursStart = 0.15f; private const float DawnStart = 0.2f; private const float MorningStart = 0.25f; private const float MidDayStart = 0.35f; private const float EveningStart = 0.6f; private const float DuskStart = 0.7f; private const float NightfallStart = 0.75f; private const float MidnightStart = 0.85f; public static string GetLabel(float dayFraction) { if (!(dayFraction >= 0.85f)) { if (!(dayFraction >= 0.75f)) { if (!(dayFraction >= 0.7f)) { if (!(dayFraction >= 0.6f)) { if (!(dayFraction >= 0.35f)) { if (!(dayFraction >= 0.25f)) { if (!(dayFraction >= 0.2f)) { if (dayFraction >= 0.15f) { return "Jiig O'Clock"; } return "Midnight"; } return "Dawn"; } return "Morning"; } return "Mid-day"; } return "Evening"; } return "Dusk"; } return "Nightfall"; } return "Midnight"; } } [HarmonyPatch(typeof(Character), "SetupMaxHealth")] public static class CharacterSetupMaxHealthPatch { private static void Postfix(Character __instance) { if (!__instance.IsPlayer()) { float maxHealthBase = __instance.GetMaxHealthBase(); int num = __instance.GetLevel() - 1; bool boss = __instance.m_boss; float num2 = (boss ? Plugin.BossHealthMult.Value : Plugin.CreatureHealthMult.Value); float num3 = 1f + (float)num * 1f * Plugin.PerStarHealthMult.Value; float num4 = maxHealthBase * num2 * num3; __instance.SetMaxHealth(num4); if (Plugin.VerboseLogging.Value) { Plugin.Log.LogInfo((object)($"[HEALTH PATCHED] {((Object)__instance).name} | stars={num} isBoss={boss} " + $"baseHealth={maxHealthBase:F1} mult={num2:F2} starBonus={num3:F2} => final={num4:F1}")); } } } } [HarmonyPatch(typeof(Character), "Damage")] public static class CharacterDamagePatch { private struct DamageComponentLog { public string Name { get; init; } public float Before { get; init; } public float After { get; init; } } private static void Prefix(Character __instance, ref HitData hit) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) Character attacker = hit.GetAttacker(); if ((Object)(object)attacker == (Object)null || attacker.IsPlayer()) { return; } int num = attacker.GetLevel() - 1; bool boss = attacker.m_boss; float num2 = (boss ? Plugin.BossDamageMult.Value : Plugin.CreatureDamageMult.Value); float num3 = 1f + (float)num * 0.5f; float num4 = 1f + (float)num * 0.5f * Plugin.PerStarDamageMult.Value; float num5 = num2 * (num4 / num3); DamageTypes damage = hit.m_damage; hit.ApplyModifier(num5); DamageTypes damage2 = hit.m_damage; if (!Plugin.VerboseLogging.Value) { return; } DamageComponentLog[] obj = new DamageComponentLog[10] { new DamageComponentLog { Name = "blunt", Before = damage.m_blunt, After = damage2.m_blunt }, new DamageComponentLog { Name = "slash", Before = damage.m_slash, After = damage2.m_slash }, new DamageComponentLog { Name = "pierce", Before = damage.m_pierce, After = damage2.m_pierce }, new DamageComponentLog { Name = "chop", Before = damage.m_chop, After = damage2.m_chop }, new DamageComponentLog { Name = "pickaxe", Before = damage.m_pickaxe, After = damage2.m_pickaxe }, new DamageComponentLog { Name = "fire", Before = damage.m_fire, After = damage2.m_fire }, new DamageComponentLog { Name = "frost", Before = damage.m_frost, After = damage2.m_frost }, new DamageComponentLog { Name = "lightning", Before = damage.m_lightning, After = damage2.m_lightning }, new DamageComponentLog { Name = "poison", Before = damage.m_poison, After = damage2.m_poison }, new DamageComponentLog { Name = "spirit", Before = damage.m_spirit, After = damage2.m_spirit } }; List<string> list = new List<string>(); DamageComponentLog[] array = obj; for (int i = 0; i < array.Length; i++) { DamageComponentLog damageComponentLog = array[i]; if (damageComponentLog.Before != 0f || damageComponentLog.After != 0f) { list.Add($" {damageComponentLog.Name}: {damageComponentLog.Before:F1} => {damageComponentLog.After:F1}"); } } string text = string.Join("\n", list); Plugin.Log.LogInfo((object)($"[DMG PATCHED] attacker={((Object)attacker).name} stars={num} isBoss={boss} " + $"mult={num2:F2} starBonus={num4:F2} totalMult={num5:F2}\n" + text)); } } public static class MeadIconRenderer { public static Sprite RenderIcon(GameObject liveMeadPrefab, Quaternion rotation, int width = 64, int height = 64, float fieldOfView = 30f) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown GameObject val = Object.Instantiate<GameObject>(liveMeadPrefab); ((Object)val).name = ((Object)liveMeadPrefab).name + "_IconClone"; ((Object)val).hideFlags = (HideFlags)61; List<Material> list = new List<Material>(); try { FixRenderOnlyMaterials(val, list); RenderRequest val2 = new RenderRequest(val) { Rotation = rotation, Width = width, Height = height, FieldOfView = fieldOfView }; return RenderManager.Instance.Render(val2); } finally { foreach (Material item in list) { Object.DestroyImmediate((Object)(object)item); } Object.DestroyImmediate((Object)(object)val); } } private static void FixRenderOnlyMaterials(GameObject root, List<Material> instancedMaterials) { MeshRenderer[] componentsInChildren = root.GetComponentsInChildren<MeshRenderer>(true); foreach (MeshRenderer val in componentsInChildren) { Material[] materials = ((Renderer)val).materials; instancedMaterials.AddRange(materials); Material[] array = materials; foreach (Material val2 in array) { if (!((Object)(object)val2 == (Object)null)) { ForceOpaque(val2); } } ((Renderer)val).materials = materials; } } private static void ForceOpaque(Material mat) { if (mat.HasProperty("_SrcBlend") && mat.HasProperty("_DstBlend")) { mat.SetInt("_SrcBlend", 1); mat.SetInt("_DstBlend", 0); mat.DisableKeyword("_ALPHABLEND_ON"); mat.DisableKeyword("_ALPHATEST_ON"); mat.DisableKeyword("_ALPHAPREMULTIPLY_ON"); } } } public static class SwiftfootMead { public const string EffectName = "SE_SwiftfootMead"; public const string ItemName = "SwiftfootMead"; private static readonly Color TintColor = new Color(0.55f, 0.1f, 0.45f); private const float TintBlend = 0.85f; public static void Init() { PrefabManager.OnVanillaPrefabsAvailable += OnVanillaPrefabsAvailable; } private static void OnVanillaPrefabsAvailable() { PrefabManager.OnVanillaPrefabsAvailable -= OnVanillaPrefabsAvailable; RegisterItemAndEffect(); } private static void RegisterItemAndEffect() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) SE_Stats val = ScriptableObject.CreateInstance<SE_Stats>(); ((Object)val).name = "SE_SwiftfootMead"; ((StatusEffect)val).m_name = "Swiftfoot"; ((StatusEffect)val).m_tooltip = "Movement speed +10%, jump height +10%."; ((StatusEffect)val).m_ttl = 600f; val.m_speedModifier = 0.1f; val.m_jumpModifier = new Vector3(0f, 0.1f, 0f); ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)val, false)); CustomItem val2 = new CustomItem("SwiftfootMead", "MeadPoisonResist"); ItemDrop itemDrop = val2.ItemDrop; GameObject gameObject = ((Component)itemDrop).gameObject; itemDrop.m_itemData.m_shared.m_name = "Swiftfoot Mead"; itemDrop.m_itemData.m_shared.m_description = "A light, fizzy mead. Quickens the step and lightens the legs for a short while."; itemDrop.m_itemData.m_shared.m_consumeStatusEffect = (StatusEffect)(object)val; RecolorLiquid(gameObject, TintColor, 0.85f); Sprite val3 = MeadIconRenderer.RenderIcon(gameObject, Quaternion.Euler(0f, 90f, 20f)); itemDrop.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { val3 }; ((StatusEffect)val).m_icon = val3; ItemManager.Instance.AddItem(val2); } private static void RecolorLiquid(GameObject root, Color tint, float blend) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) Renderer[] componentsInChildren = root.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if (val is ParticleSystemRenderer) { continue; } Material material = val.material; if (!material.HasProperty("_MainTex")) { continue; } Texture texture = material.GetTexture("_MainTex"); Texture2D val2 = (Texture2D)(object)((texture is Texture2D) ? texture : null); if (val2 == null) { continue; } Texture2D val3 = MakeReadableCopy(val2); Color[] pixels = val3.GetPixels(); for (int j = 0; j < pixels.Length; j++) { if (LooksLikeLiquid(pixels[j])) { Color val4 = pixels[j]; Color val5 = Color.Lerp(val4, tint, blend); val5.a = val4.a; pixels[j] = val5; } } val3.SetPixels(pixels); val3.Apply(); material.SetTexture("_MainTex", (Texture)(object)val3); } } private static bool LooksLikeLiquid(Color pixel) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (pixel.g > 0.15f && pixel.g > pixel.r + 0.08f) { return pixel.g > pixel.b + 0.08f; } return false; } private static Texture2D MakeReadableCopy(Texture2D source) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown RenderTexture temporary = RenderTexture.GetTemporary(((Texture)source).width, ((Texture)source).height, 0, (RenderTextureFormat)0); Graphics.Blit((Texture)(object)source, temporary); RenderTexture active = RenderTexture.active; RenderTexture.active = temporary; Texture2D val = new Texture2D(((Texture)source).width, ((Texture)source).height, (TextureFormat)4, false); val.ReadPixels(new Rect(0f, 0f, (float)((Texture)source).width, (float)((Texture)source).height), 0, 0); val.Apply(); RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); return val; } } [BepInPlugin("mightytightymods.mtm-core", "MTMCore", "0.1.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] internal class Plugin : BaseUnityPlugin { public const string PluginGUID = "mightytightymods.mtm-core"; public const string PluginName = "MTMCore"; public const string PluginVersion = "0.1.1"; public static ConfigEntry<float> CreatureHealthMult; public static ConfigEntry<float> CreatureDamageMult; public static ConfigEntry<float> BossHealthMult; public static ConfigEntry<float> BossDamageMult; public static ConfigEntry<float> PerStarHealthMult; public static ConfigEntry<float> PerStarDamageMult; public static ConfigEntry<float> AdrenalineMultiplier; public static ConfigEntry<float> AdrenalineDecayMultiplier; public static ConfigEntry<float> AdrenalineDecayDelayMultiplier; public static ConfigEntry<bool> VerboseLogging; public static ConfigEntry<int> UpperLeftSplitAmount; public static ConfigEntry<int> UpperRightSplitAmount; public static ConfigEntry<int> LowerLeftSplitAmount; public static ConfigEntry<int> LowerRightSplitAmount; public static ConfigEntry<int> SkillBookBreakpoint; public static ConfigEntry<int> SkillBookCap; private readonly Harmony harmony = new Harmony("mightytightymods.mtm-core"); public static ManualLogSource Log; private void Awake() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: 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_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Expected O, but got Unknown //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Expected O, but got Unknown //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Expected O, but got Unknown //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Expected O, but got Unknown //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Expected O, but got Unknown //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Expected O, but got Unknown //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Expected O, but got Unknown //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Expected O, but got Unknown //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Expected O, but got Unknown //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Expected O, but got Unknown //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Expected O, but got Unknown //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; ConfigurationManagerAttributes val = new ConfigurationManagerAttributes { IsAdminOnly = true }; AcceptableValueRange<float> val2 = new AcceptableValueRange<float>(0.1f, 5f); CreatureHealthMult = ((BaseUnityPlugin)this).Config.Bind<float>("Creatures", "HealthMultiplier", 1f, new ConfigDescription("Multiplier applied to all non-boss creature hitpoints. 1.0 = vanilla.", (AcceptableValueBase)(object)val2, new object[1] { val })); CreatureDamageMult = ((BaseUnityPlugin)this).Config.Bind<float>("Creatures", "DamageMultiplier", 1f, new ConfigDescription("Multiplier applied to all non-boss creature damage output. 1.0 = vanilla.", (AcceptableValueBase)(object)val2, new object[1] { val })); PerStarHealthMult = ((BaseUnityPlugin)this).Config.Bind<float>("Creatures", "PerStarHealthMultiplier", 1f, new ConfigDescription("Multiplier to creature health added per star level. 1.0 = vanilla star health scaling -> +100% health per star.NOTE: This is multiplicative with HealthMultiplier.", (AcceptableValueBase)(object)val2, new object[1] { val })); PerStarDamageMult = ((BaseUnityPlugin)this).Config.Bind<float>("Creatures", "PerStarDamageMultiplier", 1f, new ConfigDescription("Multiplier to creature damage added per star level. 1.0 = vanilla star damage scaling -> +50% damage per star.NOTE: This is multiplicative with DamageMultiplier.", (AcceptableValueBase)(object)val2, new object[1] { val })); BossHealthMult = ((BaseUnityPlugin)this).Config.Bind<float>("Bosses", "BossHealthMultiplier", 1f, new ConfigDescription("Multiplier applied to boss health. 1.0 = vanilla.", (AcceptableValueBase)(object)val2, new object[1] { val })); BossDamageMult = ((BaseUnityPlugin)this).Config.Bind<float>("Bosses", "BossDamageMultiplier", 1f, new ConfigDescription("Multiplier applied to all boss damage output. 1.0 = vanilla.", (AcceptableValueBase)(object)val2, new object[1] { val })); AdrenalineMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Adrenaline", "AdrenalineMultiplier", 1f, new ConfigDescription("Multiplier applied to adrenaline gained. Lower = harder (e.g. 0.5), higher = easier (e.g. 1.5). 1.0 = vanilla.", (AcceptableValueBase)(object)val2, new object[1] { val })); AdrenalineDecayMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Adrenaline", "AdrenalineDecayMultiplier", 1f, new ConfigDescription("Multiplier applied to adrenaline lost. Higher = harder (e.g. 1.5), lower = easier (e.g. 0.5). 1.0 = vanilla.", (AcceptableValueBase)(object)val2, new object[1] { val })); AdrenalineDecayDelayMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Adrenaline", "AdrenalineDecayDelayMultiplier", 1f, new ConfigDescription("Multiplier applied to the delay before adrenaline starts decaying. Lower = harder (e.g. 0.5), higher = easier (e.g. 1.5). 1.0 = vanilla.", (AcceptableValueBase)(object)val2, new object[1] { val })); VerboseLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("Diagnostics", "VerboseLogging", false, new ConfigDescription("Logs detailed per-hit and per-creature scaling information.", (AcceptableValueBase)null, Array.Empty<object>())); AcceptableValueRange<int> val3 = new AcceptableValueRange<int>(1, 50); UpperLeftSplitAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Split Buttons", "UpperLeftAmount", 1, new ConfigDescription("Split Amount", (AcceptableValueBase)(object)val3, Array.Empty<object>())); UpperRightSplitAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Split Buttons", "UpperRightAmount", 2, new ConfigDescription("Split Amount", (AcceptableValueBase)(object)val3, Array.Empty<object>())); LowerLeftSplitAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Split Buttons", "LowerLeftAmount", 10, new ConfigDescription("Split Amount", (AcceptableValueBase)(object)val3, Array.Empty<object>())); LowerRightSplitAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Split Buttons", "LowerRightAmount", 20, new ConfigDescription("Split Amount", (AcceptableValueBase)(object)val3, Array.Empty<object>())); AcceptableValueRange<int> val4 = new AcceptableValueRange<int>(1, 100); SkillBookBreakpoint = ((BaseUnityPlugin)this).Config.Bind<int>("Skill Book Limits", "SkillBookBreakpoint", 100, new ConfigDescription("Skill level past which costs double", (AcceptableValueBase)(object)val4, new object[1] { val })); SkillBookCap = ((BaseUnityPlugin)this).Config.Bind<int>("Skill Book Limits", "SkillBookCap", 100, new ConfigDescription("Max skill level trained with a skill book", (AcceptableValueBase)(object)val4, new object[1] { val })); harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"MTM Difficulty initialized."); } } [HarmonyPatch(typeof(SplitDialog), "OnEnable")] internal static class SplitDialogOnEnablePatch { private static void Postfix(SplitDialog __instance) { StackSplitButtons.Setup(__instance); } } internal static class StackSplitButtons { internal static void Setup(SplitDialog splitDialog) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) RectTransform groupRect; if (!((Object)(object)((Transform)splitDialog.m_panel).Find("StackSplitButtonGroup") != (Object)null)) { GameObject val = new GameObject("StackSplitButtonGroup", new Type[1] { typeof(RectTransform) }); groupRect = val.GetComponent<RectTransform>(); ((Transform)groupRect).SetParent((Transform)(object)splitDialog.m_panel, false); Vector2 anchoredPosition = default(Vector2); ((Vector2)(ref anchoredPosition))..ctor(10f, -63f); RectTransform obj = groupRect; RectTransform obj2 = groupRect; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(1f, 1f); obj2.anchorMax = val2; obj.anchorMin = val2; groupRect.pivot = new Vector2(1f, 1f); groupRect.sizeDelta = new Vector2(124f, 64f); groupRect.anchoredPosition = anchoredPosition; MakeButton(Plugin.UpperLeftSplitAmount.Value.ToString(), new Vector2(0f, 0f), delegate { splitDialog.SliderValue = Plugin.UpperLeftSplitAmount.Value; splitDialog.SplitOk(); }); MakeButton(Plugin.UpperRightSplitAmount.Value.ToString(), new Vector2(64f, 0f), delegate { splitDialog.SliderValue = Plugin.UpperRightSplitAmount.Value; splitDialog.SplitOk(); }); MakeButton(Plugin.LowerLeftSplitAmount.Value.ToString(), new Vector2(0f, -34f), delegate { splitDialog.SliderValue = Plugin.LowerLeftSplitAmount.Value; splitDialog.SplitOk(); }); MakeButton(Plugin.LowerRightSplitAmount.Value.ToString(), new Vector2(64f, -34f), delegate { splitDialog.SliderValue = Plugin.LowerRightSplitAmount.Value; splitDialog.SplitOk(); }); } GameObject MakeButton(string label, Vector2 position, Action onClick) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown GameObject obj3 = GUIManager.Instance.CreateButton(label, (Transform)(object)groupRect, new Vector2(0f, 1f), new Vector2(0f, 1f), position, 60f, 30f); ((UnityEvent)obj3.GetComponent<Button>().onClick).AddListener((UnityAction)delegate { onClick(); }); return obj3; } } } [HarmonyPatch(typeof(Player), "CanConsumeItem")] internal static class SkillBookConsumeGatePatch { private static void Postfix(Player __instance, ItemData item, ref bool __result) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) if (__result) { StatusEffect obj = item?.m_shared?.m_consumeStatusEffect; SkillBook_SE val = (SkillBook_SE)(object)((obj is SkillBook_SE) ? obj : null); if (val != null && ((Character)__instance).GetSkills().GetSkill(val.skillType).m_level >= (float)Plugin.SkillBookCap.Value) { ((Character)__instance).Message((MessageType)2, "$skill_" + ((object)Unsafe.As<SkillType, SkillType>(ref val.skillType)/*cast due to .constrained prefix*/).ToString().ToLower() + " is already capped at " + Plugin.SkillBookCap.Value, 0, (Sprite)null, false); __result = false; } } } } [HarmonyPatch(typeof(SkillBook_SE), "ApplySkillBook")] internal static class SkillBookCapPatch { private const float FullRateCredit = 1f; private const float HalfRateCredit = 0.5f; private static bool Prefix(SkillBook_SE __instance, Player ___player, ref bool ___shouldRemove) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)___player == (Object)null) { ___shouldRemove = true; return false; } Skill skill = ((Character)___player).GetSkills().GetSkill(__instance.skillType); if (skill.m_level >= (float)Plugin.SkillBookCap.Value) { ((Character)___player).Message((MessageType)2, "$skill_" + ((object)Unsafe.As<SkillType, SkillType>(ref __instance.skillType)/*cast due to .constrained prefix*/).ToString().ToLower() + " is capped at " + Plugin.SkillBookCap.Value, 0, (Sprite)null, false); ___shouldRemove = true; return false; } int num = __instance.bookTier switch { 1 => 1, 2 => 3, 3 => 5, _ => 1, }; bool flag = false; bool flag2 = false; for (int i = 0; i < num; i++) { if (!(skill.m_level < (float)Plugin.SkillBookCap.Value)) { break; } bool flag3 = skill.m_level >= (float)Plugin.SkillBookBreakpoint.Value; float credit = (flag3 ? 0.5f : 1f); if (ApplyCredit(skill, ___player, __instance.skillType, credit)) { if (flag3) { flag2 = true; } else { flag = true; } } } string text = "$skill_" + ((object)Unsafe.As<SkillType, SkillType>(ref __instance.skillType)/*cast due to .constrained prefix*/).ToString().ToLower(); if (flag2) { ((Character)___player).Message((MessageType)2, text + " increased to " + (int)skill.m_level + " — advanced training yields less", 0, skill.m_info?.m_icon, false); } else if (flag) { ((Character)___player).Message((MessageType)2, text + " increased to " + (int)skill.m_level, 0, skill.m_info?.m_icon, false); } else { ((Character)___player).Message((MessageType)2, text + " training progress recorded", 0, (Sprite)null, false); } ___shouldRemove = true; return false; } private static bool ApplyCredit(Skill skill, Player player, SkillType skillType, float credit) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) if (skill.m_level >= (float)Plugin.SkillBookCap.Value) { return false; } float nextLevelRequirement = skill.GetNextLevelRequirement(); float num = ((nextLevelRequirement > 0f) ? (skill.m_accumulator / nextLevelRequirement) : 0f); num += credit; bool result = false; while (num >= 1f && skill.m_level < (float)Plugin.SkillBookCap.Value) { num -= 1f; skill.m_level = Mathf.Clamp(skill.m_level + 1f, 0f, (float)Plugin.SkillBookCap.Value); player.OnSkillLevelup(skillType, skill.m_level); result = true; } float nextLevelRequirement2 = skill.GetNextLevelRequirement(); skill.m_accumulator = num * nextLevelRequirement2; return result; } }