using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Jotunn; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Splatform; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("Deadheim")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Deadheimxx")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("d361daa4-9ce5-430e-a275-944805ecb71e")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace MassFarming { [HarmonyPatch] public static class MassPickup { private static FieldInfo m_interactMaskField = AccessTools.Field(typeof(Player), "m_interactMask"); private static MethodInfo _ExtractMethod = AccessTools.Method(typeof(Beehive), "Extract", (Type[])null, (Type[])null); [HarmonyPatch(typeof(Player), "Interact")] public static void Prefix(Player __instance, GameObject go, bool hold, bool alt) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) if (((Character)__instance).InAttack() || ((Character)__instance).InDodge() || hold || !Input.GetKey((KeyCode)304)) { return; } Interactable componentInParent = go.GetComponentInParent(); Pickable val = (Pickable)(object)((componentInParent is Pickable) ? componentInParent : null); if (val != null) { int num = (int)m_interactMaskField.GetValue(__instance); Collider[] array = Physics.OverlapSphere(go.transform.position, 10f, num); Collider[] array2 = array; foreach (Collider val2 in array2) { object obj; if (val2 == null) { obj = null; } else { GameObject gameObject = ((Component)val2).gameObject; obj = ((gameObject != null) ? gameObject.GetComponentInParent() : null); } Pickable val3 = (Pickable)obj; if (val3 != null && (Object)(object)val3 != (Object)(object)val && ((Object)val3.m_itemPrefab).name == ((Object)val.m_itemPrefab).name) { val3.Interact((Humanoid)(object)__instance, false, alt); } } return; } Beehive val4 = (Beehive)(object)((componentInParent is Beehive) ? componentInParent : null); if (val4 == null) { return; } int num2 = (int)m_interactMaskField.GetValue(__instance); Collider[] array3 = Physics.OverlapSphere(go.transform.position, 10f, num2); Collider[] array4 = array3; foreach (Collider val5 in array4) { object obj2; if (val5 == null) { obj2 = null; } else { GameObject gameObject2 = ((Component)val5).gameObject; obj2 = ((gameObject2 != null) ? gameObject2.GetComponentInParent() : null); } Beehive val6 = (Beehive)obj2; if (val6 != null && (Object)(object)val6 != (Object)(object)val4 && PrivateArea.CheckAccess(((Component)val6).transform.position, 0f, true, false)) { _ExtractMethod.Invoke(val6, null); } } } } } namespace Deadheim { [HarmonyPatch] public class FasterBoats { [HarmonyPatch(typeof(Ship), "GetSailForce")] private class ChangeShipBaseSpeed { private static void Postfix(ref Vector3 __result) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) __result *= Plugin.BoatWindSpeedmultiplier.Value; } } } [HarmonyPatch] public class ClonedItems { [HarmonyPatch(typeof(ItemDrop), "DropItem")] public static class DropItem { [HarmonyPriority(800)] private static void Prefix(ItemDrop __instance, ItemData item) { if (!((Object)(object)item.m_dropPrefab != (Object)null)) { if (item != null && item.m_shared != null && item.m_shared.m_name.Equals(" Basic Armor Kit I", StringComparison.CurrentCultureIgnoreCase)) { item.m_dropPrefab = PrefabManager.Instance.GetPrefab("ArmorKit1"); } if (item != null && item.m_shared != null && item.m_shared.m_name.Equals("Good Armor Kit II", StringComparison.CurrentCultureIgnoreCase)) { item.m_dropPrefab = PrefabManager.Instance.GetPrefab("ArmorKit2"); } if (item != null && item.m_shared != null && item.m_shared.m_name.Equals("Great Armor Kit III", StringComparison.CurrentCultureIgnoreCase)) { item.m_dropPrefab = PrefabManager.Instance.GetPrefab("ArmorKit3"); } if (item != null && item.m_shared != null && item.m_shared.m_name.Equals("Superior Armor Kit IV", StringComparison.CurrentCultureIgnoreCase)) { item.m_dropPrefab = PrefabManager.Instance.GetPrefab("ArmorKit4"); } if (item != null && item.m_shared != null && item.m_shared.m_name.Equals("Basic Weapon Kit I", StringComparison.CurrentCultureIgnoreCase)) { item.m_dropPrefab = PrefabManager.Instance.GetPrefab("WeaponKit1"); } if (item != null && item.m_shared != null && item.m_shared.m_name.Equals("Good Weapon Kit II", StringComparison.CurrentCultureIgnoreCase)) { item.m_dropPrefab = PrefabManager.Instance.GetPrefab("WeaponKit2"); } if (item != null && item.m_shared != null && item.m_shared.m_name.Equals("Great Weapon Kit III", StringComparison.CurrentCultureIgnoreCase)) { item.m_dropPrefab = PrefabManager.Instance.GetPrefab("WeaponKit3"); } if (item != null && item.m_shared != null && item.m_shared.m_name.Equals("Superior Weapon Kit IV", StringComparison.CurrentCultureIgnoreCase)) { item.m_dropPrefab = PrefabManager.Instance.GetPrefab("WeaponKit4"); } } } } public static void LoadAssets() { PrefabManager.OnPrefabsRegistered += AddClonedItems; PieceManager.OnPiecesRegistered += AddClonedPieces; CreatureManager.OnVanillaCreaturesAvailable += AddVanillaClonedCreatures; } private static void AddClonedItems() { AddPortalToken(); AddSpawnerToken(); AddItemKits(); PrefabManager.OnPrefabsRegistered -= AddClonedItems; } private static void AddClonedPieces() { AddAesirChest(); AddAdminWards(); AddBuildableSpawners(); PieceManager.OnPiecesRegistered -= AddClonedPieces; } private static void AddVanillaClonedCreatures() { AddBatzao(); AddNomTameableWolf(); AddPorcoLox(); AddSkeletao(); CreatureManager.OnVanillaCreaturesAvailable -= AddVanillaClonedCreatures; } private static void AddAdminWards() { AddBigdminWard(); AddSmallAdminWard(); } private static void AddItemKits() { AddArmorKit("ArmorKit1", "piece_chest_wood", "Basic Armor Kit I", "Kit de itens utilizados para fabricar armaduras de menor qualidade pertencente a era do bronze.", "Wood", "Guck", "armorkit1.png"); AddArmorKit("ArmorKit2", "piece_chest_wood", "Good Armor Kit II", "Kit de itens utilizados para fabricar armaduras de refinadas de qualidade pertencente a era do ferro.", "Wood", "Blueberries", "armorkit2.png"); AddArmorKit("ArmorKit3", "piece_chest_wood", "Great Armor Kit III", "Kit de itens utilizados para fabricar armaduras reluzentes beirando a perfeição, sua qualidade pertence a era da prata.", "Wood", "Amber", "armorkit3.png"); AddArmorKit("ArmorKit4", "piece_chest_wood", "Superior Armor Kit IV", "Kit de itens utilizados para fabricar armaduras de maior qualidade dentro os mortais beirando o divino pertencentes a era do linho.", "Wood", "Ruby", "armorkit4.png"); AddArmorKit("WeaponKit1", "piece_chest_wood", "Basic Weapon Kit I", "Kit de itens utilizados para fabricar armas mais simples de qualidade duvidosa, muito utilizada na era do bronze.", "FineWood", "Guck", "weaponkit1.png"); AddArmorKit("WeaponKit2", "piece_chest_wood", "Good Weapon Kit II", "Kit de itens utilizados para fabricar armas maior refinaria, muito utilizada na era do ferro.", "FineWood", "Blueberries", "weaponkit2.png"); AddArmorKit("WeaponKit3", "piece_chest_wood", "Great Weapon Kit III", "Kit de itens utilizados para fabricar armas prateadas com brilhos que afligem os olhos, muito utilizada na era da prata.", "FineWood", "Amber", "weaponkit3.png"); AddArmorKit("WeaponKit4", "piece_chest_wood", "Superior Weapon Kit IV", "Kit de itens utilizados para fabricar armas negras, extremamente laminadas capazes de perfurar a grossa pele de um Lox utilizada por aqueles que chegaram na era do metal negro.", "FineWood", "Ruby", "weaponkit4.png"); } private static T CopyComponent(T original, GameObject destination) where T : Component { Type type = ((object)original).GetType(); Component val = destination.AddComponent(type); FieldInfo[] fields = type.GetFields(); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { fieldInfo.SetValue(val, fieldInfo.GetValue(original)); } return (T)(object)((val is T) ? val : null); } private static void AddArmorKit(string prefabName, string prefabToCopy, string name, string description, string firstShaderPrefabName, string secondShaderPrefabName, string icon) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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) ItemDrop component = PrefabManager.Instance.GetPrefab("Resin").GetComponent(); GameObject val = PrefabManager.Instance.CreateClonedPrefab(prefabName, prefabToCopy); Object.Destroy((Object)(object)val.GetComponent()); Object.Destroy((Object)(object)val.GetComponent()); Object.Destroy((Object)(object)val.GetComponent()); Object.Destroy((Object)(object)val.GetComponent()); val.AddComponent(); ItemDrop val2 = val.AddComponent(); val2.m_floating = val.AddComponent(); val2.m_body = val.AddComponent(); val2.m_itemData.m_shared = new SharedData(); val2.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { Util.LoadSprite(icon, 64, 64) }; val2.m_itemData.m_shared.m_name = name; val2.m_itemData.m_shared.m_description = description; val2.m_itemData.m_shared.m_maxStackSize = 25; Vector3 localScale = val.transform.localScale; localScale.x *= 0.3f; localScale.y *= 0.3f; localScale.z *= 0.3f; val.transform.localScale = localScale; MeshRenderer[] componentsInChildren = val.GetComponentsInChildren(); MeshRenderer[] array = componentsInChildren; foreach (MeshRenderer val3 in array) { List list = new List(); if ((Object)(object)val3 == (Object)(object)componentsInChildren[0]) { list.Add(((Renderer)PrefabManager.Instance.GetPrefab(firstShaderPrefabName).GetComponentInChildren()).materials[0]); } else { list.Add(((Renderer)PrefabManager.Instance.GetPrefab(secondShaderPrefabName).GetComponentInChildren()).materials[0]); } ((Renderer)val3).materials = list.ToArray(); } val.GetComponent().m_itemData.m_dropPrefab = val; ItemManager.Instance.RegisterItemInObjectDB(val); } private static void AddSmallAdminWard() { GameObject val = PrefabManager.Instance.CreateClonedPrefab("AdminWardSmall", "guard_stone"); Piece component = val.GetComponent(); component.m_resources[0].m_resItem = PrefabManager.Instance.GetPrefab("SwordCheat").GetComponent(); component.m_resources[0].m_recover = false; component.m_description = "Admin Ward small"; component.m_name = "Admin Ward small"; PrivateArea component2 = ((Component)component).GetComponent(); component2.m_radius = 40f; component2.m_name = "AdminWardSmall"; MeshRenderer componentInChildren = val.GetComponentInChildren(); List list = new List(); list.Add(((Renderer)PrefabManager.Instance.GetPrefab("FreezeGland").GetComponentInChildren()).materials[0]); list.Add(((Renderer)PrefabManager.Instance.GetPrefab("FreezeGland").GetComponentInChildren()).materials[0]); ((Renderer)componentInChildren).materials = list.ToArray(); PieceManager.Instance.RegisterPieceInPieceTable(val, "Hammer", "Misc"); } private static void AddBigdminWard() { GameObject val = PrefabManager.Instance.CreateClonedPrefab("AdminWard", "guard_stone"); Piece component = val.GetComponent(); component.m_resources[0].m_resItem = PrefabManager.Instance.GetPrefab("SwordCheat").GetComponent(); component.m_resources[0].m_recover = false; component.m_description = "Admin Ward"; component.m_name = "Admin Ward"; PrivateArea component2 = ((Component)component).GetComponent(); component2.m_radius = 150f; component2.m_name = "AdminWard"; MeshRenderer componentInChildren = val.GetComponentInChildren(); List list = new List(); list.Add(((Renderer)PrefabManager.Instance.GetPrefab("Tar").GetComponentInChildren()).materials[0]); list.Add(((Renderer)PrefabManager.Instance.GetPrefab("SurtlingCore").GetComponentInChildren()).materials[0]); ((Renderer)componentInChildren).materials = list.ToArray(); PieceManager.Instance.RegisterPieceInPieceTable(val, "Hammer", "Misc"); } private static void AddAesirChest() { GameObject val = PrefabManager.Instance.CreateClonedPrefab("AesirChest", "piece_chest_private"); Piece component = val.GetComponent(); component.m_resources[0].m_resItem = PrefabManager.Instance.GetPrefab("Bronze").GetComponent(); component.m_resources[1].m_resItem = PrefabManager.Instance.GetPrefab("Wood").GetComponent(); component.m_description = "Aesir Chest"; component.m_name = "Aesir Chest"; PieceManager.Instance.RegisterPieceInPieceTable(val, "Hammer", "Furniture"); } private static void AddPortalToken() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown CustomItem val = new CustomItem("PortalToken", "Thunderstone"); ItemDrop itemDrop = val.ItemDrop; itemDrop.m_itemData.m_shared.m_name = "Portal Token"; itemDrop.m_itemData.m_shared.m_description = "Me compre para o Detalhes poder manter seu vício."; itemDrop.m_itemData.m_shared.m_maxStackSize = 10; ItemManager.Instance.AddItem(val); } private static void AddSpawnerToken() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown CustomItem val = new CustomItem("SpawnerToken", "Thunderstone"); ItemDrop itemDrop = val.ItemDrop; itemDrop.m_itemData.m_shared.m_name = "Spawner Token"; itemDrop.m_itemData.m_shared.m_description = "Token used to build protected vanilla spawners."; itemDrop.m_itemData.m_shared.m_maxStackSize = 10; ItemManager.Instance.AddItem(val); } private static void AddBuildableSpawners() { AddBuildableSpawner("BuildableGreydwarfNestSpawner", "Spawner_GreydwarfNest", "Black Forest Spawner", "Indestructible Black Forest monster spawner."); AddBuildableSpawner("BuildableDraugrPileSpawner", "Spawner_DraugrPile", "Swamp Spawner", "Indestructible Swamp monster spawner."); } private static void AddBuildableSpawner(string prefabName, string sourcePrefabName, string name, string description) { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown GameObject prefab = PrefabManager.Instance.GetPrefab(sourcePrefabName); if ((Object)(object)prefab == (Object)null) { Logger.LogWarning((object)("Could not create " + name + ". Missing vanilla prefab: " + sourcePrefabName)); return; } GameObject val = PrefabManager.Instance.CreateClonedPrefab(prefabName, sourcePrefabName); Piece val2 = val.GetComponent() ?? val.AddComponent(); val2.m_name = name; val2.m_description = description; val2.m_enabled = true; val2.m_icon = GetSpawnerIcon(sourcePrefabName) ?? val2.m_icon; val2.m_category = (PieceCategory)0; val2.m_groundPiece = true; val2.m_groundOnly = true; val2.m_clipGround = true; val2.m_noInWater = true; val2.m_canRotate = true; val2.m_canBeRemoved = true; val2.m_repairPiece = false; val2.m_resources = (Requirement[])(object)new Requirement[1] { new Requirement { m_resItem = PrefabManager.Instance.GetPrefab("SpawnerToken").GetComponent(), m_amount = 1, m_recover = true } }; WearNTear component = val.GetComponent(); if ((Object)(object)component != (Object)null) { component.m_health = 999999f; component.m_noRoofWear = true; component.m_noSupportWear = true; } Destructible component2 = val.GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.m_health = 999999f; } PieceManager.Instance.RegisterPieceInPieceTable(val, "Hammer", "Misc"); } private static Sprite GetSpawnerIcon(string sourcePrefabName) { string text = ((sourcePrefabName == "Spawner_GreydwarfNest") ? "GreydwarfEye" : "WitheredBone"); GameObject prefab = PrefabManager.Instance.GetPrefab(text); Sprite val = ((prefab == null) ? null : prefab.GetComponent()?.m_itemData?.m_shared?.m_icons?.FirstOrDefault()); if ((Object)(object)val != (Object)null) { return val; } GameObject prefab2 = PrefabManager.Instance.GetPrefab("SpawnerToken"); return (prefab2 == null) ? null : prefab2.GetComponent()?.m_itemData?.m_shared?.m_icons?.FirstOrDefault(); } private static void AddNomTameableWolf() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown CustomCreature val = new CustomCreature("LoboNaoDomavel", "Wolf", new CreatureConfig()); Humanoid component = val.Prefab.GetComponent(); ((Character)component).m_name = "Lobo nao domavel"; CreatureManager.Instance.AddCreature(val); Object.Destroy((Object)(object)val.Prefab.GetComponent()); Object.Destroy((Object)(object)val.Prefab.GetComponent()); } private static void AddSkeletao() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) CustomCreature val = new CustomCreature("Skeletao", "Skeleton", new CreatureConfig { Faction = (Faction)3 }); Humanoid component = val.Prefab.GetComponent(); ((Character)component).m_name = "Esqueletão"; ((Character)component).m_boss = true; ((Character)component).m_health = 500f; SkinnedMeshRenderer[] componentsInChildren = val.Prefab.GetComponentsInChildren(); SkinnedMeshRenderer[] array = componentsInChildren; foreach (SkinnedMeshRenderer val2 in array) { ((Renderer)val2).material.color = Color.black; ((Renderer)val2).sharedMaterial.color = Color.black; } Vector3 localScale = val.Prefab.transform.localScale; localScale.x *= 1.3f; localScale.y *= 1.3f; localScale.z *= 1.3f; val.Prefab.transform.localScale = localScale; CreatureManager.Instance.AddCreature(val); Object.Destroy((Object)(object)val.Prefab.GetComponent()); Object.Destroy((Object)(object)val.Prefab.GetComponent()); } private static void AddPorcoLox() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) CustomCreature val = new CustomCreature("PorcoLox", "Lox", new CreatureConfig { Faction = (Faction)2 }); Humanoid component = val.Prefab.GetComponent(); GameObject val2 = PrefabManager.Instance.CreateClonedPrefab("PorcoLoxRagDoll", "lox_ragdoll"); ((Character)component).m_name = "PorcoLox"; ((Character)component).m_boss = true; ((Character)component).m_health = 300f; ColorRenderers(val.Prefab, Color.black); Vector3 localScale = val.Prefab.transform.localScale; localScale.x *= 0.5f; localScale.y *= 0.5f; localScale.z *= 0.5f; val2.transform.localScale = localScale; int index = ((Character)component).m_deathEffects.m_effectPrefabs.ToList().FindIndex((EffectData x) => ((Object)x.m_prefab).name == "lox_ragdoll"); ((Character)val.Prefab.GetComponent()).m_deathEffects.m_effectPrefabs.ToList()[index].m_prefab = val2; ColorRenderers(val2, Color.black); val.Prefab.transform.localScale = localScale; CreatureManager.Instance.AddCreature(val); Object.Destroy((Object)(object)val.Prefab.GetComponent()); Object.Destroy((Object)(object)val.Prefab.GetComponent()); } public static void ColorRenderers(GameObject gameObject, Color color) { //IL_001a: 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) SkinnedMeshRenderer[] componentsInChildren = gameObject.GetComponentsInChildren(); SkinnedMeshRenderer[] array = componentsInChildren; foreach (SkinnedMeshRenderer val in array) { ((Renderer)val).material.color = color; ((Renderer)val).sharedMaterial.color = color; } } private static void AddBatzao() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_005a: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_007e: 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_00bf: Unknown result type (might be due to invalid IL or missing references) CreatureConfig val = new CreatureConfig(); val.DropConfigs = (DropConfig[])(object)new DropConfig[1] { new DropConfig { Item = "Coins", Chance = 100f, MinAmount = 50, MaxAmount = 100, OnePerPlayer = false, LevelMultiplier = false } }; val.Faction = (Faction)3; CustomCreature val2 = new CustomCreature("Morcegao", "Bat", val); Vector3 localScale = val2.Prefab.transform.localScale; localScale.x *= 3f; localScale.y *= 3f; localScale.z *= 3f; val2.Prefab.transform.localScale = localScale; Humanoid component = val2.Prefab.GetComponent(); ((Character)component).m_name = "Morcegão"; ((Character)component).m_health = 500f; ((Character)component).m_boss = true; CreatureManager.Instance.AddCreature(val2); } } [HarmonyPatch(typeof(Container), "Awake")] public static class Container_Awake_Patch { private const int woodChestRows = 4; private const int woodChestColumns = 5; private const int personalChestRows = 6; private const int personalChestColumns = 6; private const int ironChestRows = 8; private const int ironChestColumns = 6; private const int karveInventoryRows = 4; private const int karveInventoryColumns = 2; private const int longboatInventoryRows = 6; private const int longboatInventoryColumns = 6; private const int cartInventoryRows = 5; private const int cartInventoryColumns = 6; private const int aesirRows = 8; private static void Postfix(Container __instance, ref Inventory ___m_inventory) { if (((Object)(object)__instance == (Object)null || ___m_inventory == null || !Object.op_Implicit((Object)(object)((Component)__instance).transform.parent)) && ___m_inventory != null && ((Object)((Component)__instance).gameObject).name.Contains("AesirChest")) { ___m_inventory.m_width = 6; ___m_inventory.m_height = 6; } } } internal class CraftingStations { [HarmonyPatch(typeof(CraftingStation), "CheckUsable")] public static class WorkbenchRemoveRestrictions { private static bool Prefix(ref CraftingStation __instance) { __instance.m_craftRequireRoof = false; return true; } } [HarmonyPatch(typeof(PrivateArea), "Awake")] public static class PrivateAreaAwake { public static void Postfix(ref PrivateArea __instance) { int num = Plugin.WardRadius.Value; if (__instance.m_name.Contains("AdminWard")) { num = 50; } if (__instance.m_name.Contains("RaidWard")) { num = 50; } __instance.m_areaMarker.m_radius = num; __instance.m_radius = num; } } } public static class EpicMMOApi { private enum API_State { NotReady, NotInstalled, Ready } private static string pluginKey = "EpicMMOSystem"; private static API_State state = API_State.NotReady; private static MethodInfo eGetLevel; private static MethodInfo eAddExp; private static MethodInfo eGetAttribute; public static int GetLevel() { int result = 0; Init(); if (eGetLevel != null) { result = (int)eGetLevel.Invoke(null, null); } return result; } public static int GetAttribute(string attribute) { string value = 0.ToString(); Player.m_localPlayer.m_knownTexts.TryGetValue(pluginKey + "_LevelSystem_" + attribute, out value); return Convert.ToInt32(value); } public static void AddExp(int value) { Init(); eAddExp?.Invoke(null, new object[1] { value }); } private static void Init() { API_State aPI_State = state; if (aPI_State != API_State.Ready && aPI_State != API_State.NotInstalled) { if (Type.GetType("EpicMMOSystem.EpicMMOSystem, EpicMMOSystem") == null) { state = API_State.NotInstalled; return; } state = API_State.Ready; Type type = Type.GetType("API.EMMOS_API, EpicMMOSystem"); eGetLevel = type.GetMethod("GetLevel", BindingFlags.Static | BindingFlags.Public); eAddExp = type.GetMethod("AddExp", BindingFlags.Static | BindingFlags.Public); eGetAttribute = type.GetMethod("GetAttribute", BindingFlags.Static | BindingFlags.Public); } } } internal class ItemService { public static void ModifyItemsCost() { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Expected O, but got Unknown //IL_00f6: 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) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Expected O, but got Unknown GameObject prefab = PrefabManager.Instance.GetPrefab("piece_cartographytable"); prefab.GetComponent().m_resources[0].m_amount = 100; prefab.GetComponent().m_resources[1].m_amount = 100; prefab.GetComponent().m_resources[2].m_amount = 100; prefab.GetComponent().m_resources[3].m_amount = 100; prefab.GetComponent().m_resources[4].m_amount = 100; GameObject prefab2 = PrefabManager.Instance.GetPrefab("portal_wood"); Piece component = prefab2.GetComponent(); component.m_resources = (Requirement[])(object)new Requirement[4] { new Requirement { m_resItem = PrefabManager.Instance.GetPrefab("PortalToken").GetComponent(), m_amount = 1, m_recover = true }, new Requirement { m_resItem = PrefabManager.Instance.GetPrefab("FineWood").GetComponent(), m_amount = 100, m_recover = true }, new Requirement { m_resItem = PrefabManager.Instance.GetPrefab("GreydwarfEye").GetComponent(), m_amount = 30, m_recover = true }, new Requirement { m_resItem = PrefabManager.Instance.GetPrefab("SurtlingCore").GetComponent(), m_amount = 10, m_recover = true } }; } public static void OnlyAdminPieces() { GameObject val = ((IEnumerable)ObjectDB.instance.m_items).FirstOrDefault((Func)((GameObject x) => ((Object)x).name == "Hammer")); PieceTable buildPieces = val.GetComponent().m_itemData.m_shared.m_buildPieces; string[] array = Plugin.OnlyAdminPieces.Value.Split(new char[1] { ',' }); foreach (string text in array) { GameObject prefab = PrefabManager.Instance.GetPrefab(text); if (prefab != null) { Piece component = prefab.GetComponent(); Requirement[] resources = component.m_resources; foreach (Requirement val2 in resources) { val2.m_resItem = PrefabManager.Instance.GetPrefab("SwordCheat").GetComponent(); val2.m_recover = false; } if (!SynchronizationManager.Instance.PlayerIsAdmin) { buildPieces.m_pieces.Remove(prefab); } } } } public static void SetWardFirePlace() { GameObject prefab = PrefabManager.Instance.GetPrefab("guard_stone"); Fireplace val = prefab.AddComponent(); val.m_fuelItem = PrefabManager.Instance.GetPrefab("GreydwarfEye").GetComponent(); } public static void NerfRunicCape() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("rae_CapeHorseHide"); if (Object.op_Implicit((Object)(object)itemPrefab)) { ItemDrop component = itemPrefab.GetComponent(); SE_Stats val = (SE_Stats)component.m_itemData.m_shared.m_equipStatusEffect; val.m_mods = new List(); } } public static void WolvesTameable() { if (!Plugin.WolvesAreTameable.Value) { GameObject prefab = PrefabManager.Instance.GetPrefab("Wolf"); if (Object.op_Implicit((Object)(object)prefab)) { Tameable component = prefab.GetComponent(); Procreation component2 = prefab.GetComponent(); Object.Destroy((Object)(object)component); Object.Destroy((Object)(object)component2); } } } public static void LoxTameable() { if (!Plugin.LoxTameable.Value) { GameObject prefab = PrefabManager.Instance.GetPrefab("Lox"); if (Object.op_Implicit((Object)(object)prefab)) { Tameable component = prefab.GetComponent(); Procreation component2 = prefab.GetComponent(); Object.Destroy((Object)(object)component); Object.Destroy((Object)(object)component2); } } } public static void StubNoLife() { List list = new List(); list.Add(PrefabManager.Instance.GetPrefab("Pinetree_01_Stub")); list.Add(PrefabManager.Instance.GetPrefab("SwampTree1_Stub")); list.Add(PrefabManager.Instance.GetPrefab("BirchStub")); list.Add(PrefabManager.Instance.GetPrefab("FirTree_Stub")); list.Add(PrefabManager.Instance.GetPrefab("OakStub")); list.Add(PrefabManager.Instance.GetPrefab("Beech_Stub")); foreach (GameObject item in list) { Destructible component = item.GetComponent(); component.m_health = 1f; } } } public static class MarketplaceTeleporterCosts { private static readonly Regex RichTextRegex = new Regex("]*>", RegexOptions.Compiled); private static string _currentTeleporterNpcName = ""; private static Harmony _harmony; private static bool _npcPatchApplied; private static bool _clickPatchApplied; private static bool _waitingLogged; private static string _lastPatchError = ""; public static void StartPatchRetry(MonoBehaviour host, Harmony harmony) { if (!((Object)(object)host == (Object)null) && harmony != null) { _harmony = harmony; host.StartCoroutine(PatchWhenMarketplaceReady()); } } private static IEnumerator PatchWhenMarketplaceReady() { while (!_npcPatchApplied || !_clickPatchApplied) { TryPatchMarketplace(); if (_npcPatchApplied && _clickPatchApplied) { Debug.Log((object)"[Deadheim] Marketplace teleporter cost patches applied."); break; } if (!_waitingLogged) { Debug.Log((object)"[Deadheim] Waiting for Marketplace to load before applying teleporter cost patches."); _waitingLogged = true; } yield return (object)new WaitForSeconds(2f); } } private static void TryPatchMarketplace() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown if (_harmony == null) { return; } try { if (!_npcPatchApplied) { MethodBase methodBase = FindRememberTeleporterNpcTarget(); if (methodBase != null) { _harmony.Patch(methodBase, new HarmonyMethod(typeof(MarketplaceTeleporterCosts), "RememberTeleporterNpcPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); _npcPatchApplied = true; } } if (!_clickPatchApplied) { MethodBase methodBase2 = FindTeleporterPinClickTarget(); if (methodBase2 != null) { _harmony.Patch(methodBase2, new HarmonyMethod(typeof(MarketplaceTeleporterCosts), "ChargeOnTeleporterPinClickPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); _clickPatchApplied = true; } } } catch (Exception ex) { if (_lastPatchError != ex.Message) { _lastPatchError = ex.Message; Debug.LogWarning((object)("[Deadheim] Marketplace teleporter patch retry failed: " + ex.Message)); } } } private static MethodBase FindRememberTeleporterNpcTarget() { Type type = AccessTools.TypeByName("Marketplace.Modules.NPC.Market_NPC+NPCcomponent"); if (type != null) { MethodBase methodBase = FindOpenUIForType(type); if (methodBase != null) { return methodBase; } } Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { Type[] array; try { array = assembly.GetTypes(); } catch (ReflectionTypeLoadException ex) { array = Array.FindAll(ex.Types, (Type t) => t != null); } catch { continue; } Type[] array2 = array; foreach (Type type2 in array2) { if (type2.FullName.IndexOf("Marketplace", StringComparison.OrdinalIgnoreCase) >= 0) { MethodBase methodBase2 = FindOpenUIForType(type2); if (methodBase2 != null) { return methodBase2; } } } } return null; } private static MethodBase FindOpenUIForType(Type type) { foreach (MethodInfo declaredMethod in AccessTools.GetDeclaredMethods(type)) { ParameterInfo[] parameters = declaredMethod.GetParameters(); if (declaredMethod.Name != "OpenUIForType" || parameters.Length < 3 || parameters[1].ParameterType != typeof(string) || parameters[2].ParameterType != typeof(string)) { continue; } return declaredMethod; } return null; } private static void RememberTeleporterNpcPrefix(object[] __args) { if (__args != null && __args.Length >= 3 && __args[0] != null) { string text = __args[0].ToString(); if (text.Equals("Teleporter", StringComparison.OrdinalIgnoreCase)) { _currentTeleporterNpcName = CleanName(__args[2] as string); } } } private static MethodBase FindTeleporterPinClickTarget() { Type type = AccessTools.TypeByName("Marketplace.Modules.Teleporter.Teleporter_Main_Client+PatchClickIconMinimap"); MethodBase methodBase = ((type == null) ? null : AccessTools.Method(type, "Prefix", new Type[1] { typeof(Minimap) }, (Type[])null)); if (methodBase != null) { return methodBase; } Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { Type[] array; try { array = assembly.GetTypes(); } catch (ReflectionTypeLoadException ex) { array = Array.FindAll(ex.Types, (Type t) => t != null); } catch { continue; } Type[] array2 = array; foreach (Type type2 in array2) { if (type2.FullName.IndexOf("Marketplace", StringComparison.OrdinalIgnoreCase) >= 0 && type2.FullName.IndexOf("Teleporter", StringComparison.OrdinalIgnoreCase) >= 0) { MethodInfo methodInfo = AccessTools.Method(type2, "Prefix", new Type[1] { typeof(Minimap) }, (Type[])null); if (methodInfo != null) { return methodInfo; } } } } return null; } private static bool ChargeOnTeleporterPinClickPrefix(Minimap __0) { try { if ((Object)(object)__0 == (Object)null || (Object)(object)Player.m_localPlayer == (Object)null) { return true; } if (!TryGetClickedTeleporterPin(__0, out var _)) { return true; } int costForNpc = GetCostForNpc(_currentTeleporterNpcName); if (costForNpc <= 0) { return true; } if (!CanUseMarketplaceTeleporterWithCurrentInventory()) { return true; } Inventory inventory = ((Humanoid)Player.m_localPlayer).GetInventory(); string value = Plugin.MarketplaceTeleporterCostItem.Value; int num = inventory.CountItems(value, -1, true); if (num < costForNpc) { ((Character)Player.m_localPlayer).Message((MessageType)2, $"Voce precisa de {costForNpc} moedas para teleportar com {_currentTeleporterNpcName}.", 0, (Sprite)null); __0.SetMapMode((MapMode)1); return false; } inventory.RemoveItem(value, costForNpc, -1, true); ((Character)Player.m_localPlayer).Message((MessageType)2, $"Teleporte pago: {costForNpc} moedas.", 0, (Sprite)null); return true; } catch (Exception ex) { Debug.LogWarning((object)("[Deadheim] Marketplace teleporter cost check failed: " + ex)); return true; } } private static int GetCostForNpc(string npcName) { if (string.IsNullOrWhiteSpace(npcName) || Plugin.MarketplaceTeleporterCosts == null) { return 0; } Dictionary dictionary = ParseCosts(Plugin.MarketplaceTeleporterCosts.Value); int value; return dictionary.TryGetValue(NormalizeName(npcName), out value) ? value : 0; } private static Dictionary ParseCosts(string raw) { Dictionary dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase); if (string.IsNullOrWhiteSpace(raw)) { return dictionary; } string[] array = raw.Split(new char[2] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries); string[] array2 = array; foreach (string text in array2) { string[] array3 = text.Split(new char[1] { ':' }, 2); if (array3.Length == 2) { string text2 = NormalizeName(array3[0]); if (!string.IsNullOrWhiteSpace(text2) && int.TryParse(array3[1].Trim(), out var result) && result > 0) { dictionary[text2] = result; } } } return dictionary; } private static bool TryGetClickedTeleporterPin(Minimap minimap, out PinData clickedPin) { //IL_0050: 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_005a: 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_00a5: Unknown result type (might be due to invalid IL or missing references) clickedPin = null; Type type = AccessTools.TypeByName("Marketplace.Modules.Teleporter.Teleporter_Main_Client"); if (!(((type == null) ? null : AccessTools.Field(type, "CurrentTeleporterObjects"))?.GetValue(null) is IEnumerable enumerable)) { return false; } Vector3 val = minimap.ScreenToWorldPoint(Input.mousePosition); float num = minimap.m_removeRadius * minimap.m_largeZoom * 2f; foreach (object item in enumerable) { PinData val2 = (PinData)((item is PinData) ? item : null); if (val2 == null || Vector3.Distance(val2.m_pos, val) > num) { continue; } clickedPin = val2; return true; } return false; } private static bool CanUseMarketplaceTeleporterWithCurrentInventory() { if (((Humanoid)Player.m_localPlayer).IsTeleportable()) { return true; } return MarketplaceAllowsTeleportWithOre(); } private static bool MarketplaceAllowsTeleportWithOre() { try { Type type = AccessTools.TypeByName("Marketplace.Modules.Global_Options.Global_Configs"); object obj = ((type == null) ? null : AccessTools.Field(type, "SyncedGlobalOptions"))?.GetValue(null); object obj2 = obj?.GetType().GetProperty("Value")?.GetValue(obj, null); FieldInfo fieldInfo = ((obj2 == null) ? null : AccessTools.Field(obj2.GetType(), "_canTeleportWithOre")); return fieldInfo != null && (bool)fieldInfo.GetValue(obj2); } catch { return false; } } private static string CleanName(string name) { if (string.IsNullOrWhiteSpace(name)) { return ""; } return RichTextRegex.Replace(name, "").Trim(); } private static string NormalizeName(string name) { return CleanName(name).ToLowerInvariant(); } } [HarmonyPatch] public class Patches : MonoBehaviour { [HarmonyPatch(typeof(Player), "SetPlayerID")] internal class SetPlayerID { private static void Postfix(long playerID, string name) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) try { if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { Plugin.steamId = ((IUser)PlatformManager.DistributionPlatform.LocalUser).PlatformUserID.m_userID; Plugin.PlayerName = ((Character)Player.m_localPlayer).m_nview.GetZDO().GetString("playerName", ""); Debug.Log((object)("steamId: " + Plugin.steamId)); } } catch { } } } [HarmonyPatch(typeof(Chat), "OnNewChatMessage")] internal class OnNewChatMessage { private static bool Prefix(string text) { if (text.ToLower().Contains("i have arrived")) { return false; } if (text.ToLower().Contains("i have arrived")) { return false; } return true; } } [HarmonyPatch(typeof(Player), "HaveSeenTutorial")] public class Player_HaveSeenTutorial_Patch { [HarmonyPrefix] private static void Prefix(Player __instance, ref string name) { if (!__instance.m_shownTutorials.Contains(name)) { __instance.m_shownTutorials.Add(name); } } } [HarmonyPatch(typeof(SE_Stats), "Setup")] public static class SE_Stats_Setup_Patch { private static void Postfix(ref SE_Stats __instance) { int num = 200; if (__instance.m_addMaxCarryWeight > 0f) { __instance.m_addMaxCarryWeight = __instance.m_addMaxCarryWeight - 150f + (float)num; } } } [HarmonyPatch(typeof(Player), "Update")] public static class PlayerUpdate { [HarmonyPriority(0)] private static void Postfix(Player __instance) { if (Plugin.StaffMessage.Value != "") { ((Character)Player.m_localPlayer).Message((MessageType)2, Plugin.StaffMessage.Value, 0, (Sprite)null); } } } [HarmonyPatch(typeof(ZNet), "GetOtherPublicPlayers")] private class AdminGetOtherPublicPlayers { [HarmonyPriority(0)] private static void Postfix(List playerList) { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) if (!SynchronizationManager.Instance.PlayerIsAdmin || (Object)(object)ZNet.instance == (Object)null || playerList == null) { return; } Player localPlayer = Player.m_localPlayer; object obj; if (localPlayer == null) { obj = null; } else { ZNetView nview = ((Character)localPlayer).m_nview; if (nview == null) { obj = null; } else { ZDO zDO = nview.GetZDO(); obj = ((zDO != null) ? zDO.GetString("playerName", "") : null); } } if (obj == null) { obj = ""; } string text = (string)obj; foreach (PlayerInfo player in ZNet.instance.GetPlayerList()) { if (!string.IsNullOrWhiteSpace(player.m_name) && !(player.m_name == text) && !playerList.Exists((PlayerInfo existing) => existing.m_name == player.m_name)) { playerList.Add(player); } } } } [HarmonyPatch(typeof(CraftingStation), "Start")] public static class WorkbenchRangeIncrease { public static void Prefix(ref CraftingStation __instance, ref float ___m_rangeBuild, GameObject ___m_areaMarker) { try { ___m_rangeBuild = 30f; ___m_areaMarker.GetComponent().m_radius = ___m_rangeBuild; } catch { } } } [HarmonyPatch(typeof(Skills), "RaiseSkill")] public static class RaiseSkill { private static bool Prefix(ref Skills __instance, ref SkillType skillType, ref float factor) { Skill skill = __instance.GetSkill(skillType); if (skill.m_level >= (float)Plugin.SkillCap.Value) { return false; } factor *= Plugin.SkillMultiplier.Value; return true; } } [HarmonyPatch(typeof(TeleportWorld), "Teleport")] public static class TeleportWorldAesir { private static bool Prefix(TeleportWorld __instance, Player player) { if ((Object)(object)player != (Object)(object)Player.m_localPlayer) { return true; } if (Plugin.Vip.Value.Contains(Plugin.steamId)) { return true; } string text = __instance.GetText(); if (!Plugin.VipPortalNames.Value.Contains(text)) { return true; } ((Character)player).Message((MessageType)2, "Only Aesir can access this portal.", 0, (Sprite)null); return false; } } [HarmonyPatch(typeof(Player), "PlacePiece")] public static class NoBuild_Patch { [HarmonyPriority(0)] private static bool Prefix(Piece piece, Player __instance) { if (Plugin.Vip.Value.Contains(Plugin.steamId)) { return true; } if (((Object)((Component)piece).gameObject).name == "AesirChest") { ((Character)__instance).Message((MessageType)2, "Esse báu é apenas para Aesir's", 0, (Sprite)null); return false; } return true; } } [HarmonyPatch(typeof(ZNetScene), "RemoveObjects")] public static class ZNetScene_RemoveObjects_NullGuard { private static readonly FieldInfo s_instances = typeof(ZNetScene).GetField("m_instances", BindingFlags.Instance | BindingFlags.NonPublic); private static bool _dirty = true; [HarmonyPrefix] private static void Prefix(ZNetScene __instance) { if (!_dirty || !(s_instances?.GetValue(__instance) is Dictionary dictionary)) { return; } List list = null; foreach (KeyValuePair item in dictionary) { if ((Object)(object)item.Value == (Object)null) { if (list == null) { list = new List(); } list.Add(item.Key); } } if (list != null) { foreach (ZDO item2 in list) { dictionary.Remove(item2); } Debug.LogWarning((object)$"[Deadheim] Removed {list.Count} null ZNetView entries from ZNetScene.m_instances to stop NullReferenceException spam."); } else { _dirty = false; } } [HarmonyPatch(typeof(Game), "Logout")] [HarmonyPostfix] private static void OnLogout() { _dirty = true; } } [HarmonyPostfix] [HarmonyPatch(typeof(Game), "Update")] private static void GameUpdate() { if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { ((Selectable)InventoryGui.instance.m_pvp).interactable = false; } } [HarmonyPatch(typeof(Player), "OnSpawned")] [HarmonyPostfix] public static void Awake_Postfix(ref Player __instance) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown if (ZRoutedRpc.instance != null) { ItemService.SetWardFirePlace(); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "Sync", new object[1] { (object)new ZPackage() }); } } [HarmonyPatch(typeof(Player), "EdgeOfWorldKill")] [HarmonyPrefix] public static bool EdgeOfWorldKill() { return false; } public static void setDeathStat(HitData ___m_lastHit) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected I4, but got Unknown HitType hitType = ___m_lastHit.m_hitType; HitType val = hitType; switch ((int)val) { case 0: Game.instance.IncrementPlayerStat((PlayerStatType)55, 1f); break; case 1: Game.instance.IncrementPlayerStat((PlayerStatType)56, 1f); break; case 2: Game.instance.IncrementPlayerStat((PlayerStatType)57, 1f); break; case 3: Game.instance.IncrementPlayerStat((PlayerStatType)58, 1f); break; case 4: Game.instance.IncrementPlayerStat((PlayerStatType)59, 1f); break; case 5: Game.instance.IncrementPlayerStat((PlayerStatType)60, 1f); break; case 6: Game.instance.IncrementPlayerStat((PlayerStatType)61, 1f); break; case 7: Game.instance.IncrementPlayerStat((PlayerStatType)62, 1f); break; case 8: Game.instance.IncrementPlayerStat((PlayerStatType)64, 1f); break; case 9: Game.instance.IncrementPlayerStat((PlayerStatType)63, 1f); break; case 10: Game.instance.IncrementPlayerStat((PlayerStatType)65, 1f); break; case 11: Game.instance.IncrementPlayerStat((PlayerStatType)66, 1f); break; case 12: Game.instance.IncrementPlayerStat((PlayerStatType)67, 1f); break; case 13: Game.instance.IncrementPlayerStat((PlayerStatType)68, 1f); break; case 14: Game.instance.IncrementPlayerStat((PlayerStatType)69, 1f); break; case 15: Game.instance.IncrementPlayerStat((PlayerStatType)70, 1f); break; case 16: Game.instance.IncrementPlayerStat((PlayerStatType)71, 1f); break; case 17: Game.instance.IncrementPlayerStat((PlayerStatType)72, 1f); break; case 18: Game.instance.IncrementPlayerStat((PlayerStatType)73, 1f); break; default: ZLog.LogWarning((object)("Not implemented death type " + ((object)(HitType)(ref ___m_lastHit.m_hitType)).ToString())); break; } } } [BepInPlugin("Detalhes.Deadheim", "Detalhes.Deadheim", "6.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string Version = "6.0.0"; public const string PluginGUID = "Detalhes.Deadheim"; public static string steamId = ""; public static ConfigEntry Vip; public static ConfigEntry AdminList; public static ConfigEntry OnlyAdminPieces; public static ConfigEntry VipPortalNames; public static ConfigEntry WardRadius; public static ConfigEntry StaffMessage; public static ConfigEntry DungeonPrefabs; public static ConfigEntry SkillMultiplier; public static ConfigEntry BoatWindSpeedmultiplier; public static ConfigEntry SafeArea; public static ConfigEntry WardLimit; public static ConfigEntry WardLimitVip; public static ConfigEntry MarketplaceTeleporterCosts; public static ConfigEntry MarketplaceTeleporterCostItem; public static ConfigEntry WardChargeDurationInSec; public static ConfigEntry ResetWorldDay; public static ConfigEntry WolvesAreTameable; public static ConfigEntry LoxTameable; public static ConfigEntry SkillCap; public static ConfigEntry PortalMaterials; public static string PlayerName = ""; public static bool IsAdmin = false; public static int PlayerWardCount = 999; public static int PlayerPortalCount = 999; public static int maxPlayers = 50; public static List validatedUsers = new List(); public static bool hasSpawned = false; private Harmony _harmony = new Harmony("Detalhes.deadheim"); private void Update() { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown Player localPlayer = Player.m_localPlayer; if ((Object)(object)Player.m_localPlayer == (Object)null || !Object.op_Implicit((Object)(object)localPlayer.m_hovering)) { return; } Interactable componentInParent = localPlayer.m_hovering.GetComponentInParent(); if (componentInParent != null && componentInParent is Bed) { Bed val = (Bed)componentInParent; if (val.IsMine() && Input.GetKeyDown((KeyCode)112)) { Retreat.SetHearthStonePosition(); ((Character)Player.m_localPlayer).Message((MessageType)2, "Seu novo ponto de Retreat", 0, (Sprite)null); } } } private void Awake() { //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_0064: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_0096: 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_00a4: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Expected O, but got Unknown //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Expected O, but got Unknown //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Expected O, but got Unknown //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Expected O, but got Unknown //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Expected O, but got Unknown //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Expected O, but got Unknown //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Expected O, but got Unknown //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Expected O, but got Unknown //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Expected O, but got Unknown //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Expected O, but got Unknown //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Expected O, but got Unknown //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Expected O, but got Unknown //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Expected O, but got Unknown //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Expected O, but got Unknown //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Expected O, but got Unknown //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Expected O, but got Unknown //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Expected O, but got Unknown //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Expected O, but got Unknown //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Expected O, but got Unknown //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Expected O, but got Unknown //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Expected O, but got Unknown //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Expected O, but got Unknown //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03c8: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Expected O, but got Unknown //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Expected O, but got Unknown //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_0408: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Expected O, but got Unknown //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_041b: Expected O, but got Unknown //IL_0443: Unknown result type (might be due to invalid IL or missing references) //IL_0448: Unknown result type (might be due to invalid IL or missing references) //IL_0451: Expected O, but got Unknown //IL_0451: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Expected O, but got Unknown //IL_0483: Unknown result type (might be due to invalid IL or missing references) //IL_0488: Unknown result type (might be due to invalid IL or missing references) //IL_0491: Expected O, but got Unknown //IL_0491: Unknown result type (might be due to invalid IL or missing references) //IL_049b: Expected O, but got Unknown //IL_04bf: Unknown result type (might be due to invalid IL or missing references) //IL_04c4: Unknown result type (might be due to invalid IL or missing references) //IL_04cd: Expected O, but got Unknown //IL_04cd: Unknown result type (might be due to invalid IL or missing references) //IL_04d7: Expected O, but got Unknown //IL_04ff: Unknown result type (might be due to invalid IL or missing references) //IL_0504: Unknown result type (might be due to invalid IL or missing references) //IL_050d: Expected O, but got Unknown //IL_050d: Unknown result type (might be due to invalid IL or missing references) //IL_0517: Expected O, but got Unknown SynchronizationManager.OnConfigurationSynchronized += delegate(object obj, ConfigurationSynchronizationEventArgs attr) { if (attr.InitialSynchronization) { ItemService.SetWardFirePlace(); ItemService.ModifyItemsCost(); ItemService.LoxTameable(); ItemService.WolvesTameable(); ItemService.StubNoLife(); ItemService.OnlyAdminPieces(); IsAdmin = AdminList.Value.Contains(steamId); } else { Logger.LogMessage((object)"Config sync event received"); } }; ((BaseUnityPlugin)this).Config.SaveOnConfigSet = true; OnlyAdminPieces = ((BaseUnityPlugin)this).Config.Bind("Server config", "OnlyAdminPieces", "SHGateHouse,SHWallMusteringHall,SHTowerSquareTwoFloorCenter,SHTowerSquareTwoFloorCorner,SHTowerSquareTwoFloorJunction,SHWallOpenTwoFloorCapped,SHWallOpenTwoFloorWithNest,SHWallOpenTwoFloorWithNestCapped,SHWallOpenTwoFloor,SHEnclosedTower,SHBunkhouse,SHWell,SHOuterWallCovered,SHOuterWallOpenCapped,SHOuterWallOpen,SHOuterWallTowerSquareCenter,SHOuterWallTowerTransition,SHOuterWallTowerRound,SHOuterWallGate,SHWatchtower,SHTowerRoundWallEnd,SHOuterWallCoverdCapped,SHWallInnerArch,SHWallInnerPillar,SHWallInnerPlain,SHWallInnerPosh,SHHouseSmall,SHHouseMedium,SHHouseLarge,SHHayBarn,SHOldBarn,SHStorageBarn,SHMainHall", new ConfigDescription("OnlyAdminPieces", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); VipPortalNames = ((BaseUnityPlugin)this).Config.Bind("Server config", "VipPortalNames", "cavalinho,eguinha", new ConfigDescription("VipPortalNames", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); SkillCap = ((BaseUnityPlugin)this).Config.Bind("Server config", "SkillCap", 100, new ConfigDescription("SkillCap", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); AdminList = ((BaseUnityPlugin)this).Config.Bind("Server config", "AdminList", "76561198053330247 76561197961128381 76561198111650012 76561197993642177 76561198993982965", new ConfigDescription("AdminList", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); Vip = ((BaseUnityPlugin)this).Config.Bind("Server config", "Vip", "76561198053330247", new ConfigDescription("VipList", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); StaffMessage = ((BaseUnityPlugin)this).Config.Bind("Server config", "StaffMessage", "", new ConfigDescription("StaffMessage", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); DungeonPrefabs = ((BaseUnityPlugin)this).Config.Bind("Server config", "DungeonPrefabs", "dungeon_forestcrypt_door,dungeon_sunkencrypt_irongate", new ConfigDescription("DungeonPrefabs", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); WolvesAreTameable = ((BaseUnityPlugin)this).Config.Bind("Server config", "WolvesAreTameable", false, new ConfigDescription("WolvesAreTameable", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); LoxTameable = ((BaseUnityPlugin)this).Config.Bind("Server config", "LoxTameable", false, new ConfigDescription("LoxTameable", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); SafeArea = ((BaseUnityPlugin)this).Config.Bind("Server config", "SafeArea", 1500, new ConfigDescription("SafeArea", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); WardChargeDurationInSec = ((BaseUnityPlugin)this).Config.Bind("Server config", "WardChargeDurationInSec", 86400, new ConfigDescription("WardChargeDurationInSec", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); MarketplaceTeleporterCosts = ((BaseUnityPlugin)this).Config.Bind("Server config", "MarketplaceTeleporterCosts", "agostinho:100,barqueiro:50", new ConfigDescription("Gold cost for Marketplace teleporter NPCs. Format: NPCName:Cost,NPCName:Cost", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); MarketplaceTeleporterCostItem = ((BaseUnityPlugin)this).Config.Bind("Server config", "MarketplaceTeleporterCostItem", "Coins", new ConfigDescription("Item prefab consumed when using Marketplace teleporter NPCs.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); WardLimit = ((BaseUnityPlugin)this).Config.Bind("Server config", "WardLimit", 3, new ConfigDescription("WardLimit", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); WardLimitVip = ((BaseUnityPlugin)this).Config.Bind("Server config", "WardLimitVip", 5, new ConfigDescription("WardLimitVip", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); WardRadius = ((BaseUnityPlugin)this).Config.Bind("Server config", "WardRadius", 150, new ConfigDescription("WardRadius", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); BoatWindSpeedmultiplier = ((BaseUnityPlugin)this).Config.Bind("Server config", "boatWindSpeedmultiplier", 1f, new ConfigDescription("boatWindSpeedmultiplier", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); SkillMultiplier = ((BaseUnityPlugin)this).Config.Bind("Server config", "SkillMultiplier", 0.5f, new ConfigDescription("SkillMultiplier", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); ResetWorldDay = ((BaseUnityPlugin)this).Config.Bind("Server config", "ResetWorldDay", false, new ConfigDescription("ResetWorldDay", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); PortalMaterials = ((BaseUnityPlugin)this).Config.Bind("Portal Mats", "PortalMaterials", "PortalToken:1,FineWood:100,GreydwarfEye:30,SurtlingCore:10", new ConfigDescription("Dynamic materials for the portal. Format: PrefabName:Amount,PrefabName:Amount", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); _harmony.PatchAll(); Deadheim.MarketplaceTeleporterCosts.StartPatchRetry((MonoBehaviour)(object)this, _harmony); ClonedItems.LoadAssets(); } } [HarmonyPatch] internal class Portal { [HarmonyPatch(typeof(Player), "PlacePiece")] public static class NoBuild_Patch { public static void UpdatePortalMaterials() { //IL_00e9: 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_00f6: 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_010a: Expected O, but got Unknown GameObject prefab = PrefabManager.Instance.GetPrefab("portal_wood"); if ((Object)(object)prefab == (Object)null) { return; } Piece component = prefab.GetComponent(); List list = new List(); string[] array = Plugin.PortalMaterials.Value.Split(new char[1] { ',' }); string[] array2 = array; foreach (string text in array2) { string[] array3 = text.Split(new char[1] { ':' }); if (array3.Length != 2) { continue; } string text2 = array3[0].Trim(); if (!int.TryParse(array3[1].Trim(), out var result) || result <= 0) { continue; } GameObject prefab2 = PrefabManager.Instance.GetPrefab(text2); if ((Object)(object)prefab2 != (Object)null) { ItemDrop component2 = prefab2.GetComponent(); if ((Object)(object)component2 != (Object)null) { list.Add(new Requirement { m_resItem = component2, m_amount = result, m_recover = true }); } else { Logger.LogWarning((object)("[Deadheim] O prefab '" + text2 + "' não é um item válido.")); } } else { Logger.LogWarning((object)("[Deadheim] Prefab '" + text2 + "' não encontrado no jogo.")); } } if (list.Count > 0) { component.m_resources = list.ToArray(); Logger.LogInfo((object)"[Deadheim] Materiais do portal atualizados dinamicamente!"); } else { Logger.LogWarning((object)"[Deadheim] Nenhum material válido na config. Mantendo os materiais originais."); } } private static int GetPortalCount() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown if (SynchronizationManager.Instance.PlayerIsAdmin) { return 0; } ZPackage val = new ZPackage(); val.Write(Player.m_localPlayer.GetPlayerID()); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "DeadheimPortalAndTotemCountServer", new object[1] { val }); return Plugin.PlayerPortalCount; } } } [HarmonyPatch] public class Retreat { [HarmonyPatch(typeof(Terminal), "InitTerminal")] public class AddChatCommands { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEvent <>9__0_0; internal void b__0_0(ConsoleEventArgs args) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_005c: 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_008e: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.Vip.Value.Contains(Plugin.steamId)) { args.Context.AddString("Only Aesir can use this command"); return; } if (!((Humanoid)Player.m_localPlayer).IsTeleportable()) { args.Context.AddString("Can't teleport"); return; } Vector3 hearthStonePosition = GetHearthStonePosition(); if (hearthStonePosition == Vector3.zero) { args.Context.AddString("You need to set hearthstone spawn point"); } else { ((Character)Player.m_localPlayer).TeleportTo(hearthStonePosition, ((Component)Player.m_localPlayer).transform.rotation, true); } } } private static void Postfix() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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) //IL_002a: Expected O, but got Unknown object obj = <>c.<>9__0_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_005c: 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_008e: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.Vip.Value.Contains(Plugin.steamId)) { args.Context.AddString("Only Aesir can use this command"); } else if (!((Humanoid)Player.m_localPlayer).IsTeleportable()) { args.Context.AddString("Can't teleport"); } else { Vector3 hearthStonePosition = GetHearthStonePosition(); if (hearthStonePosition == Vector3.zero) { args.Context.AddString("You need to set hearthstone spawn point"); } else { ((Character)Player.m_localPlayer).TeleportTo(hearthStonePosition, ((Component)Player.m_localPlayer).transform.rotation, true); } } }; <>c.<>9__0_0 = val; obj = (object)val; } new ConsoleCommand("retreat", "go back home", (ConsoleEvent)obj, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } } [HarmonyPatch(typeof(Chat), "Awake")] public class AddGroupChat { private static void Postfix(Chat __instance) { int index = Math.Max(0, ((Terminal)__instance).m_chatBuffer.Count - 5); ((Terminal)__instance).m_chatBuffer.Insert(index, "/retreat go back home"); ((Terminal)__instance).UpdateChat(); } } [HarmonyPatch(typeof(Bed), "GetHoverText")] private static class Bed_GetHoverText_Patch { private static void Postfix(Bed __instance, ref string __result, ZNetView ___m_nview) { if ((__instance.IsMine() && ___m_nview.GetZDO().GetLong("owner", 0L) != 0L) || Traverse.Create((object)__instance).Method("IsCurrent", Array.Empty()).GetValue()) { __result += Localization.instance.Localize("\n[P] Definir ponto de retreat"); } } } public static Vector3 GetHearthStonePosition() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.m_localPlayer == (Object)null || !Player.m_localPlayer.m_customData.ContainsKey("positionX")) { return Vector3.zero; } Vector3 result = default(Vector3); result.x = float.Parse(Player.m_localPlayer.m_customData["positionX"]); result.y = float.Parse(Player.m_localPlayer.m_customData["positionY"]); result.z = float.Parse(Player.m_localPlayer.m_customData["positionZ"]); return result; } public static void SetHearthStonePosition() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Player.m_localPlayer == (Object)null)) { Vector3 position = ((Component)Player.m_localPlayer).transform.position; Player.m_localPlayer.m_customData["positionX"] = position.x.ToString(); Player.m_localPlayer.m_customData["positionY"] = position.y.ToString(); Player.m_localPlayer.m_customData["positionZ"] = position.z.ToString(); } } } [HarmonyPatch] internal class RPC { [HarmonyPatch(typeof(Player), "OnSpawned")] public static class OnSpawned { public static void Postfix() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ZPackage val = new ZPackage(); val.Write(Player.m_localPlayer.GetPlayerID()); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "DeadheimPortalAndTotemCountServer", new object[1] { val }); } } [HarmonyPatch(typeof(Game), "Start")] public static class GameStart { public static void Postfix() { if (ZRoutedRpc.instance != null) { ZRoutedRpc.instance.Register("DeadheimPortalAndTotemCountServer", (Action)RPC_PortalAndTotemCountServer); ZRoutedRpc.instance.Register("DeadheimPortalAndTotemCountClient", (Action)RPC_PortalAndTotemCountClient); } } } public static void RPC_PortalAndTotemCountServer(long sender, ZPackage pkg) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown if (ZNet.instance.IsServer()) { long creatorId = pkg.ReadLong(); string creatorWardAndPortalCount = Util.GetCreatorWardAndPortalCount(creatorId); ZPackage val = new ZPackage(); val.Write(creatorWardAndPortalCount); ZRoutedRpc.instance.InvokeRoutedRPC(sender, "DeadheimPortalAndTotemCountClient", new object[1] { val }); } } public static void RPC_PortalAndTotemCountClient(long sender, ZPackage pkg) { string text = pkg.ReadString(); Plugin.PlayerPortalCount = Convert.ToInt32(text.Split(new char[1] { ',' })[0]); Plugin.PlayerWardCount = Convert.ToInt32(text.Split(new char[1] { ',' })[1]); } } [HarmonyPatch] internal class Smelters { [HarmonyPatch(typeof(Smelter), "Awake")] public static class Smelter_Awake_Patch { private static void Prefix(ref Smelter __instance) { string value = "$piece_charcoalkiln"; string value2 = "$piece_smelter"; string value3 = "$piece_blastfurnace"; if (__instance.m_name.Equals(value)) { __instance.m_maxOre = 100; __instance.m_secPerProduct = 20f; } else if (__instance.m_name.Equals(value2)) { __instance.m_maxOre = 50; __instance.m_maxFuel = 100; __instance.m_secPerProduct = 20f; __instance.m_fuelPerProduct = 2; } else if (__instance.m_name.Equals(value3)) { __instance.m_maxOre = 50; __instance.m_maxFuel = 100; __instance.m_secPerProduct = 20f; __instance.m_fuelPerProduct = 2; } } } } public static class Util { public static int CREATORHASH = StringExtensionMethods.GetStableHashCode("creator"); public static string GetCreatorWardAndPortalCount(long creatorId) { int creatorPrefabCount = GetCreatorPrefabCount(StringExtensionMethods.GetStableHashCode("portal_wood"), creatorId); int creatorPrefabCount2 = GetCreatorPrefabCount(StringExtensionMethods.GetStableHashCode("guard_stone"), creatorId); return $"{creatorPrefabCount},{creatorPrefabCount2}"; } private static int GetCreatorPrefabCount(int prefabHash, long creatorId) { int num = 0; List[] objectsBySector = ZDOMan.instance.m_objectsBySector; foreach (List list in objectsBySector) { if (list == null) { continue; } for (int j = 0; j < list.Count; j++) { ZDO val = list[j]; if (val.GetPrefab() == prefabHash) { long @long = val.GetLong(CREATORHASH, 0L); if (@long != 0 && @long == creatorId) { num++; } } } } return num; } private static byte[] ReadEmbeddedFileBytes(string name) { using MemoryStream memoryStream = new MemoryStream(); Assembly.GetExecutingAssembly().GetManifestResourceStream(Assembly.GetExecutingAssembly().GetName().Name + "." + name).CopyTo(memoryStream); return memoryStream.ToArray(); } private static Texture2D LoadTexture(string name) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown Texture2D val = new Texture2D(2, 2); byte[] array = ReadEmbeddedFileBytes("assets." + name); if (array == null || array.Length == 0) { return val; } MethodInfo method = typeof(ImageConversion).GetMethod("LoadImage", new Type[2] { typeof(Texture2D), typeof(byte[]) }); if (method != null) { method.Invoke(null, new object[2] { val, array }); } else { Debug.LogError((object)"[LoadTexture] Could not find LoadImage method via Reflection."); } return val; } public static Sprite LoadSprite(string name, int width, int height) { //IL_0014: 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) return Sprite.Create(LoadTexture(name), new Rect(0f, 0f, (float)width, (float)height), Vector2.zero); } } } namespace Deadheim.world { internal class World { [HarmonyPatch(typeof(ZNet), "SaveWorldThread")] internal class SaveWorldThread { private static void Prefix(ref ZNet __instance) { if (Plugin.ResetWorldDay.Value) { __instance.m_netTime = 2040.0; } } } } } namespace Deadheim.EnhancedWards { [HarmonyPatch] public class Ward { [HarmonyPatch(typeof(WearNTear), "RPC_Damage")] public static class RPC_Damage { [HarmonyPriority(800)] private static bool Prefix(WearNTear __instance, ref HitData hit, ZNetView ___m_nview) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) try { if (___m_nview == null) { return false; } if (!CheckInPrivateArea(((Component)__instance).transform.position)) { return true; } if (((Object)((Component)__instance).gameObject).name.Contains("guard_stone")) { return false; } if (((Object)((Component)__instance).gameObject).name.Contains("AdminWard")) { return false; } if (Vector3.Distance(new Vector3(0f, 0f), ((Component)Player.m_localPlayer).transform.position) <= (float)Plugin.SafeArea.Value) { return false; } return true; } catch (Exception ex) { Debug.LogError((object)(ex.Message + " - " + ex.StackTrace)); return false; } } } [HarmonyPatch(typeof(Door), "CanInteract")] public static class DoorCanInteract { private static void Postfix(Door __instance, ref bool __result) { string name = ((Object)((Component)__instance).gameObject).name; name = name.Replace("(Clone)", ""); if (Plugin.DungeonPrefabs.Value.Split(new char[1] { ',' }).Contains(((Object)((Component)__instance).gameObject).name.Replace("(Clone)", ""))) { __result = true; } } } [HarmonyPatch(typeof(PrivateArea), "IsEnabled")] public static class PrivateAreaCheckAccess { private static void Postfix(PrivateArea __instance, ref bool __result) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown Player localPlayer = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)localPlayer) || !Object.op_Implicit((Object)(object)localPlayer.m_hovering)) { return; } Interactable componentInParent = localPlayer.m_hovering.GetComponentInParent(); if (componentInParent == null) { return; } Door val = null; Container val2 = null; if (((object)componentInParent).GetType().Name == "Door") { val = (Door)componentInParent; } if (((object)componentInParent).GetType().Name == "Container") { val2 = (Container)componentInParent; } if (val == null && val2 == null) { return; } string text = ""; if (val != null) { text = ((Object)((Component)val).gameObject).name; } if (Object.op_Implicit((Object)(object)val2)) { text = ((Object)((Component)val2).gameObject).name; } if (!(text == "")) { text = text.Replace("(Clone)", ""); if (Plugin.DungeonPrefabs.Value.Split(new char[1] { ',' }).Contains(text)) { __result = false; } } } } [HarmonyPatch(typeof(Fireplace), "UpdateState")] public static class FireplaceUpdateState { private static bool Prefix(Fireplace __instance) { if (!((Object)((Component)__instance).gameObject).name.Contains("guard_stone")) { return true; } return false; } } [HarmonyPatch(typeof(Fireplace), "Awake")] public static class FireplaceAwake { private static bool Prefix(Fireplace __instance) { try { if (!((Object)((Component)__instance).gameObject).name.Contains("guard_stone")) { return true; } __instance.m_nview = ((Component)__instance).gameObject.GetComponent(); __instance.m_piece = ((Component)__instance).gameObject.GetComponent(); if (__instance.m_nview.GetZDO() == null) { return false; } if (__instance.m_nview.IsOwner() && (double)__instance.m_nview.GetZDO().GetFloat("fuel", -1f) == -1.0) { __instance.m_nview.GetZDO().Set("fuel", __instance.m_startFuel); } __instance.m_nview.Register("AddFuel", (Action)__instance.RPC_AddFuel); ((MonoBehaviour)__instance).InvokeRepeating("UpdateFireplace", 0f, 10f); return false; } catch { return false; } } } [HarmonyPatch(typeof(Fireplace), "UpdateFireplace")] public static class UpdateFireplace { private static bool Prefix(Fireplace __instance) { if (!((Object)((Component)__instance).gameObject).name.Contains("guard_stone")) { return true; } if (!__instance.m_nview.IsValid()) { return false; } Piece component = ((Component)__instance).gameObject.GetComponent(); if (__instance.m_nview.IsOwner()) { if (__instance.m_fuelItem == null) { __instance.m_fuelItem = PrefabManager.Instance.GetPrefab("GreydwarfEye").GetComponent(); } __instance.m_secPerFuel = Plugin.WardChargeDurationInSec.Value; __instance.m_maxFuel = 10f; PrivateArea component2 = ((Component)__instance).gameObject.GetComponent(); float @float = __instance.m_nview.GetZDO().GetFloat("fuel", 0f); double timeSinceLastUpdate = __instance.GetTimeSinceLastUpdate(); float num = (float)timeSinceLastUpdate / __instance.m_secPerFuel; float num2 = @float - num; if ((double)num2 <= 0.0) { num2 = 0f; if (component2.IsEnabled()) { component2.SetEnabled(false); } } if (num2 > 10f) { num2 = 10f; } __instance.m_nview.GetZDO().Set("fuel", num2); } return false; } } [HarmonyPatch(typeof(Player), "PlacePiece")] public static class NoBuild_Patch { [HarmonyPriority(800)] private static bool Prefix(Piece piece, Player __instance) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_00b0: Unknown result type (might be due to invalid IL or missing references) if (SynchronizationManager.Instance.PlayerIsAdmin) { return true; } bool flag = ((Object)((Component)piece).gameObject).name.Contains("guard_stone"); bool flag2 = false; Vector3 position = __instance.m_placementGhost.transform.position; if (flag) { List zDOList = GetZDOList(StringExtensionMethods.GetStableHashCode(((Object)((Component)piece).gameObject).name)); foreach (ZDO item in zDOList) { if (Vector3.Distance(new Vector3(position.x, 0f, position.z), new Vector3(item.m_position.x, 0f, item.m_position.z)) <= ((Component)piece).GetComponent().m_radius * 3f && !IsBuilderPermitted(item, __instance)) { ((Character)Player.m_localPlayer).Message((MessageType)2, "Não é possível construir wards próximo da área de outros wards.", 0, (Sprite)null); return false; } } } if (!flag) { return true; } int wardCount = GetWardCount(); if (Plugin.Vip.Value.Contains(Plugin.steamId)) { if (wardCount >= Plugin.WardLimitVip.Value) { ((Character)Player.m_localPlayer).Message((MessageType)2, "Você não pode mais colocar wards.", 0, (Sprite)null); return false; } } else if (wardCount >= Plugin.WardLimit.Value) { ((Character)Player.m_localPlayer).Message((MessageType)2, "Você não pode mais colocar wards.", 0, (Sprite)null); return false; } Minimap.instance.AddPin(((Component)__instance).transform.position, (PinType)9, "WARD", true, false, 0L, default(PlatformUserID)); ZPackage val = new ZPackage(); val.Write(Player.m_localPlayer.GetPlayerID()); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "DeadheimPortalAndTotemCountServer", new object[1] { val }); return true; } } [HarmonyPatch(typeof(Player), "Update")] public static class Update { private static void Postfix(ref Player __instance) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)__instance.m_hovering)) { return; } Interactable componentInParent = __instance.m_hovering.GetComponentInParent(); if (componentInParent == null) { return; } PrivateArea val = (PrivateArea)(object)((componentInParent is PrivateArea) ? componentInParent : null); if (val == null) { return; } Fireplace componentInParent2 = ((Component)val).GetComponentInParent(); StringBuilder stringBuilder = new StringBuilder(256); KeyCode val2 = (KeyCode)107; KeyCode val3 = (KeyCode)121; if (val.IsPermitted(__instance.GetPlayerID()) || val.m_piece.m_creator == __instance.GetPlayerID()) { if (Object.op_Implicit((Object)(object)componentInParent2)) { stringBuilder.Append("\n[" + ((object)(KeyCode)(ref val3)).ToString() + "] Fuel: " + Math.Round(componentInParent2.m_nview.GetZDO().GetFloat("fuel", 0f), 2) + "/" + componentInParent2.m_maxFuel); } stringBuilder.Append("\n[" + ((object)(KeyCode)(ref val2)).ToString() + "]"); val.m_name = stringBuilder.ToString(); val.AddUserList(stringBuilder); if (Input.GetKeyDown(val2)) { Interact(__instance, __instance.m_hovering, val); } if (Input.GetKeyDown(val3)) { FuelWard(__instance, componentInParent2); } } } public static void FuelWard(Player player, Fireplace fireplace) { if (!((double)fireplace.m_holdRepeatInterval <= 0.0) && !(Time.time - fireplace.m_lastUseTime < fireplace.m_holdRepeatInterval)) { if (!fireplace.m_nview.HasOwner()) { fireplace.m_nview.ClaimOwnership(); } if (fireplace.m_fuelItem == null) { fireplace.m_fuelItem = PrefabManager.Instance.GetPrefab("GreydwarfEye").GetComponent(); } fireplace.Interact((Humanoid)(object)player, false, false); } } public static void Interact(Player player, GameObject go, PrivateArea privateArea) { //IL_003c: 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) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) player.m_lastHoverInteractTime = Time.time; privateArea.m_nview.InvokeRPC("ToggleEnabled", new object[1] { privateArea.m_piece.GetCreator() }); Vector3 val = go.transform.position - ((Component)player).transform.position; val.y = 0f; ((Vector3)(ref val)).Normalize(); ((Component)player).transform.rotation = Quaternion.LookRotation(val); ((Character)player).m_zanim.SetTrigger("interact"); } } public static bool CheckInPrivateArea(Vector3 point, bool flash = false) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) foreach (PrivateArea allArea in PrivateArea.m_allAreas) { if (allArea.IsEnabled() && allArea.IsInside(point, 0f)) { if (flash) { allArea.FlashShield(false); } return true; } } return false; } private static int GetWardCount() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown if (SynchronizationManager.Instance.PlayerIsAdmin) { return 0; } ZPackage val = new ZPackage(); val.Write(Player.m_localPlayer.GetPlayerID()); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "DeadheimPortalAndTotemCountServer", new object[1] { val }); return Plugin.PlayerWardCount; } private static List GetZDOList(int prefabHash) { List list = new List(); List[] objectsBySector = ZDOMan.instance.m_objectsBySector; foreach (List list2 in objectsBySector) { if (list2 == null) { continue; } for (int j = 0; j < list2.Count; j++) { ZDO val = list2[j]; if (val.GetPrefab() == prefabHash) { list.Add(val); } } } return list; } private static bool IsBuilderPermitted(ZDO zdo, Player player) { List> list = new List>(); long @long = zdo.GetLong(Util.CREATORHASH, 0L); if (@long == player.GetPlayerID()) { return true; } int @int = zdo.GetInt("permitted", 0); for (int i = 0; i < @int; i++) { long long2 = zdo.GetLong("pu_id" + i, 0L); string @string = zdo.GetString("pu_name" + i, ""); if (long2 != 0) { list.Add(new KeyValuePair(long2, @string)); } } foreach (KeyValuePair item in list) { if (item.Key == player.GetPlayerID()) { return true; } } return false; } } } namespace Deadheim.Craft { public class CraftPatches { [HarmonyPatch(typeof(InventoryGui), "UpdateRecipe")] private class FasterCrafting { private static void Prefix(ref InventoryGui __instance) { __instance.m_craftDuration = 0.25f; } } } }