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.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using FreyjaLandlord.Core; using FreyjaLandlord.Data; using FreyjaLandlord.Network; using FreyjaLandlord.UI; using FreyjaLandlord.Utils; using HarmonyLib; using Microsoft.CodeAnalysis; using Splatform; using TMPro; 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: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("freyja")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("A comprehensive landlord and territory economy system for Valheim")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("FreyjaLandlord")] [assembly: AssemblyTitle("FreyjaLandlord")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace FreyjaLandlord { [BepInPlugin("freyja.landlord", "Freyja Landlord System", "1.0.0")] [BepInProcess("valheim.exe")] [BepInProcess("valheim_server.exe")] public class Plugin : BaseUnityPlugin { public const string PluginGUID = "freyja.landlord"; public const string PluginName = "Freyja Landlord System"; public const string PluginVersion = "1.0.0"; private Harmony _harmony; private GameObject _managerObject; public static Plugin Instance { get; private set; } public static ManualLogSource Log { get; private set; } private void Awake() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown //IL_0159: Unknown result type (might be due to invalid IL or missing references) Instance = this; Log = ((BaseUnityPlugin)this).Logger; Log.LogInfo((object)"Loading Freyja Landlord System v1.0.0..."); LandlordConfig.Initialize(((BaseUnityPlugin)this).Config); if (!ServerGuard.Init(this)) { Log.LogError((object)"Server authentication failed - mod disabled"); return; } _harmony = new Harmony("freyja.landlord"); _harmony.PatchAll(typeof(Plugin).Assembly); Log.LogInfo((object)"Harmony patches applied"); _managerObject = new GameObject("FreyjaLandlordManager"); Object.DontDestroyOnLoad((Object)(object)_managerObject); _managerObject.AddComponent(); _managerObject.AddComponent(); _managerObject.AddComponent(); _managerObject.AddComponent(); _managerObject.AddComponent(); _managerObject.AddComponent(); _managerObject.AddComponent(); _managerObject.AddComponent(); _managerObject.AddComponent(); _managerObject.AddComponent(); _managerObject.AddComponent(); _managerObject.AddComponent(); Log.LogInfo((object)"Freyja Landlord System loaded successfully!"); Log.LogInfo((object)$"Press {LandlordConfig.HUDToggleKey.Value} to open the Landlord HUD"); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } if ((Object)(object)_managerObject != (Object)null) { Object.Destroy((Object)(object)_managerObject); } } } public class PositionTracker : MonoBehaviour { private float _trackTimer = 0f; private const float TrackInterval = 0.5f; private Vector2i? _lastReportedGrid = null; private void Update() { if ((Object)(object)Player.m_localPlayer == (Object)null) { return; } ZNet instance = ZNet.instance; if (instance == null || !instance.IsServer()) { _trackTimer += Time.deltaTime; if (_trackTimer >= 0.5f) { _trackTimer = 0f; ReportPosition(); } } } private void ReportPosition() { //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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { Vector3 position = ((Component)localPlayer).transform.position; Vector2i val = GridUtils.WorldToVisualGrid(position); if (!_lastReportedGrid.HasValue || _lastReportedGrid.Value != val) { _lastReportedGrid = val; LandlordRPC.Instance?.ReportPlayerPosition(position); } } } } } namespace FreyjaLandlord.Utils { public static class BiomeUtils { private static Dictionary _merchantCache = new Dictionary(); private static float _merchantCacheTime = 0f; private const float MerchantCacheLifetime = 60f; public static Biome GetBiomeAt(Vector3 position) { //IL_0016: 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) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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) if (WorldGenerator.instance == null) { return (Biome)1; } return WorldGenerator.instance.GetBiome(position); } public static Dictionary SampleBiomeComposition(Vector2i gridPos, int sampleCount = 100) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: 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_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Expected I4, but got Unknown //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected I4, but got Unknown Dictionary dictionary = new Dictionary(); Vector3 regionCenter = VoronoiGrid.Instance.GetRegionCenter(gridPos); float num = VoronoiGrid.Instance.GetApproximateRegionRadius(gridPos); if (num < 200f) { num = 200f; } if (num > 2000f) { num = 2000f; } int num2 = (int)Mathf.Sqrt((float)sampleCount); if (num2 < 5) { num2 = 5; } float num3 = num * 2f; float num4 = num3 * 2f / (float)num2; int num5 = 0; Vector3 val = default(Vector3); for (int i = 0; i < num2; i++) { for (int j = 0; j < num2; j++) { float num6 = regionCenter.x - num3 + ((float)i + 0.5f) * num4; float num7 = regionCenter.z - num3 + ((float)j + 0.5f) * num4; ((Vector3)(ref val))..ctor(num6, 0f, num7); Vector2i region = VoronoiGrid.Instance.GetRegion(val); if (region.x == gridPos.x && region.y == gridPos.y) { Biome biomeAt = GetBiomeAt(val); int key = (int)biomeAt; if (!dictionary.ContainsKey(key)) { dictionary[key] = 0f; } dictionary[key]++; num5++; } } } if (num5 > 0) { foreach (int item in new List(dictionary.Keys)) { dictionary[item] = dictionary[item] / (float)num5 * 100f; } } if (num5 == 0) { Biome biomeAt2 = GetBiomeAt(regionCenter); dictionary[(int)biomeAt2] = 100f; } return dictionary; } public static bool CellHasMerchant(Vector2i gridPos) { //IL_004b: 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_008b: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_00fc: 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_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0122: 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_0131: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ZoneSystem.instance == (Object)null) { return false; } if (Time.time - _merchantCacheTime > 60f) { _merchantCache.Clear(); _merchantCacheTime = Time.time; } if (_merchantCache.TryGetValue(gridPos, out var value)) { return value; } bool flag = false; Vector3 worldPos = default(Vector3); foreach (KeyValuePair locationInstance in ZoneSystem.instance.m_locationInstances) { LocationInstance value2 = locationInstance.Value; if (value2.m_location == null) { continue; } string text = value2.m_location.m_prefabName?.ToLower() ?? ""; if (text.Contains("haldor") || text.Contains("hildir")) { ((Vector3)(ref worldPos))..ctor(value2.m_position.x, 0f, value2.m_position.z); Vector2i region = VoronoiGrid.Instance.GetRegion(worldPos); if (region.x == gridPos.x && region.y == gridPos.y) { flag = true; break; } } } _merchantCache[gridPos] = flag; return flag; } public static Biome GetDominantBiome(Dictionary composition) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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) if (composition == null || composition.Count == 0) { return (Biome)1; } int num = 1; float num2 = 0f; foreach (KeyValuePair item in composition) { if (item.Value > num2) { num2 = item.Value; num = item.Key; } } return (Biome)num; } public static bool HasPointOfInterest(Vector2i gridPos) { //IL_0038: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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) if ((Object)(object)ZoneSystem.instance == (Object)null) { return false; } Vector3 worldPos = default(Vector3); foreach (KeyValuePair locationInstance in ZoneSystem.instance.m_locationInstances) { LocationInstance value = locationInstance.Value; if (value.m_location == null) { continue; } string prefabName = value.m_location.m_prefabName ?? ""; if (IsPOILocation(prefabName)) { ((Vector3)(ref worldPos))..ctor(value.m_position.x, 0f, value.m_position.z); Vector2i region = VoronoiGrid.Instance.GetRegion(worldPos); if (region.x == gridPos.x && region.y == gridPos.y) { return true; } } } return false; } private static bool IsPOILocation(string prefabName) { if (string.IsNullOrEmpty(prefabName)) { return false; } string text = prefabName.ToLower(); if (text.Contains("altar") || text.Contains("boss")) { return true; } if (text.Contains("haldor") || text.Contains("hildir")) { return true; } if (text.Contains("infectedmine") || text.Contains("sunkencrypt") || text.Contains("mountaincave") || text.Contains("goblinking")) { return true; } return false; } public static Color GetBiomeColor(Biome biome) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Invalid comparison between Unknown and I4 //IL_000a: 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) //IL_0022: Expected I4, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Invalid comparison between Unknown and I4 //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Invalid comparison between Unknown and I4 //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: 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_0026: Invalid comparison between Unknown and I4 //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Invalid comparison between Unknown and I4 //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Invalid comparison between Unknown and I4 //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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_0100: 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_012e: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Invalid comparison between Unknown and I4 //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) if (1 == 0) { } Color result; if ((int)biome <= 16) { switch (biome - 1) { case 0: goto IL_0070; case 1: goto IL_00a4; case 3: goto IL_00be; case 2: goto IL_0148; } if ((int)biome != 8) { if ((int)biome != 16) { goto IL_0148; } result = new Color(0.9f, 0.85f, 0.4f); } else { result = new Color(0.2f, 0.4f, 0.2f); } } else if ((int)biome <= 64) { if ((int)biome != 32) { if ((int)biome != 64) { goto IL_0148; } result = new Color(0.7f, 0.9f, 1f); } else { result = new Color(0.8f, 0.3f, 0.2f); } } else if ((int)biome != 256) { if ((int)biome != 512) { goto IL_0148; } result = new Color(0.5f, 0.3f, 0.6f); } else { result = new Color(0.2f, 0.4f, 0.8f); } goto IL_0150; IL_0148: result = Color.gray; goto IL_0150; IL_00be: result = new Color(0.8f, 0.8f, 0.9f); goto IL_0150; IL_0070: result = new Color(0.4f, 0.8f, 0.3f); goto IL_0150; IL_00a4: result = new Color(0.4f, 0.35f, 0.2f); goto IL_0150; IL_0150: if (1 == 0) { } return result; } public static string GetBiomeName(Biome biome) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 if (1 == 0) { } string result = (((int)biome == 8) ? "Black Forest" : (((int)biome == 32) ? "Ashlands" : (((int)biome != 64) ? ((object)(Biome)(ref biome)).ToString() : "Deep North"))); if (1 == 0) { } return result; } public static float GetBiomeTollMultiplier(Biome biome) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Invalid comparison between Unknown and I4 //IL_000a: 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) //IL_0022: Expected I4, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Invalid comparison between Unknown and I4 //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Invalid comparison between Unknown and I4 //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Invalid comparison between Unknown and I4 //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Invalid comparison between Unknown and I4 //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Invalid comparison between Unknown and I4 //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Invalid comparison between Unknown and I4 if (1 == 0) { } float result; if ((int)biome <= 16) { switch (biome - 1) { case 0: goto IL_0058; case 1: goto IL_0068; case 3: goto IL_0070; case 2: goto IL_00a0; } if ((int)biome != 8) { if ((int)biome != 16) { goto IL_00a0; } result = 3f; } else { result = 1.5f; } } else if ((int)biome <= 64) { if ((int)biome != 32) { if ((int)biome != 64) { goto IL_00a0; } result = 3f; } else { result = 5f; } } else if ((int)biome != 256) { if ((int)biome != 512) { goto IL_00a0; } result = 4f; } else { result = 0.5f; } goto IL_00a8; IL_00a0: result = 1f; goto IL_00a8; IL_0070: result = 2.5f; goto IL_00a8; IL_0058: result = 1f; goto IL_00a8; IL_0068: result = 2f; goto IL_00a8; IL_00a8: if (1 == 0) { } return result; } public static List GetObjectivesForBiome(Biome biome) { //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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Invalid comparison between Unknown and I4 //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected I4, but got Unknown //IL_014b: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_0111: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Invalid comparison between Unknown and I4 //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Invalid comparison between Unknown and I4 //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) List list = new List(); if ((int)biome <= 8) { switch (biome - 1) { case 0: goto IL_0056; case 1: goto IL_00c9; case 3: goto IL_0103; case 2: goto IL_01e4; } if ((int)biome != 8) { goto IL_01e4; } list.Add(new TerritoryObjective(ObjectiveType.KillMonsters, "Greydwarf", "Greydwarfs", 10, forUnlock: true, biome)); list.Add(new TerritoryObjective(ObjectiveType.KillMonsters, "Troll", "Trolls", 1, forUnlock: true, biome)); } else if ((int)biome != 16) { if ((int)biome != 32) { if ((int)biome != 512) { goto IL_01e4; } list.Add(new TerritoryObjective(ObjectiveType.KillMonsters, "Seeker", "Seekers", 10, forUnlock: true, biome)); list.Add(new TerritoryObjective(ObjectiveType.KillMonsters, "Gjall", "Gjalls", 1, forUnlock: true, biome)); } else { list.Add(new TerritoryObjective(ObjectiveType.KillMonsters, "Charred_Melee", "Charred Warriors", 15, forUnlock: true, biome)); list.Add(new TerritoryObjective(ObjectiveType.KillMonsters, "Morgen", "Morgens", 2, forUnlock: true, biome)); } } else { list.Add(new TerritoryObjective(ObjectiveType.KillMonsters, "Goblin", "Fulings", 10, forUnlock: true, biome)); list.Add(new TerritoryObjective(ObjectiveType.KillMonsters, "Lox", "Loxes", 2, forUnlock: true, biome)); } goto IL_0200; IL_0056: list.Add(new TerritoryObjective(ObjectiveType.KillMonsters, "Boar", "Boars", 5, forUnlock: true, biome)); list.Add(new TerritoryObjective(ObjectiveType.KillMonsters, "Neck", "Necks", 3, forUnlock: true, biome)); goto IL_0200; IL_01e4: list.Add(new TerritoryObjective(ObjectiveType.KillMonsters, "Greyling", "Greylings", 5, forUnlock: true, biome)); goto IL_0200; IL_0200: return list; IL_0103: list.Add(new TerritoryObjective(ObjectiveType.KillMonsters, "Wolf", "Wolves", 5, forUnlock: true, biome)); list.Add(new TerritoryObjective(ObjectiveType.KillMonsters, "Drake", "Drakes", 3, forUnlock: true, biome)); goto IL_0200; IL_00c9: list.Add(new TerritoryObjective(ObjectiveType.KillMonsters, "Draugr", "Draugrs", 10, forUnlock: true, biome)); list.Add(new TerritoryObjective(ObjectiveType.KillMonsters, "Blob", "Blobs", 5, forUnlock: true, biome)); goto IL_0200; } } public static class GridUtils { public static Vector2i WorldToGrid(Vector3 worldPos) { //IL_0006: 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_000c: 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) return VoronoiGrid.Instance.GetRegion(worldPos); } public static Vector2i WorldToVisualGrid(Vector3 worldPos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //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_000a: Unknown result type (might be due to invalid IL or missing references) return WorldToGrid(worldPos); } public static Vector3 GridToWorldCenter(Vector2i grid) { //IL_0006: 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_000c: 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) return VoronoiGrid.Instance.GetRegionCenter(grid); } public static Vector3 GridToWorld(Vector2i grid) { //IL_0006: 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_000c: 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) return VoronoiGrid.Instance.GetRegionCenter(grid); } public static int GridDistance(Vector2i a, Vector2i b) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //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_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) //IL_0010: Unknown result type (might be due to invalid IL or missing references) Vector3 val = GridToWorldCenter(a); Vector3 val2 = GridToWorldCenter(b); float num = Vector3.Distance(val, val2); return Mathf.RoundToInt(num / 100f); } public static bool IsWithinMapBounds(Vector2i grid) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0024: 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_0031: Unknown result type (might be due to invalid IL or missing references) float num = LandlordConfig.WorldRadius?.Value ?? 10500f; Vector3 val = GridToWorldCenter(grid); float num2 = Mathf.Sqrt(val.x * val.x + val.z * val.z); return num2 < num; } public static bool IsInSpawnProtection(Vector2i grid) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_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_002d: 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_003a: Unknown result type (might be due to invalid IL or missing references) if (VoronoiGrid.Instance.IsSpawnZone(grid)) { return true; } float value = LandlordConfig.SpawnProtectionRadius.Value; Vector3 val = GridToWorldCenter(grid); float num = Mathf.Sqrt(val.x * val.x + val.z * val.z); return num <= value; } public static bool IsInSpawnProtection(Vector3 worldPos) { //IL_000c: 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_0019: 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) float value = LandlordConfig.SpawnProtectionRadius.Value; float num = Mathf.Sqrt(worldPos.x * worldPos.x + worldPos.z * worldPos.z); return num <= value; } public static bool GridCellOverlapsSpawnProtection(Vector2i grid) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return IsInSpawnProtection(grid); } public static int CalculateTollForCell(Vector2i grid) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) if (IsInSpawnProtection(grid)) { return 0; } Dictionary dictionary = BiomeUtils.SampleBiomeComposition(grid); float num = 0f; foreach (KeyValuePair item in dictionary) { int biomeToll = LandlordConfig.GetBiomeToll((Biome)item.Key); num += (float)biomeToll * (item.Value / 100f); } int num2 = Mathf.Max(1, (int)Math.Ceiling(num)); float approximateRegionRadius = VoronoiGrid.Instance.GetApproximateRegionRadius(grid); float num3 = Mathf.Clamp(approximateRegionRadius / 500f, 0.3f, 3f); num2 = Mathf.Max(1, (int)((float)num2 * num3)); if (CellHasMerchant(grid)) { num2 *= 2; } return num2; } public static bool CellHasMerchant(Vector2i grid) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return BiomeUtils.CellHasMerchant(grid); } public static int GetClaimCost(Vector2i grid) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Invalid comparison between Unknown and I4 //IL_001a: 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_0032: Expected I4, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Invalid comparison between Unknown and I4 //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Invalid comparison between Unknown and I4 //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Invalid comparison between Unknown and I4 //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Invalid comparison between Unknown and I4 //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Invalid comparison between Unknown and I4 //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: 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_003d: Invalid comparison between Unknown and I4 Dictionary composition = BiomeUtils.SampleBiomeComposition(grid); Biome dominantBiome = BiomeUtils.GetDominantBiome(composition); if (1 == 0) { } int num; if ((int)dominantBiome <= 16) { switch (dominantBiome - 1) { case 0: goto IL_0068; case 1: goto IL_007a; case 3: goto IL_0083; case 2: goto IL_00b9; } if ((int)dominantBiome != 8) { if ((int)dominantBiome != 16) { goto IL_00b9; } num = 6000; } else { num = 3000; } } else if ((int)dominantBiome <= 64) { if ((int)dominantBiome != 32) { if ((int)dominantBiome != 64) { goto IL_00b9; } num = 10000; } else { num = 9000; } } else if ((int)dominantBiome != 256) { if ((int)dominantBiome != 512) { goto IL_00b9; } num = 7000; } else { num = 2000; } goto IL_00c2; IL_00b9: num = 2000; goto IL_00c2; IL_0083: num = 5000; goto IL_00c2; IL_0068: num = 2000; goto IL_00c2; IL_007a: num = 4000; goto IL_00c2; IL_00c2: if (1 == 0) { } int num2 = num; float approximateRegionRadius = VoronoiGrid.Instance.GetApproximateRegionRadius(grid); float num3 = 500f; float num4 = Mathf.Clamp(approximateRegionRadius / num3, 0.3f, 3f); num2 = (int)((float)num2 * num4); if (CellHasMerchant(grid)) { num2 *= 2; } return num2; } public static string GetBiomeCompositionString(Vector2i grid) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Dictionary dictionary = BiomeUtils.SampleBiomeComposition(grid); if (dictionary == null || dictionary.Count == 0) { return "Unknown"; } return TerritoryNaming.GetBiomeCompositionDescription(dictionary); } public static string GetTerritoryName(Vector2i grid) { //IL_0001: 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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) Dictionary biomeComposition = BiomeUtils.SampleBiomeComposition(grid); bool hasMerchant = CellHasMerchant(grid); bool hasBossAltar = BiomeUtils.HasPointOfInterest(grid); return TerritoryNaming.GenerateTerritoryName(grid, biomeComposition, hasMerchant, hasBossAltar); } } public static class TerritoryNaming { private static readonly string[] NorthPrefixes = new string[5] { "Norðri", "Northern", "Frost", "Winter's", "Boreal" }; private static readonly string[] SouthPrefixes = new string[5] { "Suðri", "Southern", "Sun's", "Warm", "Golden" }; private static readonly string[] EastPrefixes = new string[5] { "Austri", "Eastern", "Dawn", "Rising", "Morning" }; private static readonly string[] WestPrefixes = new string[5] { "Vestri", "Western", "Twilight", "Setting", "Dusk" }; private static readonly string[] CenterPrefixes = new string[5] { "Miðgarð", "Central", "Heart of", "Ancient", "Old" }; private static readonly Dictionary BiomeNames = new Dictionary { { (Biome)1, new string[8] { "Meadow", "Grassland", "Green Vale", "Peaceful Fields", "Idavoll", "Folkvangr", "Verdant Lea", "Shepherd's Rest" } }, { (Biome)8, new string[8] { "Dark Woods", "Eerie Forest", "Shadow Grove", "Myrkviðr", "Ironwood", "Troll's Domain", "Whispering Pines", "Draugr's Reach" } }, { (Biome)2, new string[8] { "Murky Fen", "Poison Marsh", "Dead Man's Bog", "Hel's Mire", "Rotting Wetlands", "Drowned Vale", "Festering Swamp", "Corpse Marsh" } }, { (Biome)4, new string[8] { "Frost Peak", "Stone Heights", "Jötunheimr", "Eagle's Nest", "Ice Crown", "Thunder Summit", "Goat's Path", "Windswept Ridge" } }, { (Biome)16, new string[8] { "Golden Plains", "Fuling Lands", "Scorched Fields", "Barren Reach", "Vigriðr", "Blood Prairie", "Deathstalker's Domain", "Sun-bleached Expanse" } }, { (Biome)512, new string[8] { "Shrouded Vale", "Spider's Web", "Mist Hollow", "Gjöll", "Veiled Ruins", "Ancient's Rest", "Forgotten Realm", "Skuld's Domain" } }, { (Biome)32, new string[8] { "Scorched Waste", "Múspellheim", "Ember Fields", "Burning Reach", "Cinder Vale", "Charred Domain", "Flame's Edge", "Surt's Realm" } }, { (Biome)64, new string[8] { "Frozen Waste", "Niflheim", "Eternal Ice", "Frost Giant's Land", "Glacial Expanse", "Winter's End", "Permafrost Domain", "Hrimfaxi's Path" } }, { (Biome)256, new string[8] { "Ægir's Domain", "Depths", "Serpent's Sea", "Njord's Waters", "Kraken's Reach", "Wayward Waves", "Storm Channel", "Ran's Grasp" } } }; private static readonly string[] MixedSuffixes = new string[6] { "Borderlands", "Frontier", "Crossroads", "Threshold", "Edge", "Marches" }; private static readonly string[] MerchantModifiers = new string[4] { "Market", "Trade Post", "Merchant's Haven", "Trader's Rest" }; private static readonly string[] BossModifiers = new string[4] { "Altar", "Sacred Ground", "Ritual Site", "Offering Place" }; public static string GenerateTerritoryName(Vector2i gridPos, Dictionary biomeComposition, bool hasMerchant = false, bool hasBossAltar = false) { //IL_003d: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_0095: Unknown result type (might be due to invalid IL or missing references) //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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) if (biomeComposition == null || biomeComposition.Count == 0) { return $"Unknown Land ({gridPos.x}, {gridPos.y})"; } int seed = gridPos.x * 10000 + gridPos.y; Random random = new Random(seed); Biome dominantBiome = GetDominantBiome(biomeComposition); float biomePercent = GetBiomePercent(biomeComposition, dominantBiome); string directionalPrefix = GetDirectionalPrefix(gridPos, random); string text = GetBiomeName(dominantBiome, random); if (biomePercent < 70f && biomeComposition.Count > 1) { Biome secondaryBiome = GetSecondaryBiome(biomeComposition, dominantBiome); if (secondaryBiome != dominantBiome) { string text2 = MixedSuffixes[random.Next(MixedSuffixes.Length)]; text = GetShortBiomeName(dominantBiome) + "-" + GetShortBiomeName(secondaryBiome) + " " + text2; } } if (hasMerchant) { string text3 = MerchantModifiers[random.Next(MerchantModifiers.Length)]; return directionalPrefix + " " + text3; } if (hasBossAltar) { string text4 = BossModifiers[random.Next(BossModifiers.Length)]; return text + " " + text4; } return directionalPrefix + " " + text; } public static string GetSimpleName(Vector2i gridPos, Dictionary biomeComposition) { //IL_001d: 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_0039: 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_003f: Unknown result type (might be due to invalid IL or missing references) if (biomeComposition == null || biomeComposition.Count == 0) { return "Unknown"; } int seed = gridPos.x * 10000 + gridPos.y; Random rng = new Random(seed); Biome dominantBiome = GetDominantBiome(biomeComposition); return GetBiomeName(dominantBiome, rng); } private static string GetDirectionalPrefix(Vector2i gridPos, Random rng) { //IL_0006: 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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) Vector3 regionCenter = VoronoiGrid.Instance.GetRegionCenter(gridPos); float x = regionCenter.x; float z = regionCenter.z; float num = Mathf.Sqrt(x * x + z * z); if (num < 2000f) { return CenterPrefixes[rng.Next(CenterPrefixes.Length)]; } float num2 = Mathf.Atan2(z, x) * 57.29578f; if (num2 >= 45f && num2 < 135f) { return NorthPrefixes[rng.Next(NorthPrefixes.Length)]; } if (num2 >= -45f && num2 < 45f) { return EastPrefixes[rng.Next(EastPrefixes.Length)]; } if (num2 >= -135f && num2 < -45f) { return SouthPrefixes[rng.Next(SouthPrefixes.Length)]; } return WestPrefixes[rng.Next(WestPrefixes.Length)]; } private static string GetBiomeName(Biome biome, Random rng) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (BiomeNames.TryGetValue(biome, out var value)) { return value[rng.Next(value.Length)]; } return ((object)(Biome)(ref biome)).ToString(); } private static string GetShortBiomeName(Biome biome) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Invalid comparison between Unknown and I4 //IL_000a: 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) //IL_0022: Expected I4, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Invalid comparison between Unknown and I4 //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Invalid comparison between Unknown and I4 //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Invalid comparison between Unknown and I4 //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Invalid comparison between Unknown and I4 //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Invalid comparison between Unknown and I4 //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Invalid comparison between Unknown and I4 if (1 == 0) { } string result; if ((int)biome <= 16) { switch (biome - 1) { case 0: goto IL_0058; case 1: goto IL_0068; case 3: goto IL_0070; case 2: goto IL_00a0; } if ((int)biome != 8) { if ((int)biome != 16) { goto IL_00a0; } result = "Plains"; } else { result = "Forest"; } } else if ((int)biome <= 64) { if ((int)biome != 32) { if ((int)biome != 64) { goto IL_00a0; } result = "Frost"; } else { result = "Ash"; } } else if ((int)biome != 256) { if ((int)biome != 512) { goto IL_00a0; } result = "Mist"; } else { result = "Sea"; } goto IL_00b0; IL_00a0: result = ((object)(Biome)(ref biome)).ToString(); goto IL_00b0; IL_0070: result = "Mountain"; goto IL_00b0; IL_0058: result = "Meadow"; goto IL_00b0; IL_0068: result = "Swamp"; goto IL_00b0; IL_00b0: if (1 == 0) { } return result; } private static Biome GetDominantBiome(Dictionary composition) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) int num = 1; float num2 = 0f; foreach (KeyValuePair item in composition) { if (item.Value > num2) { num2 = item.Value; num = item.Key; } } return (Biome)num; } private static Biome GetSecondaryBiome(Dictionary composition, Biome exclude) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Expected I4, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between I4 and Unknown //IL_0067: 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) int num = (int)exclude; float num2 = 0f; foreach (KeyValuePair item in composition) { if (item.Key != (int)exclude && item.Value > num2) { num2 = item.Value; num = item.Key; } } return (Biome)num; } private static float GetBiomePercent(Dictionary composition, Biome biome) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected I4, but got Unknown float value; return composition.TryGetValue((int)biome, out value) ? value : 0f; } public static string GetBiomeCompositionDescription(Dictionary composition) { if (composition == null || composition.Count == 0) { return "Unknown terrain"; } List list = new List(); List> list2 = new List>(composition); list2.Sort((KeyValuePair a, KeyValuePair b) => b.Value.CompareTo(a.Value)); foreach (KeyValuePair item in list2) { if (item.Value >= 5f) { string biomeName = BiomeUtils.GetBiomeName((Biome)item.Key); list.Add($"{biomeName} {item.Value:F0}%"); } } return string.Join(", ", list); } } public static class Utils { public static string GetSaveDataPath() { return Application.persistentDataPath; } public static string GetPrefabName(GameObject obj) { if ((Object)(object)obj == (Object)null) { return ""; } string text = ((Object)obj).name; int num = text.IndexOf("(Clone)"); if (num > 0) { text = text.Substring(0, num); } return text.Trim(); } public static string FormatNumber(int number) { if (number >= 1000000) { return $"{(float)number / 1000000f:F1}M"; } if (number >= 1000) { return $"{(float)number / 1000f:F1}K"; } return number.ToString(); } public static string FormatCoins(int amount) { return $"{amount} coins"; } public static bool IsDedicatedServer() { ZNet instance = ZNet.instance; return instance != null && instance.IsDedicated(); } public static bool IsServer() { ZNet instance = ZNet.instance; return instance != null && instance.IsServer(); } public static long GetLocalPlayerId() { Player localPlayer = Player.m_localPlayer; return (localPlayer != null) ? localPlayer.GetPlayerID() : 0; } public static string GetLocalPlayerName() { Player localPlayer = Player.m_localPlayer; return ((localPlayer != null) ? localPlayer.GetPlayerName() : null) ?? "Unknown"; } public static int ParseInt(string value, int defaultValue = 0) { int result; return int.TryParse(value, out result) ? result : defaultValue; } public static Color LerpColor(Color a, Color b, float t) { //IL_0001: 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_0013: 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_0025: 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_003d: 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) //IL_0051: Unknown result type (might be due to invalid IL or missing references) return new Color(Mathf.Lerp(a.r, b.r, t), Mathf.Lerp(a.g, b.g, t), Mathf.Lerp(a.b, b.b, t), Mathf.Lerp(a.a, b.a, t)); } } public class VoronoiGrid { private static VoronoiGrid _instance; private static readonly object _lock = new object(); private List _seeds; private Dictionary _quantizedToIndex; private Dictionary> _spatialGrid; private const float SpatialCellSize = 2000f; private Dictionary _regionCache; private const float CacheQuantize = 8f; private float MapRadius = 10500f; private float _spawnProtectionRadius; public static VoronoiGrid Instance { get { if (_instance == null) { lock (_lock) { if (_instance == null) { _instance = new VoronoiGrid(); } } } return _instance; } } public bool IsInitialized { get; private set; } public int SpawnZoneSeedIndex => 0; public int RegionCount { get { EnsureInitialized(); return _seeds.Count; } } public static void Reset() { lock (_lock) { _instance = null; } } private VoronoiGrid() { _seeds = new List(); _quantizedToIndex = new Dictionary(); _spatialGrid = new Dictionary>(); _regionCache = new Dictionary(); IsInitialized = false; } public void Initialize(string worldName) { if (!IsInitialized) { _spawnProtectionRadius = LandlordConfig.SpawnProtectionRadius.Value; MapRadius = LandlordConfig.WorldRadius?.Value ?? 10500f; int num = LandlordConfig.TerritoryCount?.Value ?? 180; int num2 = worldName?.GetHashCode() ?? 0; Plugin.Log.LogWarning((object)$"VoronoiGrid: MapRadius={MapRadius}, TerritoryCount={num}, SpawnProtection={_spawnProtectionRadius}, WorldSeed={num2}"); GenerateSeeds(num2, num); BuildSpatialGrid(); BuildQuantizedIndex(); IsInitialized = true; Plugin.Log.LogWarning((object)$"VoronoiGrid initialized with {_seeds.Count} regions for world '{worldName}' (radius={MapRadius})"); } } public void EnsureInitialized() { if (!IsInitialized) { string text = null; if ((Object)(object)ZNet.instance != (Object)null) { text = ZNet.instance.GetWorldName(); } if (string.IsNullOrEmpty(text)) { text = "default_world"; } Initialize(text); } } private void GenerateSeeds(int worldSeed, int targetCount) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0147: 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_0278: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) _seeds.Clear(); Random random = new Random(worldSeed); _seeds.Add(new Vector2(0f, 0f)); float num = MapRadius * 2f / Mathf.Sqrt((float)targetCount) * 0.6f; int num2 = targetCount * 80; int num3 = 0; while (_seeds.Count < targetCount && num3 < num2) { num3++; float num4 = (float)(random.NextDouble() * 2.0 * Math.PI); float num5 = (float)Math.Sqrt(random.NextDouble()) * (MapRadius - 200f); float num6 = num5 * Mathf.Cos(num4); float num7 = num5 * Mathf.Sin(num4); if (num6 * num6 + num7 * num7 < _spawnProtectionRadius * _spawnProtectionRadius) { continue; } float num8 = Mathf.Sqrt(num6 * num6 + num7 * num7); float num9 = num8 / MapRadius; float num10 = 0.3f + num9 * 1.5f; float num11 = 0.7f + (float)random.NextDouble() * 0.6f; float num12 = num10 * num11; float num13 = num * num12; bool flag = false; for (int i = 0; i < _seeds.Count; i++) { float num14 = _seeds[i].x - num6; float num15 = _seeds[i].y - num7; if (num14 * num14 + num15 * num15 < num13 * num13) { flag = true; break; } } if (!flag) { _seeds.Add(new Vector2(num6, num7)); } } float num16 = num * 0.4f; float[] array = new float[3] { MapRadius * 0.7f, MapRadius * 0.82f, MapRadius * 0.93f }; int num17 = 45; for (int j = 0; j < array.Length; j++) { float num18 = array[j]; float num19 = (float)j * 0.5f; for (int k = 0; k < num17; k++) { float num20 = ((float)k + num19) / (float)num17 * (float)Math.PI * 2f; float num21 = num18 * Mathf.Cos(num20); float num22 = num18 * Mathf.Sin(num20); bool flag2 = false; for (int l = 0; l < _seeds.Count; l++) { float num23 = _seeds[l].x - num21; float num24 = _seeds[l].y - num22; if (num23 * num23 + num24 * num24 < num16 * num16) { flag2 = true; break; } } if (!flag2) { _seeds.Add(new Vector2(num21, num22)); } } } for (int m = 0; m < 3; m++) { LloydRelaxation(); } Plugin.Log.LogInfo((object)$"Generated {_seeds.Count} Voronoi seeds (target: {targetCount}, attempts: {num3})"); } private void LloydRelaxation() { //IL_01ae: Unknown result type (might be due to invalid IL or missing references) int num = 80; float num2 = MapRadius * 2f / (float)num; float[] array = new float[_seeds.Count]; float[] array2 = new float[_seeds.Count]; int[] array3 = new int[_seeds.Count]; for (int i = 0; i < num; i++) { for (int j = 0; j < num; j++) { float num3 = 0f - MapRadius + ((float)i + 0.5f) * num2; float num4 = 0f - MapRadius + ((float)j + 0.5f) * num2; if (!(num3 * num3 + num4 * num4 > MapRadius * MapRadius)) { int num5 = FindNearestSeedBruteForce(num3, num4); if (num5 >= 0) { array[num5] += num3; array2[num5] += num4; array3[num5]++; } } } } for (int k = 0; k < _seeds.Count; k++) { if (k != SpawnZoneSeedIndex && array3[k] > 0) { float num6 = array[k] / (float)array3[k]; float num7 = array2[k] / (float)array3[k]; if (num6 * num6 + num7 * num7 >= _spawnProtectionRadius * _spawnProtectionRadius && num6 * num6 + num7 * num7 < MapRadius * MapRadius) { _seeds[k] = new Vector2(num6, num7); } } } } private float SmoothNoise(float x, float z, int seed) { int num = Mathf.FloorToInt(x); int num2 = Mathf.FloorToInt(z); float num3 = x - (float)num; float num4 = z - (float)num2; num3 = num3 * num3 * (3f - 2f * num3); num4 = num4 * num4 * (3f - 2f * num4); float num5 = HashFloat(num, num2, seed); float num6 = HashFloat(num + 1, num2, seed); float num7 = HashFloat(num, num2 + 1, seed); float num8 = HashFloat(num + 1, num2 + 1, seed); float num9 = num5 + (num6 - num5) * num3; float num10 = num7 + (num8 - num7) * num3; return num9 + (num10 - num9) * num4; } private float HashFloat(int x, int z, int seed) { int num = x * 374761393 + z * 668265263 + seed * 1274126177; num = (num ^ (num >> 13)) * 1103515245; num ^= num >> 16; return (float)(num & 0x7FFFFFFF) / 2.1474836E+09f; } private float PerturbedDistanceSq(float x, float z, int seedIndex) { //IL_0008: 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) float num = _seeds[seedIndex].x - x; float num2 = _seeds[seedIndex].y - z; float num3 = Mathf.Sqrt(num * num + num2 * num2); float num4 = (float)seedIndex * 73.7f; float num5 = (float)seedIndex * 91.3f; float num6 = 0f; num6 += (Mathf.PerlinNoise((x + num4) * 0.006f, (z + num5) * 0.006f) - 0.5f) * 2f; num6 += (Mathf.PerlinNoise((x + num4) * 0.015f, (z + num5) * 0.015f) - 0.5f) * 1f; num6 += (Mathf.PerlinNoise((x + num4) * 0.03f, (z + num5) * 0.03f) - 0.5f) * 0.5f; num6 += (Mathf.PerlinNoise((x + num4) * 0.06f, (z + num5) * 0.06f) - 0.5f) * 0.25f; float num7 = num3 + num6 * 80f; return num7 * num7; } private int FindNearestSeedBruteForce(float x, float z) { int result = -1; float num = float.MaxValue; for (int i = 0; i < _seeds.Count; i++) { float num2 = PerturbedDistanceSq(x, z, i); if (num2 < num) { num = num2; result = i; } } return result; } private void BuildSpatialGrid() { //IL_001a: 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) _spatialGrid.Clear(); for (int i = 0; i < _seeds.Count; i++) { long key = SpatialKey(_seeds[i].x, _seeds[i].y); if (!_spatialGrid.TryGetValue(key, out var value)) { value = new List(); _spatialGrid[key] = value; } value.Add(i); } } private long SpatialKey(float x, float z) { int num = Mathf.FloorToInt(x / 2000f); int num2 = Mathf.FloorToInt(z / 2000f); return ((long)num << 32) | (uint)num2; } private void BuildQuantizedIndex() { //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) //IL_001a: 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) _quantizedToIndex.Clear(); for (int i = 0; i < _seeds.Count; i++) { Vector2i val = QuantizeSeed(i); long key = ((long)val.x << 32) | (uint)val.y; _quantizedToIndex[key] = i; } } private Vector2i QuantizeSeed(int index) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) Vector2 val = _seeds[index]; int num = Mathf.RoundToInt(val.x / 10f); int num2 = Mathf.RoundToInt(val.y / 10f); return new Vector2i(num, num2); } public Vector2i GetRegion(Vector3 worldPos) { //IL_0009: 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) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_002f: 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_007a: 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_0082: 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) EnsureInitialized(); long key = CacheKey(worldPos.x, worldPos.z); if (_regionCache.TryGetValue(key, out var value)) { return value; } int index = FindNearestSeed(worldPos.x, worldPos.z); Vector2i val = QuantizeSeed(index); if (_regionCache.Count > 500000) { _regionCache.Clear(); } _regionCache[key] = val; return val; } public Vector3 GetRegionCenter(Vector2i regionId) { //IL_0009: 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) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_0036: 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_0042: 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_0077: Unknown result type (might be due to invalid IL or missing references) EnsureInitialized(); int num = RegionIdToIndex(regionId); if (num >= 0 && num < _seeds.Count) { Vector2 val = _seeds[num]; return new Vector3(val.x, 0f, val.y); } return new Vector3((float)regionId.x * 10f, 0f, (float)regionId.y * 10f); } public bool IsSpawnZone(Vector2i regionId) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) int num = RegionIdToIndex(regionId); return num == SpawnZoneSeedIndex; } public string GetRegionKey(Vector2i regionId) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) return $"{regionId.x}_{regionId.y}"; } public bool IsOnBorder(Vector3 worldPos, float threshold = 80f) { //IL_0008: 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) //IL_009e: 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) EnsureInitialized(); float x = worldPos.x; float z = worldPos.z; int num = -1; int num2 = -1; float num3 = float.MaxValue; float num4 = float.MaxValue; int num5 = Mathf.FloorToInt(x / 2000f); int num6 = Mathf.FloorToInt(z / 2000f); for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { long key = ((long)(num5 + i) << 32) | (uint)(num6 + j); if (!_spatialGrid.TryGetValue(key, out var value)) { continue; } for (int k = 0; k < value.Count; k++) { int num7 = value[k]; float num8 = _seeds[num7].x - x; float num9 = _seeds[num7].y - z; float num10 = num8 * num8 + num9 * num9; if (num10 < num3) { num4 = num3; num2 = num; num3 = num10; num = num7; } else if (num10 < num4) { num4 = num10; num2 = num7; } } } } if (num < 0 || num2 < 0) { return false; } float num11 = Mathf.Sqrt(num3); float num12 = Mathf.Sqrt(num4); return num12 - num11 < threshold; } public float GetApproximateRegionRadius(Vector2i regionId) { //IL_0009: 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_0030: 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_005c: 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) //IL_0077: Unknown result type (might be due to invalid IL or missing references) EnsureInitialized(); int num = RegionIdToIndex(regionId); if (num < 0) { return 500f; } Vector2 val = _seeds[num]; float num2 = float.MaxValue; for (int i = 0; i < _seeds.Count; i++) { if (i != num) { float num3 = _seeds[i].x - val.x; float num4 = _seeds[i].y - val.y; float num5 = num3 * num3 + num4 * num4; if (num5 < num2) { num2 = num5; } } } return Mathf.Sqrt(num2) * 0.5f; } public IReadOnlyList GetAllSeeds() { EnsureInitialized(); return _seeds; } public int RegionIdToIndex(Vector2i regionId) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) long key = ((long)regionId.x << 32) | (uint)regionId.y; if (_quantizedToIndex.TryGetValue(key, out var value)) { return value; } return -1; } public Vector2i IndexToRegionId(int index) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0031: Unknown result type (might be due to invalid IL or missing references) if (index < 0 || index >= _seeds.Count) { return new Vector2i(0, 0); } return QuantizeSeed(index); } private int FindNearestSeed(float x, float z) { int num = -1; float num2 = float.MaxValue; int num3 = Mathf.FloorToInt(x / 2000f); int num4 = Mathf.FloorToInt(z / 2000f); for (int i = -2; i <= 2; i++) { for (int j = -2; j <= 2; j++) { long key = ((long)(num3 + i) << 32) | (uint)(num4 + j); if (!_spatialGrid.TryGetValue(key, out var value)) { continue; } for (int k = 0; k < value.Count; k++) { int num5 = value[k]; float num6 = PerturbedDistanceSq(x, z, num5); if (num6 < num2) { num2 = num6; num = num5; } } } } if (num < 0) { num = FindNearestSeedBruteForce(x, z); } return num; } private long CacheKey(float x, float z) { int num = Mathf.FloorToInt(x / 8f); int num2 = Mathf.FloorToInt(z / 8f); return ((long)num << 32) | (uint)num2; } } } namespace FreyjaLandlord.UI { public class LandlordHUD : MonoBehaviour { private bool _isVisible = false; private int _currentTab = 0; private readonly string[] _tabNames = new string[7] { "Overview", "Your Land", "Leaderboard", "Vassals", "Auctions", "Raid Log", "?" }; private Vector2 _scrollPos = Vector2.zero; private Dictionary _renameInputs = new Dictionary(); private string _renamingTerritoryKey = null; private bool _isRaiding = false; private float _raidTimer = 0f; private float _raidDuration = 0f; private int _raidKeyType = -1; private Vector2i _raidTerritory; private List _raidResults = null; private bool _raidSuccess = false; private string _raidSuccessMessage = null; private int _raidSelectedKey = -1; private GameObject _raidVfxInstance = null; private Vector2 _raidResultsScroll = Vector2.zero; private float _raidNotifyTimer = 0f; private Vector2 _raidLogScroll = Vector2.zero; private int _raidFlickerIndex = -1; private float _raidFlickerTimer = 0f; private static int _highlightVaultIndex = -1; private bool _showRaidWindow = false; private Territory _raidTargetTerritory = null; private Rect _raidWindowRect = new Rect(100f, 100f, 450f, 500f); private int _raidWindowId; private static readonly string[] KeyNames = new string[3] { "Bronze", "Silver", "Gold" }; private static readonly Color[] KeyColors = (Color[])(object)new Color[3] { new Color(0.8f, 0.5f, 0.2f), new Color(0.75f, 0.75f, 0.8f), new Color(1f, 0.85f, 0.4f) }; private GUIStyle _windowStyle; private GUIStyle _headerStyle; private GUIStyle _tabStyle; private GUIStyle _tabActiveStyle; private GUIStyle _labelStyle; private GUIStyle _labelGoldStyle; private GUIStyle _labelGreenStyle; private GUIStyle _labelRedStyle; private GUIStyle _buttonStyle; private GUIStyle _boxStyle; private GUIStyle _scrollStyle; private Texture2D _pixelTex; private Texture2D _panelBg; private bool _stylesInit = false; private Font _valheimFont; private bool _fontLoaded = false; private Rect _windowRect; private int _windowId; private VaultItem _vaultHoverItem = null; private Vector2 _vaultHoverPos; private bool _rentTooltipActive = false; private Vector2 _rentTooltipPos; private Dictionary _spriteCache = new Dictionary(); private bool _spriteCacheBuilt = false; public static LandlordHUD Instance { get; private set; } public bool IsVisible => _isVisible; private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)this); return; } Instance = this; _windowId = ((Object)this).GetInstanceID(); _raidWindowId = _windowId + 1; } private void Start() { //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) _windowRect = new Rect((float)((Screen.width - 800) / 2), (float)(Screen.height - 470), 800f, 450f); LoadValheimFont(); } private void Update() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Unknown result type (might be due to invalid IL or missing references) if (Input.GetKeyDown(LandlordConfig.HUDToggleKey.Value)) { _isVisible = !_isVisible; if (_isVisible) { ((Rect)(ref _windowRect)).x = ((float)Screen.width - ((Rect)(ref _windowRect)).width) / 2f; ((Rect)(ref _windowRect)).y = (float)Screen.height - ((Rect)(ref _windowRect)).height - 20f; } } if (Input.GetKeyDown((KeyCode)27)) { if (_showRaidWindow && !_isRaiding) { _showRaidWindow = false; _isVisible = true; } else if (_isRaiding) { _isRaiding = false; _raidTimer = 0f; _raidKeyType = -1; _raidSelectedKey = -1; _showRaidWindow = false; _isVisible = true; if ((Object)(object)_raidVfxInstance != (Object)null) { Object.Destroy((Object)(object)_raidVfxInstance); _raidVfxInstance = null; } MessageHud instance = MessageHud.instance; if (instance != null) { instance.ShowMessage((MessageType)1, "Raid cancelled! Key wasted.", 0, (Sprite)null, false); } } else if (_isVisible) { _isVisible = false; } } if (_showRaidWindow && _raidTargetTerritory != null && (Object)(object)Player.m_localPlayer != (Object)null) { Vector2i val = GridUtils.WorldToVisualGrid(((Component)Player.m_localPlayer).transform.position); if ((val.x != _raidTargetTerritory.GridX || val.y != _raidTargetTerritory.GridY) && !_isRaiding) { _showRaidWindow = false; _raidTargetTerritory = null; } } if (_isRaiding) { _raidTimer -= Time.deltaTime; _raidNotifyTimer -= Time.deltaTime; _raidFlickerTimer -= Time.deltaTime; if (_raidFlickerTimer <= 0f) { _raidFlickerTimer = 0.15f; int valueOrDefault = ((TerritoryManager.Instance?.Data?.GetTerritory(_raidTerritory))?.Vault?.Count).GetValueOrDefault(); _raidFlickerIndex = ((valueOrDefault > 0) ? Random.Range(0, valueOrDefault) : (-1)); } if (_raidNotifyTimer <= 0f) { _raidNotifyTimer = 10f; Player localPlayer = Player.m_localPlayer; string arg = ((localPlayer != null) ? localPlayer.GetPlayerName() : null) ?? "Someone"; string arg2 = (TerritoryManager.Instance?.Data?.GetTerritory(_raidTerritory))?.OwnerName ?? "Unknown"; string message = $"{arg} is raiding {arg2}'s Vault! ({Mathf.CeilToInt(_raidTimer)}s remaining)"; LandlordRPC.Instance?.BroadcastGlobalMessage(message); } if ((Object)(object)_raidVfxInstance == (Object)null && (Object)(object)Player.m_localPlayer != (Object)null) { try { ZNetScene instance2 = ZNetScene.instance; object obj = ((instance2 != null) ? instance2.GetPrefab("vfx_Potion_health_medium") : null); if (obj == null) { ZNetScene instance3 = ZNetScene.instance; obj = ((instance3 != null) ? instance3.GetPrefab("vfx_FireAddFuel") : null); } GameObject val2 = (GameObject)obj; if ((Object)(object)val2 != (Object)null) { _raidVfxInstance = Object.Instantiate(val2, ((Component)Player.m_localPlayer).transform.position, Quaternion.identity, ((Component)Player.m_localPlayer).transform); } } catch { } } if (_raidTimer <= 0f) { ProcessRaidResult(); } } if (_isVisible) { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; if (ZInput.instance != null) { ZInput.ResetButtonStatus("Attack"); ZInput.ResetButtonStatus("SecondaryAttack"); ZInput.ResetButtonStatus("Block"); ZInput.ResetButtonStatus("Use"); ZInput.ResetButtonStatus("Jump"); } } } private void LateUpdate() { if (_isVisible) { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } } private void LoadValheimFont() { try { Font[] array = Resources.FindObjectsOfTypeAll(); Font[] array2 = array; foreach (Font val in array2) { string text = ((Object)val).name.ToLower(); if (text.Contains("norse") || text.Contains("averia") || text.Contains("valheim")) { _valheimFont = val; _fontLoaded = true; Plugin.Log.LogDebug((object)("Loaded Valheim font: " + ((Object)val).name)); break; } } } catch (Exception ex) { Plugin.Log.LogDebug((object)("Could not load Valheim font: " + ex.Message)); } } private void InitStyles() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected O, but got Unknown //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Expected O, but got Unknown //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Expected O, but got Unknown //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Expected O, but got Unknown //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0259: 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_0295: Expected O, but got Unknown //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Expected O, but got Unknown //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Expected O, but got Unknown //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Expected O, but got Unknown //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Expected O, but got Unknown //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Expected O, but got Unknown //IL_03d9: Unknown result type (might be due to invalid IL or missing references) //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_0410: Expected O, but got Unknown //IL_042a: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Expected O, but got Unknown //IL_046d: Unknown result type (might be due to invalid IL or missing references) //IL_0490: Unknown result type (might be due to invalid IL or missing references) //IL_049a: Expected O, but got Unknown //IL_0508: Unknown result type (might be due to invalid IL or missing references) //IL_051e: Unknown result type (might be due to invalid IL or missing references) //IL_0550: Unknown result type (might be due to invalid IL or missing references) //IL_055a: Expected O, but got Unknown //IL_0565: Unknown result type (might be due to invalid IL or missing references) //IL_056f: Expected O, but got Unknown //IL_0599: Unknown result type (might be due to invalid IL or missing references) //IL_05a3: Expected O, but got Unknown //IL_05ca: Unknown result type (might be due to invalid IL or missing references) //IL_05d4: Expected O, but got Unknown //IL_05df: Unknown result type (might be due to invalid IL or missing references) //IL_05e9: Expected O, but got Unknown //IL_05f5: Unknown result type (might be due to invalid IL or missing references) //IL_05ff: Expected O, but got Unknown if (!_stylesInit) { _pixelTex = new Texture2D(1, 1); _pixelTex.SetPixel(0, 0, Color.white); _pixelTex.Apply(); _panelBg = CreatePanelTexture(64, 64); _windowStyle = new GUIStyle(GUI.skin.window); _windowStyle.normal.background = _panelBg; _windowStyle.onNormal.background = _panelBg; _windowStyle.border = new RectOffset(12, 12, 45, 12); _windowStyle.padding = new RectOffset(16, 16, 50, 16); _windowStyle.normal.textColor = new Color(1f, 0.85f, 0.4f); _windowStyle.fontSize = 20; _windowStyle.fontStyle = (FontStyle)1; _windowStyle.alignment = (TextAnchor)1; if (_fontLoaded) { _windowStyle.font = _valheimFont; } _headerStyle = new GUIStyle(GUI.skin.label); _headerStyle.fontSize = 16; _headerStyle.fontStyle = (FontStyle)1; _headerStyle.normal.textColor = new Color(1f, 0.85f, 0.4f); _headerStyle.margin = new RectOffset(0, 0, 10, 8); if (_fontLoaded) { _headerStyle.font = _valheimFont; } _tabStyle = new GUIStyle(GUI.skin.button); _tabStyle.normal.background = CreateButtonTexture(32, 32, highlighted: false); _tabStyle.hover.background = CreateButtonTexture(32, 32, highlighted: true); _tabStyle.active.background = CreateButtonTexture(32, 32, highlighted: true); _tabStyle.normal.textColor = new Color(0.85f, 0.8f, 0.65f); _tabStyle.hover.textColor = new Color(1f, 0.95f, 0.8f); _tabStyle.fontSize = 13; _tabStyle.fontStyle = (FontStyle)1; _tabStyle.padding = new RectOffset(12, 12, 8, 8); _tabStyle.margin = new RectOffset(2, 2, 0, 0); if (_fontLoaded) { _tabStyle.font = _valheimFont; } _tabActiveStyle = new GUIStyle(_tabStyle); _tabActiveStyle.normal.background = CreateButtonTexture(32, 32, highlighted: true); _tabActiveStyle.normal.textColor = new Color(1f, 0.9f, 0.5f); _labelStyle = new GUIStyle(GUI.skin.label); _labelStyle.normal.textColor = new Color(0.9f, 0.88f, 0.8f); _labelStyle.fontSize = 14; _labelStyle.wordWrap = true; _labelStyle.richText = true; _labelStyle.margin = new RectOffset(0, 0, 2, 2); if (_fontLoaded) { _labelStyle.font = _valheimFont; } _labelGoldStyle = new GUIStyle(_labelStyle); _labelGoldStyle.normal.textColor = new Color(1f, 0.85f, 0.4f); _labelGoldStyle.fontStyle = (FontStyle)1; _labelGoldStyle.fontSize = 15; _labelGreenStyle = new GUIStyle(_labelStyle); _labelGreenStyle.normal.textColor = new Color(0.5f, 0.95f, 0.4f); _labelGreenStyle.fontStyle = (FontStyle)1; _labelRedStyle = new GUIStyle(_labelStyle); _labelRedStyle.normal.textColor = new Color(0.98f, 0.5f, 0.4f); _labelRedStyle.fontStyle = (FontStyle)1; _buttonStyle = new GUIStyle(GUI.skin.button); _buttonStyle.normal.background = CreateButtonTexture(32, 32, highlighted: false); _buttonStyle.hover.background = CreateButtonTexture(32, 32, highlighted: true); _buttonStyle.active.background = CreateButtonTexture(32, 32, highlighted: true); _buttonStyle.normal.textColor = new Color(1f, 0.9f, 0.7f); _buttonStyle.hover.textColor = Color.white; _buttonStyle.fontSize = 14; _buttonStyle.fontStyle = (FontStyle)1; _buttonStyle.padding = new RectOffset(14, 14, 8, 8); _buttonStyle.margin = new RectOffset(0, 0, 4, 4); if (_fontLoaded) { _buttonStyle.font = _valheimFont; } _boxStyle = new GUIStyle(GUI.skin.box); _boxStyle.normal.background = CreateInsetTexture(32, 32); _boxStyle.padding = new RectOffset(10, 10, 8, 8); _boxStyle.margin = new RectOffset(0, 0, 4, 4); _scrollStyle = new GUIStyle(GUI.skin.scrollView); _stylesInit = true; } } private Texture2D CreatePanelTexture(int width, int height) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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_00cc: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: 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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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) Texture2D val = new Texture2D(width, height); Color val2 = default(Color); ((Color)(ref val2))..ctor(0.08f, 0.06f, 0.04f, 0.96f); Color val3 = default(Color); ((Color)(ref val3))..ctor(0.45f, 0.35f, 0.22f, 0.9f); Color val4 = default(Color); ((Color)(ref val4))..ctor(0.02f, 0.015f, 0.01f, 1f); for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { Color val5; if (j < 3 || j >= width - 3 || i < 3 || i >= height - 3) { val5 = val4; } else if (j < 5 || j >= width - 5 || i < 5 || i >= height - 5) { val5 = val3; } else { float num = (float)i / (float)height; val5 = Color.Lerp(val2, new Color(val2.r * 1.1f, val2.g * 1.1f, val2.b * 1.1f, val2.a), num * 0.3f); } val.SetPixel(j, i, val5); } } val.Apply(); ((Texture)val).filterMode = (FilterMode)0; return val; } private Texture2D CreateButtonTexture(int width, int height, bool highlighted) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_0073: 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_0078: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //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) Texture2D val = new Texture2D(width, height); Color val2 = (highlighted ? new Color(0.28f, 0.2f, 0.12f, 0.95f) : new Color(0.18f, 0.13f, 0.08f, 0.95f)); Color val3 = (highlighted ? new Color(0.5f, 0.38f, 0.22f, 1f) : new Color(0.35f, 0.27f, 0.16f, 1f)); Color val4 = default(Color); ((Color)(ref val4))..ctor(0.06f, 0.04f, 0.02f, 1f); for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { Color val5; if (i >= height - 2) { val5 = val3; } else if (i < 2) { val5 = val4; } else if (j < 1 || j >= width - 1) { val5 = Color.Lerp(val2, val4, 0.4f); } else { float num = (float)i / (float)height; val5 = Color.Lerp(val2, val3, num * 0.25f); } val.SetPixel(j, i, val5); } } val.Apply(); return val; } private Texture2D CreateInsetTexture(int width, int height) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown //IL_0076: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(width, height); Color val2 = default(Color); ((Color)(ref val2))..ctor(0.05f, 0.04f, 0.025f, 0.9f); Color val3 = default(Color); ((Color)(ref val3))..ctor(0.02f, 0.015f, 0.01f, 0.95f); Color val4 = default(Color); ((Color)(ref val4))..ctor(0.12f, 0.09f, 0.05f, 0.9f); for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { Color val5 = ((i < height - 2) ? ((i >= 2) ? val2 : val4) : val3); val.SetPixel(j, i, val5); } } val.Apply(); return val; } private void OnGUI() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Invalid comparison between Unknown and I4 //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Invalid comparison between Unknown and I4 //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Invalid comparison between Unknown and I4 //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Expected O, but got Unknown //IL_00e2: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Expected O, but got Unknown //IL_0131: 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) if ((_isVisible || _showRaidWindow) && !((Object)(object)Player.m_localPlayer == (Object)null)) { InitStyles(); Event current = Event.current; if (((int)current.type == 4 || (int)current.type == 5) && (int)current.keyCode != 27 && current.keyCode != LandlordConfig.HUDToggleKey.Value) { current.Use(); } if ((int)current.type == 6) { current.Use(); } Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; if (_isVisible) { _windowRect = GUI.Window(_windowId, _windowRect, new WindowFunction(DrawWindow), "", _windowStyle); } if (_showRaidWindow && _raidTargetTerritory != null) { _raidWindowRect = GUILayout.Window(_raidWindowId, _raidWindowRect, new WindowFunction(DrawRaidWindow), "Vault Raid", _windowStyle, Array.Empty()); } } } private void DrawWindow(int id) { //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: 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_00b0: Unknown result type (might be due to invalid IL or missing references) DrawTitleBar(); GUILayout.Space(48f); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.FlexibleSpace(); for (int i = 0; i < _tabNames.Length; i++) { GUILayoutOption[] array = (GUILayoutOption[])(object)((!(_tabNames[i] == "?")) ? new GUILayoutOption[1] { GUILayout.Height(32f) } : new GUILayoutOption[2] { GUILayout.Width(34f), GUILayout.Height(32f) }); if (GUILayout.Button(_tabNames[i], (i == _currentTab) ? _tabActiveStyle : _tabStyle, array)) { _currentTab = i; _scrollPos = Vector2.zero; } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(8f); DrawSeparator(); GUILayout.Space(6f); _scrollPos = GUILayout.BeginScrollView(_scrollPos, _scrollStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) }); switch (_currentTab) { case 0: DrawOverview(); break; case 1: DrawYourLand(); break; case 2: DrawLeaderboard(); break; case 3: DrawVassals(); break; case 4: DrawAuctions(); break; case 5: DrawRaidLog(); break; case 6: DrawHelp(); break; } GUILayout.EndScrollView(); DrawRentTooltipIfNeeded(); DrawVaultTooltipIfNeeded(); GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref _windowRect)).width - 40f, 45f)); } private void DrawTitleBar() { //IL_0015: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) GUI.color = new Color(0.06f, 0.045f, 0.03f, 0.95f); GUI.DrawTexture(new Rect(5f, 5f, ((Rect)(ref _windowRect)).width - 10f, 38f), (Texture)(object)_pixelTex); GUI.color = new Color(0.55f, 0.42f, 0.25f, 0.8f); GUI.DrawTexture(new Rect(5f, 42f, ((Rect)(ref _windowRect)).width - 10f, 1f), (Texture)(object)_pixelTex); GUI.color = Color.white; GUIStyle val = new GUIStyle(_headerStyle); val.fontSize = 18; val.alignment = (TextAnchor)4; GUI.Label(new Rect(0f, 8f, ((Rect)(ref _windowRect)).width, 32f), "LAND MANAGEMENT", val); if (GUI.Button(new Rect(((Rect)(ref _windowRect)).width - 38f, 10f, 28f, 26f), "X", _tabStyle)) { _isVisible = false; } } private void DrawSeparator() { //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_0034: 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_004c: Unknown result type (might be due to invalid IL or missing references) Rect rect = GUILayoutUtility.GetRect(1f, 1f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUI.color = new Color(0.45f, 0.35f, 0.22f, 0.5f); GUI.DrawTexture(rect, (Texture)(object)_pixelTex); GUI.color = Color.white; } private void DrawSectionHeader(string text) { GUILayout.Space(4f); GUILayout.Label(text, _labelGoldStyle, Array.Empty()); GUILayout.Space(4f); } private void DrawOverview() { //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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_041b: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_09d6: Unknown result type (might be due to invalid IL or missing references) //IL_09db: Unknown result type (might be due to invalid IL or missing references) //IL_0a10: Unknown result type (might be due to invalid IL or missing references) //IL_0b46: Unknown result type (might be due to invalid IL or missing references) //IL_0b4b: Unknown result type (might be due to invalid IL or missing references) //IL_0b80: Unknown result type (might be due to invalid IL or missing references) //IL_0c8e: Unknown result type (might be due to invalid IL or missing references) //IL_0c93: Unknown result type (might be due to invalid IL or missing references) //IL_0cc8: Unknown result type (might be due to invalid IL or missing references) //IL_0e9f: Unknown result type (might be due to invalid IL or missing references) //IL_0ea4: Unknown result type (might be due to invalid IL or missing references) //IL_0ec6: Unknown result type (might be due to invalid IL or missing references) //IL_0ed1: Unknown result type (might be due to invalid IL or missing references) //IL_0f30: Unknown result type (might be due to invalid IL or missing references) //IL_0f71: Unknown result type (might be due to invalid IL or missing references) //IL_10bb: Unknown result type (might be due to invalid IL or missing references) //IL_10e0: Unknown result type (might be due to invalid IL or missing references) //IL_1111: Unknown result type (might be due to invalid IL or missing references) //IL_113c: Unknown result type (might be due to invalid IL or missing references) //IL_116d: Unknown result type (might be due to invalid IL or missing references) //IL_117e: Unknown result type (might be due to invalid IL or missing references) //IL_104d: Unknown result type (might be due to invalid IL or missing references) //IL_1079: Unknown result type (might be due to invalid IL or missing references) //IL_11ea: Unknown result type (might be due to invalid IL or missing references) //IL_11f1: Expected O, but got Unknown //IL_1221: Unknown result type (might be due to invalid IL or missing references) //IL_1254: Unknown result type (might be due to invalid IL or missing references) //IL_1263: Unknown result type (might be due to invalid IL or missing references) //IL_126e: Unknown result type (might be due to invalid IL or missing references) LandlordData landlordData = TerritoryManager.Instance?.Data; Player localPlayer = Player.m_localPlayer; long num = ((localPlayer != null) ? localPlayer.GetPlayerID() : 0); DrawSectionHeader("Current Territory"); Vector3 position = ((Component)Player.m_localPlayer).transform.position; Vector2i gridPos = GridUtils.WorldToVisualGrid(position); Territory territory = TerritoryManager.Instance?.GetTerritory(gridPos); if (territory != null) { GUILayout.BeginVertical(_boxStyle, Array.Empty()); GUILayout.Label(territory.DisplayName, _labelGoldStyle, Array.Empty()); string biomeCompositionDescription = TerritoryNaming.GetBiomeCompositionDescription(territory.BiomeComposition); GUILayout.Label("Biomes: " + biomeCompositionDescription, _labelStyle, Array.Empty()); if (territory.OwnerPlayerId == num) { GUILayout.Label("Your Territory", _labelGreenStyle, Array.Empty()); GUILayout.Label($"Toll: {territory.CalculateToll()} coins | Guardians: {territory.Guardians.Count}/2", _labelStyle, Array.Empty()); GUILayout.Label(string.Format("PvP: {0} | Loot Tax: {1}% | Prestige: {2}", territory.IsPvPEnabled ? "ON" : "OFF", territory.LootTaxPercent, territory.Prestige), _labelStyle, Array.Empty()); GUILayout.Label($"Accumulated Income: {territory.AccumulatedIncome} coins", _labelGreenStyle, Array.Empty()); } else { GUILayout.Label("Owner: " + territory.OwnerName, _labelStyle, Array.Empty()); GUILayout.Label($"Toll: {territory.CalculateToll()} coins", _labelStyle, Array.Empty()); GUILayout.Label(string.Format("PvP: {0} | Loot Tax: {1}% | Prestige: {2}", territory.IsPvPEnabled ? "ON" : "OFF", territory.LootTaxPercent, territory.Prestige), _labelStyle, Array.Empty()); GUILayout.Space(6f); GUILayout.Label("" + territory.OwnerName + "'s Vault:", _labelGoldStyle, Array.Empty()); DrawVaultItemGrid(territory.Vault); } GUILayout.EndVertical(); } else { GUILayout.BeginVertical(_boxStyle, Array.Empty()); GUILayout.Label("Unclaimed Territory", _labelStyle, Array.Empty()); string text = "Unknown"; try { Dictionary dictionary = BiomeUtils.SampleBiomeComposition(gridPos); if (dictionary != null && dictionary.Count > 0) { text = TerritoryNaming.GetBiomeCompositionDescription(dictionary); } } catch { } GUILayout.Label("Biomes: " + text, _labelStyle, Array.Empty()); GUILayout.Label("Open the map (M) and click on a grid cell to claim territory.", _labelStyle, Array.Empty()); GUILayout.EndVertical(); } Player localPlayer2 = Player.m_localPlayer; Inventory inventory = ((localPlayer2 != null) ? ((Humanoid)localPlayer2).GetInventory() : null); int[] array = VaultKeySetup.CountKeysInInventory(inventory); int num2 = array[0] + array[1] + array[2]; if (num2 > 0) { GUILayout.Space(12f); DrawSectionHeader("Vault Keys"); GUILayout.BeginVertical(_boxStyle, Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); for (int i = 0; i < 3; i++) { if (array[i] > 0) { Rect rect = GUILayoutUtility.GetRect(24f, 24f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(24f), GUILayout.Height(24f) }); Sprite vaultItemSprite = GetVaultItemSprite(VaultKeySetup.PrefabNames[i]); if ((Object)(object)vaultItemSprite != (Object)null) { DrawSprite(rect, vaultItemSprite); } else { GUI.color = KeyColors[i]; GUI.DrawTexture(rect, (Texture)(object)_pixelTex); GUI.color = Color.white; } GUILayout.Label($"{KeyNames[i]}: {array[i]}", _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) }); } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Label("Stand on another player's territory to raid their vault.", _labelStyle, Array.Empty()); GUILayout.EndVertical(); } if (territory != null && territory.OwnerPlayerId != num) { Player localPlayer3 = Player.m_localPlayer; Inventory inventory2 = ((localPlayer3 != null) ? ((Humanoid)localPlayer3).GetInventory() : null); int[] array2 = VaultKeySetup.CountKeysInInventory(inventory2); int num3 = array2[0] + array2[1] + array2[2]; if (num3 > 0 || _isRaiding || _raidResults != null) { GUILayout.Space(4f); if (GUILayout.Button("Raid " + territory.OwnerName + "'s Vault", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { _showRaidWindow = true; _raidTargetTerritory = territory; _isVisible = false; } } } Debt debt = landlordData?.GetDebt(num); if (debt != null && debt.Amount > 0) { GUILayout.Space(12f); DrawSectionHeader("Your Vassalage"); GUILayout.BeginVertical(_boxStyle, Array.Empty()); GUILayout.Label($"Total Owed: {debt.Amount} coins", _labelRedStyle, Array.Empty()); GUILayout.Label("Lord: " + debt.CreditorName, _labelStyle, Array.Empty()); GUILayout.Label($"Loot Redirect: {debt.VassalLootPercent}%", _labelRedStyle, Array.Empty()); if (debt.IsEscalated) { GUILayout.Label("ESCALATED - 30% loot redirected!", _labelRedStyle, Array.Empty()); } else { GUILayout.Label("Escalation in: " + debt.GetTimeRemainingString() + " (then 30%)", _labelStyle, Array.Empty()); } GUILayout.EndVertical(); if (GUILayout.Button("Pay Debt", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(32f) })) { LandlordRPC.Instance?.RequestPayDebt(); } } GUILayout.Space(12f); DrawSeparator(); GUILayout.Space(8f); int num4 = (landlordData?.GetPlayerTerritories(num))?.Count ?? 0; int num5 = landlordData?.GetMaxTerritories(num) ?? LandlordConfig.MaxTerritoriesPerPlayer.Value; int num6 = landlordData?.GetBossKillCount(num) ?? 0; GUILayout.Label($"Territories Owned: {num4} / {num5}", _labelStyle, Array.Empty()); GUILayout.Label($"Bosses Defeated: {num6} / {LandlordData.AllBossPrefabs.Length}", _labelStyle, Array.Empty()); if (landlordData != null && landlordData.IsEmperor(num)) { GUILayout.Space(4f); GUILayout.Label("*** EMPEROR - All territories permanent, 50% tax ***", _labelGoldStyle, Array.Empty()); } else if (landlordData != null && landlordData.HasKilledAllBosses(num)) { GUILayout.Space(4f); GUILayout.Label($"All bosses defeated! Claim {10 - num4} more territories to become Emperor!", _labelStyle, Array.Empty()); } GUILayout.Space(12f); DrawSectionHeader("Global Debt (Odin's Wrath)"); int num7 = landlordData?.GlobalDebt ?? 0; int num8 = landlordData?.GetStarLevelBonus() ?? 0; if (num7 > 0) { GUILayout.Label($"Total Global Debt: {num7} coins", _labelRedStyle, Array.Empty()); GUILayout.Label($"Monster Star Bonus: +{num8} stars", _labelRedStyle, Array.Empty()); GUILayout.Label("Monsters are empowered by collective debt!", _labelStyle, Array.Empty()); GUILayout.Space(6f); Sprite vaultItemSprite2 = GetVaultItemSprite("Coins"); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.FlexibleSpace(); if (GUILayout.Button("Pay 100 ", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(115f), GUILayout.Height(32f) })) { Player localPlayer4 = Player.m_localPlayer; Inventory val = ((localPlayer4 != null) ? ((Humanoid)localPlayer4).GetInventory() : null); int num9 = 0; if (val != null) { foreach (ItemData allItem in val.GetAllItems()) { if (allItem.m_shared.m_name == "$item_coins") { num9 += allItem.m_stack; } } } int num10 = Math.Min(100, Math.Min(num9, num7)); if (num10 > 0) { val.RemoveItem("$item_coins", num10, -1, true); LandlordRPC.Instance?.RequestPayGlobalDebt(num10); } else { MessageHud instance = MessageHud.instance; if (instance != null) { instance.ShowMessage((MessageType)1, "Not enough coins!", 0, (Sprite)null, false); } } } Rect lastRect = GUILayoutUtility.GetLastRect(); if ((Object)(object)vaultItemSprite2 != (Object)null) { DrawSprite(new Rect(((Rect)(ref lastRect)).xMax - 22f, ((Rect)(ref lastRect)).y + 8f, 16f, 16f), vaultItemSprite2); } GUILayout.Space(6f); if (GUILayout.Button("Pay 500 ", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(115f), GUILayout.Height(32f) })) { Player localPlayer5 = Player.m_localPlayer; Inventory val2 = ((localPlayer5 != null) ? ((Humanoid)localPlayer5).GetInventory() : null); int num11 = 0; if (val2 != null) { foreach (ItemData allItem2 in val2.GetAllItems()) { if (allItem2.m_shared.m_name == "$item_coins") { num11 += allItem2.m_stack; } } } int num12 = Math.Min(500, Math.Min(num11, num7)); if (num12 > 0) { val2.RemoveItem("$item_coins", num12, -1, true); LandlordRPC.Instance?.RequestPayGlobalDebt(num12); } else { MessageHud instance2 = MessageHud.instance; if (instance2 != null) { instance2.ShowMessage((MessageType)1, "Not enough coins!", 0, (Sprite)null, false); } } } Rect lastRect2 = GUILayoutUtility.GetLastRect(); if ((Object)(object)vaultItemSprite2 != (Object)null) { DrawSprite(new Rect(((Rect)(ref lastRect2)).xMax - 22f, ((Rect)(ref lastRect2)).y + 8f, 16f, 16f), vaultItemSprite2); } GUILayout.Space(6f); if (GUILayout.Button("Pay All ", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(115f), GUILayout.Height(32f) })) { Player localPlayer6 = Player.m_localPlayer; Inventory val3 = ((localPlayer6 != null) ? ((Humanoid)localPlayer6).GetInventory() : null); int num13 = 0; if (val3 != null) { foreach (ItemData allItem3 in val3.GetAllItems()) { if (allItem3.m_shared.m_name == "$item_coins") { num13 += allItem3.m_stack; } } } int num14 = Math.Min(num13, num7); if (num14 > 0) { val3.RemoveItem("$item_coins", num14, -1, true); LandlordRPC.Instance?.RequestPayGlobalDebt(num14); } } Rect lastRect3 = GUILayoutUtility.GetLastRect(); if ((Object)(object)vaultItemSprite2 != (Object)null) { DrawSprite(new Rect(((Rect)(ref lastRect3)).xMax - 22f, ((Rect)(ref lastRect3)).y + 8f, 16f, 16f), vaultItemSprite2); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } else { GUILayout.Label("No global debt. Odin is pleased!", _labelGreenStyle, Array.Empty()); } GUILayout.Space(12f); DrawSectionHeader("Tribute to the Gods"); if (landlordData?.CurrentTribute != null) { GlobalTribute currentTribute = landlordData.CurrentTribute; int num15 = landlordData.Territories?.Count ?? 0; int adjustedRequired = currentTribute.GetAdjustedRequired(num15); bool flag = currentTribute.IsComplete(num15); double num16 = currentTribute.DaysRemaining(); float num17 = Mathf.Clamp01((float)(7.0 - num16) / 7f); GUILayout.BeginVertical(_boxStyle, Array.Empty()); string text2 = ((currentTribute.Type == ObjectiveType.KillMonsters) ? "Slay" : "Offer"); string text3 = (flag ? "#00ff00" : "#ff8844"); GUILayout.Label("" + text2 + " " + currentTribute.TargetDisplayName + "", _labelGoldStyle, Array.Empty()); GUILayout.Label($"{currentTribute.CurrentAmount} / {adjustedRequired} (base: {currentTribute.BaseRequiredAmount}, -{num15}% from claimed territories)", _labelStyle, Array.Empty()); if (flag) { GUILayout.Label("Tribute fulfilled! Awaiting the gods' judgment...", _labelGreenStyle, Array.Empty()); } float num18 = Mathf.Clamp01(1f - num17); Rect rect2 = GUILayoutUtility.GetRect(1f, 22f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); float num19 = ((Rect)(ref rect2)).width * num18; GUI.color = new Color(0.08f, 0.04f, 0.04f, 0.9f); GUI.DrawTexture(rect2, (Texture)(object)_pixelTex); float num20 = 1f + Mathf.Sin(Time.time * 2f) * 0.08f; Color color = default(Color); ((Color)(ref color))..ctor(Mathf.Clamp01(0.6f * num20), Mathf.Clamp01(0.1f * num20), Mathf.Clamp01(0.08f * num20), 0.95f); GUI.color = color; GUI.DrawTexture(new Rect(((Rect)(ref rect2)).x + 1f, ((Rect)(ref rect2)).y + 1f, Mathf.Max(0f, num19 - 2f), ((Rect)(ref rect2)).height - 2f), (Texture)(object)_pixelTex); if (num19 > 4f) { float num21 = 1f - (Mathf.Repeat(Time.time * 0.35f, 1.3f) - 0.15f); float num22 = num19 * num21; float num23 = num19 * 0.2f; float num24 = Mathf.Max(((Rect)(ref rect2)).x + 1f, ((Rect)(ref rect2)).x + 1f + num22 - num23 * 0.5f); float num25 = Mathf.Min(((Rect)(ref rect2)).x + 1f + num19 - 2f, ((Rect)(ref rect2)).x + 1f + num22 + num23 * 0.5f); if (num25 > num24) { GUI.color = new Color(1f, 0.6f, 0.5f, 0.12f); GUI.DrawTexture(new Rect(num24, ((Rect)(ref rect2)).y + 1f, num25 - num24, ((Rect)(ref rect2)).height - 2f), (Texture)(object)_pixelTex); } } float num26 = 0.3f + 0.2f * Mathf.Sin(Time.time * 2.5f); GUI.color = new Color(0.8f, 0.15f, 0.1f, num26); GUI.DrawTexture(new Rect(((Rect)(ref rect2)).x, ((Rect)(ref rect2)).y, ((Rect)(ref rect2)).width, 1f), (Texture)(object)_pixelTex); GUI.DrawTexture(new Rect(((Rect)(ref rect2)).x, ((Rect)(ref rect2)).yMax - 1f, ((Rect)(ref rect2)).width, 1f), (Texture)(object)_pixelTex); GUI.DrawTexture(new Rect(((Rect)(ref rect2)).x, ((Rect)(ref rect2)).y, 1f, ((Rect)(ref rect2)).height), (Texture)(object)_pixelTex); GUI.DrawTexture(new Rect(((Rect)(ref rect2)).xMax - 1f, ((Rect)(ref rect2)).y, 1f, ((Rect)(ref rect2)).height), (Texture)(object)_pixelTex); GUI.color = Color.white; string text4 = ((num16 >= 1.0) ? $"{(int)num16}d {(int)(num16 % 1.0 * 24.0)}h" : $"{(int)(num16 * 24.0)}h"); GUIStyle val4 = new GUIStyle(_labelStyle); val4.alignment = (TextAnchor)4; val4.fontSize = 12; val4.fontStyle = (FontStyle)1; GUI.color = new Color(0f, 0f, 0f, 0.7f); GUI.Label(new Rect(((Rect)(ref rect2)).x + 1f, ((Rect)(ref rect2)).y + 1f, ((Rect)(ref rect2)).width, ((Rect)(ref rect2)).height), text4, val4); GUI.color = Color.white; GUI.Label(rect2, text4, val4); GUILayout.EndVertical(); } else { GUILayout.Label("No active tribute.", _labelStyle, Array.Empty()); } } private void DrawYourLand() { //IL_009c: 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) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Unknown result type (might be due to invalid IL or missing references) //IL_0479: 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_0c2c: Unknown result type (might be due to invalid IL or missing references) //IL_0c31: Unknown result type (might be due to invalid IL or missing references) //IL_0c53: Unknown result type (might be due to invalid IL or missing references) //IL_0c5e: Unknown result type (might be due to invalid IL or missing references) //IL_1136: Unknown result type (might be due to invalid IL or missing references) //IL_113b: Unknown result type (might be due to invalid IL or missing references) //IL_1151: Unknown result type (might be due to invalid IL or missing references) //IL_115c: Unknown result type (might be due to invalid IL or missing references) //IL_0cc8: Unknown result type (might be due to invalid IL or missing references) //IL_0ccd: Unknown result type (might be due to invalid IL or missing references) //IL_0cef: Unknown result type (might be due to invalid IL or missing references) //IL_0cfe: Unknown result type (might be due to invalid IL or missing references) //IL_0d0d: Unknown result type (might be due to invalid IL or missing references) //IL_0d1c: Unknown result type (might be due to invalid IL or missing references) //IL_0d28: Unknown result type (might be due to invalid IL or missing references) //IL_0d69: Unknown result type (might be due to invalid IL or missing references) //IL_0cad: Unknown result type (might be due to invalid IL or missing references) //IL_0c92: Unknown result type (might be due to invalid IL or missing references) //IL_0eb3: Unknown result type (might be due to invalid IL or missing references) //IL_0ed8: Unknown result type (might be due to invalid IL or missing references) //IL_0f09: Unknown result type (might be due to invalid IL or missing references) //IL_0f34: Unknown result type (might be due to invalid IL or missing references) //IL_0f65: Unknown result type (might be due to invalid IL or missing references) //IL_0f76: Unknown result type (might be due to invalid IL or missing references) //IL_0af4: Unknown result type (might be due to invalid IL or missing references) //IL_0af9: Unknown result type (might be due to invalid IL or missing references) //IL_0afc: Unknown result type (might be due to invalid IL or missing references) //IL_0e45: Unknown result type (might be due to invalid IL or missing references) //IL_0e71: Unknown result type (might be due to invalid IL or missing references) //IL_1193: Unknown result type (might be due to invalid IL or missing references) //IL_11d4: Unknown result type (might be due to invalid IL or missing references) //IL_0ffe: Unknown result type (might be due to invalid IL or missing references) //IL_1005: Expected O, but got Unknown //IL_1035: Unknown result type (might be due to invalid IL or missing references) //IL_1068: Unknown result type (might be due to invalid IL or missing references) //IL_1077: Unknown result type (might be due to invalid IL or missing references) //IL_1082: Unknown result type (might be due to invalid IL or missing references) //IL_129c: Unknown result type (might be due to invalid IL or missing references) //IL_122d: Unknown result type (might be due to invalid IL or missing references) //IL_1276: Unknown result type (might be due to invalid IL or missing references) //IL_12d4: Unknown result type (might be due to invalid IL or missing references) //IL_12f7: Unknown result type (might be due to invalid IL or missing references) //IL_1417: Unknown result type (might be due to invalid IL or missing references) //IL_1426: Unknown result type (might be due to invalid IL or missing references) LandlordData landlordData = TerritoryManager.Instance?.Data; Player localPlayer = Player.m_localPlayer; long num = ((localPlayer != null) ? localPlayer.GetPlayerID() : 0); DrawSectionHeader("Your Territories"); List list = landlordData?.GetPlayerTerritories(num); if (list == null || list.Count == 0) { GUILayout.Label("You don't own any territories yet.", _labelStyle, Array.Empty()); GUILayout.Space(6f); GUILayout.Label("Open the map (M) and click on a grid cell to claim territory.", _labelStyle, Array.Empty()); return; } Vector2i val = GridUtils.WorldToVisualGrid(((Component)Player.m_localPlayer).transform.position); int num2 = 0; Color color = default(Color); foreach (Territory item in list) { GUILayout.BeginVertical(_boxStyle, Array.Empty()); string text = LandlordData.GridToKey(item.GridPosition); if (_renamingTerritoryKey == text) { GUILayout.BeginHorizontal(Array.Empty()); if (!_renameInputs.ContainsKey(text)) { _renameInputs[text] = item.CustomName ?? item.DisplayName; } _renameInputs[text] = GUILayout.TextField(_renameInputs[text], 32, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(300f), GUILayout.Height(26f) }); if (GUILayout.Button("Save", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(80f), GUILayout.Height(30f) })) { string text2 = _renameInputs[text]?.Trim(); if (!string.IsNullOrEmpty(text2) && text2.Length <= 32) { Player localPlayer2 = Player.m_localPlayer; Inventory val2 = ((localPlayer2 != null) ? ((Humanoid)localPlayer2).GetInventory() : null); int num3 = 0; if (val2 != null) { foreach (ItemData allItem in val2.GetAllItems()) { if (allItem.m_shared.m_name == "$item_coins") { num3 += allItem.m_stack; } } } if (num3 < 500) { MessageHud instance = MessageHud.instance; if (instance != null) { instance.ShowMessage((MessageType)1, $"Need 500 coins to rename! (have {num3})", 0, (Sprite)null, false); } } else { val2.RemoveItem("$item_coins", 500, -1, true); item.CustomName = text2; item.LastRenameTime = DateTime.UtcNow; TerritoryManager.Instance?.MarkDirty(); MessageHud instance2 = MessageHud.instance; if (instance2 != null) { instance2.ShowMessage((MessageType)1, "Territory renamed to: " + text2 + " (500 coins)", 0, (Sprite)null, false); } } } _renamingTerritoryKey = null; } if (GUILayout.Button("Cancel", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(80f), GUILayout.Height(30f) })) { _renamingTerritoryKey = null; } GUILayout.EndHorizontal(); } else { GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label(item.DisplayName, _labelGoldStyle, Array.Empty()); double num4 = ((item.LastRenameTicks != 0L) ? (DateTime.UtcNow - item.LastRenameTime).TotalHours : 24.0); if (num4 < 24.0) { int num5 = (int)(24.0 - num4); GUILayout.Label($"(Rename: {num5}h)", _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(110f) }); } else { if (GUILayout.Button(" Rename for 500 ", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(160f), GUILayout.Height(28f) })) { _renamingTerritoryKey = text; _renameInputs[text] = item.CustomName ?? item.DisplayName; } Rect lastRect = GUILayoutUtility.GetLastRect(); Sprite vaultItemSprite = GetVaultItemSprite("Coins"); if ((Object)(object)vaultItemSprite != (Object)null) { DrawSprite(new Rect(((Rect)(ref lastRect)).xMax - 22f, ((Rect)(ref lastRect)).y + 6f, 16f, 16f), vaultItemSprite); } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } string biomeCompositionDescription = TerritoryNaming.GetBiomeCompositionDescription(item.BiomeComposition); GUILayout.Label("Biomes: " + biomeCompositionDescription, _labelStyle, Array.Empty()); GUILayout.Label($"Toll: {item.CalculateToll()} coins | Guardians: {item.Guardians.Count}/2", _labelStyle, Array.Empty()); if (item.IsEmperorTerritory) { GUILayout.Label("EMPEROR TERRITORY - 50% Loot Tax, No Upkeep", _labelGoldStyle, Array.Empty()); } else { GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("PvP: " + (item.IsPvPEnabled ? "ON" : "OFF"), _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) }); if (item.IsPvPEnabled && item.LastPvPToggleTicks != 0L && (DateTime.UtcNow - item.LastPvPToggleTime).TotalHours < 1.0) { int num6 = (int)(60.0 - (DateTime.UtcNow - item.LastPvPToggleTime).TotalMinutes); GUILayout.Label($"Cooldown: {num6}m", _labelStyle, Array.Empty()); } else if (GUILayout.Button(item.IsPvPEnabled ? "Disable PvP" : "Enable PvP", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(130f), GUILayout.Height(30f) })) { item.IsPvPEnabled = !item.IsPvPEnabled; if (item.IsPvPEnabled) { item.LastPvPToggleTime = DateTime.UtcNow; } TerritoryManager.Instance?.MarkDirty(); string text3 = (item.IsPvPEnabled ? ("" + item.OwnerName + " enabled PvP on " + item.DisplayName + "!") : ("" + item.OwnerName + " disabled PvP on " + item.DisplayName + "")); foreach (Player allPlayer in Player.GetAllPlayers()) { ((Character)allPlayer).Message((MessageType)2, text3, 0, (Sprite)null); } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label($"Loot Tax: {item.LootTaxPercent}%", _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) }); int[] array = new int[5] { 0, 5, 10, 15, 20 }; double totalHours = (DateTime.UtcNow - item.LastLootTaxChangeTime).TotalHours; if (item.LastLootTaxChangeTicks != 0L && totalHours < 24.0) { int num7 = (int)(24.0 - totalHours); GUILayout.Label($" ({num7}h cooldown)", _labelStyle, Array.Empty()); } else { int[] array2 = array; foreach (int num8 in array2) { if (!GUILayout.Button($"{num8}%", (item.LootTaxPercent == num8) ? _tabActiveStyle : _tabStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(50f), GUILayout.Height(30f) }) || item.LootTaxPercent == num8) { continue; } item.LootTaxPercent = num8; item.LastLootTaxChangeTime = DateTime.UtcNow; TerritoryManager.Instance?.MarkDirty(); string text4 = $"{item.OwnerName} changed loot tax on {item.DisplayName} to {num8}%"; foreach (Player allPlayer2 in Player.GetAllPlayers()) { ((Character)allPlayer2).Message((MessageType)2, text4, 0, (Sprite)null); } } } GUILayout.EndHorizontal(); } if (!item.IsEmperorTerritory) { double totalDays = (DateTime.UtcNow - item.LastUpkeepTime).TotalDays; double num9 = 7.0 - totalDays; float num10 = Mathf.Clamp01((float)(totalDays / 7.0)); if (item.AreAllObjectivesComplete()) { string text5 = ((num9 >= 1.0) ? $"{(int)num9}d {(int)(num9 % 1.0 * 24.0)}h" : $"{(int)(num9 * 24.0)}h"); GUILayout.Label("This week's rent is paid! Next rent in: " + text5 + "", _labelGreenStyle, Array.Empty()); } else { DrawRentHeader(); if (item.Objectives != null) { foreach (TerritoryObjective objective in item.Objectives) { GUILayout.BeginHorizontal(Array.Empty()); Sprite objectiveSprite = GetObjectiveSprite(objective); if ((Object)(object)objectiveSprite != (Object)null) { Rect rect = GUILayoutUtility.GetRect(28f, 28f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(28f), GUILayout.Height(28f) }); DrawSprite(rect, objectiveSprite); } string text6 = (objective.IsComplete ? "[+]" : "[-]"); GUILayout.Label(text6 + " " + objective.GetDescription(), _labelStyle, Array.Empty()); GUILayout.EndHorizontal(); if (objective.Type == ObjectiveType.PayMaterials && !objective.IsComplete) { GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Space(32f); int num11 = objective.RequiredAmount - objective.CurrentAmount; if (GUILayout.Button($"Pay {num11}", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(120f), GUILayout.Height(26f) })) { TryPayRentObjective(item, objective, num); } GUILayout.EndHorizontal(); } } } } float num12 = Mathf.Clamp01(1f - num10); Rect rect2 = GUILayoutUtility.GetRect(1f, 22f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); float num13 = ((Rect)(ref rect2)).width * num12; GUI.color = new Color(0.08f, 0.06f, 0.04f, 0.9f); GUI.DrawTexture(rect2, (Texture)(object)_pixelTex); Color val3 = ((num12 > 0.5f) ? new Color(0.7f, 0.25f, 0.15f, 0.95f) : ((num12 > 0.2f) ? new Color(0.85f, 0.6f, 0.1f, 0.95f) : new Color(0.2f, 0.7f, 0.25f, 0.95f))); float num14 = 1f + Mathf.Sin(Time.time * 2f) * 0.08f; ((Color)(ref color))..ctor(Mathf.Clamp01(val3.r * num14), Mathf.Clamp01(val3.g * num14), Mathf.Clamp01(val3.b * num14), val3.a); GUI.color = color; GUI.DrawTexture(new Rect(((Rect)(ref rect2)).x + 1f, ((Rect)(ref rect2)).y + 1f, Mathf.Max(0f, num13 - 2f), ((Rect)(ref rect2)).height - 2f), (Texture)(object)_pixelTex); if (num13 > 4f) { float num15 = 1f - (Mathf.Repeat(Time.time * 0.35f, 1.3f) - 0.15f); float num16 = num13 * num15; float num17 = num13 * 0.2f; float num18 = Mathf.Max(((Rect)(ref rect2)).x + 1f, ((Rect)(ref rect2)).x + 1f + num16 - num17 * 0.5f); float num19 = Mathf.Min(((Rect)(ref rect2)).x + 1f + num13 - 2f, ((Rect)(ref rect2)).x + 1f + num16 + num17 * 0.5f); if (num19 > num18) { GUI.color = new Color(1f, 1f, 1f, 0.12f); GUI.DrawTexture(new Rect(num18, ((Rect)(ref rect2)).y + 1f, num19 - num18, ((Rect)(ref rect2)).height - 2f), (Texture)(object)_pixelTex); } } float num20 = 0.3f + 0.2f * Mathf.Sin(Time.time * 2.5f); GUI.color = new Color(1f, 0.85f, 0.4f, num20); GUI.DrawTexture(new Rect(((Rect)(ref rect2)).x, ((Rect)(ref rect2)).y, ((Rect)(ref rect2)).width, 1f), (Texture)(object)_pixelTex); GUI.DrawTexture(new Rect(((Rect)(ref rect2)).x, ((Rect)(ref rect2)).yMax - 1f, ((Rect)(ref rect2)).width, 1f), (Texture)(object)_pixelTex); GUI.DrawTexture(new Rect(((Rect)(ref rect2)).x, ((Rect)(ref rect2)).y, 1f, ((Rect)(ref rect2)).height), (Texture)(object)_pixelTex); GUI.DrawTexture(new Rect(((Rect)(ref rect2)).xMax - 1f, ((Rect)(ref rect2)).y, 1f, ((Rect)(ref rect2)).height), (Texture)(object)_pixelTex); GUI.color = Color.white; string text7 = ((!(num9 > 0.0)) ? "OVERDUE!" : ((num9 >= 1.0) ? $"{(int)num9}d {(int)(num9 % 1.0 * 24.0)}h" : $"{(int)(num9 * 24.0)}h")); GUIStyle val4 = new GUIStyle(_labelStyle); val4.alignment = (TextAnchor)4; val4.fontSize = 12; val4.fontStyle = (FontStyle)1; GUI.color = new Color(0f, 0f, 0f, 0.7f); GUI.Label(new Rect(((Rect)(ref rect2)).x + 1f, ((Rect)(ref rect2)).y + 1f, ((Rect)(ref rect2)).width, ((Rect)(ref rect2)).height), text7, val4); GUI.color = Color.white; GUI.Label(rect2, text7, val4); } GUILayout.Space(4f); int num21 = item.UniquePiecesPlaced?.Count ?? 0; float num22 = ((item.Prestige >= 5) ? 1f : ((float)(num21 - item.Prestige * 10) / 10f)); num22 = Mathf.Clamp01(num22); GUILayout.Label($"Prestige Level: {item.Prestige}/5 (+{item.Prestige * 100}% toll) [{num21} unique builds]", _labelGoldStyle, Array.Empty()); Rect rect3 = GUILayoutUtility.GetRect(1f, 20f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUI.color = new Color(0.15f, 0.12f, 0.08f, 0.8f); GUI.DrawTexture(rect3, (Texture)(object)_pixelTex); float num23 = ((Rect)(ref rect3)).width / 5f; for (int j = 0; j < item.Prestige && j < 5; j++) { GUI.color = new Color(0.85f, 0.65f, 0.2f, 0.9f); GUI.DrawTexture(new Rect(((Rect)(ref rect3)).x + (float)j * num23 + 1f, ((Rect)(ref rect3)).y + 1f, num23 - 2f, ((Rect)(ref rect3)).height - 2f), (Texture)(object)_pixelTex); } if (item.Prestige < 5) { GUI.color = new Color(0.6f, 0.45f, 0.15f, 0.6f); GUI.DrawTexture(new Rect(((Rect)(ref rect3)).x + (float)item.Prestige * num23 + 1f, ((Rect)(ref rect3)).y + 1f, (num23 - 2f) * num22, ((Rect)(ref rect3)).height - 2f), (Texture)(object)_pixelTex); } GUI.color = new Color(0.3f, 0.25f, 0.15f, 0.9f); for (int k = 1; k < 5; k++) { GUI.DrawTexture(new Rect(((Rect)(ref rect3)).x + (float)k * num23 - 1f, ((Rect)(ref rect3)).y, 2f, ((Rect)(ref rect3)).height), (Texture)(object)_pixelTex); } GUI.color = Color.white; GUILayout.Label($"Accumulated: {item.AccumulatedIncome} coins", _labelGreenStyle, Array.Empty()); num2 += item.AccumulatedIncome; GUILayout.Space(6f); DrawSeparator(); GUILayout.Space(4f); int num24 = item.Vault?.Count ?? 0; int num25 = 0; if (item.Vault != null) { foreach (VaultItem item2 in item.Vault) { num25 += item2.Amount; } } GUILayout.Label($"Lord's Vault ({num24} types, {num25} items)", _labelGoldStyle, Array.Empty()); if (item.Vault != null && item.Vault.Count > 0) { DrawVaultItemGrid(item.Vault); bool flag2 = (GUI.enabled = val.x == item.GridX && val.y == item.GridY); if (GUILayout.Button(flag2 ? "Withdraw All Items" : "Go to this territory to withdraw", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { Player localPlayer3 = Player.m_localPlayer; if ((Object)(object)localPlayer3 != (Object)null) { Inventory inventory = ((Humanoid)localPlayer3).GetInventory(); foreach (VaultItem item3 in item.Vault) { try { ObjectDB instance3 = ObjectDB.instance; GameObject val5 = ((instance3 != null) ? instance3.GetItemPrefab(item3.PrefabName) : null); if ((Object)(object)val5 != (Object)null && inventory != null) { inventory.AddItem(val5, item3.Amount); } } catch { } } item.Vault.Clear(); TerritoryManager.Instance?.MarkDirty(); MessageHud instance4 = MessageHud.instance; if (instance4 != null) { instance4.ShowMessage((MessageType)1, "Vault items withdrawn!", 0, (Sprite)null, false); } } } GUI.enabled = true; } else { GUILayout.Label(" Empty - items taxed from visitors will appear here", _labelStyle, Array.Empty()); } GUILayout.EndVertical(); GUILayout.Space(4f); } GUILayout.Space(8f); GUILayout.Label($"Total Accumulated: {num2} coins", _labelGoldStyle, Array.Empty()); if (num2 > 0) { GUILayout.Space(4f); if (GUILayout.Button("Withdraw All Coins", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(32f) })) { LandlordRPC.Instance?.RequestWithdrawIncome(); } } } private void DrawRaidWindow(int windowId) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: 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_0576: Unknown result type (might be due to invalid IL or missing references) //IL_057b: Unknown result type (might be due to invalid IL or missing references) //IL_0591: Unknown result type (might be due to invalid IL or missing references) //IL_059c: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_041c: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_0713: Unknown result type (might be due to invalid IL or missing references) //IL_0738: Unknown result type (might be due to invalid IL or missing references) //IL_0769: Unknown result type (might be due to invalid IL or missing references) //IL_0794: Unknown result type (might be due to invalid IL or missing references) //IL_07c5: Unknown result type (might be due to invalid IL or missing references) //IL_07d6: Unknown result type (might be due to invalid IL or missing references) //IL_07e7: Unknown result type (might be due to invalid IL or missing references) //IL_07ee: Expected O, but got Unknown //IL_0817: Unknown result type (might be due to invalid IL or missing references) //IL_0822: Unknown result type (might be due to invalid IL or missing references) //IL_05d4: Unknown result type (might be due to invalid IL or missing references) //IL_05f9: Unknown result type (might be due to invalid IL or missing references) //IL_062a: Unknown result type (might be due to invalid IL or missing references) //IL_0655: Unknown result type (might be due to invalid IL or missing references) //IL_0686: Unknown result type (might be due to invalid IL or missing references) //IL_0697: Unknown result type (might be due to invalid IL or missing references) //IL_06ea: Unknown result type (might be due to invalid IL or missing references) if (GUI.Button(new Rect(((Rect)(ref _raidWindowRect)).width - 38f, 10f, 28f, 26f), "X", _tabStyle)) { if (_isRaiding) { _isRaiding = false; _raidTimer = 0f; _raidKeyType = -1; _raidSelectedKey = -1; if ((Object)(object)_raidVfxInstance != (Object)null) { Object.Destroy((Object)(object)_raidVfxInstance); _raidVfxInstance = null; } MessageHud instance = MessageHud.instance; if (instance != null) { instance.ShowMessage((MessageType)1, "Raid cancelled! Key wasted.", 0, (Sprite)null, false); } } _showRaidWindow = false; _raidResults = null; _isVisible = true; return; } GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref _raidWindowRect)).width - 45f, 25f)); LandlordData landlordData = TerritoryManager.Instance?.Data; Player localPlayer = Player.m_localPlayer; long localId = ((localPlayer != null) ? localPlayer.GetPlayerID() : 0); Territory raidTargetTerritory = _raidTargetTerritory; if (raidTargetTerritory == null || landlordData == null) { _showRaidWindow = false; return; } Player localPlayer2 = Player.m_localPlayer; Inventory inventory = ((localPlayer2 != null) ? ((Humanoid)localPlayer2).GetInventory() : null); int[] array = VaultKeySetup.CountKeysInInventory(inventory); GUILayout.Label("" + raidTargetTerritory.OwnerName + "'s Vault:", _labelStyle, Array.Empty()); _highlightVaultIndex = (_isRaiding ? _raidFlickerIndex : (-1)); DrawVaultItemGrid(raidTargetTerritory.Vault); _highlightVaultIndex = -1; GUILayout.Space(6f); if (_raidResults != null) { _raidResultsScroll = GUILayout.BeginScrollView(_raidResultsScroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(150f) }); if (_raidSuccess) { GUILayout.Label(_raidSuccessMessage ?? "Raid successful!", _labelGreenStyle, Array.Empty()); GUILayout.Space(4f); if (_raidResults.Count > 0) { DrawVaultItemGrid(_raidResults); } } else { GUILayout.Label("The key broke... The vault holds firm.", _labelRedStyle, Array.Empty()); } GUILayout.EndScrollView(); GUILayout.Space(4f); if (GUILayout.Button("Dismiss", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(120f), GUILayout.Height(28f) })) { _raidResults = null; _raidSuccessMessage = null; _raidResultsScroll = Vector2.zero; _showRaidWindow = false; _isVisible = true; } return; } if (_isRaiding) { int num = Mathf.CeilToInt(_raidTimer); float num2 = _raidTimer / _raidDuration; GUILayout.Label($"Raiding with {KeyNames[_raidKeyType]} Key... {num}s remaining", _labelRedStyle, Array.Empty()); Rect rect = GUILayoutUtility.GetRect(1f, 22f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUI.color = new Color(0.1f, 0.08f, 0.05f, 0.9f); GUI.DrawTexture(rect, (Texture)(object)_pixelTex); float num3 = 1f + Mathf.Sin(Time.time * 3f) * 0.12f; Color color = default(Color); ((Color)(ref color))..ctor(Mathf.Clamp01(0.85f * num3), Mathf.Clamp01(0.25f * num3), Mathf.Clamp01(0.1f * num3), 0.95f); GUI.color = color; GUI.DrawTexture(new Rect(((Rect)(ref rect)).x + 1f, ((Rect)(ref rect)).y + 1f, (((Rect)(ref rect)).width - 2f) * num2, ((Rect)(ref rect)).height - 2f), (Texture)(object)_pixelTex); GUI.color = Color.white; GUILayout.Space(4f); GUILayout.Label("WARNING: You are vulnerable while raiding! You cannot move or fight.", _labelRedStyle, Array.Empty()); GUILayout.Space(8f); DrawSeparator(); GUILayout.Space(4f); GUILayout.Label("Did you know?", _labelGoldStyle, Array.Empty()); string raidTip = GetRaidTip(); GUILayout.Label(raidTip, _labelStyle, Array.Empty()); GUILayout.Space(4f); if (GUILayout.Button("Cancel Raid (wastes key)", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) })) { _isRaiding = false; _raidTimer = 0f; _raidKeyType = -1; _raidSelectedKey = -1; _showRaidWindow = false; if ((Object)(object)_raidVfxInstance != (Object)null) { Object.Destroy((Object)(object)_raidVfxInstance); _raidVfxInstance = null; } MessageHud instance2 = MessageHud.instance; if (instance2 != null) { instance2.ShowMessage((MessageType)1, "Raid cancelled! Key wasted.", 0, (Sprite)null, false); } } return; } GUILayout.BeginHorizontal(Array.Empty()); GUILayout.FlexibleSpace(); Rect rect2 = GUILayoutUtility.GetRect(48f, 48f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(48f), GUILayout.Height(48f) }); GUI.color = new Color(0.06f, 0.05f, 0.03f, 0.9f); GUI.DrawTexture(rect2, (Texture)(object)_pixelTex); if (_raidSelectedKey >= 0 && _raidSelectedKey < 3) { GUI.color = KeyColors[_raidSelectedKey]; GUI.DrawTexture(new Rect(((Rect)(ref rect2)).x, ((Rect)(ref rect2)).y, ((Rect)(ref rect2)).width, 2f), (Texture)(object)_pixelTex); GUI.DrawTexture(new Rect(((Rect)(ref rect2)).x, ((Rect)(ref rect2)).yMax - 2f, ((Rect)(ref rect2)).width, 2f), (Texture)(object)_pixelTex); GUI.DrawTexture(new Rect(((Rect)(ref rect2)).x, ((Rect)(ref rect2)).y, 2f, ((Rect)(ref rect2)).height), (Texture)(object)_pixelTex); GUI.DrawTexture(new Rect(((Rect)(ref rect2)).xMax - 2f, ((Rect)(ref rect2)).y, 2f, ((Rect)(ref rect2)).height), (Texture)(object)_pixelTex); GUI.color = Color.white; Sprite vaultItemSprite = GetVaultItemSprite(VaultKeySetup.PrefabNames[_raidSelectedKey]); if ((Object)(object)vaultItemSprite != (Object)null) { DrawSprite(new Rect(((Rect)(ref rect2)).x + 6f, ((Rect)(ref rect2)).y + 6f, 36f, 36f), vaultItemSprite); } } else { GUI.color = new Color(0.3f, 0.25f, 0.18f, 0.5f); GUI.DrawTexture(new Rect(((Rect)(ref rect2)).x, ((Rect)(ref rect2)).y, ((Rect)(ref rect2)).width, 1f), (Texture)(object)_pixelTex); GUI.DrawTexture(new Rect(((Rect)(ref rect2)).x, ((Rect)(ref rect2)).yMax - 1f, ((Rect)(ref rect2)).width, 1f), (Texture)(object)_pixelTex); GUI.DrawTexture(new Rect(((Rect)(ref rect2)).x, ((Rect)(ref rect2)).y, 1f, ((Rect)(ref rect2)).height), (Texture)(object)_pixelTex); GUI.DrawTexture(new Rect(((Rect)(ref rect2)).xMax - 1f, ((Rect)(ref rect2)).y, 1f, ((Rect)(ref rect2)).height), (Texture)(object)_pixelTex); GUI.color = Color.white; GUIStyle val = new GUIStyle(_labelStyle); val.fontSize = 10; val.alignment = (TextAnchor)4; val.normal.textColor = new Color(0.5f, 0.45f, 0.35f); GUI.Label(rect2, "Insert\nKey", val); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(4f); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.FlexibleSpace(); for (int i = 0; i < 3; i++) { bool enabled = array[i] > 0; GUI.enabled = enabled; bool flag = _raidSelectedKey == i; GUIStyle val2 = (flag ? _tabActiveStyle : _buttonStyle); string text = $" {KeyNames[i]} x{array[i]}"; if (GUILayout.Button(text, val2, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(125f), GUILayout.Height(42f) })) { _raidSelectedKey = (flag ? (-1) : i); } GUI.enabled = true; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(6f); if (_raidSelectedKey >= 0 && _raidSelectedKey < 3 && array[_raidSelectedKey] > 0) { int num4 = ((_raidSelectedKey == 0) ? 25 : ((_raidSelectedKey == 1) ? 50 : 75)); float num5 = Math.Max(30f, 30f * (float)raidTargetTerritory.Prestige); float num6 = ((_raidSelectedKey == 1) ? 1.25f : ((_raidSelectedKey == 2) ? 1.5f : 1f)); float num7 = num5 * num6; int num8 = Mathf.RoundToInt(num7); if (GUILayout.Button($"Begin Raid ({num4}% | {num8}s)", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(34f) })) { StartRaid(raidTargetTerritory, landlordData, localId, _raidSelectedKey); } } } private void TryPayRentObjective(Territory territory, TerritoryObjective obj, long localId) { //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } Inventory inventory = ((Humanoid)localPlayer).GetInventory(); if (inventory == null) { return; } int num = obj.RequiredAmount - obj.CurrentAmount; if (num <= 0) { return; } if (obj.TargetPrefab.Equals("Coins", StringComparison.OrdinalIgnoreCase)) { int num2 = 0; foreach (ItemData allItem in inventory.GetAllItems()) { if (allItem.m_shared.m_name == "$item_coins") { num2 += allItem.m_stack; } } int num3 = Math.Min(num, num2); if (num3 <= 0) { MessageHud instance = MessageHud.instance; if (instance != null) { instance.ShowMessage((MessageType)1, "You don't have enough coins!", 0, (Sprite)null, false); } return; } inventory.RemoveItem("$item_coins", num3, -1, true); TerritoryManager.Instance?.ReportObjectiveProgress(localId, territory.GridPosition, obj.TargetPrefab, num3); MessageHud instance2 = MessageHud.instance; if (instance2 != null) { instance2.ShowMessage((MessageType)1, $"Paid {num3} {obj.TargetDisplayName}!", 0, (Sprite)null, false); } return; } int num4 = 0; foreach (ItemData allItem2 in inventory.GetAllItems()) { GameObject dropPrefab = allItem2.m_dropPrefab; string text = ((dropPrefab != null) ? ((Object)dropPrefab).name : null) ?? ""; if (text.Equals(obj.TargetPrefab, StringComparison.OrdinalIgnoreCase)) { num4 += allItem2.m_stack; } } int num5 = Math.Min(num, num4); if (num5 <= 0) { MessageHud instance3 = MessageHud.instance; if (instance3 != null) { instance3.ShowMessage((MessageType)1, "You don't have enough " + obj.TargetDisplayName + "!", 0, (Sprite)null, false); } return; } int num6 = num5; List list = new List(inventory.GetAllItems()); foreach (ItemData item in list) { if (num6 <= 0) { break; } GameObject dropPrefab2 = item.m_dropPrefab; string text2 = ((dropPrefab2 != null) ? ((Object)dropPrefab2).name : null) ?? ""; if (text2.Equals(obj.TargetPrefab, StringComparison.OrdinalIgnoreCase)) { if (item.m_stack <= num6) { num6 -= item.m_stack; inventory.RemoveItem(item); } else { item.m_stack -= num6; num6 = 0; } } } int num7 = num5 - num6; TerritoryManager.Instance?.ReportObjectiveProgress(localId, territory.GridPosition, obj.TargetPrefab, num7); MessageHud instance4 = MessageHud.instance; if (instance4 != null) { instance4.ShowMessage((MessageType)1, $"Paid {num7} {obj.TargetDisplayName}!", 0, (Sprite)null, false); } } private void StartRaid(Territory territory, LandlordData data, long localId, int keyType) { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; Inventory inventory = ((localPlayer != null) ? ((Humanoid)localPlayer).GetInventory() : null); if (!VaultKeySetup.RemoveKeyFromInventory(inventory, keyType)) { MessageHud instance = MessageHud.instance; if (instance != null) { instance.ShowMessage((MessageType)1, "You don't have that key!", 0, (Sprite)null, false); } return; } _raidSelectedKey = -1; TerritoryManager.Instance?.MarkDirty(); _isRaiding = true; _raidKeyType = keyType; _raidTerritory = territory.GridPosition; _raidDuration = Math.Max(30f, 30f * (float)territory.Prestige) * keyType switch { 2 => 1.5f, 1 => 1.25f, _ => 1f, }; _raidTimer = _raidDuration; _raidNotifyTimer = 0f; _raidResults = null; _raidSuccess = false; try { Player localPlayer2 = Player.m_localPlayer; if ((Object)(object)localPlayer2 != (Object)null && (Object)(object)ZNetScene.instance != (Object)null) { GameObject val = ZNetScene.instance.GetPrefab("vfx_Potion_health_medium") ?? ZNetScene.instance.GetPrefab("vfx_FireAddFuel"); if ((Object)(object)val != (Object)null) { _raidVfxInstance = Object.Instantiate(val, ((Component)localPlayer2).transform.position, Quaternion.identity, ((Component)localPlayer2).transform); } } } catch { } Player localPlayer3 = Player.m_localPlayer; string text = ((localPlayer3 != null) ? localPlayer3.GetPlayerName() : null) ?? "Someone"; string text2 = "" + text + " is raiding " + territory.OwnerName + "'s Vault!"; LandlordRPC.Instance?.BroadcastGlobalMessage(text2); foreach (Player allPlayer in Player.GetAllPlayers()) { ((Character)allPlayer).Message((MessageType)2, text2, 0, (Sprite)null); } } private void ProcessRaidResult() { //IL_005b: Unknown result type (might be due to invalid IL or missing references) _isRaiding = false; _raidTimer = 0f; _raidFlickerIndex = -1; if ((Object)(object)_raidVfxInstance != (Object)null) { Object.Destroy((Object)(object)_raidVfxInstance); _raidVfxInstance = null; } LandlordData landlordData = TerritoryManager.Instance?.Data; Territory territory = landlordData?.GetTerritory(_raidTerritory); if (territory == null) { _raidResults = new List(); _raidSuccess = false; return; } float num = ((_raidKeyType == 0) ? 0.25f : ((_raidKeyType == 1) ? 0.5f : 0.75f)); int num2 = ((_raidKeyType == 0) ? 1 : ((_raidKeyType == 1) ? 2 : 3)); _raidSuccess = Random.value < num; _raidResults = new List(); if (_raidSuccess && territory.Vault != null && territory.Vault.Count > 0) { int val = Random.Range(1, num2 + 1); val = Math.Min(val, territory.Vault.Count); Player localPlayer = Player.m_localPlayer; Inventory val2 = ((localPlayer != null) ? ((Humanoid)localPlayer).GetInventory() : null); for (int i = 0; i < val; i++) { if (territory.Vault.Count <= 0) { break; } int index = Random.Range(0, territory.Vault.Count); VaultItem vaultItem = territory.Vault[index]; _raidResults.Add(new VaultItem(vaultItem.PrefabName, vaultItem.DisplayName, vaultItem.Amount)); if (val2 != null) { try { ObjectDB instance = ObjectDB.instance; GameObject val3 = ((instance != null) ? instance.GetItemPrefab(vaultItem.PrefabName) : null); if ((Object)(object)val3 != (Object)null) { val2.AddItem(val3, vaultItem.Amount); } } catch { } } territory.Vault.RemoveAt(index); } TerritoryManager.Instance?.MarkDirty(); MessageHud instance2 = MessageHud.instance; if (instance2 != null) { instance2.ShowMessage((MessageType)1, $"Vault raided! Pulled {_raidResults.Count} item stacks!", 0, (Sprite)null, false); } _raidSuccessMessage = GetRaidSuccessMessage(territory?.OwnerName ?? "Unknown", _raidResults); } else if (!_raidSuccess) { _raidSuccessMessage = null; MessageHud instance3 = MessageHud.instance; if (instance3 != null) { instance3.ShowMessage((MessageType)1, "Key broke! The vault holds firm.", 0, (Sprite)null, false); } } else { _raidSuccessMessage = null; MessageHud instance4 = MessageHud.instance; if (instance4 != null) { instance4.ShowMessage((MessageType)1, "Vault was empty!", 0, (Sprite)null, false); } } Player localPlayer2 = Player.m_localPlayer; string raider = ((localPlayer2 != null) ? localPlayer2.GetPlayerName() : null) ?? "Unknown"; string items = ((_raidSuccess && _raidResults.Count > 0) ? string.Join(", ", _raidResults.ConvertAll((VaultItem r) => $"{r.Amount}x {r.DisplayName}")) : ""); string keyType = ((_raidKeyType >= 0 && _raidKeyType < KeyNames.Length) ? KeyNames[_raidKeyType] : "Unknown"); _raidKeyType = -1; if (landlordData != null) { landlordData.RaidLog.Add(new RaidLogEntry(raider, territory?.OwnerName ?? "Unknown", territory?.DisplayName ?? "Unknown", _raidSuccess, keyType, items)); while (landlordData.RaidLog.Count > 100) { landlordData.RaidLog.RemoveAt(0); } TerritoryManager.Instance?.MarkDirty(); TerritoryManager.Instance?.SaveData(); } } private void DrawLeaderboard() { //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_019c: 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_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: 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_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Expected O, but got Unknown //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Expected O, but got Unknown //IL_04c3: Unknown result type (might be due to invalid IL or missing references) //IL_04c8: Unknown result type (might be due to invalid IL or missing references) //IL_04e9: Unknown result type (might be due to invalid IL or missing references) //IL_0544: Unknown result type (might be due to invalid IL or missing references) //IL_0549: Unknown result type (might be due to invalid IL or missing references) //IL_0550: Unknown result type (might be due to invalid IL or missing references) //IL_0581: Unknown result type (might be due to invalid IL or missing references) //IL_0592: Unknown result type (might be due to invalid IL or missing references) DrawSectionHeader("Landlord Leaderboard"); LandlordData landlordData = TerritoryManager.Instance?.Data; if (landlordData == null) { GUILayout.Label("No data available.", _labelStyle, Array.Empty()); return; } Dictionary, int)> dictionary = new Dictionary, int)>(); foreach (KeyValuePair territory in landlordData.Territories) { Territory value = territory.Value; if (!dictionary.ContainsKey(value.OwnerName)) { int item = 0; if (landlordData.PlayerStats.TryGetValue(value.OwnerPlayerId, out var value2)) { item = value2.TotalIncomeEarned; } dictionary[value.OwnerName] = (value.OwnerPlayerId, new List(), item); } dictionary[value.OwnerName].Item2.Add(value); } List, int)>> list = new List, int)>>(dictionary); list.Sort(delegate(KeyValuePair territories, int totalIncome)> a, KeyValuePair territories, int totalIncome)> b) { int num2 = b.Value.territories.Count.CompareTo(a.Value.territories.Count); return (num2 != 0) ? num2 : b.Value.totalIncome.CompareTo(a.Value.totalIncome); }); if (list.Count == 0) { GUILayout.Label("No territories claimed yet.", _labelStyle, Array.Empty()); return; } Color[] array = (Color[])(object)new Color[3] { new Color(1f, 0.84f, 0f, 0.9f), new Color(0.75f, 0.75f, 0.78f, 0.8f), new Color(0.8f, 0.5f, 0.2f, 0.7f) }; Sprite vaultItemSprite = GetVaultItemSprite("Coins"); int num = 1; foreach (KeyValuePair, int)> item2 in list) { if (num > 10) { break; } bool flag = num <= 3; GUILayout.BeginVertical(_boxStyle, Array.Empty()); Rect zero = Rect.zero; GUILayout.BeginHorizontal(Array.Empty()); GUIStyle val = new GUIStyle(_labelStyle); val.alignment = (TextAnchor)4; val.fontStyle = (FontStyle)1; if (flag) { val.fontSize = 16; GUILayout.Label(string.Format("#{1}", num switch { 2 => "#c0c0c0", 1 => "#ffd700", _ => "#cd7f32", }, num), val, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(36f), GUILayout.Height(24f) }); } else { val.fontSize = 13; GUILayout.Label($"#{num}", val, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(36f), GUILayout.Height(24f) }); } GUILayout.BeginVertical(Array.Empty()); GUIStyle val2 = new GUIStyle(_labelStyle); val2.fontStyle = (FontStyle)1; if (flag) { val2.fontSize = 15; string text = num switch { 2 => "#c0c0c0", 1 => "#ffd700", _ => "#cd7f32", }; GUILayout.Label("" + item2.Key + "", val2, Array.Empty()); } else { GUILayout.Label(item2.Key, val2, Array.Empty()); } if (flag) { foreach (Territory item3 in item2.Value.Item2) { GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Space(8f); GUILayout.Label("• " + item3.DisplayName + "", _labelStyle, Array.Empty()); GUILayout.EndHorizontal(); } } GUILayout.EndVertical(); GUILayout.FlexibleSpace(); GUILayout.BeginVertical(Array.Empty()); GUILayout.Label($"{item2.Value.Item2.Count} territories", _labelStyle, Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); if ((Object)(object)vaultItemSprite != (Object)null) { Rect rect = GUILayoutUtility.GetRect(18f, 20f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(18f), GUILayout.Height(20f) }); DrawSprite(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y + 2f, 18f, 18f), vaultItemSprite); } GUILayout.Label($"{item2.Value.Item3}", _labelStyle, Array.Empty()); GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); if (flag) { Rect lastRect = GUILayoutUtility.GetLastRect(); GUI.color = array[num - 1]; GUI.DrawTexture(new Rect(((Rect)(ref lastRect)).x, ((Rect)(ref lastRect)).y + 2f, 3f, ((Rect)(ref lastRect)).height - 4f), (Texture)(object)_pixelTex); GUI.color = Color.white; } GUILayout.Space(2f); num++; } } private void DrawVassals() { //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_04ce: Unknown result type (might be due to invalid IL or missing references) //IL_04d3: Unknown result type (might be due to invalid IL or missing references) //IL_04e9: Unknown result type (might be due to invalid IL or missing references) //IL_051a: 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_0468: Unknown result type (might be due to invalid IL or missing references) //IL_046d: Unknown result type (might be due to invalid IL or missing references) //IL_048e: Unknown result type (might be due to invalid IL or missing references) DrawSectionHeader("Vassals List"); LandlordData landlordData = TerritoryManager.Instance?.Data; if (landlordData == null) { GUILayout.Label("No data available.", _labelStyle, Array.Empty()); return; } Sprite vaultItemSprite = GetVaultItemSprite("Coins"); bool flag = false; foreach (Debt value2 in landlordData.Debts.Values) { if (value2.Amount > 0) { flag = true; bool isEscalated = value2.IsEscalated; Color color = (isEscalated ? new Color(0.9f, 0.3f, 0.1f, 0.7f) : new Color(0.8f, 0.6f, 0.2f, 0.5f)); GUILayout.BeginVertical(_boxStyle, Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("" + value2.DebtorName + "", _labelStyle, Array.Empty()); GUILayout.FlexibleSpace(); if ((Object)(object)vaultItemSprite != (Object)null) { Rect rect = GUILayoutUtility.GetRect(18f, 20f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(18f), GUILayout.Height(20f) }); DrawSprite(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y + 2f, 18f, 18f), vaultItemSprite); } GUILayout.Label($"{value2.Amount}", _labelStyle, Array.Empty()); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Owed to: " + value2.CreditorName, _labelStyle, Array.Empty()); GUILayout.FlexibleSpace(); GUILayout.Label($"Loot redirect: {value2.VassalLootPercent}%", _labelStyle, Array.Empty()); GUILayout.EndHorizontal(); if (isEscalated) { GUILayout.Label("ESCALATED - 30% loot redirected to lord", _labelRedStyle, Array.Empty()); } else { GUILayout.Label("Escalation in: " + value2.GetTimeRemainingString(), _labelStyle, Array.Empty()); } GUILayout.EndVertical(); Rect lastRect = GUILayoutUtility.GetLastRect(); GUI.color = color; GUI.DrawTexture(new Rect(((Rect)(ref lastRect)).x, ((Rect)(ref lastRect)).y + 2f, 3f, ((Rect)(ref lastRect)).height - 4f), (Texture)(object)_pixelTex); GUI.color = Color.white; GUILayout.Space(3f); } } if (!flag) { GUILayout.Label("No personal vassals.", _labelGreenStyle, Array.Empty()); } GUILayout.Space(12f); DrawSectionHeader("Odin's Wrath - Debt Contributors"); if (landlordData.GlobalDebtContributions != null && landlordData.GlobalDebtContributions.Count > 0) { List> list = new List>(landlordData.GlobalDebtContributions); list.Sort((KeyValuePair a, KeyValuePair b) => b.Value.CompareTo(a.Value)); int num = 1; { foreach (KeyValuePair item in list) { if (item.Value > 0) { string value; string text = (landlordData.GlobalDebtContributorNames.TryGetValue(item.Key, out value) ? value : "Unknown"); GUILayout.BeginVertical(_boxStyle, Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label($"#{num}", _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(28f) }); GUILayout.Label("" + text + "", _labelStyle, Array.Empty()); GUILayout.FlexibleSpace(); if ((Object)(object)vaultItemSprite != (Object)null) { Rect rect2 = GUILayoutUtility.GetRect(18f, 20f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(18f), GUILayout.Height(20f) }); DrawSprite(new Rect(((Rect)(ref rect2)).x, ((Rect)(ref rect2)).y + 2f, 18f, 18f), vaultItemSprite); } GUILayout.Label($"{item.Value} owed", _labelStyle, Array.Empty()); GUILayout.EndHorizontal(); GUILayout.EndVertical(); Rect lastRect2 = GUILayoutUtility.GetLastRect(); GUI.color = new Color(0.8f, 0.2f, 0.1f, 0.5f); GUI.DrawTexture(new Rect(((Rect)(ref lastRect2)).x, ((Rect)(ref lastRect2)).y + 2f, 3f, ((Rect)(ref lastRect2)).height - 4f), (Texture)(object)_pixelTex); GUI.color = Color.white; GUILayout.Space(2f); num++; } } return; } } GUILayout.Label("No global debt contributors.", _labelGreenStyle, Array.Empty()); } private void DrawAuctions() { DrawSectionHeader("Territory Auctions"); List list = AuctionManager.Instance?.GetActiveAuctions(); if (list == null || list.Count == 0) { GUILayout.Label("No active auctions.", _labelStyle, Array.Empty()); GUILayout.Space(8f); GUILayout.Label("Bankrupt territories will appear here for auction.", _labelStyle, Array.Empty()); return; } foreach (Auction item in list) { GUILayout.BeginVertical(_boxStyle, Array.Empty()); GUILayout.Label($"Territory ({item.TerritoryGridX}, {item.TerritoryGridY})", _labelGoldStyle, Array.Empty()); GUILayout.Label($"Current Bid: {item.CurrentBid} coins", _labelStyle, Array.Empty()); AuctionBid currentLeader = item.CurrentLeader; if (currentLeader != null) { GUILayout.Label("Highest Bidder: " + currentLeader.PlayerName, _labelStyle, Array.Empty()); } else { GUILayout.Label("No bids yet", _labelStyle, Array.Empty()); } GUILayout.Label("Time Left: " + item.GetTimeRemainingString(), _labelStyle, Array.Empty()); GUILayout.EndVertical(); GUILayout.Space(4f); } } private void DrawRaidLog() { DrawSectionHeader("Aurora Raid Log"); LandlordData landlordData = TerritoryManager.Instance?.Data; if (landlordData == null || landlordData.RaidLog == null || landlordData.RaidLog.Count == 0) { GUILayout.Label("No raids have been attempted yet.", _labelStyle, Array.Empty()); return; } GUILayout.Label($"Total raids: {landlordData.RaidLog.Count}", _labelStyle, Array.Empty()); GUILayout.Space(4f); for (int num = landlordData.RaidLog.Count - 1; num >= 0; num--) { RaidLogEntry raidLogEntry = landlordData.RaidLog[num]; string text = (raidLogEntry.Success ? "#00ff00" : "#ff4444"); string text2 = (raidLogEntry.Success ? "SUCCESS" : "FAILED"); string text3 = DateTimeOffset.FromUnixTimeSeconds(raidLogEntry.Timestamp).LocalDateTime.ToString("MM/dd HH:mm"); GUILayout.BeginVertical(_boxStyle, Array.Empty()); GUILayout.Label("[" + text3 + "] " + text2 + "", _labelStyle, Array.Empty()); GUILayout.Label(raidLogEntry.RaiderName + " raided " + raidLogEntry.OwnerName + "'s " + raidLogEntry.TerritoryName + " with " + raidLogEntry.KeyType + " Key", _labelStyle, Array.Empty()); if (raidLogEntry.Success && !string.IsNullOrEmpty(raidLogEntry.ItemsSummary)) { GUILayout.Label(" Loot: " + raidLogEntry.ItemsSummary + "", _labelStyle, Array.Empty()); } GUILayout.EndVertical(); GUILayout.Space(2f); } } private void DrawHelp() { DrawSectionHeader("Guide"); GUILayout.BeginVertical(_boxStyle, Array.Empty()); GUILayout.Label("Getting Started", _labelGoldStyle, Array.Empty()); GUILayout.Label("Open the map (M) to see the territory grid across the world. Click any unclaimed cell to open the claim panel and pay coins to make it yours. You must be standing inside the territory to claim it.", _labelStyle, Array.Empty()); GUILayout.EndVertical(); GUILayout.Space(4f); GUILayout.BeginVertical(_boxStyle, Array.Empty()); GUILayout.Label("Territories & Rent", _labelGoldStyle, Array.Empty()); GUILayout.Label("Once you own a territory, you must pay rent every 7 days by completing objectives (kill monsters, gather resources, or pay coins). Check the Your Land tab to see what's needed. If rent expires, your territory goes to auction.", _labelStyle, Array.Empty()); GUILayout.EndVertical(); GUILayout.Space(4f); GUILayout.BeginVertical(_boxStyle, Array.Empty()); GUILayout.Label("Tolls & Income", _labelGoldStyle, Array.Empty()); GUILayout.Label("Players crossing your territory pay a toll based on the biome (harder biomes cost more). Merchant territories earn double. Tolls are paid once per border crossing with a 1-hour cooldown. Your accumulated income can be withdrawn from the Your Land tab.", _labelStyle, Array.Empty()); GUILayout.EndVertical(); GUILayout.Space(4f); GUILayout.BeginVertical(_boxStyle, Array.Empty()); GUILayout.Label("Debt & Vassalage", _labelRedStyle, Array.Empty()); GUILayout.Label("Can't pay a toll? You become a vassal to the territory owner. 10% of items you pick up are redirected to your lord. After 7 days unpaid, this escalates to 30%. Pay off your debt to break free. Check the Vassals tab for details.", _labelStyle, Array.Empty()); GUILayout.EndVertical(); GUILayout.Space(4f); GUILayout.BeginVertical(_boxStyle, Array.Empty()); GUILayout.Label("Odin's Wrath (Global Debt)", _labelRedStyle, Array.Empty()); GUILayout.Label("Unpaid tolls in unclaimed territories anger Odin. Every 5000 coins of global debt adds +1 star level to all monsters on the server. Keep coins on you, or the whole world suffers!", _labelStyle, Array.Empty()); GUILayout.EndVertical(); GUILayout.Space(4f); GUILayout.BeginVertical(_boxStyle, Array.Empty()); GUILayout.Label("Vault Raiding", _labelGoldStyle, Array.Empty()); GUILayout.Label("Territory owners can set a loot tax (0-20%). Taxed items go into the territory vault. Other players can raid vaults using keys dropped by monsters. Stand on someone's territory and open the Vault Raid window to try your luck.", _labelStyle, Array.Empty()); GUILayout.Space(4f); GUILayout.Label("Bronze Key: 25% success, 1 stack | Silver Key: 50%, up to 2 stacks | Gold Key: 75%, up to 3 stacks", _labelStyle, Array.Empty()); GUILayout.EndVertical(); GUILayout.Space(4f); GUILayout.BeginVertical(_boxStyle, Array.Empty()); GUILayout.Label("Territory Settings", _labelGoldStyle, Array.Empty()); GUILayout.Label("In the Your Land tab you can toggle PvP, adjust loot tax, rename your territory, and withdraw vault items or income.", _labelStyle, Array.Empty()); GUILayout.EndVertical(); GUILayout.Space(4f); GUILayout.BeginVertical(_boxStyle, Array.Empty()); GUILayout.Label("Emperor Mode", _labelGoldStyle, Array.Empty()); GUILayout.Label("Defeat all bosses to unlock additional territory slots. Claim 10 territories with all bosses defeated to become Emperor: no rent, boosted loot tax, and your territories become permanent.", _labelStyle, Array.Empty()); GUILayout.EndVertical(); GUILayout.Space(4f); GUILayout.BeginVertical(_boxStyle, Array.Empty()); GUILayout.Label("New Player Protection", _labelGoldStyle, Array.Empty()); GUILayout.Label("New characters receive toll immunity for their first day on the server. Use this time to explore and gather coins before the economy kicks in.", _labelStyle, Array.Empty()); GUILayout.EndVertical(); GUILayout.Space(8f); DrawSeparator(); GUILayout.Space(4f); if ((Object)(object)ExplorationTracker.Instance != (Object)null) { int exploredTileCount = ExplorationTracker.Instance.ExploredTileCount; GUILayout.Label($"Tiles Explored: {exploredTileCount}", _labelStyle, Array.Empty()); } } private void DrawVaultItemGrid(List vault) { //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Expected O, but got Unknown //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) if (vault == null || vault.Count == 0) { GUILayout.Label(" Empty", _labelStyle, Array.Empty()); return; } int num = 48; int num2 = 4; int num3 = (int)((((Rect)(ref _windowRect)).width - 60f) / (float)(num + num2)); if (num3 < 1) { num3 = 1; } int num4 = 0; int num5 = 0; GUILayout.BeginHorizontal(Array.Empty()); Rect position = default(Rect); foreach (VaultItem item in vault) { if (num4 >= num3) { GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty()); num4 = 0; } Rect rect = GUILayoutUtility.GetRect((float)num, (float)num, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width((float)num), GUILayout.Height((float)num) }); GUI.color = new Color(0.12f, 0.1f, 0.07f, 0.9f); GUI.DrawTexture(rect, (Texture)(object)_pixelTex); GUI.color = new Color(0.35f, 0.28f, 0.18f, 0.8f); GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, 1f), (Texture)(object)_pixelTex); GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).yMax - 1f, ((Rect)(ref rect)).width, 1f), (Texture)(object)_pixelTex); GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, 1f, ((Rect)(ref rect)).height), (Texture)(object)_pixelTex); GUI.DrawTexture(new Rect(((Rect)(ref rect)).xMax - 1f, ((Rect)(ref rect)).y, 1f, ((Rect)(ref rect)).height), (Texture)(object)_pixelTex); GUI.color = Color.white; Sprite vaultItemSprite = GetVaultItemSprite(item.PrefabName); if ((Object)(object)vaultItemSprite != (Object)null) { ((Rect)(ref position))..ctor(((Rect)(ref rect)).x + 4f, ((Rect)(ref rect)).y + 4f, ((Rect)(ref rect)).width - 8f, ((Rect)(ref rect)).height - 8f); DrawSprite(position, vaultItemSprite); } if (_highlightVaultIndex == num5) { GUI.color = new Color(1f, 0.85f, 0f, 0.3f + 0.15f * Mathf.Sin(Time.time * 8f)); GUI.DrawTexture(rect, (Texture)(object)_pixelTex); GUI.color = Color.white; } if (item.Amount > 1) { GUIStyle val = new GUIStyle(_labelStyle); val.fontSize = 11; val.alignment = (TextAnchor)8; val.normal.textColor = Color.white; val.fontStyle = (FontStyle)1; GUI.Label(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width - 3f, ((Rect)(ref rect)).height - 2f), item.Amount.ToString(), val); } if (((Rect)(ref rect)).Contains(Event.current.mousePosition)) { _vaultHoverItem = item; _vaultHoverPos = Event.current.mousePosition; } num4++; num5++; } GUILayout.EndHorizontal(); } private Sprite GetVaultItemSprite(string prefabName) { if (string.IsNullOrEmpty(prefabName)) { return null; } if (_spriteCache.TryGetValue(prefabName, out var value)) { return value; } Sprite val = null; try { ObjectDB instance = ObjectDB.instance; GameObject val2 = ((instance != null) ? instance.GetItemPrefab(prefabName) : null); if ((Object)(object)val2 != (Object)null) { ItemDrop component = val2.GetComponent(); if (component?.m_itemData?.m_shared?.m_icons != null && component.m_itemData.m_shared.m_icons.Length != 0) { val = component.m_itemData.m_shared.m_icons[0]; } } } catch { } if ((Object)(object)val == (Object)null) { for (int i = 0; i < VaultKeySetup.PrefabNames.Length; i++) { if (!(prefabName == VaultKeySetup.PrefabNames[i])) { continue; } string[] array = new string[3] { "HildirKey_forestcrypt", "HildirKey_mountaincave", "HildirKey_plainsfortress" }; if (i >= array.Length) { break; } ObjectDB instance2 = ObjectDB.instance; GameObject val3 = ((instance2 != null) ? instance2.GetItemPrefab(array[i]) : null); if ((Object)(object)val3 != (Object)null) { ItemDrop component2 = val3.GetComponent(); if (component2?.m_itemData?.m_shared?.m_icons != null && component2.m_itemData.m_shared.m_icons.Length != 0) { val = component2.m_itemData.m_shared.m_icons[0]; } } break; } } if ((Object)(object)val != (Object)null) { _spriteCache[prefabName] = val; } return val; } private void DrawVaultTooltipIfNeeded() { //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) if (_vaultHoverItem == null) { return; } string displayName = _vaultHoverItem.DisplayName; string text = $"Amount: {_vaultHoverItem.Amount}"; try { ObjectDB instance = ObjectDB.instance; GameObject val = ((instance != null) ? instance.GetItemPrefab(_vaultHoverItem.PrefabName) : null); if ((Object)(object)val != (Object)null) { ItemDrop component = val.GetComponent(); if (component?.m_itemData?.m_shared != null) { Localization instance2 = Localization.instance; string text2 = ((instance2 != null) ? instance2.Localize(component.m_itemData.m_shared.m_description) : null) ?? ""; if (!string.IsNullOrEmpty(text2)) { text = text + "\n" + text2; } } } } catch { } float num = 250f; float num2 = (string.IsNullOrEmpty(text) ? 40f : 80f); Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(_vaultHoverPos.x + 15f, _vaultHoverPos.y - 10f, num, num2); if (((Rect)(ref val2)).xMax > ((Rect)(ref _windowRect)).width) { ((Rect)(ref val2)).x = _vaultHoverPos.x - num - 5f; } if (((Rect)(ref val2)).yMax > ((Rect)(ref _windowRect)).height) { ((Rect)(ref val2)).y = _vaultHoverPos.y - num2 - 5f; } GUI.Box(val2, "", _boxStyle); GUI.Label(new Rect(((Rect)(ref val2)).x + 8f, ((Rect)(ref val2)).y + 4f, num - 16f, 20f), "" + displayName + "", _labelStyle); GUI.Label(new Rect(((Rect)(ref val2)).x + 8f, ((Rect)(ref val2)).y + 22f, num - 16f, num2 - 26f), text, _labelStyle); _vaultHoverItem = null; } private void DrawRentHeader() { //IL_0051: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Required Rent", _labelStyle, Array.Empty()); GUILayout.Space(2f); GUILayout.Label("(?)", _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(22f) }); Rect lastRect = GUILayoutUtility.GetLastRect(); if (((Rect)(ref lastRect)).Contains(Event.current.mousePosition)) { _rentTooltipActive = true; _rentTooltipPos = Event.current.mousePosition; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } private void DrawRentTooltipIfNeeded() { //IL_00e3: 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_010f: 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) //IL_0165: 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_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: 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_01ea: Expected O, but got Unknown //IL_0231: Unknown result type (might be due to invalid IL or missing references) if (_rentTooltipActive) { _rentTooltipActive = false; string text = "Rent is due every 7 days. Complete all\nobjectives below to keep your territory.\nIf the timer runs out, your territory goes\nto auction!"; float num = 280f; float num2 = 60f; Rect val = default(Rect); ((Rect)(ref val))..ctor(_rentTooltipPos.x + 15f, _rentTooltipPos.y - 5f, num, num2); if (((Rect)(ref val)).xMax > ((Rect)(ref _windowRect)).width - 10f) { ((Rect)(ref val)).x = _rentTooltipPos.x - num - 5f; } if (((Rect)(ref val)).yMax > ((Rect)(ref _windowRect)).height - 10f) { ((Rect)(ref val)).y = _rentTooltipPos.y - num2 - 5f; } GUI.color = new Color(0.08f, 0.06f, 0.04f, 0.95f); GUI.DrawTexture(val, (Texture)(object)_pixelTex); GUI.color = new Color(0.7f, 0.55f, 0.2f, 0.8f); GUI.DrawTexture(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y, ((Rect)(ref val)).width, 1f), (Texture)(object)_pixelTex); GUI.DrawTexture(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).yMax - 1f, ((Rect)(ref val)).width, 1f), (Texture)(object)_pixelTex); GUI.DrawTexture(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y, 1f, ((Rect)(ref val)).height), (Texture)(object)_pixelTex); GUI.DrawTexture(new Rect(((Rect)(ref val)).xMax - 1f, ((Rect)(ref val)).y, 1f, ((Rect)(ref val)).height), (Texture)(object)_pixelTex); GUI.color = Color.white; GUIStyle val2 = new GUIStyle(_labelStyle); val2.fontSize = 11; val2.wordWrap = true; GUI.Label(new Rect(((Rect)(ref val)).x + 8f, ((Rect)(ref val)).y + 5f, ((Rect)(ref val)).width - 16f, ((Rect)(ref val)).height - 10f), text, val2); } } private Sprite GetObjectiveSprite(TerritoryObjective obj) { if (obj == null || string.IsNullOrEmpty(obj.TargetPrefab)) { return null; } if ((Object)(object)ObjectDB.instance == (Object)null) { return null; } string targetPrefab = obj.TargetPrefab; if (_spriteCache.TryGetValue(targetPrefab, out var value)) { return value; } Sprite val = null; try { string[] array = ((obj.Type != 0) ? new string[1] { targetPrefab } : new string[2] { "Trophy" + targetPrefab, targetPrefab }); string[] array2 = array; foreach (string text in array2) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(text); if ((Object)(object)itemPrefab == (Object)null) { continue; } ItemDrop component = itemPrefab.GetComponent(); if (component?.m_itemData?.m_shared?.m_icons != null && component.m_itemData.m_shared.m_icons.Length != 0) { val = component.m_itemData.m_shared.m_icons[0]; if ((Object)(object)val != (Object)null) { break; } } } } catch { } if ((Object)(object)val != (Object)null) { _spriteCache[targetPrefab] = val; } return val; } private void DrawSprite(Rect position, Sprite sprite) { //IL_0022: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)sprite == (Object)null) && !((Object)(object)sprite.texture == (Object)null)) { Rect textureRect = sprite.textureRect; float num = ((Texture)sprite.texture).width; float num2 = ((Texture)sprite.texture).height; Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref textureRect)).x / num, ((Rect)(ref textureRect)).y / num2, ((Rect)(ref textureRect)).width / num, ((Rect)(ref textureRect)).height / num2); GUI.DrawTextureWithTexCoords(position, (Texture)(object)sprite.texture, val); } } public void Show() { _isVisible = true; } public void Hide() { _isVisible = false; } public void Toggle() { _isVisible = !_isVisible; } public static bool ShouldBlockInput() { return (Object)(object)Instance != (Object)null && (Instance._isVisible || Instance._isRaiding || Instance._showRaidWindow); } private string GetRaidSuccessMessage(string ownerName, List results) { if (results == null || results.Count == 0) { return "The vault was empty... nothing to take."; } string arg = string.Join(", ", results.ConvertAll((VaultItem r) => $"{r.Amount}x {r.DisplayName}")); string[] array = new string[8] { "You have successfully nicked {0} from {1}'s vault!", "A swift hand and a bit of luck! You swiped {0} from {1}!", "The vault crumbles before you! {0} now belongs to you, courtesy of {1}.", "{1} won't be happy... you've made off with {0}!", "Odin smiles upon your boldness! You claimed {0} from {1}'s hoard!", "Under cover of chaos, you pocketed {0} from {1}'s vault!", "The lock gives way! {0} liberated from {1}'s greedy clutches!", "A daring heist! You escaped with {0} from {1}'s coffers!" }; int num = Random.Range(0, array.Length); string text = string.Format(array[num], arg, ownerName); return "" + text + ""; } private string GetRaidTip() { string[] array = new string[18] { "Toll rates vary by biome. The deeper you venture, the more it costs to pass.", "Territory owners earn coins from every player who crosses their land.", "Odin's Wrath grows when debts go unpaid. Monsters across the world grow stronger!", "Gold keys have a 75% success rate and can pull up to 3 item stacks from vaults!", "Silver keys are balanced: 50% success with up to 2 stacks. A solid middle ground.", "Bronze keys are common drops but unreliable: only 25% chance to crack a vault.", "Setting a loot tax stores a cut of items visitors pick up in your vault.", "Check the Leaderboard in the F4 panel to see who dominates the land.", "New players enjoy toll immunity for their first day on the server.", "Merchant territories see heavy traffic. High tolls there mean steady income.", "Keep coins on you when traveling! Unpaid tolls become debts that follow you.", "Territory names are generated from Viking lore based on the local biome.", "The world spawn zone is neutral ground. No one can claim the land around it.", "You can enable PvP on your territory to defend it from unwanted visitors.", "Raid duration increases with territory prestige. Higher prestige = longer raids.", "Silver key raids take 25% longer. Gold key raids take 50% longer.", "All raid attempts are logged. Check the Raid Log tab to see server history.", "Completing rent objectives on time prevents your territory from going to auction." }; int num = Mathf.FloorToInt(Time.time / 12f) % array.Length; return array[num]; } private void OnDestroy() { if ((Object)(object)_pixelTex != (Object)null) { Object.Destroy((Object)(object)_pixelTex); } if ((Object)(object)_panelBg != (Object)null) { Object.Destroy((Object)(object)_panelBg); } if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } } public class MapGridOverlay : MonoBehaviour { private Vector2i? _selectedCell = null; private bool _showClaimPanel = false; private Texture2D _pixelTex; private GUIStyle _panelStyle; private GUIStyle _headerStyle; private GUIStyle _labelStyle; private GUIStyle _buttonStyle; private GUIStyle _closeButtonStyle; private GUIStyle _tooltipTitleStyle; private GUIStyle _tooltipDetailStyle; private bool _stylesInit = false; private Vector2 _mouseDownPos; private bool _isDragging; private int _closeCooldown = 0; private Vector2i? _cachedHighlightRegion = null; private Texture2D _highlightTex = null; private Rect _highlightWorldBounds; private float _lastZoom = -1f; private Vector2i? _stableHoveredCell = null; private int _hoverStableFrames = 0; private int _frameSkip = 0; private Vector2i? _lastLookupResult = null; private List _cachedScreenPoints = new List(); private float _lastMapPanX = float.MinValue; private float _lastMapPanY = float.MinValue; private float _lastMapZoom2 = float.MinValue; private List _cachedBorderWorldPoints = new List(); public static MapGridOverlay Instance { get; private set; } private float WorldRadius => LandlordConfig.WorldRadius?.Value ?? 10500f; private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)this); return; } Instance = this; Plugin.Log.LogInfo((object)"Map overlay initialized (Voronoi mode)"); } private void Update() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Minimap.instance == (Object)null || (int)Minimap.instance.m_mode != 2) { _showClaimPanel = false; _selectedCell = null; _isDragging = false; return; } if (_closeCooldown > 0) { _closeCooldown--; } if (Input.GetMouseButtonDown(0)) { _mouseDownPos = Vector2.op_Implicit(Input.mousePosition); _isDragging = false; } if (Input.GetMouseButton(0) && Vector2.Distance(_mouseDownPos, Vector2.op_Implicit(Input.mousePosition)) > 10f) { _isDragging = true; } if (!_isDragging && Input.GetMouseButtonUp(0) && _closeCooldown == 0) { Vector2i? cellUnderMouse = GetCellUnderMouse(); if (cellUnderMouse.HasValue) { _selectedCell = cellUnderMouse; _showClaimPanel = true; } } } private void ClosePanel() { _showClaimPanel = false; _selectedCell = null; _closeCooldown = 10; } private Vector2 WorldToMapPoint(Vector3 worldPos) { //IL_0018: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) float num = Minimap.instance.m_textureSize; float pixelSize = Minimap.instance.m_pixelSize; float num2 = (worldPos.x / pixelSize + num / 2f) / num; float num3 = (worldPos.z / pixelSize + num / 2f) / num; return new Vector2(num2, num3); } private Vector3 MapPointToWorld(Vector2 mapPoint) { //IL_0018: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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) float num = Minimap.instance.m_textureSize; float pixelSize = Minimap.instance.m_pixelSize; float num2 = (mapPoint.x * num - num / 2f) * pixelSize; float num3 = (mapPoint.y * num - num / 2f) * pixelSize; return new Vector3(num2, 0f, num3); } private Vector2? WorldToScreenGUI(float worldX, float worldZ) { //IL_0054: 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_0062: 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_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) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Minimap.instance == (Object)null) { return null; } RawImage mapImageLarge = Minimap.instance.m_mapImageLarge; if ((Object)(object)mapImageLarge == (Object)null) { return null; } RectTransform component = ((Component)mapImageLarge).GetComponent(); Rect uvRect = mapImageLarge.uvRect; Vector2 val = WorldToMapPoint(new Vector3(worldX, 0f, worldZ)); float num = (val.x - ((Rect)(ref uvRect)).x) / ((Rect)(ref uvRect)).width; float num2 = (val.y - ((Rect)(ref uvRect)).y) / ((Rect)(ref uvRect)).height; if (num < -0.1f || num > 1.1f || num2 < -0.1f || num2 > 1.1f) { return null; } Vector3[] array = (Vector3[])(object)new Vector3[4]; component.GetWorldCorners(array); float num3 = Mathf.Lerp(array[0].x, array[2].x, num); float num4 = Mathf.Lerp(array[0].y, array[2].y, num2); return new Vector2(num3, (float)Screen.height - num4); } private Vector3? ScreenGUIToWorld(Vector2 guiPos) { //IL_0054: 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_005a: 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_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Minimap.instance == (Object)null) { return null; } RawImage mapImageLarge = Minimap.instance.m_mapImageLarge; if ((Object)(object)mapImageLarge == (Object)null) { return null; } RectTransform component = ((Component)mapImageLarge).GetComponent(); Rect uvRect = mapImageLarge.uvRect; float x = guiPos.x; float num = (float)Screen.height - guiPos.y; Vector3[] array = (Vector3[])(object)new Vector3[4]; component.GetWorldCorners(array); if (x < array[0].x || x > array[2].x || num < array[0].y || num > array[2].y) { return null; } float num2 = (x - array[0].x) / (array[2].x - array[0].x); float num3 = (num - array[0].y) / (array[2].y - array[0].y); float num4 = ((Rect)(ref uvRect)).x + num2 * ((Rect)(ref uvRect)).width; float num5 = ((Rect)(ref uvRect)).y + num3 * ((Rect)(ref uvRect)).height; return MapPointToWorld(new Vector2(num4, num5)); } private Vector2i WorldToGridCell(Vector3 worldPos) { //IL_0006: 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_000c: 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) return VoronoiGrid.Instance.GetRegion(worldPos); } private Vector2i? GetCellUnderMouse() { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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) Vector2 guiPos = default(Vector2); ((Vector2)(ref guiPos))..ctor(Input.mousePosition.x, (float)Screen.height - Input.mousePosition.y); Vector3? val = ScreenGUIToWorld(guiPos); if (!val.HasValue) { return null; } float num = Mathf.Sqrt(val.Value.x * val.Value.x + val.Value.z * val.Value.z); if (num > WorldRadius) { return null; } return WorldToGridCell(val.Value); } private void OnGUI() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_011c: 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_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Minimap.instance == (Object)null || (int)Minimap.instance.m_mode != 2) { return; } InitStyles(); _frameSkip++; if (_frameSkip >= 3) { _frameSkip = 0; _lastLookupResult = GetCellUnderMouse(); } Vector2i? lastLookupResult = _lastLookupResult; if (lastLookupResult.HasValue) { if (!_stableHoveredCell.HasValue || _stableHoveredCell.Value.x != lastLookupResult.Value.x || _stableHoveredCell.Value.y != lastLookupResult.Value.y) { _hoverStableFrames++; if (_hoverStableFrames > 3) { _stableHoveredCell = lastLookupResult; _hoverStableFrames = 0; } } else { _hoverStableFrames = 0; } Vector2i val = (Vector2i)(((??)_stableHoveredCell) ?? lastLookupResult.Value); DrawRegionBorder(val, new Color(1f, 0.85f, 0.3f, 0.85f)); DrawCellTooltip(val); } else { _stableHoveredCell = null; _hoverStableFrames = 0; } if (_showClaimPanel && _selectedCell.HasValue) { DrawClaimPanel(_selectedCell.Value); } } private void InitStyles() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_0025: 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_0051: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Expected O, but got Unknown //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Expected O, but got Unknown //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Expected O, but got Unknown //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Expected O, but got Unknown //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Expected O, but got Unknown //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Expected O, but got Unknown //IL_026a: Unknown result type (might be due to invalid IL or missing references) if (!_stylesInit) { _pixelTex = new Texture2D(1, 1); _pixelTex.SetPixel(0, 0, Color.white); _pixelTex.Apply(); _panelStyle = new GUIStyle(GUI.skin.box); _panelStyle.normal.background = MakeTex(2, 2, new Color(0.1f, 0.1f, 0.1f, 0.95f)); _panelStyle.padding = new RectOffset(15, 15, 10, 10); _headerStyle = new GUIStyle(GUI.skin.label); _headerStyle.fontSize = 18; _headerStyle.fontStyle = (FontStyle)1; _headerStyle.normal.textColor = new Color(1f, 0.85f, 0.4f); _headerStyle.alignment = (TextAnchor)4; _labelStyle = new GUIStyle(GUI.skin.label); _labelStyle.fontSize = 14; _labelStyle.normal.textColor = Color.white; _labelStyle.richText = true; _labelStyle.wordWrap = true; _buttonStyle = new GUIStyle(GUI.skin.button); _buttonStyle.fontSize = 14; _buttonStyle.normal.textColor = Color.white; _buttonStyle.padding = new RectOffset(10, 10, 6, 6); _closeButtonStyle = new GUIStyle(GUI.skin.button); _closeButtonStyle.fontSize = 16; _closeButtonStyle.fontStyle = (FontStyle)1; _closeButtonStyle.normal.textColor = Color.white; _tooltipTitleStyle = new GUIStyle(GUI.skin.label); _tooltipTitleStyle.fontSize = 14; _tooltipTitleStyle.fontStyle = (FontStyle)1; _tooltipTitleStyle.normal.textColor = new Color(1f, 0.85f, 0.4f); _tooltipDetailStyle = new GUIStyle(GUI.skin.label); _tooltipDetailStyle.fontSize = 12; _tooltipDetailStyle.normal.textColor = Color.white; _tooltipDetailStyle.richText = true; _stylesInit = true; } } private Texture2D MakeTex(int width, int height, Color col) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //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_002c: Expected O, but got Unknown Color[] array = (Color[])(object)new Color[width * height]; for (int i = 0; i < array.Length; i++) { array[i] = col; } Texture2D val = new Texture2D(width, height); val.SetPixels(array); val.Apply(); return val; } private void DrawRegionMarker(Vector2i regionId, Color color, float size) { //IL_0006: 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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_0041: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) Vector3 regionCenter = VoronoiGrid.Instance.GetRegionCenter(regionId); Vector2? val = WorldToScreenGUI(regionCenter.x, regionCenter.z); if (val.HasValue) { GUI.color = color; float num = size / 2f; GUI.DrawTexture(new Rect(val.Value.x - num, val.Value.y - num, size, size), (Texture)(object)_pixelTex); GUI.color = Color.white; } } private void DrawPlayerCellMarker() { //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) //IL_0023: 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_0029: 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_0040: 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; Vector2i regionId = WorldToGridCell(position); DrawRegionMarker(regionId, new Color(0.3f, 0.8f, 0.3f, 0.4f), 10f); } } private void DrawRegionBorder(Vector2i regionId, Color color) { //IL_0014: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: 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_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_017c: 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_0204: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) if (!_cachedHighlightRegion.HasValue || _cachedHighlightRegion.Value.x != regionId.x || _cachedHighlightRegion.Value.y != regionId.y) { BuildBorderWorldPoints(regionId); _cachedHighlightRegion = regionId; _lastMapPanX = float.MinValue; } if (_cachedBorderWorldPoints == null || _cachedBorderWorldPoints.Count < 3) { return; } Rect uvRect = Minimap.instance.m_mapImageLarge.uvRect; if (Mathf.Abs(((Rect)(ref uvRect)).x - _lastMapPanX) > 0.0001f || Mathf.Abs(((Rect)(ref uvRect)).y - _lastMapPanY) > 0.0001f || Mathf.Abs(((Rect)(ref uvRect)).width - _lastMapZoom2) > 0.0001f) { _lastMapPanX = ((Rect)(ref uvRect)).x; _lastMapPanY = ((Rect)(ref uvRect)).y; _lastMapZoom2 = ((Rect)(ref uvRect)).width; _cachedScreenPoints.Clear(); for (int i = 0; i < _cachedBorderWorldPoints.Count; i++) { Vector2 val = _cachedBorderWorldPoints[i]; Vector2? val2 = WorldToScreenGUI(val.x, val.y); _cachedScreenPoints.Add((Vector2)(((??)val2) ?? new Vector2(-9999f, -9999f))); } } if (_cachedScreenPoints.Count < 3) { return; } GUI.color = color; for (int j = 0; j < _cachedScreenPoints.Count; j++) { Vector2 val3 = _cachedScreenPoints[j]; Vector2 val4 = _cachedScreenPoints[(j + 1) % _cachedScreenPoints.Count]; if (!(val3.x < -9000f) && !(val4.x < -9000f)) { DrawLineSimple(val3, val4, 2f); } } GUI.color = Color.white; } private void DrawLineSimple(Vector2 a, Vector2 b, float thickness) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_0040: 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_004d: 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_006e: Unknown result type (might be due to invalid IL or missing references) Vector2 val = b - a; float magnitude = ((Vector2)(ref val)).magnitude; if (!(magnitude < 0.5f)) { float num = Mathf.Atan2(val.y, val.x) * 57.29578f; Matrix4x4 matrix = GUI.matrix; GUIUtility.RotateAroundPivot(num, a); GUI.DrawTexture(new Rect(a.x, a.y - thickness * 0.5f, magnitude, thickness), (Texture)(object)_pixelTex); GUI.matrix = matrix; } } private void BuildBorderWorldPoints(Vector2i regionId) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_0081: 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_00ab: 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) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0125: 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_012f: 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_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) _cachedBorderWorldPoints.Clear(); Vector3 regionCenter = VoronoiGrid.Instance.GetRegionCenter(regionId); float num = VoronoiGrid.Instance.GetApproximateRegionRadius(regionId) * 4f; if (num < 2000f) { num = 2000f; } int num2 = 90; float num3 = (float)Math.PI * 2f / (float)num2; for (int i = 0; i < num2; i++) { float num4 = (float)i * num3; float num5 = Mathf.Cos(num4); float num6 = Mathf.Sin(num4); float num7 = 30f; float num8 = num; for (float num9 = num7; num9 < num; num9 += num7) { float num10 = regionCenter.x + num5 * num9; float num11 = regionCenter.z + num6 * num9; Vector2i region = VoronoiGrid.Instance.GetRegion(new Vector3(num10, 0f, num11)); if (region.x == regionId.x && region.y == regionId.y) { continue; } float num12 = num9 - num7; float num13 = num9; for (int j = 0; j < 5; j++) { float num14 = (num12 + num13) * 0.5f; Vector2i region2 = VoronoiGrid.Instance.GetRegion(new Vector3(regionCenter.x + num5 * num14, 0f, regionCenter.z + num6 * num14)); if (region2.x == regionId.x && region2.y == regionId.y) { num12 = num14; } else { num13 = num14; } } num8 = (num12 + num13) * 0.5f; break; } float num15 = regionCenter.x + num5 * num8; float num16 = regionCenter.z + num6 * num8; float num17 = Mathf.Sqrt(num15 * num15 + num16 * num16); if (num17 > WorldRadius) { num15 *= WorldRadius / num17; num16 *= WorldRadius / num17; } _cachedBorderWorldPoints.Add(new Vector2(num15, num16)); } } private void DrawCellTooltip(Vector2i cell) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_0081: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: 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) Vector2 value = default(Vector2); ((Vector2)(ref value))..ctor(Input.mousePosition.x, (float)Screen.height - Input.mousePosition.y); Vector2? val = value; bool flag = IsCellExplored(cell); Territory territory = TerritoryManager.Instance?.GetTerritory(cell); bool flag2 = false; if ((Object)(object)Player.m_localPlayer != (Object)null) { Vector2i val2 = WorldToGridCell(((Component)Player.m_localPlayer).transform.position); flag2 = val2.x == cell.x && val2.y == cell.y; } string text; string text2; if (VoronoiGrid.Instance.IsSpawnZone(cell)) { text = "Spawn Zone"; text2 = "Neutral territory\nNo tolls, no claims"; } else if (!flag) { text = "? ? ? ? ? ?"; text2 = "Unexplored territory\nExplore to reveal"; } else if (territory != null) { text = territory.DisplayName; text2 = territory.OwnerName + "'s land"; } else { text = GridUtils.GetTerritoryName(cell); text2 = "Unclaimed\nClick to claim"; } string text3 = (flag2 ? "You are here" : ""); float num = 260f; float num2 = 95f; float num3 = val.Value.x + 20f; float num4 = val.Value.y - num2 / 2f; num3 = Mathf.Clamp(num3, 10f, (float)Screen.width - num - 10f); num4 = Mathf.Clamp(num4, 10f, (float)Screen.height - num2 - 10f); GUI.Box(new Rect(num3 - 5f, num4 - 5f, num + 10f, num2 + 10f), "", _panelStyle); GUI.Label(new Rect(num3, num4, num, 22f), text, _tooltipTitleStyle); GUI.Label(new Rect(num3, num4 + 22f, num, 40f), text2, _tooltipDetailStyle); if (!string.IsNullOrEmpty(text3)) { GUI.Label(new Rect(num3, num4 + 58f, num, 22f), text3, _tooltipDetailStyle); } } private bool IsCellExplored(Vector2i cell) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_004a: 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_0058: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ExplorationTracker.Instance != (Object)null) { return ExplorationTracker.Instance.IsTileExplored(cell); } if ((Object)(object)Player.m_localPlayer != (Object)null) { Vector2i val = GridUtils.WorldToVisualGrid(((Component)Player.m_localPlayer).transform.position); if (val.x == cell.x && val.y == cell.y) { return true; } } return false; } private void DrawClaimPanel(Vector2i cell) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: 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) //IL_0101: Unknown result type (might be due to invalid IL or missing references) float num = 380f; float num2 = 400f; float num3 = ((float)Screen.width - num) / 2f; float num4 = ((float)Screen.height - num2) / 2f; Rect val = default(Rect); ((Rect)(ref val))..ctor(num3, num4, num, num2); GUI.Box(val, "", _panelStyle); GUILayout.BeginArea(new Rect(num3 + 15f, num4 + 10f, num - 30f, num2 - 20f)); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.FlexibleSpace(); GUILayout.Label("Territory", _headerStyle, Array.Empty()); GUILayout.FlexibleSpace(); if (GUILayout.Button("X", _closeButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) })) { ClosePanel(); } GUILayout.EndHorizontal(); GUILayout.Space(15f); Territory territory = TerritoryManager.Instance?.GetTerritory(cell); if (territory != null) { DrawOwnedTerritoryInfo(territory, cell); } else { DrawUnclaimedTerritoryInfo(cell); } GUILayout.EndArea(); } private void DrawOwnedTerritoryInfo(Territory territory, Vector2i cell) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) GUILayout.Label("" + territory.DisplayName + "", _headerStyle, Array.Empty()); GUILayout.Space(5f); GUILayout.Label("Owner: " + territory.OwnerName, _labelStyle, Array.Empty()); GUILayout.Space(5f); string biomeCompositionString = GridUtils.GetBiomeCompositionString(cell); GUILayout.Label("Biomes: " + biomeCompositionString, _labelStyle, Array.Empty()); int num = territory.CalculateToll(); GUILayout.Label($"Toll: {num} coins", _labelStyle, Array.Empty()); if (territory.HasMerchant) { GUILayout.Label("Merchant Territory", _labelStyle, Array.Empty()); } if (territory.IsEmperorTerritory) { GUILayout.Label("EMPEROR TERRITORY", _labelStyle, Array.Empty()); } if (territory.IsPvPEnabled) { GUILayout.Label("PvP Zone", _labelStyle, Array.Empty()); } if (territory.LootTaxPercent > 0) { GUILayout.Label($"Loot Tax: {territory.LootTaxPercent}%", _labelStyle, Array.Empty()); } GUILayout.Space(20f); if (!((Object)(object)Player.m_localPlayer != (Object)null)) { return; } long playerID = Player.m_localPlayer.GetPlayerID(); if (territory.OwnerPlayerId == playerID) { GUILayout.Label("You own this territory", _labelStyle, Array.Empty()); GUILayout.Space(10f); if (!territory.IsEmperorTerritory && GUILayout.Button("Abandon Territory", _buttonStyle, Array.Empty())) { TerritoryManager.Instance?.AbandonTerritory(playerID, cell); ClosePanel(); } } } private void DrawUnclaimedTerritoryInfo(Vector2i cell) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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_00f4: 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) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) if (!IsCellExplored(cell)) { GUILayout.Label("? ? ? ? ? ?", _headerStyle, Array.Empty()); GUILayout.Space(10f); GUILayout.Label("Unexplored Territory", _labelStyle, Array.Empty()); GUILayout.Space(15f); GUILayout.Label("You must explore this area before\nyou can see its details or claim it.", _labelStyle, Array.Empty()); GUILayout.Space(10f); GUILayout.Label("Tip: Travel there to reveal!", _labelStyle, Array.Empty()); return; } string territoryName = GridUtils.GetTerritoryName(cell); GUILayout.Label("" + territoryName + "", _headerStyle, Array.Empty()); GUILayout.Space(5f); GUILayout.Label("Unclaimed Territory", _labelStyle, Array.Empty()); GUILayout.Space(10f); string biomeCompositionString = GridUtils.GetBiomeCompositionString(cell); int num = GridUtils.CalculateTollForCell(cell); bool flag = GridUtils.CellHasMerchant(cell); GUILayout.Label("Biomes: " + biomeCompositionString, _labelStyle, Array.Empty()); if (flag) { GUILayout.Label("Merchant Territory", _labelStyle, Array.Empty()); GUILayout.Label("2x toll rate / 2x claim cost", _labelStyle, Array.Empty()); } GUILayout.Label($"Base Toll: {num} coins", _labelStyle, Array.Empty()); if (GridUtils.IsInSpawnProtection(cell)) { GUILayout.Space(10f); GUILayout.Label("Cannot claim: Spawn protection zone", _labelStyle, Array.Empty()); return; } Vector2i val = GridUtils.WorldToVisualGrid(((Component)Player.m_localPlayer).transform.position); bool flag2 = val.x == cell.x && val.y == cell.y; GUILayout.Space(20f); if (!flag2) { GUILayout.Label("You must be standing in this territory to claim it.", _labelStyle, Array.Empty()); return; } int claimCost = GridUtils.GetClaimCost(cell); GUILayout.Label($"Claim Cost: {claimCost} coins", _labelStyle, Array.Empty()); GUILayout.Space(10f); if (GUILayout.Button("Claim Territory", _buttonStyle, Array.Empty())) { TryClaimTerritory(cell); } } private void TryClaimTerritory(Vector2i cell) { //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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_003a: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.m_localPlayer == (Object)null) { return; } Vector2i val = GridUtils.WorldToVisualGrid(((Component)Player.m_localPlayer).transform.position); if (val.x != cell.x || val.y != cell.y) { ((Character)Player.m_localPlayer).Message((MessageType)2, "You must be standing in the territory to claim it!", 0, (Sprite)null); return; } int claimCost = GridUtils.GetClaimCost(cell); Inventory inventory = ((Humanoid)Player.m_localPlayer).GetInventory(); int num = 0; foreach (ItemData allItem in inventory.GetAllItems()) { if (allItem.m_shared.m_name == "$item_coins") { num += allItem.m_stack; } } if (num < claimCost) { ((Character)Player.m_localPlayer).Message((MessageType)2, $"Not enough coins! Need {claimCost}, have {num}", 0, (Sprite)null); return; } inventory.RemoveItem("$item_coins", claimCost, -1, true); long playerID = Player.m_localPlayer.GetPlayerID(); string playerName = Player.m_localPlayer.GetPlayerName(); TerritoryManager.Instance?.TryClaimTerritory(playerID, playerName, cell); string territoryName = GridUtils.GetTerritoryName(cell); ((Character)Player.m_localPlayer).Message((MessageType)2, "Claimed " + territoryName + "!", 0, (Sprite)null); ClosePanel(); } } public class TerritoryPopup : MonoBehaviour { [CompilerGenerated] private sealed class d__25 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public GameObject biomeObject; public float delay; public TerritoryPopup <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__25(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(delay); <>1__state = 1; return true; case 1: <>1__state = -1; if ((Object)(object)biomeObject != (Object)null) { biomeObject.SetActive(false); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private string _currentTerritoryName = ""; private float _displayTimer = 0f; private bool _isShowing = false; private const float DisplayDuration = 3f; private const float FadeInDuration = 0.5f; private const float FadeOutDuration = 0.5f; private GameObject _popupObject; private TextMeshProUGUI _territoryText; private CanvasGroup _canvasGroup; private RectTransform _rectTransform; private Image _leftDecor; private Image _rightDecor; private bool _subscribed = false; private bool _isPvPZone = false; public static TerritoryPopup Instance { get; private set; } private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)this); } else { Instance = this; } } private void Start() { TrySubscribe(); } private void TrySubscribe() { if (!_subscribed && (Object)(object)ExplorationTracker.Instance != (Object)null) { ExplorationTracker.Instance.OnTileEntered += OnTileEntered; _subscribed = true; Plugin.Log.LogInfo((object)"TerritoryPopup subscribed to ExplorationTracker (all tiles)"); } } private void Update() { if (!_subscribed) { TrySubscribe(); } if (!_isShowing) { return; } _displayTimer += Time.deltaTime; if (_displayTimer < 0.5f) { float num = _displayTimer / 0.5f; SetAlpha(Mathf.SmoothStep(0f, 1f, num)); } else if (_displayTimer > 2.5f) { float num2 = _displayTimer - 2.5f; float num3 = num2 / 0.5f; SetAlpha(Mathf.SmoothStep(1f, 0f, num3)); if (_displayTimer >= 3f) { HidePopup(); } } else { SetAlpha(1f); } } private void OnTileEntered(Vector2i tile, bool wasExplored) { //IL_000d: 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) Territory territory = TerritoryManager.Instance?.GetTerritory(tile); string territoryName = ((territory != null) ? territory.DisplayName : GridUtils.GetTerritoryName(tile)); if (territory != null && territory.IsPvPEnabled) { _isPvPZone = true; } else { _isPvPZone = false; } ShowTerritoryName(territoryName); } public void ShowTerritoryName(string territoryName) { if (string.IsNullOrEmpty(territoryName)) { return; } _currentTerritoryName = territoryName.ToUpperInvariant(); _displayTimer = 0f; _isShowing = true; if (TryUseNativeBiomeDisplay(_currentTerritoryName)) { _isShowing = false; return; } EnsurePopupCreated(); if ((Object)(object)_popupObject == (Object)null || (Object)(object)_territoryText == (Object)null) { _isShowing = false; Plugin.Log.LogWarning((object)"Territory popup could not be created - skipping display"); } else { UpdatePopupText(); _popupObject.SetActive(true); Plugin.Log.LogDebug((object)("Showing territory popup: " + territoryName)); } } private bool TryUseNativeBiomeDisplay(string territoryName) { if ((Object)(object)Hud.instance == (Object)null) { Plugin.Log.LogDebug((object)"TryUseNativeBiomeDisplay: Hud.instance is null"); return false; } try { FieldInfo field = typeof(Hud).GetField("m_biome", BindingFlags.Instance | BindingFlags.NonPublic); FieldInfo field2 = typeof(Hud).GetField("m_biomeName", BindingFlags.Instance | BindingFlags.NonPublic); if (field == null) { Plugin.Log.LogDebug((object)"TryUseNativeBiomeDisplay: m_biome field not found"); return false; } if (field2 == null) { Plugin.Log.LogDebug((object)"TryUseNativeBiomeDisplay: m_biomeName field not found"); return false; } object? value = field.GetValue(Hud.instance); GameObject val = (GameObject)((value is GameObject) ? value : null); object? value2 = field2.GetValue(Hud.instance); TextMeshProUGUI val2 = (TextMeshProUGUI)((value2 is TextMeshProUGUI) ? value2 : null); if ((Object)(object)val == (Object)null) { Plugin.Log.LogDebug((object)"TryUseNativeBiomeDisplay: biomeObject is null"); return false; } if ((Object)(object)val2 == (Object)null) { Plugin.Log.LogDebug((object)"TryUseNativeBiomeDisplay: biomeName is null"); return false; } ((TMP_Text)val2).text = territoryName; val.SetActive(true); ((MonoBehaviour)this).StartCoroutine(HideBiomeAfterDelay(val, 3f)); Plugin.Log.LogInfo((object)("Showing territory via native biome display: " + territoryName)); return true; } catch (Exception ex) { Plugin.Log.LogWarning((object)("Native biome display failed: " + ex.Message)); return false; } } [IteratorStateMachine(typeof(d__25))] private IEnumerator HideBiomeAfterDelay(GameObject biomeObject, float delay) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__25(0) { <>4__this = this, biomeObject = biomeObject, delay = delay }; } private void EnsurePopupCreated() { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Expected O, but got Unknown //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_popupObject != (Object)null) { return; } TMP_FontAsset val = FindValidFont(); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)"No TMP font available for territory popup - skipping creation"); return; } Canvas val2 = FindUICanvas(); if ((Object)(object)val2 == (Object)null) { Plugin.Log.LogWarning((object)"Could not find UI canvas for territory popup"); return; } _popupObject = new GameObject("TerritoryPopup"); _popupObject.transform.SetParent(((Component)val2).transform, false); _rectTransform = _popupObject.AddComponent(); _rectTransform.anchorMin = new Vector2(0.5f, 0.7f); _rectTransform.anchorMax = new Vector2(0.5f, 0.7f); _rectTransform.pivot = new Vector2(0.5f, 0.5f); _rectTransform.anchoredPosition = Vector2.zero; _rectTransform.sizeDelta = new Vector2(600f, 100f); _canvasGroup = _popupObject.AddComponent(); _canvasGroup.alpha = 0f; GameObject val3 = new GameObject("TerritoryText"); val3.transform.SetParent(_popupObject.transform, false); RectTransform val4 = val3.AddComponent(); val4.anchorMin = Vector2.zero; val4.anchorMax = Vector2.one; val4.offsetMin = Vector2.zero; val4.offsetMax = Vector2.zero; _territoryText = val3.AddComponent(); ((TMP_Text)_territoryText).font = val; ((TMP_Text)_territoryText).alignment = (TextAlignmentOptions)514; ((TMP_Text)_territoryText).fontSize = 32f; ((TMP_Text)_territoryText).fontStyle = (FontStyles)1; ((Graphic)_territoryText).color = new Color(1f, 0.85f, 0.4f); ((TMP_Text)_territoryText).outlineWidth = 0.2f; ((TMP_Text)_territoryText).outlineColor = new Color32((byte)20, (byte)15, (byte)10, (byte)200); CreateDecorativeLines(); _popupObject.SetActive(false); Plugin.Log.LogInfo((object)"Territory popup UI created"); } private TMP_FontAsset FindValidFont() { try { if ((Object)(object)Hud.instance != (Object)null) { FieldInfo field = typeof(Hud).GetField("m_biomeName", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { object? value = field.GetValue(Hud.instance); TextMeshProUGUI val = (TextMeshProUGUI)((value is TextMeshProUGUI) ? value : null); if ((Object)(object)val != (Object)null && (Object)(object)((TMP_Text)val).font != (Object)null) { Plugin.Log.LogDebug((object)("Using font from Hud.m_biomeName: " + ((Object)((TMP_Text)val).font).name)); return ((TMP_Text)val).font; } } } TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll(); TMP_FontAsset[] array2 = array; foreach (TMP_FontAsset val2 in array2) { if ((Object)(object)val2 != (Object)null && !string.IsNullOrEmpty(((Object)val2).name)) { string text = ((Object)val2).name.ToLower(); if (text.Contains("norse") || text.Contains("averia") || text.Contains("valheim")) { Plugin.Log.LogDebug((object)("Using Valheim-style font: " + ((Object)val2).name)); return val2; } } } TMP_FontAsset[] array3 = array; foreach (TMP_FontAsset val3 in array3) { if ((Object)(object)val3 != (Object)null) { Plugin.Log.LogDebug((object)("Using fallback font: " + ((Object)val3).name)); return val3; } } } catch (Exception ex) { Plugin.Log.LogError((object)("Error finding font: " + ex.Message)); } return null; } private void CreateDecorativeLines() { } private void UpdatePopupText() { //IL_0057: 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) if ((Object)(object)_territoryText != (Object)null) { ((TMP_Text)_territoryText).text = _currentTerritoryName; ((Graphic)_territoryText).color = (_isPvPZone ? new Color(1f, 0.3f, 0.3f) : new Color(1f, 0.85f, 0.4f)); } } private void SetAlpha(float alpha) { if ((Object)(object)_canvasGroup != (Object)null) { _canvasGroup.alpha = alpha; } } private void HidePopup() { _isShowing = false; if ((Object)(object)_popupObject != (Object)null) { _popupObject.SetActive(false); } } private Canvas FindUICanvas() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Invalid comparison between Unknown and I4 if ((Object)(object)Hud.instance != (Object)null) { Canvas componentInParent = ((Component)Hud.instance).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null) { return componentInParent; } } Canvas[] array = Object.FindObjectsOfType(); Canvas[] array2 = array; foreach (Canvas val in array2) { if ((int)val.renderMode == 0) { return val; } } return null; } private void OnDestroy() { if ((Object)(object)ExplorationTracker.Instance != (Object)null) { ExplorationTracker.Instance.OnTileEntered -= OnTileEntered; } if ((Object)(object)_popupObject != (Object)null) { Object.Destroy((Object)(object)_popupObject); } if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } } } namespace FreyjaLandlord.Patches { [HarmonyPatch] public static class InputBlockingPatches { [HarmonyPatch(typeof(Player), "TakeInput")] [HarmonyPrefix] public static bool Player_TakeInput_Prefix() { if (LandlordHUD.ShouldBlockInput()) { return false; } return true; } [HarmonyPatch(typeof(PlayerController), "TakeInput")] [HarmonyPrefix] public static bool PlayerController_TakeInput_Prefix() { if (LandlordHUD.ShouldBlockInput()) { return false; } return true; } } [HarmonyPatch] public static class CameraPatches { [HarmonyPatch(typeof(ZInput), "GetMouseScrollWheel")] [HarmonyPrefix] public static bool ZInput_GetMouseScrollWheel_Prefix(ref float __result) { if (LandlordHUD.ShouldBlockInput()) { __result = 0f; return false; } return true; } } [HarmonyPatch] public static class CursorPatches { [HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")] [HarmonyPrefix] public static bool GameCamera_UpdateMouseCapture_Prefix() { if (LandlordHUD.ShouldBlockInput()) { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; return false; } return true; } } [HarmonyPatch] public static class PlayerPatches { private static Vector2i? _lastGrid = null; private static float _positionReportTimer = 0f; private const float PositionReportInterval = 1f; private static bool _skipFirstReport = true; [HarmonyPatch(typeof(Player), "Update")] [HarmonyPostfix] public static void Player_Update_Postfix(Player __instance) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0163: 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_0190: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer || !((Character)__instance).IsOwner()) { return; } _positionReportTimer += Time.deltaTime; if (_positionReportTimer < 1f) { return; } _positionReportTimer = 0f; Vector3 position = ((Component)__instance).transform.position; Vector2i val = GridUtils.WorldToVisualGrid(position); if (!_lastGrid.HasValue || _lastGrid.Value != val) { if (_skipFirstReport) { Plugin.Log.LogInfo((object)$"Skipping first position report at cell ({val.x}, {val.y})"); _skipFirstReport = false; _lastGrid = val; return; } Plugin.Log.LogInfo((object)$"CELL CHANGED: from ({_lastGrid?.x}, {_lastGrid?.y}) to ({val.x}, {val.y})"); _lastGrid = val; LandlordRPC.Instance?.ReportPlayerPosition(position); } } [HarmonyPatch(typeof(Player), "OnSpawned")] [HarmonyPostfix] public static void Player_OnSpawned_Postfix(Player __instance) { if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { _skipFirstReport = true; _lastGrid = null; LandlordRPC.Instance?.RequestDataFromServer(); } } } [HarmonyPatch] public static class TeleportPatches { [HarmonyPatch(typeof(Player), "TeleportTo")] [HarmonyPostfix] public static void Player_TeleportTo_Postfix(Player __instance, Vector3 pos) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { LandlordRPC.Instance?.ReportPlayerPosition(pos); } } } [HarmonyPatch] public static class LootTaxPatches { private static Dictionary _pickupCounters = new Dictionary(); [HarmonyPatch(typeof(Humanoid), "Pickup")] [HarmonyPrefix] public static bool Humanoid_Pickup_Prefix(Humanoid __instance, GameObject go, ref bool __result) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0380: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) try { Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val == null) { return true; } if ((Object)(object)val != (Object)(object)Player.m_localPlayer) { return true; } if ((Object)(object)go == (Object)null) { return true; } ItemDrop component = go.GetComponent(); if ((Object)(object)component == (Object)null) { return true; } long playerID = val.GetPlayerID(); Vector3 position = ((Component)val).transform.position; Vector2i gridPos = GridUtils.WorldToVisualGrid(position); Territory territory = TerritoryManager.Instance?.GetTerritory(gridPos); int num = 0; if (territory != null && !territory.IsExemptFromToll(playerID) && territory.LootTaxPercent > 0) { num = territory.LootTaxPercent; } LandlordData landlordData = TerritoryManager.Instance?.Data; if (landlordData != null && landlordData.Debts.TryGetValue(playerID, out var value)) { int vassalLootPercent = value.VassalLootPercent; if (vassalLootPercent > num) { num = vassalLootPercent; } } if (num <= 0) { return true; } if (!_pickupCounters.ContainsKey(playerID)) { _pickupCounters[playerID] = 0; } _pickupCounters[playerID]++; int num2 = 100 / num; if (_pickupCounters[playerID] >= num2) { _pickupCounters[playerID] = 0; string text = component.m_itemData?.m_shared?.m_name ?? "item"; Localization instance = Localization.instance; string text2 = ((instance != null) ? instance.Localize(text) : null) ?? text; ItemData itemData = component.m_itemData; object obj; if (itemData == null) { obj = null; } else { GameObject dropPrefab = itemData.m_dropPrefab; obj = ((dropPrefab != null) ? ((Object)dropPrefab).name : null); } if (obj == null) { obj = text; } string prefabName = (string)obj; int num3 = component.m_itemData?.m_stack ?? 1; Plugin.Log.LogInfo((object)$"LOOT TAX: {text2} x{num3} taxed at {num}%"); if (territory != null) { territory.AddToVault(prefabName, text2, num3); TerritoryManager.Instance?.MarkDirty(); } if (landlordData != null && landlordData.Debts.TryGetValue(playerID, out var value2)) { value2.Amount = Math.Max(0, value2.Amount - 10); if (value2.Amount <= 0) { landlordData.Debts.Remove(playerID); TollManager.Instance?.NotifyDebtPaid(value2); } TerritoryManager.Instance?.MarkDirty(); } string arg = ((territory != null) ? territory.OwnerName : "your lord"); MessageHud instance2 = MessageHud.instance; if (instance2 != null) { instance2.ShowMessage((MessageType)1, $"Loot taxed: {text2} x{num3} -> {arg}", 0, (Sprite)null, false); } try { string[] array = new string[3] { "vfx_coin_pile_destroyed", "vfx_PickUp", "vfx_coin_stack_destroyed" }; string[] array2 = array; foreach (string text3 in array2) { ZNetScene instance3 = ZNetScene.instance; GameObject val2 = ((instance3 != null) ? instance3.GetPrefab(text3) : null); if ((Object)(object)val2 != (Object)null) { Object.Instantiate(val2, go.transform.position, Quaternion.identity); break; } } } catch { } ZNetView component2 = go.GetComponent(); if ((Object)(object)component2 != (Object)null && component2.IsValid()) { component2.Destroy(); } else { Object.Destroy((Object)(object)go); } __result = false; return false; } return true; } catch (Exception ex) { Plugin.Log.LogError((object)("LOOT TAX ERROR: " + ex.Message + "\n" + ex.StackTrace)); return true; } } } [HarmonyPatch] public static class BossKillPatches { [HarmonyPatch(typeof(Character), "OnDeath")] [HarmonyPostfix] public static void Character_OnDeath_BossCheck_Postfix(Character __instance) { //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_00b4: 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) if ((Object)(object)__instance == (Object)null || __instance.IsPlayer()) { return; } string cleanPrefabName = GetCleanPrefabName(((Component)__instance).gameObject); if (string.IsNullOrEmpty(cleanPrefabName)) { return; } bool flag = false; string[] allBossPrefabs = LandlordData.AllBossPrefabs; foreach (string value in allBossPrefabs) { if (cleanPrefabName.Equals(value, StringComparison.OrdinalIgnoreCase)) { flag = true; break; } } if (!flag) { return; } Vector3 position = ((Component)__instance).transform.position; foreach (Player allPlayer in Player.GetAllPlayers()) { if (Vector3.Distance(((Component)allPlayer).transform.position, position) < 100f) { TerritoryManager.Instance?.RecordBossKill(allPlayer.GetPlayerID(), cleanPrefabName); Plugin.Log.LogInfo((object)("Boss kill recorded: " + allPlayer.GetPlayerName() + " killed " + cleanPrefabName)); } } } private static string GetCleanPrefabName(GameObject obj) { if ((Object)(object)obj == (Object)null) { return ""; } string text = ((Object)obj).name; int num = text.IndexOf("(Clone)"); if (num > 0) { text = text.Substring(0, num); } return text.Trim(); } } [HarmonyPatch] public static class PrestigePatches { [HarmonyPatch(typeof(Player), "PlacePiece")] [HarmonyPostfix] public static void Player_PlacePiece_Postfix(Player __instance, Piece piece) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_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_0042: 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) if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer || (Object)(object)piece == (Object)null) { return; } long playerID = __instance.GetPlayerID(); Vector3 position = ((Component)__instance).transform.position; Vector2i gridPos = GridUtils.WorldToVisualGrid(position); Territory territory = TerritoryManager.Instance?.GetTerritory(gridPos); if (territory == null || territory.OwnerPlayerId != playerID || !territory.IsUnlocked) { return; } string text = ((Object)((Component)piece).gameObject).name; int num = text.IndexOf("(Clone)"); if (num > 0) { text = text.Substring(0, num).Trim(); } if (string.IsNullOrEmpty(text)) { return; } if (territory.UniquePiecesPlaced == null) { territory.UniquePiecesPlaced = new List(); } if (territory.UniquePiecesPlaced.Contains(text)) { return; } territory.UniquePiecesPlaced.Add(text); int num2 = Math.Min(territory.UniquePiecesPlaced.Count / 10, 5); if (num2 > territory.Prestige) { territory.Prestige = num2; TerritoryManager.Instance?.MarkDirty(); int num3 = num2 * 100; MessageHud instance = MessageHud.instance; if (instance != null) { instance.ShowMessage((MessageType)1, $"Prestige Level {num2}! Toll bonus: +{num3}%", 0, (Sprite)null, false); } } } } [HarmonyPatch] public static class TraderPatches { private static GameObject _permitButton; [HarmonyPatch(typeof(StoreGui), "Show")] [HarmonyPostfix] public static void StoreGui_Show_Postfix(StoreGui __instance) { } [HarmonyPatch(typeof(StoreGui), "Hide")] [HarmonyPostfix] public static void StoreGui_Hide_Postfix() { } private static void CreatePermitButton(StoreGui storeGui) { } private static void OnBuyPermit(StoreGui storeGui) { } } [HarmonyPatch] public static class ObjectivePatches { private static Dictionary _lastAttackers = new Dictionary(); [HarmonyPatch(typeof(Character), "RPC_Damage")] [HarmonyPrefix] public static void Character_RPC_Damage_Prefix(Character __instance, HitData hit) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_004c: Unknown result type (might be due to invalid IL or missing references) ZDOID? val = hit?.m_attacker; ZDOID none = ZDOID.None; if (val.HasValue && !(val.GetValueOrDefault() != none)) { return; } ZNetScene instance = ZNetScene.instance; GameObject val2 = ((instance != null) ? instance.FindInstance(hit.m_attacker) : null); if ((Object)(object)val2 != (Object)null) { Player component = val2.GetComponent(); if ((Object)(object)component != (Object)null) { int instanceID = ((Object)__instance).GetInstanceID(); _lastAttackers[instanceID] = component.GetPlayerID(); } } } [HarmonyPatch(typeof(Character), "OnDeath")] [HarmonyPostfix] public static void Character_OnDeath_Postfix(Character __instance) { //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)null || __instance.IsPlayer()) { return; } int instanceID = ((Object)__instance).GetInstanceID(); if (!_lastAttackers.TryGetValue(instanceID, out var value)) { return; } _lastAttackers.Remove(instanceID); Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || localPlayer.GetPlayerID() != value) { return; } string prefabName = GetPrefabName(((Component)__instance).gameObject); long playerID = localPlayer.GetPlayerID(); LandlordData landlordData = TerritoryManager.Instance?.Data; if (landlordData == null) { return; } foreach (Territory playerTerritory in landlordData.GetPlayerTerritories(playerID)) { if (playerTerritory.CurrentObjective != null && playerTerritory.CurrentObjective.Type == ObjectiveType.KillMonsters && playerTerritory.CurrentObjective.TargetPrefab.Equals(prefabName, StringComparison.OrdinalIgnoreCase)) { TerritoryManager.Instance?.ReportObjectiveProgress(playerID, playerTerritory.GridPosition, prefabName, 1); MessageHud instance = MessageHud.instance; if (instance != null) { instance.ShowMessage((MessageType)1, $"Kill progress: {playerTerritory.CurrentObjective.CurrentAmount + 1}/{playerTerritory.CurrentObjective.RequiredAmount} {playerTerritory.CurrentObjective.TargetDisplayName}", 0, (Sprite)null, false); } } } LandlordData landlordData2 = TerritoryManager.Instance?.Data; if (landlordData2?.CurrentTribute != null && landlordData2.CurrentTribute.Type == ObjectiveType.KillMonsters && landlordData2.CurrentTribute.TargetPrefab.Equals(prefabName, StringComparison.OrdinalIgnoreCase)) { landlordData2.CurrentTribute.CurrentAmount++; TerritoryManager.Instance?.MarkDirty(); } try { if (Random.Range(0, 200) != 0) { return; } int num = Random.Range(0, 100); int num2; string text; if (num < 70) { num2 = 0; text = "Bronze"; } else if (num < 95) { num2 = 1; text = "Silver"; } else { num2 = 2; text = "Gold"; } Inventory inventory = ((Humanoid)localPlayer).GetInventory(); if (VaultKeySetup.AddKeyToInventory(inventory, num2)) { MessageHud instance2 = MessageHud.instance; if (instance2 != null) { instance2.ShowMessage((MessageType)1, "You found a " + text + " Vault Key!", 0, (Sprite)null, false); } Plugin.Log.LogInfo((object)$"Player {playerID} found a {text} Key!"); return; } ObjectDB instance3 = ObjectDB.instance; GameObject val = ((instance3 != null) ? instance3.GetItemPrefab(VaultKeySetup.PrefabNames[num2]) : null); if ((Object)(object)val != (Object)null) { GameObject val2 = Object.Instantiate(val, ((Component)localPlayer).transform.position + Vector3.up * 0.5f, Quaternion.identity); val2.SetActive(true); MessageHud instance4 = MessageHud.instance; if (instance4 != null) { instance4.ShowMessage((MessageType)1, "A " + text + " Vault Key dropped on the ground!", 0, (Sprite)null, false); } Plugin.Log.LogInfo((object)$"Player {playerID} found a {text} Key (dropped on ground - inventory full)"); } } catch (Exception ex) { Plugin.Log.LogError((object)("Key drop error: " + ex.Message)); } } private static string GetPrefabName(GameObject obj) { if ((Object)(object)obj == (Object)null) { return ""; } string text = ((Object)obj).name; int num = text.IndexOf("(Clone)"); if (num > 0) { text = text.Substring(0, num); } return text.Trim(); } [HarmonyPatch(typeof(Inventory), "AddItem", new Type[] { typeof(ItemData) })] [HarmonyPostfix] public static void Inventory_AddItem_Postfix(Inventory __instance, ItemData item, bool __result) { //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) if (!__result || (Object)(object)Player.m_localPlayer == (Object)null || __instance != ((Humanoid)Player.m_localPlayer).GetInventory()) { return; } GameObject dropPrefab = item.m_dropPrefab; string text = ((dropPrefab != null) ? ((Object)dropPrefab).name : null) ?? item.m_shared?.m_name ?? ""; int stack = item.m_stack; long playerID = Player.m_localPlayer.GetPlayerID(); LandlordData landlordData = TerritoryManager.Instance?.Data; if (landlordData == null) { return; } foreach (Territory playerTerritory in landlordData.GetPlayerTerritories(playerID)) { if (playerTerritory.CurrentObjective == null) { continue; } if (playerTerritory.CurrentObjective.Type == ObjectiveType.GatherResources) { if (playerTerritory.CurrentObjective.TargetPrefab.Equals(text, StringComparison.OrdinalIgnoreCase)) { TerritoryManager.Instance?.ReportObjectiveProgress(playerID, playerTerritory.GridPosition, text, stack); MessageHud instance = MessageHud.instance; if (instance != null) { instance.ShowMessage((MessageType)1, $"Gather progress: {playerTerritory.CurrentObjective.CurrentAmount + stack}/{playerTerritory.CurrentObjective.RequiredAmount} {playerTerritory.CurrentObjective.TargetDisplayName}", 0, (Sprite)null, false); } } } else if (playerTerritory.CurrentObjective.Type == ObjectiveType.PayMaterials && playerTerritory.CurrentObjective.TargetPrefab.Equals(text, StringComparison.OrdinalIgnoreCase)) { TerritoryManager.Instance?.ReportObjectiveProgress(playerID, playerTerritory.GridPosition, text, stack); MessageHud instance2 = MessageHud.instance; if (instance2 != null) { instance2.ShowMessage((MessageType)1, $"Pay progress: {playerTerritory.CurrentObjective.CurrentAmount + stack}/{playerTerritory.CurrentObjective.RequiredAmount} {playerTerritory.CurrentObjective.TargetDisplayName}", 0, (Sprite)null, false); } } } LandlordData landlordData2 = TerritoryManager.Instance?.Data; if (landlordData2?.CurrentTribute != null && landlordData2.CurrentTribute.Type == ObjectiveType.GatherResources && landlordData2.CurrentTribute.TargetPrefab.Equals(text, StringComparison.OrdinalIgnoreCase)) { landlordData2.CurrentTribute.CurrentAmount += stack; TerritoryManager.Instance?.MarkDirty(); } } } [HarmonyPatch] public static class PvPLockPatches { [HarmonyPatch(typeof(Player), "SetPVP")] [HarmonyPrefix] public static bool Player_SetPVP_Prefix(Player __instance, bool enabled) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //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_004f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return true; } if (TollManager.SuppressCenterMessages) { return true; } if (!enabled) { Vector3 position = ((Component)__instance).transform.position; Vector2i gridPos = GridUtils.WorldToVisualGrid(position); Territory territory = TerritoryManager.Instance?.GetTerritory(gridPos); if (territory != null && territory.IsPvPEnabled && !territory.IsExemptFromToll(__instance.GetPlayerID())) { MessageHud instance = MessageHud.instance; if (instance != null) { instance.ShowMessage((MessageType)2, "PvP is enforced in this territory!", 0, (Sprite)null, false); } return false; } } return true; } } [HarmonyPatch] public static class MessagePatches { [HarmonyPatch(typeof(MessageHud), "ShowMessage")] [HarmonyPrefix] public static bool MessageHud_ShowMessage_Prefix(MessageType type) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 if ((int)type == 2 && TollManager.SuppressCenterMessages) { return false; } return true; } [HarmonyPatch(typeof(Player), "Message")] [HarmonyPrefix] public static bool Player_Message_Prefix(MessageType type) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 if ((int)type == 2 && TollManager.SuppressCenterMessages) { return false; } return true; } [HarmonyPatch(typeof(MessageHud), "UpdateMessage")] [HarmonyPrefix] public static void MessageHud_UpdateMessage_Prefix(ref float dt) { dt *= 0.7f; } } [HarmonyPatch] public static class SaveLoadPatches { [HarmonyPatch(typeof(ZNet), "Shutdown")] [HarmonyPrefix] public static void ZNet_Shutdown_Prefix() { TerritoryManager.Instance?.SaveData(); VoronoiGrid.Reset(); } [HarmonyPatch(typeof(Game), "SavePlayerProfile")] [HarmonyPostfix] public static void Game_SavePlayerProfile_Postfix() { ZNet instance = ZNet.instance; if (instance != null && instance.IsServer()) { TerritoryManager.Instance?.SaveData(); } } } [HarmonyPatch] public static class MinimapPatches { [HarmonyPatch(typeof(Minimap), "UpdateExplore")] [HarmonyPostfix] public static void Minimap_UpdateExplore_Postfix(Minimap __instance) { } } [HarmonyPatch] public static class ChatPatches { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEvent <>9__0_0; public static ConsoleEvent <>9__0_1; public static ConsoleEvent <>9__0_2; internal void b__0_0(ConsoleEventArgs args) { ProcessLandlordCommand("/landlord " + string.Join(" ", args.Args)); } internal void b__0_1(ConsoleEventArgs args) { LandlordRPC.Instance?.RequestPayDebt(); } internal void b__0_2(ConsoleEventArgs args) { LandlordRPC.Instance?.RequestWithdrawIncome(); } } [HarmonyPatch(typeof(Terminal), "Awake")] [HarmonyPostfix] public static void Terminal_Awake_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 //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_0062: Expected O, but got Unknown //IL_00a3: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown object obj = <>c.<>9__0_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { ProcessLandlordCommand("/landlord " + string.Join(" ", args.Args)); }; <>c.<>9__0_0 = val; obj = (object)val; } new ConsoleCommand("landlord", "Landlord system commands", (ConsoleEvent)obj, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj2 = <>c.<>9__0_1; if (obj2 == null) { ConsoleEvent val2 = delegate { LandlordRPC.Instance?.RequestPayDebt(); }; <>c.<>9__0_1 = val2; obj2 = (object)val2; } new ConsoleCommand("paydebt", "Pay off your debt", (ConsoleEvent)obj2, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj3 = <>c.<>9__0_2; if (obj3 == null) { ConsoleEvent val3 = delegate { LandlordRPC.Instance?.RequestWithdrawIncome(); }; <>c.<>9__0_2 = val3; obj3 = (object)val3; } new ConsoleCommand("withdraw", "Withdraw accumulated income", (ConsoleEvent)obj3, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } private static void ProcessLandlordCommand(string text) { string[] array = text.Split(new char[1] { ' ' }); if (array.Length < 2) { ShowHelp(); return; } string text2 = array[1].ToLower(); switch (text2) { case "help": ShowHelp(); return; case "status": ShowStatus(); return; case "forgive": { if (array.Length >= 3 && long.TryParse(array[2], out var result)) { LandlordRPC.Instance?.RequestForgiveDebt(result); } return; } case "cleartrialrun": ClearTrialRun(); return; } Console instance = Console.instance; if (instance != null) { instance.Print("Unknown command: " + text2); } } private static void ClearTrialRun() { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { Console instance = Console.instance; if (instance != null) { instance.Print("No local player found"); } return; } TollManager instance2 = TollManager.Instance; if (instance2 != null && instance2.HasTrialRunProtection(localPlayer)) { TollManager.Instance?.RemoveTrialRunProtection(localPlayer); Console instance3 = Console.instance; if (instance3 != null) { instance3.Print("Trial Run protection removed!"); } } else { Console instance4 = Console.instance; if (instance4 != null) { instance4.Print("You don't have Trial Run protection"); } } } private static void ShowHelp() { Console instance = Console.instance; if (instance != null) { instance.Print("Landlord Commands:"); } Console instance2 = Console.instance; if (instance2 != null) { instance2.Print(" landlord help - Show this help"); } Console instance3 = Console.instance; if (instance3 != null) { instance3.Print(" landlord status - Show your landlord status"); } Console instance4 = Console.instance; if (instance4 != null) { instance4.Print(" landlord cleartrialrun - Remove Trial Run protection"); } Console instance5 = Console.instance; if (instance5 != null) { instance5.Print(" paydebt - Pay off your debt"); } Console instance6 = Console.instance; if (instance6 != null) { instance6.Print(" withdraw - Withdraw all accumulated income"); } Console instance7 = Console.instance; if (instance7 != null) { instance7.Print(" Press F4 to open the Landlord HUD"); } } private static void ShowStatus() { //IL_0167: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } long playerID = localPlayer.GetPlayerID(); LandlordData landlordData = TerritoryManager.Instance?.Data; if (landlordData == null) { Console instance = Console.instance; if (instance != null) { instance.Print("Landlord system not loaded"); } return; } List playerTerritories = landlordData.GetPlayerTerritories(playerID); int value; int num = (landlordData.PlayerPermitCounts.TryGetValue(playerID, out value) ? value : 0); Console instance2 = Console.instance; if (instance2 != null) { instance2.Print("=== Landlord Status ==="); } int num2 = TerritoryManager.Instance?.Data?.GetMaxTerritories(playerID) ?? LandlordConfig.MaxTerritoriesPerPlayer.Value; Console instance3 = Console.instance; if (instance3 != null) { instance3.Print($"Territories owned: {playerTerritories.Count}/{num2}"); } Console instance4 = Console.instance; if (instance4 != null) { instance4.Print($"Permits used: {num}"); } int num3 = 0; foreach (Territory item in playerTerritories) { num3 += item.AccumulatedIncome; Console instance5 = Console.instance; if (instance5 != null) { instance5.Print($" {item.GridPosition}: {item.GetDominantBiomeName()} - Income: {item.AccumulatedIncome}"); } } Console instance6 = Console.instance; if (instance6 != null) { instance6.Print($"Total pending income: {num3} coins"); } Debt debt = TollManager.Instance?.GetPlayerDebt(playerID); if (debt != null) { Console instance7 = Console.instance; if (instance7 != null) { instance7.Print($"IN DEBT: {debt.Amount} coins to {debt.CreditorName}"); } if (debt.IsEscalated) { Console instance8 = Console.instance; if (instance8 != null) { instance8.Print($"VASSAL - {debt.VassalLootPercent}% loot redirected!"); } } else { Console instance9 = Console.instance; if (instance9 != null) { instance9.Print($"Escalation in: {debt.GetTimeRemainingString()} (then {30}% loot)"); } } } int valueOrDefault = (TerritoryManager.Instance?.Data?.GetBossKillCount(playerID)).GetValueOrDefault(); int valueOrDefault2 = (TerritoryManager.Instance?.Data?.GetMaxTerritories(playerID)).GetValueOrDefault(3); Console instance10 = Console.instance; if (instance10 != null) { instance10.Print($"Boss kills: {valueOrDefault} | Max territories: {valueOrDefault2}"); } TerritoryManager instance11 = TerritoryManager.Instance; if (instance11 != null && (instance11.Data?.IsEmperor(playerID)).GetValueOrDefault()) { Console instance12 = Console.instance; if (instance12 != null) { instance12.Print("*** EMPEROR ***"); } } int valueOrDefault3 = (TerritoryManager.Instance?.Data?.GlobalDebt).GetValueOrDefault(); int valueOrDefault4 = (TerritoryManager.Instance?.Data?.GetStarLevelBonus()).GetValueOrDefault(); Console instance13 = Console.instance; if (instance13 != null) { instance13.Print($"Global Debt: {valueOrDefault3} coins (+{valueOrDefault4} monster stars)"); } } } [HarmonyPatch] public static class CreatureStarPatches { [HarmonyPatch(typeof(Character), "Awake")] [HarmonyPostfix] public static void Character_Awake_Postfix(Character __instance) { if (__instance.IsPlayer() || __instance.IsTamed()) { return; } int valueOrDefault = (TerritoryManager.Instance?.Data?.GetStarLevelBonus()).GetValueOrDefault(); if (valueOrDefault > 0) { int level = __instance.GetLevel(); int val = level + valueOrDefault; val = Math.Min(val, 5); if (val > level) { __instance.SetLevel(val); } } } } [HarmonyPatch] public static class NewPlayerPatches { private static HashSet _playersGivenTrialRun = new HashSet(); [HarmonyPatch(typeof(Player), "OnSpawned")] [HarmonyPostfix] public static void Player_OnSpawned_Postfix(Player __instance) { if ((Object)(object)__instance == (Object)null) { return; } long playerID = __instance.GetPlayerID(); if (_playersGivenTrialRun.Contains(playerID)) { return; } _playersGivenTrialRun.Add(playerID); bool flag = false; try { Skills skills = ((Character)__instance).GetSkills(); if ((Object)(object)skills != (Object)null) { float num = 0f; num += skills.GetSkillLevel((SkillType)102); num += skills.GetSkillLevel((SkillType)100); num += skills.GetSkillLevel((SkillType)1); num += skills.GetSkillLevel((SkillType)3); num += skills.GetSkillLevel((SkillType)7); num += skills.GetSkillLevel((SkillType)13); Plugin.Log.LogInfo((object)$"Player skill total: {num}"); flag = num < 10f; } } catch { flag = false; } bool flag2 = TollManager.Instance?.HasTrialRunProtection(__instance) ?? false; Plugin.Log.LogInfo((object)$"Player OnSpawned - isNew: {flag}, hasTrial: {flag2}"); if (!flag2 && flag) { TollManager.Instance?.ApplyTrialRunProtection(__instance); } } } [HarmonyPatch] public static class ConsolePatches { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEvent <>9__0_0; public static ConsoleEvent <>9__0_1; internal void b__0_0(ConsoleEventArgs args) { LandlordData landlordData = TerritoryManager.Instance?.Data; if (landlordData == null) { args.Context.AddString("No landlord data available."); return; } landlordData.GenerateNewTribute(); TerritoryManager.Instance?.MarkDirty(); TerritoryManager.Instance?.SaveData(); string arg = ((landlordData.CurrentTribute.Type == ObjectiveType.KillMonsters) ? "Slay" : "Gather"); args.Context.AddString($"Tribute rerolled: {arg} {landlordData.CurrentTribute.BaseRequiredAmount}x {landlordData.CurrentTribute.TargetDisplayName}"); string message = "The gods have changed their demands! Check the new Tribute."; LandlordRPC.Instance?.BroadcastGlobalMessage(message); } internal void b__0_1(ConsoleEventArgs args) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { args.Context.AddString("No local player."); return; } ObjectDB instance = ObjectDB.instance; GameObject val = ((instance != null) ? instance.GetItemPrefab("Coins") : null); if ((Object)(object)val == (Object)null) { args.Context.AddString("Coins prefab not found."); return; } Inventory inventory = ((Humanoid)localPlayer).GetInventory(); if (inventory != null) { inventory.AddItem(val, 10000); } args.Context.AddString("Added 10000 coins to inventory."); } } [HarmonyPatch(typeof(Terminal), "InitTerminal")] [HarmonyPostfix] public static void Terminal_InitTerminal_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 //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_0062: Expected O, but got Unknown object obj = <>c.<>9__0_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { LandlordData landlordData = TerritoryManager.Instance?.Data; if (landlordData == null) { args.Context.AddString("No landlord data available."); } else { landlordData.GenerateNewTribute(); TerritoryManager.Instance?.MarkDirty(); TerritoryManager.Instance?.SaveData(); string arg = ((landlordData.CurrentTribute.Type == ObjectiveType.KillMonsters) ? "Slay" : "Gather"); args.Context.AddString($"Tribute rerolled: {arg} {landlordData.CurrentTribute.BaseRequiredAmount}x {landlordData.CurrentTribute.TargetDisplayName}"); string message = "The gods have changed their demands! Check the new Tribute."; LandlordRPC.Instance?.BroadcastGlobalMessage(message); } }; <>c.<>9__0_0 = val; obj = (object)val; } new ConsoleCommand("rerolltribute", "Reroll the Tribute to the Gods (admin only)", (ConsoleEvent)obj, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj2 = <>c.<>9__0_1; if (obj2 == null) { ConsoleEvent val2 = delegate(ConsoleEventArgs args) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { args.Context.AddString("No local player."); } else { ObjectDB instance = ObjectDB.instance; GameObject val3 = ((instance != null) ? instance.GetItemPrefab("Coins") : null); if ((Object)(object)val3 == (Object)null) { args.Context.AddString("Coins prefab not found."); } else { Inventory inventory = ((Humanoid)localPlayer).GetInventory(); if (inventory != null) { inventory.AddItem(val3, 10000); } args.Context.AddString("Added 10000 coins to inventory."); } } }; <>c.<>9__0_1 = val2; obj2 = (object)val2; } new ConsoleCommand("givecoins", "Give 10000 coins to your inventory (admin only)", (ConsoleEvent)obj2, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } } } namespace FreyjaLandlord.Network { public class BanManager : MonoBehaviour { private string _banListPath; private Dictionary _managedBans = new Dictionary(); public static BanManager Instance { get; private set; } private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { Instance = this; } } private void Start() { try { _banListPath = Path.Combine(Application.persistentDataPath, "bannedlist.txt"); } catch { _banListPath = Path.Combine(Paths.ConfigPath, "bannedlist.txt"); } } public void BanPlayer(long playerId, string playerName, BanRecord record) { ZNet instance = ZNet.instance; if (instance != null && instance.IsServer()) { _managedBans[playerId] = record; ZNetPeer peerByPlayerId = GetPeerByPlayerId(playerId); string text = null; if (peerByPlayerId != null) { ISocket socket = peerByPlayerId.m_socket; text = ((socket != null) ? socket.GetHostName() : null); ZNet.instance.Disconnect(peerByPlayerId); } if (!string.IsNullOrEmpty(text)) { AddToBanList(text, playerName, record.Reason); } Plugin.Log.LogInfo((object)$"Banned player {playerName} (ID: {playerId}) for bankruptcy until {record.BanEndTime}"); int num = LandlordConfig.BanDurationDays?.Value ?? 7; MessageHud instance2 = MessageHud.instance; if (instance2 != null) { instance2.ShowMessage((MessageType)2, $"{playerName} has been BANKRUPTED and banned for {num} days!", 0, (Sprite)null, false); } } } public void UnbanPlayer(long playerId, string playerName) { ZNet instance = ZNet.instance; if (instance != null && instance.IsServer() && _managedBans.TryGetValue(playerId, out var _)) { _managedBans.Remove(playerId); Plugin.Log.LogInfo((object)$"Unbanned player {playerName} (ID: {playerId}) - bankruptcy ban expired"); } } public bool ShouldBlockConnection(long playerId, out string reason) { reason = null; LandlordData landlordData = TerritoryManager.Instance?.Data; if (landlordData == null) { return false; } if (landlordData.BannedPlayers.TryGetValue(playerId, out var value) && !value.IsExpired) { reason = $"You are banned for bankruptcy until {value.BanEndTime:g}\nTime remaining: {value.GetTimeRemainingString()}"; return true; } return false; } private ZNetPeer GetPeerByPlayerId(long playerId) { foreach (ZNetPeer peer in ZNet.instance.GetPeers()) { } return null; } private void AddToBanList(string platformId, string playerName, string reason) { try { string text = platformId + " // " + playerName + " - " + reason + " (FreyjaLandlord bankruptcy ban)"; using (StreamWriter streamWriter = File.AppendText(_banListPath)) { streamWriter.WriteLine(text); } Plugin.Log.LogInfo((object)("Added to ban list: " + text)); } catch (Exception ex) { Plugin.Log.LogError((object)("Failed to write to ban list: " + ex.Message)); } } private void RemoveFromBanList(string platformId) { try { if (File.Exists(_banListPath)) { List list = new List(File.ReadAllLines(_banListPath)); list.RemoveAll((string l) => l.StartsWith(platformId)); File.WriteAllLines(_banListPath, list); } } catch (Exception ex) { Plugin.Log.LogError((object)("Failed to update ban list: " + ex.Message)); } } public void CheckBanExpiries() { List list = new List(); foreach (KeyValuePair managedBan in _managedBans) { if (managedBan.Value.IsExpired) { list.Add(managedBan.Key); } } foreach (long item in list) { if (_managedBans.TryGetValue(item, out var value)) { UnbanPlayer(item, value.PlayerName); } } } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } } public class LandlordRPC : MonoBehaviour { private const string RPC_RequestData = "FreyjaLandlord_RequestData"; private const string RPC_SyncData = "FreyjaLandlord_SyncData"; private const string RPC_TerritoryUpdate = "FreyjaLandlord_TerritoryUpdate"; private const string RPC_ClaimTerritory = "FreyjaLandlord_ClaimTerritory"; private const string RPC_ClaimResult = "FreyjaLandlord_ClaimResult"; private const string RPC_AbandonTerritory = "FreyjaLandlord_AbandonTerritory"; private const string RPC_PlaceBid = "FreyjaLandlord_PlaceBid"; private const string RPC_BidUpdate = "FreyjaLandlord_BidUpdate"; private const string RPC_PayDebt = "FreyjaLandlord_PayDebt"; private const string RPC_ForgivDebt = "FreyjaLandlord_ForgiveDebt"; private const string RPC_CollectDebt = "FreyjaLandlord_CollectDebt"; private const string RPC_Notification = "FreyjaLandlord_Notification"; private const string RPC_WithdrawIncome = "FreyjaLandlord_WithdrawIncome"; private const string RPC_AddGuardian = "FreyjaLandlord_AddGuardian"; private const string RPC_RemoveGuardian = "FreyjaLandlord_RemoveGuardian"; private const string RPC_PlayerPosition = "FreyjaLandlord_PlayerPosition"; private const string RPC_DebtorWards = "FreyjaLandlord_DebtorWards"; private const string RPC_DebtorPosition = "FreyjaLandlord_DebtorPosition"; private const string RPC_PayGlobalDebt = "FreyjaLandlord_PayGlobalDebt"; public static LandlordRPC Instance { get; private set; } public event Action OnNotificationReceived; public event Action OnClaimResultReceived; private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { Instance = this; } } private void Start() { RegisterRPCs(); } private long GetServerPeerID() { ZNet instance = ZNet.instance; if (instance != null && instance.IsServer()) { return 0L; } ZNet instance2 = ZNet.instance; return ((instance2 != null) ? instance2.GetServerPeer() : null)?.m_uid ?? 0; } private void RegisterRPCs() { if (ZRoutedRpc.instance == null) { Plugin.Log.LogWarning((object)"ZRoutedRpc not available - RPCs not registered"); return; } ZRoutedRpc.instance.Register("FreyjaLandlord_RequestData", (Action)RPC_OnRequestData); ZRoutedRpc.instance.Register("FreyjaLandlord_SyncData", (Action)RPC_OnSyncData); ZRoutedRpc.instance.Register("FreyjaLandlord_TerritoryUpdate", (Action)RPC_OnTerritoryUpdate); ZRoutedRpc.instance.Register("FreyjaLandlord_ClaimTerritory", (Action)RPC_OnClaimTerritory); ZRoutedRpc.instance.Register("FreyjaLandlord_ClaimResult", (Action)RPC_OnClaimResult); ZRoutedRpc.instance.Register("FreyjaLandlord_AbandonTerritory", (Action)RPC_OnAbandonTerritory); ZRoutedRpc.instance.Register("FreyjaLandlord_PlaceBid", (Action)RPC_OnPlaceBid); ZRoutedRpc.instance.Register("FreyjaLandlord_BidUpdate", (Action)RPC_OnBidUpdate); ZRoutedRpc.instance.Register("FreyjaLandlord_PayDebt", (Action)RPC_OnPayDebt); ZRoutedRpc.instance.Register("FreyjaLandlord_ForgiveDebt", (Action)RPC_OnForgiveDebt); ZRoutedRpc.instance.Register("FreyjaLandlord_CollectDebt", (Action)RPC_OnCollectDebt); ZRoutedRpc.instance.Register("FreyjaLandlord_Notification", (Action)RPC_OnNotification); ZRoutedRpc.instance.Register("FreyjaLandlord_WithdrawIncome", (Action)RPC_OnWithdrawIncome); ZRoutedRpc.instance.Register("FreyjaLandlord_AddGuardian", (Action)RPC_OnAddGuardian); ZRoutedRpc.instance.Register("FreyjaLandlord_RemoveGuardian", (Action)RPC_OnRemoveGuardian); ZRoutedRpc.instance.Register("FreyjaLandlord_PlayerPosition", (Action)RPC_OnPlayerPosition); ZRoutedRpc.instance.Register("FreyjaLandlord_DebtorWards", (Action)RPC_OnDebtorWards); ZRoutedRpc.instance.Register("FreyjaLandlord_DebtorPosition", (Action)RPC_OnDebtorPosition); ZRoutedRpc.instance.Register("FreyjaLandlord_PayGlobalDebt", (Action)RPC_OnPayGlobalDebt); Plugin.Log.LogInfo((object)"Landlord RPCs registered"); } public void RequestDataFromServer() { //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(); Player localPlayer = Player.m_localPlayer; val.Write((localPlayer != null) ? localPlayer.GetPlayerID() : 0); ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.InvokeRoutedRPC(GetServerPeerID(), "FreyjaLandlord_RequestData", new object[1] { val }); } } private void RPC_OnRequestData(long sender, ZPackage pkg) { if (ZNet.instance.IsServer()) { SyncAllDataToClient(sender); } } public void SyncAllDataToClients() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown if (!ZNet.instance.IsServer()) { return; } LandlordData landlordData = TerritoryManager.Instance?.Data; if (landlordData == null) { return; } byte[] array = landlordData.Serialize(); ZPackage val = new ZPackage(); val.Write(array.Length); val.Write(array); foreach (ZNetPeer peer in ZNet.instance.GetPeers()) { ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.InvokeRoutedRPC(peer.m_uid, "FreyjaLandlord_SyncData", new object[1] { val }); } } } public void SyncAllDataToClient(long clientId) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown if (!ZNet.instance.IsServer()) { return; } LandlordData landlordData = TerritoryManager.Instance?.Data; if (landlordData != null) { byte[] array = landlordData.Serialize(); ZPackage val = new ZPackage(); val.Write(array.Length); val.Write(array); ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.InvokeRoutedRPC(clientId, "FreyjaLandlord_SyncData", new object[1] { val }); } } } private void RPC_OnSyncData(long sender, ZPackage pkg) { int num = pkg.ReadInt(); byte[] data = pkg.ReadByteArray(); LandlordData landlordData = LandlordData.Deserialize(data); TerritoryManager.Instance?.ApplyServerData(landlordData); Plugin.Log.LogInfo((object)$"Received landlord data sync: {landlordData.Territories.Count} territories"); } public void BroadcastTerritoryUpdate(Territory territory) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown if (!ZNet.instance.IsServer()) { return; } ZPackage val = new ZPackage(); WriteTerritory(val, territory); foreach (ZNetPeer peer in ZNet.instance.GetPeers()) { ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.InvokeRoutedRPC(peer.m_uid, "FreyjaLandlord_TerritoryUpdate", new object[1] { val }); } } } private void RPC_OnTerritoryUpdate(long sender, ZPackage pkg) { Territory territory = ReadTerritory(pkg); TerritoryManager.Instance?.ApplyTerritoryUpdate(territory); } public void RequestClaimTerritory(Vector2i gridPos) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { ZPackage val = new ZPackage(); val.Write(localPlayer.GetPlayerID()); val.Write(localPlayer.GetPlayerName()); val.Write(gridPos.x); val.Write(gridPos.y); ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.InvokeRoutedRPC(GetServerPeerID(), "FreyjaLandlord_ClaimTerritory", new object[1] { val }); } } } private void RPC_OnClaimTerritory(long sender, ZPackage pkg) { //IL_0045: 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_0058: Expected O, but got Unknown if (ZNet.instance.IsServer()) { long playerId = pkg.ReadLong(); string playerName = pkg.ReadString(); int num = pkg.ReadInt(); int num2 = pkg.ReadInt(); ClaimResult claimResult = TerritoryManager.Instance?.TryClaimTerritory(playerId, playerName, new Vector2i(num, num2)); ZPackage val = new ZPackage(); val.Write(claimResult?.Success ?? false); val.Write(claimResult?.Message ?? "Unknown error"); ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.InvokeRoutedRPC(sender, "FreyjaLandlord_ClaimResult", new object[1] { val }); } } } private void RPC_OnClaimResult(long sender, ZPackage pkg) { bool success = pkg.ReadBool(); string message = pkg.ReadString(); this.OnClaimResultReceived?.Invoke(new ClaimResult(success, message)); } public void RequestAbandonTerritory(Vector2i gridPos) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { ZPackage val = new ZPackage(); val.Write(localPlayer.GetPlayerID()); val.Write(gridPos.x); val.Write(gridPos.y); ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.InvokeRoutedRPC(GetServerPeerID(), "FreyjaLandlord_AbandonTerritory", new object[1] { val }); } } } private void RPC_OnAbandonTerritory(long sender, ZPackage pkg) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (ZNet.instance.IsServer()) { long playerId = pkg.ReadLong(); int num = pkg.ReadInt(); int num2 = pkg.ReadInt(); TerritoryManager.Instance?.AbandonTerritory(playerId, new Vector2i(num, num2)); } } public void RequestPlaceBid(Vector2i gridPos, int amount) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { ZPackage val = new ZPackage(); val.Write(localPlayer.GetPlayerID()); val.Write(localPlayer.GetPlayerName()); val.Write(gridPos.x); val.Write(gridPos.y); val.Write(amount); ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.InvokeRoutedRPC(GetServerPeerID(), "FreyjaLandlord_PlaceBid", new object[1] { val }); } } } private void RPC_OnPlaceBid(long sender, ZPackage pkg) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) if (ZNet.instance.IsServer()) { long playerId = pkg.ReadLong(); string playerName = pkg.ReadString(); int num = pkg.ReadInt(); int num2 = pkg.ReadInt(); int bidAmount = pkg.ReadInt(); BidResult bidResult = AuctionManager.Instance?.PlaceBid(playerId, playerName, new Vector2i(num, num2), bidAmount); SendNotification(sender, (bidResult != null && bidResult.Success) ? ("" + bidResult.Message + "") : ("" + (bidResult?.Message ?? "Bid failed") + "")); } } public void BroadcastAuctionBid(Auction auction, AuctionBid bid) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_001f: 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) if (!ZNet.instance.IsServer()) { return; } ZPackage val = new ZPackage(); val.Write(auction.TerritoryGrid.x); val.Write(auction.TerritoryGrid.y); val.Write(bid.PlayerId); val.Write(bid.PlayerName); val.Write(bid.Amount); foreach (ZNetPeer peer in ZNet.instance.GetPeers()) { ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.InvokeRoutedRPC(peer.m_uid, "FreyjaLandlord_BidUpdate", new object[1] { val }); } } } private void RPC_OnBidUpdate(long sender, ZPackage pkg) { int num = pkg.ReadInt(); int num2 = pkg.ReadInt(); long num3 = pkg.ReadLong(); string text = pkg.ReadString(); int num4 = pkg.ReadInt(); } public void RequestPayDebt() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { ZPackage val = new ZPackage(); val.Write(localPlayer.GetPlayerID()); ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.InvokeRoutedRPC(GetServerPeerID(), "FreyjaLandlord_PayDebt", new object[1] { val }); } } } private void RPC_OnPayDebt(long sender, ZPackage pkg) { if (ZNet.instance.IsServer()) { long debtorId = pkg.ReadLong(); bool flag = TollManager.Instance?.PayDebt(debtorId) ?? false; SendNotification(sender, flag ? "Debt paid!" : "Failed to pay debt"); } } public void RequestPayGlobalDebt(int amount) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { ZPackage val = new ZPackage(); val.Write(localPlayer.GetPlayerID()); val.Write(amount); ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.InvokeRoutedRPC(GetServerPeerID(), "FreyjaLandlord_PayGlobalDebt", new object[1] { val }); } } } private void RPC_OnPayGlobalDebt(long sender, ZPackage pkg) { if (!ZNet.instance.IsServer()) { return; } long playerId = pkg.ReadLong(); int num = pkg.ReadInt(); Player val = Player.GetAllPlayers().Find((Player p) => p.GetPlayerID() == playerId); if ((Object)(object)val == (Object)null) { SendNotification(sender, "Player not found"); return; } Inventory inventory = ((Humanoid)val).GetInventory(); int num2 = ((inventory != null) ? inventory.CountItems("$item_coins", -1, true) : 0); if (num2 < num) { SendNotification(sender, $"Not enough coins! Need {num}, have {num2}"); return; } inventory.RemoveItem("$item_coins", num, -1, true); LandlordData landlordData = TerritoryManager.Instance?.Data; if (landlordData != null) { int starLevelBonus = landlordData.GetStarLevelBonus(); landlordData.PayGlobalDebt(num); int starLevelBonus2 = landlordData.GetStarLevelBonus(); TerritoryManager.Instance?.MarkDirty(); string text = $"Paid {num} coins to Odin!\n" + $"Global Debt: {landlordData.GlobalDebt} (Monster bonus: +{starLevelBonus2} stars)"; if (starLevelBonus2 < starLevelBonus) { text += "\nDifficulty reduced!"; } SendNotification(sender, text); } } public void RequestForgiveDebt(long debtorId) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { ZPackage val = new ZPackage(); val.Write(localPlayer.GetPlayerID()); val.Write(debtorId); ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.InvokeRoutedRPC(GetServerPeerID(), "FreyjaLandlord_ForgiveDebt", new object[1] { val }); } } } private void RPC_OnForgiveDebt(long sender, ZPackage pkg) { if (ZNet.instance.IsServer()) { long landlordId = pkg.ReadLong(); long debtorId = pkg.ReadLong(); bool flag = TollManager.Instance?.ForgiveDeb(landlordId, debtorId) ?? false; SendNotification(sender, flag ? "Debt forgiven" : "Failed to forgive debt"); } } public void RequestCollectDebt(long debtorId) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { ZPackage val = new ZPackage(); val.Write(localPlayer.GetPlayerID()); val.Write(debtorId); ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.InvokeRoutedRPC(GetServerPeerID(), "FreyjaLandlord_CollectDebt", new object[1] { val }); } } } private void RPC_OnCollectDebt(long sender, ZPackage pkg) { if (ZNet.instance.IsServer()) { long landlordId = pkg.ReadLong(); long debtorId = pkg.ReadLong(); bool flag = TollManager.Instance?.CollectDebt(landlordId, debtorId) ?? false; SendNotification(sender, flag ? "Debt collected" : "Failed to collect debt"); } } public void RequestWithdrawIncome(bool all = true, Vector2i? gridPos = null) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { ZPackage val = new ZPackage(); val.Write(localPlayer.GetPlayerID()); val.Write(all); if (!all && gridPos.HasValue) { val.Write(gridPos.Value.x); val.Write(gridPos.Value.y); } ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.InvokeRoutedRPC(GetServerPeerID(), "FreyjaLandlord_WithdrawIncome", new object[1] { val }); } } } private void RPC_OnWithdrawIncome(long sender, ZPackage pkg) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) if (!ZNet.instance.IsServer()) { return; } long playerId = pkg.ReadLong(); int num; if (pkg.ReadBool()) { num = TerritoryManager.Instance?.WithdrawAllIncome(playerId) ?? 0; } else { int num2 = pkg.ReadInt(); int num3 = pkg.ReadInt(); num = TerritoryManager.Instance?.WithdrawIncome(playerId, new Vector2i(num2, num3)) ?? 0; } if (num > 0) { Player val = Player.GetAllPlayers().Find((Player p) => p.GetPlayerID() == playerId); if (val != null) { Inventory inventory = ((Humanoid)val).GetInventory(); if (inventory != null) { inventory.AddItem(ObjectDB.instance.GetItemPrefab("Coins"), num); } } SendNotification(sender, $"Withdrew {num} coins"); } else { SendNotification(sender, "No income to withdraw"); } } public void RequestAddGuardian(Vector2i gridPos, long guardianId, string guardianName) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { ZPackage val = new ZPackage(); val.Write(localPlayer.GetPlayerID()); val.Write(gridPos.x); val.Write(gridPos.y); val.Write(guardianId); val.Write(guardianName); ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.InvokeRoutedRPC(GetServerPeerID(), "FreyjaLandlord_AddGuardian", new object[1] { val }); } } } private void RPC_OnAddGuardian(long sender, ZPackage pkg) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (ZNet.instance.IsServer()) { long ownerId = pkg.ReadLong(); int num = pkg.ReadInt(); int num2 = pkg.ReadInt(); long guardianId = pkg.ReadLong(); string text = pkg.ReadString(); bool flag = TerritoryManager.Instance?.AddGuardian(ownerId, new Vector2i(num, num2), guardianId, text) ?? false; SendNotification(sender, flag ? ("" + text + " added as guardian") : "Failed to add guardian"); } } public void RequestRemoveGuardian(Vector2i gridPos, long guardianId) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { ZPackage val = new ZPackage(); val.Write(localPlayer.GetPlayerID()); val.Write(gridPos.x); val.Write(gridPos.y); val.Write(guardianId); ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.InvokeRoutedRPC(GetServerPeerID(), "FreyjaLandlord_RemoveGuardian", new object[1] { val }); } } } private void RPC_OnRemoveGuardian(long sender, ZPackage pkg) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) if (ZNet.instance.IsServer()) { long ownerId = pkg.ReadLong(); int num = pkg.ReadInt(); int num2 = pkg.ReadInt(); long guardianId = pkg.ReadLong(); bool flag = TerritoryManager.Instance?.RemoveGuardian(ownerId, new Vector2i(num, num2), guardianId) ?? false; SendNotification(sender, flag ? "Guardian removed" : "Failed to remove guardian"); } } public void ReportPlayerPosition(Vector3 position) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } long playerID = localPlayer.GetPlayerID(); string playerName = localPlayer.GetPlayerName(); ZNet instance = ZNet.instance; if (instance != null && instance.IsServer()) { TollManager.Instance?.CheckPlayerPosition(playerID, playerName, position); return; } ZPackage val = new ZPackage(); val.Write(playerID); val.Write(playerName); val.Write(position.x); val.Write(position.y); val.Write(position.z); ZRoutedRpc instance2 = ZRoutedRpc.instance; if (instance2 != null) { instance2.InvokeRoutedRPC(GetServerPeerID(), "FreyjaLandlord_PlayerPosition", new object[1] { val }); } } private void RPC_OnPlayerPosition(long sender, ZPackage pkg) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) if (ZNet.instance.IsServer()) { long playerId = pkg.ReadLong(); string playerName = pkg.ReadString(); float num = pkg.ReadSingle(); float num2 = pkg.ReadSingle(); float num3 = pkg.ReadSingle(); TollManager.Instance?.CheckPlayerPosition(playerId, playerName, new Vector3(num, num2, num3)); } } public void SendDebtorWardLocations(long landlordId, long debtorId, string debtorName, List wards) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown if (!ZNet.instance.IsServer()) { return; } ZPackage val = new ZPackage(); val.Write(debtorId); val.Write(debtorName); val.Write(wards.Count); foreach (WardLocation ward in wards) { val.Write(ward.Position.x); val.Write(ward.Position.y); val.Write(ward.Position.z); val.Write(ward.IsEnabled); val.Write(ward.WardName ?? "Ward"); } ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.InvokeRoutedRPC(landlordId, "FreyjaLandlord_DebtorWards", new object[1] { val }); } } private void RPC_OnDebtorWards(long sender, ZPackage pkg) { //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) long debtorId = pkg.ReadLong(); string debtorName = pkg.ReadString(); int num = pkg.ReadInt(); List list = new List(); for (int i = 0; i < num; i++) { WardLocation item = new WardLocation { Position = new Vector3(pkg.ReadSingle(), pkg.ReadSingle(), pkg.ReadSingle()), IsEnabled = pkg.ReadBool(), WardName = pkg.ReadString() }; list.Add(item); } DebtorTracker.Instance?.ReceiveDebtorWards(debtorId, debtorName, list); } public void SendDebtorPosition(long landlordId, DebtorPosition position) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown if (ZNet.instance.IsServer()) { ZPackage val = new ZPackage(); val.Write(position.PlayerId); val.Write(position.PlayerName); val.Write(position.Position.x); val.Write(position.Position.y); val.Write(position.Position.z); val.Write(position.LastUpdate.ToBinary()); ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.InvokeRoutedRPC(landlordId, "FreyjaLandlord_DebtorPosition", new object[1] { val }); } } } private void RPC_OnDebtorPosition(long sender, ZPackage pkg) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) DebtorPosition position = new DebtorPosition { PlayerId = pkg.ReadLong(), PlayerName = pkg.ReadString(), Position = new Vector3(pkg.ReadSingle(), pkg.ReadSingle(), pkg.ReadSingle()), LastUpdate = DateTime.FromBinary(pkg.ReadLong()) }; DebtorTracker.Instance?.ReceiveDebtorPosition(position); } public void SendNotification(long targetPlayerId, string message) { ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.InvokeRoutedRPC(targetPlayerId, "FreyjaLandlord_Notification", new object[1] { message }); } } public void BroadcastGlobalMessage(string message) { ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "FreyjaLandlord_Notification", new object[1] { message }); } } private void RPC_OnNotification(long sender, string message) { this.OnNotificationReceived?.Invoke(message); MessageHud instance = MessageHud.instance; if (instance != null) { instance.ShowMessage((MessageType)2, message, 0, (Sprite)null, false); } } private void WriteTerritory(ZPackage pkg, Territory territory) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) pkg.Write(territory.GridPosition.x); pkg.Write(territory.GridPosition.y); pkg.Write(territory.OwnerPlayerId); pkg.Write(territory.OwnerName); pkg.Write(territory.ClaimTime.ToBinary()); pkg.Write(territory.LastUpkeepTime.ToBinary()); pkg.Write(territory.IsUnlocked); pkg.Write(territory.AccumulatedIncome); pkg.Write(territory.HasPOI); pkg.Write(territory.IsAbandoned); pkg.Write(territory.IsInAuction); pkg.Write(territory.IsPvPEnabled); pkg.Write(territory.LootTaxPercent); pkg.Write(territory.LastPassiveIncomeTicks); pkg.Write(territory.IsEmperorTerritory); pkg.Write(territory.Prestige); pkg.Write(territory.BiomeComposition.Count); foreach (KeyValuePair item in territory.BiomeComposition) { pkg.Write(item.Key); pkg.Write(item.Value); } pkg.Write(territory.Guardians.Count); foreach (long guardian in territory.Guardians) { pkg.Write(guardian); } pkg.Write(territory.Vault?.Count ?? 0); if (territory.Vault == null) { return; } foreach (VaultItem item2 in territory.Vault) { pkg.Write(item2.PrefabName ?? ""); pkg.Write(item2.DisplayName ?? ""); pkg.Write(item2.Amount); } } private Territory ReadTerritory(ZPackage pkg) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) Territory territory = new Territory(); territory.GridPosition = new Vector2i(pkg.ReadInt(), pkg.ReadInt()); territory.OwnerPlayerId = pkg.ReadLong(); territory.OwnerName = pkg.ReadString(); territory.ClaimTime = DateTime.FromBinary(pkg.ReadLong()); territory.LastUpkeepTime = DateTime.FromBinary(pkg.ReadLong()); territory.IsUnlocked = pkg.ReadBool(); territory.AccumulatedIncome = pkg.ReadInt(); territory.HasPOI = pkg.ReadBool(); territory.IsAbandoned = pkg.ReadBool(); territory.IsInAuction = pkg.ReadBool(); territory.IsPvPEnabled = pkg.ReadBool(); territory.LootTaxPercent = pkg.ReadInt(); territory.LastPassiveIncomeTicks = pkg.ReadLong(); territory.IsEmperorTerritory = pkg.ReadBool(); territory.Prestige = pkg.ReadInt(); int num = pkg.ReadInt(); for (int i = 0; i < num; i++) { int key = pkg.ReadInt(); float value = pkg.ReadSingle(); territory.BiomeComposition[key] = value; } int num2 = pkg.ReadInt(); for (int j = 0; j < num2; j++) { territory.Guardians.Add(pkg.ReadLong()); } territory.Vault = new List(); int num3 = pkg.ReadInt(); for (int k = 0; k < num3; k++) { territory.Vault.Add(new VaultItem(pkg.ReadString(), pkg.ReadString(), pkg.ReadInt())); } return territory; } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } } } namespace FreyjaLandlord.Data { [Serializable] public class Auction { public static readonly TimeSpan AuctionDuration = TimeSpan.FromHours(48.0); public const int MinBidIncrement = 50; public int TerritoryGridX { get; set; } public int TerritoryGridY { get; set; } public long StartTimeTicks { get; set; } public long EndTimeTicks { get; set; } public int MinimumBid { get; set; } public List Bids { get; set; } = new List(); public bool IsFinalized { get; set; } public Vector2i TerritoryGrid { get { //IL_000c: Unknown result type (might be due to invalid IL or missing references) return new Vector2i(TerritoryGridX, TerritoryGridY); } set { //IL_0002: 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) TerritoryGridX = value.x; TerritoryGridY = value.y; } } public DateTime StartTime { get { return DateTime.FromBinary(StartTimeTicks); } set { StartTimeTicks = value.ToBinary(); } } public DateTime EndTime { get { return DateTime.FromBinary(EndTimeTicks); } set { EndTimeTicks = value.ToBinary(); } } public int CurrentBid { get { if (Bids.Count == 0) { return MinimumBid; } return Bids[Bids.Count - 1].Amount; } } public AuctionBid CurrentLeader => (Bids.Count > 0) ? Bids[Bids.Count - 1] : null; public TimeSpan TimeRemaining { get { TimeSpan timeSpan = EndTime - DateTime.UtcNow; return (timeSpan > TimeSpan.Zero) ? timeSpan : TimeSpan.Zero; } } public bool HasEnded => DateTime.UtcNow >= EndTime; public int MinimumValidBid { get { if (Bids.Count == 0) { return MinimumBid; } return CurrentBid + 50; } } public Auction() { StartTime = DateTime.UtcNow; EndTime = StartTime + AuctionDuration; Bids = new List(); } public Auction(Vector2i grid, int minimumBid) : this() { //IL_0009: Unknown result type (might be due to invalid IL or missing references) TerritoryGrid = grid; MinimumBid = minimumBid; } public bool PlaceBid(long playerId, string playerName, int amount) { if (HasEnded || IsFinalized) { return false; } if (amount < MinimumValidBid) { return false; } Bids.Add(new AuctionBid(playerId, playerName, amount)); if (TimeRemaining < TimeSpan.FromMinutes(5.0)) { EndTime = DateTime.UtcNow + TimeSpan.FromMinutes(5.0); } return true; } public string GetTimeRemainingString() { TimeSpan timeRemaining = TimeRemaining; if (timeRemaining.TotalDays >= 1.0) { return $"{(int)timeRemaining.TotalDays}d {timeRemaining.Hours}h"; } if (timeRemaining.TotalHours >= 1.0) { return $"{(int)timeRemaining.TotalHours}h {timeRemaining.Minutes}m"; } if (timeRemaining.TotalMinutes >= 1.0) { return $"{(int)timeRemaining.TotalMinutes}m"; } return "Ending..."; } } [Serializable] public class AuctionBid { public long PlayerId { get; set; } public string PlayerName { get; set; } public int Amount { get; set; } public long BidTimeTicks { get; set; } public DateTime BidTime { get { return DateTime.FromBinary(BidTimeTicks); } set { BidTimeTicks = value.ToBinary(); } } public AuctionBid() { BidTime = DateTime.UtcNow; } public AuctionBid(long playerId, string playerName, int amount) : this() { PlayerId = playerId; PlayerName = playerName; Amount = amount; } } [Serializable] public class Debt { public static readonly TimeSpan VassalEscalationThreshold = TimeSpan.FromDays(7.0); public long DebtorPlayerId { get; set; } public string DebtorName { get; set; } public long CreditorPlayerId { get; set; } public string CreditorName { get; set; } public int TerritoryGridX { get; set; } public int TerritoryGridY { get; set; } public int Amount { get; set; } public long IncurredTimeTicks { get; set; } public long LastNotificationTimeTicks { get; set; } public int VassalLootPercent => ((DateTime.UtcNow - IncurredTime).TotalDays >= 7.0) ? 30 : 10; public Vector2i TerritoryGrid { get { //IL_000c: Unknown result type (might be due to invalid IL or missing references) return new Vector2i(TerritoryGridX, TerritoryGridY); } set { //IL_0002: 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) TerritoryGridX = value.x; TerritoryGridY = value.y; } } public DateTime IncurredTime { get { return DateTime.FromBinary(IncurredTimeTicks); } set { IncurredTimeTicks = value.ToBinary(); } } public DateTime LastNotificationTime { get { return DateTime.FromBinary(LastNotificationTimeTicks); } set { LastNotificationTimeTicks = value.ToBinary(); } } public TimeSpan TimeUntilEscalation { get { TimeSpan timeSpan = DateTime.UtcNow - IncurredTime; TimeSpan timeSpan2 = VassalEscalationThreshold - timeSpan; return (timeSpan2 > TimeSpan.Zero) ? timeSpan2 : TimeSpan.Zero; } } public bool IsEscalated => TimeUntilEscalation == TimeSpan.Zero; public double DaysRemaining => TimeUntilEscalation.TotalDays; public Debt() { IncurredTime = DateTime.UtcNow; LastNotificationTime = DateTime.UtcNow; } public Debt(long debtorId, string debtorName, long creditorId, string creditorName, Vector2i territory, int amount) : this() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) DebtorPlayerId = debtorId; DebtorName = debtorName; CreditorPlayerId = creditorId; CreditorName = creditorName; TerritoryGrid = territory; Amount = amount; } public string GetTimeRemainingString() { TimeSpan timeUntilEscalation = TimeUntilEscalation; if (timeUntilEscalation.TotalDays >= 1.0) { return $"{(int)timeUntilEscalation.TotalDays}d {timeUntilEscalation.Hours}h"; } if (timeUntilEscalation.TotalHours >= 1.0) { return $"{(int)timeUntilEscalation.TotalHours}h {timeUntilEscalation.Minutes}m"; } if (timeUntilEscalation.TotalMinutes >= 1.0) { return $"{(int)timeUntilEscalation.TotalMinutes}m"; } return "< 1m"; } public void AddDebt(int additionalAmount) { Amount += additionalAmount; } } [Serializable] public class BanRecord { public long PlayerId { get; set; } public string PlayerName { get; set; } public long BanStartTimeTicks { get; set; } public long BanEndTimeTicks { get; set; } public string Reason { get; set; } public DateTime BanStartTime { get { return DateTime.FromBinary(BanStartTimeTicks); } set { BanStartTimeTicks = value.ToBinary(); } } public DateTime BanEndTime { get { return DateTime.FromBinary(BanEndTimeTicks); } set { BanEndTimeTicks = value.ToBinary(); } } public bool IsExpired => DateTime.UtcNow >= BanEndTime; public TimeSpan TimeRemaining { get { TimeSpan timeSpan = BanEndTime - DateTime.UtcNow; return (timeSpan > TimeSpan.Zero) ? timeSpan : TimeSpan.Zero; } } public BanRecord() { } public BanRecord(long playerId, string playerName, TimeSpan duration, string reason) { PlayerId = playerId; PlayerName = playerName; BanStartTime = DateTime.UtcNow; BanEndTime = BanStartTime + duration; Reason = reason; } public string GetTimeRemainingString() { TimeSpan timeRemaining = TimeRemaining; if (timeRemaining.TotalDays >= 1.0) { return $"{(int)timeRemaining.TotalDays}d {timeRemaining.Hours}h"; } if (timeRemaining.TotalHours >= 1.0) { return $"{(int)timeRemaining.TotalHours}h {timeRemaining.Minutes}m"; } return "< 1h"; } } [Serializable] public class LandlordData { public const int DataVersion = 8; public static readonly string[] AllBossPrefabs = new string[7] { "Eikthyr", "gd_king", "Bonemass", "Dragon", "GoblinKing", "SeekerQueen", "Fader" }; public int Version { get; set; } = 8; public Dictionary Territories { get; set; } = new Dictionary(); public Dictionary Debts { get; set; } = new Dictionary(); public Dictionary Auctions { get; set; } = new Dictionary(); public Dictionary BannedPlayers { get; set; } = new Dictionary(); public Dictionary PlayerPermitCounts { get; set; } = new Dictionary(); public Dictionary PlayerStats { get; set; } = new Dictionary(); public int GlobalDebt { get; set; } = 0; public int LastStarLevelBonus { get; set; } = 0; public Dictionary> PlayerBossKills { get; set; } = new Dictionary>(); public Dictionary GlobalDebtContributions { get; set; } = new Dictionary(); public Dictionary GlobalDebtContributorNames { get; set; } = new Dictionary(); public Dictionary PlayerKeys { get; set; } = new Dictionary(); public List RaidLog { get; set; } = new List(); public GlobalTribute CurrentTribute { get; set; } public LandlordData() { Territories = new Dictionary(); Debts = new Dictionary(); Auctions = new Dictionary(); BannedPlayers = new Dictionary(); PlayerPermitCounts = new Dictionary(); PlayerStats = new Dictionary(); GlobalDebt = 0; LastStarLevelBonus = 0; PlayerBossKills = new Dictionary>(); GlobalDebtContributions = new Dictionary(); GlobalDebtContributorNames = new Dictionary(); PlayerKeys = new Dictionary(); RaidLog = new List(); CurrentTribute = null; } public void GenerateNewTribute() { //IL_003b: 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) Random random = new Random(); ObjectiveType[] array = new ObjectiveType[2] { ObjectiveType.KillMonsters, ObjectiveType.GatherResources }; ObjectiveType type = array[random.Next(array.Length)]; Biome[] array2 = new Biome[5]; RuntimeHelpers.InitializeArray(array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); Biome[] array3 = (Biome[])(object)array2; Biome biome = array3[random.Next(array3.Length)]; TerritoryObjective territoryObjective = ObjectiveDefinitions.GenerateObjective(biome, type, forUnlock: true); int num = random.Next(50, 81); int num2 = territoryObjective.RequiredAmount * num; if (territoryObjective.Type == ObjectiveType.KillMonsters) { string[] array4 = new string[6] { "Troll", "StoneGolem", "Gjall", "GoblinBrute", "Lox", "Morgen" }; string[] array5 = new string[8] { "Greydwarf_Elite", "Draugr_Elite", "GoblinShaman", "Wraith", "Fenring", "SeekerBrute", "Charred_Mage", "Asksvin" }; bool flag = false; bool flag2 = false; string[] array6 = array4; foreach (string text in array6) { if (territoryObjective.TargetPrefab == text) { flag = true; break; } } if (!flag) { string[] array7 = array5; foreach (string text2 in array7) { if (territoryObjective.TargetPrefab == text2) { flag2 = true; break; } } } if (flag) { num2 = Math.Max(5, num2 / 8); } else if (flag2) { num2 = Math.Max(10, num2 / 5); } } CurrentTribute = new GlobalTribute { Type = territoryObjective.Type, TargetPrefab = territoryObjective.TargetPrefab, TargetDisplayName = territoryObjective.TargetDisplayName, BaseRequiredAmount = num2, CurrentAmount = 0, StartTimestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds() }; } public void AddKey(long playerId, int keyType) { if (keyType >= 0 && keyType <= 2) { if (!PlayerKeys.ContainsKey(playerId)) { PlayerKeys[playerId] = new int[3]; } PlayerKeys[playerId][keyType]++; } } public int[] GetKeys(long playerId) { if (PlayerKeys.TryGetValue(playerId, out var value)) { return value; } return new int[3]; } public bool RemoveKey(long playerId, int keyType) { if (keyType < 0 || keyType > 2) { return false; } if (!PlayerKeys.TryGetValue(playerId, out var value)) { return false; } if (value[keyType] <= 0) { return false; } value[keyType]--; return true; } public void AddGlobalDebt(int amount, long playerId = 0L, string playerName = "") { GlobalDebt += amount; if (playerId != 0) { if (!GlobalDebtContributions.ContainsKey(playerId)) { GlobalDebtContributions[playerId] = 0; } GlobalDebtContributions[playerId] += amount; if (!string.IsNullOrEmpty(playerName)) { GlobalDebtContributorNames[playerId] = playerName; } } Plugin.Log.LogInfo((object)$"Global debt increased by {amount}. Total: {GlobalDebt}"); } public bool PayGlobalDebt(int amount) { if (amount > GlobalDebt) { amount = GlobalDebt; } GlobalDebt -= amount; Plugin.Log.LogInfo((object)$"Global debt reduced by {amount}. Remaining: {GlobalDebt}"); return true; } public int GetStarLevelBonus() { int val = GlobalDebt / 5000; int val2 = LandlordConfig.MaxDebtStarBonus?.Value ?? 10; return Math.Min(val, val2); } public void RecordBossKill(long playerId, string bossPrefab) { if (!PlayerBossKills.ContainsKey(playerId)) { PlayerBossKills[playerId] = new List(); } if (!PlayerBossKills[playerId].Contains(bossPrefab)) { PlayerBossKills[playerId].Add(bossPrefab); Plugin.Log.LogInfo((object)$"Player {playerId} killed boss: {bossPrefab} (total: {PlayerBossKills[playerId].Count})"); } } public int GetBossKillCount(long playerId) { List value; return PlayerBossKills.TryGetValue(playerId, out value) ? value.Count : 0; } public int GetMaxTerritories(long playerId) { int value = LandlordConfig.MaxTerritoriesPerPlayer.Value; int bossKillCount = GetBossKillCount(playerId); return Math.Min(value + bossKillCount, 10); } public bool IsEmperor(long playerId) { int bossKillCount = GetBossKillCount(playerId); if (bossKillCount < AllBossPrefabs.Length) { return false; } List playerTerritories = GetPlayerTerritories(playerId); return playerTerritories.Count >= 10; } public bool HasKilledAllBosses(long playerId) { return GetBossKillCount(playerId) >= AllBossPrefabs.Length; } public static string GridToKey(Vector2i grid) { //IL_0005: 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) return $"{grid.x}_{grid.y}"; } public static Vector2i KeyToGrid(string key) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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) string[] array = key.Split(new char[1] { '_' }); return new Vector2i(int.Parse(array[0]), int.Parse(array[1])); } public Territory GetTerritory(Vector2i grid) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) string key = GridToKey(grid); Territory value; return Territories.TryGetValue(key, out value) ? value : null; } public void SetTerritory(Vector2i grid, Territory territory) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) Territories[GridToKey(grid)] = territory; } public void RemoveTerritory(Vector2i grid) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) Territories.Remove(GridToKey(grid)); } public List GetPlayerTerritories(long playerId) { List list = new List(); foreach (Territory value in Territories.Values) { if (value.OwnerPlayerId == playerId) { list.Add(value); } } return list; } public Debt GetDebt(long playerId) { Debt value; return Debts.TryGetValue(playerId, out value) ? value : null; } public List GetDebtsForLandlord(long landlordId) { List list = new List(); foreach (Debt value in Debts.Values) { if (value.CreditorPlayerId == landlordId) { list.Add(value); } } return list; } public Auction GetAuction(Vector2i grid) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) string key = GridToKey(grid); Auction value; return Auctions.TryGetValue(key, out value) ? value : null; } public void SetAuction(Vector2i grid, Auction auction) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) Auctions[GridToKey(grid)] = auction; } public void RemoveAuction(Vector2i grid) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) Auctions.Remove(GridToKey(grid)); } public List GetActiveAuctions() { List list = new List(); foreach (Auction value in Auctions.Values) { if (!value.HasEnded && !value.IsFinalized) { list.Add(value); } } return list; } public byte[] Serialize() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown try { ZPackage val = new ZPackage(); val.Write(8); val.Write(Territories.Count); foreach (KeyValuePair territory in Territories) { val.Write(territory.Key); WriteTerritory(val, territory.Value); } val.Write(Debts.Count); foreach (KeyValuePair debt in Debts) { val.Write(debt.Key); WriteDebt(val, debt.Value); } val.Write(Auctions.Count); foreach (KeyValuePair auction in Auctions) { val.Write(auction.Key); WriteAuction(val, auction.Value); } val.Write(BannedPlayers.Count); foreach (KeyValuePair bannedPlayer in BannedPlayers) { val.Write(bannedPlayer.Key); WriteBanRecord(val, bannedPlayer.Value); } val.Write(PlayerPermitCounts.Count); foreach (KeyValuePair playerPermitCount in PlayerPermitCounts) { val.Write(playerPermitCount.Key); val.Write(playerPermitCount.Value); } val.Write(PlayerStats.Count); foreach (KeyValuePair playerStat in PlayerStats) { val.Write(playerStat.Key); WriteStats(val, playerStat.Value); } val.Write(GlobalDebt); val.Write(PlayerBossKills.Count); foreach (KeyValuePair> playerBossKill in PlayerBossKills) { val.Write(playerBossKill.Key); val.Write(playerBossKill.Value.Count); foreach (string item in playerBossKill.Value) { val.Write(item); } } val.Write(GlobalDebtContributions.Count); foreach (KeyValuePair globalDebtContribution in GlobalDebtContributions) { val.Write(globalDebtContribution.Key); val.Write(globalDebtContribution.Value); val.Write(GlobalDebtContributorNames.TryGetValue(globalDebtContribution.Key, out var value) ? value : ""); } val.Write(PlayerKeys.Count); foreach (KeyValuePair playerKey in PlayerKeys) { val.Write(playerKey.Key); int[] array = playerKey.Value ?? new int[3]; val.Write((array.Length >= 1) ? array[0] : 0); val.Write((array.Length >= 2) ? array[1] : 0); val.Write((array.Length >= 3) ? array[2] : 0); } val.Write(RaidLog?.Count ?? 0); if (RaidLog != null) { foreach (RaidLogEntry item2 in RaidLog) { val.Write(item2.RaiderName ?? ""); val.Write(item2.OwnerName ?? ""); val.Write(item2.TerritoryName ?? ""); val.Write(item2.Success); val.Write(item2.KeyType ?? ""); val.Write(item2.ItemsSummary ?? ""); val.Write(item2.Timestamp); } } bool flag = CurrentTribute != null; val.Write(flag); if (flag) { val.Write((int)CurrentTribute.Type); val.Write(CurrentTribute.TargetPrefab ?? ""); val.Write(CurrentTribute.TargetDisplayName ?? ""); val.Write(CurrentTribute.BaseRequiredAmount); val.Write(CurrentTribute.CurrentAmount); val.Write(CurrentTribute.StartTimestamp); } return val.GetArray(); } catch (Exception ex) { Debug.LogError((object)("[FreyjaLandlord] Failed to serialize data: " + ex.Message)); return new byte[0]; } } public static LandlordData Deserialize(byte[] data) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown if (data == null || data.Length == 0) { return new LandlordData(); } try { ZPackage val = new ZPackage(data); LandlordData landlordData = new LandlordData(); landlordData.Version = val.ReadInt(); int version = landlordData.Version; int num = val.ReadInt(); for (int i = 0; i < num; i++) { string key = val.ReadString(); Territory value = ReadTerritory(val, version); landlordData.Territories[key] = value; } int num2 = val.ReadInt(); for (int j = 0; j < num2; j++) { long key2 = val.ReadLong(); Debt value2 = ReadDebt(val); landlordData.Debts[key2] = value2; } int num3 = val.ReadInt(); for (int k = 0; k < num3; k++) { string key3 = val.ReadString(); Auction value3 = ReadAuction(val); landlordData.Auctions[key3] = value3; } int num4 = val.ReadInt(); for (int l = 0; l < num4; l++) { long key4 = val.ReadLong(); BanRecord value4 = ReadBanRecord(val); landlordData.BannedPlayers[key4] = value4; } int num5 = val.ReadInt(); for (int m = 0; m < num5; m++) { long key5 = val.ReadLong(); int value5 = val.ReadInt(); landlordData.PlayerPermitCounts[key5] = value5; } int num6 = val.ReadInt(); for (int n = 0; n < num6; n++) { long key6 = val.ReadLong(); LandlordStats value6 = ReadStats(val); landlordData.PlayerStats[key6] = value6; } if (version >= 2 && val.GetPos() < val.Size()) { landlordData.GlobalDebt = val.ReadInt(); } if (version >= 4 && val.GetPos() < val.Size()) { int num7 = val.ReadInt(); for (int num8 = 0; num8 < num7; num8++) { long key7 = val.ReadLong(); int num9 = val.ReadInt(); List list = new List(); for (int num10 = 0; num10 < num9; num10++) { list.Add(val.ReadString()); } landlordData.PlayerBossKills[key7] = list; } } if (version >= 5 && val.GetPos() < val.Size()) { int num11 = val.ReadInt(); for (int num12 = 0; num12 < num11; num12++) { long key8 = val.ReadLong(); int value7 = val.ReadInt(); string value8 = val.ReadString(); landlordData.GlobalDebtContributions[key8] = value7; if (!string.IsNullOrEmpty(value8)) { landlordData.GlobalDebtContributorNames[key8] = value8; } } } if (version >= 6 && val.GetPos() < val.Size()) { int num13 = val.ReadInt(); for (int num14 = 0; num14 < num13; num14++) { long key9 = val.ReadLong(); int num15 = val.ReadInt(); int num16 = val.ReadInt(); int num17 = val.ReadInt(); landlordData.PlayerKeys[key9] = new int[3] { num15, num16, num17 }; } } if (version >= 7 && val.GetPos() < val.Size()) { int num18 = val.ReadInt(); for (int num19 = 0; num19 < num18; num19++) { RaidLogEntry raidLogEntry = new RaidLogEntry(); raidLogEntry.RaiderName = val.ReadString(); raidLogEntry.OwnerName = val.ReadString(); raidLogEntry.TerritoryName = val.ReadString(); raidLogEntry.Success = val.ReadBool(); raidLogEntry.KeyType = val.ReadString(); raidLogEntry.ItemsSummary = val.ReadString(); raidLogEntry.Timestamp = val.ReadLong(); landlordData.RaidLog.Add(raidLogEntry); } } Debug.Log((object)$"[FreyjaLandlord] Deserialize: loadedVersion={version}, pos={val.GetPos()}, size={val.Size()}, checking v8 tribute..."); if (version >= 8 && val.GetPos() < val.Size()) { bool flag = val.ReadBool(); Debug.Log((object)$"[FreyjaLandlord] Deserialize: hasTribute={flag}"); if (flag) { landlordData.CurrentTribute = new GlobalTribute(); landlordData.CurrentTribute.Type = (ObjectiveType)val.ReadInt(); landlordData.CurrentTribute.TargetPrefab = val.ReadString(); landlordData.CurrentTribute.TargetDisplayName = val.ReadString(); landlordData.CurrentTribute.BaseRequiredAmount = val.ReadInt(); landlordData.CurrentTribute.CurrentAmount = val.ReadInt(); landlordData.CurrentTribute.StartTimestamp = val.ReadLong(); Debug.Log((object)$"[FreyjaLandlord] Deserialize: Loaded tribute {landlordData.CurrentTribute.Type} {landlordData.CurrentTribute.BaseRequiredAmount}x {landlordData.CurrentTribute.TargetDisplayName}"); } } else { Debug.Log((object)$"[FreyjaLandlord] Deserialize: Skipped v8 tribute (version={version}, pos={val.GetPos()}, size={val.Size()})"); } Debug.Log((object)$"[FreyjaLandlord] Deserialize: RaidLog count={landlordData.RaidLog?.Count ?? 0}, CurrentTribute={landlordData.CurrentTribute != null}"); return landlordData; } catch (Exception ex) { Debug.LogError((object)("[FreyjaLandlord] Failed to deserialize data: " + ex.Message + "\n" + ex.StackTrace)); return new LandlordData(); } } private static void WriteTerritory(ZPackage pkg, Territory t) { pkg.Write(t.GridX); pkg.Write(t.GridY); pkg.Write(t.OwnerPlayerId); pkg.Write(t.OwnerName ?? ""); pkg.Write(t.CustomName ?? ""); pkg.Write(t.ClaimTimeTicks); pkg.Write(t.LastUpkeepTimeTicks); pkg.Write(t.IsUnlocked); pkg.Write(t.AccumulatedIncome); pkg.Write(t.HasPOI); pkg.Write(t.HasMerchant); pkg.Write(t.IsPvPEnabled); pkg.Write(t.LootTaxPercent); pkg.Write(t.LastPassiveIncomeTicks); pkg.Write(t.IsEmperorTerritory); pkg.Write(t.Prestige); pkg.Write(t.LastLootTaxChangeTicks); pkg.Write(t.LastRenameTicks); pkg.Write(t.UniquePiecesPlaced?.Count ?? 0); if (t.UniquePiecesPlaced != null) { foreach (string item in t.UniquePiecesPlaced) { pkg.Write(item); } } pkg.Write(t.IsAbandoned); pkg.Write(t.IsInAuction); pkg.Write(t.AuctionEndTimeTicks); pkg.Write(t.HighestBidderId); pkg.Write(t.HighestBidderName ?? ""); pkg.Write(t.HighestBid); pkg.Write(t.BiomeComposition?.Count ?? 0); if (t.BiomeComposition != null) { foreach (KeyValuePair item2 in t.BiomeComposition) { pkg.Write(item2.Key); pkg.Write(item2.Value); } } pkg.Write(t.Guardians?.Count ?? 0); if (t.Guardians != null) { foreach (long guardian in t.Guardians) { pkg.Write(guardian); } } pkg.Write(t.CurrentObjective != null); if (t.CurrentObjective != null) { WriteObjective(pkg, t.CurrentObjective); } pkg.Write(t.Objectives?.Count ?? 0); if (t.Objectives != null) { foreach (TerritoryObjective objective in t.Objectives) { WriteObjective(pkg, objective); } } pkg.Write(t.Vault?.Count ?? 0); if (t.Vault == null) { return; } foreach (VaultItem item3 in t.Vault) { pkg.Write(item3.PrefabName ?? ""); pkg.Write(item3.DisplayName ?? ""); pkg.Write(item3.Amount); } } private static Territory ReadTerritory(ZPackage pkg, int version) { Territory territory = new Territory(); territory.GridX = pkg.ReadInt(); territory.GridY = pkg.ReadInt(); territory.OwnerPlayerId = pkg.ReadLong(); territory.OwnerName = pkg.ReadString(); if (version >= 3) { territory.CustomName = pkg.ReadString(); } else { territory.CustomName = ""; } territory.ClaimTimeTicks = pkg.ReadLong(); territory.LastUpkeepTimeTicks = pkg.ReadLong(); territory.IsUnlocked = pkg.ReadBool(); territory.AccumulatedIncome = pkg.ReadInt(); territory.HasPOI = pkg.ReadBool(); if (version >= 3) { territory.HasMerchant = pkg.ReadBool(); } else { territory.HasMerchant = false; } if (version >= 4) { territory.IsPvPEnabled = pkg.ReadBool(); territory.LootTaxPercent = pkg.ReadInt(); territory.LastPassiveIncomeTicks = pkg.ReadLong(); territory.IsEmperorTerritory = pkg.ReadBool(); territory.Prestige = pkg.ReadInt(); territory.LastLootTaxChangeTicks = pkg.ReadLong(); if (version >= 6) { territory.LastRenameTicks = pkg.ReadLong(); } int num = pkg.ReadInt(); territory.UniquePiecesPlaced = new List(); for (int i = 0; i < num; i++) { territory.UniquePiecesPlaced.Add(pkg.ReadString()); } } territory.IsAbandoned = pkg.ReadBool(); territory.IsInAuction = pkg.ReadBool(); territory.AuctionEndTimeTicks = pkg.ReadLong(); territory.HighestBidderId = pkg.ReadLong(); territory.HighestBidderName = pkg.ReadString(); territory.HighestBid = pkg.ReadInt(); int num2 = pkg.ReadInt(); territory.BiomeComposition = new Dictionary(); for (int j = 0; j < num2; j++) { int key = pkg.ReadInt(); float value = pkg.ReadSingle(); territory.BiomeComposition[key] = value; } int num3 = pkg.ReadInt(); territory.Guardians = new List(); for (int k = 0; k < num3; k++) { territory.Guardians.Add(pkg.ReadLong()); } if (pkg.ReadBool()) { territory.CurrentObjective = ReadObjective(pkg); } territory.Objectives = new List(); if (version >= 3) { int num4 = pkg.ReadInt(); for (int l = 0; l < num4; l++) { territory.Objectives.Add(ReadObjective(pkg)); } } territory.Vault = new List(); if (version >= 5) { int num5 = pkg.ReadInt(); for (int m = 0; m < num5; m++) { territory.Vault.Add(new VaultItem(pkg.ReadString(), pkg.ReadString(), pkg.ReadInt())); } } return territory; } private static void WriteObjective(ZPackage pkg, TerritoryObjective obj) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected I4, but got Unknown pkg.Write((int)obj.Type); pkg.Write(obj.TargetPrefab ?? ""); pkg.Write(obj.TargetDisplayName ?? ""); pkg.Write(obj.RequiredAmount); pkg.Write(obj.CurrentAmount); pkg.Write(obj.IsForUnlock); pkg.Write((int)obj.SourceBiome); } private static TerritoryObjective ReadObjective(ZPackage pkg) { return new TerritoryObjective { Type = (ObjectiveType)pkg.ReadInt(), TargetPrefab = pkg.ReadString(), TargetDisplayName = pkg.ReadString(), RequiredAmount = pkg.ReadInt(), CurrentAmount = pkg.ReadInt(), IsForUnlock = pkg.ReadBool(), SourceBiome = (Biome)pkg.ReadInt() }; } private static void WriteDebt(ZPackage pkg, Debt d) { pkg.Write(d.DebtorPlayerId); pkg.Write(d.DebtorName ?? ""); pkg.Write(d.CreditorPlayerId); pkg.Write(d.CreditorName ?? ""); pkg.Write(d.TerritoryGridX); pkg.Write(d.TerritoryGridY); pkg.Write(d.Amount); pkg.Write(d.IncurredTimeTicks); pkg.Write(d.LastNotificationTimeTicks); } private static Debt ReadDebt(ZPackage pkg) { return new Debt { DebtorPlayerId = pkg.ReadLong(), DebtorName = pkg.ReadString(), CreditorPlayerId = pkg.ReadLong(), CreditorName = pkg.ReadString(), TerritoryGridX = pkg.ReadInt(), TerritoryGridY = pkg.ReadInt(), Amount = pkg.ReadInt(), IncurredTimeTicks = pkg.ReadLong(), LastNotificationTimeTicks = pkg.ReadLong() }; } private static void WriteAuction(ZPackage pkg, Auction a) { pkg.Write(a.TerritoryGridX); pkg.Write(a.TerritoryGridY); pkg.Write(a.StartTimeTicks); pkg.Write(a.EndTimeTicks); pkg.Write(a.MinimumBid); pkg.Write(a.IsFinalized); pkg.Write(a.Bids?.Count ?? 0); if (a.Bids == null) { return; } foreach (AuctionBid bid in a.Bids) { pkg.Write(bid.PlayerId); pkg.Write(bid.PlayerName ?? ""); pkg.Write(bid.Amount); pkg.Write(bid.BidTimeTicks); } } private static Auction ReadAuction(ZPackage pkg) { Auction auction = new Auction(); auction.TerritoryGridX = pkg.ReadInt(); auction.TerritoryGridY = pkg.ReadInt(); auction.StartTimeTicks = pkg.ReadLong(); auction.EndTimeTicks = pkg.ReadLong(); auction.MinimumBid = pkg.ReadInt(); auction.IsFinalized = pkg.ReadBool(); int num = pkg.ReadInt(); auction.Bids = new List(); for (int i = 0; i < num; i++) { auction.Bids.Add(new AuctionBid { PlayerId = pkg.ReadLong(), PlayerName = pkg.ReadString(), Amount = pkg.ReadInt(), BidTimeTicks = pkg.ReadLong() }); } return auction; } private static void WriteBanRecord(ZPackage pkg, BanRecord b) { pkg.Write(b.PlayerId); pkg.Write(b.PlayerName ?? ""); pkg.Write(b.BanStartTimeTicks); pkg.Write(b.BanEndTimeTicks); pkg.Write(b.Reason ?? ""); } private static BanRecord ReadBanRecord(ZPackage pkg) { return new BanRecord { PlayerId = pkg.ReadLong(), PlayerName = pkg.ReadString(), BanStartTimeTicks = pkg.ReadLong(), BanEndTimeTicks = pkg.ReadLong(), Reason = pkg.ReadString() }; } private static void WriteStats(ZPackage pkg, LandlordStats s) { pkg.Write(s.PlayerId); pkg.Write(s.PlayerName ?? ""); pkg.Write(s.TotalIncomeEarned); pkg.Write(s.TotalDebtsCollected); pkg.Write(s.TerritoriesOwned); } private static LandlordStats ReadStats(ZPackage pkg) { return new LandlordStats { PlayerId = pkg.ReadLong(), PlayerName = pkg.ReadString(), TotalIncomeEarned = pkg.ReadInt(), TotalDebtsCollected = pkg.ReadInt(), TerritoriesOwned = pkg.ReadInt() }; } } [Serializable] public class LandlordStats { public long PlayerId { get; set; } public string PlayerName { get; set; } public int TotalIncomeEarned { get; set; } public int TotalDebtsCollected { get; set; } public int TerritoriesOwned { get; set; } public LandlordStats() { } public LandlordStats(long playerId, string playerName) { PlayerId = playerId; PlayerName = playerName; } } [Serializable] public class RaidLogEntry { public string RaiderName { get; set; } public string OwnerName { get; set; } public string TerritoryName { get; set; } public bool Success { get; set; } public string KeyType { get; set; } public string ItemsSummary { get; set; } public long Timestamp { get; set; } public RaidLogEntry() { } public RaidLogEntry(string raider, string owner, string territory, bool success, string keyType, string items) { RaiderName = raider; OwnerName = owner; TerritoryName = territory; Success = success; KeyType = keyType; ItemsSummary = items; Timestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); } } [Serializable] public class GlobalTribute { public ObjectiveType Type { get; set; } public string TargetPrefab { get; set; } public string TargetDisplayName { get; set; } public int BaseRequiredAmount { get; set; } public int CurrentAmount { get; set; } public long StartTimestamp { get; set; } public int GetAdjustedRequired(int claimedTerritoryCount) { float num = Mathf.Clamp01((float)claimedTerritoryCount * 0.01f); return Mathf.Max(1, Mathf.RoundToInt((float)BaseRequiredAmount * (1f - num))); } public bool IsComplete(int claimedTerritoryCount) { return CurrentAmount >= GetAdjustedRequired(claimedTerritoryCount); } public bool IsExpired() { double num = (double)(DateTimeOffset.UtcNow.ToUnixTimeSeconds() - StartTimestamp) / 86400.0; return num >= 7.0; } public double DaysRemaining() { double num = (double)(DateTimeOffset.UtcNow.ToUnixTimeSeconds() - StartTimestamp) / 86400.0; return Math.Max(0.0, 7.0 - num); } } public enum ObjectiveType { KillMonsters, GatherResources, PayMaterials } [Serializable] public class TerritoryObjective { public ObjectiveType Type { get; set; } public string TargetPrefab { get; set; } public string TargetDisplayName { get; set; } public int RequiredAmount { get; set; } public int CurrentAmount { get; set; } public bool IsForUnlock { get; set; } public Biome SourceBiome { get; set; } public bool IsComplete => CurrentAmount >= RequiredAmount; public float ProgressPercent => (RequiredAmount > 0) ? ((float)CurrentAmount / (float)RequiredAmount * 100f) : 0f; public TerritoryObjective() { } public TerritoryObjective(ObjectiveType type, string prefab, string displayName, int amount, bool forUnlock, Biome biome) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) Type = type; TargetPrefab = prefab; TargetDisplayName = displayName; RequiredAmount = amount; CurrentAmount = 0; IsForUnlock = forUnlock; SourceBiome = biome; } public string GetDescription() { ObjectiveType type = Type; if (1 == 0) { } string text = type switch { ObjectiveType.KillMonsters => "Kill", ObjectiveType.GatherResources => "Gather", ObjectiveType.PayMaterials => "Pay", _ => "Complete", }; if (1 == 0) { } string text2 = text; return $"{text2} {CurrentAmount}/{RequiredAmount} {TargetDisplayName}"; } } public static class ObjectiveDefinitions { public static readonly Dictionary> KillObjectives = new Dictionary> { { (Biome)1, new List<(string, string, int)> { ("Boar", "Boars", 50), ("Neck", "Necks", 60), ("Greyling", "Greylings", 75) } }, { (Biome)8, new List<(string, string, int)> { ("Greydwarf", "Greydwarfs", 80), ("Greydwarf_Elite", "Greydwarf Brutes", 30), ("Skeleton", "Skeletons", 70), ("Troll", "Trolls", 10) } }, { (Biome)2, new List<(string, string, int)> { ("Draugr", "Draugrs", 70), ("Draugr_Elite", "Draugr Elites", 25), ("Blob", "Blobs", 60), ("Leech", "Leeches", 50), ("Wraith", "Wraiths", 15) } }, { (Biome)4, new List<(string, string, int)> { ("Wolf", "Wolves", 60), ("Fenring", "Fenrings", 30), ("StoneGolem", "Stone Golems", 15), ("Drake", "Drakes", 45) } }, { (Biome)16, new List<(string, string, int)> { ("Goblin", "Fulings", 70), ("GoblinBrute", "Fuling Berserkers", 15), ("GoblinShaman", "Fuling Shamans", 25), ("Deathsquito", "Deathsquitos", 60), ("Lox", "Loxes", 15) } }, { (Biome)512, new List<(string, string, int)> { ("Seeker", "Seekers", 60), ("SeekerBrute", "Seeker Soldiers", 25), ("Gjall", "Gjalls", 10), ("Tick", "Ticks", 80) } }, { (Biome)32, new List<(string, string, int)> { ("Charred_Melee", "Charred Warriors", 70), ("Charred_Mage", "Charred Mages", 30), ("Morgen", "Morgens", 15), ("Asksvin", "Asksvins", 25) } }, { (Biome)64, new List<(string, string, int)> { ("Wolf", "Wolves", 80), ("Fenring", "Fenrings", 40) } } }; public static readonly Dictionary> GatherObjectives = new Dictionary> { { (Biome)1, new List<(string, string, int)> { ("Wood", "Wood", 500), ("Stone", "Stone", 400), ("Raspberry", "Raspberries", 120), ("Honey", "Honey", 50), ("FineWood", "Fine Wood", 200) } }, { (Biome)8, new List<(string, string, int)> { ("RoundLog", "Core Wood", 250), ("TinOre", "Tin Ore", 120), ("CopperOre", "Copper Ore", 120), ("Thistle", "Thistle", 100), ("Mushroom", "Mushrooms", 150), ("Carrot", "Carrots", 80), ("AncientSeed", "Ancient Seeds", 15) } }, { (Biome)2, new List<(string, string, int)> { ("IronScrap", "Iron Scrap", 60), ("Guck", "Guck", 30), ("Bloodbag", "Bloodbags", 25), ("Entrails", "Entrails", 40), ("ElderBark", "Ancient Bark", 50), ("Turnip", "Turnips", 30) } }, { (Biome)4, new List<(string, string, int)> { ("SilverOre", "Silver Ore", 50), ("Obsidian", "Obsidian", 40), ("WolfPelt", "Wolf Pelts", 15), ("DragonTear", "Dragon Tears", 5), ("Onion", "Onions", 30) } }, { (Biome)16, new List<(string, string, int)> { ("BlackMetalScrap", "Black Metal Scrap", 40), ("Barley", "Barley", 100), ("Flax", "Flax", 80), ("LoxPelt", "Lox Pelts", 10), ("Needle", "Needles", 30), ("FineWood", "Fine Wood", 100) } }, { (Biome)512, new List<(string, string, int)> { ("Softtissue", "Soft Tissue", 50), ("Carapace", "Carapace", 30), ("BlackCore", "Black Cores", 8), ("RoyalJelly", "Royal Jelly", 25), ("YggdrasilWood", "Yggdrasil Wood", 60) } }, { (Biome)32, new List<(string, string, int)> { ("FlametalOre", "Flametal Ore", 30), ("GemstoneRed", "Red Gemstones", 15), ("Proustitite", "Proustitite", 25), ("CharredBone", "Charred Bones", 40) } }, { (Biome)64, new List<(string, string, int)> { ("FreezeGland", "Freeze Glands", 20), ("WolfPelt", "Wolf Pelts", 25) } }, { (Biome)256, new List<(string, string, int)> { ("Chitin", "Chitin", 30), ("FishRaw", "Raw Fish", 25), ("SerpentScale", "Serpent Scales", 10) } } }; public static readonly Dictionary> PayObjectives = new Dictionary> { { (Biome)1, new List<(string, string, int)> { ("Coins", "Coins", 100), ("Resin", "Resin", 50), ("LeatherScraps", "Leather Scraps", 30) } }, { (Biome)8, new List<(string, string, int)> { ("Coins", "Coins", 250), ("RoundLog", "Core Wood", 30), ("TrollHide", "Troll Hides", 5), ("GreydwarfEye", "Greydwarf Eyes", 25) } }, { (Biome)2, new List<(string, string, int)> { ("Coins", "Coins", 500), ("Iron", "Iron Bars", 20), ("WitheredBone", "Withered Bones", 15) } }, { (Biome)4, new List<(string, string, int)> { ("Coins", "Coins", 750), ("Silver", "Silver Bars", 15), ("Crystal", "Crystals", 20) } }, { (Biome)16, new List<(string, string, int)> { ("Coins", "Coins", 1000), ("BlackMetal", "Black Metal Bars", 15), ("GoblinTotem", "Fuling Totems", 5) } }, { (Biome)512, new List<(string, string, int)> { ("Coins", "Coins", 1500), ("Eitr", "Eitr", 20), ("Sap", "Sap", 30) } }, { (Biome)32, new List<(string, string, int)> { ("Coins", "Coins", 2000), ("Flametal", "Flametal Bars", 10), ("Askbladder", "Ask Bladders", 15) } }, { (Biome)64, new List<(string, string, int)> { ("Coins", "Coins", 2500), ("FreezeGland", "Freeze Glands", 30) } }, { (Biome)256, new List<(string, string, int)> { ("Coins", "Coins", 200), ("Chitin", "Chitin", 20) } } }; public static TerritoryObjective GenerateObjective(Biome biome, ObjectiveType type, bool forUnlock) { //IL_0045: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_00de: 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) if (1 == 0) { } Dictionary> dictionary = type switch { ObjectiveType.KillMonsters => KillObjectives, ObjectiveType.GatherResources => GatherObjectives, ObjectiveType.PayMaterials => PayObjectives, _ => PayObjectives, }; if (1 == 0) { } Dictionary> dictionary2 = dictionary; if (!dictionary2.ContainsKey(biome)) { biome = (Biome)1; } List<(string, string, int)> list = dictionary2[biome]; if (list.Count == 0) { return new TerritoryObjective(ObjectiveType.PayMaterials, "Coins", "Coins", forUnlock ? 500 : 100, forUnlock, biome); } Random random = new Random(); (string, string, int) tuple = list[random.Next(list.Count)]; int val = (forUnlock ? tuple.Item3 : ((int)((float)tuple.Item3 * 0.3f))); val = Math.Max(1, val); return new TerritoryObjective(type, tuple.Item1, tuple.Item2, val, forUnlock, biome); } } [Serializable] public class VaultItem { public string PrefabName { get; set; } public string DisplayName { get; set; } public int Amount { get; set; } public VaultItem() { } public VaultItem(string prefab, string display, int amount) { PrefabName = prefab; DisplayName = display; Amount = amount; } } [Serializable] public class Territory { public int GridX { get; set; } public int GridY { get; set; } public long OwnerPlayerId { get; set; } public string OwnerName { get; set; } public long ClaimTimeTicks { get; set; } public long LastUpkeepTimeTicks { get; set; } public bool IsUnlocked { get; set; } public string CustomName { get; set; } public Dictionary BiomeComposition { get; set; } = new Dictionary(); public TerritoryObjective CurrentObjective { get; set; } public List Objectives { get; set; } = new List(); public List Guardians { get; set; } = new List(); public int AccumulatedIncome { get; set; } public bool HasPOI { get; set; } public bool HasMerchant { get; set; } public bool IsPvPEnabled { get; set; } public int LootTaxPercent { get; set; } public long LastPassiveIncomeTicks { get; set; } public bool IsEmperorTerritory { get; set; } public int Prestige { get; set; } public long LastLootTaxChangeTicks { get; set; } public long LastRenameTicks { get; set; } public DateTime LastRenameTime { get { return DateTime.FromBinary(LastRenameTicks); } set { LastRenameTicks = value.ToBinary(); } } public long LastPvPToggleTicks { get; set; } public DateTime LastPvPToggleTime { get { return DateTime.FromBinary(LastPvPToggleTicks); } set { LastPvPToggleTicks = value.ToBinary(); } } public DateTime LastLootTaxChangeTime { get { return DateTime.FromBinary(LastLootTaxChangeTicks); } set { LastLootTaxChangeTicks = value.ToBinary(); } } public List UniquePiecesPlaced { get; set; } = new List(); public List Vault { get; set; } = new List(); public bool IsAbandoned { get; set; } public bool IsInAuction { get; set; } public long AuctionEndTimeTicks { get; set; } public long HighestBidderId { get; set; } public string HighestBidderName { get; set; } public int HighestBid { get; set; } public DateTime ClaimTime { get { return DateTime.FromBinary(ClaimTimeTicks); } set { ClaimTimeTicks = value.ToBinary(); } } public DateTime LastUpkeepTime { get { return DateTime.FromBinary(LastUpkeepTimeTicks); } set { LastUpkeepTimeTicks = value.ToBinary(); } } public DateTime AuctionEndTime { get { return DateTime.FromBinary(AuctionEndTimeTicks); } set { AuctionEndTimeTicks = value.ToBinary(); } } public DateTime LastPassiveIncomeTime { get { return DateTime.FromBinary(LastPassiveIncomeTicks); } set { LastPassiveIncomeTicks = value.ToBinary(); } } public Vector2i GridPosition { get { //IL_000c: Unknown result type (might be due to invalid IL or missing references) return new Vector2i(GridX, GridY); } set { //IL_0002: 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) GridX = value.x; GridY = value.y; } } public string DisplayName { get { //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrEmpty(CustomName)) { return CustomName; } return TerritoryNaming.GenerateTerritoryName(GridPosition, BiomeComposition, HasMerchant, HasPOI); } } public Territory() { BiomeComposition = new Dictionary(); Guardians = new List(); Objectives = new List(); UniquePiecesPlaced = new List(); Vault = new List(); ClaimTime = DateTime.UtcNow; LastUpkeepTime = DateTime.UtcNow; LastPassiveIncomeTime = DateTime.UtcNow; } public Territory(Vector2i gridPos, long ownerId, string ownerName) : this() { //IL_0009: Unknown result type (might be due to invalid IL or missing references) GridPosition = gridPos; OwnerPlayerId = ownerId; OwnerName = ownerName; } public void AddToVault(string prefabName, string displayName, int amount) { VaultItem vaultItem = Vault.Find((VaultItem v) => v.PrefabName == prefabName); if (vaultItem != null) { vaultItem.Amount += amount; } else { Vault.Add(new VaultItem(prefabName, displayName, amount)); } } public bool AreAllObjectivesComplete() { if (Objectives == null || Objectives.Count == 0) { return CurrentObjective == null || CurrentObjective.IsComplete; } foreach (TerritoryObjective objective in Objectives) { if (!objective.IsComplete) { return false; } } return true; } public int CalculateToll() { float num = 0f; foreach (KeyValuePair item in BiomeComposition) { int biomeToll = LandlordConfig.GetBiomeToll((Biome)item.Key); num += (float)biomeToll * (item.Value / 100f); } int num2 = (int)Math.Ceiling(num); if (HasPOI) { num2 *= 2; } if (Prestige > 0) { float num3 = 1f + (float)Prestige; num2 = (int)Math.Ceiling((float)num2 * num3); } return num2; } public bool IsExemptFromToll(long playerId) { return playerId == OwnerPlayerId || Guardians.Contains(playerId); } public bool IsUpkeepDue() { return (DateTime.UtcNow - LastUpkeepTime).TotalDays >= 7.0; } public string GetDominantBiomeName() { //IL_007b: Unknown result type (might be due to invalid IL or missing references) if (BiomeComposition.Count == 0) { return "Unknown"; } int num = 0; float num2 = 0f; foreach (KeyValuePair item in BiomeComposition) { if (item.Value > num2) { num2 = item.Value; num = item.Key; } } Biome val = (Biome)num; return ((object)(Biome)(ref val)).ToString(); } } } namespace FreyjaLandlord.Core { public class AuctionManager : MonoBehaviour { public static AuctionManager Instance { get; private set; } public event Action OnAuctionStarted; public event Action OnAuctionEnded; public event Action OnBidPlaced; private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { Instance = this; } } public List GetActiveAuctions() { LandlordData landlordData = TerritoryManager.Instance?.Data; if (landlordData == null) { return new List(); } return landlordData.GetActiveAuctions(); } public Auction GetAuction(Vector2i gridPos) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) return TerritoryManager.Instance?.Data?.GetAuction(gridPos); } public BidResult PlaceBid(long playerId, string playerName, Vector2i gridPos, int bidAmount) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) LandlordData landlordData = TerritoryManager.Instance?.Data; if (landlordData == null) { return new BidResult(success: false, "System unavailable"); } Auction auction = landlordData.GetAuction(gridPos); if (auction == null) { return new BidResult(success: false, "No auction found for this territory"); } if (auction.HasEnded) { return new BidResult(success: false, "This auction has ended"); } if (bidAmount < auction.MinimumValidBid) { return new BidResult(success: false, $"Minimum bid is {auction.MinimumValidBid} coins"); } Player playerById = GetPlayerById(playerId); if ((Object)(object)playerById == (Object)null) { return new BidResult(success: false, "Player not found"); } Inventory inventory = ((Humanoid)playerById).GetInventory(); if (inventory == null) { return new BidResult(success: false, "Inventory not available"); } int num = inventory.CountItems("$item_coins", -1, true); if (num < bidAmount) { return new BidResult(success: false, $"Insufficient coins ({num}/{bidAmount})"); } int value; int num2 = (landlordData.PlayerPermitCounts.TryGetValue(playerId, out value) ? value : 0); int maxTerritories = landlordData.GetMaxTerritories(playerId); if (num2 >= maxTerritories) { return new BidResult(success: false, $"You already own {num2} territories (max {maxTerritories}). No free slots!"); } AuctionBid currentLeader = auction.CurrentLeader; if (currentLeader != null && currentLeader.PlayerId != playerId) { RefundBidder(currentLeader.PlayerId, currentLeader.Amount); } inventory.RemoveItem("$item_coins", bidAmount, -1, true); foreach (AuctionBid bid in auction.Bids) { if (bid.PlayerId == playerId) { RefundBidder(playerId, bid.Amount); break; } } if (!auction.PlaceBid(playerId, playerName, bidAmount)) { return new BidResult(success: false, "Failed to place bid"); } TerritoryManager.Instance?.MarkDirty(); AuctionBid currentLeader2 = auction.CurrentLeader; this.OnBidPlaced?.Invoke(auction, currentLeader2); LandlordRPC.Instance?.BroadcastAuctionBid(auction, currentLeader2); return new BidResult(success: true, $"Bid placed: {bidAmount} coins"); } private void RefundBidder(long playerId, int amount) { Player playerById = GetPlayerById(playerId); if ((Object)(object)playerById == (Object)null) { Plugin.Log.LogWarning((object)$"Cannot refund {amount} to offline player {playerId}"); return; } Inventory inventory = ((Humanoid)playerById).GetInventory(); if (inventory != null) { inventory.AddItem(ObjectDB.instance.GetItemPrefab("Coins"), amount); LandlordRPC.Instance?.SendNotification(playerId, $"Auction refund: {amount} coins"); } } public List GetBidHistory(Vector2i gridPos) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) Auction auction = GetAuction(gridPos); if (auction == null) { return new List(); } return new List(auction.Bids); } public List GetPlayerLeadingAuctions(long playerId) { List list = new List(); List activeAuctions = GetActiveAuctions(); foreach (Auction item in activeAuctions) { AuctionBid currentLeader = item.CurrentLeader; if (currentLeader != null && currentLeader.PlayerId == playerId) { list.Add(item); } } return list; } public List GetPlayerOutbidAuctions(long playerId) { List list = new List(); List activeAuctions = GetActiveAuctions(); foreach (Auction item in activeAuctions) { AuctionBid currentLeader = item.CurrentLeader; if (currentLeader != null && currentLeader.PlayerId == playerId) { continue; } foreach (AuctionBid bid in item.Bids) { if (bid.PlayerId == playerId) { list.Add(item); break; } } } return list; } private Player GetPlayerById(long playerId) { foreach (Player allPlayer in Player.GetAllPlayers()) { if (allPlayer.GetPlayerID() == playerId) { return allPlayer; } } return null; } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } } public class BidResult { public bool Success { get; } public string Message { get; } public BidResult(bool success, string message) { Success = success; Message = message; } } public class DebtManager : MonoBehaviour { private float _debtCheckTimer = 0f; private const float DebtCheckInterval = 60f; private HashSet _notifiedEscalation = new HashSet(); public static DebtManager Instance { get; private set; } public event Action OnVassalEscalated; public event Action OnVassalFreed; private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { Instance = this; } } private void Update() { ZNet instance = ZNet.instance; if (instance != null && instance.IsServer()) { _debtCheckTimer += Time.deltaTime; if (_debtCheckTimer >= 60f) { _debtCheckTimer = 0f; CheckDebts(); } } } private void CheckDebts() { LandlordData landlordData = TerritoryManager.Instance?.Data; if (landlordData == null) { return; } foreach (Debt value in landlordData.Debts.Values) { if (!value.IsEscalated || _notifiedEscalation.Contains(value.DebtorPlayerId)) { continue; } _notifiedEscalation.Add(value.DebtorPlayerId); this.OnVassalEscalated?.Invoke(value); string message = "" + value.DebtorName + " has become a vassal of " + value.CreditorName + "!\n" + $"{value.VassalLootPercent}% loot redirected."; foreach (ZNetPeer peer in ZNet.instance.GetPeers()) { LandlordRPC.Instance?.SendNotification(peer.m_uid, message); } LandlordRPC.Instance?.SendNotification(value.DebtorPlayerId, message); Plugin.Log.LogInfo((object)$"Vassalage escalated for {value.DebtorName} - debt of {value.Amount} coins unpaid for 7 days"); } List list = new List(); foreach (long item in _notifiedEscalation) { if (!landlordData.Debts.ContainsKey(item)) { list.Add(item); } } foreach (long item2 in list) { _notifiedEscalation.Remove(item2); this.OnVassalFreed?.Invoke(item2); } } public bool IsVassalEscalated(long playerId) { LandlordData landlordData = TerritoryManager.Instance?.Data; if (landlordData == null) { return false; } if (landlordData.Debts.TryGetValue(playerId, out var value)) { return value.IsEscalated; } return false; } public List GetAllDebts() { LandlordData landlordData = TerritoryManager.Instance?.Data; if (landlordData == null) { return new List(); } return new List(landlordData.Debts.Values); } public List GetDebtsForLandlord(long landlordId) { LandlordData landlordData = TerritoryManager.Instance?.Data; if (landlordData == null) { return new List(); } return landlordData.GetDebtsForLandlord(landlordId); } public List GetDebtorsSortedByUrgency() { List allDebts = GetAllDebts(); allDebts.Sort((Debt a, Debt b) => a.TimeUntilEscalation.CompareTo(b.TimeUntilEscalation)); return allDebts; } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } } public class DebtorTracker : MonoBehaviour { private Dictionary> _debtorWards = new Dictionary>(); private Dictionary _debtorPositions = new Dictionary(); private Dictionary _mapPins = new Dictionary(); private float _wardScanTimer = 0f; private float _positionUpdateTimer = 0f; private const float WardScanInterval = 30f; private const float PositionUpdateInterval = 2f; public static DebtorTracker Instance { get; private set; } private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { Instance = this; } } private void Start() { if ((Object)(object)TollManager.Instance != (Object)null) { TollManager.Instance.OnDebtCreated += OnDebtCreated; TollManager.Instance.OnDebtPaid += OnDebtPaid; } } private void Update() { if ((Object)(object)Player.m_localPlayer == (Object)null) { return; } ZNet instance = ZNet.instance; if (instance != null && instance.IsServer()) { _wardScanTimer += Time.deltaTime; if (_wardScanTimer >= 30f) { _wardScanTimer = 0f; ScanDebtorWards(); } _positionUpdateTimer += Time.deltaTime; if (_positionUpdateTimer >= 2f) { _positionUpdateTimer = 0f; BroadcastDebtorPositions(); } } UpdateMinimapPins(); } private void ScanDebtorWards() { //IL_00f9: 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) LandlordData landlordData = TerritoryManager.Instance?.Data; if (landlordData == null) { return; } _debtorWards.Clear(); HashSet hashSet = new HashSet(landlordData.Debts.Keys); if (hashSet.Count == 0) { return; } PrivateArea[] array = Object.FindObjectsOfType(); PrivateArea[] array2 = array; foreach (PrivateArea val in array2) { if ((Object)(object)val == (Object)null) { continue; } Piece component = ((Component)val).GetComponent(); if ((Object)(object)component == (Object)null) { continue; } long creator = component.GetCreator(); if (creator != 0 && hashSet.Contains(creator)) { if (!_debtorWards.ContainsKey(creator)) { _debtorWards[creator] = new List(); } WardLocation item = new WardLocation { Position = ((Component)val).transform.position, IsEnabled = true, WardName = (val.m_name ?? "Ward") }; _debtorWards[creator].Add(item); } } SyncWardDataToLandlords(); } private void SyncWardDataToLandlords() { LandlordData landlordData = TerritoryManager.Instance?.Data; if (landlordData == null) { return; } foreach (Debt value2 in landlordData.Debts.Values) { if (_debtorWards.TryGetValue(value2.DebtorPlayerId, out var value)) { LandlordRPC.Instance?.SendDebtorWardLocations(value2.CreditorPlayerId, value2.DebtorPlayerId, value2.DebtorName, value); } } } private void BroadcastDebtorPositions() { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) LandlordData landlordData = TerritoryManager.Instance?.Data; if (landlordData == null) { return; } HashSet hashSet = new HashSet(landlordData.Debts.Keys); if (hashSet.Count == 0) { return; } foreach (Player allPlayer in Player.GetAllPlayers()) { long playerID = allPlayer.GetPlayerID(); if (hashSet.Contains(playerID)) { Debt debt = landlordData.Debts[playerID]; DebtorPosition debtorPosition = new DebtorPosition { PlayerId = playerID, PlayerName = allPlayer.GetPlayerName(), Position = ((Component)allPlayer).transform.position, LastUpdate = DateTime.UtcNow }; _debtorPositions[playerID] = debtorPosition; LandlordRPC.Instance?.SendDebtorPosition(debt.CreditorPlayerId, debtorPosition); } } } public void ReceiveDebtorWards(long debtorId, string debtorName, List wards) { _debtorWards[debtorId] = wards; Plugin.Log.LogInfo((object)$"Received {wards.Count} ward locations for debtor {debtorName}"); } public void ReceiveDebtorPosition(DebtorPosition position) { _debtorPositions[position.PlayerId] = position; } private void UpdateMinimapPins() { //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Minimap.instance == (Object)null) { return; } Player localPlayer = Player.m_localPlayer; long num = ((localPlayer != null) ? localPlayer.GetPlayerID() : 0); if (num == 0) { return; } LandlordData landlordData = TerritoryManager.Instance?.Data; if (landlordData == null) { return; } List debtsForLandlord = landlordData.GetDebtsForLandlord(num); if (debtsForLandlord.Count == 0) { ClearAllPins(); return; } HashSet hashSet = new HashSet(); foreach (Debt item in debtsForLandlord) { hashSet.Add(item.DebtorPlayerId); } foreach (KeyValuePair> kvp in _debtorWards) { if (!hashSet.Contains(kvp.Key)) { continue; } Debt debt = debtsForLandlord.Find((Debt d) => d.DebtorPlayerId == kvp.Key); if (debt == null) { continue; } int num2 = 0; foreach (WardLocation item2 in kvp.Value) { string key = $"ward_{kvp.Key}_{num2}"; UpdateOrCreatePin(key, item2.Position, (PinType)3, debt.DebtorName + "'s Ward", isWard: true); num2++; } } foreach (KeyValuePair debtorPosition in _debtorPositions) { if (hashSet.Contains(debtorPosition.Key)) { string key2 = $"debtor_{debtorPosition.Key}"; if ((DateTime.UtcNow - debtorPosition.Value.LastUpdate).TotalSeconds < 10.0) { UpdateOrCreatePin(key2, debtorPosition.Value.Position, (PinType)6, "[DEBTOR] " + debtorPosition.Value.PlayerName, isWard: false); } else { RemovePin(key2); } } } CleanupStalePins(hashSet); } private void UpdateOrCreatePin(string key, Vector3 position, PinType type, string name, bool isWard) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (_mapPins.TryGetValue(key, out var value)) { value.m_pos = position; return; } PinData val = Minimap.instance.AddPin(position, type, name, false, false, 0L, default(PlatformUserID)); if (val != null) { if (isWard) { } _mapPins[key] = val; } } private void RemovePin(string key) { if (_mapPins.TryGetValue(key, out var value)) { Minimap instance = Minimap.instance; if (instance != null) { instance.RemovePin(value); } _mapPins.Remove(key); } } private void ClearAllPins() { foreach (PinData value in _mapPins.Values) { Minimap instance = Minimap.instance; if (instance != null) { instance.RemovePin(value); } } _mapPins.Clear(); } private void CleanupStalePins(HashSet activeDebtorIds) { List list = new List(); foreach (string key in _mapPins.Keys) { string[] array = key.Split(new char[1] { '_' }); if (array.Length >= 2 && long.TryParse(array[1], out var result) && !activeDebtorIds.Contains(result)) { list.Add(key); } } foreach (string item in list) { RemovePin(item); } } public List GetDebtorWards(long debtorId) { List value; return _debtorWards.TryGetValue(debtorId, out value) ? value : new List(); } public DebtorPosition GetDebtorPosition(long debtorId) { DebtorPosition value; return _debtorPositions.TryGetValue(debtorId, out value) ? value : null; } public List GetAllTrackedDebtors(long landlordId) { List list = new List(); LandlordData landlordData = TerritoryManager.Instance?.Data; if (landlordData == null) { return list; } List debtsForLandlord = landlordData.GetDebtsForLandlord(landlordId); foreach (Debt item2 in debtsForLandlord) { DebtorTrackingData item = new DebtorTrackingData { Debt = item2, Wards = GetDebtorWards(item2.DebtorPlayerId), CurrentPosition = GetDebtorPosition(item2.DebtorPlayerId) }; list.Add(item); } return list; } private void OnDebtCreated(Debt debt) { ZNet instance = ZNet.instance; if (instance != null && instance.IsServer()) { ScanDebtorWards(); } } private void OnDebtPaid(Debt debt) { _debtorWards.Remove(debt.DebtorPlayerId); _debtorPositions.Remove(debt.DebtorPlayerId); List list = new List(); foreach (string key in _mapPins.Keys) { if (key.Contains($"_{debt.DebtorPlayerId}_") || key.EndsWith($"_{debt.DebtorPlayerId}")) { list.Add(key); } } foreach (string item in list) { RemovePin(item); } } private void OnDestroy() { ClearAllPins(); if ((Object)(object)TollManager.Instance != (Object)null) { TollManager.Instance.OnDebtCreated -= OnDebtCreated; TollManager.Instance.OnDebtPaid -= OnDebtPaid; } if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } } [Serializable] public class WardLocation { public Vector3 Position; public bool IsEnabled; public string WardName; } [Serializable] public class DebtorPosition { public long PlayerId; public string PlayerName; public Vector3 Position; public DateTime LastUpdate; } public class DebtorTrackingData { public Debt Debt; public List Wards; public DebtorPosition CurrentPosition; } public class ExplorationTracker : MonoBehaviour { private HashSet _exploredTiles = new HashSet(); private Vector2i? _currentTile = null; private string _worldId = ""; private string _savePath = ""; private float _saveTimer = 0f; private bool _needsSave = false; private const float SaveDelay = 5f; public static ExplorationTracker Instance { get; private set; } public int ExploredTileCount => _exploredTiles.Count; public event Action OnNewTileExplored; public event Action OnTileEntered; private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)this); return; } Instance = this; Plugin.Log.LogInfo((object)"ExplorationTracker initialized"); } private void Start() { } private void Update() { //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_0054: 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_006d: 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_0085: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.m_localPlayer == (Object)null) { return; } if (string.IsNullOrEmpty(_worldId)) { InitializeForWorld(); if (string.IsNullOrEmpty(_worldId)) { return; } } Vector3 position = ((Component)Player.m_localPlayer).transform.position; Vector2i val = GridUtils.WorldToVisualGrid(position); if (!_currentTile.HasValue || _currentTile.Value.x != val.x || _currentTile.Value.y != val.y) { OnPlayerChangedTile(val); _currentTile = val; } if (_needsSave) { _saveTimer += Time.deltaTime; if (_saveTimer >= 5f) { SaveExplorationData(); _needsSave = false; _saveTimer = 0f; } } } private void InitializeForWorld() { if ((Object)(object)ZNet.instance == (Object)null) { return; } string worldName = ZNet.instance.GetWorldName(); if (!string.IsNullOrEmpty(worldName)) { _worldId = worldName.GetHashCode().ToString("X8"); string text = Path.Combine(Paths.ConfigPath, "FreyjaLandlord"); if (!Directory.Exists(text)) { Directory.CreateDirectory(text); } Player localPlayer = Player.m_localPlayer; string name = ((localPlayer != null) ? localPlayer.GetPlayerName() : null) ?? "unknown"; string text2 = SanitizeFileName(name); _savePath = Path.Combine(text, "exploration_" + _worldId + "_" + text2 + ".json"); VoronoiGrid.Instance.Initialize(worldName); LoadExplorationData(); Plugin.Log.LogInfo((object)("ExplorationTracker initialized for world '" + worldName + "' (" + _worldId + ")")); Plugin.Log.LogInfo((object)$"Loaded {_exploredTiles.Count} explored tiles"); } } private void OnPlayerChangedTile(Vector2i newTile) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_0063: 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) string tileKey = GetTileKey(newTile); bool flag = _exploredTiles.Contains(tileKey); this.OnTileEntered?.Invoke(newTile, flag); if (!flag) { _exploredTiles.Add(tileKey); _needsSave = true; _saveTimer = 0f; string territoryName = GridUtils.GetTerritoryName(newTile); Plugin.Log.LogInfo((object)$"New tile explored: {newTile} - {territoryName}, firing event..."); this.OnNewTileExplored?.Invoke(newTile, territoryName); } } public bool IsTileExplored(Vector2i tile) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) return _exploredTiles.Contains(GetTileKey(tile)); } public bool IsTileExplored(int x, int y) { return _exploredTiles.Contains($"{x},{y}"); } public IReadOnlyCollection GetExploredTiles() { return _exploredTiles; } public void MarkTileExplored(Vector2i tile) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) string tileKey = GetTileKey(tile); if (!_exploredTiles.Contains(tileKey)) { _exploredTiles.Add(tileKey); _needsSave = true; _saveTimer = 0f; } } public void ClearExplorationData() { _exploredTiles.Clear(); _currentTile = null; SaveExplorationData(); Plugin.Log.LogInfo((object)"Exploration data cleared"); } private void SaveExplorationData() { if (string.IsNullOrEmpty(_savePath)) { return; } try { List list = new List(); list.Add("{"); list.Add(" \"WorldId\": \"" + _worldId + "\","); list.Add(" \"LastSaved\": \"" + DateTime.UtcNow.ToString("o") + "\","); list.Add(" \"ExploredTiles\": ["); List list2 = new List(_exploredTiles); for (int i = 0; i < list2.Count; i++) { string text = ((i < list2.Count - 1) ? "," : ""); list.Add(" \"" + list2[i] + "\"" + text); } list.Add(" ]"); list.Add("}"); File.WriteAllLines(_savePath, list); Plugin.Log.LogDebug((object)$"Saved {_exploredTiles.Count} explored tiles"); } catch (Exception ex) { Plugin.Log.LogError((object)("Failed to save exploration data: " + ex.Message)); } } private void LoadExplorationData() { if (string.IsNullOrEmpty(_savePath)) { return; } if (!File.Exists(_savePath)) { Plugin.Log.LogDebug((object)"No exploration save file found, starting fresh"); return; } try { string text = File.ReadAllText(_savePath); _exploredTiles.Clear(); int num = text.IndexOf("\"ExploredTiles\""); if (num >= 0) { int num2 = text.IndexOf('[', num); int num3 = text.IndexOf(']', num2); if (num2 >= 0 && num3 > num2) { string text2 = text.Substring(num2 + 1, num3 - num2 - 1); int num4 = 0; while (num4 < text2.Length) { int num5 = text2.IndexOf('"', num4); if (num5 < 0) { break; } int num6 = text2.IndexOf('"', num5 + 1); if (num6 < 0) { break; } string text3 = text2.Substring(num5 + 1, num6 - num5 - 1); if (!string.IsNullOrEmpty(text3)) { _exploredTiles.Add(text3); } num4 = num6 + 1; } } } Plugin.Log.LogDebug((object)$"Loaded {_exploredTiles.Count} explored tiles"); } catch (Exception ex) { Plugin.Log.LogError((object)("Failed to load exploration data: " + ex.Message)); _exploredTiles = new HashSet(); } } private string GetTileKey(Vector2i tile) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) return $"{tile.x},{tile.y}"; } private string SanitizeFileName(string name) { char[] invalidFileNameChars = Path.GetInvalidFileNameChars(); foreach (char oldChar in invalidFileNameChars) { name = name.Replace(oldChar, '_'); } return name; } private void OnDestroy() { if (_needsSave) { SaveExplorationData(); } if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } private void OnApplicationQuit() { if (_needsSave) { SaveExplorationData(); } } } public class GridManager : MonoBehaviour { private Vector2i? _currentTerritory = null; private Territory _lastAnnouncedTerritory = null; private float _announcementCooldown = 0f; private const float AnnouncementCooldownTime = 3f; private float _minimapUpdateTimer = 0f; private const float MinimapUpdateInterval = 2f; private Dictionary _territoryPins = new Dictionary(); private Territory _pendingAnnouncement = null; private bool _pendingUnclaimed = false; private int _announceDelay = 0; public static GridManager Instance { get; private set; } private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { Instance = this; } } private void Update() { if (!((Object)(object)Player.m_localPlayer == (Object)null)) { if (_announcementCooldown > 0f) { _announcementCooldown -= Time.deltaTime; } CheckTerritoryChange(); _minimapUpdateTimer += Time.deltaTime; if (_minimapUpdateTimer >= 2f) { _minimapUpdateTimer = 0f; UpdateMinimapTerritoryPins(); } } } private void CheckTerritoryChange() { //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: 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_0108: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } if (_announceDelay > 0) { _announceDelay--; if (_announceDelay == 0) { if (_pendingAnnouncement != null) { AnnounceTerritory(_pendingAnnouncement); _lastAnnouncedTerritory = _pendingAnnouncement; _announcementCooldown = 3f; _pendingAnnouncement = null; } else if (_pendingUnclaimed) { ShowMessage("Entering unclaimed territory", (MessageType)1); _lastAnnouncedTerritory = null; _announcementCooldown = 3f; _pendingUnclaimed = false; } } return; } Vector2i val = GridUtils.WorldToVisualGrid(((Component)localPlayer).transform.position); if (_currentTerritory.HasValue && _currentTerritory.Value.x == val.x && _currentTerritory.Value.y == val.y) { return; } _currentTerritory = val; Territory territory = (TerritoryManager.Instance?.Data)?.GetTerritory(val); if (territory != null && _announcementCooldown <= 0f) { if (_lastAnnouncedTerritory == null || _lastAnnouncedTerritory.GridX != territory.GridX || _lastAnnouncedTerritory.GridY != territory.GridY) { _pendingAnnouncement = territory; _pendingUnclaimed = false; _announceDelay = 2; } } else if (territory == null && _lastAnnouncedTerritory != null && _announcementCooldown <= 0f) { _pendingUnclaimed = true; _pendingAnnouncement = null; _announceDelay = 2; } } private void AnnounceTerritory(Territory territory) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; long num = ((localPlayer != null) ? localPlayer.GetPlayerID() : 0); if (territory.OwnerPlayerId == num) { ShowMessage("Your Territory.", (MessageType)2); } else if (GridUtils.IsInSpawnProtection(territory.GridPosition)) { ShowMessage("Spawn Protected Zone", (MessageType)1); } else if (territory.IsInAuction) { ShowMessage("Territory in Auction!\n" + territory.OwnerName + "'s Territory", (MessageType)2); } else { ShowMessage("" + territory.OwnerName + "'s Territory", (MessageType)2); } } private void ShowMessage(string message, MessageType type) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)MessageHud.instance != (Object)null) { MessageHud.instance.ShowMessage(type, message, 0, (Sprite)null, false); } } private void UpdateMinimapTerritoryPins() { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_00a4: 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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: 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_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0130: 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_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0151: 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) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Minimap.instance == (Object)null) { return; } LandlordData landlordData = TerritoryManager.Instance?.Data; if (landlordData == null) { return; } Player localPlayer = Player.m_localPlayer; long num = ((localPlayer != null) ? localPlayer.GetPlayerID() : 0); HashSet hashSet = new HashSet(); foreach (Territory value2 in landlordData.Territories.Values) { Vector2i gridPosition = value2.GridPosition; hashSet.Add(gridPosition); string displayName = value2.DisplayName; string text; PinType val; if (value2.OwnerPlayerId == num) { text = displayName; val = (PinType)1; } else if (value2.IsInAuction) { text = displayName + " (Auction)"; val = (PinType)0; } else { text = displayName + " (" + value2.OwnerName + ")"; val = (PinType)2; } Vector3 val2 = GridUtils.GridToWorldCenter(gridPosition); if (_territoryPins.TryGetValue(gridPosition, out var value)) { value.m_name = text; value.m_pos = val2; continue; } PinData val3 = Minimap.instance.AddPin(val2, val, text, false, false, 0L, default(PlatformUserID)); if (val3 != null) { _territoryPins[gridPosition] = val3; } } List list = new List(); foreach (KeyValuePair territoryPin in _territoryPins) { if (!hashSet.Contains(territoryPin.Key)) { Minimap.instance.RemovePin(territoryPin.Value); list.Add(territoryPin.Key); } } foreach (Vector2i item in list) { _territoryPins.Remove(item); } } public void ClearTerritoryPins() { if ((Object)(object)Minimap.instance == (Object)null) { return; } foreach (PinData value in _territoryPins.Values) { Minimap.instance.RemovePin(value); } _territoryPins.Clear(); } public Territory GetCurrentTerritory() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) if (!_currentTerritory.HasValue) { return null; } return TerritoryManager.Instance?.Data?.GetTerritory(_currentTerritory.Value); } public Vector2i? GetCurrentGridPosition() { return _currentTerritory; } private void OnDestroy() { ClearTerritoryPins(); if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } } public static class LandlordConfig { public static ConfigEntry GridCellSize; public static ConfigEntry SpawnProtectionRadius; public static ConfigEntry MaxTerritoriesPerPlayer; public static ConfigEntry WorldRadius; public static ConfigEntry ClaimCost; public static ConfigEntry TollMeadows; public static ConfigEntry TollBlackForest; public static ConfigEntry TollSwamp; public static ConfigEntry TollMountain; public static ConfigEntry TollPlains; public static ConfigEntry TollMistlands; public static ConfigEntry TollAshlands; public static ConfigEntry TollDeepNorth; public static ConfigEntry TollOcean; public static ConfigEntry POIMultiplier; public static ConfigEntry DaysUntilBankruptcy; public static ConfigEntry BanDurationDays; public static ConfigEntry MaxDebtStarBonus; public static ConfigEntry UpkeepIntervalDays; public static ConfigEntry UpkeepMultiplier; public static ConfigEntry MaxGuardiansPerTerritory; public static ConfigEntry AuctionDurationHours; public static ConfigEntry MinimumBidIncrement; public static ConfigEntry HUDToggleKey; public static ConfigEntry TrialRunDurationHours; public static ConfigEntry PassiveIncomeIntervalHours; public static ConfigEntry TollCooldownMinutes; public static ConfigEntry TerritoryCount; private static Dictionary _biomeTolls; public static void Initialize(ConfigFile config) { GridCellSize = config.Bind("Grid", "TerritorySize", 500f, "Size of each territory in meters. Default 500m (larger = fewer territories). Requires restart."); SpawnProtectionRadius = config.Bind("Grid", "SpawnProtectionRadius", 2500f, "Radius around world spawn where territories cannot be claimed"); MaxTerritoriesPerPlayer = config.Bind("Grid", "MaxTerritoriesPerPlayer", 3, "Maximum number of territories a player can own"); WorldRadius = config.Bind("Grid", "WorldRadius", 10500f, "World radius in meters. Default Valheim is 10500. For Expand World mod, match your world radius setting (e.g. 15000)."); ClaimCost = config.Bind("Economy", "ClaimCost", 500, "Base cost to claim a territory in coins"); TollMeadows = config.Bind("Economy.Tolls", "Meadows", 20, "Toll for Meadows biome"); TollBlackForest = config.Bind("Economy.Tolls", "BlackForest", 40, "Toll for Black Forest biome"); TollSwamp = config.Bind("Economy.Tolls", "Swamp", 80, "Toll for Swamp biome"); TollMountain = config.Bind("Economy.Tolls", "Mountain", 120, "Toll for Mountain biome"); TollPlains = config.Bind("Economy.Tolls", "Plains", 160, "Toll for Plains biome"); TollMistlands = config.Bind("Economy.Tolls", "Mistlands", 200, "Toll for Mistlands biome"); TollAshlands = config.Bind("Economy.Tolls", "Ashlands", 240, "Toll for Ashlands biome"); TollDeepNorth = config.Bind("Economy.Tolls", "DeepNorth", 280, "Toll for Deep North biome"); TollOcean = config.Bind("Economy.Tolls", "Ocean", 10, "Toll for Ocean biome"); POIMultiplier = config.Bind("Economy", "POIMultiplier", 2f, "Multiplier for territories containing Points of Interest (boss altars, traders)"); TrialRunDurationHours = config.Bind("NewPlayer", "TrialRunDurationHours", 24f, "Duration in hours that new players are exempt from toll payments"); DaysUntilBankruptcy = config.Bind("Debt", "DaysUntilBankruptcy", 14, "Days a player can be in debt before bankruptcy"); BanDurationDays = config.Bind("Debt", "BanDurationDays", 7, "Duration of ban after bankruptcy (in days)"); MaxDebtStarBonus = config.Bind("Economy", "MaxDebtStarBonus", 2, "Maximum monster star level bonus from global debt. Set to match your Creature Level Control max stars."); UpkeepIntervalDays = config.Bind("Upkeep", "IntervalDays", 7, "Days between upkeep payments"); UpkeepMultiplier = config.Bind("Upkeep", "CostMultiplier", 0.3f, "Upkeep cost as a fraction of unlock cost"); MaxGuardiansPerTerritory = config.Bind("Guardians", "MaxPerTerritory", 2, "Maximum guardians a landlord can assign per territory"); AuctionDurationHours = config.Bind("Auction", "DurationHours", 48, "Duration of territory auctions in hours"); MinimumBidIncrement = config.Bind("Auction", "MinimumBidIncrement", 50, "Minimum amount a bid must exceed the current bid by"); PassiveIncomeIntervalHours = config.Bind("Economy", "PassiveIncomeIntervalHours", 3f, "Hours between passive income ticks for territory owners (1x toll per interval)"); TollCooldownMinutes = config.Bind("Economy", "TollCooldownMinutes", 60f, "Minutes a player can re-cross a border without paying toll again"); TerritoryCount = config.Bind("Grid", "TerritoryCount", 350, "Target number of territories. For larger worlds (e.g. 15000m radius with Expand World), increase proportionally. Suggested: 350 for 10500m, 700 for 15000m."); HUDToggleKey = config.Bind("UI", "HUDToggleKey", (KeyCode)285, "Key to toggle the Landlord HUD"); RebuildTollDictionary(); } public static void RebuildTollDictionary() { _biomeTolls = new Dictionary { { (Biome)1, TollMeadows.Value }, { (Biome)8, TollBlackForest.Value }, { (Biome)2, TollSwamp.Value }, { (Biome)4, TollMountain.Value }, { (Biome)16, TollPlains.Value }, { (Biome)512, TollMistlands.Value }, { (Biome)32, TollAshlands.Value }, { (Biome)64, TollDeepNorth.Value }, { (Biome)256, TollOcean.Value } }; } public static int GetBiomeToll(Biome biome) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_0036: Invalid comparison between Unknown and I4 if (_biomeTolls == null) { RebuildTollDictionary(); } int num = 0; foreach (KeyValuePair biomeToll in _biomeTolls) { if ((biome & biomeToll.Key) > 0 && biomeToll.Value > num) { num = biomeToll.Value; } } return (num > 0) ? num : TollMeadows.Value; } public static Dictionary GetAllTolls() { return new Dictionary { { "Meadows", TollMeadows.Value }, { "Black Forest", TollBlackForest.Value }, { "Swamp", TollSwamp.Value }, { "Mountain", TollMountain.Value }, { "Plains", TollPlains.Value }, { "Mistlands", TollMistlands.Value }, { "Ashlands", TollAshlands.Value }, { "Deep North", TollDeepNorth.Value }, { "Ocean", TollOcean.Value } }; } } public static class ServerGuard { private const string CorrectPassword = "peaches"; private const string ConfigSection = "Protection"; private const string ConfigKey = "password"; private static ConfigEntry _cfgPassword; public static bool Init(Plugin plugin) { _cfgPassword = ((BaseUnityPlugin)plugin).Config.Bind("Protection", "password", "enter_password_here", "Server password required to run Freyja Landlord on a dedicated server. Leave as-is on game clients — this check is ignored there."); if (!IsDedicatedServer()) { Plugin.Log.LogInfo((object)"[ServerGuard] Running on client - auth skipped"); return true; } string text = _cfgPassword.Value?.Trim() ?? string.Empty; if (text == "peaches") { Plugin.Log.LogInfo((object)"[ServerGuard] Server auth OK. Welcome, Freyja's chosen."); return true; } Plugin.Log.LogError((object)"══════════════════════════════════════════════════\n INVALID PASSWORD — Freyja Landlord will not load.\n Set the correct password in:\n BepInEx/config/freyja.landlord.cfg\n under [Protection] > password\n══════════════════════════════════════════════════"); return false; } private static bool IsDedicatedServer() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 return (int)SystemInfo.graphicsDeviceType == 4; } } public class TerritoryManager : MonoBehaviour { private bool _isServer = false; private bool _serverChecked = false; private bool _dataLoaded = false; private float _saveTimer = 0f; private const float SaveInterval = 60f; private bool _dataDirty = false; private float _passiveIncomeTimer = 0f; private const float PassiveIncomeCheckInterval = 60f; private float _emperorCheckTimer = 0f; private const float EmperorCheckInterval = 30f; private float _upkeepCheckTimer = 0f; private const float UpkeepCheckInterval = 60f; private float _auctionCheckTimer = 0f; private const float AuctionCheckInterval = 30f; public static TerritoryManager Instance { get; private set; } public LandlordData Data { get; private set; } public event Action OnTerritoryChanged; public event Action OnTerritoryClaimed; public event Action OnTerritoryAbandoned; public event Action OnDataLoaded; private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } Instance = this; Data = new LandlordData(); } private void Start() { TryInitializeServer(); } private void TryInitializeServer() { if (!_serverChecked && !((Object)(object)ZNet.instance == (Object)null)) { _isServer = ZNet.instance.IsServer(); _serverChecked = true; Plugin.Log.LogInfo((object)$"TerritoryManager: IsServer = {_isServer}"); if (_isServer && !_dataLoaded) { LoadData(); _dataLoaded = true; } } } private void Update() { if (!_serverChecked) { TryInitializeServer(); } else { if (!_isServer) { return; } if (_dataDirty) { _saveTimer += Time.deltaTime; if (_saveTimer >= 60f) { SaveData(); _saveTimer = 0f; } } ProcessUpkeepChecks(); ProcessPassiveIncome(); ProcessEmperorStatus(); ProcessAuctions(); } } public void LoadData() { if (_isServer) { string savePath = GetSavePath(); Plugin.Log.LogInfo((object)("Loading landlord data from: " + savePath)); byte[] worldCustomData = GetWorldCustomData(); if (worldCustomData != null && worldCustomData.Length != 0) { Data = LandlordData.Deserialize(worldCustomData); Plugin.Log.LogInfo((object)$"Loaded landlord data: {Data.Territories.Count} territories, {Data.Debts.Count} debts"); } else { Plugin.Log.LogInfo((object)"No existing landlord data found, starting fresh"); } this.OnDataLoaded?.Invoke(); LandlordRPC.Instance?.SyncAllDataToClients(); } } public void SaveData() { if (!_isServer) { ZNet instance = ZNet.instance; if (instance == null || !instance.IsServer()) { return; } _isServer = true; _serverChecked = true; } byte[] array = Data.Serialize(); SetWorldCustomData(array); _dataDirty = false; Plugin.Log.LogInfo((object)$"Saved landlord data: {array.Length} bytes, {Data.Territories.Count} territories to {GetSavePath()}"); } private byte[] GetWorldCustomData() { string savePath = GetSavePath(); if (File.Exists(savePath)) { return File.ReadAllBytes(savePath); } return null; } private void SetWorldCustomData(byte[] data) { string savePath = GetSavePath(); string directoryName = Path.GetDirectoryName(savePath); if (!Directory.Exists(directoryName)) { Directory.CreateDirectory(directoryName); } File.WriteAllBytes(savePath, data); } private string GetSavePath() { ZNet instance = ZNet.instance; long num = ((instance != null) ? instance.GetWorldUID() : 0); string text; if (num != 0) { text = num.ToString(); } else { ZNet instance2 = ZNet.instance; string text2 = ((instance2 != null) ? instance2.GetWorldName() : null) ?? "local"; text = text2.GetHashCode().ToString("X8"); } return Path.Combine(Paths.ConfigPath, "FreyjaLandlord", "landlord_data_" + text + ".dat"); } public void MarkDirty() { _dataDirty = true; } public Territory GetTerritory(Vector2i gridPos) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) return Data.GetTerritory(gridPos); } public ClaimResult TryClaimTerritory(long playerId, string playerName, Vector2i gridPos) { //IL_0001: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_010f: 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) if (GridUtils.GridCellOverlapsSpawnProtection(gridPos)) { return new ClaimResult(success: false, "This area is protected (near spawn)"); } if (Data.GetTerritory(gridPos) != null) { return new ClaimResult(success: false, "This territory is already claimed"); } if (Data.GetAuction(gridPos) != null) { return new ClaimResult(success: false, "This territory is currently in auction"); } int value; int num = (Data.PlayerPermitCounts.TryGetValue(playerId, out value) ? value : 0); int maxTerritories = Data.GetMaxTerritories(playerId); if (num >= maxTerritories) { return new ClaimResult(success: false, $"You already own {num} territories (max {maxTerritories})"); } Territory territory = new Territory(gridPos, playerId, playerName); territory.BiomeComposition = BiomeUtils.SampleBiomeComposition(gridPos); territory.HasPOI = BiomeUtils.HasPointOfInterest(gridPos); territory.HasMerchant = BiomeUtils.CellHasMerchant(gridPos); territory.IsUnlocked = true; territory.LastUpkeepTime = DateTime.UtcNow; territory.CustomName = TerritoryNaming.GenerateTerritoryName(gridPos, territory.BiomeComposition, territory.HasMerchant, territory.HasPOI); territory.Objectives = GenerateObjectivesForTerritory(territory, forUnlock: false); territory.CurrentObjective = ((territory.Objectives.Count > 0) ? territory.Objectives[0] : null); Data.SetTerritory(gridPos, territory); Data.PlayerPermitCounts[playerId] = num + 1; if (!Data.PlayerStats.ContainsKey(playerId)) { Data.PlayerStats[playerId] = new LandlordStats(playerId, playerName); } Data.PlayerStats[playerId].TerritoriesOwned++; MarkDirty(); if (_isServer) { SaveData(); Plugin.Log.LogInfo((object)("Territory claimed and saved: " + territory.DisplayName + " by " + playerName)); } this.OnTerritoryClaimed?.Invoke(territory); if (_isServer) { LandlordRPC.Instance?.BroadcastTerritoryUpdate(territory); } return new ClaimResult(success: true, "Claimed " + territory.DisplayName + "! Complete objectives to unlock it.", territory); } public bool AbandonTerritory(long playerId, Vector2i gridPos) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) Territory territory = Data.GetTerritory(gridPos); if (territory == null) { return false; } if (territory.OwnerPlayerId != playerId) { return false; } if (territory.IsEmperorTerritory) { return false; } int minimumBid = CalculateMinimumBid(territory); Auction auction = new Auction(gridPos, minimumBid); territory.IsAbandoned = true; territory.IsInAuction = true; territory.AuctionEndTime = auction.EndTime; Data.SetAuction(gridPos, auction); if (Data.PlayerPermitCounts.ContainsKey(playerId)) { Data.PlayerPermitCounts[playerId] = Math.Max(0, Data.PlayerPermitCounts[playerId] - 1); } MarkDirty(); this.OnTerritoryAbandoned?.Invoke(gridPos); if (_isServer) { LandlordRPC.Instance?.BroadcastTerritoryUpdate(territory); } return true; } public bool AddGuardian(long ownerId, Vector2i gridPos, long guardianId, string guardianName) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) Territory territory = Data.GetTerritory(gridPos); if (territory == null) { return false; } if (territory.OwnerPlayerId != ownerId) { return false; } if (territory.Guardians.Count >= LandlordConfig.MaxGuardiansPerTerritory.Value) { return false; } if (territory.Guardians.Contains(guardianId)) { return false; } territory.Guardians.Add(guardianId); MarkDirty(); this.OnTerritoryChanged?.Invoke(territory); return true; } public bool RemoveGuardian(long ownerId, Vector2i gridPos, long guardianId) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) Territory territory = Data.GetTerritory(gridPos); if (territory == null) { return false; } if (territory.OwnerPlayerId != ownerId) { return false; } bool flag = territory.Guardians.Remove(guardianId); if (flag) { MarkDirty(); this.OnTerritoryChanged?.Invoke(territory); } return flag; } public int WithdrawIncome(long playerId, Vector2i gridPos) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) Territory territory = Data.GetTerritory(gridPos); if (territory == null) { return 0; } if (territory.OwnerPlayerId != playerId) { return 0; } int accumulatedIncome = territory.AccumulatedIncome; territory.AccumulatedIncome = 0; MarkDirty(); return accumulatedIncome; } public int WithdrawAllIncome(long playerId) { int num = 0; foreach (Territory playerTerritory in Data.GetPlayerTerritories(playerId)) { num += playerTerritory.AccumulatedIncome; playerTerritory.AccumulatedIncome = 0; } if (num > 0) { MarkDirty(); } return num; } private TerritoryObjective GenerateObjectiveForTerritory(Territory territory, bool forUnlock) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) Random random = new Random(); Biome biome = SelectBiomeByWeight(territory.BiomeComposition, random); ObjectiveType type = (ObjectiveType)random.Next(3); TerritoryObjective territoryObjective = ObjectiveDefinitions.GenerateObjective(biome, type, forUnlock); if (territory.HasPOI) { territoryObjective.RequiredAmount = (int)((float)territoryObjective.RequiredAmount * LandlordConfig.POIMultiplier.Value); } return territoryObjective; } private List GenerateObjectivesForTerritory(Territory territory, bool forUnlock) { //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) List list = new List(); HashSet hashSet = new HashSet(); int num = (int)(DateTime.UtcNow.Ticks / 864000000000L / 7); int seed = territory.GridX * 10000 + territory.GridY + num; Random random = new Random(seed); List> list2 = new List>(territory.BiomeComposition); list2.Sort((KeyValuePair a, KeyValuePair b) => b.Value.CompareTo(a.Value)); HashSet hashSet2 = new HashSet(); int num2 = 30; while (list.Count < 3 && num2 > 0) { num2--; Biome biome; if (list.Count < list2.Count) { bool flag = false; foreach (KeyValuePair item2 in list2) { if (hashSet2.Contains(item2.Key) || !(item2.Value >= 1f)) { continue; } biome = (Biome)item2.Key; hashSet2.Add(item2.Key); flag = true; ObjectiveType type = (ObjectiveType)random.Next(3); TerritoryObjective territoryObjective = ObjectiveDefinitions.GenerateObjective(biome, type, forUnlock); if (!hashSet.Contains(territoryObjective.TargetPrefab)) { hashSet.Add(territoryObjective.TargetPrefab); if (territory.HasPOI || territory.HasMerchant) { territoryObjective.RequiredAmount = (int)((float)territoryObjective.RequiredAmount * LandlordConfig.POIMultiplier.Value); } list.Add(territoryObjective); } break; } if (flag) { continue; } } biome = SelectBiomeByWeight(territory.BiomeComposition, random); ObjectiveType type2 = (ObjectiveType)random.Next(3); TerritoryObjective territoryObjective2 = ObjectiveDefinitions.GenerateObjective(biome, type2, forUnlock); if (!hashSet.Contains(territoryObjective2.TargetPrefab)) { hashSet.Add(territoryObjective2.TargetPrefab); if (territory.HasPOI || territory.HasMerchant) { territoryObjective2.RequiredAmount = (int)((float)territoryObjective2.RequiredAmount * LandlordConfig.POIMultiplier.Value); } list.Add(territoryObjective2); } } while (list.Count < 3) { TerritoryObjective item = new TerritoryObjective(ObjectiveType.KillMonsters, "Greyling", "Greylings", 10, forUnlock, (Biome)1); list.Add(item); } return list; } private Biome SelectBiomeByWeight(Dictionary composition, Random random) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_006f: Unknown result type (might be due to invalid IL or missing references) float num = (float)random.NextDouble() * 100f; float num2 = 0f; foreach (KeyValuePair item in composition) { num2 += item.Value; if (num <= num2) { return (Biome)item.Key; } } return BiomeUtils.GetDominantBiome(composition); } public void ReportObjectiveProgress(long playerId, Vector2i gridPos, string prefab, int amount) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) Territory territory = Data.GetTerritory(gridPos); if (territory == null || territory.OwnerPlayerId != playerId || territory.Objectives == null || territory.Objectives.Count == 0) { return; } bool flag = false; foreach (TerritoryObjective objective in territory.Objectives) { if (!objective.IsComplete && objective.TargetPrefab.Equals(prefab, StringComparison.OrdinalIgnoreCase)) { objective.CurrentAmount += amount; flag = true; } } if (flag) { if (territory.AreAllObjectivesComplete()) { CompleteAllObjectives(territory); } MarkDirty(); this.OnTerritoryChanged?.Invoke(territory); } } private void CompleteAllObjectives(Territory territory) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) territory.CurrentObjective = null; territory.LastUpkeepTime = DateTime.UtcNow; Plugin.Log.LogInfo((object)$"Territory {territory.GridPosition} rent paid by {territory.OwnerName}. Next rent in 7 days."); } private void ProcessPassiveIncome() { _passiveIncomeTimer += Time.deltaTime; if (_passiveIncomeTimer < 60f) { return; } _passiveIncomeTimer = 0f; float value = LandlordConfig.PassiveIncomeIntervalHours.Value; bool flag = false; foreach (Territory value2 in Data.Territories.Values) { if (value2.IsUnlocked && !value2.IsAbandoned) { double totalHours = (DateTime.UtcNow - value2.LastPassiveIncomeTime).TotalHours; if (totalHours >= (double)value) { int num = (int)(totalHours / (double)value); int num2 = value2.CalculateToll(); int num3 = num2 * num; value2.AccumulatedIncome += num3; value2.LastPassiveIncomeTime = DateTime.UtcNow; flag = true; Plugin.Log.LogInfo((object)$"Passive income: {value2.DisplayName} earned {num3} coins ({num} intervals)"); } } } if (flag) { MarkDirty(); } } private void ProcessEmperorStatus() { _emperorCheckTimer += Time.deltaTime; if (_emperorCheckTimer < 30f) { return; } _emperorCheckTimer = 0f; bool flag = false; HashSet hashSet = new HashSet(); foreach (Territory value in Data.Territories.Values) { if (hashSet.Contains(value.OwnerPlayerId)) { continue; } hashSet.Add(value.OwnerPlayerId); bool flag2 = Data.IsEmperor(value.OwnerPlayerId); List playerTerritories = Data.GetPlayerTerritories(value.OwnerPlayerId); foreach (Territory item in playerTerritories) { if (flag2 && !item.IsEmperorTerritory) { item.IsEmperorTerritory = true; item.LootTaxPercent = 50; flag = true; Plugin.Log.LogInfo((object)("Emperor mode activated for " + item.OwnerName + "'s territory " + item.DisplayName)); } else if (!flag2 && item.IsEmperorTerritory) { item.IsEmperorTerritory = false; if (item.LootTaxPercent == 50) { item.LootTaxPercent = 0; } flag = true; } } } if (flag) { MarkDirty(); } } public void RecordBossKill(long playerId, string bossPrefab) { Data.RecordBossKill(playerId, bossPrefab); MarkDirty(); int maxTerritories = Data.GetMaxTerritories(playerId); LandlordRPC.Instance?.SendNotification(playerId, $"Boss defeated! You can now claim up to {maxTerritories} territories!"); if (Data.HasKilledAllBosses(playerId)) { LandlordRPC.Instance?.SendNotification(playerId, "All bosses defeated! Claim 10 territories to become EMPEROR!"); } } private void ProcessUpkeepChecks() { //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0440: Unknown result type (might be due to invalid IL or missing references) //IL_0451: Unknown result type (might be due to invalid IL or missing references) //IL_0479: Unknown result type (might be due to invalid IL or missing references) _upkeepCheckTimer += Time.deltaTime; if (_upkeepCheckTimer < 60f) { return; } _upkeepCheckTimer = 0f; foreach (Territory value in Data.Territories.Values) { if (!value.IsUnlocked || value.IsAbandoned || value.IsEmperorTerritory) { continue; } if (value.IsUpkeepDue() && value.CurrentObjective == null) { value.Objectives = GenerateObjectivesForTerritory(value, forUnlock: false); value.CurrentObjective = ((value.Objectives.Count > 0) ? value.Objectives[0] : null); Plugin.Log.LogInfo((object)$"Upkeep due for territory {value.GridPosition}"); MarkDirty(); this.OnTerritoryChanged?.Invoke(value); } if (value.CurrentObjective != null && !value.CurrentObjective.IsForUnlock) { double num = (DateTime.UtcNow - value.LastUpkeepTime).TotalDays - 7.0; if (num >= 7.0) { ForceAbandonTerritory(value); } } } if (Data == null) { return; } if (Data.CurrentTribute == null) { Data.GenerateNewTribute(); MarkDirty(); SaveData(); Plugin.Log.LogInfo((object)$"Generated new Global Tribute: {Data.CurrentTribute.Type} {Data.CurrentTribute.BaseRequiredAmount}x {Data.CurrentTribute.TargetDisplayName}"); } if (Data.CurrentTribute == null || !Data.CurrentTribute.IsExpired()) { return; } int count = Data.Territories.Count; if (Data.CurrentTribute.IsComplete(count)) { Plugin.Log.LogInfo((object)"Global Tribute completed! Generating new one."); string message = "Tribute to the Gods completed! The gods are appeased... for now."; LandlordRPC.Instance?.BroadcastGlobalMessage(message); } else { int num2 = Random.Range(5000, 10001); Data.GlobalDebt += num2; Plugin.Log.LogInfo((object)$"Global Tribute FAILED! Adding {num2} to global debt. Total: {Data.GlobalDebt}"); string arg = ""; List list = new List(); foreach (Territory value2 in Data.Territories.Values) { if (!value2.IsAbandoned && !value2.IsInAuction && !value2.IsEmperorTerritory) { list.Add(value2); } } if (list.Count > 0) { Territory territory = list[Random.Range(0, list.Count)]; string ownerName = territory.OwnerName; string displayName = territory.DisplayName; Plugin.Log.LogInfo((object)("Odin seizes territory '" + displayName + "' from " + ownerName)); if (Data.PlayerPermitCounts.ContainsKey(territory.OwnerPlayerId)) { Data.PlayerPermitCounts[territory.OwnerPlayerId] = Math.Max(0, Data.PlayerPermitCounts[territory.OwnerPlayerId] - 1); } Data.Territories.Remove($"{territory.GridPosition.x},{territory.GridPosition.y}"); this.OnTerritoryAbandoned?.Invoke(territory.GridPosition); arg = "\nOdin has reclaimed " + ownerName + "'s territory \"" + displayName + "\"!"; } string message2 = $"Tribute to the Gods failed! Odin's wrath intensifies! (+{num2} global debt){arg}"; LandlordRPC.Instance?.BroadcastGlobalMessage(message2); } Data.GenerateNewTribute(); MarkDirty(); SaveData(); } private void ForceAbandonTerritory(Territory territory) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) Plugin.Log.LogInfo((object)$"Territory {territory.GridPosition} abandoned due to upkeep failure"); int minimumBid = CalculateMinimumBid(territory) / 2; Auction auction = new Auction(territory.GridPosition, minimumBid); territory.IsAbandoned = true; territory.IsInAuction = true; territory.AuctionEndTime = auction.EndTime; territory.CurrentObjective = null; Data.SetAuction(territory.GridPosition, auction); if (Data.PlayerPermitCounts.ContainsKey(territory.OwnerPlayerId)) { Data.PlayerPermitCounts[territory.OwnerPlayerId] = Math.Max(0, Data.PlayerPermitCounts[territory.OwnerPlayerId] - 1); } MarkDirty(); this.OnTerritoryAbandoned?.Invoke(territory.GridPosition); } private int CalculateMinimumBid(Territory territory) { int num = territory.CalculateToll() * 50; if (territory.HasPOI) { num = (int)((float)num * LandlordConfig.POIMultiplier.Value); } return Math.Max(100, num); } private void ProcessAuctions() { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) _auctionCheckTimer += Time.deltaTime; if (_auctionCheckTimer < 30f) { return; } _auctionCheckTimer = 0f; List list = new List(); foreach (Auction value in Data.Auctions.Values) { if (value.HasEnded && !value.IsFinalized) { FinalizeAuction(value); list.Add(value.TerritoryGrid); } } foreach (Vector2i item in list) { Data.RemoveAuction(item); } if (list.Count > 0) { MarkDirty(); } } private void FinalizeAuction(Auction auction) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) auction.IsFinalized = true; Territory territory = Data.GetTerritory(auction.TerritoryGrid); if (territory == null) { return; } if (auction.CurrentLeader != null) { AuctionBid currentLeader = auction.CurrentLeader; int value; int num = (Data.PlayerPermitCounts.TryGetValue(currentLeader.PlayerId, out value) ? value : 0); Data.PlayerPermitCounts[currentLeader.PlayerId] = num + 1; territory.OwnerPlayerId = currentLeader.PlayerId; territory.OwnerName = currentLeader.PlayerName; territory.IsAbandoned = false; territory.IsInAuction = false; territory.Guardians.Clear(); territory.AccumulatedIncome = 0; territory.IsUnlocked = true; territory.LastUpkeepTime = DateTime.UtcNow; territory.Objectives = GenerateObjectivesForTerritory(territory, forUnlock: false); territory.CurrentObjective = ((territory.Objectives.Count > 0) ? territory.Objectives[0] : null); Plugin.Log.LogInfo((object)$"Auction won: {currentLeader.PlayerName} acquired territory {auction.TerritoryGrid} for {currentLeader.Amount} coins"); if (!Data.PlayerStats.ContainsKey(currentLeader.PlayerId)) { Data.PlayerStats[currentLeader.PlayerId] = new LandlordStats(currentLeader.PlayerId, currentLeader.PlayerName); } Data.PlayerStats[currentLeader.PlayerId].TerritoriesOwned++; this.OnTerritoryClaimed?.Invoke(territory); } else { Data.RemoveTerritory(auction.TerritoryGrid); Plugin.Log.LogInfo((object)$"Auction ended with no bids: Territory {auction.TerritoryGrid} is now unclaimed"); } } public void ApplyServerData(LandlordData data) { Data = data; this.OnDataLoaded?.Invoke(); } public void ApplyTerritoryUpdate(Territory territory) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) Data.SetTerritory(territory.GridPosition, territory); this.OnTerritoryChanged?.Invoke(territory); } private void OnDestroy() { if (_isServer) { Plugin.Log.LogInfo((object)"TerritoryManager shutting down, saving data..."); SaveData(); } if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } private void OnApplicationQuit() { if (_isServer) { Plugin.Log.LogInfo((object)"Application quitting, saving landlord data..."); SaveData(); } } } public class ClaimResult { public bool Success { get; } public string Message { get; } public Territory Territory { get; } public ClaimResult(bool success, string message, Territory territory = null) { Success = success; Message = message; Territory = territory; } } public class TollManager : MonoBehaviour { [CompilerGenerated] private sealed class d__45 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public TollManager <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__45(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; SuppressCenterMessages = false; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private Dictionary _playerCurrentTerritories = new Dictionary(); private Dictionary _tollCooldowns = new Dictionary(); private Dictionary _originalPvPState = new Dictionary(); public const string TrialRunEffectName = "freyja_trialrun"; public static bool SuppressCenterMessages; public static TollManager Instance { get; private set; } public event Action OnTollCharged; public event Action OnDebtCreated; public event Action OnDebtPaid; private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { Instance = this; } } public void CheckPlayerPosition(long playerId, string playerName, Vector3 worldPos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //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_0013: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) Vector2i val = GridUtils.WorldToVisualGrid(worldPos); Plugin.Log.LogInfo((object)$"[TOLL] CheckPlayerPosition: {playerName} at world {worldPos}, grid {val}"); if (GridUtils.IsInSpawnProtection(val)) { Plugin.Log.LogInfo((object)"[TOLL] -> Spawn zone territory, skipping"); _playerCurrentTerritories[playerId] = null; return; } if (!GridUtils.IsWithinMapBounds(val)) { Plugin.Log.LogInfo((object)"[TOLL] -> Outside map bounds, skipping"); _playerCurrentTerritories[playerId] = null; return; } Vector2i? value; Vector2i? val2 = (_playerCurrentTerritories.TryGetValue(playerId, out value) ? value : null); if (!val2.HasValue || val2.Value != val) { Plugin.Log.LogInfo((object)$"[TOLL] -> New grid cell (prev: {val2})"); Territory territory = TerritoryManager.Instance?.GetTerritory(val); if (territory != null) { Plugin.Log.LogInfo((object)("[TOLL] -> Claimed territory by " + territory.OwnerName)); ProcessTerritoryEntry(playerId, playerName, territory); } else if (territory == null) { Plugin.Log.LogInfo((object)"[TOLL] -> UNCLAIMED territory - processing toll"); ProcessUnclaimedTerritoryEntry(playerId, playerName, val); } EnforcePvP(playerId, territory); _playerCurrentTerritories[playerId] = val; } } private void ProcessUnclaimedTerritoryEntry(long playerId, string playerName, Vector2i gridPos) { //IL_000c: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) Plugin.Log.LogInfo((object)$"ProcessUnclaimedTerritoryEntry: {playerName} entered {gridPos}"); if (HasTollCooldown(playerId, gridPos)) { int cooldownMinutesLeft = GetCooldownMinutesLeft(playerId, gridPos); Player playerById = GetPlayerById(playerId); if (playerById != null) { ((Character)playerById).Message((MessageType)1, $"Toll paid. Resets in: {cooldownMinutesLeft}m", 0, (Sprite)null); } return; } Player playerById2 = GetPlayerById(playerId); if ((Object)(object)playerById2 != (Object)null) { bool flag = HasTrialRunProtection(playerById2); Plugin.Log.LogInfo((object)$" -> Trial Run check: {flag}"); if (flag) { Plugin.Log.LogInfo((object)" -> Player has Trial Run protection, no toll"); return; } } int num = GridUtils.CalculateTollForCell(gridPos); Plugin.Log.LogInfo((object)$" -> Toll amount: {num}"); bool flag2 = TryDeductToll(playerId, num); RecordTollPaid(playerId, gridPos); if (flag2) { Plugin.Log.LogInfo((object)" -> Toll PAID"); ShowUnclaimedTollNotification(playerId, num, addedToGlobalDebt: false); return; } Plugin.Log.LogInfo((object)" -> Cannot pay - adding to GLOBAL DEBT"); LandlordData landlordData = TerritoryManager.Instance?.Data; if (landlordData != null) { int starLevelBonus = landlordData.GetStarLevelBonus(); landlordData.AddGlobalDebt(num, playerId, playerName); int starLevelBonus2 = landlordData.GetStarLevelBonus(); Plugin.Log.LogInfo((object)$" -> Global debt now: {landlordData.GlobalDebt}, star bonus: {starLevelBonus2}"); if (starLevelBonus2 > starLevelBonus) { NotifyGlobalDebtIncrease(starLevelBonus2); } TerritoryManager.Instance?.MarkDirty(); } ShowUnclaimedTollNotification(playerId, num, addedToGlobalDebt: true); } private void ShowUnclaimedTollNotification(long playerId, int amount, bool addedToGlobalDebt) { Player playerById = GetPlayerById(playerId); if (!((Object)(object)playerById == (Object)null)) { string text; if (addedToGlobalDebt) { int valueOrDefault = (TerritoryManager.Instance?.Data?.GlobalDebt).GetValueOrDefault(); text = $"{amount} coins toll added to global debt ({valueOrDefault} total)"; } else { text = $"{amount} coins toll deducted"; } ((Character)playerById).Message((MessageType)2, text, 0, (Sprite)null); } } private void NotifyGlobalDebtIncrease(int newStarBonus) { string text = "WARNING: Global Debt has increased!\n" + $"Monsters are now +{newStarBonus} star levels stronger!\n" + "Pay off debt to reduce difficulty!"; foreach (Player allPlayer in Player.GetAllPlayers()) { ((Character)allPlayer).Message((MessageType)2, text, 0, (Sprite)null); } } public void ProcessPortalEntry(long playerId, string playerName, Vector3 destination) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) _playerCurrentTerritories[playerId] = null; CheckPlayerPosition(playerId, playerName, destination); } private void ProcessTerritoryEntry(long playerId, string playerName, Territory territory) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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) if (territory.IsExemptFromToll(playerId)) { return; } if (HasTollCooldown(playerId, territory.GridPosition)) { int cooldownMinutesLeft = GetCooldownMinutesLeft(playerId, territory.GridPosition); Player playerById = GetPlayerById(playerId); if (playerById != null) { ((Character)playerById).Message((MessageType)1, $"Toll paid. Resets in: {cooldownMinutesLeft}m", 0, (Sprite)null); } return; } Player playerById2 = GetPlayerById(playerId); if ((Object)(object)playerById2 != (Object)null && HasTrialRunProtection(playerById2)) { return; } int num = territory.CalculateToll(); bool flag = TryDeductToll(playerId, num); RecordTollPaid(playerId, territory.GridPosition); if (flag) { territory.AccumulatedIncome += num; if (TerritoryManager.Instance?.Data?.PlayerStats != null && TerritoryManager.Instance.Data.PlayerStats.TryGetValue(territory.OwnerPlayerId, out var value)) { value.TotalIncomeEarned += num; } TerritoryManager.Instance?.MarkDirty(); this.OnTollCharged?.Invoke(playerId, territory, num); ShowTollNotification(playerId, territory, num, isDebt: false); } else { CreateOrAddDebt(playerId, playerName, territory, num); ShowTollNotification(playerId, territory, num, isDebt: true); } } private bool TryDeductToll(long playerId, int amount) { Player playerById = GetPlayerById(playerId); if ((Object)(object)playerById == (Object)null) { Plugin.Log.LogWarning((object)$"TryDeductToll: Player {playerId} not found"); return false; } Inventory inventory = ((Humanoid)playerById).GetInventory(); if (inventory == null) { Plugin.Log.LogWarning((object)$"TryDeductToll: Inventory null for player {playerId}"); return false; } int num = 0; foreach (ItemData allItem in inventory.GetAllItems()) { if (!(allItem.m_shared.m_name == "$item_coins")) { GameObject dropPrefab = allItem.m_dropPrefab; if (!(((dropPrefab != null) ? ((Object)dropPrefab).name : null) == "Coins") && !allItem.m_shared.m_name.ToLower().Contains("coin")) { continue; } } num += allItem.m_stack; } Plugin.Log.LogInfo((object)$"TryDeductToll: Player has {num} coins, needs {amount}"); if (num >= amount) { inventory.RemoveItem("$item_coins", amount, -1, true); Plugin.Log.LogInfo((object)$"TryDeductToll: Removed {amount} coins successfully"); return true; } Plugin.Log.LogInfo((object)"TryDeductToll: Not enough coins, adding to debt"); return false; } private void CreateOrAddDebt(long playerId, string playerName, Territory territory, int amount) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) LandlordData landlordData = TerritoryManager.Instance?.Data; if (landlordData != null) { if (landlordData.Debts.TryGetValue(playerId, out var value)) { value.AddDebt(amount); Plugin.Log.LogInfo((object)$"{playerName} debt increased by {amount} to {value.Amount}"); } else { Debt debt = new Debt(playerId, playerName, territory.OwnerPlayerId, territory.OwnerName, territory.GridPosition, amount); landlordData.Debts[playerId] = debt; this.OnDebtCreated?.Invoke(debt); Plugin.Log.LogInfo((object)$"{playerName} now in debt: {amount} coins to {territory.OwnerName}"); } TerritoryManager.Instance?.MarkDirty(); } } public bool PayDebt(long debtorId, int amount = -1) { //IL_012d: Unknown result type (might be due to invalid IL or missing references) LandlordData landlordData = TerritoryManager.Instance?.Data; if (landlordData == null) { return false; } if (!landlordData.Debts.TryGetValue(debtorId, out var value)) { return false; } if (amount == -1) { amount = value.Amount; } Player playerById = GetPlayerById(debtorId); if ((Object)(object)playerById == (Object)null) { return false; } Inventory inventory = ((Humanoid)playerById).GetInventory(); if (inventory == null) { return false; } int val = inventory.CountItems("$item_coins", -1, true); int num = Math.Min(amount, Math.Min(val, value.Amount)); if (num <= 0) { return false; } inventory.RemoveItem("$item_coins", num, -1, true); value.Amount -= num; Player playerById2 = GetPlayerById(value.CreditorPlayerId); if ((Object)(object)playerById2 != (Object)null) { Inventory inventory2 = ((Humanoid)playerById2).GetInventory(); if (inventory2 != null) { inventory2.AddItem(ObjectDB.instance.GetItemPrefab("Coins"), num); } } else { Territory territory = landlordData.GetTerritory(value.TerritoryGrid); if (territory != null) { territory.AccumulatedIncome += num; } } if (value.Amount <= 0) { landlordData.Debts.Remove(debtorId); this.OnDebtPaid?.Invoke(value); Plugin.Log.LogInfo((object)(value.DebtorName + " paid off their debt")); } TerritoryManager.Instance?.MarkDirty(); return true; } public bool ForgiveDeb(long landlordId, long debtorId) { LandlordData landlordData = TerritoryManager.Instance?.Data; if (landlordData == null) { return false; } if (!landlordData.Debts.TryGetValue(debtorId, out var value)) { return false; } if (value.CreditorPlayerId != landlordId) { return false; } landlordData.Debts.Remove(debtorId); this.OnDebtPaid?.Invoke(value); TerritoryManager.Instance?.MarkDirty(); Plugin.Log.LogInfo((object)("Landlord " + value.CreditorName + " forgave debt of " + value.DebtorName)); return true; } public bool CollectDebt(long landlordId, long debtorId) { LandlordData landlordData = TerritoryManager.Instance?.Data; if (landlordData == null) { return false; } if (!landlordData.Debts.TryGetValue(debtorId, out var value)) { return false; } if (value.CreditorPlayerId != landlordId) { return false; } Player playerById = GetPlayerById(debtorId); Player playerById2 = GetPlayerById(landlordId); if ((Object)(object)playerById == (Object)null || (Object)(object)playerById2 == (Object)null) { landlordData.Debts.Remove(debtorId); TerritoryManager.Instance?.MarkDirty(); return true; } Inventory inventory = ((Humanoid)playerById).GetInventory(); Inventory inventory2 = ((Humanoid)playerById2).GetInventory(); if (inventory == null || inventory2 == null) { return false; } int val = inventory.CountItems("$item_coins", -1, true); int num = Math.Min(val, value.Amount); if (num > 0) { inventory.RemoveItem("$item_coins", num, -1, true); inventory2.AddItem(ObjectDB.instance.GetItemPrefab("Coins"), num); value.Amount -= num; } landlordData.Debts.Remove(debtorId); this.OnDebtPaid?.Invoke(value); TerritoryManager.Instance?.MarkDirty(); Plugin.Log.LogInfo((object)$"Landlord {value.CreditorName} collected {num} coins from {value.DebtorName}"); return true; } public Debt GetPlayerDebt(long playerId) { TerritoryManager instance = TerritoryManager.Instance; Debt value = default(Debt); return (instance != null && (instance.Data?.Debts.TryGetValue(playerId, out value)).GetValueOrDefault()) ? value : null; } public void NotifyDebtPaid(Debt debt) { this.OnDebtPaid?.Invoke(debt); } public bool IsPlayerInDebt(long playerId) { return GetPlayerDebt(playerId) != null; } public List GetDebtorInventory(long landlordId, long debtorId) { List list = new List(); Debt playerDebt = GetPlayerDebt(debtorId); if (playerDebt == null || playerDebt.CreditorPlayerId != landlordId) { return list; } Player playerById = GetPlayerById(debtorId); if ((Object)(object)playerById == (Object)null) { return list; } Inventory inventory = ((Humanoid)playerById).GetInventory(); if (inventory == null) { return list; } foreach (ItemData allItem in inventory.GetAllItems()) { list.Add(new ItemInfo { Name = allItem.m_shared.m_name, DisplayName = Localization.instance.Localize(allItem.m_shared.m_name), Amount = allItem.m_stack, Quality = allItem.m_quality }); } return list; } private void ShowTollNotification(long playerId, Territory territory, int amount, bool isDebt) { string message = (isDebt ? $"{amount} coins toll added to personal debt ({territory.OwnerName}'s land)" : $"{amount} coins toll deducted"); LandlordRPC.Instance?.SendNotification(playerId, message); } public bool HasTrialRunProtection(Player player) { if ((Object)(object)player == (Object)null) { return false; } SEMan sEMan = ((Character)player).GetSEMan(); if (sEMan == null) { return false; } List statusEffects = sEMan.GetStatusEffects(); if (statusEffects != null && statusEffects.Count > 0) { Plugin.Log.LogDebug((object)$"Player has {statusEffects.Count} status effects"); foreach (StatusEffect item in statusEffects) { if ((Object)(object)item != (Object)null) { Plugin.Log.LogDebug((object)(" Effect: '" + ((Object)item).name + "' (looking for 'freyja_trialrun')")); if (((Object)item).name == "freyja_trialrun") { Plugin.Log.LogDebug((object)$" -> MATCH! Remaining: {item.GetRemaningTime()}s"); return true; } } } } return false; } public void ApplyTrialRunProtection(Player player) { if ((Object)(object)player == (Object)null) { return; } SEMan sEMan = ((Character)player).GetSEMan(); if (sEMan == null || HasTrialRunProtection(player)) { return; } float ttl = LandlordConfig.TrialRunDurationHours.Value * 3600f; ObjectDB instance = ObjectDB.instance; StatusEffect val = ((instance != null) ? instance.GetStatusEffect("Rested".GetHashCode()) : null); if ((Object)(object)val != (Object)null) { SE_Stats val2 = ScriptableObject.CreateInstance(); ((Object)val2).name = "freyja_trialrun"; ((StatusEffect)val2).m_name = "Trial Run"; ((StatusEffect)val2).m_tooltip = "New player protection - no toll payments!"; ((StatusEffect)val2).m_ttl = ttl; ObjectDB instance2 = ObjectDB.instance; GameObject val3 = ((instance2 != null) ? instance2.GetItemPrefab("Dandelion") : null); ItemDrop val4 = ((val3 != null) ? val3.GetComponent() : null); if (val4?.m_itemData?.m_shared?.m_icons != null && val4.m_itemData.m_shared.m_icons.Length != 0) { ((StatusEffect)val2).m_icon = val4.m_itemData.m_shared.m_icons[0]; } else { ((StatusEffect)val2).m_icon = val.m_icon; } sEMan.AddStatusEffect((StatusEffect)(object)val2, false, 0, 0f); ((Character)player).Message((MessageType)2, "TRIAL RUN ACTIVE!\n" + $"No toll payments for {LandlordConfig.TrialRunDurationHours.Value} hours", 0, (Sprite)null); Plugin.Log.LogInfo((object)("Applied Trial Run protection to " + player.GetPlayerName())); } } public float GetTrialRunTimeRemaining(Player player) { if ((Object)(object)player == (Object)null) { return 0f; } SEMan sEMan = ((Character)player).GetSEMan(); if (sEMan == null) { return 0f; } foreach (StatusEffect statusEffect in sEMan.GetStatusEffects()) { if ((Object)(object)statusEffect != (Object)null && ((Object)statusEffect).name == "freyja_trialrun") { return statusEffect.GetRemaningTime(); } } return 0f; } public void RemoveTrialRunProtection(Player player) { if ((Object)(object)player == (Object)null) { return; } SEMan sEMan = ((Character)player).GetSEMan(); if (sEMan == null) { return; } StatusEffect val = null; foreach (StatusEffect statusEffect in sEMan.GetStatusEffects()) { if ((Object)(object)statusEffect != (Object)null && ((Object)statusEffect).name == "freyja_trialrun") { val = statusEffect; break; } } if ((Object)(object)val != (Object)null) { sEMan.RemoveStatusEffect(val, false); Plugin.Log.LogInfo((object)("Removed Trial Run protection from " + player.GetPlayerName())); ((Character)player).Message((MessageType)2, "Trial Run protection removed", 0, (Sprite)null); } } private string GetCooldownKey(long playerId, Vector2i cell) { //IL_000c: 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) return $"{playerId}_{cell.x}_{cell.y}"; } public bool HasTollCooldown(long playerId, Vector2i cell) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) string cooldownKey = GetCooldownKey(playerId, cell); if (_tollCooldowns.TryGetValue(cooldownKey, out var value)) { double num = LandlordConfig.TollCooldownMinutes.Value; if ((DateTime.UtcNow - value).TotalMinutes < num) { return true; } _tollCooldowns.Remove(cooldownKey); } return false; } public int GetCooldownMinutesLeft(long playerId, Vector2i cell) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) string cooldownKey = GetCooldownKey(playerId, cell); if (_tollCooldowns.TryGetValue(cooldownKey, out var value)) { double num = LandlordConfig.TollCooldownMinutes.Value; double totalMinutes = (DateTime.UtcNow - value).TotalMinutes; int val = (int)(num - totalMinutes); return Math.Max(0, val); } return 0; } private void RecordTollPaid(long playerId, Vector2i cell) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) _tollCooldowns[GetCooldownKey(playerId, cell)] = DateTime.UtcNow; } public void EnforcePvP(long playerId, Territory territory) { Player playerById = GetPlayerById(playerId); if ((Object)(object)playerById == (Object)null) { return; } bool value; if (territory != null && territory.IsPvPEnabled && !territory.IsExemptFromToll(playerId)) { if (!_originalPvPState.ContainsKey(playerId)) { _originalPvPState[playerId] = ((Character)playerById).IsPVPEnabled(); } if (!((Character)playerById).IsPVPEnabled()) { SetPvPSilent(playerById, pvpEnabled: true); } } else if (_originalPvPState.TryGetValue(playerId, out value)) { if (((Character)playerById).IsPVPEnabled() != value) { SetPvPSilent(playerById, value); } _originalPvPState.Remove(playerId); } } private void SetPvPSilent(Player player, bool pvpEnabled) { SuppressCenterMessages = true; player.SetPVP(pvpEnabled); ((MonoBehaviour)this).StartCoroutine(ResetSuppressNextFrame()); } [IteratorStateMachine(typeof(d__45))] private IEnumerator ResetSuppressNextFrame() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__45(0) { <>4__this = this }; } private Player GetPlayerById(long playerId) { foreach (Player allPlayer in Player.GetAllPlayers()) { if (allPlayer.GetPlayerID() == playerId) { return allPlayer; } } return null; } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } } public class ItemInfo { public string Name; public string DisplayName; public int Amount; public int Quality; } public static class VaultKeySetup { public static readonly string[] PrefabNames = new string[3] { "freyja_vaultkey_bronze", "freyja_vaultkey_silver", "freyja_vaultkey_gold" }; public static readonly string[] DisplayNames = new string[3] { "Bronze Vault Key", "Silver Vault Key", "Gold Vault Key" }; public static readonly string[] Descriptions = new string[3] { "A crude bronze key, warm to the touch. It hums faintly near territory vaults.\n25% raid success chance. Yields 1 item stack.", "A polished silver key etched with runes. Odin's favor lingers upon it.\n50% raid success chance. Yields up to 2 item stacks.", "A radiant golden key forged in divine fire. Even the bravest lords fear its holder.\n75% raid success chance. Yields up to 3 item stacks." }; private static readonly GameObject[] _keyPrefabs = (GameObject[])(object)new GameObject[3]; private static GameObject _prefabRoot; private static bool _itemsCreated = false; private static bool _registeredInObjectDB = false; private static GameObject[] FindHildirKeys(ObjectDB objectDB) { Plugin.Log.LogInfo((object)"VaultKeySetup: Searching for Hildir key prefabs..."); List list = new List(); foreach (GameObject item in objectDB.m_items) { if (!((Object)(object)item == (Object)null)) { string text = ((Object)item).name.ToLowerInvariant(); if (text.Contains("hildir") && text.Contains("key")) { Plugin.Log.LogInfo((object)(" Found: '" + ((Object)item).name + "'")); list.Add(item); } } } if (list.Count == 0) { return null; } list.Sort((GameObject a, GameObject b) => string.Compare(((Object)a).name, ((Object)b).name, StringComparison.OrdinalIgnoreCase)); GameObject[] array = (GameObject[])(object)new GameObject[3]; for (int i = 0; i < 3; i++) { array[i] = list[Math.Min(i, list.Count - 1)]; } for (int j = 0; j < 3; j++) { Plugin.Log.LogInfo((object)$" Tier {j} ({PrefabNames[j]}) -> '{((Object)array[j]).name}'"); } return array; } private static void CreateKeyPrefabs(ObjectDB objectDB) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown if (_itemsCreated) { return; } GameObject[] array = FindHildirKeys(objectDB); if (array == null) { return; } _prefabRoot = new GameObject("FreyjaVaultKeyPrefabs"); _prefabRoot.SetActive(false); Object.DontDestroyOnLoad((Object)(object)_prefabRoot); for (int i = 0; i < 3; i++) { try { GameObject val = Object.Instantiate(array[i], _prefabRoot.transform); ((Object)val).name = PrefabNames[i]; val.SetActive(true); ItemDrop component = val.GetComponent(); if (component?.m_itemData?.m_shared == null) { Plugin.Log.LogError((object)("VaultKeySetup: '" + PrefabNames[i] + "' has no valid ItemDrop!")); continue; } SharedData shared = component.m_itemData.m_shared; string text = PrefabNames[i].Split(new char[1] { '_' }).Last(); shared.m_name = "$freyja_vaultkey_" + text; shared.m_description = "$freyja_vaultkey_" + text + "_desc"; shared.m_maxStackSize = 20; shared.m_weight = 0.5f; shared.m_maxQuality = 1; shared.m_questItem = false; component.m_itemData.m_dropPrefab = val; _keyPrefabs[i] = val; Plugin.Log.LogInfo((object)("VaultKeySetup: Created '" + PrefabNames[i] + "' from '" + ((Object)array[i]).name + "'")); } catch (Exception arg) { Plugin.Log.LogError((object)$"VaultKeySetup: Failed {PrefabNames[i]}: {arg}"); } } _itemsCreated = true; } public static void RegisterInObjectDB(ObjectDB objectDB) { if (_registeredInObjectDB || (Object)(object)objectDB == (Object)null || objectDB.m_items == null || objectDB.m_items.Count == 0) { return; } if (!_itemsCreated) { CreateKeyPrefabs(objectDB); } int i; for (i = 0; i < 3; i++) { if (!((Object)(object)_keyPrefabs[i] == (Object)null) && !objectDB.m_items.Exists((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name == PrefabNames[i])) { objectDB.m_items.Add(_keyPrefabs[i]); } } UpdateHash(objectDB); for (int j = 0; j < 3; j++) { GameObject itemPrefab = objectDB.GetItemPrefab(PrefabNames[j]); Plugin.Log.LogInfo((object)(((Object)(object)itemPrefab != (Object)null) ? ("VaultKeySetup: VERIFIED ObjectDB '" + PrefabNames[j] + "'") : ("VaultKeySetup: FAILED ObjectDB '" + PrefabNames[j] + "'"))); } _registeredInObjectDB = true; } private static void UpdateHash(ObjectDB objectDB) { BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; string[] array = new string[3] { "m_itemByHash", "m_itemsByHash", "m_itemHashes" }; foreach (string name in array) { FieldInfo field = typeof(ObjectDB).GetField(name, bindingAttr); if (field == null || !(field.GetValue(objectDB) is Dictionary dictionary)) { continue; } GameObject[] keyPrefabs = _keyPrefabs; foreach (GameObject val in keyPrefabs) { if ((Object)(object)val != (Object)null) { dictionary[StringExtensionMethods.GetStableHashCode(((Object)val).name)] = val; } } return; } FieldInfo[] fields = typeof(ObjectDB).GetFields(bindingAttr); foreach (FieldInfo fieldInfo in fields) { if (fieldInfo.FieldType != typeof(Dictionary) || !(fieldInfo.GetValue(objectDB) is Dictionary dictionary2) || dictionary2.Count < 50) { continue; } GameObject[] keyPrefabs2 = _keyPrefabs; foreach (GameObject val2 in keyPrefabs2) { if ((Object)(object)val2 != (Object)null) { dictionary2[StringExtensionMethods.GetStableHashCode(((Object)val2).name)] = val2; } } break; } } public static void RegisterInZNetScene(ZNetScene zNetScene) { if ((Object)(object)zNetScene == (Object)null) { return; } BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; Dictionary dictionary = null; string[] array = new string[2] { "m_namedPrefabs", "m_prefabsByHash" }; foreach (string name in array) { FieldInfo field = typeof(ZNetScene).GetField(name, bindingAttr); if (!(field == null)) { dictionary = field.GetValue(zNetScene) as Dictionary; if (dictionary != null) { break; } } } if (dictionary == null) { FieldInfo[] fields = typeof(ZNetScene).GetFields(bindingAttr); foreach (FieldInfo fieldInfo in fields) { if (!(fieldInfo.FieldType != typeof(Dictionary)) && fieldInfo.GetValue(zNetScene) is Dictionary dictionary2 && dictionary2.Count > 50) { dictionary = dictionary2; break; } } } if (dictionary == null) { return; } GameObject[] keyPrefabs = _keyPrefabs; foreach (GameObject val in keyPrefabs) { if (!((Object)(object)val == (Object)null)) { int stableHashCode = StringExtensionMethods.GetStableHashCode(((Object)val).name); if (!dictionary.ContainsKey(stableHashCode)) { dictionary[stableHashCode] = val; Plugin.Log.LogInfo((object)("VaultKeySetup: Registered " + ((Object)val).name + " in ZNetScene")); } } } } public static void RegisterLocalization() { Localization instance = Localization.instance; if (instance == null) { return; } BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; Dictionary dictionary = null; string[] array = new string[3] { "m_translations", "m_words", "m_strings" }; foreach (string name in array) { FieldInfo field = typeof(Localization).GetField(name, bindingAttr); if (!(field == null)) { dictionary = field.GetValue(instance) as Dictionary; if (dictionary != null) { break; } } } if (dictionary == null) { FieldInfo[] fields = typeof(Localization).GetFields(bindingAttr); foreach (FieldInfo fieldInfo in fields) { if (!(fieldInfo.FieldType != typeof(Dictionary))) { dictionary = fieldInfo.GetValue(instance) as Dictionary; if (dictionary != null) { break; } } } } if (dictionary != null) { for (int k = 0; k < 3; k++) { string text = PrefabNames[k].Split(new char[1] { '_' }).Last(); dictionary["freyja_vaultkey_" + text] = DisplayNames[k]; dictionary["freyja_vaultkey_" + text + "_desc"] = Descriptions[k]; } Plugin.Log.LogInfo((object)"VaultKeySetup: Localization registered."); } } public static int[] CountKeysInInventory(Inventory inventory) { int[] array = new int[3]; if (inventory == null) { return array; } foreach (ItemData allItem in inventory.GetAllItems()) { GameObject dropPrefab = allItem.m_dropPrefab; string text = ((dropPrefab != null) ? ((Object)dropPrefab).name : null) ?? ""; string text2 = allItem.m_shared?.m_name ?? ""; for (int i = 0; i < 3; i++) { string text3 = PrefabNames[i].Split(new char[1] { '_' }).Last(); if (text == PrefabNames[i] || text2 == "$freyja_vaultkey_" + text3) { array[i] += allItem.m_stack; } } } return array; } public static bool RemoveKeyFromInventory(Inventory inventory, int keyType) { if (inventory == null || keyType < 0 || keyType > 2) { return false; } string text = PrefabNames[keyType]; string text2 = PrefabNames[keyType].Split(new char[1] { '_' }).Last(); string text3 = "$freyja_vaultkey_" + text2; foreach (ItemData allItem in inventory.GetAllItems()) { GameObject dropPrefab = allItem.m_dropPrefab; string text4 = ((dropPrefab != null) ? ((Object)dropPrefab).name : null) ?? ""; string text5 = allItem.m_shared?.m_name ?? ""; if (text4 == text || text5 == text3) { if (allItem.m_stack > 1) { allItem.m_stack--; } else { inventory.RemoveItem(allItem); } return true; } } return false; } public static bool AddKeyToInventory(Inventory inventory, int keyType) { if (inventory == null || keyType < 0 || keyType > 2) { return false; } GameObject val = _keyPrefabs[keyType]; if ((Object)(object)val == (Object)null) { ObjectDB instance = ObjectDB.instance; val = ((instance != null) ? instance.GetItemPrefab(PrefabNames[keyType]) : null); } if ((Object)(object)val == (Object)null) { return false; } inventory.AddItem(val, 1); return true; } public static void FixDropPrefab(ItemData item) { if (item == null || (Object)(object)item.m_dropPrefab != (Object)null) { return; } string text = item.m_shared?.m_name ?? ""; for (int i = 0; i < 3; i++) { string text2 = PrefabNames[i].Split(new char[1] { '_' }).Last(); if (text == "$freyja_vaultkey_" + text2) { object obj = _keyPrefabs[i]; if (obj == null) { ObjectDB instance = ObjectDB.instance; obj = ((instance != null) ? instance.GetItemPrefab(PrefabNames[i]) : null); } item.m_dropPrefab = (GameObject)obj; break; } } } } [HarmonyPatch] public static class VaultKeyPatches { [HarmonyPatch(typeof(ObjectDB), "Awake")] [HarmonyPostfix] public static void ObjectDB_Awake_Postfix(ObjectDB __instance) { VaultKeySetup.RegisterInObjectDB(__instance); VaultKeySetup.RegisterLocalization(); } [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] [HarmonyPostfix] public static void ObjectDB_CopyOtherDB_Postfix(ObjectDB __instance) { VaultKeySetup.RegisterInObjectDB(__instance); VaultKeySetup.RegisterLocalization(); } [HarmonyPatch(typeof(ZNetScene), "Awake")] [HarmonyPostfix] public static void ZNetScene_Awake_Postfix(ZNetScene __instance) { VaultKeySetup.RegisterInZNetScene(__instance); } [HarmonyPatch(typeof(Humanoid), "DropItem")] [HarmonyPrefix] public static void Humanoid_DropItem_Prefix(Inventory inventory, ItemData item, int amount) { VaultKeySetup.FixDropPrefab(item); } [HarmonyPatch(typeof(Player), "OnSpawned")] [HarmonyPostfix] public static void Player_OnSpawned_Postfix(Player __instance) { if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return; } Inventory inventory = ((Humanoid)__instance).GetInventory(); if (inventory == null) { return; } foreach (ItemData allItem in inventory.GetAllItems()) { VaultKeySetup.FixDropPrefab(allItem); } } [HarmonyPatch(typeof(Inventory), "Load")] [HarmonyPostfix] public static void Inventory_Load_Postfix(Inventory __instance) { foreach (ItemData allItem in __instance.GetAllItems()) { VaultKeySetup.FixDropPrefab(allItem); } } [HarmonyPatch(typeof(Player), "AutoPickup")] [HarmonyPrefix] public static void Player_AutoPickup_Prefix(Player __instance) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)null) { return; } try { Collider[] array = Physics.OverlapSphere(((Component)__instance).transform.position, __instance.m_autoPickupRange, LayerMask.GetMask(new string[1] { "item" })); Collider[] array2 = array; foreach (Collider val in array2) { if (!((Object)(object)val == (Object)null)) { ItemDrop componentInParent = ((Component)val).GetComponentInParent(); if (componentInParent?.m_itemData != null) { VaultKeySetup.FixDropPrefab(componentInParent.m_itemData); } } } } catch { } } } }