Decompiled source of EpicLoot v0.9.38
plugins/EpicLoot.dll
Decompiled a month ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.CodeDom; using System.CodeDom.Compiler; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.ComponentModel; using System.Configuration; using System.Data; using System.Data.SqlTypes; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Dynamic; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Linq.Expressions; using System.Numerics; using System.Reflection; using System.Reflection.Emit; using System.Resources; using System.Runtime; using System.Runtime.CompilerServices; using System.Runtime.Diagnostics; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Serialization.Configuration; using System.Runtime.Serialization.Diagnostics; using System.Runtime.Serialization.Diagnostics.Application; using System.Runtime.Serialization.Formatters; using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Serialization.Json; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using System.Xml; using System.Xml.Linq; using System.Xml.Schema; using System.Xml.Serialization; using System.Xml.XPath; using AdventureBackpacks.API; using Auga; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Common; using EpicLoot.Abilities; using EpicLoot.Adventure; using EpicLoot.Adventure.Feature; using EpicLoot.Crafting; using EpicLoot.CraftingV2; using EpicLoot.Data; using EpicLoot.GatedItemType; using EpicLoot.Healing; using EpicLoot.LegendarySystem; using EpicLoot.LootBeams; using EpicLoot.MagicItemEffects; using EpicLoot.Patching; using EpicLoot_UnityLib; using HarmonyLib; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Newtonsoft.Json.Bson; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq.JsonPath; using Newtonsoft.Json.Schema; using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Utilities; using ServerSync; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: AssemblyDescription("")] [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyFileVersion("0.9.38")] [assembly: Guid("963cf4f8-ba02-49fc-8884-97e781e6bc18")] [assembly: ComVisible(false)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("EpicLoot")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Randy Knapp Mods")] [assembly: AssemblyProduct("EpicLoot")] [assembly: AssemblyCopyright("Copyright © Randy Knapp 2023")] [assembly: AssemblyTrademark("")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.9.38.0")] [module: UnverifiableCode] [module: <0a00dcee-c39f-46f8-b9b0-c21351570b77>RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<8a37dae9-30bb-42cc-b92a-7e3dd651189c>Embedded] internal sealed class <8a37dae9-30bb-42cc-b92a-7e3dd651189c>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [<8a37dae9-30bb-42cc-b92a-7e3dd651189c>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class <291ecdf0-57cd-4d5a-a9ba-3163fb378ad3>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <291ecdf0-57cd-4d5a-a9ba-3163fb378ad3>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <291ecdf0-57cd-4d5a-a9ba-3163fb378ad3>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] [<8a37dae9-30bb-42cc-b92a-7e3dd651189c>Embedded] internal sealed class <59af7e11-a305-4e90-a14f-6684b96c853d>NullableContextAttribute : Attribute { public readonly byte Flag; public <59af7e11-a305-4e90-a14f-6684b96c853d>NullableContextAttribute(byte P_0) { Flag = P_0; } } [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] [<8a37dae9-30bb-42cc-b92a-7e3dd651189c>Embedded] [CompilerGenerated] internal sealed class <0a00dcee-c39f-46f8-b9b0-c21351570b77>RefSafetyRulesAttribute : Attribute { public readonly int Version; public <0a00dcee-c39f-46f8-b9b0-c21351570b77>RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } public static class PlayerExtensions { public static ZDO GetZDO(this Player player) { return ((Character)player).m_nview.GetZDO(); } } namespace Common { public class ConfigPositionedElement : MonoBehaviour { public ConfigEntry<TextAnchor> AnchorConfig; public ConfigEntry<Vector2> PositionConfig; protected RectTransform _rt; protected TextAnchor _currentAnchor; public virtual void Awake() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown _rt = (RectTransform)((Component)this).transform; EnsureCorrectPosition(); } public virtual void Update() { EnsureCorrectPosition(); } public virtual void EnsureCorrectPosition() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected I4, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) if (AnchorConfig != null && PositionConfig != null && (_currentAnchor != AnchorConfig.Value || !(_rt.anchoredPosition == PositionConfig.Value))) { _currentAnchor = AnchorConfig.Value; TextAnchor currentAnchor = _currentAnchor; Vector2 val = default(Vector2); switch ((int)currentAnchor) { case 0: { RectTransform rt25 = _rt; RectTransform rt26 = _rt; RectTransform rt27 = _rt; ((Vector2)(ref val))..ctor(0f, 1f); rt27.anchorMax = val; Vector2 pivot = (rt26.anchorMin = val); rt25.pivot = pivot; break; } case 1: { RectTransform rt22 = _rt; RectTransform rt23 = _rt; RectTransform rt24 = _rt; ((Vector2)(ref val))..ctor(0.5f, 1f); rt24.anchorMax = val; Vector2 pivot = (rt23.anchorMin = val); rt22.pivot = pivot; break; } case 2: { RectTransform rt19 = _rt; RectTransform rt20 = _rt; RectTransform rt21 = _rt; ((Vector2)(ref val))..ctor(1f, 1f); rt21.anchorMax = val; Vector2 pivot = (rt20.anchorMin = val); rt19.pivot = pivot; break; } case 3: { RectTransform rt16 = _rt; RectTransform rt17 = _rt; RectTransform rt18 = _rt; ((Vector2)(ref val))..ctor(0f, 0.5f); rt18.anchorMax = val; Vector2 pivot = (rt17.anchorMin = val); rt16.pivot = pivot; break; } case 4: { RectTransform rt13 = _rt; RectTransform rt14 = _rt; RectTransform rt15 = _rt; ((Vector2)(ref val))..ctor(0.5f, 0.5f); rt15.anchorMax = val; Vector2 pivot = (rt14.anchorMin = val); rt13.pivot = pivot; break; } case 5: { RectTransform rt10 = _rt; RectTransform rt11 = _rt; RectTransform rt12 = _rt; ((Vector2)(ref val))..ctor(1f, 0.5f); rt12.anchorMax = val; Vector2 pivot = (rt11.anchorMin = val); rt10.pivot = pivot; break; } case 6: { RectTransform rt7 = _rt; RectTransform rt8 = _rt; RectTransform rt9 = _rt; ((Vector2)(ref val))..ctor(0f, 0f); rt9.anchorMax = val; Vector2 pivot = (rt8.anchorMin = val); rt7.pivot = pivot; break; } case 7: { RectTransform rt4 = _rt; RectTransform rt5 = _rt; RectTransform rt6 = _rt; ((Vector2)(ref val))..ctor(0.5f, 0f); rt6.anchorMax = val; Vector2 pivot = (rt5.anchorMin = val); rt4.pivot = pivot; break; } case 8: { RectTransform rt = _rt; RectTransform rt2 = _rt; RectTransform rt3 = _rt; ((Vector2)(ref val))..ctor(1f, 0f); rt3.anchorMax = val; Vector2 pivot = (rt2.anchorMin = val); rt.pivot = pivot; break; } } _rt.anchoredPosition = PositionConfig.Value; } } } [Serializable] public class RecipeRequirementConfig { public string item = ""; public int amount = 1; } [Serializable] public class RecipeConfig { public string name = ""; public string item = ""; public int amount = 1; public string craftingStation = ""; public int minStationLevel = 1; public bool enabled = true; public string repairStation = ""; public List<RecipeRequirementConfig> resources = new List<RecipeRequirementConfig>(); } [Serializable] public class RecipesConfig { public List<RecipeConfig> recipes = new List<RecipeConfig>(); } public static class GameObjectExtensions { public static RectTransform RectTransform(this GameObject go) { Transform transform = go.transform; return (RectTransform)(object)((transform is RectTransform) ? transform : null); } public static T RequireComponent<T>(this GameObject go) where T : Component { T component = go.GetComponent<T>(); if (!((Object)(object)component == (Object)null)) { return component; } return go.AddComponent<T>(); } } public class GotDestroyed : MonoBehaviour { public void OnDisable() { Debug.LogError((object)("I got destroyed! (" + ((Object)((Component)this).gameObject).name + ")")); Debug.Log((object)Environment.StackTrace); } } public class MultiValueDictionary<TKey, TValue> : Dictionary<TKey, List<TValue>> { public void Add(TKey key, TValue value) { if (!TryGetValue(key, out var value2)) { value2 = new List<TValue>(); Add(key, value2); } value2.Add(value); } public bool ContainsValue(TKey key, TValue value) { if (TryGetValue(key, out var value2)) { return value2.Contains(value); } return false; } public void Remove(TKey key, TValue value) { if (TryGetValue(key, out var value2)) { value2.Remove(value); if (value2.Count <= 0) { Remove(key); } } } public void Merge(MultiValueDictionary<TKey, TValue> toMergeWith) { if (toMergeWith == null) { return; } foreach (KeyValuePair<TKey, List<TValue>> item in toMergeWith) { foreach (TValue item2 in item.Value) { Add(item.Key, item2); } } } public List<TValue> GetValues(TKey key, bool returnEmptySet = false) { if (!TryGetValue(key, out var value) && returnEmptySet) { return new List<TValue>(); } return value; } } public static class PrefabCreator { public static ManualLogSource Logger; public static Dictionary<string, CraftingStation> CraftingStations; public static T RequireComponent<T>(GameObject go) where T : Component { T val = go.GetComponent<T>(); if ((Object)(object)val == (Object)null) { val = go.AddComponent<T>(); } return val; } public static void Reset() { CraftingStations = null; } private static void InitCraftingStations() { if (CraftingStations != null) { return; } CraftingStations = new Dictionary<string, CraftingStation>(); foreach (Recipe recipe in ObjectDB.instance.m_recipes) { if ((Object)(object)recipe.m_craftingStation != (Object)null && !CraftingStations.ContainsKey(((Object)recipe.m_craftingStation).name)) { CraftingStations.Add(((Object)recipe.m_craftingStation).name, recipe.m_craftingStation); } } } public static Recipe CreateRecipe(string name, string itemId, RecipeConfig recipeConfig) { //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Expected O, but got Unknown InitCraftingStations(); GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(itemId); if ((Object)(object)itemPrefab == (Object)null) { ManualLogSource logger = Logger; if (logger != null) { logger.LogWarning((object)("[PrefabCreator] Could not find item prefab (" + itemId + ")")); } return null; } Recipe val = ScriptableObject.CreateInstance<Recipe>(); ((Object)val).name = name; val.m_amount = recipeConfig.amount; val.m_minStationLevel = recipeConfig.minStationLevel; val.m_item = itemPrefab.GetComponent<ItemDrop>(); val.m_enabled = recipeConfig.enabled; if (!string.IsNullOrEmpty(recipeConfig.craftingStation)) { if (!CraftingStations.ContainsKey(recipeConfig.craftingStation)) { ManualLogSource logger2 = Logger; if (logger2 != null) { logger2.LogWarning((object)("[PrefabCreator] Could not find crafting station (" + itemId + "): " + recipeConfig.craftingStation)); } string text = string.Join(", ", CraftingStations.Keys); ManualLogSource logger3 = Logger; if (logger3 != null) { logger3.LogInfo((object)("[PrefabCreator] Available Stations: " + text)); } } else { val.m_craftingStation = CraftingStations[recipeConfig.craftingStation]; } } if (!string.IsNullOrEmpty(recipeConfig.repairStation)) { if (!CraftingStations.ContainsKey(recipeConfig.repairStation)) { ManualLogSource logger4 = Logger; if (logger4 != null) { logger4.LogWarning((object)("[PrefabCreator] Could not find repair station (" + itemId + "): " + recipeConfig.repairStation)); } string text2 = string.Join(", ", CraftingStations.Keys); ManualLogSource logger5 = Logger; if (logger5 != null) { logger5.LogInfo((object)("[PrefabCreator] Available Stations: " + text2)); } } else { val.m_repairStation = CraftingStations[recipeConfig.repairStation]; } } List<Requirement> list = new List<Requirement>(); foreach (RecipeRequirementConfig resource in recipeConfig.resources) { GameObject itemPrefab2 = ObjectDB.instance.GetItemPrefab(resource.item); if ((Object)(object)itemPrefab2 == (Object)null) { ManualLogSource logger6 = Logger; if (logger6 != null) { logger6.LogError((object)("[PrefabCreator] Could not find requirement item (" + itemId + "): " + resource.item)); } } else { list.Add(new Requirement { m_amount = resource.amount, m_resItem = itemPrefab2.GetComponent<ItemDrop>() }); } } val.m_resources = list.ToArray(); return val; } public static Recipe AddNewRecipe(string name, string itemId, RecipeConfig recipeConfig) { Recipe val = CreateRecipe(name, itemId, recipeConfig); if ((Object)(object)val == (Object)null) { ManualLogSource logger = Logger; if (logger != null) { logger.LogError((object)("[PrefabCreator] Failed to create recipe (" + name + ")")); } return null; } return AddNewRecipe(val); } public static Recipe AddNewRecipe(Recipe recipe) { int num = ObjectDB.instance.m_recipes.RemoveAll((Recipe x) => ((Object)x).name == ((Object)recipe).name); if (num > 0) { ManualLogSource logger = Logger; if (logger != null) { logger.LogInfo((object)$"[PrefabCreator] Removed recipe ({((Object)recipe).name}): {num}"); } } ObjectDB.instance.m_recipes.Add(recipe); ManualLogSource logger2 = Logger; if (logger2 != null) { logger2.LogInfo((object)("[PrefabCreator] Added recipe: " + ((Object)recipe).name)); } return recipe; } } [Serializable] public struct SerializableVector3 { public float x; public float y; public float z; public SerializableVector3(float x, float y, float z) { this.x = x; this.y = y; this.z = z; } public void ToPackage(ZPackage pkg) { pkg.Write(x); pkg.Write(y); pkg.Write(z); } public static SerializableVector3 FromPackage(ZPackage pkg) { SerializableVector3 result = default(SerializableVector3); result.x = pkg.ReadSingle(); result.y = pkg.ReadSingle(); result.z = pkg.ReadSingle(); return result; } public override string ToString() { return $"[{x}, {y}, {z}]"; } public static implicit operator Vector3(SerializableVector3 s) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vector3(s.x, s.y, s.z); } public static implicit operator SerializableVector3(Vector3 v) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) return new SerializableVector3(v.x, v.y, v.z); } public static SerializableVector3 operator +(SerializableVector3 a, SerializableVector3 b) { return new SerializableVector3(a.x + b.x, a.y + b.y, a.z + b.z); } public static SerializableVector3 operator -(SerializableVector3 a, SerializableVector3 b) { return new SerializableVector3(a.x - b.x, a.y - b.y, a.z - b.z); } public static SerializableVector3 operator -(SerializableVector3 a) { return new SerializableVector3(0f - a.x, 0f - a.y, 0f - a.z); } public static SerializableVector3 operator *(SerializableVector3 a, float m) { return new SerializableVector3(a.x * m, a.y * m, a.z * m); } public static SerializableVector3 operator *(float m, SerializableVector3 a) { return new SerializableVector3(a.x * m, a.y * m, a.z * m); } public static SerializableVector3 operator /(SerializableVector3 a, float d) { return new SerializableVector3(a.x / d, a.y / d, a.z / d); } } public static class Utils { public static void PrintObject(object o) { if (o == null) { Debug.Log((object)"null"); } else { Debug.Log((object)(o?.ToString() + ":\n" + GetObjectString(o, " "))); } } public static string GetObjectString(object obj, string indent) { string text = ""; foreach (FieldInfo item in from f in obj.GetType().GetFields() where f.IsPublic select f) { object value = item.GetValue(obj); string text2 = ((value == null) ? "null" : value.ToString()); text = text + "\n" + indent + item.Name + ": " + text2; } return text; } public static Sprite LoadSpriteFromFile(string spritePath) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) spritePath = Path.Combine(Paths.PluginPath, spritePath); if (File.Exists(spritePath)) { byte[] array = File.ReadAllBytes(spritePath); Texture2D val = new Texture2D(20, 20); if (ImageConversion.LoadImage(val, array)) { return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), default(Vector2), 100f); } } return null; } public static Sprite LoadSpriteFromFile(string modFolder, string iconName) { return LoadSpriteFromFile(Path.Combine(modFolder, iconName)); } public static string RemoveBetween(string s, string from, string to) { int num = 0; while (num >= 0) { num = s.IndexOf(from, StringComparison.InvariantCulture); if (num < 0) { break; } int num2 = s.IndexOf(to, num, StringComparison.InvariantCulture); if (num2 < 0) { break; } s = s.Remove(num, num2 - num + to.Length); } return s; } public static void CopyFields(object originalObject, object cloneObject, Type typeToReflect, BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public) { FieldInfo[] fields = typeToReflect.GetFields(bindingFlags); foreach (FieldInfo obj in fields) { object value = obj.GetValue(originalObject); obj.SetValue(cloneObject, value); } } public static bool IsServer() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 if (!ZNet.instance.IsServer() && !ZNet.instance.IsDedicated()) { return (int)SystemInfo.graphicsDeviceType == 4; } return true; } } public static class ArrayUtils { public static bool IsNullOrEmpty<T>(T[] a) { if (a != null) { return a.Length == 0; } return true; } public static T[] Copy<T>(T[] other) { return other?.ToArray(); } } public static class ListExtensions { public static bool TryFind<T>(this List<T> list, Predicate<T> predicate, out T result) { int num = list.FindIndex(predicate); if (num != -1) { result = list[num]; return true; } result = default(T); return false; } } public class WeightedRandomCollection<T> { private readonly Random _random; private List<T> _list; private Func<T, float> _weightSelector; private bool _removeOnSelect; public float TotalWeight { get; private set; } public WeightedRandomCollection(Random random) { _random = random; } public WeightedRandomCollection(Random random, IEnumerable<T> collection, Func<T, float> weightSelector, bool removeOnSelect = false) { _random = random ?? new Random(); Setup(collection, weightSelector, removeOnSelect); } public void Setup(IEnumerable<T> collection, Func<T, float> weightSelector, bool removeOnSelect = false) { _list = collection.ToList(); _weightSelector = weightSelector; _removeOnSelect = removeOnSelect; TotalWeight = _list.Sum(_weightSelector); } public T Roll() { if (_list == null) { return default(T); } float num = (float)_random.NextDouble() * TotalWeight; float num2 = 0f; T val = default(T); foreach (var item in _list.Select((T weightedItem) => new { Value = weightedItem, Weight = _weightSelector(weightedItem) })) { num2 += item.Weight; if (num2 >= num) { val = item.Value; break; } } if (_removeOnSelect) { _list.Remove(val); TotalWeight = _list.Sum(_weightSelector); } return val; } public List<T> Roll(int numberOfRolls) { if (_list == null) { return null; } List<T> list = new List<T>(); for (int i = 0; i < numberOfRolls; i++) { T x = Roll(); if (!EqualityComparer<T>.Default.Equals(x, default(T))) { list.Add(Roll()); } } return list; } public void Reset() { _list = null; _weightSelector = null; _removeOnSelect = false; TotalWeight = 0f; } } } namespace EpicLoot { [HarmonyPatch] public static class Attack_Patch { public static Attack ActiveAttack; [HarmonyPriority(0)] [HarmonyPatch(typeof(Attack), "DoMeleeAttack")] [HarmonyPrefix] public static void Attack_DoMeleeAttack_Prefix(Attack __instance) { ActiveAttack = __instance; } [HarmonyPostfix] [HarmonyPatch(typeof(Attack), "DoMeleeAttack")] public static void Attack_DoMeleeAttack_Postfix() { ActiveAttack = null; } } [HarmonyPatch(typeof(Hud), "Awake")] public static class Hud_Awake_Patch { public static void Postfix(Hud __instance) { Object.Instantiate<GameObject>(EpicLoot.Assets.DebugTextPrefab, __instance.m_rootObject.transform, false).AddComponent<DebugText>(); } } public class DebugText : MonoBehaviour { public Text Label; private static DebugText _instance; public void Awake() { _instance = this; Label = ((Component)this).GetComponentInChildren<Text>(); ((Component)this).gameObject.SetActive(false); } public void OnDestroy() { _instance = null; } public static void SetText(string s) { _instance.Label.text = s; } } public static class EpicLootAuga { public static Button ReplaceButton(Button button, bool icon = false, bool keepListeners = false) { return ReplaceButtonInternal(API.MediumButton_Create(((Component)button).transform.parent, ((Object)button).name, string.Empty), button, icon, keepListeners); } public static Button ReplaceButtonFancy(Button button, bool icon = false, bool keepListeners = false) { return ReplaceButtonInternal(API.FancyButton_Create(((Component)button).transform.parent, ((Object)button).name, string.Empty), button, icon, keepListeners); } private static Button ReplaceButtonInternal(Button newButton, Button button, bool icon, bool keepListeners) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) if (icon) { Object.Destroy((Object)(object)((Component)((Component)newButton).GetComponentInChildren<TMP_Text>()).gameObject); ((Object)Object.Instantiate<Transform>(((Component)button).transform.Find("Icon"), ((Component)newButton).transform)).name = "Icon"; } else { string text = ((Component)button).GetComponentInChildren<Text>().text; ((Component)newButton).GetComponentInChildren<TMP_Text>().text = text; } RectTransform val = (RectTransform)((Component)button).transform; RectTransform val2 = (RectTransform)((Component)newButton).transform; val2.anchorMin = val.anchorMin; val2.anchorMax = val.anchorMax; val2.pivot = val.pivot; val2.anchoredPosition = val.anchoredPosition; Rect rect = val.rect; val2.SetSizeWithCurrentAnchors((Axis)0, ((Rect)(ref rect)).width); if (keepListeners) { newButton.onClick = button.onClick; button.onClick = new ButtonClickedEvent(); } UIGamePad component = ((Component)button).GetComponent<UIGamePad>(); if ((Object)(object)component != (Object)null && (Object)(object)component.m_hint != (Object)null) { component.m_hint.transform.SetParent(((Component)newButton).transform); UIGamePad obj = ((Component)newButton).gameObject.AddComponent<UIGamePad>(); obj.m_keyCode = component.m_keyCode; obj.m_zinputKey = component.m_zinputKey; obj.m_hint = component.m_hint; obj.m_blockingElements = component.m_blockingElements.ToList(); } Object.DestroyImmediate((Object)(object)((Component)button).gameObject); return newButton; } public static void MakeSimpleTooltip(GameObject obj) { API.Tooltip_MakeSimpleTooltip(obj); } public static void ReplaceBackground(GameObject obj, bool withCornerDecoration) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) Object.Destroy((Object)(object)obj.GetComponent<Image>()); RectTransform val = (RectTransform)API.Panel_Create(obj.transform, Vector2.one, "AugaBackground", withCornerDecoration).transform; ((Transform)val).SetSiblingIndex(0); val.anchorMin = Vector2.zero; val.anchorMax = Vector2.one; val.pivot = new Vector2(0.5f, 0.5f); val.sizeDelta = new Vector2(40f, 40f); } public static void FixItemBG(GameObject obj) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) Transform val = obj.transform.Find("MagicBG"); if ((Object)(object)val != (Object)null) { Image component = ((Component)val).GetComponent<Image>(); if ((Object)(object)component != (Object)null) { component.sprite = EpicLoot.GetMagicItemBgSprite(); } } bool flag = false; Transform val2 = obj.transform.Find("ItemBG"); Image val3 = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponent<Image>() : null); if ((Object)(object)val3 == (Object)null) { val3 = obj.GetComponent<Image>(); } if ((Object)(object)val3 != (Object)null) { val3.sprite = API.GetItemBackgroundSprite(); ((Graphic)val3).color = new Color(0f, 0f, 0f, 0.5f); flag = true; } if (!flag) { Transform val4 = obj.transform.Find("Icon"); if ((Object)(object)val4 != (Object)null) { Transform obj2 = Object.Instantiate<Transform>(val4, val4.parent); obj2.SetSiblingIndex(2); Image component2 = ((Component)obj2).GetComponent<Image>(); component2.sprite = API.GetItemBackgroundSprite(); ((Graphic)component2).color = new Color(0f, 0f, 0f, 0.5f); } } } public static void FixListElementColors(GameObject obj) { //IL_0038: 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) //IL_0081: Unknown result type (might be due to invalid IL or missing references) Transform val = obj.transform.Find("Selected"); if ((Object)(object)val != (Object)null) { Image component = ((Component)val).GetComponent<Image>(); if ((Object)(object)component != (Object)null) { Color color = default(Color); ColorUtility.TryParseHtmlString(API.Blue, ref color); ((Graphic)component).color = color; } } Transform val2 = obj.transform.Find("Background"); if ((Object)(object)val2 != (Object)null) { Image component2 = ((Component)val2).GetComponent<Image>(); if ((Object)(object)component2 != (Object)null) { ((Graphic)component2).color = new Color(0f, 0f, 0f, 0.5f); } } Button component3 = obj.GetComponent<Button>(); if ((Object)(object)component3 != (Object)null) { ((Selectable)component3).colors = ColorBlock.defaultColorBlock; } } public static void FixFonts(GameObject obj) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) TMP_Text[] componentsInChildren = obj.GetComponentsInChildren<TMP_Text>(true); Color color = default(Color); Color color2 = default(Color); foreach (TMP_Text val in componentsInChildren) { if (((Object)val.font).name == "Norsebold") { ColorUtility.TryParseHtmlString(API.Brown1, ref color); ((Graphic)val).color = color; val.text = Localization.instance.Localize(val.text).ToUpperInvariant(); } if (((Object)val).name == "Count" || ((Object)val).name == "RewardLabel" || ((Object)val).name.EndsWith("Count")) { ColorUtility.TryParseHtmlString(API.BrightGold, ref color2); ((Graphic)val).color = color2; } val.text = val.text.Replace("<color=yellow>", "<color=" + API.BrightGold + ">"); } } public static Button ReplaceVerticalLargeTab(Button button) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) GameObject obj = Object.Instantiate<GameObject>(EpicLoot.LoadAsset<GameObject>("EnchantingTabAuga"), ((Component)button).transform.parent); ((Object)obj).name = ((Object)button).name; FixFonts(obj); int siblingIndex = ((Component)button).transform.GetSiblingIndex(); RectTransform val = (RectTransform)((Component)button).transform; RectTransform val2 = (RectTransform)obj.transform; val2.anchorMin = val.anchorMin; val2.anchorMax = val.anchorMax; val2.pivot = val.pivot; val2.anchoredPosition = val.anchoredPosition; Rect rect = val.rect; val2.SetSizeWithCurrentAnchors((Axis)0, ((Rect)(ref rect)).width); ((Component)obj.transform.Find("Text")).GetComponent<TMP_Text>().text = ((Component)((Component)button).transform.Find("Text")).GetComponent<TMP_Text>().text; ((Component)obj.transform.Find("Image")).GetComponent<Image>().sprite = ((Component)((Component)button).transform.Find("Image")).GetComponent<Image>().sprite; FeatureStatus component = obj.GetComponent<FeatureStatus>(); FeatureStatus component2 = ((Component)button).GetComponent<FeatureStatus>(); if ((Object)(object)component2 == (Object)null && (Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } if ((Object)(object)component != (Object)null && (Object)(object)component2 != (Object)null) { component.Feature = component2.Feature; component.Refresh(); } Object.DestroyImmediate((Object)(object)((Component)button).gameObject); obj.transform.SetSiblingIndex(siblingIndex); return obj.GetComponent<Button>(); } public static void FixupScrollbar(Scrollbar scrollbar) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) Object.Destroy((Object)(object)((Component)scrollbar).GetComponent<Image>()); ((Selectable)scrollbar).colors = ColorBlock.defaultColorBlock; Image component = ((Component)scrollbar.handleRect).GetComponent<Image>(); Color val = default(Color); if (ColorUtility.TryParseHtmlString("#8B7C6A", ref val)) { ((Graphic)component).color = new Color(val.r, val.g, val.b, 1f); } } } [HarmonyPatch(typeof(GameCamera), "UpdateCamera")] public static class GameCamera_UpdateCamera_Patch { public static bool Prefix(GameCamera __instance) { if (__instance.m_freeFly) { __instance.UpdateFreeFly(1f / 30f); __instance.UpdateCameraShake(1f / 30f); return false; } return true; } } [HarmonyPatch(typeof(Humanoid))] public class Humanoid_Patch { [HarmonyPatch("SetupVisEquipment")] [HarmonyPrefix] public static bool SetupVisEquipment_Prefix(Humanoid __instance, VisEquipment visEq, bool isRagdoll) { if (!isRagdoll) { object obj; if (__instance.m_leftItem == null) { obj = ""; } else { ItemData leftItem = __instance.m_leftItem; if (leftItem == null) { obj = null; } else { GameObject dropPrefab = leftItem.m_dropPrefab; obj = ((dropPrefab != null) ? ((Object)dropPrefab).name : null); } } visEq.SetLeftItem((string)obj, __instance.m_leftItem?.m_variant ?? 0); object rightItem; if (__instance.m_rightItem == null) { rightItem = ""; } else { ItemData rightItem2 = __instance.m_rightItem; if (rightItem2 == null) { rightItem = null; } else { GameObject dropPrefab2 = rightItem2.m_dropPrefab; rightItem = ((dropPrefab2 != null) ? ((Object)dropPrefab2).name : null); } } visEq.SetRightItem((string)rightItem); if (((Character)__instance).IsPlayer()) { object obj2; if (__instance.m_hiddenLeftItem == null) { obj2 = ""; } else { GameObject dropPrefab3 = __instance.m_hiddenLeftItem.m_dropPrefab; obj2 = ((dropPrefab3 != null) ? ((Object)dropPrefab3).name : null); } visEq.SetLeftBackItem((string)obj2, __instance.m_hiddenLeftItem?.m_variant ?? 0); object rightBackItem; if (__instance.m_hiddenRightItem == null) { rightBackItem = ""; } else { GameObject dropPrefab4 = __instance.m_hiddenRightItem.m_dropPrefab; rightBackItem = ((dropPrefab4 != null) ? ((Object)dropPrefab4).name : null); } visEq.SetRightBackItem((string)rightBackItem); } } object chestItem; if (__instance.m_chestItem == null) { chestItem = ""; } else { ItemData chestItem2 = __instance.m_chestItem; if (chestItem2 == null) { chestItem = null; } else { GameObject dropPrefab5 = chestItem2.m_dropPrefab; chestItem = ((dropPrefab5 != null) ? ((Object)dropPrefab5).name : null); } } visEq.SetChestItem((string)chestItem); object legItem; if (__instance.m_legItem == null) { legItem = ""; } else { ItemData legItem2 = __instance.m_legItem; if (legItem2 == null) { legItem = null; } else { GameObject dropPrefab6 = legItem2.m_dropPrefab; legItem = ((dropPrefab6 != null) ? ((Object)dropPrefab6).name : null); } } visEq.SetLegItem((string)legItem); object helmetItem; if (__instance.m_helmetItem == null) { helmetItem = ""; } else { ItemData helmetItem2 = __instance.m_helmetItem; if (helmetItem2 == null) { helmetItem = null; } else { GameObject dropPrefab7 = helmetItem2.m_dropPrefab; helmetItem = ((dropPrefab7 != null) ? ((Object)dropPrefab7).name : null); } } visEq.SetHelmetItem((string)helmetItem); object obj3; if (__instance.m_shoulderItem == null) { obj3 = ""; } else { ItemData shoulderItem = __instance.m_shoulderItem; if (shoulderItem == null) { obj3 = null; } else { GameObject dropPrefab8 = shoulderItem.m_dropPrefab; obj3 = ((dropPrefab8 != null) ? ((Object)dropPrefab8).name : null); } } visEq.SetShoulderItem((string)obj3, __instance.m_shoulderItem?.m_variant ?? 0); object utilityItem; if (__instance.m_utilityItem == null) { utilityItem = ""; } else { ItemData utilityItem2 = __instance.m_utilityItem; if (utilityItem2 == null) { utilityItem = null; } else { GameObject dropPrefab9 = utilityItem2.m_dropPrefab; utilityItem = ((dropPrefab9 != null) ? ((Object)dropPrefab9).name : null); } } visEq.SetUtilityItem((string)utilityItem); if (!((Character)__instance).IsPlayer()) { return false; } visEq.SetBeardItem(__instance.m_beardItem); visEq.SetHairItem(__instance.m_hairItem); return false; } } public static class EpicLootDropsHelper { public static bool InstantDropsEnabled { get; set; } } [HarmonyPatch(typeof(CharacterDrop), "OnDeath")] public static class CharacterDrop_OnDeath_Patch { public static void Postfix(CharacterDrop __instance) { if (EpicLootDropsHelper.InstantDropsEnabled) { EpicLoot.OnCharacterDeath(__instance); } } } [HarmonyPatch(typeof(Ragdoll), "Setup")] public static class Ragdoll_Setup_Patch { public static void Postfix(Ragdoll __instance, CharacterDrop characterDrop) { if (!((Object)(object)characterDrop == (Object)null) && !((Object)(object)characterDrop.m_character == (Object)null) && !characterDrop.m_character.IsPlayer() && EpicLoot.CanCharacterDropLoot(characterDrop.m_character)) { EpicLootDropsHelper.InstantDropsEnabled = false; string characterCleanName = EpicLoot.GetCharacterCleanName(characterDrop.m_character); int level = characterDrop.m_character.GetLevel(); __instance.m_nview.m_zdo.Set("characterName", characterCleanName); __instance.m_nview.m_zdo.Set("level", level); } } } [HarmonyPatch(typeof(Ragdoll), "SpawnLoot")] public static class Ragdoll_SpawnLoot_Patch { public static void Postfix(Ragdoll __instance, Vector3 center) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) string @string = __instance.m_nview.m_zdo.GetString("characterName", ""); int @int = __instance.m_nview.m_zdo.GetInt("level", 0); if (!string.IsNullOrEmpty(@string)) { EpicLoot.OnCharacterDeath(@string, @int, center + Vector3.up * 0.75f); } } } [HarmonyPatch(typeof(CharacterDrop), "GenerateDropList")] public static class CharacterDrop_GenerateDropList_DropsEnabled { [HarmonyPriority(800)] [HarmonyBefore(new string[] { "org.bepinex.plugins.creaturelevelcontrol" })] public static void Postfix(CharacterDrop __instance) { EpicLootDropsHelper.InstantDropsEnabled = __instance.m_dropsEnabled; } } [HarmonyPatch(typeof(CharacterDrop), "GenerateDropList")] public static class CharacterDrop_GenerateDropList_Patch { public static void Prefix(CharacterDrop __instance) { if (!((Object)(object)__instance.m_character != (Object)null) || !__instance.m_character.IsBoss() || EpicLoot.GetBossTrophyDropMode() == BossDropMode.Default) { return; } foreach (Drop drop in __instance.m_drops) { if (!((Object)(object)drop.m_prefab == (Object)null) && ((((Object)drop.m_prefab).name.Equals("Wishbone") && EpicLoot.GetBossWishboneDropMode() != 0) || (((Object)drop.m_prefab).name.Equals("CryptKey") && EpicLoot.GetBossCryptKeyDropMode() != 0)) && drop.m_onePerPlayer) { drop.m_onePerPlayer = false; } } } public static void Postfix(CharacterDrop __instance, ref List<KeyValuePair<GameObject, int>> __result) { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Invalid comparison between Unknown and I4 //IL_00f1: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)__instance.m_character != (Object)null) || !__instance.m_character.IsBoss() || EpicLoot.GetBossTrophyDropMode() == BossDropMode.Default) { return; } for (int i = 0; i < __result.Count; i++) { GameObject key = __result[i].Key; ItemDrop component = key.GetComponent<ItemDrop>(); if (!((Object)(object)component == (Object)null) && component.m_itemData != null && ((int)component.m_itemData.m_shared.m_itemType == 13 || ((Object)key).name.Equals("Wishbone") || ((Object)key).name.Equals("CryptKey"))) { List<PlayerInfo> playerList = ZNet.instance.GetPlayerList(); int num = EpicLoot.GetBossTrophyDropMode() switch { BossDropMode.OnePerPlayerOnServer => playerList.Count, BossDropMode.OnePerPlayerNearBoss => Math.Max(Player.GetPlayersInRangeXZ(((Component)__instance.m_character).transform.position, EpicLoot.GetBossTrophyDropPlayerRange()), playerList.Count((PlayerInfo x) => Vector3.Distance(x.m_position, ((Component)__instance.m_character).transform.position) <= EpicLoot.GetBossTrophyDropPlayerRange())), _ => 1, }; EpicLoot.Log($"Dropping trophies: {num} (mode={EpicLoot.GetBossTrophyDropMode()})"); __result[i] = new KeyValuePair<GameObject, int>(key, num); } } } } public class Multiplayer_Player_Patch { [HarmonyPatch] public static class Humanoid_Patch { [HarmonyPatch(typeof(Humanoid), "EquipItem")] public class AttachExtendedDataToZDO_Humanoid_EquipItem_Patch { [UsedImplicitly] private static void Postfix(ItemData item, bool __result, Humanoid __instance) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown if (__result && (Object)(object)__instance == (Object)(object)Player.m_localPlayer && item != null) { UpdatePlayerZDOForEquipment((Player)__instance, item, equip: true); } } } [HarmonyPatch(typeof(Humanoid), "UnequipItem")] public class AttachExtendedDataToZDO_Humanoid_UnequipItem_Patch { [UsedImplicitly] private static void Prefix(Humanoid __instance, ItemData item) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer && item != null && ((Humanoid)Player.m_localPlayer).IsItemEquiped(item)) { UpdatePlayerZDOForEquipment((Player)__instance, item, equip: false); } } } } [HarmonyPatch(typeof(Player), "Update")] public static class WatchLegendaryEquipment_Player_Update_Patch { private static float _updateEventTime; [UsedImplicitly] public static void Postfix(Player __instance) { _updateEventTime -= Time.deltaTime; if ((double)_updateEventTime > 0.0) { return; } _updateEventTime = 10f; if ((Object)(object)__instance != (Object)null && (Object)(object)__instance != (Object)(object)Player.m_localPlayer && (Object)(object)((Character)__instance).m_nview != (Object)null) { ZDO zDO = ((Character)__instance).m_nview.GetZDO(); if (zDO != null && (DoCheck(__instance, zDO, "LeftItem", "lf-ell", ref ((Humanoid)__instance).m_leftItem) || DoCheck(__instance, zDO, "RightItem", "ri-ell", ref ((Humanoid)__instance).m_rightItem) || DoCheck(__instance, zDO, "ChestItem", "ch-ell", ref ((Humanoid)__instance).m_chestItem) || DoCheck(__instance, zDO, "LegItem", "lg-ell", ref ((Humanoid)__instance).m_legItem) || DoCheck(__instance, zDO, "HelmetItem", "hl-ell", ref ((Humanoid)__instance).m_helmetItem) || DoCheck(__instance, zDO, "ShoulderItem", "sh-ell", ref ((Humanoid)__instance).m_shoulderItem) || DoCheck(__instance, zDO, "UtilityItem", "ut-ell", ref ((Humanoid)__instance).m_utilityItem))) { ((Humanoid)__instance).SetupVisEquipment(((Humanoid)__instance).m_visEquipment, false); } } } private static bool DoCheck(Player player, ZDO zdo, string equipKey, string legendaryDataKey, ref ItemData itemData) { string @string = zdo.GetString(legendaryDataKey, ""); if (string.IsNullOrEmpty(@string)) { bool num = itemData != null; if (num) { ForceResetVisEquipment((Humanoid)(object)player, itemData); } itemData = null; return num; } if (itemData?.GetMagicItem()?.LegendaryID == @string) { return false; } int @int = zdo.GetInt(equipKey, 0); GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(@int); ItemData val = ((itemPrefab == null) ? null : itemPrefab.GetComponent<ItemDrop>()?.m_itemData); if (val != null) { itemData = val.Clone(); itemData.m_durability = float.PositiveInfinity; MagicItemComponent orCreate = itemData.Data().GetOrCreate<MagicItemComponent>(); MagicItem magicItem = new MagicItem { Rarity = ItemRarity.Legendary, LegendaryID = @string }; orCreate.SetMagicItem(magicItem); ForceResetVisEquipment((Humanoid)(object)player, itemData); } return false; } public static void ForceResetVisEquipment(Humanoid humanoid, ItemData item) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected I4, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Invalid comparison between Unknown and I4 if ((Object)(object)humanoid == (Object)null || (Object)(object)humanoid.m_visEquipment == (Object)null || item == null) { return; } ItemType itemType = item.m_shared.m_itemType; switch (itemType - 3) { case 0: if (humanoid.m_rightItem != null && (int)humanoid.m_rightItem.m_shared.m_itemType == 15 && humanoid.m_leftItem == null) { humanoid.m_visEquipment.m_currentLeftItemHash = -1; } humanoid.m_visEquipment.m_currentRightItemHash = -1; break; case 1: case 2: humanoid.m_visEquipment.m_currentLeftItemHash = -1; break; case 11: case 19: humanoid.m_visEquipment.m_currentRightItemHash = -1; humanoid.m_visEquipment.m_currentLeftItemHash = -1; break; case 4: humanoid.m_visEquipment.m_currentChestItemHash = -1; break; case 8: humanoid.m_visEquipment.m_currentLegItemHash = -1; break; case 3: humanoid.m_visEquipment.m_currentHelmetItemHash = -1; break; case 14: humanoid.m_visEquipment.m_currentShoulderItemHash = -1; break; case 15: humanoid.m_visEquipment.m_currentUtilityItemHash = -1; break; case 16: humanoid.m_visEquipment.m_currentRightItemHash = -1; break; case 5: case 6: case 7: case 9: case 10: case 12: case 13: case 17: case 18: break; } } } [HarmonyPatch] public static class WatchMultiplayerMagicEffects_Player_Patch { [HarmonyPatch(typeof(Humanoid), "EquipItem")] [HarmonyPostfix] public static void EquipItem_Postfix(Humanoid __instance) { Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null) { UpdateRichesAndLuck(val); } } [HarmonyPatch(typeof(Humanoid), "UnequipItem")] [HarmonyPostfix] public static void UnequipItem_Postfix(Humanoid __instance) { Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null) { UpdateRichesAndLuck(val); } } public static void UpdateRichesAndLuck(Player player) { if (!((Object)(object)player == (Object)(object)Player.m_localPlayer)) { return; } ZNetView nview = ((Character)player).m_nview; ZDO val = ((nview != null) ? nview.GetZDO() : null); if (val != null) { int @int = val.GetInt("el-luk", 0); int int2 = val.GetInt("el-rch", 0); int num = (int)player.GetTotalActiveMagicEffectValue(MagicEffectType.Luck); int num2 = (int)player.GetTotalActiveMagicEffectValue(MagicEffectType.Riches); if (num != @int) { val.Set("el-luk", num); } if (num2 != int2) { val.Set("el-rch", num2); } } } } public static void UpdatePlayerZDOForEquipment(Player player, ItemData item, bool equip) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected I4, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Invalid comparison between Unknown and I4 object obj; if (player == null) { obj = null; } else { ZNetView nview = ((Character)player).m_nview; obj = ((nview != null) ? nview.GetZDO() : null); } ZDO val = (ZDO)obj; if (val == null) { return; } MagicItem magicItem = item.GetMagicItem(); string text = ((!equip) ? "" : ((magicItem != null && magicItem.IsUniqueLegendary()) ? magicItem.LegendaryID : "")); ItemType itemType = item.m_shared.m_itemType; switch (itemType - 3) { default: if ((int)itemType != 22) { break; } goto case 0; case 0: case 1: case 2: case 11: { ItemData leftItem = ((Humanoid)player).m_leftItem; if (((leftItem != null) ? ((Object)leftItem.m_dropPrefab).name : null) == ((Object)item.m_dropPrefab).name) { val.Set("lf-ell", text); } ItemData rightItem = ((Humanoid)player).m_rightItem; if (((rightItem != null) ? ((Object)rightItem.m_dropPrefab).name : null) == ((Object)item.m_dropPrefab).name) { val.Set("ri-ell", text); } break; } case 4: val.Set("ch-ell", text); break; case 8: val.Set("lg-ell", text); break; case 3: val.Set("hl-ell", text); break; case 14: val.Set("sh-ell", text); break; case 15: val.Set("ut-ell", text); break; case 5: case 6: case 7: case 9: case 10: case 12: case 13: break; } } } [HarmonyPatch(typeof(Terminal), "InitTerminal")] public static class Terminal_Patch { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEvent <>9__1_0; public static ConsoleEvent <>9__1_1; public static ConsoleEvent <>9__1_2; public static ConsoleEvent <>9__1_3; public static ConsoleEvent <>9__1_4; public static ConsoleEvent <>9__1_5; public static ConsoleEvent <>9__1_6; public static ConsoleEvent <>9__1_7; public static ConsoleEvent <>9__1_8; public static ConsoleEvent <>9__1_9; public static ConsoleEvent <>9__1_10; public static ConsoleEvent <>9__1_11; public static ConsoleEvent <>9__1_12; public static ConsoleEvent <>9__1_13; public static ConsoleEvent <>9__1_14; public static ConsoleEvent <>9__1_15; public static ConsoleEvent <>9__1_16; public static ConsoleEvent <>9__1_17; public static ConsoleEvent <>9__1_18; public static ConsoleEvent <>9__1_19; public static ConsoleEvent <>9__1_20; public static ConsoleEvent <>9__1_21; public static ConsoleEvent <>9__1_22; public static ConsoleEvent <>9__1_23; public static ConsoleEvent <>9__1_24; public static ConsoleEvent <>9__1_25; public static ConsoleEvent <>9__1_26; public static ConsoleEvent <>9__1_27; public static ConsoleEvent <>9__1_28; public static ConsoleEvent <>9__1_29; public static ConsoleEvent <>9__1_30; public static Func<TreasureMapChestInfo, int> <>9__4_0; public static Func<GameObject, bool> <>9__8_0; public static Func<GameObject, bool> <>9__8_1; public static Func<GameObject, string> <>9__8_2; public static Func<string, float> <>9__8_3; internal void <Postfix>b__1_0(ConsoleEventArgs args) { MagicItem(args.Context, args.Args); } internal void <Postfix>b__1_1(ConsoleEventArgs args) { MagicItem(args.Context, args.Args); } internal void <Postfix>b__1_2(ConsoleEventArgs args) { SpawnMagicItemWithEffect(args.Context, args.Args); } internal void <Postfix>b__1_3(ConsoleEventArgs args) { SpawnMagicItemWithEffect(args.Context, args.Args); } internal void <Postfix>b__1_4(ConsoleEventArgs args) { SpawnLegendaryMagicItem(args.Context, args.Args); } internal void <Postfix>b__1_5(ConsoleEventArgs args) { SpawnLegendaryMagicItem(args.Context, args.Args); } internal void <Postfix>b__1_6(ConsoleEventArgs args) { SpawnMagicItemSet(args.Context, args.Args); } internal void <Postfix>b__1_7(ConsoleEventArgs args) { SpawnMagicItemSet(args.Context, args.Args); } internal void <Postfix>b__1_8(ConsoleEventArgs args) { CheckStackQuality(args.Context); } internal void <Postfix>b__1_9(ConsoleEventArgs args) { SpawnMagicCraftingMaterials(); } internal void <Postfix>b__1_10(ConsoleEventArgs args) { ToggleAlwaysDrop(args.Context); } internal void <Postfix>b__1_11(ConsoleEventArgs args) { LootRoller.CheatDisableGating = !LootRoller.CheatDisableGating; args.Context.AddString($"> Disable gating for magic item drops: {LootRoller.CheatDisableGating}"); } internal void <Postfix>b__1_12(ConsoleEventArgs args) { TestTreasureMap(args.Args); } internal void <Postfix>b__1_13(ConsoleEventArgs args) { TestTreasureMap(args.Args); } internal void <Postfix>b__1_14(ConsoleEventArgs args) { AdventureSaveData adventureSaveData = Player.m_localPlayer.GetAdventureSaveData(); adventureSaveData.TreasureMaps.Clear(); adventureSaveData.NumberOfTreasureMapsOrBountiesStarted = 0; ResetMinimap(); } internal void <Postfix>b__1_15(ConsoleEventArgs args) { AdventureSaveData adventureSaveData = Player.m_localPlayer.GetAdventureSaveData(); adventureSaveData.TreasureMaps.Clear(); adventureSaveData.NumberOfTreasureMapsOrBountiesStarted = 0; ResetMinimap(); } internal void <Postfix>b__1_16(ConsoleEventArgs args) { MinimapController.DebugMode = !MinimapController.DebugMode; args.Context.AddString($"> Treasure Map Debug Mode: {MinimapController.DebugMode}"); } internal void <Postfix>b__1_17(ConsoleEventArgs args) { MinimapController.DebugMode = !MinimapController.DebugMode; args.Context.AddString($"> Treasure Map Debug Mode: {MinimapController.DebugMode}"); } internal void <Postfix>b__1_18(ConsoleEventArgs args) { Player.m_localPlayer.GetAdventureSaveData().Bounties.Clear(); ResetMinimap(); } internal void <Postfix>b__1_19(ConsoleEventArgs args) { Random random = new Random(); int num = ((args.Length >= 2) ? int.Parse(args[1]) : 10); for (int i = 0; i < num; i++) { string text = BountiesAdventureFeature.GenerateTargetName(random); args.Context.AddString(text); } } internal void <Postfix>b__1_20(ConsoleEventArgs args) { ((Component)Player.m_localPlayer).GetComponent<AdventureComponent>().SaveData = new AdventureSaveDataList(); ResetMinimap(); } internal void <Postfix>b__1_21(ConsoleEventArgs args) { int num = ((args.Length >= 2) ? int.Parse(args[1]) : AdventureDataManager.Bounties.GetCurrentInterval()); List<BountyInfo> availableBounties = AdventureDataManager.Bounties.GetAvailableBounties(num, removeAcceptedBounties: false); BountiesAdventureFeature.PrintBounties($"Bounties for Interval {num}:", availableBounties); } internal void <Postfix>b__1_22(ConsoleEventArgs args) { List<BountyInfo> bounties = Player.m_localPlayer.GetAdventureSaveData().Bounties; BountiesAdventureFeature.PrintBounties("Player Bounties:", bounties); } internal void <Postfix>b__1_23(ConsoleEventArgs args) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; LocationInstance val = default(LocationInstance); if (ZoneSystem.instance.FindClosestLocation("Vendor_BlackForest", ((Component)localPlayer).transform.position, ref val)) { ((Terminal)Console.instance).AddString(((object)(Vector3)(ref val.m_position)).ToString()); } } internal void <Postfix>b__1_24(ConsoleEventArgs args) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; LocationInstance val = default(LocationInstance); if (ZoneSystem.instance.FindClosestLocation("Vendor_BlackForest", ((Component)localPlayer).transform.position, ref val)) { ((Terminal)Console.instance).AddString(((object)(Vector3)(ref val.m_position)).ToString()); } } internal void <Postfix>b__1_25(ConsoleEventArgs args) { if (!((Object)(object)ZoneSystem.instance != (Object)null)) { return; } args.Context.AddString("> Print Global Keys:"); foreach (string globalKey in ZoneSystem.instance.GetGlobalKeys()) { args.Context.AddString("> " + globalKey); } } internal void <Postfix>b__1_26(ConsoleEventArgs args) { FixResistances(Player.m_localPlayer); } internal void <Postfix>b__1_27(ConsoleEventArgs args) { string lootTableName = ((args.Length > 1) ? args[1] : "Greydwarf"); float luckFactor = ((args.Length > 2) ? float.Parse(args[2]) : 0f); LootRoller.PrintLuckTest(lootTableName, luckFactor); } internal void <Postfix>b__1_28(ConsoleEventArgs args) { string lootTableName = ((args.Length > 1) ? args[1] : "Greydwarf"); int level = ((args.Length <= 2) ? 1 : int.Parse(args[2])); int itemIndex = ((args.Length > 3) ? int.Parse(args[3]) : 0); LootRoller.PrintLootResolutionTest(lootTableName, level, itemIndex); } internal void <Postfix>b__1_29(ConsoleEventArgs args) { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer != (Object)null)) { return; } AbilityController component = ((Component)localPlayer).GetComponent<AbilityController>(); if (!((Object)(object)component != (Object)null)) { return; } foreach (Ability currentAbility in component.CurrentAbilities) { currentAbility.ResetCooldown(); } } internal void <Postfix>b__1_30(ConsoleEventArgs args) { LootRoller.DebugLuckFactor(); } internal int <TestTreasureMapCoroutine>b__4_0(TreasureMapChestInfo x) { return x.Interval; } internal bool <MagicItem>b__8_0(GameObject x) { return EpicLoot.CanBeMagicItem(x.GetComponent<ItemDrop>().m_itemData); } internal bool <MagicItem>b__8_1(GameObject x) { if (((Object)x).name != "HelmetDverger" && ((Object)x).name != "BeltStrength") { return ((Object)x).name != "Wishbone"; } return false; } internal string <MagicItem>b__8_2(GameObject x) { return ((Object)x).name; } internal float <MagicItem>b__8_3(string x) { return 1f; } } private static readonly Random _random = new Random(); public static void Postfix() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_0061: Expected O, but got Unknown //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Expected O, but got Unknown //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Expected O, but got Unknown //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Expected O, but got Unknown //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Expected O, but got Unknown //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Expected O, but got Unknown //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Expected O, but got Unknown //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Expected O, but got Unknown //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Expected O, but got Unknown //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Expected O, but got Unknown //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Expected O, but got Unknown //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Expected O, but got Unknown //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Expected O, but got Unknown //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Expected O, but got Unknown //IL_03ea: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Expected O, but got Unknown //IL_0422: Unknown result type (might be due to invalid IL or missing references) //IL_040e: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Expected O, but got Unknown //IL_045a: Unknown result type (might be due to invalid IL or missing references) //IL_0446: Unknown result type (might be due to invalid IL or missing references) //IL_044b: Unknown result type (might be due to invalid IL or missing references) //IL_0451: Expected O, but got Unknown //IL_0492: Unknown result type (might be due to invalid IL or missing references) //IL_047e: Unknown result type (might be due to invalid IL or missing references) //IL_0483: Unknown result type (might be due to invalid IL or missing references) //IL_0489: Expected O, but got Unknown //IL_04ca: Unknown result type (might be due to invalid IL or missing references) //IL_04b6: Unknown result type (might be due to invalid IL or missing references) //IL_04bb: Unknown result type (might be due to invalid IL or missing references) //IL_04c1: Expected O, but got Unknown //IL_0502: Unknown result type (might be due to invalid IL or missing references) //IL_04ee: Unknown result type (might be due to invalid IL or missing references) //IL_04f3: Unknown result type (might be due to invalid IL or missing references) //IL_04f9: Expected O, but got Unknown //IL_053a: Unknown result type (might be due to invalid IL or missing references) //IL_0526: Unknown result type (might be due to invalid IL or missing references) //IL_052b: Unknown result type (might be due to invalid IL or missing references) //IL_0531: Expected O, but got Unknown //IL_0572: Unknown result type (might be due to invalid IL or missing references) //IL_055e: Unknown result type (might be due to invalid IL or missing references) //IL_0563: Unknown result type (might be due to invalid IL or missing references) //IL_0569: Expected O, but got Unknown //IL_05aa: Unknown result type (might be due to invalid IL or missing references) //IL_0596: Unknown result type (might be due to invalid IL or missing references) //IL_059b: Unknown result type (might be due to invalid IL or missing references) //IL_05a1: Expected O, but got Unknown //IL_05e2: Unknown result type (might be due to invalid IL or missing references) //IL_05ce: Unknown result type (might be due to invalid IL or missing references) //IL_05d3: Unknown result type (might be due to invalid IL or missing references) //IL_05d9: Expected O, but got Unknown //IL_061a: Unknown result type (might be due to invalid IL or missing references) //IL_0606: Unknown result type (might be due to invalid IL or missing references) //IL_060b: Unknown result type (might be due to invalid IL or missing references) //IL_0611: Expected O, but got Unknown //IL_0652: Unknown result type (might be due to invalid IL or missing references) //IL_063e: Unknown result type (might be due to invalid IL or missing references) //IL_0643: Unknown result type (might be due to invalid IL or missing references) //IL_0649: Expected O, but got Unknown //IL_068a: Unknown result type (might be due to invalid IL or missing references) //IL_0676: Unknown result type (might be due to invalid IL or missing references) //IL_067b: Unknown result type (might be due to invalid IL or missing references) //IL_0681: Expected O, but got Unknown //IL_06c2: Unknown result type (might be due to invalid IL or missing references) //IL_06ae: Unknown result type (might be due to invalid IL or missing references) //IL_06b3: Unknown result type (might be due to invalid IL or missing references) //IL_06b9: Expected O, but got Unknown object obj = <>c.<>9__1_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { MagicItem(args.Context, args.Args); }; <>c.<>9__1_0 = val; obj = (object)val; } new ConsoleCommand("magicitem", "", (ConsoleEvent)obj, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj2 = <>c.<>9__1_1; if (obj2 == null) { ConsoleEvent val2 = delegate(ConsoleEventArgs args) { MagicItem(args.Context, args.Args); }; <>c.<>9__1_1 = val2; obj2 = (object)val2; } new ConsoleCommand("mi", "", (ConsoleEvent)obj2, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj3 = <>c.<>9__1_2; if (obj3 == null) { ConsoleEvent val3 = delegate(ConsoleEventArgs args) { SpawnMagicItemWithEffect(args.Context, args.Args); }; <>c.<>9__1_2 = val3; obj3 = (object)val3; } new ConsoleCommand("magicitemwitheffect", "", (ConsoleEvent)obj3, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj4 = <>c.<>9__1_3; if (obj4 == null) { ConsoleEvent val4 = delegate(ConsoleEventArgs args) { SpawnMagicItemWithEffect(args.Context, args.Args); }; <>c.<>9__1_3 = val4; obj4 = (object)val4; } new ConsoleCommand("mieffect", "", (ConsoleEvent)obj4, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj5 = <>c.<>9__1_4; if (obj5 == null) { ConsoleEvent val5 = delegate(ConsoleEventArgs args) { SpawnLegendaryMagicItem(args.Context, args.Args); }; <>c.<>9__1_4 = val5; obj5 = (object)val5; } new ConsoleCommand("magicitemlegendary", "", (ConsoleEvent)obj5, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj6 = <>c.<>9__1_5; if (obj6 == null) { ConsoleEvent val6 = delegate(ConsoleEventArgs args) { SpawnLegendaryMagicItem(args.Context, args.Args); }; <>c.<>9__1_5 = val6; obj6 = (object)val6; } new ConsoleCommand("milegend", "", (ConsoleEvent)obj6, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj7 = <>c.<>9__1_6; if (obj7 == null) { ConsoleEvent val7 = delegate(ConsoleEventArgs args) { SpawnMagicItemSet(args.Context, args.Args); }; <>c.<>9__1_6 = val7; obj7 = (object)val7; } new ConsoleCommand("magicitemset", "", (ConsoleEvent)obj7, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj8 = <>c.<>9__1_7; if (obj8 == null) { ConsoleEvent val8 = delegate(ConsoleEventArgs args) { SpawnMagicItemSet(args.Context, args.Args); }; <>c.<>9__1_7 = val8; obj8 = (object)val8; } new ConsoleCommand("miset", "", (ConsoleEvent)obj8, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj9 = <>c.<>9__1_8; if (obj9 == null) { ConsoleEvent val9 = delegate(ConsoleEventArgs args) { CheckStackQuality(args.Context); }; <>c.<>9__1_8 = val9; obj9 = (object)val9; } new ConsoleCommand("checkstackquality", "", (ConsoleEvent)obj9, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj10 = <>c.<>9__1_9; if (obj10 == null) { ConsoleEvent val10 = delegate { SpawnMagicCraftingMaterials(); }; <>c.<>9__1_9 = val10; obj10 = (object)val10; } new ConsoleCommand("magicmats", "", (ConsoleEvent)obj10, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj11 = <>c.<>9__1_10; if (obj11 == null) { ConsoleEvent val11 = delegate(ConsoleEventArgs args) { ToggleAlwaysDrop(args.Context); }; <>c.<>9__1_10 = val11; obj11 = (object)val11; } new ConsoleCommand("alwaysdrop", "", (ConsoleEvent)obj11, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj12 = <>c.<>9__1_11; if (obj12 == null) { ConsoleEvent val12 = delegate(ConsoleEventArgs args) { LootRoller.CheatDisableGating = !LootRoller.CheatDisableGating; args.Context.AddString($"> Disable gating for magic item drops: {LootRoller.CheatDisableGating}"); }; <>c.<>9__1_11 = val12; obj12 = (object)val12; } new ConsoleCommand("cheatgating", "", (ConsoleEvent)obj12, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj13 = <>c.<>9__1_12; if (obj13 == null) { ConsoleEvent val13 = delegate(ConsoleEventArgs args) { TestTreasureMap(args.Args); }; <>c.<>9__1_12 = val13; obj13 = (object)val13; } new ConsoleCommand("testtreasuremap", "", (ConsoleEvent)obj13, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj14 = <>c.<>9__1_13; if (obj14 == null) { ConsoleEvent val14 = delegate(ConsoleEventArgs args) { TestTreasureMap(args.Args); }; <>c.<>9__1_13 = val14; obj14 = (object)val14; } new ConsoleCommand("testtm", "", (ConsoleEvent)obj14, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj15 = <>c.<>9__1_14; if (obj15 == null) { ConsoleEvent val15 = delegate { AdventureSaveData adventureSaveData2 = Player.m_localPlayer.GetAdventureSaveData(); adventureSaveData2.TreasureMaps.Clear(); adventureSaveData2.NumberOfTreasureMapsOrBountiesStarted = 0; ResetMinimap(); }; <>c.<>9__1_14 = val15; obj15 = (object)val15; } new ConsoleCommand("resettreasuremap", "", (ConsoleEvent)obj15, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj16 = <>c.<>9__1_15; if (obj16 == null) { ConsoleEvent val16 = delegate { AdventureSaveData adventureSaveData = Player.m_localPlayer.GetAdventureSaveData(); adventureSaveData.TreasureMaps.Clear(); adventureSaveData.NumberOfTreasureMapsOrBountiesStarted = 0; ResetMinimap(); }; <>c.<>9__1_15 = val16; obj16 = (object)val16; } new ConsoleCommand("resettm", "", (ConsoleEvent)obj16, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj17 = <>c.<>9__1_16; if (obj17 == null) { ConsoleEvent val17 = delegate(ConsoleEventArgs args) { MinimapController.DebugMode = !MinimapController.DebugMode; args.Context.AddString($"> Treasure Map Debug Mode: {MinimapController.DebugMode}"); }; <>c.<>9__1_16 = val17; obj17 = (object)val17; } new ConsoleCommand("debugtreasuremap", "", (ConsoleEvent)obj17, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj18 = <>c.<>9__1_17; if (obj18 == null) { ConsoleEvent val18 = delegate(ConsoleEventArgs args) { MinimapController.DebugMode = !MinimapController.DebugMode; args.Context.AddString($"> Treasure Map Debug Mode: {MinimapController.DebugMode}"); }; <>c.<>9__1_17 = val18; obj18 = (object)val18; } new ConsoleCommand("debugtm", "", (ConsoleEvent)obj18, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj19 = <>c.<>9__1_18; if (obj19 == null) { ConsoleEvent val19 = delegate { Player.m_localPlayer.GetAdventureSaveData().Bounties.Clear(); ResetMinimap(); }; <>c.<>9__1_18 = val19; obj19 = (object)val19; } new ConsoleCommand("resetbounties", "", (ConsoleEvent)obj19, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj20 = <>c.<>9__1_19; if (obj20 == null) { ConsoleEvent val20 = delegate(ConsoleEventArgs args) { Random random = new Random(); int num2 = ((args.Length >= 2) ? int.Parse(args[1]) : 10); for (int i = 0; i < num2; i++) { string text = BountiesAdventureFeature.GenerateTargetName(random); args.Context.AddString(text); } }; <>c.<>9__1_19 = val20; obj20 = (object)val20; } new ConsoleCommand("testbountynames", "", (ConsoleEvent)obj20, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj21 = <>c.<>9__1_20; if (obj21 == null) { ConsoleEvent val21 = delegate { ((Component)Player.m_localPlayer).GetComponent<AdventureComponent>().SaveData = new AdventureSaveDataList(); ResetMinimap(); }; <>c.<>9__1_20 = val21; obj21 = (object)val21; } new ConsoleCommand("resetadventure", "", (ConsoleEvent)obj21, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj22 = <>c.<>9__1_21; if (obj22 == null) { ConsoleEvent val22 = delegate(ConsoleEventArgs args) { int num = ((args.Length >= 2) ? int.Parse(args[1]) : AdventureDataManager.Bounties.GetCurrentInterval()); List<BountyInfo> availableBounties = AdventureDataManager.Bounties.GetAvailableBounties(num, removeAcceptedBounties: false); BountiesAdventureFeature.PrintBounties($"Bounties for Interval {num}:", availableBounties); }; <>c.<>9__1_21 = val22; obj22 = (object)val22; } new ConsoleCommand("bounties", "", (ConsoleEvent)obj22, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj23 = <>c.<>9__1_22; if (obj23 == null) { ConsoleEvent val23 = delegate { List<BountyInfo> bounties = Player.m_localPlayer.GetAdventureSaveData().Bounties; BountiesAdventureFeature.PrintBounties("Player Bounties:", bounties); }; <>c.<>9__1_22 = val23; obj23 = (object)val23; } new ConsoleCommand("playerbounties", "", (ConsoleEvent)obj23, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj24 = <>c.<>9__1_23; if (obj24 == null) { ConsoleEvent val24 = delegate { //IL_0016: Unknown result type (might be due to invalid IL or missing references) Player localPlayer3 = Player.m_localPlayer; LocationInstance val33 = default(LocationInstance); if (ZoneSystem.instance.FindClosestLocation("Vendor_BlackForest", ((Component)localPlayer3).transform.position, ref val33)) { ((Terminal)Console.instance).AddString(((object)(Vector3)(ref val33.m_position)).ToString()); } }; <>c.<>9__1_23 = val24; obj24 = (object)val24; } new ConsoleCommand("gotomerchant", "", (ConsoleEvent)obj24, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj25 = <>c.<>9__1_24; if (obj25 == null) { ConsoleEvent val25 = delegate { //IL_0016: Unknown result type (might be due to invalid IL or missing references) Player localPlayer2 = Player.m_localPlayer; LocationInstance val32 = default(LocationInstance); if (ZoneSystem.instance.FindClosestLocation("Vendor_BlackForest", ((Component)localPlayer2).transform.position, ref val32)) { ((Terminal)Console.instance).AddString(((object)(Vector3)(ref val32.m_position)).ToString()); } }; <>c.<>9__1_24 = val25; obj25 = (object)val25; } new ConsoleCommand("gotom", "", (ConsoleEvent)obj25, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj26 = <>c.<>9__1_25; if (obj26 == null) { ConsoleEvent val26 = delegate(ConsoleEventArgs args) { if ((Object)(object)ZoneSystem.instance != (Object)null) { args.Context.AddString("> Print Global Keys:"); foreach (string globalKey in ZoneSystem.instance.GetGlobalKeys()) { args.Context.AddString("> " + globalKey); } } }; <>c.<>9__1_25 = val26; obj26 = (object)val26; } new ConsoleCommand("globalkeys", "", (ConsoleEvent)obj26, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj27 = <>c.<>9__1_26; if (obj27 == null) { ConsoleEvent val27 = delegate { FixResistances(Player.m_localPlayer); }; <>c.<>9__1_26 = val27; obj27 = (object)val27; } new ConsoleCommand("fixresistances", "", (ConsoleEvent)obj27, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj28 = <>c.<>9__1_27; if (obj28 == null) { ConsoleEvent val28 = delegate(ConsoleEventArgs args) { string lootTableName2 = ((args.Length > 1) ? args[1] : "Greydwarf"); float luckFactor = ((args.Length > 2) ? float.Parse(args[2]) : 0f); LootRoller.PrintLuckTest(lootTableName2, luckFactor); }; <>c.<>9__1_27 = val28; obj28 = (object)val28; } new ConsoleCommand("lucktest", "", (ConsoleEvent)obj28, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj29 = <>c.<>9__1_28; if (obj29 == null) { ConsoleEvent val29 = delegate(ConsoleEventArgs args) { string lootTableName = ((args.Length > 1) ? args[1] : "Greydwarf"); int level = ((args.Length <= 2) ? 1 : int.Parse(args[2])); int itemIndex = ((args.Length > 3) ? int.Parse(args[3]) : 0); LootRoller.PrintLootResolutionTest(lootTableName, level, itemIndex); }; <>c.<>9__1_28 = val29; obj29 = (object)val29; } new ConsoleCommand("lootres", "", (ConsoleEvent)obj29, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj30 = <>c.<>9__1_29; if (obj30 == null) { ConsoleEvent val30 = delegate { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null) { AbilityController component = ((Component)localPlayer).GetComponent<AbilityController>(); if ((Object)(object)component != (Object)null) { foreach (Ability currentAbility in component.CurrentAbilities) { currentAbility.ResetCooldown(); } } } }; <>c.<>9__1_29 = val30; obj30 = (object)val30; } new ConsoleCommand("resetcooldowns", "", (ConsoleEvent)obj30, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj31 = <>c.<>9__1_30; if (obj31 == null) { ConsoleEvent val31 = delegate { LootRoller.DebugLuckFactor(); }; <>c.<>9__1_30 = val31; obj31 = (object)val31; } new ConsoleCommand("debugluck", "", (ConsoleEvent)obj31, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } private static void ResetMinimap() { MinimapController.AddPinJobToQueue(new PinJob { Task = MinimapPinQueueTask.RefreshAll }); } private static void TestTreasureMap(string[] args) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; int result = 1; if (args.Length >= 2) { int.TryParse(args[1], out result); } Biome result2 = (Biome)0; if (args.Length >= 3) { Enum.TryParse<Biome>(args[2], out result2); } int result3 = -1; if (args.Length >= 4) { int.TryParse(args[3], out result3); } AdventureDataManager.CheatNumberOfBounties = result3; AdventureSaveData adventureSaveData = localPlayer.GetAdventureSaveData(); ((MonoBehaviour)localPlayer).StartCoroutine(TestTreasureMapCoroutine(adventureSaveData, result2, localPlayer, result)); } private static IEnumerator TestTreasureMapCoroutine(AdventureSaveData saveData, Biome biome, Player player, int count) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) Biome[] array = new Biome[5]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); Biome[] biomes = (Biome[])(object)array; saveData.DebugMode = true; int startInterval = ((saveData.TreasureMaps.Count == 0) ? (-1) : (saveData.TreasureMaps.Min((TreasureMapChestInfo x) => x.Interval) - 1)); int i = 0; while (i < count) { saveData.IntervalOverride = startInterval - (i + 1); Biome biome2 = (Biome)(((int)biome == 0) ? ((int)biomes[Random.Range(0, biomes.Length)]) : ((int)biome)); yield return AdventureDataManager.TreasureMaps.SpawnTreasureChest(biome2, player, OnTreasureChestSpawnComplete); int num = i + 1; i = num; } saveData.DebugMode = false; AdventureDataManager.CheatNumberOfBounties = -1; } private static void OnTreasureChestSpawnComplete(bool success, Vector3 spawnPoint) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) string text = "> Failed to spawn treasure map chest"; if (success) { text = $"> Spawning Treasure Map Chest at <{spawnPoint.x:0.#}, {spawnPoint.z:0.#}> (height:{spawnPoint.y:0.#})"; } ((Terminal)Console.instance).AddString(text); EpicLoot.LogWarning(text); } private static void ToggleAlwaysDrop(Terminal context) { EpicLoot.AlwaysDropCheat = !EpicLoot.AlwaysDropCheat; context.AddString($"> Always Drop: {EpicLoot.AlwaysDropCheat}"); } private static void SpawnMagicCraftingMaterials() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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) foreach (GameObject registeredItemPrefab in EpicLoot.RegisteredItemPrefabs) { ItemDrop component = Object.Instantiate<GameObject>(registeredItemPrefab, ((Component)Player.m_localPlayer).transform.position + ((Component)Player.m_localPlayer).transform.forward * 2f + Vector3.up, Quaternion.identity).GetComponent<ItemDrop>(); if (component.m_itemData.IsMagicCraftingMaterial() || (component.m_itemData.IsRunestone() && component.m_itemData.GetCraftingMaterialRarity() != ItemRarity.Mythic)) { component.m_itemData.m_stack = component.m_itemData.m_shared.m_maxStackSize / 2; } else { ZNetScene.instance.Destroy(((Component)component).gameObject); } } } public static void MagicItem(Terminal context, string[] args) { //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) string text = ((args.Length >= 2) ? args[1] : "random"); string text2 = ((args.Length >= 3) ? args[2] : "random"); int num = ((args.Length < 4) ? 1 : int.Parse(args[3])); int cheatEffectCount = ((args.Length >= 5) ? int.Parse(args[4]) : (-1)); context.AddString($"magicitem - rarity:{text}, item:{text2}, count:{num}"); List<string> collection = (from x in ObjectDB.instance.m_items where EpicLoot.CanBeMagicItem(x.GetComponent<ItemDrop>().m_itemData) where ((Object)x).name != "HelmetDverger" && ((Object)x).name != "BeltStrength" && ((Object)x).name != "Wishbone" select ((Object)x).name).ToList(); if ((Object)(object)Player.m_localPlayer == (Object)null) { return; } LootRoller.CheatEffectCount = cheatEffectCount; for (int i = 0; i < num; i++) { float[] rarityTable = GetRarityTable(text); string text3 = text2; if (text3 == "random") { text3 = new WeightedRandomCollection<string>(_random, collection, (string x) => 1f).Roll(); } if ((Object)(object)ObjectDB.instance.GetItemPrefab(text3) == (Object)null) { context.AddString("> Could not find item: " + text3); break; } context.AddString(string.Format("> {0} - rarity: [{1}], item: {2}", i + 1, string.Join(", ", rarityTable), text3)); LootTable lootTable = new LootTable(); lootTable.Object = "Console"; lootTable.Drops = new float[1][] { new float[2] { 1f, 1f } }; lootTable.Loot = new LootDrop[1] { new LootDrop { Item = text3, Rarity = rarityTable, Weight = 1f } }; LootTable lootTable2 = lootTable; Vector3 insideUnitSphere = Random.insideUnitSphere; Vector3 dropPoint = ((Component)Player.m_localPlayer).transform.position + ((Component)Player.m_localPlayer).transform.forward * 3f + Vector3.up * 1.5f + insideUnitSphere; LootRoller.CheatRollingItem = true; LootRoller.RollLootTableAndSpawnObjects(lootTable2, 1, lootTable2.Object, dropPoint); LootRoller.CheatRollingItem = false; } LootRoller.CheatEffectCount = -1; } public static void SpawnMagicItemWithEffect(Terminal context, string[] args) { //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) if (args.Length < 3) { EpicLoot.LogError("Specify effect and item name"); } else { if ((Object)(object)Player.m_localPlayer == (Object)null) { return; } string text = args[1]; string text2 = args[2]; context.AddString("magicitem - " + text2 + " with effect: " + text); MagicItemEffectDefinition magicItemEffectDefinition = MagicItemEffectDefinitions.Get(text); if (magicItemEffectDefinition == null) { context.AddString("> Could not find effect: " + text); return; } GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(text2); if ((Object)(object)itemPrefab == (Object)null) { context.AddString("> Could not find item: " + text2); return; } if (!EpicLoot.CanBeMagicI