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 BirdlanValheim v1.0.25
plugins/Codex-BossLootOneShot/BossLootOneShot.dll
Decompiled 2 weeks agousing System; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace Codex.BossLootOneShot; [BepInPlugin("codex.bosslootoneshot", "Boss Loot One Shot", "1.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(Ragdoll), "SpawnLoot")] private static class RagdollSpawnLootPatch { [HarmonyPrefix] private static bool Prefix(Ragdoll __instance) { suppressCurrentSpawnLoot = false; if ((Object)(object)__instance == (Object)null) { return true; } ZNetView component = ((Component)__instance).GetComponent<ZNetView>(); if ((Object)(object)component == (Object)null || !component.IsValid()) { return true; } if (!component.IsOwner()) { suppressCurrentSpawnLoot = true; return false; } ZDO zDO = component.GetZDO(); if (zDO == null) { return true; } if (zDO.GetBool("codex_ragdoll_loot_processed", false)) { suppressCurrentSpawnLoot = true; return false; } zDO.Set("codex_ragdoll_loot_processed", true); return true; } [HarmonyFinalizer] private static Exception Finalizer(Exception __exception) { suppressCurrentSpawnLoot = false; return __exception; } } private const string LootProcessedKey = "codex_ragdoll_loot_processed"; [ThreadStatic] private static bool suppressCurrentSpawnLoot; private Harmony harmony; private bool epicLootPatched; private void Awake() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown harmony = new Harmony("codex.bosslootoneshot"); harmony.PatchAll(typeof(Plugin).Assembly); PatchEpicLootCallback(); } private void Start() { PatchEpicLootCallback(); } private void PatchEpicLootCallback() { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown if (!epicLootPatched) { Type type = AccessTools.TypeByName("EpicLoot.Ragdoll_SpawnLoot_Patch"); MethodInfo methodInfo = ((type != null) ? AccessTools.Method(type, "Postfix", (Type[])null, (Type[])null) : null); MethodInfo methodInfo2 = AccessTools.Method(typeof(Plugin), "GuardEpicLootCallback", (Type[])null, (Type[])null); if (methodInfo != null && methodInfo2 != null) { harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); epicLootPatched = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"EpicLoot ragdoll loot callback is protected against repeated SpawnLoot calls."); } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)"EpicLoot ragdoll loot callback was not found; vanilla ragdoll one-shot protection remains active."); } } } private static bool GuardEpicLootCallback() { return !suppressCurrentSpawnLoot; } }
plugins/Codex-CreatureStarDamageCurve/CreatureStarDamageCurve.dll
Decompiled 2 weeks agousing System; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using HarmonyLib; using UnityEngine; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyVersion("0.0.0.0")] namespace Codex.CreatureStarDamageCurve; [BepInPlugin("codex.creaturestardamagecurve", "Creature Star Damage Curve", "1.0.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { private void Awake() { //IL_003f: 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_0069: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(AccessTools.TypeByName("CreatureManager.CreatureLevelManager"), "TrySelectDamageMultiplier", (Type[])null, (Type[])null); if (methodInfo == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"CreatureManager damage method was not found; star damage curve was not applied."); return; } new Harmony("codex.creaturestardamagecurve").Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin).GetMethod("ApplyDamageCurve", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Creature star damage scaling is linear: +100% base damage per star."); } private static void ApplyDamageCurve(Character character, ref float multiplier) { if (!((Object)(object)character == (Object)null) && !character.IsPlayer() && !(multiplier <= 0f)) { } } }
plugins/Codex-EnforcerBossProgression/EnforcerBossProgression.dll
Decompiled 2 weeks agousing System; using System.Collections; using System.Collections.Generic; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using HarmonyLib; using UnityEngine; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyVersion("0.0.0.0")] namespace Codex.EnforcerBossProgression; [BepInPlugin("codex.enforcerbossprogression", "Enforcer Boss Progression", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { private sealed class RemovedCandidate { internal int Index; internal object Value; } private static readonly Dictionary<string, string> RequiredKeys = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) { { "Eikthyr", "defeated_eikthyr" }, { "gd_king", "defeated_gdking" }, { "Bonemass", "defeated_bonemass" }, { "Dragon", "defeated_dragon" }, { "GoblinKing", "defeated_goblinking" }, { "SeekerQueen", "defeated_queen" }, { "Fader", "defeated_fader" }, { "FrozenKing", "defeated_frozenking_p3" }, { "FrozenKing_p2", "defeated_frozenking_p3" }, { "FrozenKing_p3", "defeated_frozenking_p3" } }; private void Awake() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_0086: Expected O, but got Unknown //IL_0086: Expected O, but got Unknown Type type = AccessTools.TypeByName("CreatureManager.CreatureKarmaManager"); MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "TrySelectEnforcerCandidate", (Type[])null, (Type[])null)); if (methodInfo == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"CreatureManager Enforcer selection method was not found."); return; } new Harmony("codex.enforcerbossprogression").Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(Plugin), "FilterLockedBosses", (Type[])null), new HarmonyMethod(typeof(Plugin), "RestoreLockedBosses", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Enforcer bosses are locked behind their world defeat keys."); } private static void FilterLockedBosses(IList candidates, out List<RemovedCandidate> __state) { __state = new List<RemovedCandidate>(); if (candidates == null || (Object)(object)ZoneSystem.instance == (Object)null) { return; } for (int num = candidates.Count - 1; num >= 0; num--) { object obj = candidates[num]; string bossPrefab = GetBossPrefab(obj); if (RequiredKeys.TryGetValue(bossPrefab, out var value) && !ZoneSystem.instance.GetGlobalKey(value)) { __state.Add(new RemovedCandidate { Index = num, Value = obj }); candidates.RemoveAt(num); } } } private static void RestoreLockedBosses(IList candidates, List<RemovedCandidate> __state) { if (candidates != null && __state != null) { for (int num = __state.Count - 1; num >= 0; num--) { RemovedCandidate removedCandidate = __state[num]; candidates.Insert(removedCandidate.Index, removedCandidate.Value); } } } private static string GetBossPrefab(object candidate) { if (candidate == null) { return ""; } FieldInfo fieldInfo = AccessTools.Field(candidate.GetType(), "Summon"); object obj = ((fieldInfo == null) ? null : fieldInfo.GetValue(candidate)); if (obj == null) { return ""; } FieldInfo fieldInfo2 = AccessTools.Field(obj.GetType(), "Boss"); return (fieldInfo2 == null) ? "" : ((fieldInfo2.GetValue(obj) as string) ?? ""); } }
plugins/Codex-EpicLootCraftFromChests/EpicLootCraftFromChests.dll
Decompiled 2 weeks agousing System; using System.Collections; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Logging; using HarmonyLib; using UnityEngine; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyVersion("0.0.0.0")] namespace Codex.EpicLootCraftFromChests; [BepInPlugin("codex.epiclootcraftfromchests", "Epic Loot Craft From Chests", "1.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { private static Type _inventoryManagement; private static Type _chestSource; private static Type _tableUi; private static MethodInfo _nearby; private static MethodInfo _count; private static MethodInfo _consume; private static PropertyInfo _instance; private static ManualLogSource _log; private static string _lastRequirementDiagnostic; private void Awake() { //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Expected O, but got Unknown //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Expected O, but got Unknown //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Expected O, but got Unknown //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Expected O, but got Unknown _log = ((BaseUnityPlugin)this).Logger; _inventoryManagement = FindType("EpicLoot_UnityLib.InventoryManagement"); _chestSource = FindType("NoVikingLeftBehind.ChestSource"); _tableUi = FindType("EpicLoot_UnityLib.EnchantingTableUI"); if (_inventoryManagement == null || _chestSource == null || _tableUi == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"EpicLoot or NoVikingLeftBehind API was not found; chest bridge was not applied."); return; } _nearby = AccessTools.Method(_chestSource, "Nearby", (Type[])null, (Type[])null); _count = AccessTools.Method(_chestSource, "Count", (Type[])null, (Type[])null); _consume = AccessTools.Method(_chestSource, "Consume", (Type[])null, (Type[])null); _instance = AccessTools.Property(_tableUi, "instance"); MethodInfo methodInfo = AccessTools.Method(_inventoryManagement, "CountItem", new Type[1] { typeof(string) }, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(_inventoryManagement, "RemoveItem", new Type[2] { typeof(string), typeof(int) }, (Type[])null); if (_nearby == null || _count == null || _consume == null || _instance == null || methodInfo == null || methodInfo2 == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"A required CraftFromChests bridge method was not found; patch was not applied."); return; } Harmony val = new Harmony("codex.epiclootcraftfromchests"); val.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin).GetMethod("CountItemPostfix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(Plugin).GetMethod("RemoveItemPrefix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo methodInfo3 = AccessTools.Method(typeof(Player), "HaveRequirements", new Type[4] { typeof(Recipe), typeof(bool), typeof(int), typeof(int) }, (Type[])null); MethodInfo methodInfo4 = AccessTools.Method(typeof(Player), "ConsumeResources", new Type[4] { typeof(Requirement[]), typeof(int), typeof(int), typeof(int) }, (Type[])null); if (methodInfo3 != null && methodInfo4 != null) { val.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, LastPostfix("HaveRequirementsPostfix"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo methodInfo5 = AccessTools.Method(typeof(Player), "HaveRequirementItems", new Type[4] { typeof(Recipe), typeof(bool), typeof(int), typeof(int) }, (Type[])null); if (methodInfo5 != null) { val.Patch((MethodBase)methodInfo5, (HarmonyMethod)null, LastPostfix("HaveRequirementItemsPostfix"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } val.Patch((MethodBase)methodInfo4, new HarmonyMethod(typeof(Plugin).GetMethod("ConsumeResourcesPrefix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Valheim crafting requirement and consumption bridge applied."); } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Valheim crafting bridge methods were not found; only EpicLoot enchanting is patched."); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"EpicLoot enchanting table now uses nearby NoVikingLeftBehind chests."); } private static Type FindType(string fullName) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { Type type = assembly.GetType(fullName, throwOnError: false); if (type != null) { return type; } } return null; } private static HarmonyMethod LastPostfix(string methodName) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown HarmonyMethod val = new HarmonyMethod(typeof(Plugin).GetMethod(methodName, BindingFlags.Static | BindingFlags.NonPublic)); val.priority = 0; return val; } private static bool IsEnchantingTableOpen() { if (_instance == null) { return false; } object? value = _instance.GetValue(null); Component val = (Component)((value is Component) ? value : null); return (Object)(object)val != (Object)null && val.gameObject.activeInHierarchy; } private static IList NearbyChests() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || _nearby == null) { return null; } return _nearby.Invoke(null, new object[1] { ((Component)localPlayer).transform.position }) as IList; } private static int ChestCount(string itemName, IList chests) { if (chests == null || _count == null) { return 0; } return Convert.ToInt32(_count.Invoke(null, new object[3] { itemName, chests, -1 })); } private static int ConsumeFromChests(string itemName, int amount, IList chests) { if (amount <= 0 || chests == null || _consume == null) { return 0; } return Convert.ToInt32(_consume.Invoke(null, new object[4] { itemName, amount, -1, chests })); } private static void CountItemPostfix(string item, ref int __result) { if (IsEnchantingTableOpen()) { __result += ChestCount(item, NearbyChests()); } } private static bool RemoveItemPrefix(string item, int amount) { if (!IsEnchantingTableOpen()) { return true; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || amount <= 0) { return true; } Inventory inventory = ((Humanoid)localPlayer).GetInventory(); int num = Math.Min(amount, inventory.CountItems(item, -1, true)); if (num > 0) { inventory.RemoveItem(item, num, -1, true); } int num2 = amount - num; if (num2 > 0) { ConsumeFromChests(item, num2, NearbyChests()); } return false; } private static void HaveRequirementsPostfix(Recipe recipe, bool discover, int qualityLevel, int amount, ref bool __result) { if (!__result && !((Object)(object)recipe == (Object)null) && recipe.m_resources != null && !((Object)(object)Player.m_localPlayer == (Object)null) && HasRequiredStationForNewCraft(recipe, qualityLevel) && CanCoverRequirements(recipe.m_resources, qualityLevel, amount)) { __result = true; } } private static void HaveRequirementItemsPostfix(Recipe piece, bool discover, int qualityLevel, int amount, ref bool __result) { if (!__result && !((Object)(object)piece == (Object)null) && piece.m_resources != null && !((Object)(object)Player.m_localPlayer == (Object)null) && HasRequiredStationForNewCraft(piece, qualityLevel) && CanCoverRequirements(piece.m_resources, qualityLevel, amount)) { __result = true; } } private static bool HasRequiredStationForNewCraft(Recipe recipe, int qualityLevel) { if (qualityLevel > 1 || (Object)(object)recipe.m_craftingStation == (Object)null) { return true; } CraftingStation currentCraftingStation = Player.m_localPlayer.GetCurrentCraftingStation(); return (Object)(object)currentCraftingStation != (Object)null && currentCraftingStation.GetLevel(true) >= recipe.m_minStationLevel; } private static bool ConsumeResourcesPrefix(Requirement[] requirements, int qualityLevel, int itemQuality, int multiplier) { if (requirements == null || (Object)(object)Player.m_localPlayer == (Object)null) { return true; } if (!NeedsChestMaterials(requirements, qualityLevel, multiplier)) { return true; } if (!CanCoverRequirements(requirements, qualityLevel, multiplier)) { return true; } Inventory inventory = ((Humanoid)Player.m_localPlayer).GetInventory(); IList chests = NearbyChests(); foreach (Requirement val in requirements) { if (!IsConsumableRequirement(val)) { continue; } string text = RequirementItemName(val); if (!string.IsNullOrEmpty(text)) { int num = val.GetAmount(qualityLevel) * multiplier; int num2 = Math.Min(num, inventory.CountItems(text, -1, true)); if (num2 > 0) { inventory.RemoveItem(text, num2, -1, true); } int num3 = num - num2; if (num3 > 0) { ConsumeFromChests(text, num3, chests); } } } return false; } private static bool NeedsChestMaterials(Requirement[] requirements, int qualityLevel, int multiplier) { Inventory inventory = ((Humanoid)Player.m_localPlayer).GetInventory(); foreach (Requirement val in requirements) { if (IsConsumableRequirement(val)) { int num = val.GetAmount(qualityLevel) * multiplier; string text = RequirementItemName(val); if (!string.IsNullOrEmpty(text) && inventory.CountItems(text, -1, true) < num) { return true; } } } return false; } private static bool CanCoverRequirements(Requirement[] requirements, int qualityLevel, int multiplier) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return false; } Inventory inventory = ((Humanoid)localPlayer).GetInventory(); IList chests = NearbyChests(); foreach (Requirement val in requirements) { if (!IsConsumableRequirement(val)) { continue; } string text = RequirementItemName(val); if (!string.IsNullOrEmpty(text)) { int num = val.GetAmount(qualityLevel) * multiplier; int num2 = inventory.CountItems(text, -1, true); int num3 = ChestCount(text, chests); int num4 = num2 + num3; if (num4 < num) { return false; } } } return true; } private static bool IsConsumableRequirement(Requirement requirement) { if (requirement == null || (Object)(object)requirement.m_resItem == (Object)null) { return false; } if (requirement.m_upgraderResource) { return false; } string text = RequirementItemName(requirement); return string.IsNullOrEmpty(text) || text.IndexOf("$item_upgrader_", StringComparison.Ordinal) < 0; } private static void LogRequirementDiagnostic(string itemName, int required, int carried, int chestCount, int containerCount) { string text = $"Requirement {itemName}: need={required}, player={carried}, chests={chestCount}, nearbyContainers={containerCount}"; if (!(text == _lastRequirementDiagnostic)) { _lastRequirementDiagnostic = text; if (_log != null) { _log.LogInfo((object)text); } } } private static string RequirementItemName(Requirement requirement) { if (requirement == null || (Object)(object)requirement.m_resItem == (Object)null || requirement.m_resItem.m_itemData == null || requirement.m_resItem.m_itemData.m_shared == null) { return null; } return requirement.m_resItem.m_itemData.m_shared.m_name; } }
plugins/Codex-EpicLootDisenchantKeepItem/EpicLootDisenchantKeepItem.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using EpicLoot.CraftingV2; using EpicLoot_UnityLib; using HarmonyLib; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace Codex.EpicLootDisenchantKeepItem; [BepInPlugin("codex.epiclootdisenchantkeepitem", "Epic Loot Disenchant Keep Item", "1.0.0")] public sealed class Plugin : BaseUnityPlugin { private void Awake() { //IL_0063: 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_0078: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(typeof(EnchantingUIController), "DisenchantItem", (Type[])null, (Type[])null); MethodInfo method = typeof(Plugin).GetMethod("DisenchantPostfix", BindingFlags.Static | BindingFlags.NonPublic); if (methodInfo == null || method == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Could not find EpicLoot's DisenchantItem method; patch was not applied."); return; } new Harmony("codex.epiclootdisenchantkeepitem").Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(method), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Disenchant now keeps the item and gives no materials."); } private static void DisenchantPostfix(ref List<InventoryItemListElement> __result, ref bool bonusRolled) { if (__result != null) { __result.Clear(); } bonusRolled = false; } }
plugins/Codex-EpicLootMovementSpeedCap/EpicLootMovementSpeedCap.dll
Decompiled 2 weeks agousing System; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using HarmonyLib; using UnityEngine; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyVersion("0.0.0.0")] namespace Codex.EpicLootMovementSpeedCap; [BepInPlugin("codex.epiclootmovementspeedcap", "Epic Loot Movement Speed Cap", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { private const float MaximumEpicLootBonus = 0.75f; private void Awake() { //IL_0062: 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: Expected O, but got Unknown Type type = FindType("EpicLoot.MagicItemEffects.ModifyMovementSpeed"); MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "GetModifyMovementSpeedAmount", new Type[1] { typeof(Player) }, (Type[])null)); if (methodInfo == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"EpicLoot movement-speed calculation was not found; cap was not applied."); return; } new Harmony("codex.epiclootmovementspeedcap").Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin).GetMethod("CapPostfix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Total movement-speed bonus supplied by EpicLoot is capped at +75%."); } private static Type FindType(string fullName) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { Type type = assembly.GetType(fullName, throwOnError: false); if (type != null) { return type; } } return null; } private static void CapPostfix(ref float __result) { __result = Mathf.Min(__result, 0.75f); } }
plugins/Codex-EpicLootRecallOwnerLock/EpicLootRecallOwnerLock.dll
Decompiled 2 weeks agousing System; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyVersion("0.0.0.0")] namespace Codex.EpicLootRecallOwnerLock; [BepInPlugin("codex.epiclootrecallownerlock", "Epic Loot Recall Owner Lock", "1.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { private const string OwnerKey = "codex_recall_owner"; private const string ExpiryKey = "codex_recall_expiry"; private static ConfigEntry<int> _lockSeconds; private static FieldInfo _itemDropNview; private static FieldInfo _projectileOwner; private void Awake() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Expected O, but got Unknown //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Expected O, but got Unknown //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Expected O, but got Unknown //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Expected O, but got Unknown _lockSeconds = ((BaseUnityPlugin)this).Config.Bind<int>("General", "OwnerLockSeconds", 30, new ConfigDescription("Seconds that only the original thrower may pick up a recalled weapon.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 120), new object[0])); Type type = FindType("EpicLoot.MagicItemEffects.RecallWeapon_Projectile_SpawnOnHit_Patch"); if (type == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"EpicLoot Recall implementation was not found; owner lock was not applied."); return; } MethodInfo methodInfo = AccessTools.Method(type, "IssueItemRecall", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(ItemDrop), "Interact", new Type[3] { typeof(Humanoid), typeof(bool), typeof(bool) }, (Type[])null); MethodInfo methodInfo3 = AccessTools.Method(typeof(ItemDrop), "Pickup", new Type[1] { typeof(Humanoid) }, (Type[])null); _itemDropNview = AccessTools.Field(typeof(ItemDrop), "m_nview"); _projectileOwner = AccessTools.Field(typeof(Projectile), "m_owner"); if (methodInfo == null || methodInfo2 == null || methodInfo3 == null || _itemDropNview == null || _projectileOwner == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"A required Recall or ItemDrop method was not found; owner lock was not applied."); return; } Harmony val = new Harmony("codex.epiclootrecallownerlock"); val.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(Plugin).GetMethod("RecallPrefix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(Plugin).GetMethod("PickupPrefix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)methodInfo3, new HarmonyMethod(typeof(Plugin).GetMethod("AutoPickupPrefix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Recall weapons are now owner-locked against manual and automatic pickup for " + _lockSeconds.Value + " seconds.")); } private static Type FindType(string fullName) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { Type type = assembly.GetType(fullName, throwOnError: false); if (type != null) { return type; } } return null; } private static void RecallPrefix(object[] __args) { if (__args == null || __args.Length < 2) { return; } object obj = __args[0]; ItemDrop itemDrop = (ItemDrop)((obj is ItemDrop) ? obj : null); object obj2 = __args[1]; Projectile val = (Projectile)((obj2 is Projectile) ? obj2 : null); Player val2 = (Player)(((Object)(object)val != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null); ZNetView nview = GetNview(itemDrop); if (!((Object)(object)nview == (Object)null) && nview.IsValid() && !((Object)(object)val2 == (Object)null)) { ZDO zDO = nview.GetZDO(); if (zDO != null) { double num = (((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.GetTimeSeconds() : 0.0); zDO.Set("codex_recall_owner", val2.GetPlayerID()); zDO.Set("codex_recall_expiry", (long)Math.Ceiling(num + (double)Math.Max(1, _lockSeconds.Value))); } } } private static bool PickupPrefix(ItemDrop __instance, object[] __args) { ZNetView nview = GetNview(__instance); if ((Object)(object)nview == (Object)null || !nview.IsValid() || __args == null || __args.Length < 1) { return true; } object obj = __args[0]; return CanPickup(__instance, (Player)((obj is Player) ? obj : null)); } private static bool AutoPickupPrefix(ItemDrop __instance, Humanoid character) { return CanPickup(__instance, (Player)(object)((character is Player) ? character : null)); } private static bool CanPickup(ItemDrop itemDrop, Player player) { ZNetView nview = GetNview(itemDrop); if ((Object)(object)nview == (Object)null || !nview.IsValid() || (Object)(object)player == (Object)null) { return true; } ZDO zDO = nview.GetZDO(); if (zDO == null) { return true; } long num = zDO.GetLong("codex_recall_owner", 0L); long num2 = zDO.GetLong("codex_recall_expiry", 0L); double num3 = (((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.GetTimeSeconds() : 0.0); if (num != 0 && (double)num2 > num3 && num != player.GetPlayerID()) { ((Character)player).Message((MessageType)2, "This recalled weapon belongs to another Viking.", 0, (Sprite)null, false); return false; } return true; } private static ZNetView GetNview(ItemDrop itemDrop) { return (ZNetView)(((Object)(object)itemDrop != (Object)null && _itemDropNview != null) ? /*isinst with value type is only supported in some contexts*/: null); } }
plugins/Codex-EpicLootRecallTracker/EpicLootRecallTracker.dll
Decompiled 2 weeks agousing System; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyVersion("0.0.0.0")] namespace Codex.EpicLootRecallTracker; [BepInPlugin("codex.epiclootrecalltracker", "Epic Loot Recall Compass", "2.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { private static FieldInfo _itemDropNview; private static FieldInfo _projectileOwner; private static bool _tracking; private static ZDOID _trackedId; private static Vector3 _lastPosition; private static float _lastSeenAt; private static float _nextHudUpdate; private static object _compass; private static MethodInfo _showCompass; private static MethodInfo _hideCompass; private static MethodInfo _setHint; private static MethodInfo _setItems; private static ConfigEntry<float> _hideDistance; private static ConfigEntry<float> _maxTrackingMinutes; private void Awake() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Expected O, but got Unknown _hideDistance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "HideDistance", 3f, new ConfigDescription("Stop tracking after the recalled item disappears this close to its owner.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), new object[0])); _maxTrackingMinutes = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MaxTrackingMinutes", 30f, new ConfigDescription("Safety timeout for a weapon that can no longer be recovered.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 180f), new object[0])); _itemDropNview = AccessTools.Field(typeof(ItemDrop), "m_nview"); _projectileOwner = AccessTools.Field(typeof(Projectile), "m_owner"); Type type = FindType("EpicLoot.MagicItemEffects.RecallWeapon_Projectile_SpawnOnHit_Patch"); Type type2 = FindType("NoVikingLeftBehind.GraveCompassHud"); if (_itemDropNview == null || _projectileOwner == null || type == null || type2 == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"EpicLoot Recall or NVLB GraveCompass was not found; recall compass was not applied."); return; } MethodInfo methodInfo = AccessTools.Method(type, "IssueItemRecall", new Type[2] { typeof(ItemDrop), typeof(Projectile) }, (Type[])null); _showCompass = AccessTools.Method(type2, "Show", new Type[3] { typeof(Player), typeof(Vector3), typeof(float) }, (Type[])null); _hideCompass = AccessTools.Method(type2, "Hide", (Type[])null, (Type[])null); _setHint = AccessTools.Method(type2, "SetHint", new Type[1] { typeof(string) }, (Type[])null); _setItems = AccessTools.Method(type2, "SetItems", new Type[1] { typeof(int) }, (Type[])null); if (methodInfo == null || _showCompass == null || _hideCompass == null || _setHint == null || _setItems == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"A required Recall/GraveCompass method was not found; recall compass was not applied."); return; } _compass = type2; SetField(type2, "Offset", (object)new Vector2(0f, 145f)); SetField(type2, "ArrowChar", "^"); SetField(type2, "ArrowScale", 1.6f); SetField(type2, "EdgeMode", true); SetField(type2, "EdgeMargin", 60f); SetField(type2, "HintAlpha", 0.85f); SetField(type2, "HintScale", 0.8f); _setItems.Invoke(null, new object[1] { 0 }); new Harmony("codex.epiclootrecalltracker").Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(Plugin).GetMethod("RecallPrefix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Recall tracker now uses the NVLB GraveCompass HUD with distance and X/Z coordinates."); } private static Type FindType(string fullName) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { Type type = assembly.GetType(fullName, throwOnError: false); if (type != null) { return type; } } return null; } private static void SetField(Type type, string name, object value) { FieldInfo fieldInfo = AccessTools.Field(type, name); if (fieldInfo != null) { fieldInfo.SetValue(null, value); } } private static void RecallPrefix(ItemDrop item, Projectile projectile) { //IL_0087: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) Player val = (Player)(((Object)(object)projectile != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null); if (!((Object)(object)val == (Object)null) && !((Object)(object)val != (Object)(object)Player.m_localPlayer) && !((Object)(object)item == (Object)null)) { object? value = _itemDropNview.GetValue(item); ZNetView val2 = (ZNetView)((value is ZNetView) ? value : null); if (!((Object)(object)val2 == (Object)null) && val2.IsValid() && val2.GetZDO() != null) { _trackedId = val2.GetZDO().m_uid; _lastPosition = ((Component)item).transform.position; _lastSeenAt = Time.time; _nextHudUpdate = 0f; _tracking = true; HideCompass(); } } } private void Update() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) if (!_tracking || (Object)(object)Player.m_localPlayer == (Object)null || _compass == null) { return; } ZNetScene instance = ZNetScene.instance; GameObject val = (((Object)(object)instance != (Object)null) ? instance.FindInstance(_trackedId) : null); if ((Object)(object)val != (Object)null) { _lastPosition = val.transform.position; _lastSeenAt = Time.time; } else { float num = Vector3.Distance(((Component)Player.m_localPlayer).transform.position, _lastPosition); if (num <= _hideDistance.Value) { StopTracking(); return; } if (Time.time - _lastSeenAt >= _maxTrackingMinutes.Value * 60f) { StopTracking(); return; } } if (!(Time.time < _nextHudUpdate)) { _nextHudUpdate = Time.time + 0.1f; float num2 = Vector3.Distance(((Component)Player.m_localPlayer).transform.position, _lastPosition); string arg = (((Object)(object)val == (Object)null) ? " · LAST KNOWN" : ""); string text = $"Recall Weapon · X {_lastPosition.x:0} Z {_lastPosition.z:0}{arg}"; _setHint.Invoke(null, new object[1] { text }); _showCompass.Invoke(null, new object[3] { Player.m_localPlayer, _lastPosition, num2 }); } } private static void HideCompass() { if (_compass != null && _hideCompass != null) { _hideCompass.Invoke(null, null); } } private static void StopTracking() { _tracking = false; HideCompass(); } private void OnDestroy() { StopTracking(); } }
plugins/Codex-EpicLootResistanceCap/EpicLootResistanceCap.dll
Decompiled 2 weeks agousing System; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace Codex.EpicLootResistanceCap; [BepInPlugin("codex.epiclootresistancecap", "Epic Loot Resistance Cap", "1.0.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { private sealed class CapturedDamage { internal float Value; internal float Blunt; internal float Slash; internal float Pierce; internal float Chop; internal float Pickaxe; internal float Fire; internal float Frost; internal float Lightning; internal float Poison; internal float Spirit; } [HarmonyPatch(typeof(Character), "RPC_Damage")] private static class CaptureIncomingMonsterDamage { [HarmonyPriority(800)] [HarmonyPrefix] private static void Prefix(Character __instance, HitData hit) { if (IsHostileMonsterHit(__instance, hit)) { capturedDamage.Remove(hit); capturedDamage.Add(hit, new CapturedDamage { Value = Mathf.Max(0f, hit.GetTotalDamage()), Blunt = hit.m_damage.m_blunt, Slash = hit.m_damage.m_slash, Pierce = hit.m_damage.m_pierce, Chop = hit.m_damage.m_chop, Pickaxe = hit.m_damage.m_pickaxe, Fire = hit.m_damage.m_fire, Frost = hit.m_damage.m_frost, Lightning = hit.m_damage.m_lightning, Poison = hit.m_damage.m_poison, Spirit = hit.m_damage.m_spirit }); } } } [HarmonyPatch(typeof(Character), "RPC_Damage")] private static class CapResistanceBeforeZeroDamageEarlyExit { [HarmonyPrefix] [HarmonyPriority(0)] private static void Prefix(Character __instance, HitData hit) { if (IsHostileMonsterHit(__instance, hit) && capturedDamage.TryGetValue(hit, out var value)) { float remaining = 1f - Mathf.Clamp((maximumResistance != null) ? maximumResistance.Value : 75f, 0f, 95f) / 100f; RestoreFloor(ref hit.m_damage.m_blunt, value.Blunt, remaining); RestoreFloor(ref hit.m_damage.m_slash, value.Slash, remaining); RestoreFloor(ref hit.m_damage.m_pierce, value.Pierce, remaining); RestoreFloor(ref hit.m_damage.m_chop, value.Chop, remaining); RestoreFloor(ref hit.m_damage.m_pickaxe, value.Pickaxe, remaining); RestoreFloor(ref hit.m_damage.m_fire, value.Fire, remaining); RestoreFloor(ref hit.m_damage.m_frost, value.Frost, remaining); RestoreFloor(ref hit.m_damage.m_lightning, value.Lightning, remaining); RestoreFloor(ref hit.m_damage.m_poison, value.Poison, remaining); RestoreFloor(ref hit.m_damage.m_spirit, value.Spirit, remaining); } } private static void RestoreFloor(ref float current, float original, float remaining) { if (original > 0f) { current = Mathf.Max(current, original * remaining); } } } [HarmonyPatch(typeof(Character), "ApplyDamage")] private static class EnforceFinalMonsterDamageFloor { [HarmonyPriority(0)] [HarmonyPrefix] private static void Prefix(Character __instance, HitData hit) { if (!IsHostileMonsterHit(__instance, hit) || !capturedDamage.TryGetValue(hit, out var value)) { return; } capturedDamage.Remove(hit); float value2 = value.Value; if (!(value2 <= 0f)) { float num = ((hostileMonsterDamageFloor != null) ? hostileMonsterDamageFloor.Value : 5f); float num2 = ((minimumMonsterDamage != null) ? minimumMonsterDamage.Value : 1f); float num3 = Mathf.Max(num2, value2 * Mathf.Clamp(num, 0f, 100f) / 100f); float num4 = Mathf.Max(0f, hit.GetTotalDamage()); if (num4 < num3) { ref DamageTypes damage = ref hit.m_damage; damage.m_damage += num3 - num4; } } } } private static ConfigEntry<float> maximumResistance; private static ConfigEntry<float> hostileMonsterDamageFloor; private static ConfigEntry<float> minimumMonsterDamage; private static readonly ConditionalWeakTable<HitData, CapturedDamage> capturedDamage = new ConditionalWeakTable<HitData, CapturedDamage>(); private void Awake() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Expected O, but got Unknown //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Expected O, but got Unknown maximumResistance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MaximumResistancePercent", 75f, new ConfigDescription("Maximum combined EpicLoot resistance for every physical and elemental damage type. Values below 100 prevent immunity.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 95f), new object[0])); hostileMonsterDamageFloor = ((BaseUnityPlugin)this).Config.Bind<float>("General", "HostileMonsterFinalDamageFloorPercent", 5f, new ConfigDescription("Minimum final damage from hostile monsters as a percentage of damage before resistance and armor.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), new object[0])); minimumMonsterDamage = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MinimumHostileMonsterDamage", 1f, new ConfigDescription("Absolute minimum final damage for a valid hostile-monster hit.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), new object[0])); Type type = FindType("EpicLoot.MagicItemEffects.ModifyResistance"); MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "GetCappedResistanceValue", new Type[3] { typeof(Player), typeof(string), typeof(float) }, (Type[])null)); MethodInfo method = typeof(Plugin).GetMethod("CapRemainingDamageMultiplier", BindingFlags.Static | BindingFlags.NonPublic); if (methodInfo == null || method == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"EpicLoot resistance calculation was not found; resistance cap was not applied."); return; } HarmonyMethod val = new HarmonyMethod(method); val.priority = 0; Harmony val2 = new Harmony("codex.epiclootresistancecap"); val2.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val2.PatchAll(typeof(Plugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Combined EpicLoot physical and elemental resistance is capped at " + maximumResistance.Value + "%.")); } private static Type FindType(string fullName) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { Type type = assembly.GetType(fullName, throwOnError: false); if (type != null) { return type; } } return null; } private static void CapRemainingDamageMultiplier(ref float __result) { float num = ((maximumResistance != null) ? maximumResistance.Value : 75f); float num2 = 1f - Mathf.Clamp(num, 0f, 95f) / 100f; __result = Mathf.Max(__result, num2); } private static bool IsHostileMonsterHit(Character target, HitData hit) { //IL_0059: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Invalid comparison between Unknown and I4 if ((Object)(object)target == (Object)null || hit == null || !target.IsPlayer()) { return false; } Character attacker = hit.GetAttacker(); if ((Object)(object)attacker != (Object)null) { return !attacker.IsPlayer() && !attacker.IsTamed() && (int)attacker.GetFaction() != 11; } return hit.m_attacker != ZDOID.None; } }
plugins/Codex-EpicLootRuneUiFix/EpicLootRuneUiFix.dll
Decompiled 2 weeks agousing System; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using HarmonyLib; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyVersion("0.0.0.0")] namespace Codex.EpicLootRuneUiFix; [BepInPlugin("codex.epiclootruneuifix", "Epic Loot Rune UI Fix", "1.6.6")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { public sealed class ManualRuneListScroller : MonoBehaviour, IScrollHandler, IEventSystemHandler { private const float TopOverscrollPixels = 90f; public RectTransform Content; public Scrollbar Bar; private RectTransform _viewport; private float _topY; private bool _initialized; private bool _topOverscrolled; private void Awake() { ref RectTransform viewport = ref _viewport; Transform transform = ((Component)this).transform; viewport = (RectTransform)(object)((transform is RectTransform) ? transform : null); } private void LateUpdate() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Content == (Object)null) && !((Object)(object)Bar == (Object)null) && !((Object)(object)_viewport == (Object)null)) { Rect rect = _viewport.rect; float num = Mathf.Max(1f, ((Rect)(ref rect)).height); LayoutRebuilder.ForceRebuildLayoutImmediate(Content); float preferredHeight = LayoutUtility.GetPreferredHeight(Content); float num2 = 0f; if (((Transform)Content).childCount > 0) { Bounds val = RectTransformUtility.CalculateRelativeRectTransformBounds((Transform)(object)Content); num2 = ((Bounds)(ref val)).size.y; } Rect rect2 = Content.rect; float num3 = Mathf.Max(num, Mathf.Max(((Rect)(ref rect2)).height, Mathf.Max(preferredHeight, num2))); float num4 = Mathf.Max(0f, num3 - num); Rect rect3 = Content.rect; if (num3 > ((Rect)(ref rect3)).height + 0.5f) { Content.SetSizeWithCurrentAnchors((Axis)1, num3); } if (!_initialized) { _topY = Content.anchoredPosition.y; Bar.SetValueWithoutNotify(1f); ((UnityEvent<float>)(object)Bar.onValueChanged).AddListener((UnityAction<float>)SetScrollValue); _initialized = true; } Bar.size = Mathf.Clamp01(num / num3); ((Selectable)Bar).interactable = num4 > 0.5f; ((Component)Bar).gameObject.SetActive(true); } } public void OnScroll(PointerEventData eventData) { //IL_001d: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Bar == (Object)null || !((Selectable)Bar).interactable) { return; } float y = eventData.scrollDelta.y; if (y > 0f && Bar.value >= 0.999f) { Content.anchoredPosition = new Vector2(Content.anchoredPosition.x, _topY - 90f); _topOverscrolled = true; return; } if (_topOverscrolled) { Content.anchoredPosition = new Vector2(Content.anchoredPosition.x, _topY); _topOverscrolled = false; } Bar.value = Mathf.Clamp01(Bar.value + y * 0.32f); } private void SetScrollValue(float value) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Content == (Object)null) && !((Object)(object)_viewport == (Object)null)) { Rect rect = Content.rect; float height = ((Rect)(ref rect)).height; Rect rect2 = _viewport.rect; float num = Mathf.Max(0f, height - ((Rect)(ref rect2)).height); Content.anchoredPosition = new Vector2(Content.anchoredPosition.x, _topY + (1f - value) * num); } } } public sealed class RuneUiLayerGuard : MonoBehaviour { public Transform Window; public Canvas WindowCanvas; public Canvas ParentCanvas; private void LateUpdate() { if ((Object)(object)Window != (Object)null) { Window.SetAsLastSibling(); } if ((Object)(object)WindowCanvas != (Object)null) { WindowCanvas.overrideSorting = true; WindowCanvas.sortingOrder = (((Object)(object)ParentCanvas != (Object)null) ? ParentCanvas.sortingOrder : 0) + 1000; } } } private static FieldInfo _availableRunesWindow; private static FieldInfo _enchantList; private void Awake() { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown Type type = FindType("EpicLoot_UnityLib.RuneUI"); if (type == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"EpicLoot RuneUI type was not found; UI fix was not applied."); return; } _availableRunesWindow = AccessTools.Field(type, "AvailableRunesWindow"); _enchantList = AccessTools.Field(type, "EnchantList"); MethodInfo methodInfo = AccessTools.Method(type, "OnEnable", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(type, "UpdateDisplayAvailableOverwriteEnchantments", (Type[])null, (Type[])null); if (_availableRunesWindow == null || _enchantList == null || methodInfo == null || methodInfo2 == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"EpicLoot RuneUI layout members were not found; UI fix was not applied."); return; } HarmonyMethod val = new HarmonyMethod(typeof(Plugin).GetMethod("FixRuneUiPostfix", BindingFlags.Static | BindingFlags.NonPublic)); Harmony val2 = new Harmony("codex.epiclootruneuifix"); val2.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val2.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"EpicLoot rune overwrite panel click-layer fix applied."); } private static Type FindType(string fullName) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { Type type = assembly.GetType(fullName, throwOnError: false); if (type != null) { return type; } } return null; } private static void FixRuneUiPostfix(object __instance) { object? value = _availableRunesWindow.GetValue(__instance); GameObject val = (GameObject)((value is GameObject) ? value : null); if ((Object)(object)val == (Object)null) { return; } object? value2 = _enchantList.GetValue(__instance); RectTransform val2 = (RectTransform)((value2 is RectTransform) ? value2 : null); val.transform.SetAsLastSibling(); Canvas val3 = (((Object)(object)val.transform.parent != (Object)null) ? ((Component)val.transform.parent).GetComponentInParent<Canvas>() : null); Canvas val4 = val.GetComponent<Canvas>(); if ((Object)(object)val4 == (Object)null) { val4 = val.AddComponent<Canvas>(); } val4.overrideSorting = true; val4.sortingOrder = (((Object)(object)val3 != (Object)null) ? val3.sortingOrder : 0) + 1000; if ((Object)(object)val.GetComponent<GraphicRaycaster>() == (Object)null) { val.AddComponent<GraphicRaycaster>(); } CanvasGroup val5 = val.GetComponent<CanvasGroup>(); if ((Object)(object)val5 == (Object)null) { val5 = val.AddComponent<CanvasGroup>(); } val5.interactable = true; val5.blocksRaycasts = true; RectTransform val6 = FindViewport(val2); if ((Object)(object)val6 != (Object)null) { if ((Object)(object)((Component)val6).GetComponent<RectMask2D>() == (Object)null) { ((Component)val6).gameObject.AddComponent<RectMask2D>(); } ScrollRect componentInParent = ((Component)val2).GetComponentInParent<ScrollRect>(); if ((Object)(object)componentInParent != (Object)null) { componentInParent.viewport = val6; componentInParent.content = val2; componentInParent.horizontal = false; componentInParent.vertical = true; componentInParent.movementType = (MovementType)2; componentInParent.scrollSensitivity = 32f; } EnsureVerticalScrollbar(componentInParent, val6, val2); } RuneUiLayerGuard runeUiLayerGuard = val.GetComponent<RuneUiLayerGuard>(); if ((Object)(object)runeUiLayerGuard == (Object)null) { runeUiLayerGuard = val.AddComponent<RuneUiLayerGuard>(); } runeUiLayerGuard.Window = val.transform; runeUiLayerGuard.WindowCanvas = val4; runeUiLayerGuard.ParentCanvas = val3; } private static RectTransform FindViewport(RectTransform content) { if ((Object)(object)content == (Object)null) { return null; } Transform parent = ((Transform)content).parent; while ((Object)(object)parent != (Object)null) { RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null); if ((Object)(object)val != (Object)null && (((Object)parent).name.IndexOf("viewport", StringComparison.OrdinalIgnoreCase) >= 0 || (Object)(object)((Component)parent).GetComponent<Mask>() != (Object)null || (Object)(object)((Component)parent).GetComponent<RectMask2D>() != (Object)null)) { return val; } if ((Object)(object)((Component)parent).GetComponent<ScrollRect>() != (Object)null) { return val; } parent = parent.parent; } Transform parent2 = ((Transform)content).parent; return (RectTransform)(object)((parent2 is RectTransform) ? parent2 : null); } private static void EnsureVerticalScrollbar(ScrollRect scrollRect, RectTransform viewport, RectTransform content) { //IL_0030: 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) //IL_00ad: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Expected O, but got Unknown //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: 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_022d: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)viewport == (Object)null || (Object)(object)content == (Object)null) { return; } Image val = ((Component)viewport).GetComponent<Image>(); if ((Object)(object)val == (Object)null) { val = ((Component)viewport).gameObject.AddComponent<Image>(); ((Graphic)val).color = Color.clear; } ((Graphic)val).raycastTarget = true; Scrollbar val2 = (((Object)(object)scrollRect != (Object)null) ? scrollRect.verticalScrollbar : null); if ((Object)(object)val2 == (Object)null) { GameObject val3 = new GameObject("CodexVerticalScrollbar", new Type[4] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image), typeof(Scrollbar) }); RectTransform component = val3.GetComponent<RectTransform>(); ((Transform)component).SetParent((Transform)(object)viewport, false); component.anchorMin = new Vector2(1f, 0f); component.anchorMax = new Vector2(1f, 1f); component.pivot = new Vector2(1f, 0.5f); component.anchoredPosition = new Vector2(-2f, 0f); component.sizeDelta = new Vector2(12f, -4f); Image component2 = val3.GetComponent<Image>(); ((Graphic)component2).color = new Color(0.08f, 0.06f, 0.04f, 0.85f); GameObject val4 = new GameObject("Handle", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }); RectTransform component3 = val4.GetComponent<RectTransform>(); ((Transform)component3).SetParent((Transform)(object)component, false); component3.anchorMin = Vector2.zero; component3.anchorMax = Vector2.one; component3.offsetMin = new Vector2(2f, 2f); component3.offsetMax = new Vector2(-2f, -2f); Image component4 = val4.GetComponent<Image>(); ((Graphic)component4).color = new Color(1f, 0.55f, 0.08f, 1f); val2 = val3.GetComponent<Scrollbar>(); val2.handleRect = component3; ((Selectable)val2).targetGraphic = (Graphic)(object)component4; val2.direction = (Direction)2; Scrollbar obj = val2; Navigation navigation = default(Navigation); ((Navigation)(ref navigation)).mode = (Mode)0; ((Selectable)obj).navigation = navigation; if ((Object)(object)scrollRect != (Object)null) { scrollRect.verticalScrollbar = val2; scrollRect.verticalScrollbarVisibility = (ScrollbarVisibility)0; scrollRect.verticalScrollbarSpacing = 2f; } } ((Component)val2).gameObject.SetActive(true); ((Selectable)val2).interactable = true; if ((Object)(object)scrollRect != (Object)null) { ((Behaviour)scrollRect).enabled = false; } ManualRuneListScroller manualRuneListScroller = ((Component)viewport).GetComponent<ManualRuneListScroller>(); if ((Object)(object)manualRuneListScroller == (Object)null) { manualRuneListScroller = ((Component)viewport).gameObject.AddComponent<ManualRuneListScroller>(); } manualRuneListScroller.Content = content; manualRuneListScroller.Bar = val2; } }
plugins/Codex-EpicLootRuneUiFix-1.6.3/EpicLootRuneUiFix.dll
Decompiled 2 weeks agousing System; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using HarmonyLib; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyVersion("0.0.0.0")] namespace Codex.EpicLootRuneUiFix; [BepInPlugin("codex.epiclootruneuifix", "Epic Loot Rune UI Fix", "1.6.3")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { public sealed class ManualRuneListScroller : MonoBehaviour, IScrollHandler, IEventSystemHandler { private const float TopRevealPadding = 36f; public RectTransform Content; public Scrollbar Bar; private RectTransform _viewport; private float _topY; private bool _initialized; private void Awake() { ref RectTransform viewport = ref _viewport; Transform transform = ((Component)this).transform; viewport = (RectTransform)(object)((transform is RectTransform) ? transform : null); } private void LateUpdate() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Content == (Object)null) && !((Object)(object)Bar == (Object)null) && !((Object)(object)_viewport == (Object)null)) { Rect rect = _viewport.rect; float num = Mathf.Max(1f, ((Rect)(ref rect)).height); LayoutRebuilder.ForceRebuildLayoutImmediate(Content); float preferredHeight = LayoutUtility.GetPreferredHeight(Content); float num2 = 0f; if (((Transform)Content).childCount > 0) { Bounds val = RectTransformUtility.CalculateRelativeRectTransformBounds((Transform)(object)Content); num2 = ((Bounds)(ref val)).size.y; } Rect rect2 = Content.rect; float num3 = Mathf.Max(((Rect)(ref rect2)).height, Mathf.Max(preferredHeight, num2)); float num4 = Mathf.Max(num, num3 + 36f); float num5 = Mathf.Max(0f, num4 - num); Rect rect3 = Content.rect; if (num4 > ((Rect)(ref rect3)).height + 0.5f) { Content.SetSizeWithCurrentAnchors((Axis)1, num4); } if (!_initialized) { _topY = Content.anchoredPosition.y - 36f; Content.anchoredPosition = new Vector2(Content.anchoredPosition.x, _topY); Bar.SetValueWithoutNotify(1f); ((UnityEvent<float>)(object)Bar.onValueChanged).AddListener((UnityAction<float>)SetScrollValue); _initialized = true; } Bar.size = Mathf.Clamp01(num / num4); ((Selectable)Bar).interactable = num5 > 0.5f; ((Component)Bar).gameObject.SetActive(true); } } public void OnScroll(PointerEventData eventData) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Bar == (Object)null) && ((Selectable)Bar).interactable) { Bar.value = Mathf.Clamp01(Bar.value + eventData.scrollDelta.y * 0.32f); } } private void SetScrollValue(float value) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Content == (Object)null) && !((Object)(object)_viewport == (Object)null)) { Rect rect = Content.rect; float height = ((Rect)(ref rect)).height; Rect rect2 = _viewport.rect; float num = Mathf.Max(0f, height - ((Rect)(ref rect2)).height); Content.anchoredPosition = new Vector2(Content.anchoredPosition.x, _topY + (1f - value) * num); } } } public sealed class RuneUiLayerGuard : MonoBehaviour { public Transform Window; public Canvas WindowCanvas; public Canvas ParentCanvas; private void LateUpdate() { if ((Object)(object)Window != (Object)null) { Window.SetAsLastSibling(); } if ((Object)(object)WindowCanvas != (Object)null) { WindowCanvas.overrideSorting = true; WindowCanvas.sortingOrder = (((Object)(object)ParentCanvas != (Object)null) ? ParentCanvas.sortingOrder : 0) + 1000; } } } private static FieldInfo _availableRunesWindow; private static FieldInfo _enchantList; private void Awake() { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown Type type = FindType("EpicLoot_UnityLib.RuneUI"); if (type == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"EpicLoot RuneUI type was not found; UI fix was not applied."); return; } _availableRunesWindow = AccessTools.Field(type, "AvailableRunesWindow"); _enchantList = AccessTools.Field(type, "EnchantList"); MethodInfo methodInfo = AccessTools.Method(type, "OnEnable", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(type, "UpdateDisplayAvailableOverwriteEnchantments", (Type[])null, (Type[])null); if (_availableRunesWindow == null || _enchantList == null || methodInfo == null || methodInfo2 == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"EpicLoot RuneUI layout members were not found; UI fix was not applied."); return; } HarmonyMethod val = new HarmonyMethod(typeof(Plugin).GetMethod("FixRuneUiPostfix", BindingFlags.Static | BindingFlags.NonPublic)); Harmony val2 = new Harmony("codex.epiclootruneuifix"); val2.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val2.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"EpicLoot rune overwrite panel click-layer fix applied."); } private static Type FindType(string fullName) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { Type type = assembly.GetType(fullName, throwOnError: false); if (type != null) { return type; } } return null; } private static void FixRuneUiPostfix(object __instance) { object? value = _availableRunesWindow.GetValue(__instance); GameObject val = (GameObject)((value is GameObject) ? value : null); if ((Object)(object)val == (Object)null) { return; } object? value2 = _enchantList.GetValue(__instance); RectTransform val2 = (RectTransform)((value2 is RectTransform) ? value2 : null); val.transform.SetAsLastSibling(); Canvas val3 = (((Object)(object)val.transform.parent != (Object)null) ? ((Component)val.transform.parent).GetComponentInParent<Canvas>() : null); Canvas val4 = val.GetComponent<Canvas>(); if ((Object)(object)val4 == (Object)null) { val4 = val.AddComponent<Canvas>(); } val4.overrideSorting = true; val4.sortingOrder = (((Object)(object)val3 != (Object)null) ? val3.sortingOrder : 0) + 1000; if ((Object)(object)val.GetComponent<GraphicRaycaster>() == (Object)null) { val.AddComponent<GraphicRaycaster>(); } CanvasGroup val5 = val.GetComponent<CanvasGroup>(); if ((Object)(object)val5 == (Object)null) { val5 = val.AddComponent<CanvasGroup>(); } val5.interactable = true; val5.blocksRaycasts = true; RectTransform val6 = FindViewport(val2); if ((Object)(object)val6 != (Object)null) { if ((Object)(object)((Component)val6).GetComponent<RectMask2D>() == (Object)null) { ((Component)val6).gameObject.AddComponent<RectMask2D>(); } ScrollRect componentInParent = ((Component)val2).GetComponentInParent<ScrollRect>(); if ((Object)(object)componentInParent != (Object)null) { componentInParent.viewport = val6; componentInParent.content = val2; componentInParent.horizontal = false; componentInParent.vertical = true; componentInParent.movementType = (MovementType)2; componentInParent.scrollSensitivity = 32f; } EnsureVerticalScrollbar(componentInParent, val6, val2); } RuneUiLayerGuard runeUiLayerGuard = val.GetComponent<RuneUiLayerGuard>(); if ((Object)(object)runeUiLayerGuard == (Object)null) { runeUiLayerGuard = val.AddComponent<RuneUiLayerGuard>(); } runeUiLayerGuard.Window = val.transform; runeUiLayerGuard.WindowCanvas = val4; runeUiLayerGuard.ParentCanvas = val3; } private static RectTransform FindViewport(RectTransform content) { if ((Object)(object)content == (Object)null) { return null; } Transform parent = ((Transform)content).parent; while ((Object)(object)parent != (Object)null) { RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null); if ((Object)(object)val != (Object)null && (((Object)parent).name.IndexOf("viewport", StringComparison.OrdinalIgnoreCase) >= 0 || (Object)(object)((Component)parent).GetComponent<Mask>() != (Object)null || (Object)(object)((Component)parent).GetComponent<RectMask2D>() != (Object)null)) { return val; } if ((Object)(object)((Component)parent).GetComponent<ScrollRect>() != (Object)null) { return val; } parent = parent.parent; } Transform parent2 = ((Transform)content).parent; return (RectTransform)(object)((parent2 is RectTransform) ? parent2 : null); } private static void EnsureVerticalScrollbar(ScrollRect scrollRect, RectTransform viewport, RectTransform content) { //IL_0030: 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) //IL_00ad: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Expected O, but got Unknown //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: 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_022d: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)viewport == (Object)null || (Object)(object)content == (Object)null) { return; } Image val = ((Component)viewport).GetComponent<Image>(); if ((Object)(object)val == (Object)null) { val = ((Component)viewport).gameObject.AddComponent<Image>(); ((Graphic)val).color = Color.clear; } ((Graphic)val).raycastTarget = true; Scrollbar val2 = (((Object)(object)scrollRect != (Object)null) ? scrollRect.verticalScrollbar : null); if ((Object)(object)val2 == (Object)null) { GameObject val3 = new GameObject("CodexVerticalScrollbar", new Type[4] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image), typeof(Scrollbar) }); RectTransform component = val3.GetComponent<RectTransform>(); ((Transform)component).SetParent((Transform)(object)viewport, false); component.anchorMin = new Vector2(1f, 0f); component.anchorMax = new Vector2(1f, 1f); component.pivot = new Vector2(1f, 0.5f); component.anchoredPosition = new Vector2(-2f, 0f); component.sizeDelta = new Vector2(12f, -4f); Image component2 = val3.GetComponent<Image>(); ((Graphic)component2).color = new Color(0.08f, 0.06f, 0.04f, 0.85f); GameObject val4 = new GameObject("Handle", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }); RectTransform component3 = val4.GetComponent<RectTransform>(); ((Transform)component3).SetParent((Transform)(object)component, false); component3.anchorMin = Vector2.zero; component3.anchorMax = Vector2.one; component3.offsetMin = new Vector2(2f, 2f); component3.offsetMax = new Vector2(-2f, -2f); Image component4 = val4.GetComponent<Image>(); ((Graphic)component4).color = new Color(1f, 0.55f, 0.08f, 1f); val2 = val3.GetComponent<Scrollbar>(); val2.handleRect = component3; ((Selectable)val2).targetGraphic = (Graphic)(object)component4; val2.direction = (Direction)2; Scrollbar obj = val2; Navigation navigation = default(Navigation); ((Navigation)(ref navigation)).mode = (Mode)0; ((Selectable)obj).navigation = navigation; if ((Object)(object)scrollRect != (Object)null) { scrollRect.verticalScrollbar = val2; scrollRect.verticalScrollbarVisibility = (ScrollbarVisibility)0; scrollRect.verticalScrollbarSpacing = 2f; } } ((Component)val2).gameObject.SetActive(true); ((Selectable)val2).interactable = true; if ((Object)(object)scrollRect != (Object)null) { ((Behaviour)scrollRect).enabled = false; } ManualRuneListScroller manualRuneListScroller = ((Component)viewport).GetComponent<ManualRuneListScroller>(); if ((Object)(object)manualRuneListScroller == (Object)null) { manualRuneListScroller = ((Component)viewport).gameObject.AddComponent<ManualRuneListScroller>(); } manualRuneListScroller.Content = content; manualRuneListScroller.Bar = val2; } }
plugins/Codex-EpicLootRuneUiFix-1.6.4/EpicLootRuneUiFix.dll
Decompiled 2 weeks agousing System; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using HarmonyLib; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyVersion("0.0.0.0")] namespace Codex.EpicLootRuneUiFix; [BepInPlugin("codex.epiclootruneuifix", "Epic Loot Rune UI Fix", "1.6.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { public sealed class ManualRuneListScroller : MonoBehaviour, IScrollHandler, IEventSystemHandler { public RectTransform Content; public Scrollbar Bar; private RectTransform _viewport; private float _topY; private bool _initialized; private void Awake() { ref RectTransform viewport = ref _viewport; Transform transform = ((Component)this).transform; viewport = (RectTransform)(object)((transform is RectTransform) ? transform : null); } private void LateUpdate() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Content == (Object)null) && !((Object)(object)Bar == (Object)null) && !((Object)(object)_viewport == (Object)null)) { Rect rect = _viewport.rect; float num = Mathf.Max(1f, ((Rect)(ref rect)).height); LayoutRebuilder.ForceRebuildLayoutImmediate(Content); float preferredHeight = LayoutUtility.GetPreferredHeight(Content); float num2 = 0f; if (((Transform)Content).childCount > 0) { Bounds val = RectTransformUtility.CalculateRelativeRectTransformBounds((Transform)(object)Content); num2 = ((Bounds)(ref val)).size.y; } Rect rect2 = Content.rect; float num3 = Mathf.Max(num, Mathf.Max(((Rect)(ref rect2)).height, Mathf.Max(preferredHeight, num2))); float num4 = Mathf.Max(0f, num3 - num); Rect rect3 = Content.rect; if (num3 > ((Rect)(ref rect3)).height + 0.5f) { Content.SetSizeWithCurrentAnchors((Axis)1, num3); } if (!_initialized) { _topY = Content.anchoredPosition.y; Bar.SetValueWithoutNotify(1f); ((UnityEvent<float>)(object)Bar.onValueChanged).AddListener((UnityAction<float>)SetScrollValue); _initialized = true; } Bar.size = Mathf.Clamp01(num / num3); ((Selectable)Bar).interactable = num4 > 0.5f; ((Component)Bar).gameObject.SetActive(true); } } public void OnScroll(PointerEventData eventData) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Bar == (Object)null) && ((Selectable)Bar).interactable) { Bar.value = Mathf.Clamp01(Bar.value + eventData.scrollDelta.y * 0.32f); } } private void SetScrollValue(float value) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Content == (Object)null) && !((Object)(object)_viewport == (Object)null)) { Rect rect = Content.rect; float height = ((Rect)(ref rect)).height; Rect rect2 = _viewport.rect; float num = Mathf.Max(0f, height - ((Rect)(ref rect2)).height); Content.anchoredPosition = new Vector2(Content.anchoredPosition.x, _topY + (1f - value) * num); } } } public sealed class RuneUiLayerGuard : MonoBehaviour { public Transform Window; public Canvas WindowCanvas; public Canvas ParentCanvas; private void LateUpdate() { if ((Object)(object)Window != (Object)null) { Window.SetAsLastSibling(); } if ((Object)(object)WindowCanvas != (Object)null) { WindowCanvas.overrideSorting = true; WindowCanvas.sortingOrder = (((Object)(object)ParentCanvas != (Object)null) ? ParentCanvas.sortingOrder : 0) + 1000; } } } private static FieldInfo _availableRunesWindow; private static FieldInfo _enchantList; private void Awake() { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown Type type = FindType("EpicLoot_UnityLib.RuneUI"); if (type == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"EpicLoot RuneUI type was not found; UI fix was not applied."); return; } _availableRunesWindow = AccessTools.Field(type, "AvailableRunesWindow"); _enchantList = AccessTools.Field(type, "EnchantList"); MethodInfo methodInfo = AccessTools.Method(type, "OnEnable", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(type, "UpdateDisplayAvailableOverwriteEnchantments", (Type[])null, (Type[])null); if (_availableRunesWindow == null || _enchantList == null || methodInfo == null || methodInfo2 == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"EpicLoot RuneUI layout members were not found; UI fix was not applied."); return; } HarmonyMethod val = new HarmonyMethod(typeof(Plugin).GetMethod("FixRuneUiPostfix", BindingFlags.Static | BindingFlags.NonPublic)); Harmony val2 = new Harmony("codex.epiclootruneuifix"); val2.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val2.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"EpicLoot rune overwrite panel click-layer fix applied."); } private static Type FindType(string fullName) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { Type type = assembly.GetType(fullName, throwOnError: false); if (type != null) { return type; } } return null; } private static void FixRuneUiPostfix(object __instance) { object? value = _availableRunesWindow.GetValue(__instance); GameObject val = (GameObject)((value is GameObject) ? value : null); if ((Object)(object)val == (Object)null) { return; } object? value2 = _enchantList.GetValue(__instance); RectTransform val2 = (RectTransform)((value2 is RectTransform) ? value2 : null); val.transform.SetAsLastSibling(); Canvas val3 = (((Object)(object)val.transform.parent != (Object)null) ? ((Component)val.transform.parent).GetComponentInParent<Canvas>() : null); Canvas val4 = val.GetComponent<Canvas>(); if ((Object)(object)val4 == (Object)null) { val4 = val.AddComponent<Canvas>(); } val4.overrideSorting = true; val4.sortingOrder = (((Object)(object)val3 != (Object)null) ? val3.sortingOrder : 0) + 1000; if ((Object)(object)val.GetComponent<GraphicRaycaster>() == (Object)null) { val.AddComponent<GraphicRaycaster>(); } CanvasGroup val5 = val.GetComponent<CanvasGroup>(); if ((Object)(object)val5 == (Object)null) { val5 = val.AddComponent<CanvasGroup>(); } val5.interactable = true; val5.blocksRaycasts = true; RectTransform val6 = FindViewport(val2); if ((Object)(object)val6 != (Object)null) { if ((Object)(object)((Component)val6).GetComponent<RectMask2D>() == (Object)null) { ((Component)val6).gameObject.AddComponent<RectMask2D>(); } ScrollRect componentInParent = ((Component)val2).GetComponentInParent<ScrollRect>(); if ((Object)(object)componentInParent != (Object)null) { componentInParent.viewport = val6; componentInParent.content = val2; componentInParent.horizontal = false; componentInParent.vertical = true; componentInParent.movementType = (MovementType)2; componentInParent.scrollSensitivity = 32f; } EnsureVerticalScrollbar(componentInParent, val6, val2); } RuneUiLayerGuard runeUiLayerGuard = val.GetComponent<RuneUiLayerGuard>(); if ((Object)(object)runeUiLayerGuard == (Object)null) { runeUiLayerGuard = val.AddComponent<RuneUiLayerGuard>(); } runeUiLayerGuard.Window = val.transform; runeUiLayerGuard.WindowCanvas = val4; runeUiLayerGuard.ParentCanvas = val3; } private static RectTransform FindViewport(RectTransform content) { if ((Object)(object)content == (Object)null) { return null; } Transform parent = ((Transform)content).parent; while ((Object)(object)parent != (Object)null) { RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null); if ((Object)(object)val != (Object)null && (((Object)parent).name.IndexOf("viewport", StringComparison.OrdinalIgnoreCase) >= 0 || (Object)(object)((Component)parent).GetComponent<Mask>() != (Object)null || (Object)(object)((Component)parent).GetComponent<RectMask2D>() != (Object)null)) { return val; } if ((Object)(object)((Component)parent).GetComponent<ScrollRect>() != (Object)null) { return val; } parent = parent.parent; } Transform parent2 = ((Transform)content).parent; return (RectTransform)(object)((parent2 is RectTransform) ? parent2 : null); } private static void EnsureVerticalScrollbar(ScrollRect scrollRect, RectTransform viewport, RectTransform content) { //IL_0030: 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) //IL_00ad: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Expected O, but got Unknown //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: 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_022d: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)viewport == (Object)null || (Object)(object)content == (Object)null) { return; } Image val = ((Component)viewport).GetComponent<Image>(); if ((Object)(object)val == (Object)null) { val = ((Component)viewport).gameObject.AddComponent<Image>(); ((Graphic)val).color = Color.clear; } ((Graphic)val).raycastTarget = true; Scrollbar val2 = (((Object)(object)scrollRect != (Object)null) ? scrollRect.verticalScrollbar : null); if ((Object)(object)val2 == (Object)null) { GameObject val3 = new GameObject("CodexVerticalScrollbar", new Type[4] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image), typeof(Scrollbar) }); RectTransform component = val3.GetComponent<RectTransform>(); ((Transform)component).SetParent((Transform)(object)viewport, false); component.anchorMin = new Vector2(1f, 0f); component.anchorMax = new Vector2(1f, 1f); component.pivot = new Vector2(1f, 0.5f); component.anchoredPosition = new Vector2(-2f, 0f); component.sizeDelta = new Vector2(12f, -4f); Image component2 = val3.GetComponent<Image>(); ((Graphic)component2).color = new Color(0.08f, 0.06f, 0.04f, 0.85f); GameObject val4 = new GameObject("Handle", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }); RectTransform component3 = val4.GetComponent<RectTransform>(); ((Transform)component3).SetParent((Transform)(object)component, false); component3.anchorMin = Vector2.zero; component3.anchorMax = Vector2.one; component3.offsetMin = new Vector2(2f, 2f); component3.offsetMax = new Vector2(-2f, -2f); Image component4 = val4.GetComponent<Image>(); ((Graphic)component4).color = new Color(1f, 0.55f, 0.08f, 1f); val2 = val3.GetComponent<Scrollbar>(); val2.handleRect = component3; ((Selectable)val2).targetGraphic = (Graphic)(object)component4; val2.direction = (Direction)2; Scrollbar obj = val2; Navigation navigation = default(Navigation); ((Navigation)(ref navigation)).mode = (Mode)0; ((Selectable)obj).navigation = navigation; if ((Object)(object)scrollRect != (Object)null) { scrollRect.verticalScrollbar = val2; scrollRect.verticalScrollbarVisibility = (ScrollbarVisibility)0; scrollRect.verticalScrollbarSpacing = 2f; } } ((Component)val2).gameObject.SetActive(true); ((Selectable)val2).interactable = true; if ((Object)(object)scrollRect != (Object)null) { ((Behaviour)scrollRect).enabled = false; } ManualRuneListScroller manualRuneListScroller = ((Component)viewport).GetComponent<ManualRuneListScroller>(); if ((Object)(object)manualRuneListScroller == (Object)null) { manualRuneListScroller = ((Component)viewport).gameObject.AddComponent<ManualRuneListScroller>(); } manualRuneListScroller.Content = content; manualRuneListScroller.Bar = val2; } }
plugins/Codex-EpicLootRuneUiFix-1.6.5/EpicLootRuneUiFix.dll
Decompiled 2 weeks agousing System; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using HarmonyLib; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyVersion("0.0.0.0")] namespace Codex.EpicLootRuneUiFix; [BepInPlugin("codex.epiclootruneuifix", "Epic Loot Rune UI Fix", "1.6.5")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { public sealed class ManualRuneListScroller : MonoBehaviour, IScrollHandler, IEventSystemHandler { private const float TopOverscrollPixels = 40f; public RectTransform Content; public Scrollbar Bar; private RectTransform _viewport; private float _topY; private bool _initialized; private bool _topOverscrolled; private void Awake() { ref RectTransform viewport = ref _viewport; Transform transform = ((Component)this).transform; viewport = (RectTransform)(object)((transform is RectTransform) ? transform : null); } private void LateUpdate() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Content == (Object)null) && !((Object)(object)Bar == (Object)null) && !((Object)(object)_viewport == (Object)null)) { Rect rect = _viewport.rect; float num = Mathf.Max(1f, ((Rect)(ref rect)).height); LayoutRebuilder.ForceRebuildLayoutImmediate(Content); float preferredHeight = LayoutUtility.GetPreferredHeight(Content); float num2 = 0f; if (((Transform)Content).childCount > 0) { Bounds val = RectTransformUtility.CalculateRelativeRectTransformBounds((Transform)(object)Content); num2 = ((Bounds)(ref val)).size.y; } Rect rect2 = Content.rect; float num3 = Mathf.Max(num, Mathf.Max(((Rect)(ref rect2)).height, Mathf.Max(preferredHeight, num2))); float num4 = Mathf.Max(0f, num3 - num); Rect rect3 = Content.rect; if (num3 > ((Rect)(ref rect3)).height + 0.5f) { Content.SetSizeWithCurrentAnchors((Axis)1, num3); } if (!_initialized) { _topY = Content.anchoredPosition.y; Bar.SetValueWithoutNotify(1f); ((UnityEvent<float>)(object)Bar.onValueChanged).AddListener((UnityAction<float>)SetScrollValue); _initialized = true; } Bar.size = Mathf.Clamp01(num / num3); ((Selectable)Bar).interactable = num4 > 0.5f; ((Component)Bar).gameObject.SetActive(true); } } public void OnScroll(PointerEventData eventData) { //IL_001d: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Bar == (Object)null || !((Selectable)Bar).interactable) { return; } float y = eventData.scrollDelta.y; if (y > 0f && Bar.value >= 0.999f) { Content.anchoredPosition = new Vector2(Content.anchoredPosition.x, _topY - 40f); _topOverscrolled = true; return; } if (_topOverscrolled) { Content.anchoredPosition = new Vector2(Content.anchoredPosition.x, _topY); _topOverscrolled = false; } Bar.value = Mathf.Clamp01(Bar.value + y * 0.32f); } private void SetScrollValue(float value) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Content == (Object)null) && !((Object)(object)_viewport == (Object)null)) { Rect rect = Content.rect; float height = ((Rect)(ref rect)).height; Rect rect2 = _viewport.rect; float num = Mathf.Max(0f, height - ((Rect)(ref rect2)).height); Content.anchoredPosition = new Vector2(Content.anchoredPosition.x, _topY + (1f - value) * num); } } } public sealed class RuneUiLayerGuard : MonoBehaviour { public Transform Window; public Canvas WindowCanvas; public Canvas ParentCanvas; private void LateUpdate() { if ((Object)(object)Window != (Object)null) { Window.SetAsLastSibling(); } if ((Object)(object)WindowCanvas != (Object)null) { WindowCanvas.overrideSorting = true; WindowCanvas.sortingOrder = (((Object)(object)ParentCanvas != (Object)null) ? ParentCanvas.sortingOrder : 0) + 1000; } } } private static FieldInfo _availableRunesWindow; private static FieldInfo _enchantList; private void Awake() { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown Type type = FindType("EpicLoot_UnityLib.RuneUI"); if (type == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"EpicLoot RuneUI type was not found; UI fix was not applied."); return; } _availableRunesWindow = AccessTools.Field(type, "AvailableRunesWindow"); _enchantList = AccessTools.Field(type, "EnchantList"); MethodInfo methodInfo = AccessTools.Method(type, "OnEnable", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(type, "UpdateDisplayAvailableOverwriteEnchantments", (Type[])null, (Type[])null); if (_availableRunesWindow == null || _enchantList == null || methodInfo == null || methodInfo2 == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"EpicLoot RuneUI layout members were not found; UI fix was not applied."); return; } HarmonyMethod val = new HarmonyMethod(typeof(Plugin).GetMethod("FixRuneUiPostfix", BindingFlags.Static | BindingFlags.NonPublic)); Harmony val2 = new Harmony("codex.epiclootruneuifix"); val2.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val2.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"EpicLoot rune overwrite panel click-layer fix applied."); } private static Type FindType(string fullName) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { Type type = assembly.GetType(fullName, throwOnError: false); if (type != null) { return type; } } return null; } private static void FixRuneUiPostfix(object __instance) { object? value = _availableRunesWindow.GetValue(__instance); GameObject val = (GameObject)((value is GameObject) ? value : null); if ((Object)(object)val == (Object)null) { return; } object? value2 = _enchantList.GetValue(__instance); RectTransform val2 = (RectTransform)((value2 is RectTransform) ? value2 : null); val.transform.SetAsLastSibling(); Canvas val3 = (((Object)(object)val.transform.parent != (Object)null) ? ((Component)val.transform.parent).GetComponentInParent<Canvas>() : null); Canvas val4 = val.GetComponent<Canvas>(); if ((Object)(object)val4 == (Object)null) { val4 = val.AddComponent<Canvas>(); } val4.overrideSorting = true; val4.sortingOrder = (((Object)(object)val3 != (Object)null) ? val3.sortingOrder : 0) + 1000; if ((Object)(object)val.GetComponent<GraphicRaycaster>() == (Object)null) { val.AddComponent<GraphicRaycaster>(); } CanvasGroup val5 = val.GetComponent<CanvasGroup>(); if ((Object)(object)val5 == (Object)null) { val5 = val.AddComponent<CanvasGroup>(); } val5.interactable = true; val5.blocksRaycasts = true; RectTransform val6 = FindViewport(val2); if ((Object)(object)val6 != (Object)null) { if ((Object)(object)((Component)val6).GetComponent<RectMask2D>() == (Object)null) { ((Component)val6).gameObject.AddComponent<RectMask2D>(); } ScrollRect componentInParent = ((Component)val2).GetComponentInParent<ScrollRect>(); if ((Object)(object)componentInParent != (Object)null) { componentInParent.viewport = val6; componentInParent.content = val2; componentInParent.horizontal = false; componentInParent.vertical = true; componentInParent.movementType = (MovementType)2; componentInParent.scrollSensitivity = 32f; } EnsureVerticalScrollbar(componentInParent, val6, val2); } RuneUiLayerGuard runeUiLayerGuard = val.GetComponent<RuneUiLayerGuard>(); if ((Object)(object)runeUiLayerGuard == (Object)null) { runeUiLayerGuard = val.AddComponent<RuneUiLayerGuard>(); } runeUiLayerGuard.Window = val.transform; runeUiLayerGuard.WindowCanvas = val4; runeUiLayerGuard.ParentCanvas = val3; } private static RectTransform FindViewport(RectTransform content) { if ((Object)(object)content == (Object)null) { return null; } Transform parent = ((Transform)content).parent; while ((Object)(object)parent != (Object)null) { RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null); if ((Object)(object)val != (Object)null && (((Object)parent).name.IndexOf("viewport", StringComparison.OrdinalIgnoreCase) >= 0 || (Object)(object)((Component)parent).GetComponent<Mask>() != (Object)null || (Object)(object)((Component)parent).GetComponent<RectMask2D>() != (Object)null)) { return val; } if ((Object)(object)((Component)parent).GetComponent<ScrollRect>() != (Object)null) { return val; } parent = parent.parent; } Transform parent2 = ((Transform)content).parent; return (RectTransform)(object)((parent2 is RectTransform) ? parent2 : null); } private static void EnsureVerticalScrollbar(ScrollRect scrollRect, RectTransform viewport, RectTransform content) { //IL_0030: 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) //IL_00ad: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Expected O, but got Unknown //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: 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_022d: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)viewport == (Object)null || (Object)(object)content == (Object)null) { return; } Image val = ((Component)viewport).GetComponent<Image>(); if ((Object)(object)val == (Object)null) { val = ((Component)viewport).gameObject.AddComponent<Image>(); ((Graphic)val).color = Color.clear; } ((Graphic)val).raycastTarget = true; Scrollbar val2 = (((Object)(object)scrollRect != (Object)null) ? scrollRect.verticalScrollbar : null); if ((Object)(object)val2 == (Object)null) { GameObject val3 = new GameObject("CodexVerticalScrollbar", new Type[4] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image), typeof(Scrollbar) }); RectTransform component = val3.GetComponent<RectTransform>(); ((Transform)component).SetParent((Transform)(object)viewport, false); component.anchorMin = new Vector2(1f, 0f); component.anchorMax = new Vector2(1f, 1f); component.pivot = new Vector2(1f, 0.5f); component.anchoredPosition = new Vector2(-2f, 0f); component.sizeDelta = new Vector2(12f, -4f); Image component2 = val3.GetComponent<Image>(); ((Graphic)component2).color = new Color(0.08f, 0.06f, 0.04f, 0.85f); GameObject val4 = new GameObject("Handle", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }); RectTransform component3 = val4.GetComponent<RectTransform>(); ((Transform)component3).SetParent((Transform)(object)component, false); component3.anchorMin = Vector2.zero; component3.anchorMax = Vector2.one; component3.offsetMin = new Vector2(2f, 2f); component3.offsetMax = new Vector2(-2f, -2f); Image component4 = val4.GetComponent<Image>(); ((Graphic)component4).color = new Color(1f, 0.55f, 0.08f, 1f); val2 = val3.GetComponent<Scrollbar>(); val2.handleRect = component3; ((Selectable)val2).targetGraphic = (Graphic)(object)component4; val2.direction = (Direction)2; Scrollbar obj = val2; Navigation navigation = default(Navigation); ((Navigation)(ref navigation)).mode = (Mode)0; ((Selectable)obj).navigation = navigation; if ((Object)(object)scrollRect != (Object)null) { scrollRect.verticalScrollbar = val2; scrollRect.verticalScrollbarVisibility = (ScrollbarVisibility)0; scrollRect.verticalScrollbarSpacing = 2f; } } ((Component)val2).gameObject.SetActive(true); ((Selectable)val2).interactable = true; if ((Object)(object)scrollRect != (Object)null) { ((Behaviour)scrollRect).enabled = false; } ManualRuneListScroller manualRuneListScroller = ((Component)viewport).GetComponent<ManualRuneListScroller>(); if ((Object)(object)manualRuneListScroller == (Object)null) { manualRuneListScroller = ((Component)viewport).gameObject.AddComponent<ManualRuneListScroller>(); } manualRuneListScroller.Content = content; manualRuneListScroller.Bar = val2; } }
plugins/Codex-EpicLootRuneUiFix-1.6.6/EpicLootRuneUiFix.dll
Decompiled 2 weeks agousing System; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using HarmonyLib; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyVersion("0.0.0.0")] namespace Codex.EpicLootRuneUiFix; [BepInPlugin("codex.epiclootruneuifix", "Epic Loot Rune UI Fix", "1.6.6")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { public sealed class ManualRuneListScroller : MonoBehaviour, IScrollHandler, IEventSystemHandler { private const float TopOverscrollPixels = 90f; public RectTransform Content; public Scrollbar Bar; private RectTransform _viewport; private float _topY; private bool _initialized; private bool _topOverscrolled; private void Awake() { ref RectTransform viewport = ref _viewport; Transform transform = ((Component)this).transform; viewport = (RectTransform)(object)((transform is RectTransform) ? transform : null); } private void LateUpdate() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Content == (Object)null) && !((Object)(object)Bar == (Object)null) && !((Object)(object)_viewport == (Object)null)) { Rect rect = _viewport.rect; float num = Mathf.Max(1f, ((Rect)(ref rect)).height); LayoutRebuilder.ForceRebuildLayoutImmediate(Content); float preferredHeight = LayoutUtility.GetPreferredHeight(Content); float num2 = 0f; if (((Transform)Content).childCount > 0) { Bounds val = RectTransformUtility.CalculateRelativeRectTransformBounds((Transform)(object)Content); num2 = ((Bounds)(ref val)).size.y; } Rect rect2 = Content.rect; float num3 = Mathf.Max(num, Mathf.Max(((Rect)(ref rect2)).height, Mathf.Max(preferredHeight, num2))); float num4 = Mathf.Max(0f, num3 - num); Rect rect3 = Content.rect; if (num3 > ((Rect)(ref rect3)).height + 0.5f) { Content.SetSizeWithCurrentAnchors((Axis)1, num3); } if (!_initialized) { _topY = Content.anchoredPosition.y; Bar.SetValueWithoutNotify(1f); ((UnityEvent<float>)(object)Bar.onValueChanged).AddListener((UnityAction<float>)SetScrollValue); _initialized = true; } Bar.size = Mathf.Clamp01(num / num3); ((Selectable)Bar).interactable = num4 > 0.5f; ((Component)Bar).gameObject.SetActive(true); } } public void OnScroll(PointerEventData eventData) { //IL_001d: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Bar == (Object)null || !((Selectable)Bar).interactable) { return; } float y = eventData.scrollDelta.y; if (y > 0f && Bar.value >= 0.999f) { Content.anchoredPosition = new Vector2(Content.anchoredPosition.x, _topY - 90f); _topOverscrolled = true; return; } if (_topOverscrolled) { Content.anchoredPosition = new Vector2(Content.anchoredPosition.x, _topY); _topOverscrolled = false; } Bar.value = Mathf.Clamp01(Bar.value + y * 0.32f); } private void SetScrollValue(float value) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Content == (Object)null) && !((Object)(object)_viewport == (Object)null)) { Rect rect = Content.rect; float height = ((Rect)(ref rect)).height; Rect rect2 = _viewport.rect; float num = Mathf.Max(0f, height - ((Rect)(ref rect2)).height); Content.anchoredPosition = new Vector2(Content.anchoredPosition.x, _topY + (1f - value) * num); } } } public sealed class RuneUiLayerGuard : MonoBehaviour { public Transform Window; public Canvas WindowCanvas; public Canvas ParentCanvas; private void LateUpdate() { if ((Object)(object)Window != (Object)null) { Window.SetAsLastSibling(); } if ((Object)(object)WindowCanvas != (Object)null) { WindowCanvas.overrideSorting = true; WindowCanvas.sortingOrder = (((Object)(object)ParentCanvas != (Object)null) ? ParentCanvas.sortingOrder : 0) + 1000; } } } private static FieldInfo _availableRunesWindow; private static FieldInfo _enchantList; private void Awake() { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown Type type = FindType("EpicLoot_UnityLib.RuneUI"); if (type == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"EpicLoot RuneUI type was not found; UI fix was not applied."); return; } _availableRunesWindow = AccessTools.Field(type, "AvailableRunesWindow"); _enchantList = AccessTools.Field(type, "EnchantList"); MethodInfo methodInfo = AccessTools.Method(type, "OnEnable", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(type, "UpdateDisplayAvailableOverwriteEnchantments", (Type[])null, (Type[])null); if (_availableRunesWindow == null || _enchantList == null || methodInfo == null || methodInfo2 == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"EpicLoot RuneUI layout members were not found; UI fix was not applied."); return; } HarmonyMethod val = new HarmonyMethod(typeof(Plugin).GetMethod("FixRuneUiPostfix", BindingFlags.Static | BindingFlags.NonPublic)); Harmony val2 = new Harmony("codex.epiclootruneuifix"); val2.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val2.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"EpicLoot rune overwrite panel click-layer fix applied."); } private static Type FindType(string fullName) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { Type type = assembly.GetType(fullName, throwOnError: false); if (type != null) { return type; } } return null; } private static void FixRuneUiPostfix(object __instance) { object? value = _availableRunesWindow.GetValue(__instance); GameObject val = (GameObject)((value is GameObject) ? value : null); if ((Object)(object)val == (Object)null) { return; } object? value2 = _enchantList.GetValue(__instance); RectTransform val2 = (RectTransform)((value2 is RectTransform) ? value2 : null); val.transform.SetAsLastSibling(); Canvas val3 = (((Object)(object)val.transform.parent != (Object)null) ? ((Component)val.transform.parent).GetComponentInParent<Canvas>() : null); Canvas val4 = val.GetComponent<Canvas>(); if ((Object)(object)val4 == (Object)null) { val4 = val.AddComponent<Canvas>(); } val4.overrideSorting = true; val4.sortingOrder = (((Object)(object)val3 != (Object)null) ? val3.sortingOrder : 0) + 1000; if ((Object)(object)val.GetComponent<GraphicRaycaster>() == (Object)null) { val.AddComponent<GraphicRaycaster>(); } CanvasGroup val5 = val.GetComponent<CanvasGroup>(); if ((Object)(object)val5 == (Object)null) { val5 = val.AddComponent<CanvasGroup>(); } val5.interactable = true; val5.blocksRaycasts = true; RectTransform val6 = FindViewport(val2); if ((Object)(object)val6 != (Object)null) { if ((Object)(object)((Component)val6).GetComponent<RectMask2D>() == (Object)null) { ((Component)val6).gameObject.AddComponent<RectMask2D>(); } ScrollRect componentInParent = ((Component)val2).GetComponentInParent<ScrollRect>(); if ((Object)(object)componentInParent != (Object)null) { componentInParent.viewport = val6; componentInParent.content = val2; componentInParent.horizontal = false; componentInParent.vertical = true; componentInParent.movementType = (MovementType)2; componentInParent.scrollSensitivity = 32f; } EnsureVerticalScrollbar(componentInParent, val6, val2); } RuneUiLayerGuard runeUiLayerGuard = val.GetComponent<RuneUiLayerGuard>(); if ((Object)(object)runeUiLayerGuard == (Object)null) { runeUiLayerGuard = val.AddComponent<RuneUiLayerGuard>(); } runeUiLayerGuard.Window = val.transform; runeUiLayerGuard.WindowCanvas = val4; runeUiLayerGuard.ParentCanvas = val3; } private static RectTransform FindViewport(RectTransform content) { if ((Object)(object)content == (Object)null) { return null; } Transform parent = ((Transform)content).parent; while ((Object)(object)parent != (Object)null) { RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null); if ((Object)(object)val != (Object)null && (((Object)parent).name.IndexOf("viewport", StringComparison.OrdinalIgnoreCase) >= 0 || (Object)(object)((Component)parent).GetComponent<Mask>() != (Object)null || (Object)(object)((Component)parent).GetComponent<RectMask2D>() != (Object)null)) { return val; } if ((Object)(object)((Component)parent).GetComponent<ScrollRect>() != (Object)null) { return val; } parent = parent.parent; } Transform parent2 = ((Transform)content).parent; return (RectTransform)(object)((parent2 is RectTransform) ? parent2 : null); } private static void EnsureVerticalScrollbar(ScrollRect scrollRect, RectTransform viewport, RectTransform content) { //IL_0030: 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) //IL_00ad: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Expected O, but got Unknown //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: 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_022d: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)viewport == (Object)null || (Object)(object)content == (Object)null) { return; } Image val = ((Component)viewport).GetComponent<Image>(); if ((Object)(object)val == (Object)null) { val = ((Component)viewport).gameObject.AddComponent<Image>(); ((Graphic)val).color = Color.clear; } ((Graphic)val).raycastTarget = true; Scrollbar val2 = (((Object)(object)scrollRect != (Object)null) ? scrollRect.verticalScrollbar : null); if ((Object)(object)val2 == (Object)null) { GameObject val3 = new GameObject("CodexVerticalScrollbar", new Type[4] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image), typeof(Scrollbar) }); RectTransform component = val3.GetComponent<RectTransform>(); ((Transform)component).SetParent((Transform)(object)viewport, false); component.anchorMin = new Vector2(1f, 0f); component.anchorMax = new Vector2(1f, 1f); component.pivot = new Vector2(1f, 0.5f); component.anchoredPosition = new Vector2(-2f, 0f); component.sizeDelta = new Vector2(12f, -4f); Image component2 = val3.GetComponent<Image>(); ((Graphic)component2).color = new Color(0.08f, 0.06f, 0.04f, 0.85f); GameObject val4 = new GameObject("Handle", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }); RectTransform component3 = val4.GetComponent<RectTransform>(); ((Transform)component3).SetParent((Transform)(object)component, false); component3.anchorMin = Vector2.zero; component3.anchorMax = Vector2.one; component3.offsetMin = new Vector2(2f, 2f); component3.offsetMax = new Vector2(-2f, -2f); Image component4 = val4.GetComponent<Image>(); ((Graphic)component4).color = new Color(1f, 0.55f, 0.08f, 1f); val2 = val3.GetComponent<Scrollbar>(); val2.handleRect = component3; ((Selectable)val2).targetGraphic = (Graphic)(object)component4; val2.direction = (Direction)2; Scrollbar obj = val2; Navigation navigation = default(Navigation); ((Navigation)(ref navigation)).mode = (Mode)0; ((Selectable)obj).navigation = navigation; if ((Object)(object)scrollRect != (Object)null) { scrollRect.verticalScrollbar = val2; scrollRect.verticalScrollbarVisibility = (ScrollbarVisibility)0; scrollRect.verticalScrollbarSpacing = 2f; } } ((Component)val2).gameObject.SetActive(true); ((Selectable)val2).interactable = true; if ((Object)(object)scrollRect != (Object)null) { ((Behaviour)scrollRect).enabled = false; } ManualRuneListScroller manualRuneListScroller = ((Component)viewport).GetComponent<ManualRuneListScroller>(); if ((Object)(object)manualRuneListScroller == (Object)null) { manualRuneListScroller = ((Component)viewport).gameObject.AddComponent<ManualRuneListScroller>(); } manualRuneListScroller.Content = content; manualRuneListScroller.Bar = val2; } }
plugins/Codex-EpicLootStaminaReductionCap/EpicLootStaminaReductionCap.dll
Decompiled 2 weeks agousing System; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using HarmonyLib; using UnityEngine; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyVersion("0.0.0.0")] namespace Codex.EpicLootStaminaReductionCap; [BepInPlugin("codex.epiclootstaminareductioncap", "Epic Loot Stamina Reduction Cap", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { private const float MaximumReduction = 0.75f; private void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Expected O, but got Unknown //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Expected O, but got Unknown //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Expected O, but got Unknown Harmony val = new Harmony("codex.epiclootstaminareductioncap"); string[] array = new string[4] { "GetEquipmentRunStaminaModifier", "GetEquipmentJumpStaminaModifier", "GetEquipmentDodgeStaminaModifier", "GetEquipmentBlockStaminaModifier" }; int num = 0; string[] array2 = array; foreach (string text in array2) { MethodInfo methodInfo = AccessTools.Method(typeof(Player), text, Type.EmptyTypes, (Type[])null); if (!(methodInfo == null)) { HarmonyMethod val2 = new HarmonyMethod(typeof(Plugin).GetMethod("ModifierPostfix", BindingFlags.Static | BindingFlags.NonPublic)); val2.priority = 0; val.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); num++; } } Type type = FindType("EpicLoot.MagicItemEffects.ModifyAttackCosts"); MethodInfo methodInfo2 = ((type == null) ? null : AccessTools.Method(type, "GetModifyAttackValue", (Type[])null, (Type[])null)); if (methodInfo2 != null) { HarmonyMethod val2 = new HarmonyMethod(typeof(Plugin).GetMethod("AttackMultiplierPostfix", BindingFlags.Static | BindingFlags.NonPublic)); val2.priority = 0; val.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); num++; } MethodInfo methodInfo3 = AccessTools.Method(typeof(ItemData), "GetDrawStaminaDrain", Type.EmptyTypes, (Type[])null); if (methodInfo3 != null) { HarmonyMethod val3 = new HarmonyMethod(typeof(Plugin).GetMethod("DrawPrefix", BindingFlags.Static | BindingFlags.NonPublic)); val3.priority = 800; HarmonyMethod val2 = new HarmonyMethod(typeof(Plugin).GetMethod("DrawPostfix", BindingFlags.Static | BindingFlags.NonPublic)); val2.priority = 0; val.Patch((MethodBase)methodInfo3, val3, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); num++; } if (num < 6) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Stamina cap applied to " + num + "/6 calculation paths.")); } else { ((BaseUnityPlugin)this).Logger.LogInfo((object)"EpicLoot stamina-use reductions are capped at 75%; every action costs at least 25%."); } } private static Type FindType(string fullName) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { Type type = assembly.GetType(fullName, throwOnError: false); if (type != null) { return type; } } return null; } private static void ModifierPostfix(ref float __result) { __result = Mathf.Max(__result, -0.75f); } private static void AttackMultiplierPostfix(string magicEffect, ref float __result) { if (magicEffect == "ModifyAttackStaminaUse") { __result = Mathf.Max(__result, 0.25f); } } private static void DrawPrefix(ItemData __instance, out float __state) { __state = ((__instance != null && __instance.m_shared != null && __instance.m_shared.m_attack != null) ? __instance.m_shared.m_attack.m_drawStaminaDrain : 0f); } private static void DrawPostfix(float __state, ref float __result) { if (__state > 0f) { __result = Mathf.Max(__result, __state * 0.25f); } } }
plugins/Codex-GroundItemCleanup/GroundItemCleanup.dll
Decompiled 2 weeks agousing System; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace Codex.GroundItemCleanup; [BepInPlugin("codex.grounditemcleanup", "Ground Item Cleanup", "1.0.0")] public sealed class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(ItemDrop), "Awake")] private static class ItemDropAwakePatch { [HarmonyPostfix] private static void AddExpiryTracker(ItemDrop __instance) { if ((Object)(object)__instance != (Object)null && (Object)(object)((Component)__instance).GetComponent<GroundItemExpiry>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<GroundItemExpiry>(); } } } internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<float> LifetimeMinutes; internal static ConfigEntry<float> CheckIntervalSeconds; private void Awake() { //IL_006e: Unknown result type (might be due to invalid IL or missing references) Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Remove loose ItemDrop objects after their configured lifetime. Player tombstones and inventories are never removed."); LifetimeMinutes = ((BaseUnityPlugin)this).Config.Bind<float>("General", "LifetimeMinutes", 10f, "Minutes a loose item may remain on the ground before it is removed."); CheckIntervalSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("General", "CheckIntervalSeconds", 10f, "How often each loaded loose item checks its age. Higher values use less CPU."); new Harmony("codex.grounditemcleanup").PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Loose ground items will be removed after " + LifetimeMinutes.Value + " minutes; tombstones are excluded.")); } } internal sealed class GroundItemExpiry : MonoBehaviour { private const string SpawnTicksKey = "codex_ground_item_spawn_ticks"; private ItemDrop itemDrop; private ZNetView netView; private float nextCheck; private void Awake() { itemDrop = ((Component)this).GetComponent<ItemDrop>(); netView = ((Component)this).GetComponent<ZNetView>(); nextCheck = Time.time + Random.Range(2f, 8f); } private void Update() { if (Time.time < nextCheck) { return; } float num = ((Plugin.CheckIntervalSeconds != null) ? Plugin.CheckIntervalSeconds.Value : 10f); nextCheck = Time.time + Mathf.Max(2f, num); if (Plugin.Enabled == null || !Plugin.Enabled.Value || (Object)(object)itemDrop == (Object)null || (Object)(object)netView == (Object)null || !netView.IsValid() || !netView.IsOwner() || (Object)(object)((Component)this).GetComponent<TombStone>() != (Object)null || (Object)(object)((Component)this).GetComponentInParent<TombStone>() != (Object)null) { return; } ZDO zDO = netView.GetZDO(); if (zDO == null || (Object)(object)ZNet.instance == (Object)null) { return; } long ticks = ZNet.instance.GetTime().Ticks; long num2 = zDO.GetLong("codex_ground_item_spawn_ticks", 0L); if (num2 <= 0 || num2 > ticks) { zDO.Set("codex_ground_item_spawn_ticks", ticks); return; } double totalMinutes = new TimeSpan(ticks - num2).TotalMinutes; float num3 = ((Plugin.LifetimeMinutes != null) ? Plugin.LifetimeMinutes.Value : 10f); if (!(totalMinutes < (double)Mathf.Max(1f, num3))) { ZNetScene instance = ZNetScene.instance; if ((Object)(object)instance != (Object)null) { instance.Destroy(((Component)this).gameObject); } } } }
plugins/Codex-MonsterAntiBonemass/MonsterAntiBonemass.dll
Decompiled 2 weeks agousing System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace Codex.MonsterAntiBonemass; [BepInPlugin("codex.monsterantibonemass", "Monster Anti Bonemass", "1.0.0")] public sealed class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(Character), "RPC_Damage")] private static class CharacterRpcDamagePatch { [HarmonyPrefix] private static void CounterBonemass(Character __instance, HitData hit) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Invalid comparison between Unknown and I4 if (featureEnabled == null || !featureEnabled.Value || (Object)(object)__instance == (Object)null || hit == null || !__instance.IsPlayer()) { return; } SEMan sEMan = __instance.GetSEMan(); if (sEMan != null && sEMan.HaveStatusEffect(BonemassHash)) { Character attacker = hit.GetAttacker(); if (!((Object)(object)attacker == (Object)null) && !attacker.IsPlayer() && !attacker.IsTamed() && (int)attacker.GetFaction() != 11) { float num = ((physicalMultiplier != null) ? physicalMultiplier.Value : 2f); ref DamageTypes damage = ref hit.m_damage; damage.m_blunt *= num; ref DamageTypes damage2 = ref hit.m_damage; damage2.m_slash *= num; ref DamageTypes damage3 = ref hit.m_damage; damage3.m_pierce *= num; } } } } private static ConfigEntry<bool> featureEnabled; private static ConfigEntry<float> physicalMultiplier; private static readonly int BonemassHash = StableHash("GP_Bonemass"); private static int StableHash(string text) { int num = 5381; int num2 = num; for (int i = 0; i < text.Length && text[i] != 0; i += 2) { num = ((num << 5) + num) ^ text[i]; if (i == text.Length - 1 || text[i + 1] == '\0') { break; } num2 = ((num2 << 5) + num2) ^ text[i + 1]; } return num + num2 * 1566083941; } private void Awake() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) featureEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Prevent Bonemass power from halving physical damage dealt by hostile monsters."); physicalMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "PhysicalMultiplierWhileBonemassActive", 2f, new ConfigDescription("Multiplier applied to hostile monster physical damage before Bonemass resistance. Two cancels Bonemass's normal 50% reduction.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 2f), new object[0])); new Harmony("codex.monsterantibonemass").PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Hostile monster physical damage now counters the Bonemass 50% reduction."); } }
plugins/Codex-SecondLifeCooldownHUD/SecondLifeCooldownHUD.dll
Decompiled 2 weeks agousing System; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace Codex.SecondLifeCooldownHUD; [BepInPlugin("codex.secondlifecooldownhud", "Second Life Cooldown HUD", "1.0.0")] public sealed class SecondLifeCooldownHudPlugin : BaseUnityPlugin { private ConfigEntry<bool> _enabled; private ConfigEntry<float> _x; private ConfigEntry<float> _y; private ConfigEntry<float> _scale; private Type _playerType; private Type _progressionType; private MethodInfo _getComponent; private MethodInfo _getRemaining; private FieldInfo _localPlayer; private GUIStyle _style; private void Awake() { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown _enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("HUD", "Enabled", true, "Show the Second Life cooldown on screen."); _x = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "X", 18f, "Left offset in pixels."); _y = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "Y", 300f, "Top offset in pixels."); _scale = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "Scale", 1f, new ConfigDescription("Text size multiplier.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 3f), new object[0])); } private void ResolveApi() { if (!(_getRemaining != null)) { _playerType = FindType("Player"); _progressionType = FindType("CharacterProgressionMod.Skills.PlayerSkillProgression"); if (!(_playerType == null) && !(_progressionType == null)) { _localPlayer = _playerType.GetField("m_localPlayer", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _getComponent = typeof(Component).GetMethod("GetComponent", new Type[1] { typeof(Type) }); _getRemaining = _progressionType.GetMethod("GetSecondLifeRemainingSeconds", BindingFlags.Instance | BindingFlags.Public); } } } private static Type FindType(string fullName) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { Type type = assembly.GetType(fullName, throwOnError: false); if (type != null) { return type; } } return null; } private bool TryGetRemainingSeconds(out double seconds) { seconds = 0.0; ResolveApi(); if (_localPlayer == null || _getComponent == null || _getRemaining == null) { return false; } object? value = _localPlayer.GetValue(null); Component val = (Component)((value is Component) ? value : null); if ((Object)(object)val == (Object)null) { return false; } object obj = _getComponent.Invoke(val, new object[1] { _progressionType }); if (obj == null) { return false; } object obj2 = _getRemaining.Invoke(obj, null); if (obj2 == null) { return false; } seconds = Math.Max(0.0, Convert.ToDouble(obj2)); return true; } private void OnGUI() { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_00d6: 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_0142: Unknown result type (might be due to invalid IL or missing references) if (_enabled != null && _enabled.Value && TryGetRemainingSeconds(out var seconds)) { if (_style == null) { GUIStyle val = new GUIStyle(GUI.skin.label); val.fontStyle = (FontStyle)1; val.alignment = (TextAnchor)3; _style = val; } _style.fontSize = Mathf.RoundToInt(20f * _scale.Value); bool flag = seconds <= 0.01; _style.normal.textColor = (flag ? new Color(0.45f, 1f, 0.55f) : new Color(1f, 0.83f, 0.25f)); string text = (flag ? "Second Life: READY" : $"Second Life: {Math.Floor(seconds / 60.0):00}:{Math.Floor(seconds % 60.0):00}"); GUI.Label(new Rect(_x.Value, _y.Value, 320f, 36f), text, _style); } } }
plugins/Codex-ShieldGeneratorNoSpawn/ShieldGeneratorNoSpawn.dll
Decompiled 2 weeks agousing System; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace Codex.ShieldGeneratorNoSpawn; [BepInPlugin("codex.shieldgeneratornospawn", "Shield Generator No Spawn", "1.0.1")] public sealed class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(SpawnSystem), "IsSpawnPointGood")] private static class SpawnSystemPatch { [HarmonyPostfix] private static void RejectProtectedPoint(ref Vector3 point, ref bool __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (__result && IsProtected(point)) { __result = false; } } } [HarmonyPatch(typeof(SpawnArea), "FindSpawnPoint")] private static class SpawnAreaPatch { [HarmonyPostfix] private static void RejectProtectedPoint(ref Vector3 point, ref bool __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (__result && IsProtected(point)) { __result = false; } } } [HarmonyPatch(typeof(CreatureSpawner), "Spawn")] private static class CreatureSpawnerPatch { [HarmonyPrefix] private static bool RejectProtectedSpawner(CreatureSpawner __instance, ref ZNetView __result) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!IsProtected(((Component)__instance).transform.position)) { return true; } __result = null; return false; } } internal static ConfigEntry<bool> Enabled; private void Awake() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Prevent creature spawning inside active Shield Generator domes."); Harmony val = new Harmony("codex.shieldgeneratornospawn"); val.PatchAll(typeof(Plugin).Assembly); MethodInfo methodInfo = AccessTools.Method(AccessTools.TypeByName("CreatureManager.CreatureKarmaManager"), "TrySpawnCreature", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(Plugin), "RejectProtectedEnforcer", (Type[])null, (Type[])null); if (methodInfo != null && methodInfo2 != null) { val.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"CreatureManager Karma Enforcer and minion spawning is protected by active shields."); } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)"CreatureManager Enforcer spawn method was not found; standard spawn protection is still active."); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"Active Shield Generator domes now block natural, raid, nest, fixed-spawner, and Enforcer creature spawns."); } internal static bool IsProtected(Vector3 point) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) return Enabled != null && Enabled.Value && ShieldGenerator.HasShields() && ShieldGenerator.IsInsideShield(point); } private static bool RejectProtectedEnforcer(Vector3 position, ref Character character, ref bool __result) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if (!IsProtected(position)) { return true; } character = null; __result = false; return false; } }
plugins/Codex-UniversalFarming/UniversalFarming.dll
Decompiled 2 weeks agousing System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace Codex.UniversalFarming; [BepInPlugin("codex.universalfarming", "Universal Farming", "1.0.0")] public sealed class Plugin : BaseUnityPlugin { private void Awake() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) new Harmony("codex.universalfarming").PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Universal Farming enabled: plants ignore biome, soil, roof, temperature, and spacing restrictions."); } } [HarmonyPatch(typeof(Plant), "UpdateHealth")] internal static class PlantUpdateHealthPatch { private static readonly FieldInfo StatusField = AccessTools.Field(typeof(Plant), "m_status"); [HarmonyPostfix] private static void Postfix(Plant __instance) { if ((Object)(object)__instance != (Object)null && StatusField != null) { StatusField.SetValue(__instance, 0); } } }
plugins/Codex-ZNetSceneNullGuard/ZNetSceneNullGuard.dll
Decompiled 2 weeks agousing System; using System.Collections; using System.Collections.Generic; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Logging; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace Codex.ZNetSceneNullGuard; [BepInPlugin("codex.znetscenenullguard", "ZNetScene Null Guard", "1.0.0")] public sealed class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(ZNetScene), "RemoveObjects")] private static class RemoveObjectsPatch { [HarmonyPrefix] private static void ClearDestroyedReferences(ZNetScene __instance, List<ZDO> currentNearObjects, List<ZDO> currentDistantObjects) { currentNearObjects?.RemoveAll(IsNullZdo); currentDistantObjects?.RemoveAll(IsNullZdo); PurgeDestroyedInstanceMappings(__instance); } private static bool IsNullZdo(ZDO zdo) { return object.ReferenceEquals(zdo, null); } private static void PurgeDestroyedInstanceMappings(ZNetScene scene) { if ((Object)(object)scene == (Object)null || InstancesField == null) { return; } object value = InstancesField.GetValue(scene); if (!(value is IEnumerable enumerable)) { return; } List<object> list = new List<object>(); foreach (object item in enumerable) { if (item == null) { continue; } Type type = item.GetType(); PropertyInfo property = type.GetProperty("Key"); PropertyInfo property2 = type.GetProperty("Value"); if (!(property == null) && !(property2 == null)) { object? value2 = property2.GetValue(item, null); Object val = (Object)((value2 is Object) ? value2 : null); if (val == (Object)null) { list.Add(property.GetValue(item, null)); } } } if (list.Count == 0) { return; } MethodInfo method = value.GetType().GetMethod("Remove"); if (method == null) { return; } foreach (object item2 in list) { method.Invoke(value, new object[1] { item2 }); } if (Log != null) { Log.LogWarning((object)("Removed " + list.Count + " stale ZNetScene instance reference(s) to prevent RemoveObjects lag.")); } } } private static readonly FieldInfo InstancesField = AccessTools.Field(typeof(ZNetScene), "m_instances"); internal static ManualLogSource Log; private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; new Harmony("codex.znetscenenullguard").PatchAll(typeof(Plugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)"ZNetScene Null Guard enabled."); } }