Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of AuroraFreyjaLandlord v1.2.6
plugins/FreyjaLandlord.dll
Decompiled a week ago
The result has been truncated due to the large size, download it to view full contents!
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.Cryptography; using System.Security.Permissions; using System.Text; 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.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("freyja")] [assembly: AssemblyConfiguration("Release")] [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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Invalid comparison between Unknown and I4 //IL_0140: 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<TerritoryManager>(); _managerObject.AddComponent<TollManager>(); _managerObject.AddComponent<DebtManager>(); _managerObject.AddComponent<AuctionManager>(); _managerObject.AddComponent<GridManager>(); _managerObject.AddComponent<DebtorTracker>(); _managerObject.AddComponent<LandlordRPC>(); _managerObject.AddComponent<BanManager>(); if ((int)SystemInfo.graphicsDeviceType != 4) { _managerObject.AddComponent<ExplorationTracker>(); _managerObject.AddComponent<LandlordHUD>(); _managerObject.AddComponent<MapGridOverlay>(); _managerObject.AddComponent<TerritoryPopup>(); Log.LogInfo((object)$"Press {LandlordConfig.HUDToggleKey.Value} to open the Landlord HUD"); } else { Log.LogInfo((object)"Dedicated server mode — UI components skipped"); } Log.LogInfo((object)"Freyja Landlord System loaded successfully!"); } 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; private const float TrackInterval = 0.5f; private Vector2i? _lastReportedGrid; 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_0016: 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_001c: 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_0022: 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_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_0059: 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<Vector2i, bool> _merchantCache = new Dictionary<Vector2i, bool>(); private static float _merchantCacheTime = 0f; private const float MerchantCacheLifetime = 60f; public static Biome GetBiomeAt(Vector3 position) { //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) if (WorldGenerator.instance == null) { return (Biome)1; } return WorldGenerator.instance.GetBiome(position); } public static Dictionary<int, float> SampleBiomeComposition(Vector2i gridPos, int sampleCount = 100) { //IL_000b: 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_0011: 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_0072: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Expected I4, but got Unknown //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Expected I4, but got Unknown Dictionary<int, float> dictionary = new Dictionary<int, float>(); 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) { int key = (int)GetBiomeAt(val); if (!dictionary.ContainsKey(key)) { dictionary[key] = 0f; } dictionary[key]++; num5++; } } } if (num5 > 0) { foreach (int item in new List<int>(dictionary.Keys)) { dictionary[item] = dictionary[item] / (float)num5 * 100f; } } if (num5 == 0) { Biome biomeAt = GetBiomeAt(regionCenter); dictionary[(int)biomeAt] = 100f; } return dictionary; } public static bool CellHasMerchant(Vector2i gridPos) { //IL_003a: 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_006e: 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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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_00e2: 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_00e9: 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_00f2: 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_0101: 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<Vector2i, LocationInstance> 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<int, float> composition) { if (composition != null && composition.Count != 0) { int num = 1; float num2 = 0f; foreach (KeyValuePair<int, float> item in composition) { if (item.Value > num2) { num2 = item.Value; num = item.Key; } } return (Biome)num; } return (Biome)1; } public static bool HasPointOfInterest(Vector2i gridPos) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_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_0069: 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_007e: 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_0084: 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_008d: 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_009c: 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<Vector2i, LocationInstance> locationInstance in ZoneSystem.instance.m_locationInstances) { LocationInstance value = locationInstance.Value; if (value.m_location != null && IsPOILocation(value.m_location.m_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_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Invalid comparison between Unknown and I4 //IL_0005: 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_001d: Expected I4, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Invalid comparison between Unknown and I4 //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Invalid comparison between Unknown and I4 //IL_0072: 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_00a6: 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_013b: 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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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_001f: Invalid comparison between Unknown and I4 //IL_0133: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Invalid comparison between Unknown and I4 //IL_0105: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Invalid comparison between Unknown and I4 //IL_0141: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between Unknown and I4 //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: 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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: 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) if ((int)biome <= 16) { switch (biome - 1) { default: if ((int)biome != 8) { if ((int)biome != 16) { break; } return new Color(0.9f, 0.85f, 0.4f); } return new Color(0.2f, 0.4f, 0.2f); case 0: return new Color(0.4f, 0.8f, 0.3f); case 1: return new Color(0.4f, 0.35f, 0.2f); case 3: return new Color(0.8f, 0.8f, 0.9f); case 2: break; } } else if ((int)biome <= 64) { if ((int)biome == 32) { return new Color(0.8f, 0.3f, 0.2f); } if ((int)biome == 64) { return new Color(0.7f, 0.9f, 1f); } } else { if ((int)biome == 256) { return new Color(0.2f, 0.4f, 0.8f); } if ((int)biome == 512) { return new Color(0.5f, 0.3f, 0.6f); } } return Color.gray; } public static string GetBiomeName(Biome biome) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 //IL_0005: 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_001d: Expected I4, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Invalid comparison between Unknown and I4 //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Invalid comparison between Unknown and I4 //IL_0081: 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_008d: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between Unknown and I4 //IL_0099: 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_00a8: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: 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_00e6: Unknown result type (might be due to invalid IL or missing references) if ((int)biome <= 16) { switch (biome - 1) { default: if ((int)biome != 8) { if ((int)biome != 16) { break; } return "Plains"; } return "Black Forest"; case 0: return "Meadows"; case 1: return "Swamp"; case 3: return "Mountain"; case 2: break; } } else if ((int)biome <= 64) { if ((int)biome == 32) { return "Ashlands"; } if ((int)biome == 64) { return "Deep North"; } } else { if ((int)biome == 256) { return "Ocean"; } if ((int)biome == 512) { return "Mistlands"; } } if ((biome & 0x20) != 0) { return "Ashlands"; } if ((biome & 0x40) != 0) { return "Deep North"; } if ((biome & 0x200) != 0) { return "Mistlands"; } if ((biome & 0x10) != 0) { return "Plains"; } if ((biome & 4) != 0) { return "Mountain"; } if ((biome & 2) != 0) { return "Swamp"; } if ((biome & 8) != 0) { return "Black Forest"; } if ((biome & 1) != 0) { return "Meadows"; } if ((biome & 0x100) != 0) { return "Ocean"; } return "Wilds"; } public static float GetBiomeTollMultiplier(Biome biome) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Invalid comparison between Unknown and I4 //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Invalid comparison between Unknown and I4 //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_0024: Expected I4, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Invalid comparison between Unknown and I4 //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Invalid comparison between Unknown and I4 //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Invalid comparison between Unknown and I4 //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 Biome val = ResolveBiome(biome); if ((int)val <= 16) { switch (val - 1) { default: if ((int)val != 8) { if ((int)val != 16) { break; } return 3f; } return 1.5f; case 0: return 1f; case 1: return 2f; case 3: return 2.5f; case 2: break; } } else if ((int)val <= 64) { if ((int)val == 32) { return 5f; } if ((int)val == 64) { return 3f; } } else { if ((int)val == 256) { return 0.5f; } if ((int)val == 512) { return 4f; } } return 1f; } public static Biome ResolveBiome(Biome biome) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Invalid comparison between Unknown and I4 //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Invalid comparison between Unknown and I4 //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Invalid comparison between Unknown and I4 //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 //IL_0009: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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 //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 //IL_0043: 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: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_0067: 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_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_0076: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) if ((int)biome <= 16) { if ((int)biome <= 4) { if (biome - 1 <= 1 || (int)biome == 4) { goto IL_0041; } } else if ((int)biome == 8 || (int)biome == 16) { goto IL_0041; } } else if ((int)biome <= 64) { if ((int)biome == 32 || (int)biome == 64) { goto IL_0041; } } else if ((int)biome == 256 || (int)biome == 512) { goto IL_0041; } if ((biome & 0x20) == 0) { if ((biome & 0x40) == 0) { if ((biome & 0x200) == 0) { if ((biome & 0x10) == 0) { if ((biome & 4) == 0) { if ((biome & 2) == 0) { if ((biome & 8) == 0) { if ((biome & 1) == 0) { if ((biome & 0x100) == 0) { return (Biome)1; } return (Biome)256; } return (Biome)1; } return (Biome)8; } return (Biome)2; } return (Biome)4; } return (Biome)16; } return (Biome)512; } return (Biome)64; } return (Biome)32; IL_0041: return biome; } public static List<TerritoryObjective> GetObjectivesForBiome(Biome biome) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0138: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Invalid comparison between Unknown and I4 //IL_0059: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_0100: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between Unknown and I4 //IL_01a5: 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) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Invalid comparison between Unknown and I4 //IL_0091: 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_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) List<TerritoryObjective> list = new List<TerritoryObjective>(); if ((int)biome <= 8) { switch (biome - 1) { case 0: goto IL_004b; case 1: goto IL_00ba; case 3: goto IL_00f2; case 2: goto IL_01cb; } if ((int)biome != 8) { goto IL_01cb; } 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_01cb; } 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_01e4; IL_004b: 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_01e4; IL_01cb: list.Add(new TerritoryObjective(ObjectiveType.KillMonsters, "Greyling", "Greylings", 5, forUnlock: true, biome)); goto IL_01e4; IL_01e4: return list; IL_00f2: 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_01e4; IL_00ba: 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_01e4; } } public static class GridUtils { public static Vector2i WorldToGrid(Vector3 worldPos) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) return VoronoiGrid.Instance.GetRegion(worldPos); } public static Vector2i WorldToVisualGrid(Vector3 worldPos) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) return WorldToGrid(worldPos); } public static Vector3 GridToWorldCenter(Vector2i grid) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) return VoronoiGrid.Instance.GetRegionCenter(grid); } public static Vector3 GridToWorld(Vector2i grid) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) return VoronoiGrid.Instance.GetRegionCenter(grid); } public static int GridDistance(Vector2i a, Vector2i b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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) Vector3 val = GridToWorldCenter(a); Vector3 val2 = GridToWorldCenter(b); return Mathf.RoundToInt(Vector3.Distance(val, val2) / 100f); } public static bool IsWithinMapBounds(Vector2i grid) { //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_001d: 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_002a: 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) float num = LandlordConfig.WorldRadius?.Value ?? 10500f; Vector3 val = GridToWorldCenter(grid); return Mathf.Sqrt(val.x * val.x + val.z * val.z) < num; } public static bool IsInSpawnProtection(Vector2i grid) { //IL_0005: 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_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_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_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) if (VoronoiGrid.Instance.IsSpawnZone(grid)) { return true; } float value = LandlordConfig.SpawnProtectionRadius.Value; Vector3 val = GridToWorldCenter(grid); return Mathf.Sqrt(val.x * val.x + val.z * val.z) <= value; } public static bool IsInSpawnProtection(Vector3 worldPos) { //IL_000b: 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) //IL_001e: Unknown result type (might be due to invalid IL or missing references) float value = LandlordConfig.SpawnProtectionRadius.Value; return Mathf.Sqrt(worldPos.x * worldPos.x + worldPos.z * worldPos.z) <= value; } public static bool GridCellOverlapsSpawnProtection(Vector2i grid) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return IsInSpawnProtection(grid); } public static int CalculateTollForCell(Vector2i grid) { //IL_0000: 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_0078: 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) if (IsInSpawnProtection(grid)) { return 0; } Dictionary<int, float> dictionary = BiomeUtils.SampleBiomeComposition(grid); float num = 0f; foreach (KeyValuePair<int, float> 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 num3 = Mathf.Clamp(VoronoiGrid.Instance.GetApproximateRegionRadius(grid) / 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_0000: Unknown result type (might be due to invalid IL or missing references) return BiomeUtils.CellHasMerchant(grid); } public static int GetClaimCost(Vector2i grid) { //IL_0000: 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_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_0011: 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_0013: 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_002b: Expected I4, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Invalid comparison between Unknown and I4 //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Invalid comparison between Unknown and I4 //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Invalid comparison between Unknown and I4 //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Invalid comparison between Unknown and I4 //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Invalid comparison between Unknown and I4 //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Invalid comparison between Unknown and I4 Biome dominantBiome = BiomeUtils.GetDominantBiome(BiomeUtils.SampleBiomeComposition(grid)); int num; if ((int)dominantBiome <= 16) { switch (dominantBiome - 1) { case 0: goto IL_0059; case 1: goto IL_006b; case 3: goto IL_0074; case 2: goto IL_00aa; } if ((int)dominantBiome != 8) { if ((int)dominantBiome != 16) { goto IL_00aa; } num = 6000; } else { num = 3000; } } else if ((int)dominantBiome <= 64) { if ((int)dominantBiome != 32) { if ((int)dominantBiome != 64) { goto IL_00aa; } num = 10000; } else { num = 9000; } } else if ((int)dominantBiome != 256) { if ((int)dominantBiome != 512) { goto IL_00aa; } num = 7000; } else { num = 2000; } goto IL_00b1; IL_0074: num = 5000; goto IL_00b1; IL_0059: num = 2000; goto IL_00b1; IL_006b: num = 4000; goto IL_00b1; IL_00b1: 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; IL_00aa: num = 2000; goto IL_00b1; } public static string GetBiomeCompositionString(Vector2i grid) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) Dictionary<int, float> dictionary = BiomeUtils.SampleBiomeComposition(grid); if (dictionary == null || dictionary.Count == 0) { return "Unknown"; } return TerritoryNaming.GetBiomeCompositionDescription(dictionary); } public static string GetTerritoryName(Vector2i grid) { //IL_0000: 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_0010: 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) Dictionary<int, float> 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<Biome, string[]> BiomeNames = new Dictionary<Biome, string[]> { { (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<int, float> biomeComposition, bool hasMerchant = false, bool hasBossAltar = false) { //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_002c: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_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_007c: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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})"; } Random random = new Random(gridPos.x * 10000 + gridPos.y); 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<int, float> biomeComposition) { //IL_0011: 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_002b: Unknown result type (might be due to invalid IL or missing references) if (biomeComposition == null || biomeComposition.Count == 0) { return "Unknown"; } Random rng = new Random(gridPos.x * 10000 + gridPos.y); return GetBiomeName(GetDominantBiome(biomeComposition), rng); } private static string GetDirectionalPrefix(Vector2i gridPos, Random rng) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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; if (Mathf.Sqrt(x * x + z * z) < 2000f) { return CenterPrefixes[rng.Next(CenterPrefixes.Length)]; } float num = Mathf.Atan2(z, x) * 57.29578f; if (num >= 45f && num < 135f) { return NorthPrefixes[rng.Next(NorthPrefixes.Length)]; } if (num >= -45f && num < 45f) { return EastPrefixes[rng.Next(EastPrefixes.Length)]; } if (num >= -135f && num < -45f) { return SouthPrefixes[rng.Next(SouthPrefixes.Length)]; } return WestPrefixes[rng.Next(WestPrefixes.Length)]; } private static string GetBiomeName(Biome biome, Random rng) { //IL_0005: 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_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_0022: 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_002b: 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)]; } Biome val = ResolveBiomeFlag(biome); if (val != biome && BiomeNames.TryGetValue(val, out var value2)) { return value2[rng.Next(value2.Length)]; } return "Wilderness"; } private static Biome ResolveBiomeFlag(Biome biome) { //IL_0000: 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_0009: 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_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_0021: 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: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_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_003f: 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_0046: 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_0055: Unknown result type (might be due to invalid IL or missing references) if ((biome & 0x20) != 0) { return (Biome)32; } if ((biome & 0x40) != 0) { return (Biome)64; } if ((biome & 0x200) != 0) { return (Biome)512; } if ((biome & 0x10) != 0) { return (Biome)16; } if ((biome & 4) != 0) { return (Biome)4; } if ((biome & 2) != 0) { return (Biome)2; } if ((biome & 8) != 0) { return (Biome)8; } if ((biome & 1) != 0) { return (Biome)1; } if ((biome & 0x100) != 0) { return (Biome)256; } return biome; } private static string GetShortBiomeName(Biome biome) { //IL_0000: 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_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) //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_0027: 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_0033: 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_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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) if ((biome & 0x20) != 0) { return "Ash"; } if ((biome & 0x40) != 0) { return "Frost"; } if ((biome & 0x200) != 0) { return "Mist"; } if ((biome & 0x10) != 0) { return "Plains"; } if ((biome & 4) != 0) { return "Mountain"; } if ((biome & 2) != 0) { return "Swamp"; } if ((biome & 8) != 0) { return "Forest"; } if ((biome & 1) != 0) { return "Meadow"; } if ((biome & 0x100) != 0) { return "Sea"; } return "Wilds"; } private static Biome GetDominantBiome(Dictionary<int, float> composition) { int num = 1; float num2 = 0f; foreach (KeyValuePair<int, float> item in composition) { if (item.Value > num2) { num2 = item.Value; num = item.Key; } } return (Biome)num; } private static Biome GetSecondaryBiome(Dictionary<int, float> composition, Biome exclude) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Expected I4, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between I4 and Unknown int num = (int)exclude; float num2 = 0f; foreach (KeyValuePair<int, float> 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<int, float> composition, Biome biome) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected I4, but got Unknown if (!composition.TryGetValue((int)biome, out var value)) { return 0f; } return value; } public static string GetBiomeCompositionDescription(Dictionary<int, float> composition) { if (composition == null || composition.Count == 0) { return "Unknown terrain"; } List<string> list = new List<string>(); List<KeyValuePair<int, float>> list2 = new List<KeyValuePair<int, float>>(composition); list2.Sort((KeyValuePair<int, float> a, KeyValuePair<int, float> b) => b.Value.CompareTo(a.Value)); foreach (KeyValuePair<int, float> 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; if (instance == null) { return false; } return instance.IsDedicated(); } public static bool IsServer() { ZNet instance = ZNet.instance; if (instance == null) { return false; } return instance.IsServer(); } public static long GetLocalPlayerId() { Player localPlayer = Player.m_localPlayer; if (localPlayer == null) { return 0L; } return localPlayer.GetPlayerID(); } 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) { if (!int.TryParse(value, out var result)) { return defaultValue; } return result; } public static Color LerpColor(Color a, Color b, float t) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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_0024: 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_0036: 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_0048: 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<Vector2> _seeds; private Dictionary<long, int> _quantizedToIndex; private Dictionary<long, List<int>> _spatialGrid; private const float SpatialCellSize = 2000f; private Dictionary<long, Vector2i> _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<Vector2>(); _quantizedToIndex = new Dictionary<long, int>(); _spatialGrid = new Dictionary<long, List<int>>(); _regionCache = new Dictionary<long, Vector2i>(); 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_0022: 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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0234: 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_028f: 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) / MapRadius; float num9 = 0.3f + num8 * 1.5f; float num10 = 0.7f + (float)random.NextDouble() * 0.6f; float num11 = num9 * num10; float num12 = num * num11; bool flag = false; for (int i = 0; i < _seeds.Count; i++) { float num13 = _seeds[i].x - num6; float num14 = _seeds[i].y - num7; if (num13 * num13 + num14 * num14 < num12 * num12) { flag = true; break; } } if (!flag) { _seeds.Add(new Vector2(num6, num7)); } } float num15 = num * 0.4f; float[] array = new float[3] { MapRadius * 0.7f, MapRadius * 0.82f, MapRadius * 0.93f }; int num16 = 45; for (int j = 0; j < array.Length; j++) { float num17 = array[j]; float num18 = (float)j * 0.5f; for (int k = 0; k < num16; k++) { float num19 = ((float)k + num18) / (float)num16 * (float)Math.PI * 2f; float num20 = num17 * Mathf.Cos(num19); float num21 = num17 * Mathf.Sin(num19); bool flag2 = false; for (int l = 0; l < _seeds.Count; l++) { float num22 = _seeds[l].x - num20; float num23 = _seeds[l].y - num21; if (num22 * num22 + num23 * num23 < num15 * num15) { flag2 = true; break; } } if (!flag2) { _seeds.Add(new Vector2(num20, num21)); } } } 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_0163: 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; int num2 = (num ^ (num >> 13)) * 1103515245; return (float)((num2 ^ (num2 >> 16)) & 0x7FFFFFFF) / 2.1474836E+09f; } private float PerturbedDistanceSq(float x, float z, int seedIndex) { //IL_0007: 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) 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_0017: 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) _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<int>(); _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_0011: 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) //IL_0017: 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) _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_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_0031: 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_0007: 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_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_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_0029: 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_0070: 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_0007: 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_0056: 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_0027: 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_002d: 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_003e: 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_0001: Unknown result type (might be due to invalid IL or missing references) return RegionIdToIndex(regionId) == SpawnZoneSeedIndex; } public string GetRegionKey(Vector2i regionId) { //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 $"{regionId.x}_{regionId.y}"; } public bool IsOnBorder(Vector3 worldPos, float threshold = 80f) { //IL_0006: 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_008d: 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) 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); return Mathf.Sqrt(num4) - num11 < threshold; } public float GetApproximateRegionRadius(Vector2i regionId) { //IL_0007: 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_003a: 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_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) 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<Vector2> GetAllSeeds() { EnsureInitialized(); return _seeds; } public int RegionIdToIndex(Vector2i regionId) { //IL_0000: 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) 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_0014: 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) 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 { [CompilerGenerated] private sealed class <TeleportImmunity>d__93 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Player player; public float duration; private bool <wasGodMode>5__2; private float <elapsed>5__3; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <TeleportImmunity>d__93(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; if ((Object)(object)player == (Object)null) { return false; } <wasGodMode>5__2 = ((Character)player).InGodMode(); if (!<wasGodMode>5__2) { player.SetGodMode(true); } ((Character)player).Message((MessageType)1, $"<color=#88ffff>Travel protection active ({(int)duration}s)</color>", 0, (Sprite)null); <elapsed>5__3 = 0f; break; case 1: <>1__state = -1; break; } if (<elapsed>5__3 < duration && (Object)(object)player != (Object)null && (!(<elapsed>5__3 > 3f) || !((Character)player).IsOnGround())) { <elapsed>5__3 += Time.deltaTime; <>2__current = null; <>1__state = 1; return true; } if ((Object)(object)player != (Object)null && !<wasGodMode>5__2) { player.SetGodMode(false); ((Character)player).Message((MessageType)1, "<color=#88ffff>Travel protection ended</color>", 0, (Sprite)null); } 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 bool _isVisible; private int _currentTab; private readonly string[] _tabNames = new string[9] { "Overview", "Your Land", "Vault", "Leaderboard", "Vassals", "Auctions", "Raid Log", "Tax Log", "?" }; private Vector2 _scrollPos = Vector2.zero; private Dictionary<string, string> _renameInputs = new Dictionary<string, string>(); private string _renamingTerritoryKey; private Vector2i? _addingGuardianFor; private string _guardianNameInput = ""; private static Dictionary<long, DateTime> _teleportCooldowns = new Dictionary<long, DateTime>(); private bool _isRaiding; private float _raidTimer; private float _raidDuration; private int _raidKeyType = -1; private Vector2i _raidTerritory; private List<VaultItem> _raidResults; private bool _raidSuccess; private string _raidSuccessMessage; private int _raidSelectedKey = -1; private GameObject _raidVfxInstance; private Vector2 _raidResultsScroll = Vector2.zero; private float _raidNotifyTimer; private Vector2 _raidLogScroll = Vector2.zero; private int _raidFlickerIndex = -1; private float _raidFlickerTimer; private static int _highlightVaultIndex = -1; private bool _showRaidWindow; private Territory _raidTargetTerritory; 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 bool _showConfirmDialog; private string _confirmTitle = ""; private string _confirmMessage = ""; private int _confirmCost; private Action _onConfirm; private Rect _confirmWindowRect = new Rect(0f, 0f, 480f, 220f); 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 Texture2D _btnNormalTex; private Texture2D _btnHoverTex; private Texture2D _insetTex; private bool _stylesInit; private Font _valheimFont; private bool _fontLoaded; private Rect _windowRect; private int _windowId; private bool _isExpanded; private const float BaseWidth = 800f; private const float BaseHeight = 450f; private const float ExpandedWidth = 1200f; private const float ExpandedHeight = 585f; private long _expandedDebtHistoryId; private Dictionary<string, string> _auctionBidInputs = new Dictionary<string, string>(); private Dictionary<string, Sprite> _taxIconCache = new Dictionary<string, Sprite>(); private VaultItem _vaultHoverItem; private Vector2 _vaultHoverPos; private bool _rentTooltipActive; private Vector2 _rentTooltipPos; private Dictionary<string, Sprite> _spriteCache = new Dictionary<string, Sprite>(); private bool _spriteCacheBuilt; public static LandlordHUD Instance { get; private set; } private static float UIScale => (float)Screen.height / 1080f; public bool IsVisible => _isVisible; private void RequestConfirmation(string title, string message, int cost, Action onConfirm) { _showConfirmDialog = true; _confirmTitle = title; _confirmMessage = message; _confirmCost = cost; _onConfirm = onConfirm; } private void DrawConfirmationModalWindow(int id) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) float width = ((Rect)(ref _confirmWindowRect)).width; float height = ((Rect)(ref _confirmWindowRect)).height; GUILayout.BeginArea(new Rect(12f, 12f, width - 24f, height - 24f)); GUILayout.Label("<size=18><b><color=#ffd700>" + _confirmTitle + "</color></b></size>", _labelGoldStyle, Array.Empty<GUILayoutOption>()); GUILayout.Space(8f); DrawSeparator(); GUILayout.Space(10f); GUILayout.Label(_confirmMessage, _labelStyle, Array.Empty<GUILayoutOption>()); GUILayout.Space(6f); if (_confirmCost > 0) { GUILayout.Label($"<color=#ffd700>Cost: {_confirmCost} coins</color>", _labelGoldStyle, Array.Empty<GUILayoutOption>()); } GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button("<color=#ff4444>Cancel</color>", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(34f) })) { _showConfirmDialog = false; _onConfirm = null; } if (GUILayout.Button("<color=#00ff00>Confirm</color>", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(34f) })) { Action onConfirm = _onConfirm; _showConfirmDialog = false; _onConfirm = null; onConfirm?.Invoke(); } GUILayout.EndHorizontal(); GUILayout.EndArea(); } 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; try { _isExpanded = LandlordConfig.HUDExpanded?.Value ?? false; } catch { _isExpanded = false; } } private void Start() { //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) float num = (float)Screen.width / UIScale; float num2 = (float)Screen.height / UIScale; float num3 = (_isExpanded ? 1200f : 800f); float num4 = (_isExpanded ? 585f : 450f); _windowRect = new Rect((num - num3) / 2f, num2 - (num4 + 20f), num3, num4); LoadValheimFont(); } private void Update() { //IL_002e: 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_0020: Invalid comparison between Unknown and I4 //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: 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_0188: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) if (_isVisible && (Object)(object)Minimap.instance != (Object)null && (int)Minimap.instance.m_mode == 2) { _isVisible = false; } if (Input.GetKeyDown(LandlordConfig.HUDToggleKey.Value)) { _isVisible = !_isVisible; if (_isVisible) { float num = (float)Screen.width / UIScale; float num2 = (float)Screen.height / UIScale; ((Rect)(ref _windowRect)).x = (num - ((Rect)(ref _windowRect)).width) / 2f; ((Rect)(ref _windowRect)).y = num2 - ((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, "<color=#ffaa66>Raid cancelled. Key returned to inventory.</color>", 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; Territory territory = TerritoryManager.Instance?.Data?.GetTerritory(_raidTerritory); int num3 = ((territory == null) ? null : TerritoryManager.Instance?.Data?.GetPlayerVault(territory.OwnerPlayerId))?.Count ?? 0; _raidFlickerIndex = ((num3 > 0) ? Random.Range(0, num3) : (-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 = $"<color=#ff0000>{arg} is raiding {arg2}'s Vault! ({Mathf.CeilToInt(_raidTimer)}s remaining)</color>"; 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<GameObject>(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>(); foreach (Font val in array) { 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_0061: 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_0073: Expected O, but got Unknown //IL_007b: 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_011b: Expected O, but got Unknown //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Expected O, but got Unknown //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Expected O, but got Unknown //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Expected O, but got Unknown //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Expected O, but got Unknown //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Expected O, but got Unknown //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Expected O, but got Unknown //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Expected O, but got Unknown //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Expected O, but got Unknown //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_03b4: Expected O, but got Unknown //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Expected O, but got Unknown //IL_0431: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Expected O, but got Unknown //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Unknown result type (might be due to invalid IL or missing references) //IL_0489: Expected O, but got Unknown //IL_04a3: Unknown result type (might be due to invalid IL or missing references) //IL_04c0: Unknown result type (might be due to invalid IL or missing references) //IL_04ca: Expected O, but got Unknown //IL_04e4: Unknown result type (might be due to invalid IL or missing references) //IL_0505: Unknown result type (might be due to invalid IL or missing references) //IL_050f: Expected O, but got Unknown //IL_056b: Unknown result type (might be due to invalid IL or missing references) //IL_0580: Unknown result type (might be due to invalid IL or missing references) //IL_05af: Unknown result type (might be due to invalid IL or missing references) //IL_05b9: Expected O, but got Unknown //IL_05c3: Unknown result type (might be due to invalid IL or missing references) //IL_05cd: Expected O, but got Unknown //IL_05f1: Unknown result type (might be due to invalid IL or missing references) //IL_05fb: Expected O, but got Unknown //IL_061d: Unknown result type (might be due to invalid IL or missing references) //IL_0627: Expected O, but got Unknown //IL_0631: Unknown result type (might be due to invalid IL or missing references) //IL_063b: Expected O, but got Unknown //IL_0646: Unknown result type (might be due to invalid IL or missing references) //IL_0650: Expected O, but got Unknown if (_stylesInit && ((Object)(object)_pixelTex == (Object)null || (Object)(object)_panelBg == (Object)null || (Object)(object)_btnNormalTex == (Object)null || (Object)(object)_btnHoverTex == (Object)null || (Object)(object)_insetTex == (Object)null)) { _stylesInit = false; } if (!_stylesInit) { _pixelTex = new Texture2D(1, 1) { hideFlags = (HideFlags)61 }; _pixelTex.SetPixel(0, 0, Color.white); _pixelTex.Apply(); _panelBg = CreatePanelTexture(64, 64); ((Object)_panelBg).hideFlags = (HideFlags)61; _btnNormalTex = CreateButtonTexture(32, 32, highlighted: false); ((Object)_btnNormalTex).hideFlags = (HideFlags)61; _btnHoverTex = CreateButtonTexture(32, 32, highlighted: true); ((Object)_btnHoverTex).hideFlags = (HideFlags)61; _insetTex = CreateInsetTexture(32, 32); ((Object)_insetTex).hideFlags = (HideFlags)61; _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 = _btnNormalTex; _tabStyle.hover.background = _btnHoverTex; _tabStyle.active.background = _btnHoverTex; _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 = _btnHoverTex; _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 = _btnNormalTex; _buttonStyle.hover.background = _btnHoverTex; _buttonStyle.active.background = _btnHoverTex; _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 = _insetTex; _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_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //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_00ef: 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_009f: 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_00ac: 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_00c4: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missi