Decompiled source of BuildableNature v1.0.1
BuildableNature.dll
Decompiled 2 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using BuildableBossStone.Managers; using BuildableNature.Managers; using HarmonyLib; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using ServerSync; using TMPro; using UnityEngine; using UnityEngine.UI; using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Core.Tokens; using YamlDotNet.Helpers; using YamlDotNet.Serialization; using YamlDotNet.Serialization.BufferedDeserialization; using YamlDotNet.Serialization.BufferedDeserialization.TypeDiscriminators; 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: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("BuildableNature")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyProduct("BuildableNature")] [assembly: AssemblyCopyright("Copyright © 2022")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("E0E2F92E-557C-4A05-9D89-AA92A0BD75C4")] [assembly: AssemblyFileVersion("1.0.1")] [assembly: AssemblyCompany("RustyMods")] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<ae1abf84-b9c0-4f3b-855f-7ca7d3729dc4>Embedded] internal sealed class <ae1abf84-b9c0-4f3b-855f-7ca7d3729dc4>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [<ae1abf84-b9c0-4f3b-855f-7ca7d3729dc4>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class <793b3815-081d-4ba3-ad9f-fef60d3789f2>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <793b3815-081d-4ba3-ad9f-fef60d3789f2>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <793b3815-081d-4ba3-ad9f-fef60d3789f2>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [<ae1abf84-b9c0-4f3b-855f-7ca7d3729dc4>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class <38234ec0-cf0a-4937-a412-d83163601bb7>NullableContextAttribute : Attribute { public readonly byte Flag; public <38234ec0-cf0a-4937-a412-d83163601bb7>NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace BuildableNature { [<38234ec0-cf0a-4937-a412-d83163601bb7>NullableContext(1)] [<793b3815-081d-4ba3-ad9f-fef60d3789f2>Nullable(0)] [BepInPlugin("RustyMods.BuildableNature", "BuildableNature", "1.0.1")] public class BuildableNaturePlugin : BaseUnityPlugin { [<38234ec0-cf0a-4937-a412-d83163601bb7>NullableContext(0)] public enum Toggle { On = 1, Off = 0 } [<38234ec0-cf0a-4937-a412-d83163601bb7>NullableContext(0)] private class ConfigurationManagerAttributes { [UsedImplicitly] public int? Order = null; [UsedImplicitly] public bool? Browsable = null; [<793b3815-081d-4ba3-ad9f-fef60d3789f2>Nullable(2)] [UsedImplicitly] public string Category = null; [UsedImplicitly] [<793b3815-081d-4ba3-ad9f-fef60d3789f2>Nullable(new byte[] { 2, 1 })] public Action<ConfigEntryBase> CustomDrawer = null; } internal const string ModName = "BuildableNature"; internal const string ModVersion = "1.0.1"; internal const string Author = "RustyMods"; private const string ModGUID = "RustyMods.BuildableNature"; private static readonly string ConfigFileName = "RustyMods.BuildableNature.cfg"; private static readonly string ConfigFileFullPath; internal static string ConnectionError; private readonly Harmony _harmony = new Harmony("RustyMods.BuildableNature"); public static readonly ManualLogSource BuildableNatureLogger; private static readonly ConfigSync ConfigSync; public static GameObject m_root; public static BuildableNaturePlugin m_plugin; private static ConfigEntry<Toggle> _serverConfigLocked; public static void SetupFileWatcher() { m_plugin.SetupWatcher(); } private void InitConfigs() { _serverConfigLocked = config("1 - General", "Lock Configuration", Toggle.On, "If on, the configuration is locked and can be changed by server admins only."); ConfigSync.AddLockingConfigEntry<Toggle>(_serverConfigLocked); } public void Awake() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown InitConfigs(); m_root = new GameObject("root"); m_plugin = this; Object.DontDestroyOnLoad((Object)(object)m_root); m_root.SetActive(false); Assembly executingAssembly = Assembly.GetExecutingAssembly(); _harmony.PatchAll(executingAssembly); } private void OnDestroy() { ((BaseUnityPlugin)this).Config.Save(); } private void SetupWatcher() { FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, ConfigFileName); fileSystemWatcher.Changed += ReadConfigValues; fileSystemWatcher.Created += ReadConfigValues; fileSystemWatcher.Renamed += ReadConfigValues; fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; } private void ReadConfigValues(object sender, FileSystemEventArgs e) { if (!File.Exists(ConfigFileFullPath)) { return; } try { BuildableNatureLogger.LogDebug((object)"ReadConfigValues called"); ((BaseUnityPlugin)this).Config.Reload(); } catch { BuildableNatureLogger.LogError((object)("There was an issue loading your " + ConfigFileName)); BuildableNatureLogger.LogError((object)"Please check your config entries for spelling and format!"); } } public ConfigEntry<T> config<[<793b3815-081d-4ba3-ad9f-fef60d3789f2>Nullable(2)] T>(string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown ConfigDescription val = new ConfigDescription(description.Description + (synchronizedSetting ? " [Synced with Server]" : " [Not Synced with Server]"), description.AcceptableValues, description.Tags); ConfigEntry<T> val2 = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, val); SyncedConfigEntry<T> syncedConfigEntry = ConfigSync.AddConfigEntry<T>(val2); syncedConfigEntry.SynchronizedConfig = synchronizedSetting; return val2; } public ConfigEntry<T> config<[<793b3815-081d-4ba3-ad9f-fef60d3789f2>Nullable(2)] T>(string group, string name, T value, string description, bool synchronizedSetting = true) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), synchronizedSetting); } static BuildableNaturePlugin() { string configPath = Paths.ConfigPath; char directorySeparatorChar = Path.DirectorySeparatorChar; ConfigFileFullPath = configPath + directorySeparatorChar + ConfigFileName; ConnectionError = ""; BuildableNatureLogger = Logger.CreateLogSource("BuildableNature"); ConfigSync = new ConfigSync("RustyMods.BuildableNature") { DisplayName = "BuildableNature", CurrentVersion = "1.0.1", MinimumRequiredVersion = "1.0.1" }; m_root = null; m_plugin = null; _serverConfigLocked = null; } } [HarmonyPatch(typeof(ZNet), "OnNewConnection")] public static class RegisterAndCheckVersion { [<38234ec0-cf0a-4937-a412-d83163601bb7>NullableContext(1)] private static void Prefix(ZNetPeer peer, ref ZNet __instance) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown BuildableNaturePlugin.BuildableNatureLogger.LogDebug((object)"Registering version RPC handler"); peer.m_rpc.Register<ZPackage>("BuildableNature_VersionCheck", (Action<ZRpc, ZPackage>)RpcHandlers.RPC_BuildableNature_Version); BuildableNaturePlugin.BuildableNatureLogger.LogInfo((object)"Invoking version check"); ZPackage val = new ZPackage(); val.Write("1.0.1"); val.Write(RpcHandlers.ComputeHashForMod().Replace("-", "")); peer.m_rpc.Invoke("BuildableNature_VersionCheck", new object[1] { val }); } } [<793b3815-081d-4ba3-ad9f-fef60d3789f2>Nullable(0)] [<38234ec0-cf0a-4937-a412-d83163601bb7>NullableContext(1)] [HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")] public static class VerifyClient { private static bool Prefix(ZRpc rpc, ZPackage pkg, ref ZNet __instance) { if (!__instance.IsServer() || RpcHandlers.ValidatedPeers.Contains(rpc)) { return true; } BuildableNaturePlugin.BuildableNatureLogger.LogWarning((object)("Peer (" + rpc.m_socket.GetHostName() + ") never sent version or couldn't due to previous disconnect, disconnecting")); rpc.Invoke("Error", new object[1] { 3 }); return false; } private static void Postfix(ZNet __instance) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "BuildableNatureRequestAdminSync", new object[1] { (object)new ZPackage() }); } } [HarmonyPatch(typeof(FejdStartup), "ShowConnectError")] public class ShowConnectionError { [<38234ec0-cf0a-4937-a412-d83163601bb7>NullableContext(1)] private static void Postfix(FejdStartup __instance) { if (__instance.m_connectionFailedPanel.activeSelf) { __instance.m_connectionFailedError.fontSizeMax = 25f; __instance.m_connectionFailedError.fontSizeMin = 15f; TMP_Text connectionFailedError = __instance.m_connectionFailedError; connectionFailedError.text = connectionFailedError.text + "\n" + BuildableNaturePlugin.ConnectionError; } } } [HarmonyPatch(typeof(ZNet), "Disconnect")] public static class RemoveDisconnectedPeerFromVerified { [<38234ec0-cf0a-4937-a412-d83163601bb7>NullableContext(1)] private static void Prefix(ZNetPeer peer, ref ZNet __instance) { if (__instance.IsServer()) { BuildableNaturePlugin.BuildableNatureLogger.LogInfo((object)("Peer (" + peer.m_rpc.m_socket.GetHostName() + ") disconnected, removing from validated list")); RpcHandlers.ValidatedPeers.Remove(peer.m_rpc); } } } [<38234ec0-cf0a-4937-a412-d83163601bb7>NullableContext(1)] [<793b3815-081d-4ba3-ad9f-fef60d3789f2>Nullable(0)] public static class RpcHandlers { public static readonly List<ZRpc> ValidatedPeers = new List<ZRpc>(); public static void RPC_BuildableNature_Version(ZRpc rpc, ZPackage pkg) { string text = pkg.ReadString(); string text2 = pkg.ReadString(); string text3 = ComputeHashForMod().Replace("-", ""); BuildableNaturePlugin.BuildableNatureLogger.LogInfo((object)("Version check, local: 1.0.1, remote: " + text)); if (text2 != text3 || text != "1.0.1") { BuildableNaturePlugin.ConnectionError = "BuildableNature Installed: 1.0.1 " + text3 + "\n Needed: " + text + " " + text2; if (ZNet.instance.IsServer()) { BuildableNaturePlugin.BuildableNatureLogger.LogWarning((object)("Peer (" + rpc.m_socket.GetHostName() + ") has incompatible version, disconnecting...")); rpc.Invoke("Error", new object[1] { 3 }); } } else if (!ZNet.instance.IsServer()) { BuildableNaturePlugin.BuildableNatureLogger.LogInfo((object)"Received same version from server!"); } else { BuildableNaturePlugin.BuildableNatureLogger.LogInfo((object)("Adding peer (" + rpc.m_socket.GetHostName() + ") to validated list")); ValidatedPeers.Add(rpc); } } public static string ComputeHashForMod() { using SHA256 sHA = SHA256.Create(); byte[] array = sHA.ComputeHash(File.ReadAllBytes(Assembly.GetExecutingAssembly().Location)); StringBuilder stringBuilder = new StringBuilder(); byte[] array2 = array; foreach (byte b in array2) { stringBuilder.Append(b.ToString("X2")); } return stringBuilder.ToString(); } } } namespace BuildableNature.Solution { public static class ExclusionList { [<38234ec0-cf0a-4937-a412-d83163601bb7>NullableContext(1)] public static bool IsExcluded(string name) { List<string> list = new List<string> { "CargoCrate", "Pickable_DvergerThing", "Beech_Sapling" }; return list.Contains(name); } } [<38234ec0-cf0a-4937-a412-d83163601bb7>NullableContext(1)] [<793b3815-081d-4ba3-ad9f-fef60d3789f2>Nullable(0)] public static class Flora { [<38234ec0-cf0a-4937-a412-d83163601bb7>NullableContext(0)] [HarmonyPatch(typeof(ZNetScene), "Awake")] private static class ZNetScene_Awake_Patch { [<38234ec0-cf0a-4937-a412-d83163601bb7>NullableContext(1)] private static void Postfix(ZNetScene __instance) { if (m_loaded) { return; } LoadAssets(); foreach (GameObject prefab in __instance.m_prefabs) { if (!ExclusionList.IsExcluded(((Object)prefab).name) && !ConvertPlant(prefab, "Flora") && !ConvertPickable(prefab, HandleCategory(prefab)) && !ConvertDestructible(prefab, HandleCategory(prefab)) && !ConvertTreeBase(prefab, "Flora") && !ConvertMineRock(prefab, "Rocks")) { } } foreach (GameObject piece in m_pieces) { Register(piece); } BuildableNaturePlugin.SetupFileWatcher(); m_loaded = true; } } private static bool m_loaded; private static ItemDrop m_hammer = null; private static CraftingStation m_station = null; private static EffectList m_placeEffects = null; private static EffectList m_destroyedEffects = null; private static EffectList m_hitEffects = null; private static Requirement[] m_defaultRequirements = null; private static readonly List<GameObject> m_pieces = new List<GameObject>(); private static void LoadAssets() { //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown GameObject prefab = ZNetScene.instance.GetPrefab("Hammer"); ItemDrop hammer = default(ItemDrop); if (!prefab.TryGetComponent<ItemDrop>(ref hammer)) { return; } m_hammer = hammer; GameObject prefab2 = ZNetScene.instance.GetPrefab("piece_workbench"); CraftingStation station = default(CraftingStation); if (prefab2.TryGetComponent<CraftingStation>(ref station)) { m_station = station; Piece val = default(Piece); WearNTear val2 = default(WearNTear); if (prefab2.TryGetComponent<Piece>(ref val) && prefab2.TryGetComponent<WearNTear>(ref val2)) { m_placeEffects = val.m_placeEffect; m_destroyedEffects = val2.m_destroyedEffect; m_hitEffects = val2.m_hitEffect; m_defaultRequirements = (Requirement[])(object)new Requirement[1] { new Requirement { m_resItem = ZNetScene.instance.GetPrefab("Wood").GetComponent<ItemDrop>(), m_recover = true, m_amount = 1, m_amountPerLevel = 1, m_extraAmountOnlyOneIngredient = 1 } }; } } } private static bool ConvertPlant(GameObject prefab, string category) { //IL_00f0: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)prefab.GetComponent<Plant>())) { return false; } GameObject val = Object.Instantiate<GameObject>(prefab, BuildableNaturePlugin.m_root.transform, false); ((Object)val).name = "piece_" + GetPrefabName(((Object)prefab).name); Plant val2 = default(Plant); if (!val.TryGetComponent<Plant>(ref val2)) { return false; } if (Object.op_Implicit((Object)(object)val2.m_healthy)) { Object.Destroy((Object)(object)val2.m_healthy); } if (Object.op_Implicit((Object)(object)val2.m_unhealthy)) { Object.Destroy((Object)(object)val2.m_unhealthy); } if (Object.op_Implicit((Object)(object)val2.m_unhealthyGrown)) { Object.Destroy((Object)(object)val2.m_unhealthyGrown); } if (Object.op_Implicit((Object)(object)val2.m_healthyGrown)) { val2.m_healthyGrown.SetActive(true); } RemoveComponents(val); GameObject model = SetUnderModel(val); SetLayer(val, LayerMask.op_Implicit(LayerMask.NameToLayer("piece"))); AddPiece(val, prefab, category); AddWearNTear(val, model); RegisterToHammer(val); m_pieces.Add(val); return true; } private static bool ConvertPickable(GameObject prefab, string category) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) if (!HasCollider(prefab)) { return false; } if (!Object.op_Implicit((Object)(object)prefab.GetComponent<Pickable>())) { return false; } GameObject val = Object.Instantiate<GameObject>(prefab, BuildableNaturePlugin.m_root.transform, false); ((Object)val).name = "piece_" + GetPrefabName(((Object)prefab).name); RemoveComponents(val); GameObject model = SetUnderModel(val); SetLayer(val, LayerMask.op_Implicit(LayerMask.NameToLayer("piece"))); AddPiece(val, prefab, category); AddWearNTear(val, model); RegisterToHammer(val); m_pieces.Add(val); return true; } private static bool ConvertTreeBase(GameObject prefab, string category) { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) TreeBase treeBase = default(TreeBase); if (!prefab.TryGetComponent<TreeBase>(ref treeBase)) { return false; } bool flag = false; if (!HasCollider(prefab)) { MeshCollider val = default(MeshCollider); if (!prefab.TryGetComponent<MeshCollider>(ref val)) { val = prefab.GetComponentInChildren<MeshCollider>(); if ((Object)(object)val == (Object)null) { return false; } } flag = true; } GameObject val2 = Object.Instantiate<GameObject>(prefab, BuildableNaturePlugin.m_root.transform, false); ((Object)val2).name = "piece_" + GetPrefabName(((Object)prefab).name); RemoveComponents(val2); RemovePathfindingBlockers(val2); SetLayer(val2, LayerMask.op_Implicit(LayerMask.NameToLayer("piece"))); if (flag && !AddCollider(val2)) { return false; } GameObject model = SetUnderModel(val2); AddPiece(val2, prefab, category); AddWearNTear(val2, model, null, treeBase); RegisterToHammer(val2); m_pieces.Add(val2); return true; } private static bool ConvertMineRock(GameObject prefab, string category) { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) MineRock mineRock = default(MineRock); if (!prefab.TryGetComponent<MineRock>(ref mineRock)) { return false; } bool flag = false; if (!HasCollider(prefab)) { MeshCollider val = default(MeshCollider); if (!prefab.TryGetComponent<MeshCollider>(ref val)) { val = prefab.GetComponentInChildren<MeshCollider>(); if ((Object)(object)val == (Object)null) { return false; } } flag = true; } GameObject val2 = Object.Instantiate<GameObject>(prefab, BuildableNaturePlugin.m_root.transform, false); ((Object)val2).name = "piece_" + GetPrefabName(((Object)prefab).name); RemoveComponents(val2); RemovePathfindingBlockers(val2); SetLayer(val2, LayerMask.op_Implicit(LayerMask.NameToLayer("piece"))); if (flag && !AddCollider(val2)) { return false; } GameObject model = SetUnderModel(val2); AddPiece(val2, prefab, category); AddWearNTear(val2, model, null, null, mineRock); RegisterToHammer(val2); m_pieces.Add(val2); return true; } private static void RemoveComponents(GameObject prefab) { //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Expected O, but got Unknown Destructible val = default(Destructible); if (prefab.TryGetComponent<Destructible>(ref val)) { Object.Destroy((Object)(object)val); } Pickable val2 = default(Pickable); if (prefab.TryGetComponent<Pickable>(ref val2)) { Object.Destroy((Object)(object)val2); } DropOnDestroyed val3 = default(DropOnDestroyed); if (prefab.TryGetComponent<DropOnDestroyed>(ref val3)) { Object.Destroy((Object)(object)val3); } LuredWisp val4 = default(LuredWisp); if (prefab.TryGetComponent<LuredWisp>(ref val4)) { Object.Destroy((Object)(object)val4); } Vine val5 = default(Vine); if (prefab.TryGetComponent<Vine>(ref val5)) { Object.Destroy((Object)(object)val5); } ConditionalObject val6 = default(ConditionalObject); if (prefab.TryGetComponent<ConditionalObject>(ref val6)) { Object.Destroy((Object)(object)val6); } HoverText val7 = default(HoverText); if (prefab.TryGetComponent<HoverText>(ref val7)) { Object.Destroy((Object)(object)val7); } Floating val8 = default(Floating); if (prefab.TryGetComponent<Floating>(ref val8)) { Object.Destroy((Object)(object)val8); } Rigidbody val9 = default(Rigidbody); if (prefab.TryGetComponent<Rigidbody>(ref val9)) { Object.Destroy((Object)(object)val9); } ZSyncTransform val10 = default(ZSyncTransform); if (prefab.TryGetComponent<ZSyncTransform>(ref val10)) { Object.Destroy((Object)(object)val10); } RandomFlyingBird val11 = default(RandomFlyingBird); if (prefab.TryGetComponent<RandomFlyingBird>(ref val11)) { Object.Destroy((Object)(object)val11); } Fish val12 = default(Fish); if (prefab.TryGetComponent<Fish>(ref val12)) { Object.Destroy((Object)(object)val12); } SpawnArea val13 = default(SpawnArea); if (prefab.TryGetComponent<SpawnArea>(ref val13)) { Object.Destroy((Object)(object)val13); } TerrainModifier val14 = default(TerrainModifier); if (prefab.TryGetComponent<TerrainModifier>(ref val14)) { Object.Destroy((Object)(object)val14); } MineRock val15 = default(MineRock); if (prefab.TryGetComponent<MineRock>(ref val15)) { Object.Destroy((Object)(object)val15); } Leviathan val16 = default(Leviathan); if (prefab.TryGetComponent<Leviathan>(ref val16)) { Object.Destroy((Object)(object)val16); } Plant val17 = default(Plant); if (prefab.TryGetComponent<Plant>(ref val17)) { Object.Destroy((Object)(object)val17); } foreach (Transform item in prefab.transform) { Transform val18 = item; if (Object.op_Implicit((Object)(object)((Component)val18).GetComponent<TerrainModifier>())) { Object.Destroy((Object)(object)((Component)val18).gameObject); } } TreeBase val19 = default(TreeBase); if (prefab.TryGetComponent<TreeBase>(ref val19)) { Object.Destroy((Object)(object)val19); } } private static string HandleCategory(GameObject prefab) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Invalid comparison between Unknown and I4 //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Invalid comparison between Unknown and I4 //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Invalid comparison between Unknown and I4 Destructible val = default(Destructible); if (prefab.TryGetComponent<Destructible>(ref val)) { if ((int)val.GetDestructibleType() == 2) { return "Flora"; } if ((int)val.m_damages.m_chop == 3 && (int)val.m_damages.m_pickaxe != 3) { return "Rocks"; } } if (Object.op_Implicit((Object)(object)prefab.GetComponent<Fish>())) { return "Nature"; } if (Object.op_Implicit((Object)(object)prefab.GetComponent<RandomFlyingBird>())) { return "Nature"; } Pickable val2 = default(Pickable); if (prefab.TryGetComponent<Pickable>(ref val2)) { if ((Object)(object)val2.m_itemPrefab == (Object)null) { return "Other"; } ItemDrop val3 = default(ItemDrop); if (!val2.m_itemPrefab.TryGetComponent<ItemDrop>(ref val3)) { return "Other"; } if (!val3.m_itemData.m_shared.m_teleportable) { return "Rocks"; } if ((int)val3.m_itemData.m_shared.m_itemType != 2) { return "Nature"; } } return "Other"; } private static bool ConvertDestructible(GameObject prefab, string category) { //IL_00cb: Unknown result type (might be due to invalid IL or missing references) Destructible destructible = default(Destructible); if (!prefab.TryGetComponent<Destructible>(ref destructible)) { return false; } bool flag = false; if (!HasCollider(prefab)) { MeshCollider val = default(MeshCollider); if (!prefab.TryGetComponent<MeshCollider>(ref val)) { val = prefab.GetComponentInChildren<MeshCollider>(); if ((Object)(object)val == (Object)null) { return false; } } flag = true; } GameObject val2 = Object.Instantiate<GameObject>(prefab, BuildableNaturePlugin.m_root.transform, false); ((Object)val2).name = "piece_" + GetPrefabName(((Object)prefab).name); RemoveComponents(val2); RemovePathfindingBlockers(val2); GameObject model = SetUnderModel(val2); if (flag && !AddCollider(val2)) { return false; } SetLayer(val2, LayerMask.op_Implicit(LayerMask.NameToLayer("piece"))); AddPiece(val2, prefab, category); AddWearNTear(val2, model, destructible); RegisterToHammer(val2); m_pieces.Add(val2); return true; } private static bool AddCollider(GameObject prefab) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) MeshRenderer componentInChildren = prefab.GetComponentInChildren<MeshRenderer>(); if ((Object)(object)componentInChildren == (Object)null) { return false; } GameObject val = new GameObject("collider"); val.transform.SetParent(prefab.transform); BoxCollider val2 = val.AddComponent<BoxCollider>(); Bounds bounds = ((Renderer)componentInChildren).bounds; val2.size = new Vector3(1f, ((Bounds)(ref bounds)).size.y); val2.center = ((Bounds)(ref bounds)).center; return true; } private static void RegisterToHammer(GameObject prefab) { if (!m_hammer.m_itemData.m_shared.m_buildPieces.m_pieces.Contains(prefab)) { m_hammer.m_itemData.m_shared.m_buildPieces.m_pieces.Add(prefab); } } private static GameObject SetUnderModel(GameObject prefab) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown List<Transform> list = new List<Transform>(); foreach (Transform item2 in prefab.transform) { Transform item = item2; list.Add(item); } GameObject val = new GameObject("model"); val.transform.parent = prefab.transform; foreach (Transform item3 in list) { item3.parent = val.transform; } return val; } private static void RemovePathfindingBlockers(GameObject prefab) { SphereCollider[] componentsInChildren = prefab.GetComponentsInChildren<SphereCollider>(); foreach (SphereCollider val in componentsInChildren) { if (((Object)val).name.Contains("Pathfinding")) { Object.Destroy((Object)(object)((Component)val).gameObject); } } } private static void AddPiece(GameObject prefab, GameObject original, string category) { //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) bool flag = false; Piece piece = default(Piece); if (!prefab.TryGetComponent<Piece>(ref piece)) { piece = prefab.AddComponent<Piece>(); flag = true; } ((StaticTarget)piece).m_primaryTarget = false; ((StaticTarget)piece).m_randomTarget = false; piece.m_targetNonPlayerBuilt = false; piece.m_craftingStation = m_station; piece.m_cultivatedGroundOnly = false; piece.m_canBeRemoved = true; if (flag) { piece.m_name = GetDisplayName(((Object)original).name); SpriteMan.Snapshot(prefab); piece.m_placeEffect = m_placeEffects; AddPieceRequirements(piece, original); } string group = Localization.instance.Localize(piece.m_name); ConfigEntry<string> categoryConfig = BuildableNaturePlugin.m_plugin.config(group, "Category", category, "Set build category"); piece.m_category = CategoryMan.GetCategory(categoryConfig.Value); categoryConfig.SettingChanged += [<38234ec0-cf0a-4937-a412-d83163601bb7>NullableContext(0)] (object sender, EventArgs args) => { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) piece.m_category = CategoryMan.GetCategory(categoryConfig.Value); }; ConfigEntry<BuildableNaturePlugin.Toggle> enabledConfig = BuildableNaturePlugin.m_plugin.config(group, "_Enabled", BuildableNaturePlugin.Toggle.On, "If on, piece is enabled"); piece.m_enabled = enabledConfig.Value == BuildableNaturePlugin.Toggle.On; enabledConfig.SettingChanged += [<38234ec0-cf0a-4937-a412-d83163601bb7>NullableContext(0)] (object sender, EventArgs args) => { piece.m_enabled = enabledConfig.Value == BuildableNaturePlugin.Toggle.On; }; } private static void AddPieceRequirements(Piece piece, GameObject original) { Fish fish = default(Fish); Pickable component = default(Pickable); TreeBase component2 = default(TreeBase); MineRock mineRock = default(MineRock); Destructible val = default(Destructible); MineRock5 component3 = default(MineRock5); DropOnDestroyed component4 = default(DropOnDestroyed); if (original.TryGetComponent<Fish>(ref fish)) { SetRequirements(fish, piece); } else if (original.TryGetComponent<Pickable>(ref component)) { SetRequirements(component, piece); } else if (original.TryGetComponent<TreeBase>(ref component2)) { piece.m_resources = GetRequirements(component2); } else if (original.TryGetComponent<MineRock>(ref mineRock)) { SetRequirements(mineRock, piece); } else if (original.TryGetComponent<Destructible>(ref val) && (Object)(object)val.m_spawnWhenDestroyed != (Object)null && val.m_spawnWhenDestroyed.TryGetComponent<MineRock5>(ref component3)) { piece.m_resources = GetRequirements(component3); } else if (original.TryGetComponent<DropOnDestroyed>(ref component4)) { piece.m_resources = GetRequirements(component4); } else { piece.m_resources = m_defaultRequirements; } StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < piece.m_resources.Length; i++) { Requirement val2 = piece.m_resources[i]; stringBuilder.AppendFormat("{0}:{1}{2}", ((Object)val2.m_resItem).name, val2.m_amount, (i < piece.m_resources.Length - 1) ? "," : ""); } string group = Localization.instance.Localize(piece.m_name); ConfigEntry<string> config = BuildableNaturePlugin.m_plugin.config(group, "Resources", stringBuilder.ToString(), "Set piece build requirements"); config.SettingChanged += [<38234ec0-cf0a-4937-a412-d83163601bb7>NullableContext(0)] (object sender, EventArgs args) => { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown List<Requirement> list = new List<Requirement>(); string[] array = config.Value.Split(new char[1] { ',' }); string[] array2 = array; ItemDrop resItem = default(ItemDrop); foreach (string text in array2) { string[] array3 = text.Split(new char[1] { ':' }); if (array3.Length >= 2 && int.TryParse(array3[1], out var result)) { string text2 = array3[0]; GameObject prefab = ZNetScene.instance.GetPrefab(text2); if (Object.op_Implicit((Object)(object)prefab) && prefab.TryGetComponent<ItemDrop>(ref resItem)) { list.Add(new Requirement { m_resItem = resItem, m_amount = result, m_recover = true, m_extraAmountOnlyOneIngredient = 1, m_amountPerLevel = 1 }); } } } piece.m_resources = list.ToArray(); }; } private static void SetRequirements(MineRock mineRock, Piece piece) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_00a7: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown if (!Utility.IsNullOrWhiteSpace(mineRock.m_name)) { piece.m_name = mineRock.m_name; } int childCount = ((Component)mineRock).transform.childCount; List<Requirement> list = new List<Requirement>(); int num = 0; ItemDrop resItem = default(ItemDrop); foreach (DropData drop in mineRock.m_dropItems.m_drops) { if (num > 3) { break; } if (!((Object)(object)drop.m_item == (Object)null) && drop.m_item.TryGetComponent<ItemDrop>(ref resItem)) { list.Add(new Requirement { m_resItem = resItem, m_recover = true, m_amount = (int)((float)(drop.m_stackMax * childCount) * drop.m_weight), m_amountPerLevel = 1, m_extraAmountOnlyOneIngredient = 1 }); num++; } } piece.m_resources = list.ToArray(); } private static void SetRequirements(Fish fish, Piece piece) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_0053: 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_0062: Expected O, but got Unknown piece.m_name = fish.m_name; ItemDrop val = default(ItemDrop); if (((Component)fish).TryGetComponent<ItemDrop>(ref val)) { piece.m_description = val.m_itemData.m_shared.m_description; piece.m_resources = (Requirement[])(object)new Requirement[1] { new Requirement { m_resItem = val, m_recover = true, m_amount = 1, m_amountPerLevel = 1, m_extraAmountOnlyOneIngredient = 1 } }; } } private static void SetRequirements(Pickable component, Piece piece) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_0083: Expected O, but got Unknown GameObject itemPrefab = component.m_itemPrefab; ItemDrop val = default(ItemDrop); if (Object.op_Implicit((Object)(object)itemPrefab) && itemPrefab.TryGetComponent<ItemDrop>(ref val)) { piece.m_name = val.m_itemData.m_shared.m_name; piece.m_description = val.m_itemData.m_shared.m_description; piece.m_resources = (Requirement[])(object)new Requirement[1] { new Requirement { m_resItem = val, m_recover = true, m_amount = component.m_amount, m_amountPerLevel = 1, m_extraAmountOnlyOneIngredient = 1 } }; } } private static Requirement[] GetRequirements(TreeBase component) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_005f: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown List<Requirement> list = new List<Requirement>(); int num = 0; ItemDrop resItem = default(ItemDrop); foreach (DropData drop in component.m_dropWhenDestroyed.m_drops) { if (num > 3) { break; } if (!((Object)(object)drop.m_item == (Object)null) && drop.m_item.TryGetComponent<ItemDrop>(ref resItem)) { list.Add(new Requirement { m_resItem = resItem, m_recover = true, m_amount = drop.m_stackMax, m_amountPerLevel = 1, m_extraAmountOnlyOneIngredient = 1 }); num++; } } return list.ToArray(); } private static Requirement[] GetRequirements(MineRock5 component) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_00a7: 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_00bb: 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_00ce: Expected O, but got Unknown List<Requirement> list = new List<Requirement>(); int num = 0; int childCount = ((Component)component).transform.childCount; ItemDrop resItem = default(ItemDrop); foreach (DropData drop in component.m_dropItems.m_drops) { if (num > 3) { break; } if (!((Object)(object)drop.m_item == (Object)null) && drop.m_item.TryGetComponent<ItemDrop>(ref resItem)) { float num2 = drop.m_weight; if (num2 == 0f) { num2 = 1f; } list.Add(new Requirement { m_resItem = resItem, m_recover = true, m_amount = (int)((float)(drop.m_stackMax * childCount) * num2), m_amountPerLevel = 1, m_extraAmountOnlyOneIngredient = 1 }); num++; } } return list.ToArray(); } private static Requirement[] GetRequirements(DropOnDestroyed component) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_005f: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown List<Requirement> list = new List<Requirement>(); int num = 0; ItemDrop resItem = default(ItemDrop); foreach (DropData drop in component.m_dropWhenDestroyed.m_drops) { if (num > 3) { break; } if (!((Object)(object)drop.m_item == (Object)null) && drop.m_item.TryGetComponent<ItemDrop>(ref resItem)) { list.Add(new Requirement { m_resItem = resItem, m_recover = true, m_amount = drop.m_stackMax, m_amountPerLevel = 1, m_extraAmountOnlyOneIngredient = 1 }); num++; } } return list.ToArray(); } [<38234ec0-cf0a-4937-a412-d83163601bb7>NullableContext(2)] private static void AddWearNTear([<793b3815-081d-4ba3-ad9f-fef60d3789f2>Nullable(1)] GameObject prefab, [<793b3815-081d-4ba3-ad9f-fef60d3789f2>Nullable(1)] GameObject model, Destructible destructible = null, TreeBase treeBase = null, MineRock mineRock = null) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) WearNTear val = prefab.AddComponent<WearNTear>(); val.m_new = model; val.m_worn = model; val.m_broken = model; val.m_supports = true; val.m_noRoofWear = true; val.m_noSupportWear = true; val.m_materialType = (MaterialType)0; if ((Object)(object)destructible != (Object)null) { val.m_health = destructible.m_health * 10f; val.m_damages = destructible.m_damages; val.m_minToolTier = destructible.m_minToolTier; val.m_destroyedEffect = ((destructible.m_destroyedEffect.m_effectPrefabs.Length != 0) ? destructible.m_destroyedEffect : m_destroyedEffects); val.m_hitEffect = ((destructible.m_hitEffect.m_effectPrefabs.Length != 0) ? destructible.m_hitEffect : m_hitEffects); val.m_autoCreateFragments = destructible.m_autoCreateFragments; } else if ((Object)(object)treeBase != (Object)null) { val.m_health = treeBase.m_health * 10f; val.m_damages = treeBase.m_damageModifiers; val.m_minToolTier = treeBase.m_minToolTier; val.m_destroyedEffect = treeBase.m_destroyedEffect; val.m_hitEffect = treeBase.m_hitEffect; val.m_autoCreateFragments = true; } else if ((Object)(object)mineRock != (Object)null) { val.m_health = mineRock.m_health * 10f; val.m_damages = mineRock.m_damageModifiers; val.m_minToolTier = mineRock.m_minToolTier; val.m_destroyedEffect = mineRock.m_destroyedEffect; val.m_hitEffect = mineRock.m_hitEffect; val.m_autoCreateFragments = true; } else { val.m_health = 1000f; val.m_destroyedEffect = m_destroyedEffects; val.m_hitEffect = m_hitEffects; val.m_autoCreateFragments = true; } } private static string GetDisplayName(string name) { return GetPrefabName(name).Replace('_', ' '); } private static string GetPrefabName(string name) { List<string> wordsToRemove = new List<string> { "pickable", "hanging", "spawner", "event", "destructable", "alwayshatch" }; string[] source = name.ToLower().Split(new char[1] { '_' }); IEnumerable<string> values = source.Where([<38234ec0-cf0a-4937-a412-d83163601bb7>NullableContext(0)] (string word) => !wordsToRemove.Contains(word)); return string.Join("_", values); } private static bool HasCollider(GameObject prefab) { BoxCollider val = default(BoxCollider); if (prefab.TryGetComponent<BoxCollider>(ref val)) { return true; } val = prefab.GetComponentInChildren<BoxCollider>(); if ((Object)(object)val != (Object)null) { return true; } SphereCollider val2 = default(SphereCollider); if (prefab.TryGetComponent<SphereCollider>(ref val2)) { return true; } val2 = prefab.GetComponentInChildren<SphereCollider>(); return (Object)(object)val2 != (Object)null; } private static void SetLayer(GameObject prefab, LayerMask layer) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) if (LayerMask.LayerToName(prefab.layer) != "effect") { prefab.layer = LayerMask.op_Implicit(layer); } if (prefab.transform.childCount <= 0) { return; } foreach (Transform item in prefab.transform) { Transform val = item; SetLayer(((Component)val).gameObject, layer); } } private static void Register(GameObject prefab) { if (Object.op_Implicit((Object)(object)ZNetScene.instance)) { if (!ZNetScene.instance.m_prefabs.Contains(prefab)) { ZNetScene.instance.m_prefabs.Add(prefab); } ZNetScene.instance.m_namedPrefabs[StringExtensionMethods.GetStableHashCode(((Object)prefab).name)] = prefab; } } } } namespace BuildableNature.Managers { [<793b3815-081d-4ba3-ad9f-fef60d3789f2>Nullable(0)] [<38234ec0-cf0a-4937-a412-d83163601bb7>NullableContext(1)] public static class SpriteMan { public static void Snapshot(GameObject Prefab, float lightIntensity = 1.3f, Quaternion? cameraRotation = null) { SnapshotPiece(Prefab, lightIntensity, cameraRotation); } private static void SnapshotPiece(GameObject prefab, float lightIntensity = 1.3f, Quaternion? cameraRotation = null) { //IL_0055: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: 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_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Expected O, but got Unknown //IL_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_0431: Unknown result type (might be due to invalid IL or missing references) //IL_0436: Unknown result type (might be due to invalid IL or missing references) //IL_0440: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)prefab == (Object)null) && (prefab.GetComponentsInChildren<Renderer>().Any() || prefab.GetComponentsInChildren<MeshFilter>().Any())) { Camera component = new GameObject("CameraIcon", new Type[1] { typeof(Camera) }).GetComponent<Camera>(); component.backgroundColor = Color.clear; component.clearFlags = (CameraClearFlags)2; ((Component)component).transform.position = new Vector3(10000f, 10000f, 10000f); ((Component)component).transform.rotation = (Quaternion)(((??)cameraRotation) ?? Quaternion.Euler(0f, 180f, 0f)); component.fieldOfView = 0.5f; component.farClipPlane = 100000f; component.cullingMask = 8; Light component2 = new GameObject("LightIcon", new Type[1] { typeof(Light) }).GetComponent<Light>(); ((Component)component2).transform.position = new Vector3(10000f, 10000f, 10000f); ((Component)component2).transform.rotation = Quaternion.Euler(5f, 180f, 5f); component2.type = (LightType)1; component2.cullingMask = 8; component2.intensity = lightIntensity; GameObject val = Object.Instantiate<GameObject>(prefab); LodFadeInOut val2 = default(LodFadeInOut); if (val.TryGetComponent<LodFadeInOut>(ref val2)) { ((Behaviour)val2).enabled = false; } LODGroup val3 = default(LODGroup); if (val.TryGetComponent<LODGroup>(ref val3)) { val3.enabled = false; } LODGroup[] componentsInChildren = val.GetComponentsInChildren<LODGroup>(); foreach (LODGroup val4 in componentsInChildren) { val4.enabled = false; } Transform[] componentsInChildren2 = val.GetComponentsInChildren<Transform>(); foreach (Transform val5 in componentsInChildren2) { ((Component)val5).gameObject.layer = 3; } val.transform.position = Vector3.zero; val.transform.rotation = Quaternion.Euler(23f, 51f, 25.8f); ((Object)val).name = ((Object)prefab).name; MeshRenderer[] componentsInChildren3 = val.GetComponentsInChildren<MeshRenderer>(); Vector3 val6 = componentsInChildren3.Aggregate(Vector3.positiveInfinity, [<38234ec0-cf0a-4937-a412-d83163601bb7>NullableContext(0)] (Vector3 cur, MeshRenderer renderer) => { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) Bounds bounds2 = ((Renderer)renderer).bounds; return Vector3.Min(cur, ((Bounds)(ref bounds2)).min); }); Vector3 val7 = componentsInChildren3.Aggregate(Vector3.negativeInfinity, [<38234ec0-cf0a-4937-a412-d83163601bb7>NullableContext(0)] (Vector3 cur, MeshRenderer renderer) => { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) Bounds bounds = ((Renderer)renderer).bounds; return Vector3.Max(cur, ((Bounds)(ref bounds)).max); }); val.transform.position = new Vector3(10000f, 10000f, 10000f) - (val6 + val7) / 2f; Vector3 val8 = val7 - val6; TimedDestruction val9 = val.AddComponent<TimedDestruction>(); val9.Trigger(1f); Rect val10 = default(Rect); ((Rect)(ref val10))..ctor(0f, 0f, 128f, 128f); component.targetTexture = RenderTexture.GetTemporary((int)((Rect)(ref val10)).width, (int)((Rect)(ref val10)).height); component.fieldOfView = 20f; float num = Mathf.Max(val8.x, val8.y) + 0.1f; float num2 = num / Mathf.Tan(component.fieldOfView * ((float)Math.PI / 180f)) * 1.1f; ((Component)component).transform.position = new Vector3(10000f, 10000f, 10000f) + new Vector3(0f, 0f, num2); component.Render(); RenderTexture active = RenderTexture.active; RenderTexture.active = component.targetTexture; Texture2D val11 = new Texture2D((int)((Rect)(ref val10)).width, (int)((Rect)(ref val10)).height, (TextureFormat)4, false); val11.ReadPixels(new Rect(0f, 0f, (float)(int)((Rect)(ref val10)).width, (float)(int)((Rect)(ref val10)).height), 0, 0); val11.Apply(); RenderTexture.active = active; prefab.GetComponent<Piece>().m_icon = Sprite.Create(val11, new Rect(0f, 0f, (float)(int)((Rect)(ref val10)).width, (float)(int)((Rect)(ref val10)).height), Vector2.one / 2f); ((Component)component2).gameObject.SetActive(false); component.targetTexture.Release(); ((Component)component).gameObject.SetActive(false); val.SetActive(false); ZNetScene.instance.Destroy(val); Object.Destroy((Object)(object)component); Object.Destroy((Object)(object)component2); Object.Destroy((Object)(object)((Component)component).gameObject); Object.Destroy((Object)(object)((Component)component2).gameObject); } } } } namespace BuildableBossStone.Managers { [<38234ec0-cf0a-4937-a412-d83163601bb7>NullableContext(1)] [<793b3815-081d-4ba3-ad9f-fef60d3789f2>Nullable(0)] public static class CategoryMan { private static readonly Dictionary<string, PieceCategory> PieceCategories; private static readonly Dictionary<string, PieceCategory> OtherPieceCategories; static CategoryMan() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown //IL_00b1: Expected O, but got Unknown //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Expected O, but got Unknown //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Expected O, but got Unknown PieceCategories = new Dictionary<string, PieceCategory>(); OtherPieceCategories = new Dictionary<string, PieceCategory>(); Harmony val = new Harmony("org.bepinex.helpers.CategoryManager"); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(PieceTable), "UpdateAvailable", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CategoryMan), "UpdateAvailable_Transpiler", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(PieceTable), "UpdateAvailable", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CategoryMan), "UpdateAvailable_Prefix", (Type[])null, (Type[])null)), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CategoryMan), "UpdateAvailable_Postfix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Player), "SetPlaceMode", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CategoryMan), "Patch_SetPlaceMode", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Hud), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CategoryMan), "Hud_AwakeCreateTabs", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Enum), "GetValues", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CategoryMan), "EnumGetValuesPatch", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Enum), "GetNames", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CategoryMan), "EnumGetNamesPatch", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } public static Dictionary<PieceCategory, string> GetPieceCategoriesMap() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) Array values = Enum.GetValues(typeof(PieceCategory)); string[] names = Enum.GetNames(typeof(PieceCategory)); Dictionary<PieceCategory, string> dictionary = new Dictionary<PieceCategory, string>(); for (int i = 0; i < values.Length; i++) { dictionary[(PieceCategory)values.GetValue(i)] = names[i]; } return dictionary; } public static PieceCategory GetCategory(string name) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) if (Enum.TryParse<PieceCategory>(name, ignoreCase: true, out PieceCategory result)) { return result; } if (PieceCategories.TryGetValue(name, out result)) { return result; } if (OtherPieceCategories.TryGetValue(name, out result)) { return result; } Dictionary<PieceCategory, string> pieceCategoriesMap = GetPieceCategoriesMap(); foreach (KeyValuePair<PieceCategory, string> item in pieceCategoriesMap) { if (item.Value == name) { result = item.Key; OtherPieceCategories[name] = result; return result; } } result = (PieceCategory)(pieceCategoriesMap.Count - 1); PieceCategories[name] = result; string categoryToken = GetCategoryToken(name); Localization.instance.AddWord(categoryToken, name); return result; } private static void EnumGetValuesPatch(Type enumType, ref Array __result) { if (!(enumType != typeof(PieceCategory)) && PieceCategories.Count != 0) { PieceCategory[] array = (PieceCategory[])(object)new PieceCategory[__result.Length + PieceCategories.Count]; __result.CopyTo(array, 0); PieceCategories.Values.CopyTo(array, __result.Length); __result = array; } } private static void EnumGetNamesPatch(Type enumType, ref string[] __result) { if (!(enumType != typeof(PieceCategory)) && PieceCategories.Count != 0) { __result = CollectionExtensions.AddRangeToArray<string>(__result, PieceCategories.Keys.ToArray()); } } [HarmonyPriority(200)] private static void Hud_AwakeCreateTabs() { CreateCategoryTabs(); } private static void CreateCategoryTabs() { int num = ModifiedMaxCategory(); for (int i = Hud.instance.m_pieceCategoryTabs.Length; i < num; i++) { GameObject val = CreateCategoryTab(); Hud.instance.m_pieceCategoryTabs = CollectionExtensions.AddItem<GameObject>((IEnumerable<GameObject>)Hud.instance.m_pieceCategoryTabs, val).ToArray(); } if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && Object.op_Implicit((Object)(object)Player.m_localPlayer.m_buildPieces)) { RepositionCategories(Player.m_localPlayer.m_buildPieces); Player.m_localPlayer.UpdateAvailablePiecesList(); } } private static GameObject CreateCategoryTab() { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) Transform transform = Hud.instance.m_pieceCategoryRoot.transform; GameObject val = Object.Instantiate<GameObject>(Hud.instance.m_pieceCategoryTabs[0], transform); val.SetActive(false); UIInputHandler orAddComponent = val.GetOrAddComponent<UIInputHandler>(); orAddComponent.m_onLeftDown = (Action<UIInputHandler>)Delegate.Combine(orAddComponent.m_onLeftDown, new Action<UIInputHandler>(Hud.instance.OnLeftClickCategory)); TMP_Text[] componentsInChildren = val.GetComponentsInChildren<TMP_Text>(); foreach (TMP_Text val2 in componentsInChildren) { val2.rectTransform.offsetMin = new Vector2(3f, 1f); val2.rectTransform.offsetMax = new Vector2(-3f, -1f); val2.enableAutoSizing = true; val2.fontSizeMin = 12f; val2.fontSizeMax = 20f; val2.lineSpacing = 0.8f; val2.textWrappingMode = (TextWrappingModes)1; val2.overflowMode = (TextOverflowModes)3; } return val; } private static void UpdateAvailable_Prefix(PieceTable __instance) { if (__instance.m_availablePieces.Count > 0) { int num = ModifiedMaxCategory() - __instance.m_availablePieces.Count; for (int i = 0; i < num; i++) { __instance.m_availablePieces.Add(new List<Piece>()); } } } private static void UpdateAvailable_Postfix(PieceTable __instance) { Array.Resize(ref __instance.m_selectedPiece, __instance.m_availablePieces.Count); Array.Resize(ref __instance.m_lastSelectedPiece, __instance.m_availablePieces.Count); } private static void Patch_SetPlaceMode(Player __instance) { if (Object.op_Implicit((Object)(object)__instance.m_buildPieces)) { RepositionCategories(__instance.m_buildPieces); } } private static void InitializeDefaultCategories(PieceTable pieceTable) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)pieceTable == (Object)null) { return; } HashSet<PieceCategory> source = new HashSet<PieceCategory>(from category in CategoriesInPieceTable(pieceTable) where (int)category != 100 && (int)category != 8 select category); foreach (PieceCategory item in source.ToList()) { string categoryLabel = GetCategoryLabel(item); if (!string.IsNullOrWhiteSpace(categoryLabel) && !pieceTable.m_categories.Contains(item)) { pieceTable.m_categories.Add(item); pieceTable.m_categoryLabels.Add(categoryLabel); } } } private static string GetCategoryLabel(PieceCategory category) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected I4, but got Unknown if (1 == 0) { } string result = (int)category switch { 0 => "$hud_misc", 1 => "$hud_crafting", 2 => "$hud_building", 3 => "$hud_building2", 4 => "$hud_furniture", 5 => "$hud_feasts", 7 => "$hud_meads", 6 => "$hud_food", _ => "", }; if (1 == 0) { } return result; } private static void RepositionCategories(PieceTable pieceTable) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Expected O, but got Unknown //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) InitializeDefaultCategories(pieceTable); RectTransform val = (RectTransform)Hud.instance.m_pieceCategoryTabs[0].transform; RectTransform val2 = (RectTransform)Hud.instance.m_pieceCategoryRoot.transform; RectTransform val3 = (RectTransform)Hud.instance.m_pieceSelectionWindow.transform; HorizontalLayoutGroup val4 = default(HorizontalLayoutGroup); if (((Component)((Transform)val).parent).TryGetComponent<HorizontalLayoutGroup>(ref val4)) { Object.DestroyImmediate((Object)(object)val4); } Rect rect = val.rect; Vector2 size = ((Rect)(ref rect)).size; GridLayoutGroup val5 = default(GridLayoutGroup); GridLayoutGroup val6 = (((Component)((Transform)val).parent).TryGetComponent<GridLayoutGroup>(ref val5) ? val5 : ((Component)((Transform)val).parent).gameObject.AddComponent<GridLayoutGroup>()); val6.cellSize = size; val6.spacing = new Vector2(0f, 1f); val6.constraint = (Constraint)1; val6.constraintCount = 5; ((LayoutGroup)val6).childAlignment = (TextAnchor)4; HashSet<PieceCategory> hashSet = CategoriesInPieceTable(pieceTable); UpdatePieceTableCategories(pieceTable, hashSet); rect = val2.rect; int num = Mathf.Max((int)(((Rect)(ref rect)).width / size.x), 1); int count = pieceTable.m_categories.Count; float num2 = (0f - size.x) * (float)num / 2f + size.x / 2f; float num3 = (size.y + 1f) * Mathf.Floor((float)(count - 1) / (float)num) + 5f; Vector2 val7 = default(Vector2); ((Vector2)(ref val7))..ctor(num2, num3); int num4 = Mathf.CeilToInt((float)count / (float)num); float num5 = (size.y + 1f) * (float)num4; RectTransform component = ((Component)((Transform)val).parent).GetComponent<RectTransform>(); component.anchoredPosition = new Vector2(component.anchoredPosition.x, num5 / 2f); int num6 = 0; for (int i = 0; i < Hud.instance.m_pieceCategoryTabs.Length; i++) { GameObject val8 = Hud.instance.m_pieceCategoryTabs[i]; if ((Object)(object)val8 == (Object)null) { continue; } if (i >= pieceTable.m_categories.Count) { val8.SetActive(false); continue; } PieceCategory item = pieceTable.m_categories[i]; string text = pieceTable.m_categoryLabels[i]; if (hashSet.Contains(item)) { num6++; } val8.GetComponentInChildren<TMP_Text>().text = Localization.instance.Localize(text); } Transform obj = ((Transform)val3).Find("Bkg2"); RectTransform val9 = (RectTransform)((obj != null) ? ((Component)obj).transform : null); if (Object.op_Implicit((Object)(object)val9)) { float num7 = (size.y + 1f) * (float)Mathf.Max(0, Mathf.FloorToInt((float)(num6 - 1) / (float)num)); val9.offsetMax = new Vector2(val9.offsetMax.x, num7); } else { Debug.LogWarning((object)"RefreshCategories: Could not find background image"); } ((Component)Hud.instance).GetComponentInParent<Localize>().RefreshLocalization(); } private static void UpdatePieceTableCategories(PieceTable pieceTable, HashSet<PieceCategory> visibleCategories) { //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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair<string, PieceCategory> pieceCategory in PieceCategories) { string key = pieceCategory.Key; PieceCategory value = pieceCategory.Value; if (visibleCategories.Contains(value) && !pieceTable.m_categories.Contains(value)) { pieceTable.m_categories.Add(value); pieceTable.m_categoryLabels.Add("$" + GetCategoryToken(key)); } if (visibleCategories.Contains(value) && !pieceTable.m_categoryLabels.Contains("$" + GetCategoryToken(key))) { pieceTable.m_categoryLabels.Add("$" + GetCategoryToken(key)); } if (!visibleCategories.Contains(value) && pieceTable.m_categories.Contains(value)) { int index = pieceTable.m_categories.IndexOf(value); pieceTable.m_categories.RemoveAt(index); pieceTable.m_categoryLabels.RemoveAt(index); } } } private static HashSet<PieceCategory> CategoriesInPieceTable(PieceTable pieceTable) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) HashSet<PieceCategory> hashSet = new HashSet<PieceCategory>(); foreach (GameObject piece in pieceTable.m_pieces) { hashSet.Add(piece.GetComponent<Piece>().m_category); } return hashSet; } private static string GetCategoryToken(string name) { char[] endChars = Localization.instance.m_endChars; string text = string.Concat(name.ToLower().Split(endChars)); return "piecemanager_cat_" + text; } private static IEnumerable<CodeInstruction> UpdateAvailable_Transpiler(IEnumerable<CodeInstruction> instructions) { return TranspileMaxCategory(instructions, 0); } private static List<CodeInstruction> TranspileMaxCategory(IEnumerable<CodeInstruction> instructions, int maxOffset) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown int num = GetMaxCategoryOrDefault() + maxOffset; List<CodeInstruction> list = new List<CodeInstruction>(); foreach (CodeInstruction instruction in instructions) { if (CodeInstructionExtensions.LoadsConstant(instruction, (long)num)) { list.Add(new CodeInstruction(OpCodes.Call, (object)AccessTools.DeclaredMethod(typeof(CategoryMan), "ModifiedMaxCategory", (Type[])null, (Type[])null))); if (maxOffset != 0) { list.Add(new CodeInstruction(OpCodes.Ldc_I4, (object)maxOffset)); list.Add(new CodeInstruction(OpCodes.Add, (object)null)); } } else { list.Add(instruction); } } return list; } private static int ModifiedMaxCategory() { return Enum.GetValues(typeof(PieceCategory)).Length - 1; } private static int GetMaxCategoryOrDefault() { try { return (int)Enum.Parse(typeof(PieceCategory), "Max"); } catch (ArgumentException) { Debug.LogWarning((object)"Could not find Piece.PieceCategory.Max, using fallback value 4"); return 4; } } } public static class GoExtensions { [<38234ec0-cf0a-4937-a412-d83163601bb7>NullableContext(1)] public static T GetOrAddComponent<[<793b3815-081d-4ba3-ad9f-fef60d3789f2>Nullable(0)] T>(this GameObject gameObject) where T : Component { return gameObject.GetComponent<T>() ?? gameObject.AddComponent<T>(); } } } namespace Microsoft.CodeAnalysis { [<8aec07fd-7d62-477d-8807-351117cbf2bc>Embedded] [CompilerGenerated] internal sealed class <8aec07fd-7d62-477d-8807-351117cbf2bc>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] [CompilerGenerated] [<8aec07fd-7d62-477d-8807-351117cbf2bc>Embedded] internal sealed class <57d64954-433d-443d-b35e-1c4b8943fe0a>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <57d64954-433d-443d-b35e-1c4b8943fe0a>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <57d64954-433d-443d-b35e-1c4b8943fe0a>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [<8aec07fd-7d62-477d-8807-351117cbf2bc>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class <b0357389-bc80-4831-ae36-bd269c33670e>NullableContextAttribute : Attribute { public readonly byte Flag; public <b0357389-bc80-4831-ae36-bd269c33670e>NullableContextAttribute(byte P_0) { Flag = P_0; } } [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] [CompilerGenerated] [<8aec07fd-7d62-477d-8807-351117cbf2bc>Embedded] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ServerSync { [PublicAPI] [<57d64954-433d-443d-b35e-1c4b8943fe0a>Nullable(0)] [<b0357389-bc80-4831-ae36-bd269c33670e>NullableContext(1)] internal abstract class OwnConfigEntryBase { [<57d64954-433d-443d-b35e-1c4b8943fe0a>Nullable(2)] public object LocalBaseValue; public bool SynchronizedConfig = true; public abstract ConfigEntryBase BaseConfig { get; } } [<57d64954-433d-443d-b35e-1c4b8943fe0a>Nullable(0)] [PublicAPI] [<b0357389-bc80-4831-ae36-bd269c33670e>NullableContext(1)] internal class SyncedConfigEntry<[<57d64954-433d-443d-b35e-1c4b8943fe0a>Nullable(2)] T> : OwnConfigEntryBase { public readonly ConfigEntry<T> SourceConfig; public override ConfigEntryBase BaseConfig => (ConfigEntryBase)(object)SourceConfig; public T Value { get { return SourceConfig.Value; } set { SourceConfig.Value = value; } } public SyncedConfigEntry(ConfigEntry<T> sourceConfig) { SourceConfig = sourceConfig; } public void AssignLocalValue(T value) { if (LocalBaseValue == null) { Value = value; } else { LocalBaseValue = value; } } } [<57d64954-433d-443d-b35e-1c4b8943fe0a>Nullable(0)] [<b0357389-bc80-4831-ae36-bd269c33670e>NullableContext(2)] internal abstract class CustomSyncedValueBase { public object LocalBaseValue; [<57d64954-433d-443d-b35e-1c4b8943fe0a>Nullable(1)] public readonly string Identifier; [<57d64954-433d-443d-b35e-1c4b8943fe0a>Nullable(1)] public readonly Type Type; private object boxedValue; protected bool localIsOwner; public readonly int Priority; public object BoxedValue { get { return boxedValue; } set { boxedValue = value; this.ValueChanged?.Invoke(); } } public event Action ValueChanged; [<b0357389-bc80-4831-ae36-bd269c33670e>NullableContext(1)] protected CustomSyncedValueBase(ConfigSync configSync, string identifier, Type type, int priority) { Priority = priority; Identifier = identifier; Type = type; configSync.AddCustomValue(this); localIsOwner = configSync.IsSourceOfTruth; configSync.SourceOfTruthChanged += delegate(bool truth) { localIsOwner = truth; }; } } [PublicAPI] [<b0357389-bc80-4831-ae36-bd269c33670e>NullableContext(1)] [<57d64954-433d-443d-b35e-1c4b8943fe0a>Nullable(0)] internal sealed class CustomSyncedValue<[<57d64954-433d-443d-b35e-1c4b8943fe0a>Nullable(2)] T> : CustomSyncedValueBase { public T Value { get { return (T)base.BoxedValue; } set { base.BoxedValue = value; } } public CustomSyncedValue(ConfigSync configSync, string identifier, T value = default(T), int priority = 0) : base(configSync, identifier, typeof(T), priority) { Value = value; } public void AssignLocalValue(T value) { if (localIsOwner) { Value = value; } else { LocalBaseValue = value; } } } internal class ConfigurationManagerAttributes { [UsedImplicitly] public bool? ReadOnly = false; } [PublicAPI] [<57d64954-433d-443d-b35e-1c4b8943fe0a>Nullable(0)] [<b0357389-bc80-4831-ae36-bd269c33670e>NullableContext(1)] internal class ConfigSync { [<b0357389-bc80-4831-ae36-bd269c33670e>NullableContext(0)] [HarmonyPatch(typeof(ZRpc), "HandlePackage")] private static class SnatchCurrentlyHandlingRPC { [<57d64954-433d-443d-b35e-1c4b8943fe0a>Nullable(2)] public static ZRpc currentRpc; [HarmonyPrefix] [<b0357389-bc80-4831-ae36-bd269c33670e>NullableContext(1)] private static void Prefix(ZRpc __instance) { currentRpc = __instance; } } [<b0357389-bc80-4831-ae36-bd269c33670e>NullableContext(0)] [HarmonyPatch(typeof(ZNet), "Awake")] internal static class RegisterRPCPatch { [<b0357389-bc80-4831-ae36-bd269c33670e>NullableContext(1)] [HarmonyPostfix] private static void Postfix(ZNet __instance) { isServer = __instance.IsServer(); foreach (ConfigSync configSync2 in configSyncs) { ZRoutedRpc.instance.Register<ZPackage>(configSync2.Name + " ConfigSync", (Action<long, ZPackage>)configSync2.RPC_FromOtherClientConfigSync); if (isServer) { configSync2.InitialSyncDone = true; Debug.Log((object)("Registered '" + configSync2.Name + " ConfigSync' RPC - waiting for incoming connections")); } } if (isServer) { ((MonoBehaviour)__instance).StartCoroutine(WatchAdminListChanges()); } [<b0357389-bc80-4831-ae36-bd269c33670e>NullableContext(1)] static void SendAdmin(List<ZNetPeer> peers, bool isAdmin) { ZPackage package = ConfigsToPackage(null, null, new PackageEntry[1] { new PackageEntry { section = "Internal", key = "lockexempt", type = typeof(bool), value = isAdmin } }); ConfigSync configSync = configSyncs.First(); if (configSync != null) { ((MonoBehaviour)ZNet.instance).StartCoroutine(configSync.sendZPackage(peers, package)); } } [<b0357389-bc80-4831-ae36-bd269c33670e>NullableContext(1)] static IEnumerator WatchAdminListChanges() { SyncedList adminList = (SyncedList)AccessTools.DeclaredField(typeof(ZNet), "m_adminList").GetValue(ZNet.instance); List<string> CurrentList = new List<string>(adminList.GetList()); while (true) { yield return (object)new WaitForSeconds(30f); if (!adminList.GetList().SequenceEqual(CurrentList)) { CurrentList = new List<string>(adminList.GetList()); List<ZNetPeer> adminPeer = (from p in ZNet.instance.GetPeers() where adminList.Contains(p.m_rpc.GetSocket().GetHostName()) select p).ToList(); List<ZNetPeer> nonAdminPeer = ZNet.instance.GetPeers().Except(adminPeer).ToList(); SendAdmin(nonAdminPeer, isAdmin: false); SendAdmin(adminPeer, isAdmin: true); } } } } } [HarmonyPatch(typeof(ZNet), "OnNewConnection")] [<b0357389-bc80-4831-ae36-bd269c33670e>NullableContext(0)] private static class RegisterClientRPCPatch { [HarmonyPostfix] [<b0357389-bc80-4831-ae36-bd269c33670e>NullableContext(1)] private static void Postfix(ZNet __instance, ZNetPeer peer) { if (__instance.IsServer()) { return; } foreach (ConfigSync configSync in configSyncs) { peer.m_rpc.Register<ZPackage>(configSync.Name + " ConfigSync", (Action<ZRpc, ZPackage>)configSync.RPC_FromServerConfigSync); } } } [<b0357389-bc80-4831-ae36-bd269c33670e>NullableContext(0)] private class ParsedConfigs { [<57d64954-433d-443d-b35e-1c4b8943fe0a>Nullable(new byte[] { 1, 1, 2 })] public readonly Dictionary<OwnConfigEntryBase, object> configValues = new Dictionary<OwnConfigEntryBase, object>(); [<57d64954-433d-443d-b35e-1c4b8943fe0a>Nullable(new byte[] { 1, 1, 2 })] public readonly Dictionary<CustomSyncedValueBase, object> customValues = new Dictionary<CustomSyncedValueBase, object>(); } [<b0357389-bc80-4831-ae36-bd269c33670e>NullableContext(0)] [HarmonyPatch(typeof(ZNet), "Shutdown")] private class ResetConfigsOnShutdown { [HarmonyPostfix] private static void Postfix() { ProcessingServerUpdate = true; foreach (ConfigSync configSync in configSyncs) { configSync.resetConfigsFromServer(); configSync.IsSourceOfTruth = true; configSync.InitialSyncDone = false; } ProcessingServerUpdate = false; } } [<57d64954-433d-443d-b35e-1c4b8943fe0a>Nullable(0)] [HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")] private class SendConfigsAfterLogin { [<57d64954-433d-443d-b35e-1c4b8943fe0a>Nullable(0)] private class BufferingSocket : ISocket { public volatile bool finished = false; public volatile int versionMatchQueued = -1; public readonly List<ZPackage> Package = new List<ZPackage>(); public readonly ISocket Original; public BufferingSocket(ISocket original) { Original = original; } public bool IsConnected() { return Original.IsConnected(); } public ZPackage Recv() { return Original.Recv(); } public int GetSendQueueSize() { return Original.GetSendQueueSize(); } public int GetCurrentSendRate() { return Original.GetCurrentSendRate(); } public bool IsHost() { return Original.IsHost(); } public void Dispose() { Original.Dispose(); } public bool GotNewData() { return Original.GotNewData(); } public void Close() { Original.Close(); } public string GetEndPointString() { return Original.GetEndPointString(); } public void GetAndResetStats(out int totalSent, out int totalRecv) { Original.GetAndResetStats(ref totalSent, ref totalRecv); } public void GetConnectionQuality(out float localQuality, out float remoteQuality, out int ping, out float outByteSec, out float inByteSec) { Original.GetConnectionQuality(ref localQuality, ref remoteQuality, ref ping, ref outByteSec, ref inByteSec); } public ISocket Accept() { return Original.Accept(); } public int GetHostPort() { return Original.GetHostPort(); } public bool Flush() { return Original.Flush(); } public string GetHostName() { return Original.GetHostName(); } public void VersionMatch() { if (finished) { Original.VersionMatch(); } else { versionMatchQueued = Package.Count; } } public void Send(ZPackage pkg) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown int pos = pkg.GetPos(); pkg.SetPos(0); int num = pkg.ReadInt(); if ((num == StringExtensionMethods.GetStableHashCode("PeerInfo") || num == StringExtensionMethods.GetStableHashCode("RoutedRPC") || num == StringExtensionMethods.GetStableHashCode("ZDOData")) && !finished) { ZPackage val = new ZPackage(pkg.GetArray()); val.SetPos(pos); Package.Add(val); } else { pkg.SetPos(pos); Original.Send(pkg); } } } [HarmonyPriority(800)] [HarmonyPrefix] private static void Prefix([<57d64954-433d-443d-b35e-1c4b8943fe0a>Nullable(new byte[] { 2, 1, 1 })] ref Dictionary<Assembly, BufferingSocket> __state, ZNet __instance, ZRpc rpc) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Invalid comparison between Unknown and I4 if (__instance.IsServer()) { BufferingSocket value = new BufferingSocket(rpc.GetSocket()); AccessTools.DeclaredField(typeof(ZRpc), "m_socket").SetValue(rpc, value); object? obj = AccessTools.DeclaredMethod(typeof(ZNet), "GetPeer", new Type[1] { typeof(ZRpc) }, (Type[])null).Invoke(__instance, new object[1] { rpc }); ZNetPeer val = (ZNetPeer)((obj is ZNetPeer) ? obj : null); if (val != null && (int)ZNet.m_onlineBackend > 0) { AccessTools.DeclaredField(typeof(ZNetPeer), "m_socket").SetValue(val, value); } if (__state == null) { __state = new Dictionary<Assembly, BufferingSocket>(); } __state[Assembly.GetExecutingAssembly()] = value; } } [HarmonyPostfix] private static void Postfix(Dictionary<Assembly, BufferingSocket> __state, ZNet __instance, ZRpc rpc) { ZNetPeer peer; if (__instance.IsServer()) { object obj = AccessTools.DeclaredMethod(typeof(ZNet), "GetPeer", new Type[1] { typeof(ZRpc) }, (Type[])null).Invoke(__instance, new object[1] { rpc }); peer = (ZNetPeer)((obj is ZNetPeer) ? obj : null); if (peer == null) { SendBufferedData(); } else { ((MonoBehaviour)__instance).StartCoroutine(sendAsync()); } } void SendBufferedData() { if (rpc.GetSocket() is BufferingSocket bufferingSocket) { AccessTools.DeclaredField(typeof(ZRpc), "m_socket").SetValue(rpc, bufferingSocket.Original); object? obj2 = AccessTools.DeclaredMethod(typeof(ZNet), "GetPeer", new Type[1] { typeof(ZRpc) }, (Type[])null).Invoke(__instance, new object[1] { rpc }); ZNetPeer val = (ZNetPeer)((obj2 is ZNetPeer) ? obj2 : null); if (val != null) { AccessTools.DeclaredField(typeof(ZNetPeer), "m_socket").SetValue(val, bufferingSocket.Original); } } BufferingSocket bufferingSocket2 = __state[Assembly.GetExecutingAssembly()]; bufferingSocket2.finished = true; for (int i = 0; i < bufferingSocket2.Package.Count; i++) { if (i == bufferingSocket2.versionMatchQueued) { bufferingSocket2.Original.VersionMatch(); } bufferingSocket2.Original.Send(bufferingSocket2.Package[i]); } if (bufferingSocket2.Package.Count == bufferingSocket2.versionMatchQueued) { bufferingSocket2.Original.VersionMatch(); } } IEnumerator sendAsync() { foreach (ConfigSync configSync in configSyncs) { List<PackageEntry> entries = new List<PackageEntry>(); if (configSync.CurrentVersion != null) { entries.Add(new PackageEntry { section = "Internal", key = "serverversion", type = typeof(string), value = configSync.CurrentVersion }); } MethodInfo listContainsId = AccessTools.DeclaredMethod(typeof(ZNet), "ListContainsId", (Type[])null, (Type[])null); SyncedList adminList = (SyncedList)AccessTools.DeclaredField(typeof(ZNet), "m_adminList").GetValue(ZNet.instance); entries.Add(new PackageEntry { section = "Internal", key = "lockexempt", type = typeof(bool), value = (((object)listContainsId == null) ? ((object)adminList.Contains(rpc.GetSocket().GetHostName())) : listContainsId.Invoke(ZNet.instance, new object[2] { adminList, rpc.GetSocket().GetHostName() })) }); ZPackage package = ConfigsToPackage(configSync.allConfigs.Select([<b0357389-bc80-4831-ae36-bd269c33670e>NullableContext(0)] (OwnConfigEntryBase c) => c.BaseConfig), configSync.allCustomValues, entries, partial: false); yield return ((MonoBehaviour)__instance).StartCoroutine(configSync.sendZPackage(new List<ZNetPeer> { peer }, package)); } SendBufferedData(); } } } [<57d64954-433d-443d-b35e-1c4b8943fe0a>Nullable(0)] private class PackageEntry { public string section = null; public string key = null; public Type type = null; [<57d64954-433d-443d-b35e-1c4b8943fe0a>Nullable(2)] public object value; } [<b0357389-bc80-4831-ae36-bd269c33670e>NullableContext(0)] [HarmonyPatch(typeof(ConfigEntryBase), "GetSerializedValue")] private static class PreventSavingServerInfo { [<b0357389-bc80-4831-ae36-bd269c33670e>NullableContext(1)] [HarmonyPrefix] private static bool Prefix(ConfigEntryBase __instance, ref string __result) { OwnConfigEntryBase ownConfigEntryBase = configData(__instance); if (ownConfigEntryBase == null || isWritableConfig(ownConfigEntryBase)) { return true; } __result = TomlTypeConverter.ConvertToString(ownConfigEntryBase.LocalBaseValue, __instance.SettingType); return false; } } [<b0357389-bc80-4831-ae36-bd269c33670e>NullableContext(0)] [HarmonyPatch(typeof(ConfigEntryBase), "SetSerializedValue")] private static class PreventConfigRereadChangingValues { [<b0357389-bc80-4831-ae36-bd269c33670e>NullableContext(1)] [HarmonyPrefix] private static bool Prefix(ConfigEntryBase __instance, string value) { OwnConfigEntryBase ownConfigEntryBase = configData(__instance); if (ownConfigEntryBase == null || ownConfigEntryBase.LocalBaseValue == null) { return true; } try { ownConfigEntryBase.LocalBaseValue = TomlTypeConverter.ConvertToValue(value, __instance.SettingType); } catch (Exception ex) { Debug.LogWarning((object)$"Config value of setting \"{__instance.Definition}\" could not be parsed and will be ignored. Reason: {ex.Message}; Value: {value}"); } return false; } } [<57d64954-433d-443d-b35e-1c4b8943fe0a>Nullable(0)] private class InvalidDeserializationTypeException : Exception { public string expected = null; public string received = null; public string field = ""; } public static bool ProcessingServerUpdate; public readonly string Name; [<57d64954-433d-443d-b35e-1c4b8943fe0a>Nullable(2)] public string DisplayName; [<57d64954-433d-443d-b35e-1c4b8943fe0a>Nullable(2)] public string CurrentVersion; [<57d64954-433d-443d-b35e-1c4b8943fe0a>Nullable(2)] public string MinimumRequiredVersion; public bool ModRequired = false; private bool? forceConfigLocking; private bool isSourceOfTruth = true; private static readonly HashSet<ConfigSync> configSyncs; private readonly HashSet<OwnConfigEntryBase> allConfigs = new HashSet<OwnConfigEntryBase>(); private HashSet<CustomSyncedValueBase> allCustomValues = new HashSet<CustomSyncedValueBase>(); private static bool isServer; private static bool lockExempt; [<57d64954-433d-443d-b35e-1c4b8943fe0a>Nullable(2)] private OwnConfigEntryBase lockedConfig = null; private const byte PARTIAL_CONFIGS = 1; private const byte FRAGMENTED_CONFIG = 2; private const byte COMPRESSED_CONFIG = 4; private readonly Dictionary<string, SortedDictionary<int, byte[]>> configValueCache = new Dictionary<string, SortedDictionary<int, byte[]>>(); [<57d64954-433d-443d-b35e-1c4b8943fe0a>Nullable(new byte[] { 1, 0, 1 })] private readonly List<KeyValuePair<long, string>> cacheExpirations = new List<KeyValuePair<long, string>>(); private static long packageCounter; public bool IsLocked { get { bool? flag = forceConfigLocking; bool num; if (!flag.HasValue) { if (lockedConfig == null) { goto IL_0052; } num = ((IConvertible)lockedConfig.BaseConfig.BoxedValue).ToInt32(CultureInfo.InvariantCulture) != 0; } else { num = flag.GetValueOrDefault(); } if (!num) { goto IL_0052; } int result = ((!lockExempt) ? 1 : 0); goto IL_0053; IL_0053: return (byte)result != 0; IL_0052: result = 0; goto IL_0053; } set { forceConfigLocking = value; } } public bool IsAdmin => lockExempt || isSourceOfTruth; public bool IsSourceOfTruth { get { return isSourceOfTruth; } private set { if (value != isSourceOfTruth) { isSourceOfTruth = value; this.SourceOfTruthChanged?.Invoke(value); } } } public bool InitialSyncDone { get; private set; } = false; [<57d64954-433d-443d-b35e-1c4b8943fe0a>Nullable(2)] [method: <b0357389-bc80-4831-ae36-bd269c33670e>NullableContext(2)] [field: <57d64954-433d-443d-b35e-1c4b8943fe0a>Nullable(2)] public event Action<bool> SourceOfTruthChanged; [<57d64954-433d-443d-b35e-1c4b8943fe0a>Nullable(2)] [method: <b0357389-bc80-4831-ae36-bd269c33670e>NullableContext(2)] [field: <57d64954-433d-443d-b35e-1c4b8943fe0a>Nullable(2)] private event Action lockedConfigChanged; static ConfigSync() { ProcessingServerUpdate = false; configSyncs = new HashSet<ConfigSync>(); lockExempt = false; packageCounter = 0L; RuntimeHelpers.RunClassConstructor(typeof(VersionCheck).TypeHandle); } public ConfigSync(string name) { Name = name; configSyncs.Add(this); new VersionCheck(this); } public SyncedConfigEntry<T> AddConfigEntry<[<57d64954-433d-443d-b35e-1c4b8943fe0a>Nullable(2)] T>(ConfigEntry<T> configEntry) { OwnConfigEntryBase ownConfigEntryBase = configData((ConfigEntryBase)(object)configEntry); SyncedConfigEntry<T> syncedEntry = ownConfigEntryBase as SyncedConfigEntry<T>; if (syncedEntry == null) { syncedEntry = new SyncedConfigEntry<T>(configEntry); AccessTools.DeclaredField(typeof(ConfigDescription), "<Tags>k__BackingField").SetValue(((ConfigEntryBase)configEntry).Description, new object[1] { new ConfigurationManagerAttributes() }.Concat(((ConfigEntryBase)configEntry).Description.Tags ?? Array.Empty<object>()).Concat(new SyncedConfigEntry<T>[1] { syncedEntry }).ToArray()); configEntry.SettingChanged += [<b0357389-bc80-4831-ae36-bd269c33670e>NullableContext(0)] (object _, EventArgs _) => { if (!ProcessingServerUpdate && syncedEntry.SynchronizedConfig) { Broadcast(ZRoutedRpc.Everybody, (ConfigEntryBase)configEntry); } }; allConfigs.Add(syncedEntry); } return syncedEntry; } public SyncedConfigEntry<T> AddLockingConfigEntry<[<57d64954-433d-443d-b35e-1c4b8943fe0a>Nullable(0)] T>(ConfigEntry<T> lockingConfig) where T : IConvertible { if (lockedConfig != null) {