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 Reign Of Kings v1.0.5
plugins/ReignOfKings.dll
Decompiled 8 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Buffers; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Diagnostics.Tracing; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Linq.Expressions; using System.Net; using System.Reflection; using System.Reflection.Emit; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.AccessControl; using System.Security.Cryptography; using System.Security.Permissions; using System.Security.Principal; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using BiomeLockAPI; using FxResources.System.Buffers; using Guilds; using HarmonyLib; using JetBrains.Annotations; using LiteDB; using LiteDB.Engine; using LiteDB.Utils; using LiteDB.Utils.Extensions; using LocalizationManager; using LocationManager; using Microsoft.CodeAnalysis; using ServerSync; using SoftReferenceableAssets; using Splatform; using TMPro; using UnityEngine; using UnityEngine.Audio; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Core.ObjectPool; using YamlDotNet.Core.Tokens; using YamlDotNet.Helpers; using YamlDotNet.Serialization; using YamlDotNet.Serialization.BufferedDeserialization; using YamlDotNet.Serialization.BufferedDeserialization.TypeDiscriminators; using YamlDotNet.Serialization.Callbacks; using YamlDotNet.Serialization.Converters; using YamlDotNet.Serialization.EventEmitters; using YamlDotNet.Serialization.NamingConventions; using YamlDotNet.Serialization.NodeDeserializers; using YamlDotNet.Serialization.NodeTypeResolvers; using YamlDotNet.Serialization.ObjectFactories; using YamlDotNet.Serialization.ObjectGraphTraversalStrategies; using YamlDotNet.Serialization.ObjectGraphVisitors; using YamlDotNet.Serialization.Schemas; using YamlDotNet.Serialization.TypeInspectors; using YamlDotNet.Serialization.TypeResolvers; using YamlDotNet.Serialization.Utilities; using YamlDotNet.Serialization.ValueDeserializers; [assembly: Guid("1B195B18-312C-4840-BFC5-4E43812BEA37")] [assembly: ComVisible(false)] [assembly: AssemblyTrademark("")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyProduct("ReignOfKings")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyDescription("")] [assembly: AssemblyTitle("ReignOfKings")] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyFileVersion("1.0.5")] [assembly: AssemblyCompany("Radamanto")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.5.0")] [module: <397ad75a-c82f-430d-b6cb-50f8669ce07f>RefSafetyRules(11)] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<b9404f66-ca0a-48bb-8619-2c27d5b7bfb4>Embedded] internal sealed class <b9404f66-ca0a-48bb-8619-2c27d5b7bfb4>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [<b9404f66-ca0a-48bb-8619-2c27d5b7bfb4>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class <39afbf98-53f6-44cc-b627-6c0afcd56a78>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <39afbf98-53f6-44cc-b627-6c0afcd56a78>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <39afbf98-53f6-44cc-b627-6c0afcd56a78>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [<b9404f66-ca0a-48bb-8619-2c27d5b7bfb4>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class <2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContextAttribute : Attribute { public readonly byte Flag; public <2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContextAttribute(byte P_0) { Flag = P_0; } } [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] [<b9404f66-ca0a-48bb-8619-2c27d5b7bfb4>Embedded] [CompilerGenerated] internal sealed class <397ad75a-c82f-430d-b6cb-50f8669ce07f>RefSafetyRulesAttribute : Attribute { public readonly int Version; public <397ad75a-c82f-430d-b6cb-50f8669ce07f>RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ReignOfKings { [BepInDependency(/*Could not decode attribute arguments.*/)] [<39afbf98-53f6-44cc-b627-6c0afcd56a78>Nullable(0)] [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(1)] [BepInPlugin("radamanto.ReignOfKings", "ReignOfKings", "1.0.5")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class ReignOfKingsPlugin : BaseUnityPlugin { [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(0)] private sealed class ConfigurationManagerAttributes { public bool? Browsable = false; } internal const string ModGUID = "radamanto.ReignOfKings"; internal const string ModName = "ReignOfKings"; internal const string ModVersion = "1.0.5"; internal static ManualLogSource Log; private Harmony _harmony = null; internal static ConfigEntry<string> CE_Castle_Biomes; internal static ConfigEntry<float> CE_Castle_MinDistance; internal static ConfigEntry<float> CE_Castle_MaxDistance; internal static ConfigEntry<bool> CE_Area_ShowOnMap; internal static ConfigEntry<Color> CE_Area_MapColor; internal static ConfigEntry<float> CE_King_ClaimSeconds; internal static ConfigEntry<float> CE_King_MinReignMinutes; internal static ConfigEntry<float> CE_King_CooldownMinutes; internal static ConfigEntry<float> CE_King_AbsenceMinutes; internal static ConfigEntry<bool> CE_Dethrone_LeaveArea; internal static ConfigEntry<float> CE_Dethrone_LeaveAreaSeconds; internal static ConfigEntry<KingDeathMode> CE_Dethrone_Death; internal static ConfigEntry<bool> CE_Dethrone_DirectClaim; internal static ConfigEntry<float> CE_Dethrone_MaxReignMinutes; internal static ConfigEntry<string> CE_Tax_Items; internal static ConfigEntry<float> CE_Tax_MaxPercent; internal static ConfigEntry<bool> CE_Upkeep_Enabled; internal static ConfigEntry<string> CE_Upkeep_Cost; private static bool _configChanged; private const float ConfigReloadQuietSeconds = 0.75f; [<39afbf98-53f6-44cc-b627-6c0afcd56a78>Nullable(2)] internal static ConfigSync ConfigSync; [<39afbf98-53f6-44cc-b627-6c0afcd56a78>Nullable(2)] private static ConfigEntry<bool> _serverConfigLocked; [<39afbf98-53f6-44cc-b627-6c0afcd56a78>Nullable(2)] private FileSystemWatcher _configWatcher; private DateTime _lastCfgWriteUtc = DateTime.MinValue; private DateTime _ignoreEventsUntilUtc = DateTime.MinValue; private bool _reloadScheduled; private void Awake() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Localizer.Load(); bool syncReady = BeginConfigSetup(); SetupBinds(); EndConfigSetup(syncReady); CastleLocation.Register(); _harmony = new Harmony("radamanto.ReignOfKings"); _harmony.PatchAll(); if (!Application.isBatchMode) { RoKNet.LogRole(RoKNet.IsServer); } ((BaseUnityPlugin)this).Config.SettingChanged += [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(0)] (object _, SettingChangedEventArgs _) => { _configChanged = true; }; ((MonoBehaviour)this).InvokeRepeating("Tick", 2f, 2f); } private static void ApplyConfigChange() { _configChanged = false; if (RoKNet.IsServer && KingData.Loaded) { KingNetwork.BroadcastState(); RealmServer.BroadcastState(); HuntServer.BroadcastState(); DecreeServer.BroadcastState(); } TaxStatus.Refresh(); KingPerks.RefreshMajesty(); TreasuryMenu.Refresh(); RealmMenu.Refresh(); } private void Tick() { if (_configChanged) { ApplyConfigChange(); } KingServer.Tick(); KingUpkeep.Tick(); RealmServer.Tick(); TaxVault.Tick(); RoKGuilds.ServerTick(); HuntServer.Tick(); DecreeServer.Tick(); RealmClient.Tick(); TaxCollector.Tick(); RoKGuilds.ClientTick(); CastleMapArea.Verify(); KingPerks.Tick(); HuntClient.Tick(); DecreeClient.Tick(); } private void OnApplicationQuit() { WebhookDiscord.Stop(); } private void OnDestroy() { DisposeConfigWatcher(); WebhookDiscord.Stop(); RoKDatabase.Close(); } private void SetupBinds() { BindRealmButton(); BindBiomeLock(); BindGuilds(); BindCastle(); BindRoyalBuilding(); BindKing(); BindKingPerks(); BindDethrone(); BindTax(); BindUpkeep(); BindRealm(); BindHunt(); BindDecrees(); BindChronicle(); BindWebhooks(); BindBlessings(); } private void BindCastle() { //IL_009c: Unknown result type (might be due to invalid IL or missing references) CE_Castle_Biomes = Cfg("04 - Castle", "04.01 - Biomes", "Meadows", "Biomes where the castle can be generated. Comma-separated.\nAllowed values: Meadows, BlackForest, Swamp, Mountain, Plains, Mistlands, AshLands, DeepNorth"); CE_Castle_MinDistance = Cfg("04 - Castle", "04.02 - MinDistance", 1000f, "Minimum distance (meters) from the world center where the castle can be generated."); CE_Castle_MaxDistance = Cfg("04 - Castle", "04.03 - MaxDistance", 2000f, "Maximum distance (meters) from the world center where the castle can be generated."); CE_Area_ShowOnMap = Cfg("05 - Castle Area", "05.01 - ShowOnMap", defaultValue: true, "If true, the castle area and the royal lands are painted on the map and minimap (hidden under the fog until explored).\nThe castle area itself is fixed: 40 m radius, no building, indestructible pieces and protected world (no mining, chopping, breaking or picking)."); CE_Area_MapColor = Cfg<Color>("05 - Castle Area", "05.02 - MapColor", new Color(0.85f, 0.1f, 0.1f, 0.45f), "Color of the castle area on the map. The border is drawn solid; alpha controls the strength of the fill."); CE_Area_ShowOnMap.SettingChanged += [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(0)] (object _, EventArgs _) => { CastleMapArea.Repaint(); }; CE_Area_MapColor.SettingChanged += [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(0)] (object _, EventArgs _) => { CastleMapArea.Repaint(); }; } private void BindKing() { CE_King_ClaimSeconds = Cfg("07 - King", "07.01 - ClaimSeconds", 30f, "Seconds the claimant must stay seated on the throne. Taking damage or standing up cancels the claim."); CE_King_MinReignMinutes = Cfg("07 - King", "07.02 - MinReignMinutes", 60f, "Minimum reign (minutes). During it the king cannot be challenged to a duel, face a revolt or lose the throne to a direct claim.\nPlayers can only damage the king as the challenger of an active duel."); CE_King_CooldownMinutes = Cfg("07 - King", "07.03 - ExKingCooldownMinutes", 120f, "Minutes an ex-king must wait before claiming the throne again."); CE_King_AbsenceMinutes = Cfg("07 - King", "07.04 - AbsenceMinutes", 30f, "The king is dethroned after being offline longer than this (minutes). Always active."); } private void BindDethrone() { CE_Dethrone_LeaveArea = Cfg("08 - Dethrone", "08.01 - LeaveArea", defaultValue: false, "If true, the king is dethroned when leaving the royal lands (castle area + royal ring; only the 40 m castle area if Royal Building is disabled)."); CE_Dethrone_LeaveAreaSeconds = Cfg("08 - Dethrone", "08.02 - LeaveAreaToleranceSeconds", 10f, "Seconds the king can stay outside the royal lands before being dethroned. Not used during a duel (see 11.07 OutOfAreaSeconds)."); CE_Dethrone_Death = Cfg("08 - Dethrone", "08.03 - Death", KingDeathMode.None, "None = death never dethrones. PlayerOnly = only when killed by a player (players can only hurt the king in a duel, where nobody dies). Any = any death, including creatures and falls."); CE_Dethrone_DirectClaim = Cfg("08 - Dethrone", "08.04 - DirectClaim", defaultValue: false, "If true, players can claim the throne while there is a king (after the minimum reign). If false, only when the throne is vacant."); CE_Dethrone_MaxReignMinutes = Cfg("08 - Dethrone", "08.05 - MaxReignMinutes", 0f, "Maximum reign (minutes). 0 = disabled."); } private void BindTax() { CE_Tax_Items = Cfg("09 - Tax", "09.01 - TaxableItems", "CopperOre,TinOre,CopperScrap,IronScrap,IronOre,SilverOre,BlackMetalScrap,FlametalOreNew,FlametalOre,Wood,FineWood,RoundLog,ElderBark,YggdrasilWood,Blackwood,Coins,Stone,Flint,Resin,Obsidian,Crystal,Tar,Guck,Chitin,BoneFragments,Feathers,LeatherScraps,DeerHide,TrollHide,WolfPelt,LoxPelt,SurtlingCore,Amber,AmberPearl,Ruby", "Comma-separated item prefab names that are taxed at the source of the drop (mining, trees, destructibles, pickables, creatures)."); CE_Tax_MaxPercent = Cfg("09 - Tax", "09.02 - MaxPercent", 30f, "Maximum tax rate (percent)."); CE_Tax_MaxPercent.SettingChanged += [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(0)] (object _, EventArgs _) => { TaxStatus.Refresh(); }; } private void BindUpkeep() { CE_Upkeep_Enabled = Cfg("10 - Upkeep", "10.01 - Enabled", defaultValue: false, "If true, the castle upkeep is paid from the vault at the start of every in-game day. If the vault cannot pay, the king goes bankrupt and is dethroned."); CE_Upkeep_Cost = Cfg("10 - Upkeep", "10.02 - DailyCost", "Wood:100,Coins:50", "Daily upkeep paid from the vault. Format: Item:Amount,Item:Amount"); } private bool BeginConfigSetup() { //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown ((BaseUnityPlugin)this).Config.SaveOnConfigSet = false; try { ConfigSync = new ConfigSync(((BaseUnityPlugin)this).Info.Metadata.GUID) { DisplayName = ((BaseUnityPlugin)this).Info.Metadata.Name, CurrentVersion = ((BaseUnityPlugin)this).Info.Metadata.Version.ToString(), MinimumRequiredVersion = ((BaseUnityPlugin)this).Info.Metadata.Version.ToString(), ModRequired = true }; _serverConfigLocked = ((BaseUnityPlugin)this).Config.Bind<bool>("01 - General", "LockConfiguration", true, new ConfigDescription("If true, the server locks synchronized configs.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Browsable = false } })); ConfigSync.AddLockingConfigEntry<bool>(_serverConfigLocked); return true; } catch (Exception ex) { Log.LogError((object)("[ConfigSync] " + ex)); return false; } } private void EndConfigSetup(bool syncReady) { if (syncReady) { ((BaseUnityPlugin)this).Config.Save(); } ((BaseUnityPlugin)this).Config.SaveOnConfigSet = true; if (syncReady) { SetupConfigWatcher(); } } protected ConfigEntry<T> Cfg<[<39afbf98-53f6-44cc-b627-6c0afcd56a78>Nullable(2)] T>(string section, string key, T defaultValue, string description, bool synced = true) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown ConfigDescription val = new ConfigDescription(description + (synced ? " [Synced with Server]" : " [Not Synced with Server]"), (AcceptableValueBase)null, Array.Empty<object>()); ConfigEntry<T> val2 = ((BaseUnityPlugin)this).Config.Bind<T>(section, key, defaultValue, val); SyncedConfigEntry<T> syncedConfigEntry = ConfigSync?.AddConfigEntry<T>(val2); if (syncedConfigEntry != null) { syncedConfigEntry.SynchronizedConfig = synced; } return val2; } private void SetupConfigWatcher() { DisposeConfigWatcher(); try { _configWatcher = new FileSystemWatcher(Paths.ConfigPath, Path.GetFileName(((BaseUnityPlugin)this).Config.ConfigFilePath)) { IncludeSubdirectories = false, NotifyFilter = (NotifyFilters.FileName | NotifyFilters.Size | NotifyFilters.LastWrite | NotifyFilters.CreationTime), SynchronizingObject = ThreadingHelper.SynchronizingObject }; _configWatcher.Changed += OnConfigFileChanged; _configWatcher.Created += OnConfigFileChanged; _configWatcher.Renamed += OnConfigFileChanged; _configWatcher.EnableRaisingEvents = true; } catch (Exception ex) { Log.LogError((object)("[ConfigWatcher] " + ex)); _configWatcher = null; } } private void DisposeConfigWatcher() { if (_configWatcher != null) { _configWatcher.EnableRaisingEvents = false; _configWatcher.Dispose(); _configWatcher = null; } _reloadScheduled = false; } private void OnConfigFileChanged(object sender, FileSystemEventArgs e) { if (!(DateTime.UtcNow < _ignoreEventsUntilUtc)) { _lastCfgWriteUtc = DateTime.UtcNow; if (!_reloadScheduled) { _reloadScheduled = true; ((MonoBehaviour)this).StartCoroutine(ReloadConfigAfterQuietPeriod()); } } } private IEnumerator ReloadConfigAfterQuietPeriod() { while ((DateTime.UtcNow - _lastCfgWriteUtc).TotalSeconds < 0.75) { yield return null; } _reloadScheduled = false; FileSystemWatcher watcher = _configWatcher; if (watcher == null) { yield break; } watcher.EnableRaisingEvents = false; try { ((BaseUnityPlugin)this).Config.Reload(); _ignoreEventsUntilUtc = DateTime.UtcNow.AddSeconds(1.0); } catch (Exception ex) { Log.LogError((object)("[ConfigReload] " + ex)); } finally { if (_configWatcher == watcher) { watcher.EnableRaisingEvents = true; } } } private void BindRoyalBuilding() { RoyalBuilding.CE_Enabled = Cfg("06 - Royal Building", "06.01 - Enabled", defaultValue: true, "If true, a royal ring is reserved around the castle area. Only the king (and optionally his guild) can build there. The castle area itself never allows building. Royal pieces use the vanilla durability and can be damaged normally."); RoyalBuilding.CE_RingWidth = Cfg("06 - Royal Building", "06.02 - RingWidth", 40f, "Width (meters) of the royal lands: a ring around the castle area where only the royal builders can build.\nThe castle area is fixed at 40 m from the castle center and never allows building, so the ring always starts at 40 m.\nExample: 40 = royal lands from 40 m to 80 m from the castle center."); RoyalBuilding.CE_RemoveOnDethrone = Cfg("06 - Royal Building", "06.03 - RemoveOnDethrone", defaultValue: true, "If true, every royal piece is removed (without refund, container contents included) when the king loses the throne for any reason."); RoyalBuilding.CE_Builders = Cfg("06 - Royal Building", "06.04 - Builders", RoyalBuilders.Guild, "King = only the king can build and remove royal pieces.\nGuild = the king and the members of his guild (requires the Guilds mod)."); RoyalBuilding.CE_BlockWards = Cfg("06 - Royal Building", "06.05 - BlockWards", defaultValue: true, "If true, wards of any kind cannot be built in the royal ring, nor outside close enough for their protection radius to reach the castle area or the royal ring. Applies to every player."); RoyalBuilding.CE_BlockBeds = Cfg("06 - Royal Building", "06.06 - BlockBeds", defaultValue: true, "If true, beds cannot be built in the royal ring."); RoyalBuilding.CE_AllowGathering = Cfg("06 - Royal Building", "06.08 - AllowGathering", defaultValue: true, "If true, the royal builders can chop trees, mine, break destructibles and pick pickables inside the protected castle area. Terrain changes stay blocked."); RoyalBuilding.CE_Enabled.SettingChanged += [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(0)] (object _, EventArgs _) => { CastleMapArea.Repaint(); }; RoyalBuilding.CE_RingWidth.SettingChanged += [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(0)] (object _, EventArgs _) => { CastleMapArea.Repaint(); }; } private void BindBiomeLock() { RoKBiomeLock.CE_Enabled = Cfg("02 - BiomeLock", "02.01 - Enabled", defaultValue: true, "If true and the BiomeLock mod is installed, ores and bars of biomes not yet unlocked cannot be withdrawn from the Royal Treasury."); RoKBiomeLock.CE_Enabled.SettingChanged += [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(0)] (object _, EventArgs _) => { TreasuryMenu.Refresh(); }; } private void BindGuilds() { RoKGuilds.CE_Enabled = Cfg("03 - Guilds", "03.01 - Enabled", defaultValue: true, "If true and the Guilds mod is installed, the king's guild gets the benefits and limits below."); RoKGuilds.CE_TaxPercent = Cfg("03 - Guilds", "03.02 - KingGuildTaxPercent", 50f, "Percent of the king's tax rate paid by members of the king's guild. 0 = exempt, 100 = full tax."); RoKGuilds.CE_TaxPercent.SettingChanged += [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(0)] (object _, EventArgs _) => { TaxStatus.Refresh(); }; RoKGuilds.CE_RevoltExclude = Cfg("03 - Guilds", "03.03 - RevoltExcludesKingGuild", defaultValue: true, "If true, members of the king's guild cannot vote in a revolt and do not count towards the votes needed."); RoKGuilds.CE_BlockChallenges = Cfg("03 - Guilds", "03.04 - BlockKingGuildChallenges", defaultValue: true, "If true, members of the king's guild cannot challenge the king to a duel nor claim the throne while he reigns."); RoKGuilds.CE_OfficerDeposit = Cfg("03 - Guilds", "03.05 - OfficerDeposit", defaultValue: true, "If true, officers (and higher ranks) of the king's guild can open the Royal Treasury to deposit resources."); RoKGuilds.CE_OfficerWithdraw = Cfg("03 - Guilds", "03.06 - OfficerWithdraw", defaultValue: false, "If true, officers (and higher ranks) of the king's guild can withdraw resources from the Royal Treasury."); RoKGuilds.CE_Achievements = Cfg("03 - Guilds", "03.07 - Achievements", defaultValue: true, "If true, Reign of Kings achievements progress for the guilds (crowned, reign hours, duels, taxes)."); } private void BindDecrees() { DecreeRules.CE_DropBonusEnabled = Cfg("14 - Decrees", "14.01 - DropBonusEnabled", defaultValue: true, "If true, the king can decree drop bonuses configured in Configs/Decrees/DropBonus/*.cfg."); BindTimedDecree(DecreeRules.Peace, 3, "If true, the king can decree the King's Peace: PvP is forced off for every player, the king's guild included. Royal duels are not affected."); BindTimedDecree(DecreeRules.Harvest, 7, "If true, the king can decree a Bountiful Harvest: crops and pickables (berries, mushrooms, thistle...) of every player grow faster."); BindTimedDecree(DecreeRules.Weather, 12, "If true, the king can decree weather variations and Mistlands mist removal. Swamp weather and native event overrides are preserved."); } private void BindTimedDecree(TimedDecree decree, int first, string description) { decree.CE_Enabled = Cfg("14 - Decrees", Key(0, "Enabled"), defaultValue: true, description + " Variations: Configs/Decrees/" + decree.FolderName + "/*.cfg."); string Key(int offset, string name) { return "14." + (first + offset).ToString("00") + " - " + decree.Id.Substring(0, 1).ToUpperInvariant() + decree.Id.Substring(1) + name; } } private void BindHunt() { HuntRules.CE_Enabled = Cfg("13 - Treasure Hunt", "13.01 - Enabled", defaultValue: true, "If true, the king can launch royal treasure hunts from the Royal Treasury."); HuntRules.CE_AreaRadius = Cfg("13 - Treasure Hunt", "13.06 - AreaRadius", 150f, "Radius (meters) of the search area shown on the map, clamped between 60 and 300. The treasure is somewhere inside it, never at the center."); HuntRules.CE_Biomes = Cfg("13 - Treasure Hunt", "13.08 - Biomes", "Meadows,BlackForest,Swamp,Mountain,Plains,Mistlands", "Biomes the king can choose for a hunt. The treasure can be placed anywhere in the world where the chosen biome is. Comma-separated.\nAllowed values: Meadows, BlackForest, Swamp, Mountain, Plains, Mistlands, AshLands, DeepNorth"); HuntRules.CE_KingGuildCanWin = Cfg("13 - Treasure Hunt", "13.09 - KingGuildCanWin", defaultValue: true, "If true, members of the king's guild can open the treasure chest. The king himself never can."); } private void BindChronicle() { ChronicleRules.CE_Enabled = Cfg("15 - Chronicle", "15.01 - Enabled", defaultValue: true, "If true, every reign is recorded in the Chronicle of Kings (Realm window and Royal Treasury). Reigns started by an admin are not recorded."); } private void BindKingPerks() { KingPerks.CE_Majesty = Cfg("07 - King", "07.05 - Majesty", defaultValue: true, "If true, the king gets the Majesty status effect while he reigns (removed when he loses the throne). It works anywhere, except during a duel."); KingPerks.CE_MajestyHealthRegen = Cfg("07 - King", "07.06 - MajestyHealthRegenPercent", 15f, "Health regeneration bonus (percent) of the Majesty."); KingPerks.CE_MajestyStaminaRegen = Cfg("07 - King", "07.07 - MajestyStaminaRegenPercent", 15f, "Stamina regeneration bonus (percent) of the Majesty."); KingPerks.CE_ThroneRested = Cfg("07 - King", "07.08 - ThroneRested", defaultValue: true, "If true, the king gets the vanilla Rested effect while seated on the throne. Nobody else gets it."); KingPerks.CE_ThroneRestedMinutes = Cfg("07 - King", "07.09 - ThroneRestedMinutes", 10f, "Duration (minutes) of the Rested effect after the king stands up from the throne."); KingPerks.CE_Title = Cfg("07 - King", "07.10 - KingTitle", defaultValue: true, "If true, other players see the king's name as \"King <name>\" above his head, on his hover text and on the map."); KingPerks.CE_Aura = Cfg("07 - King", "07.11 - RoyalAura", defaultValue: true, "If true, members of the king's guild near the king get the Royal Aura status effect (requires the Guilds mod). The king himself does not get it."); KingPerks.CE_AuraRadius = Cfg("07 - King", "07.12 - RoyalAuraRadius", 20f, "Distance (meters) from the king where his guild members get the Royal Aura."); KingPerks.CE_AuraHealthRegen = Cfg("07 - King", "07.13 - RoyalAuraHealthRegenPercent", 5f, "Health regeneration bonus (percent) of the Royal Aura."); KingPerks.CE_AuraStaminaRegen = Cfg("07 - King", "07.14 - RoyalAuraStaminaRegenPercent", 5f, "Stamina regeneration bonus (percent) of the Royal Aura."); } private void BindRealm() { RealmRules.CE_Duel_Enabled = Cfg("11 - Duel", "11.01 - Enabled", defaultValue: true, "If true, players can challenge the king to a duel."); RealmRules.CE_Duel_ArrivalSeconds = Cfg("11 - Duel", "11.02 - KingArrivalSeconds", 120f, "Seconds both duelists have to enter the royal lands after the challenge. If the challenger does not arrive, the king wins; if only the king does not arrive, he loses the throne (walkover)."); RealmRules.CE_Duel_DurationSeconds = Cfg("11 - Duel", "11.03 - DurationSeconds", 300f, "Maximum duel duration. If nobody dies in time, the king keeps the throne."); RealmRules.CE_Duel_LoserCooldownMinutes = Cfg("11 - Duel", "11.04 - LoserCooldownMinutes", 60f, "Minutes a defeated challenger must wait to challenge again."); RealmRules.CE_Duel_GlobalCooldownMinutes = Cfg("11 - Duel", "11.05 - GlobalCooldownMinutes", 30f, "Minutes after any duel before a new duel can be requested by anyone."); RealmRules.CE_Duel_Fee = Cfg("11 - Duel", "11.06 - EntryFee", "Coins:200", "Entry fee paid by the challenger from the inventory to the royal vault. Format: Item:Amount,Item:Amount. Empty = free."); RealmRules.CE_Duel_OutOfAreaSeconds = Cfg("11 - Duel", "11.07 - OutOfAreaSeconds", 10f, "Seconds a duelist (king or challenger) can stay outside the royal lands during the duel. Not returning in time loses the duel."); RealmRules.CE_Revolt_Enabled = Cfg("12 - Revolt", "12.01 - Enabled", defaultValue: true, "If true, players can start a revolt vote to dethrone the king."); RealmRules.CE_Revolt_VotePercent = Cfg("12 - Revolt", "12.02 - VotePercent", 60f, "Percent of the online players (king excluded) that must support the revolt."); RealmRules.CE_Revolt_MinPlayers = Cfg("12 - Revolt", "12.03 - MinPlayers", 5, "Minimum online players (king included) required to start a revolt."); RealmRules.CE_Revolt_DurationMinutes = Cfg("12 - Revolt", "12.04 - DurationMinutes", 10f, "Minutes the revolt vote stays open."); RealmRules.CE_Revolt_CooldownMinutes = Cfg("12 - Revolt", "12.05 - CooldownMinutes", 60f, "Minutes after a revolt ends before a new one can start."); } private void BindBlessings() { int num = 1; foreach (TreasuryBlessingDef def in TreasuryBlessings.Defs) { def.Enabled = Cfg("17 - Blessings", "17." + num.ToString("00") + " - " + def.Id + "Enabled", defaultValue: true, "If true, the king can grant variations with Type = " + def.Id + " configured in Configs/Blessings/*.cfg to every online player."); num++; } } private static bool UiBlocking() { return InventoryGui.IsVisible() || Menu.IsVisible() || Console.IsVisible(); } private void OnGUI() { if (KingClient.ClaimAccepted && !UiBlocking()) { DrawClaimBar(KingClient.ClaimProgress); } } private static void DrawClaimBar(float progress) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_019f: 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_00a6: 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_00f2: 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_0126: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0160: 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_018b: Unknown result type (might be due to invalid IL or missing references) float num = (float)Screen.height / 1080f; float num2 = 260f * num; float num3 = 8f * num; float num4 = ((float)Screen.width - num2) / 2f; float num5 = (float)Screen.height / 2f + 42f * num; Color color = GUI.color; try { float num6 = Mathf.Max(1f, 2f * num); GUI.color = new Color(0f, 0f, 0f, 0.85f); GUI.DrawTexture(new Rect(num4 - num6 * 2f, num5 - num6 * 2f, num2 + num6 * 4f, num3 + num6 * 4f), (Texture)(object)Texture2D.whiteTexture); GUI.color = new Color(0.85f, 0.85f, 0.85f, 0.9f); GUI.DrawTexture(new Rect(num4 - num6, num5 - num6, num2 + num6 * 2f, num3 + num6 * 2f), (Texture)(object)Texture2D.whiteTexture); GUI.color = new Color(0.12f, 0.12f, 0.12f, 0.9f); GUI.DrawTexture(new Rect(num4, num5, num2, num3), (Texture)(object)Texture2D.whiteTexture); float num7 = num2 * progress; GUI.color = new Color(0.92f, 0.92f, 0.92f, 1f); GUI.DrawTexture(new Rect(num4, num5, num7, num3), (Texture)(object)Texture2D.whiteTexture); GUI.color = Color.white; GUI.DrawTexture(new Rect(num4, num5, num7, Mathf.Max(1f, num)), (Texture)(object)Texture2D.whiteTexture); } finally { GUI.color = color; } } private void BindRealmButton() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) RealmButton.CE_Position = Cfg<Vector2>("01 - General", "01.01 - RealmButtonPosition", RealmButton.DefaultPosition, "Position of the Realm button on the screen (pixels from the left edge, vertical offset from the center).\nChanged in game with Ctrl + click and drag while the cursor is free. Local to each player.", synced: false); RealmButton.CE_Position.SettingChanged += [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(0)] (object _, EventArgs _) => { RealmButton.ApplyPosition(); }; } private void BindWebhooks() { WebhookRules.CE_Enabled = Cfg("16 - Webhooks", "16.01 - Enabled", defaultValue: false, "Send realm events to Discord. Configure links, messages and titles in ReignOfKings/DiscordWebhooks/webhooks.cfg. Server only.", synced: false); } } [<39afbf98-53f6-44cc-b627-6c0afcd56a78>Nullable(0)] [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(1)] internal static class AdminCommands { internal const string RpcAdmin = "RoK_Admin"; internal static void Register(ZRpc rpc) { rpc.Register<ZPackage>("RoK_Admin", (Action<ZRpc, ZPackage>)([<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(0)] (ZRpc r, [<39afbf98-53f6-44cc-b627-6c0afcd56a78>Nullable(1)] ZPackage pkg) => { KingRequester kingRequester = KingServer.FromRpc(r); if (kingRequester != null) { Handle(kingRequester, CastleNetwork.IsAdmin(r), pkg); } })); } internal static void Send(ConsoleEventArgs args) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown ZNet instance = ZNet.instance; if ((Object)(object)instance == (Object)null) { CastleCommand.Print("$rok_cmd_noworld"); return; } ZPackage val = new ZPackage(); val.Write(args.Args.Length); string[] args2 = args.Args; foreach (string text in args2) { val.Write(text); } if (instance.IsServer()) { val.SetPos(0); KingRequester kingRequester = KingServer.Local(); if (kingRequester != null) { Handle(kingRequester, isAdmin: true, val); } } else { ZRpc serverRPC = instance.GetServerRPC(); if (serverRPC != null) { serverRPC.Invoke("RoK_Admin", new object[1] { val }); } } } private static void Handle(KingRequester q, bool isAdmin, ZPackage pkg) { int num = pkg.ReadInt(); if (num <= 0 || num > 16) { return; } string[] array = new string[num]; for (int i = 0; i < num; i++) { array[i] = pkg.ReadString(); } if (!isAdmin) { q.Message("$rok_cmd_notadmin"); } else if (TaxVault.EnsureLoaded()) { switch (array[0]) { case "rokrealmstatus": Status(q); break; case "rokkingset": SetKing(q, array); break; case "rokvaultedit": Vault(q, array); break; case "rokeventcancel": Cancel(q, array); break; case "rokcooldownsclear": ClearCooldowns(q, array); break; case "roktaxset": SetTax(q, array); break; case "rokcooldownreset": ResetCooldowns(q, array); break; case "rokchronicleedit": ChronicleServer.Admin(q, array); break; case "rokroyalclear": RoyalClear(q, array); break; case "roktreasurestart": HuntStart(q, array); break; case "roktreasurecancel": HuntCancel(q); break; case "rokchronicleclear": q.Message("$rok_cmd_chronicle_cleared", ChronicleServer.Clear().ToString()); break; } } } private static void RoyalClear(KingRequester q, string[] args) { if (args.Length <= 1 || !string.Equals(args[1], "confirm", StringComparison.OrdinalIgnoreCase)) { q.Message("$rok_cmd_royalclear_preview", RoyalBuilding.ServerRoyalPieces().Count.ToString()); } else { q.Message("$rok_cmd_royalclear_done", RoyalBuilding.ServerClearRoyalPieces().ToString()); } } private static void HuntStart(KingRequester q, string[] args) { //IL_0060: 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) List<Biome> biomes = HuntRules.Biomes; List<HuntPrize> all = HuntPrizes.All; if (biomes.Count == 0 || all.Count == 0) { q.Message((biomes.Count == 0) ? "$rok_hunt_nobiomes" : "$rok_hunt_noprizes"); return; } string biomeName = ((args.Length > 1) ? args[1] : ((object)biomes[Random.Range(0, biomes.Count)]/*cast due to .constrained prefix*/).ToString()); int prizeIndex = Random.Range(0, all.Count); if (args.Length > 2) { string name = Join(args, 2); prizeIndex = (int.TryParse(name, out var result) ? (result - 1) : all.FindIndex((HuntPrize p) => string.Equals(p.Name, name, StringComparison.OrdinalIgnoreCase))); } if (HuntServer.Launch(q, biomeName, prizeIndex, free: true)) { q.Message("$rok_cmd_hunt_started"); } } private static void HuntCancel(KingRequester q) { if (!HuntServer.Cancel()) { q.Message("$rok_cmd_hunt_none"); } } private static string Join(string[] args, int start) { return string.Join(" ", args, start, Math.Max(0, args.Length - start)); } private static void Status(KingRequester q) { //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) if (KingData.HasKing) { KingSaveData current = KingData.Current; q.Message("$rok_status_king", current.KingName, current.KingId); q.Message("$rok_status_reign", RoKTime.Minutes(KingData.ReignSeconds), RoKTime.Minutes((double)KingRules.MinReignSeconds - KingData.ReignSeconds)); q.Message("$rok_status_tax", TaxRules.ServerPercent.ToString("0"), TaxRules.MaxPercent.ToString("0")); } else { q.Message("$rok_status_noking"); } foreach (KeyValuePair<string, float> item in TaxVault.ActiveBonusesRemaining()) { q.Message("$rok_status_bonus", TreasuryBlessings.EffectDisplayName(item.Key), RoKTime.Minutes(item.Value)); } if (KingServer.ClaimantName.Length > 0) { q.Message("$rok_status_claim", KingServer.ClaimantName); } if (RealmServer.Phase != DuelPhase.None) { q.Message("$rok_status_duel", RealmServer.ChallengerName, (RealmServer.Phase == DuelPhase.Active) ? "$rok_duel_phase_active" : "$rok_duel_phase_pending"); } if (RealmServer.RevoltActive) { q.Message("$rok_status_revolt"); } q.Message("$rok_status_vault", TaxVault.Current.Items.Count.ToString()); q.Message("$rok_status_cooldowns", KingData.Current.CooldownUntilTicks.Count.ToString()); q.Message(CastleState.HasCastle ? "$rok_status_castle" : "$rok_status_nocastle", CastleState.Position.x.ToString("0"), CastleState.Position.z.ToString("0")); } private static void SetKing(KingRequester q, string[] args) { if (args.Length < 2) { q.Message("$rok_cmd_usage_setking"); return; } string text = Join(args, 1); KingRequester kingRequester = KingServer.FindOnlineByName(text); if (kingRequester == null) { q.Message("$rok_cmd_playernotfound", text); return; } KingServer.CancelActiveClaim(); KingServer.Crown(kingRequester.Id, kingRequester.Name, admin: true); q.Message("$rok_cmd_setking_done", kingRequester.Name); } private static void Vault(KingRequester q, string[] args) { if (args.Length == 1) { if (TaxVault.Current.Items.Count == 0) { q.Message("$rok_treasury_vault_empty"); return; } { foreach (KeyValuePair<string, long> item in TaxVault.Current.Items) { q.Message("$rok_cmd_vault_line", item.Key, item.Value.ToString()); } return; } } if (args.Length >= 2 && string.Equals(args[1], "clear", StringComparison.OrdinalIgnoreCase)) { if (args.Length != 3 || !string.Equals(args[2], "confirm", StringComparison.OrdinalIgnoreCase)) { q.Message("$rok_cmd_usage_vault"); return; } foreach (string item2 in new List<string>(TaxVault.Current.Items.Keys)) { TaxVault.Take(item2, TaxVault.Amount(item2)); } TaxVault.Save(); TreasuryServer.BroadcastData(); q.Message("$rok_cmd_vault_cleared"); return; } if (args.Length != 4 || !int.TryParse(args[3], out var result) || result < 0 || (result == 0 && !string.Equals(args[1], "set", StringComparison.OrdinalIgnoreCase))) { q.Message("$rok_cmd_usage_vault"); return; } string text = args[2]; if ((Object)(object)ObjectDB.instance != (Object)null && (Object)(object)ObjectDB.instance.GetItemPrefab(text) == (Object)null) { q.Message("$rok_cmd_itemnotfound", text); return; } switch (args[1].ToLowerInvariant()) { case "set": TaxVault.Take(text, TaxVault.Amount(text)); if (result > 0) { TaxVault.Add(text, result); } break; case "add": TaxVault.Add(text, result); break; case "remove": TaxVault.Take(text, Math.Min(result, TaxVault.Amount(text))); break; default: q.Message("$rok_cmd_usage_vault"); return; } TaxVault.Save(); TreasuryServer.BroadcastData(); q.Message("$rok_cmd_vault_line", text, TaxVault.Amount(text).ToString()); } private static void SetTax(KingRequester q, string[] args) { if (args.Length != 2 || !float.TryParse(args[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result) || float.IsNaN(result) || float.IsInfinity(result) || result < 0f) { q.Message("$rok_cmd_usage_tax"); return; } if (!KingData.HasKing) { q.Message("$rok_cmd_noking"); return; } TreasuryServer.SetTax(q, result); TreasuryServer.BroadcastData(); q.Message("$rok_cmd_tax_done", TaxRules.ServerPercent.ToString("0")); } private static void Cancel(KingRequester q, string[] args) { string text = ((args.Length == 1) ? "all" : args[1].ToLowerInvariant()); if (args.Length > 2 || (text != "all" && text != "claim" && text != "duel" && text != "revolt")) { q.Message("$rok_cmd_usage_cancel"); return; } bool flag = false; if (text == "all" || text == "claim") { flag |= KingServer.CancelActiveClaim(); } switch (text) { case "all": flag |= RealmServer.CancelAll(); break; case "duel": flag |= RealmServer.CancelDuel(); break; case "revolt": flag |= RealmServer.CancelRevolt(); break; } q.Message(flag ? "$rok_cmd_cancel_done" : "$rok_cmd_cancel_none"); } private static void ResetCooldowns(KingRequester q, string[] args) { string text = ((args.Length > 1) ? args[1].ToLowerInvariant() : ""); if ((text != "all" && text != "crown" && text != "duel" && text != "revolt") || (args.Length > 2 && text != "crown" && text != "duel")) { q.Message("$rok_cmd_usage_realmcooldowns"); return; } string text2 = ((args.Length > 2) ? Join(args, 2) : ""); string text3 = ((text2.Length <= 0) ? "" : (KingServer.FindOnlineByName(text2)?.Id ?? KingServer.NormalizeId(text2))); KingSaveData current = KingData.Current; if (text == "all" || text == "crown") { if (text3.Length > 0) { current.CooldownUntilTicks.Remove(text3); } else { current.CooldownUntilTicks.Clear(); } } if (text == "all" || text == "duel") { if (text3.Length > 0) { current.DuelCooldownUntilTicks.Remove(text3); } else { current.DuelCooldownUntilTicks.Clear(); current.NextDuelTicks = 0L; } } if (text == "all" || text == "revolt") { current.NextRevoltTicks = 0L; } KingData.Save(); KingNetwork.BroadcastState(); RealmServer.RefreshCooldowns(); q.Message("$rok_cmd_realmcooldowns_done", text, (text2.Length > 0) ? text2 : "all"); } private static void ClearCooldowns(KingRequester q, string[] args) { Dictionary<string, long> cooldownUntilTicks = KingData.Current.CooldownUntilTicks; if (args.Length == 1) { int count = cooldownUntilTicks.Count; cooldownUntilTicks.Clear(); KingData.Save(); KingNetwork.BroadcastState(); q.Message("$rok_cmd_cooldowns_cleared", count.ToString()); return; } string text = Join(args, 1); KingRequester kingRequester = KingServer.FindOnlineByName(text); string key = ((kingRequester != null) ? kingRequester.Id : KingServer.NormalizeId(text)); if (!cooldownUntilTicks.Remove(key)) { q.Message("$rok_cmd_cooldown_none", text); return; } KingData.Save(); KingNetwork.BroadcastState(); q.Message("$rok_cmd_cooldown_cleared", text); } } [HarmonyPatch(typeof(Terminal), "InitTerminal")] internal static class Terminal_InitTerminal_Admin { [CompilerGenerated] private static class <>O { public static ConsoleEvent <0>__Send; } private static void Postfix() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0079: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_00ae: Expected O, but got Unknown //IL_00f7: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown //IL_0136: 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_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Expected O, but got Unknown //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Expected O, but got Unknown //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Expected O, but got Unknown //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Expected O, but got Unknown //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Expected O, but got Unknown //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Expected O, but got Unknown //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Expected O, but got Unknown //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Expected O, but got Unknown string text = RoKMessages.Localize("$rok_cmd_desc_status"); object obj = <>O.<0>__Send; if (obj == null) { ConsoleEvent val = AdminCommands.Send; <>O.<0>__Send = val; obj = (object)val; } new ConsoleCommand("rokrealmstatus", text, (ConsoleEvent)obj, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); string text2 = RoKMessages.Localize("$rok_cmd_desc_setking"); object obj2 = <>O.<0>__Send; if (obj2 == null) { ConsoleEvent val2 = AdminCommands.Send; <>O.<0>__Send = val2; obj2 = (object)val2; } new ConsoleCommand("rokkingset", text2, (ConsoleEvent)obj2, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); string text3 = RoKMessages.Localize("$rok_cmd_desc_vault"); object obj3 = <>O.<0>__Send; if (obj3 == null) { ConsoleEvent val3 = AdminCommands.Send; <>O.<0>__Send = val3; obj3 = (object)val3; } new ConsoleCommand("rokvaultedit", text3, (ConsoleEvent)obj3, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); string text4 = RoKMessages.Localize("$rok_cmd_desc_cancel"); object obj4 = <>O.<0>__Send; if (obj4 == null) { ConsoleEvent val4 = AdminCommands.Send; <>O.<0>__Send = val4; obj4 = (object)val4; } new ConsoleCommand("rokeventcancel", text4, (ConsoleEvent)obj4, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); string text5 = RoKMessages.Localize("$rok_cmd_desc_clearcooldowns"); object obj5 = <>O.<0>__Send; if (obj5 == null) { ConsoleEvent val5 = AdminCommands.Send; <>O.<0>__Send = val5; obj5 = (object)val5; } new ConsoleCommand("rokcooldownsclear", text5, (ConsoleEvent)obj5, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); string text6 = RoKMessages.Localize("$rok_cmd_desc_taxset"); object obj6 = <>O.<0>__Send; if (obj6 == null) { ConsoleEvent val6 = AdminCommands.Send; <>O.<0>__Send = val6; obj6 = (object)val6; } new ConsoleCommand("roktaxset", text6, (ConsoleEvent)obj6, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); string text7 = RoKMessages.Localize("$rok_cmd_desc_realmcooldowns"); object obj7 = <>O.<0>__Send; if (obj7 == null) { ConsoleEvent val7 = AdminCommands.Send; <>O.<0>__Send = val7; obj7 = (object)val7; } new ConsoleCommand("rokcooldownreset", text7, (ConsoleEvent)obj7, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); string text8 = RoKMessages.Localize("$rok_cmd_desc_chronicleedit"); object obj8 = <>O.<0>__Send; if (obj8 == null) { ConsoleEvent val8 = AdminCommands.Send; <>O.<0>__Send = val8; obj8 = (object)val8; } new ConsoleCommand("rokchronicleedit", text8, (ConsoleEvent)obj8, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); string text9 = RoKMessages.Localize("$rok_cmd_desc_royalclear"); object obj9 = <>O.<0>__Send; if (obj9 == null) { ConsoleEvent val9 = AdminCommands.Send; <>O.<0>__Send = val9; obj9 = (object)val9; } new ConsoleCommand("rokroyalclear", text9, (ConsoleEvent)obj9, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); string text10 = RoKMessages.Localize("$rok_cmd_desc_huntstart"); object obj10 = <>O.<0>__Send; if (obj10 == null) { ConsoleEvent val10 = AdminCommands.Send; <>O.<0>__Send = val10; obj10 = (object)val10; } new ConsoleCommand("roktreasurestart", text10, (ConsoleEvent)obj10, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); string text11 = RoKMessages.Localize("$rok_cmd_desc_huntcancel"); object obj11 = <>O.<0>__Send; if (obj11 == null) { ConsoleEvent val11 = AdminCommands.Send; <>O.<0>__Send = val11; obj11 = (object)val11; } new ConsoleCommand("roktreasurecancel", text11, (ConsoleEvent)obj11, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); string text12 = RoKMessages.Localize("$rok_cmd_desc_chronicleclear"); object obj12 = <>O.<0>__Send; if (obj12 == null) { ConsoleEvent val12 = AdminCommands.Send; <>O.<0>__Send = val12; obj12 = (object)val12; } new ConsoleCommand("rokchronicleclear", text12, (ConsoleEvent)obj12, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } } [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(1)] [<39afbf98-53f6-44cc-b627-6c0afcd56a78>Nullable(0)] internal static class CastleCommand { internal const string CommandName = "rokcastleplace"; private static bool _generating; internal static void Print(string key, params string[] args) { RoKMessages.Show((MessageType)1, key, args); } internal static void Run(ConsoleEventArgs args) { //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Expected O, but got Unknown ZNet instance = ZNet.instance; if ((Object)(object)instance == (Object)null) { Print("$rok_cmd_noworld"); return; } bool flag = false; List<float> list = new List<float>(); for (int i = 1; i < args.Length; i++) { string text = args[i]; if (string.Equals(text, "force", StringComparison.OrdinalIgnoreCase)) { flag = true; continue; } if (float.TryParse(text, NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { list.Add(result); continue; } Print("$rok_cmd_usage"); return; } if (list.Count != 0 && list.Count != 2) { Print("$rok_cmd_usage"); return; } bool flag2 = list.Count == 2; float num = (flag2 ? list[0] : 0f); float num2 = (flag2 ? list[1] : 0f); if (instance.IsServer()) { Execute(flag, flag2, num, num2, Print); return; } ZRpc serverRPC = instance.GetServerRPC(); if (serverRPC == null) { Print("$rok_cmd_noworld"); return; } ZPackage val = new ZPackage(); val.Write(flag); val.Write(flag2); val.Write(num); val.Write(num2); serverRPC.Invoke("RoK_CastleCommand", new object[1] { val }); } internal static void RPC_Command(ZRpc rpc, ZPackage pkg) { if (!CastleNetwork.IsAdmin(rpc)) { Reply("$rok_cmd_notadmin", Array.Empty<string>()); return; } bool force = pkg.ReadBool(); bool hasPosition = pkg.ReadBool(); float x = pkg.ReadSingle(); float z = pkg.ReadSingle(); Execute(force, hasPosition, x, z, Reply); void Reply(string key, params string[] args) { ReignOfKingsPlugin.Log.LogInfo((object)("[Castle] " + key + " " + string.Join(" ", args))); RoKMessages.Tell(rpc, key, args); } } private static void Execute(bool force, bool hasPosition, float x, float z, Notify reply) { //IL_00e7: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) ZoneSystem instance = ZoneSystem.instance; if ((Object)(object)instance == (Object)null) { reply("$rok_cmd_noworld"); return; } if (_generating) { reply("$rok_cmd_busy"); return; } ZoneLocation location = instance.GetLocation("RDR_Location_ReignOfKings"); if (location == null || !location.m_prefab.IsValid) { reply("$rok_cmd_missing"); return; } CastleLocation.ApplyConfig(location); Vector2s zone; LocationInstance instance2; bool flag = CastleState.TryFind(out zone, out instance2); if (flag && !force) { reply("$rok_cmd_exists", FormatPosition(instance2.m_position)); } else if (hasPosition) { if (PlaceAt(instance, location, new Vector3(x, 0f, z), reply) && flag) { Remove(instance, zone, instance2); reply("$rok_cmd_removed"); } } else { ((MonoBehaviour)instance).StartCoroutine(GenerateRandom(instance, location, reply)); } } private static void Remove(ZoneSystem zoneSystem, Vector2s zone, LocationInstance instance) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) zoneSystem.m_locationInstances.Remove(zone); foreach (List<LocationInstance> value in zoneSystem.m_locationIDCache.Values) { value.Remove(instance); } foreach (List<LocationInstance> value2 in zoneSystem.m_locationGroupCache.Values) { value2.Remove(instance); } foreach (List<LocationInstance> value3 in zoneSystem.m_locationMaxGroupCache.Values) { value3.Remove(instance); } if (instance.m_placed) { float num = Mathf.Max(instance.m_location.m_exteriorRadius, instance.m_location.m_interiorRadius); List<ZDO> list = new List<ZDO>(); int num2 = 0; while (!ZDOMan.instance.GetAllZDOsWithPrefabIterative(((Object)zoneSystem.m_locationProxyPrefab).name, list, ref num2)) { } foreach (ZDO item in list) { if (item.GetInt(ZDOVars.s_location, 0) == CastleLocation.PrefabHash && !(Utils.DistanceXZ(item.GetPosition(), instance.m_position) > num)) { item.SetOwner(ZDOMan.GetSessionID()); ZDOMan.instance.DestroyZDO(item); } } zoneSystem.SendLocationIcons(0L); } CastleState.ServerRefresh(); } private static bool PlaceAt(ZoneSystem zoneSystem, ZoneLocation location, Vector3 pos, Notify reply) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0061: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) Vector2s zone = ZoneSystem.GetZone(pos); if (zoneSystem.m_locationInstances.ContainsKey(zone)) { reply("$rok_cmd_zonetaken"); return false; } float num = Mathf.Max(location.m_exteriorRadius, location.m_interiorRadius); Vector3 zonePos = ZoneSystem.GetZonePos(zone); pos.x = Mathf.Clamp(pos.x, zonePos.x - 32f + num, zonePos.x + 32f - num); pos.z = Mathf.Clamp(pos.z, zonePos.z - 32f + num, zonePos.z + 32f - num); pos.y = WorldGenerator.instance.GetHeight(pos.x, pos.z); if (pos.y - ZoneSystem.instance.m_waterLevel < 3f) { reply("$rok_cmd_water", 3f.ToString("0")); return false; } if (!zoneSystem.IsZoneGenerated(zone)) { zoneSystem.RegisterLocation(location, pos, false); reply("$rok_cmd_pending", FormatPosition(pos)); return true; } try { zoneSystem.RegisterLocation(location, pos, true); Quaternion val = Quaternion.Euler(0f, (float)Random.Range(0, 16) * 22.5f, 0f); zoneSystem.SpawnLocation(location, Random.Range(0, 99999), pos, val, (SpawnMode)0, new List<GameObject>(), false); } catch (Exception ex) { if (zoneSystem.m_locationInstances.TryGetValue(zone, out var value)) { Remove(zoneSystem, zone, value); } ReignOfKingsPlugin.Log.LogError((object)("[Castle] Placement failed: " + ex.Message)); reply("$rok_cmd_failed"); return false; } zoneSystem.SendLocationIcons(0L); reply("$rok_cmd_placed", FormatPosition(pos)); return true; } private static IEnumerator GenerateRandom(ZoneSystem zoneSystem, ZoneLocation location, Notify reply) { _generating = true; reply("$rok_cmd_searching"); Vector2s oldZone; LocationInstance oldInstance; bool replacing = CastleState.TryFind(out oldZone, out oldInstance); bool unique = location.m_unique; int quantity = location.m_quantity; try { if (replacing) { location.m_unique = false; location.m_quantity = zoneSystem.CountNrOfLocation(location) + 1; } Stopwatch stopwatch = Stopwatch.StartNew(); ZPackage iterations = new ZPackage(); yield return zoneSystem.GenerateLocationsTimeSliced(location, stopwatch, iterations); } finally { location.m_unique = unique; location.m_quantity = quantity; _generating = false; } foreach (KeyValuePair<Vector2s, LocationInstance> entry in zoneSystem.m_locationInstances) { if (!CastleLocation.IsCastle(entry.Value.m_location) || (replacing && entry.Key == oldZone)) { continue; } Vector3 position = entry.Value.m_position; if (replacing) { Remove(zoneSystem, oldZone, oldInstance); reply("$rok_cmd_removed"); } reply("$rok_cmd_pending", FormatPosition(position)); yield break; } reply("$rok_cmd_failed"); } private static string FormatPosition(Vector3 pos) { return "(" + pos.x.ToString("0", CultureInfo.InvariantCulture) + ", " + pos.z.ToString("0", CultureInfo.InvariantCulture) + ")"; } } [HarmonyPatch(typeof(Terminal), "InitTerminal")] internal static class Terminal_InitTerminal_Castle { [CompilerGenerated] private static class <>O { public static ConsoleEvent <0>__Run; } private static void Postfix() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown string text = RoKMessages.Localize("$rok_cmd_desc_castle"); object obj = <>O.<0>__Run; if (obj == null) { ConsoleEvent val = CastleCommand.Run; <>O.<0>__Run = val; obj = (object)val; } new ConsoleCommand("rokcastleplace", text, (ConsoleEvent)obj, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } } [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(1)] [<39afbf98-53f6-44cc-b627-6c0afcd56a78>Nullable(0)] internal static class CastleLocation { internal const string FallbackIconLocation = "Vendor_BlackForest"; internal const float MinAltitude = 3f; internal static readonly int PrefabHash = StringExtensionMethods.GetStableHashCode("RDR_Location_ReignOfKings"); [<39afbf98-53f6-44cc-b627-6c0afcd56a78>Nullable(2)] private static Location _location; [<39afbf98-53f6-44cc-b627-6c0afcd56a78>Nullable(2)] private static AssetBundle _bundle; [<39afbf98-53f6-44cc-b627-6c0afcd56a78>Nullable(2)] internal static AssetBundle Bundle { [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(2)] get { return _bundle; } } internal static void Register() { //IL_005c: Unknown result type (might be due to invalid IL or missing references) try { _bundle = PrefabManager.RegisterAssetBundle("rd_reing"); RoKAudio.Initialize(_bundle); _location = new Location(_bundle, "RDR_Location_ReignOfKings") { Count = 1, Unique = true, Prioritize = true, ClearArea = true, ShowMapIcon = ShowIcon.Explored, Rotation = Rotation.Random, SpawnArea = (BiomeArea)2 }; ApplyConfig(); } catch (Exception ex) { ReignOfKingsPlugin.Log.LogError((object)("[Castle] Location not registered: " + ex.Message)); _location = null; } } internal static void ApplyConfig() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (_location != null) { _location.Biome = ParseBiomes(ReignOfKingsPlugin.CE_Castle_Biomes.Value); _location.SpawnDistance = new LocationManager.Range(ReignOfKingsPlugin.CE_Castle_MinDistance.Value, ReignOfKingsPlugin.CE_Castle_MaxDistance.Value); _location.SpawnAltitude = new LocationManager.Range(3f, 1000f); } } internal static void ApplyConfig(ZoneLocation zoneLocation) { //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) zoneLocation.m_biome = ParseBiomes(ReignOfKingsPlugin.CE_Castle_Biomes.Value); zoneLocation.m_minDistance = ReignOfKingsPlugin.CE_Castle_MinDistance.Value; zoneLocation.m_maxDistance = ReignOfKingsPlugin.CE_Castle_MaxDistance.Value; zoneLocation.m_minAltitude = 3f; } [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(2)] internal static bool IsCastle(ZoneLocation zoneLocation) { return zoneLocation != null && zoneLocation.m_prefabName == "RDR_Location_ReignOfKings"; } private static Biome ParseBiomes(string value) { //IL_0002: 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_0075: 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_004a: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) Biome val = (Biome)0; string[] array = value.Split(new char[1] { ',' }); foreach (string text in array) { string text2 = text.Trim(); if (text2.Length != 0) { if (Enum.TryParse<Biome>(text2, ignoreCase: true, out Biome result)) { val |= result; } else { ReignOfKingsPlugin.Log.LogWarning((object)("[Castle] Unknown biome: " + text2)); } } } return (Biome)(((int)val == 0) ? 1 : ((int)val)); } internal static void PrepareBarrier(ZoneSystem zoneSystem) { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Expected O, but got Unknown if ((Object)(object)_bundle == (Object)null) { return; } GameObject val = _bundle.LoadAsset<GameObject>("RDR_Location_ReignOfKings"); Transform obj = val.transform.Find("HaldorBarrier"); MeshRenderer val2 = ((obj != null) ? ((Component)obj).GetComponent<MeshRenderer>() : null); if ((Object)(object)val2 == (Object)null || ((Renderer)val2).enabled) { return; } foreach (ZoneLocation location in zoneSystem.m_locations) { if (location.m_prefabName != "Vendor_BlackForest") { continue; } location.m_prefab.Load(); try { GameObject asset = location.m_prefab.Asset; if ((Object)(object)asset == (Object)null) { break; } MeshRenderer[] componentsInChildren = asset.GetComponentsInChildren<MeshRenderer>(true); foreach (MeshRenderer val3 in componentsInChildren) { if (!(((Object)val3).name != "ForceField")) { ReferenceHolder val4 = val.GetComponent<ReferenceHolder>() ?? val.AddComponent<ReferenceHolder>(); val4.HoldReferenceTo((IReferenceCounted)(object)location.m_prefab); Material val5 = new Material(((Renderer)val2).sharedMaterial); val5.shader = ((Renderer)val3).sharedMaterial.shader; ((Renderer)val2).sharedMaterial = val5; ((Renderer)val2).enabled = true; return; } } } finally { location.m_prefab.Release(); } break; } ReignOfKingsPlugin.Log.LogWarning((object)"[Castle] Haldor barrier material not found; monster protection remains active."); } internal static void PrepareDecorationMaterials(ZNetScene scene) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown if ((Object)(object)_bundle == (Object)null) { return; } Transform val = _bundle.LoadAsset<GameObject>("RDR_Location_ReignOfKings").transform.Find("Decoration"); if ((Object)(object)val == (Object)null) { return; } foreach (Transform item in val) { Transform val2 = item; if (!((Object)val2).name.StartsWith("RDR_ReignOfKings_Decor_", StringComparison.Ordinal)) { continue; } string text = ((Object)val2).name.Substring("RDR_ReignOfKings_Decor_".Length); text = text.Substring(0, text.LastIndexOf('_')); GameObject prefab = scene.GetPrefab(text); if ((Object)(object)prefab == (Object)null) { ReignOfKingsPlugin.Log.LogWarning((object)("[Castle] Decoration source missing: " + text)); continue; } Renderer[] componentsInChildren = ((Component)val2).GetComponentsInChildren<Renderer>(true); foreach (Renderer val3 in componentsInChildren) { string text2 = ""; Transform val4 = ((Component)val3).transform; while ((Object)(object)val4 != (Object)(object)val2) { text2 = ((Object)val4).name + ((text2.Length == 0) ? "" : ("/" + text2)); val4 = val4.parent; } Transform obj = ((text2.Length == 0) ? prefab.transform : prefab.transform.Find(text2)); Renderer val5 = ((obj != null) ? ((Component)obj).GetComponent<Renderer>() : null); if ((Object)(object)val5 == (Object)null) { continue; } Material[] sharedMaterials = val3.sharedMaterials; Material[] sharedMaterials2 = val5.sharedMaterials; for (int j = 0; j < sharedMaterials.Length && j < sharedMaterials2.Length; j++) { if (!((Object)(object)sharedMaterials[j] == (Object)null) && !((Object)(object)sharedMaterials2[j] == (Object)null)) { sharedMaterials[j].shader = sharedMaterials2[j].shader; sharedMaterials[j].shaderKeywords = sharedMaterials2[j].shaderKeywords; sharedMaterials[j].renderQueue = sharedMaterials2[j].renderQueue; sharedMaterials[j].enableInstancing = sharedMaterials2[j].enableInstancing; } } } } } [return: <39afbf98-53f6-44cc-b627-6c0afcd56a78>Nullable(2)] internal static Sprite GetSprite(string name) { return ((Object)(object)_bundle != (Object)null) ? _bundle.LoadAsset<Sprite>(name) : null; } [return: <39afbf98-53f6-44cc-b627-6c0afcd56a78>Nullable(2)] internal static Sprite FindIcon(Minimap minimap) { //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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) Sprite val = (((Object)(object)_bundle != (Object)null) ? _bundle.LoadAsset<Sprite>("ico_reign_of_kings_throne") : null); if ((Object)(object)val != (Object)null) { return val; } foreach (LocationSpriteData locationIcon in minimap.m_locationIcons) { if (locationIcon.m_name == "Vendor_BlackForest") { return locationIcon.m_icon; } } return null; } } [HarmonyPatch(typeof(ZNetScene), "Awake")] internal static class ZNetScene_Awake_DecorationMaterials { [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(1)] [HarmonyPriority(0)] private static void Postfix(ZNetScene __instance) { CastleLocation.PrepareDecorationMaterials(__instance); RoKAssets.RegisterEffects(__instance); } } [HarmonyPatch(typeof(Fireplace), "CheckEnv")] internal static class Fireplace_CheckEnv_RoyalFire { [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(1)] private static void Postfix(Fireplace __instance) { if (((Object)__instance).name.StartsWith("RDR_ReignOfKings_Decor_fire_pit_iron_", StringComparison.Ordinal)) { __instance.m_infiniteFuel = true; __instance.m_canRefill = false; __instance.m_canTurnOff = false; __instance.m_checkWaterLevel = false; __instance.m_blocked = false; __instance.m_wet = false; } } } [HarmonyPatch(typeof(Fireplace), "IsBurning")] internal static class Fireplace_IsBurning_RoyalFire { [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(1)] private static bool Prefix(Fireplace __instance, ref bool __result) { if (!((Object)__instance).name.StartsWith("RDR_ReignOfKings_Decor_fire_pit_iron_", StringComparison.Ordinal)) { return true; } __result = (Object)(object)__instance.m_nview != (Object)null && __instance.m_nview.IsValid(); return false; } } [HarmonyPatch(typeof(ZoneSystem), "SetupLocations")] internal static class ZoneSystem_SetupLocations_Config { [HarmonyPriority(800)] private static void Prefix() { CastleLocation.ApplyConfig(); } [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(1)] private static void Postfix(ZoneSystem __instance) { CastleLocation.PrepareBarrier(__instance); } } [HarmonyPatch(typeof(Minimap), "Awake")] internal static class Minimap_Awake_CastleIcon { [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(1)] [HarmonyPriority(200)] private static void Postfix(Minimap __instance) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) Sprite val = CastleLocation.FindIcon(__instance); if (!((Object)(object)val == (Object)null)) { __instance.m_locationIcons.Add(new LocationSpriteData { m_name = "RDR_Location_ReignOfKings", m_icon = val }); } } } [HarmonyPatch(typeof(Location), "Awake")] internal static class Location_Awake_Attach { [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(1)] private static void Postfix(Location __instance) { if (((Object)__instance).name.StartsWith("RDR_Location_ReignOfKings")) { Transform val = ((Component)__instance).transform.Find("Trono"); if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).GetComponent<KingThrone>() == (Object)null) { ((Component)val).gameObject.AddComponent<KingThrone>(); } Transform val2 = ((Component)__instance).transform.Find("Duel_Stone"); if ((Object)(object)val2 != (Object)null && (Object)(object)((Component)val2).GetComponent<DuelStone>() == (Object)null) { ((Component)val2).gameObject.AddComponent<DuelStone>(); } Transform val3 = ((Component)__instance).transform.Find("TesouroReal"); if ((Object)(object)val3 != (Object)null && (Object)(object)((Component)val3).GetComponent<TreasuryChest>() == (Object)null) { ((Component)val3).gameObject.AddComponent<TreasuryChest>(); } } } } [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(1)] [<39afbf98-53f6-44cc-b627-6c0afcd56a78>Nullable(0)] internal static class CastleMapArea { private const float BorderPixels = 2f; private const float ProbeTolerance = 0.02f; private static readonly Dictionary<int, Color> _originalMap = new Dictionary<int, Color>(); private static readonly Dictionary<int, Color> _originalForest = new Dictionary<int, Color>(); private static int _probeX = -1; private static int _probeY = -1; private static Color _probeColor; internal static void Verify() { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) if (_probeX < 0) { return; } Minimap instance = Minimap.instance; if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance.m_mapTexture == (Object)null) && instance.m_hasGenerated) { Color pixel = instance.m_mapTexture.GetPixel(_probeX, _probeY); if (!(Mathf.Abs(pixel.r - _probeColor.r) < 0.02f) || !(Mathf.Abs(pixel.g - _probeColor.g) < 0.02f) || !(Mathf.Abs(pixel.b - _probeColor.b) < 0.02f)) { Reset(); Repaint(mapReady: true); } } } internal static void Repaint(bool mapReady = false) { //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) Minimap instance = Minimap.instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.m_mapTexture == (Object)null || (Object)(object)instance.m_forestMaskTexture == (Object)null || (!mapReady && !instance.m_hasGenerated)) { return; } Texture2D mapTexture = instance.m_mapTexture; Texture2D forestMaskTexture = instance.m_forestMaskTexture; bool flag = Restore(mapTexture, _originalMap); flag |= Restore(forestMaskTexture, _originalForest); if (ReignOfKingsPlugin.CE_Area_ShowOnMap.Value && CastleState.HasCastle) { flag |= Paint(instance, mapTexture, forestMaskTexture); } if (flag) { mapTexture.Apply(); forestMaskTexture.Apply(); if (_probeX >= 0) { _probeColor = mapTexture.GetPixel(_probeX, _probeY); } } } private static bool Restore(Texture2D texture, Dictionary<int, Color> original) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) if (original.Count == 0) { return false; } int width = ((Texture)texture).width; foreach (KeyValuePair<int, Color> item in original) { texture.SetPixel(item.Key % width, item.Key / width, item.Value); } original.Clear(); _probeX = -1; return true; } private static bool Paint(Minimap minimap, Texture2D map, Texture2D forest) { //IL_0055: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0227: 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_0244: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) int width = ((Texture)map).width; float num = 40f / minimap.m_pixelSize; float num2 = (RoyalBuilding.Enabled ? RoyalBuilding.OuterRadius : 40f) / minimap.m_pixelSize; if (num2 <= 0f) { return false; } bool flag = num2 - num > 4f; int num3 = default(int); int num4 = default(int); minimap.WorldToPixel(CastleState.Position, ref num3, ref num4); Color value = ReignOfKingsPlugin.CE_Area_MapColor.Value; Color val = default(Color); ((Color)(ref val))..ctor(value.r, value.g, value.b, 1f); int num5 = Mathf.CeilToInt(num2) + 1; for (int i = num4 - num5; i <= num4 + num5; i++) { if (i < 0 || i >= width) { continue; } for (int j = num3 - num5; j <= num3 + num5; j++) { if (j < 0 || j >= width) { continue; } float num6 = Mathf.Sqrt((float)((j - num3) * (j - num3) + (i - num4) * (i - num4))); float num7 = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01(num2 + 0.5f - num6)); if (!(num7 <= 0f)) { int key = i * width + j; Color pixel = map.GetPixel(j, i); _originalMap[key] = pixel; float num8 = Mathf.Clamp01(num6 - num2 + 2f + 0.5f); if (flag) { num8 = Mathf.Max(num8, Mathf.Clamp01(1.5f - Mathf.Abs(num6 - num))); } num8 = Mathf.SmoothStep(0f, 1f, num8); float num9 = Mathf.Lerp(value.a, 1f, num8) * num7; map.SetPixel(j, i, Color.Lerp(pixel, val, num9)); if (num8 >= 1f && num7 >= 1f && _probeX < 0) { _probeX = j; _probeY = i; } Color pixel2 = forest.GetPixel(j, i); _originalForest[key] = pixel2; forest.SetPixel(j, i, new Color(pixel2.r * (1f - num7), pixel2.g, pixel2.b, pixel2.a)); } } } return _originalMap.Count > 0; } internal static void Reset() { _originalMap.Clear(); _originalForest.Clear(); _probeX = -1; } } [HarmonyPatch(typeof(Minimap), "LoadMapData")] internal static class Minimap_LoadMapData_CastleArea { private static void Postfix() { CastleMapArea.Reset(); CastleMapArea.Repaint(mapReady: true); } } [<39afbf98-53f6-44cc-b627-6c0afcd56a78>Nullable(0)] [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(1)] internal static class CastleNetwork { internal const string RpcState = "RoK_CastleState"; internal const string RpcCommand = "RoK_CastleCommand"; internal static void BroadcastState() { ZNet instance = ZNet.instance; if (!((Object)(object)instance == (Object)null) && instance.IsServer()) { RoKNet.Broadcast("RoK_CastleState", BuildState()); } } internal static void SendState(ZRpc rpc) { rpc.Invoke("RoK_CastleState", new object[1] { BuildState() }); } private static ZPackage BuildState() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0014: Unknown result type (might be due to invalid IL or missing references) ZPackage val = new ZPackage(); val.Write(CastleState.HasCastle); val.Write(CastleState.Position); return val; } internal static void RPC_State(ZRpc rpc, ZPackage pkg) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) bool hasCastle = pkg.ReadBool(); Vector3 position = pkg.ReadVector3(); CastleState.Apply(hasCastle, position); } internal static bool IsAdmin(ZRpc rpc) { ZNet instance = ZNet.instance; return (Object)(object)instance != (Object)null && instance.ListContainsId(instance.m_adminList, rpc.GetSocket().GetHostName()); } } [HarmonyPatch(typeof(ZoneSystem), "Load")] internal static class ZoneSystem_Load_Castle { private static void Postfix() { CastleState.ServerRefresh(); } } [HarmonyPatch(typeof(ZoneSystem), "RegisterLocation")] internal static class ZoneSystem_RegisterLocation_Castle { [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(1)] private static void Postfix(ZoneLocation location) { if (CastleLocation.IsCastle(location)) { CastleState.ServerRefresh(); } } } [HarmonyPatch(typeof(ZoneSystem), "ClearNonPlacedLocations")] internal static class ZoneSystem_ClearNonPlacedLocations_Castle { private static void Postfix() { CastleState.ServerRefresh(); } } [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(1)] [<39afbf98-53f6-44cc-b627-6c0afcd56a78>Nullable(0)] internal static class WorldProtection { internal static bool Blocked(Component target) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return CastleState.IsInside(target.transform.position); } internal static bool AllowHit(Component target, HitData hit) { if (!Blocked(target) || RoyalBuilding.CanGather(hit.GetAttacker())) { return true; } CastleHitAlert.Report(hit); return false; } } [<39afbf98-53f6-44cc-b627-6c0afcd56a78>Nullable(0)] [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(1)] internal static class CastleHitAlert { internal const string RpcHit = "RoK_ProtectedHit"; private const float SendSeconds = 5f; private const float ShowSeconds = 10f; private static readonly Dictionary<long, float> _lastSent = new Dictionary<long, float>(); private static float _lastShown = -10f; internal static void Register() { ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.Register("RoK_ProtectedHit", (Action<long>)delegate { Show(); }); } } internal static void Reset() { _lastSent.Clear(); _lastShown = -10f; } internal static void Report(HitData hit) { if (hit == null) { return; } Character attacker = hit.GetAttacker(); Player val = (Player)(object)((attacker is Player) ? attacker : null); if (val == null) { return; } if ((Object)(object)val == (Object)(object)Player.m_localPlayer) { Show(); return; } ZDO val2 = (((Object)(object)((Character)val).m_nview != (Object)null) ? ((Character)val).m_nview.GetZDO() : null); if (val2 != null && ZRoutedRpc.instance != null) { long owner = val2.GetOwner(); if (!_lastSent.TryGetValue(owner, out var value) || !(Time.time - value < 5f)) { _lastSent[owner] = Time.time; ZRoutedRpc.instance.InvokeRoutedRPC(owner, "RoK_ProtectedHit", Array.Empty<object>()); } } } internal static void Show() { if (!(Time.time - _lastShown < 10f)) { _lastShown = Time.time; RoKMessages.Show((MessageType)2, "$rok_castle_protected"); } } } [HarmonyPatch(typeof(Location), "IsInsideNoBuildLocation")] internal static class Location_IsInsideNoBuildLocation_Protect { private static void Postfix(Vector3 point, ref bool __result) { //IL_0001: 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) if (CastleState.IsInside(point)) { __result = true; RoyalBuilding.NoteBlocked("$rok_remove_no_castle"); } else if (!__result && RoyalBuilding.IsInRing(point)) { __result = !RoyalBuilding.BypassNoBuild(); if (__result) { RoyalBuilding.NoteBlocked("$rok_remove_no_royal_lands"); } } } } [HarmonyPatch(typeof(WearNTear), "RPC_Damage")] internal static class WearNTear_RPC_Damage_Protect { [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(1)] private static bool Prefix(WearNTear __instance, HitData hit) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!CastleState.IsInside(((Component)__instance).transform.position)) { return true; } CastleHitAlert.Report(hit); return false; } } [HarmonyPatch(typeof(MineRock5), "RPC_Damage")] internal static class MineRock5_RPC_Damage_Protect { [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(1)] private static bool Prefix(MineRock5 __instance, HitData hit) { return WorldProtection.AllowHit((Component)(object)__instance, hit); } } [HarmonyPatch(typeof(MineRock), "RPC_Hit")] internal static class MineRock_RPC_Hit_Protect { [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(1)] private static bool Prefix(MineRock __instance, HitData hit) { return WorldProtection.AllowHit((Component)(object)__instance, hit); } } [HarmonyPatch(typeof(TreeBase), "RPC_Damage")] internal static class TreeBase_RPC_Damage_Protect { [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(1)] private static bool Prefix(TreeBase __instance, HitData hit) { return WorldProtection.AllowHit((Component)(object)__instance, hit); } } [HarmonyPatch(typeof(TreeLog), "RPC_Damage")] internal static class TreeLog_RPC_Damage_Protect { [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(1)] private static bool Prefix(TreeLog __instance, HitData hit) { return WorldProtection.AllowHit((Component)(object)__instance, hit); } } [HarmonyPatch(typeof(Destructible), "RPC_Damage")] internal static class Destructible_RPC_Damage_Protect { [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(1)] private static bool Prefix(Destructible __instance, HitData hit) { return WorldProtection.AllowHit((Component)(object)__instance, hit); } } [HarmonyPatch(typeof(Pickable), "Interact")] internal static class Pickable_Interact_Protect { [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(1)] private static bool Prefix(Pickable __instance, Humanoid character, ref bool __result) { if (!WorldProtection.Blocked((Component)(object)__instance) || RoyalBuilding.CanGather((Character)(object)character)) { return true; } if ((Object)(object)character == (Object)(object)Player.m_localPlayer) { CastleHitAlert.Show(); } __result = false; return false; } } internal enum RoyalBuilders { King, Guild } [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(1)] [<39afbf98-53f6-44cc-b627-6c0afcd56a78>Nullable(0)] internal static class RoyalBuilding { internal const string ZdoKey = "RoK_RoyalPiece"; private const float DefaultWardRadius = 32f; private const string VanillaNoBuildMessage = "$msg_nobuildzone"; internal static readonly int ZdoHash = StringExtensionMethods.GetStableHashCode("RoK_RoyalPiece"); internal static ConfigEntry<bool> CE_Enabled = null; internal static ConfigEntry<bool> CE_RemoveOnDethrone = null; internal static ConfigEntry<RoyalBuilders> CE_Builders = null; internal static ConfigEntry<bool> CE_BlockWards = null; internal static ConfigEntry<bool> CE_BlockBeds = null; internal static ConfigEntry<bool> CE_AllowGathering = null; internal static ConfigEntry<float> CE_RingWidth = null; [<39afbf98-53f6-44cc-b627-6c0afcd56a78>Nullable(new byte[] { 1, 1, 0 })] private static readonly Dictionary<string, KeyValuePair<float, DamageModifiers>> _vanilla = new Dictionary<string, KeyValuePair<float, DamageModifiers>>(); private static bool _placing; private static bool _removing; [<39afbf98-53f6-44cc-b627-6c0afcd56a78>Nullable(2)] private static string _removeBlock; internal static bool Enabled => CE_Enabled.Value; internal static float OuterRadius => 40f + Mathf.Max(0f, CE_RingWidth.Value); internal static bool LocalCanBuild => Enabled && KingClient.HasKing && (KingClient.IsLocalKing || (CE_Builders.Value == RoyalBuilders.Guild && RoKGuilds.LocalInKingGuild)); internal static bool IsInRing(Vector3 point) { //IL_000e: 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) return Enabled && CastleState.HasCastle && !CastleState.IsInside(point) && Utils.DistanceXZ(point, CastleState.Position) <= OuterRadius; } [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(2)] internal static bool CanGather(Character character) { int result; if (CE_Enabled.Value && CE_AllowGathering.Value) { Player val = (Player)(object)((character is Player) ? character : null); if (val != null) { result = (IsRoyalMember(val) ? 1 : 0); goto IL_002b; } } result = 0; goto IL_002b; IL_002b: return (byte)result != 0; } private unsafe static bool IsRoyalMember(Player player) { //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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) if (!KingClient.HasKing) { return false; } bool flag = CE_Builders.Value == RoyalBuilders.Guild; if ((Object)(object)player == (Object)(object)Player.m_localPlayer) { return KingClient.IsLocalKing || (flag && RoKGuilds.LocalInKingGuild); } if ((Object)(object)ZNet.instance == (Object)null) { return false; } ZDOID zDOID = ((Character)player).GetZDOID(); foreach (PlayerInfo player2 in ZNet.instance.m_players) { if (player2.m_characterID != zDOID) { continue; } PlatformUserID id = player2.m_userInfo.m_id; string text = ((object)(*(PlatformUserID*)(&id))/*cast due to .constrained prefix*/).ToString(); if (text == KingClient.KingId) { return true; } return flag && KingClient.KingGuildId != 0 && RoKGuilds.GuildOf(text, player2.m_name) == KingClient.KingGuildId; } return false; } internal static void Reset() { _placing = false; _removing = false; _removeBlock = null; } [<2c965e7b-2817-420f-ac75-405fe57e7c45>NullableContext(2)] internal static bool IsRoyal(ZNetView nview) { return (Object)(object)nview != (Object)null && nview.IsValid() && nview.GetZDO().GetBool(ZdoHash, false); } internal static void BeginPlacing() { _placing = true; } internal static void EndPlacing() { _placing = false; } internal static void BeginRemoving() { _removing = true; _removeBlock = null; } internal static void EndRemoving() { _removing = false; _removeBlock = null; } internal static void NoteBlocked(string reason) { if (_removing) { _removeBlock = reason; } } [return: <39afbf98-53f6-44cc-b627-6c0afcd56a78>Nullable(2)] internal static string TakeRemoveBlock(string message) { if (!_removing || _removeBlock == null || message != "$msg_nobuildzone") { return null; } string removeBlock = _removeBlock; _removeBlock = null; return removeBlock; } internal static bool BypassNoBuild() { if (_removing) { return LocalCanBuild; } if (!_placing || !LocalCanBuild) { return false; } Player localPlayer = Player.m_localPlayer; return (Object)(object)localPlayer != (Object)null && (Object)(object)localPlayer.m_placementGhost != (Object)null && BlockReason(localPlayer.m_placementGhost) == null; } internal static bool IsWard(GameObject piece) { return (Object)(object)piece.GetComponent<PrivateArea>() != (Object)null || ((Object)piece).name.ToLowerInvariant().Contains("ward"); } internal static bool WardReachesCastle(GameObject piece) { //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) if (!CE_BlockWards.Value || !CastleState.HasCastle || !IsWard(piece)) { return false; } PrivateArea component = piece.GetComponent<PrivateArea>(); float num = (((Object)(object)component != (Object)null) ? component.m_radius : 32f); float num2 = (Enabled ? OuterRadius : 40f); return Utils.DistanceXZ(piece.transform.position, CastleState.Position) < num2 + num; } [return: <39afbf98-53f6-44cc-b627-6c0afcd56a78>Nullable(2)] internal static string BlockReason(GameObject piece) { if ((Object)(object)piece.GetComponent<TerrainOp>() != (Object)null || (Object)(object)piece.GetComponent<TerrainModifier>() != (Object)null || (Object)(object)piece.GetComponent<Plant>() != (Object)null) { return "$rok_build_blocked_terrain"; } if (CE_BlockWards.Value && IsWard(piece)) { return "$rok_build_blocked_ward"; } if (CE_BlockBeds.Value && (Object)(object)piece.GetComponent<Bed>() != (Object)null) { return "$rok_build_blocked_bed"; } return null; } [return: <39afbf98-53f6-44cc-b627-6c0afcd56a78>Nullable(2)] internal static string PlacementBlock(Player player) { //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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) GameObject placementGhost = player.m_placementGhost; if ((Object)(object)placementGhost == (Object)null) { return null; } Vector3 position = placementGhost.transform.position; if (CastleState.IsInside(position)) { return "$rok_build_no_castle"; } if (IsInRing(position)) { return LocalCanBuild ? BlockReason(placementGhost) : "$rok_build_no_royal_lands"; } return WardReachesCastle(placementGhost) ? "$rok_build_blocked_ward_area" : null; } internal static bool CanRemove(Piece piece) { //IL_0006: Unknown result type (might be d