Please disclose if your mod was created primarily using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of LegacyWard v1.1.5
LegacyWard.dll
Decompiled 3 weeks 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.Collections.Specialized; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Dynamic; 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.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Xml.Serialization; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HarmonyLib; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using ServerSync; using Splatform; using TMPro; using UnityEngine; using UnityEngine.UI; using WardIsLove.API; using WardIsLove.Util; 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; using fastJSON; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("WackyMole.LegacyWard")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyProduct("WackyMole.LegacyWard")] [assembly: AssemblyCopyright("Copyright © 2022")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("6f2b2d0b-4966-4da0-8a8b-3a7818aea153")] [assembly: AssemblyFileVersion("1.1.5")] [assembly: AssemblyCompany("WackyMole")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.5.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<8dcdc875-2955-4efe-ac27-5039b44b3f14>Embedded] internal sealed class <8dcdc875-2955-4efe-ac27-5039b44b3f14>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [<8dcdc875-2955-4efe-ac27-5039b44b3f14>Embedded] [CompilerGenerated] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class <f472345c-d5f2-44e4-a7a0-cb7c3f409e9c>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <f472345c-d5f2-44e4-a7a0-cb7c3f409e9c>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <f472345c-d5f2-44e4-a7a0-cb7c3f409e9c>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [<8dcdc875-2955-4efe-ac27-5039b44b3f14>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class <f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContextAttribute : Attribute { public readonly byte Flag; public <f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace LegacyWard { [BepInPlugin("WackyMole.LegacyWard", "LegacyWard", "1.1.5")] [<f472345c-d5f2-44e4-a7a0-cb7c3f409e9c>Nullable(0)] [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(1)] public class Wackyward : BaseUnityPlugin { [HarmonyPatch(typeof(Player), "PlacePiece")] [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(0)] private static class PlacePiece_PatchLegacyWArd { [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(1)] private static bool Prefix(ref Player __instance, ref Piece piece, Vector3 pos, Quaternion rot, bool doAttack) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)((Component)piece).GetComponent<WackyWard_Component>())) { return true; } if (!WackyWard_Component.CanBuild(Player.m_localPlayer.m_placementGhost.transform.position)) { ((Character)Player.m_localPlayer).Message((MessageType)2, "Another ward nearby", 0, (Sprite)null); return false; } if (!_canPlaceWard && !Player.m_debugMode) { MessageHud.instance.ShowMessage((MessageType)2, "<color=red>Ward Limit</color>", 0, (Sprite)null, false); return false; } return true; } } [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(0)] [HarmonyPatch(typeof(ZNetScene), "Awake")] private static class ZNetScene_Awake_Patch { [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(1)] private static void Postfix(ZNetScene __instance) { if (isServer) { ZRoutedRpc.instance.Register("WackyWard wardplaced", (Action<long>)WardPlaced); return; } ZRoutedRpc.instance.Register<bool>("WackyWard Data", (Action<long, bool>)ReceiveData_WackyWard); List<GameObject> pieces = __instance.GetPrefab("Hammer").GetComponent<ItemDrop>().m_itemData.m_shared.m_buildPieces.m_pieces; if (!pieces.Contains(Ward_Prefab)) { pieces.Add(Ward_Prefab); } if (!pieces.Contains(Ward_Prefab_par)) { pieces.Add(Ward_Prefab_par); } __instance.m_prefabs.Add(FlashShield); __instance.m_namedPrefabs.Add(StringExtensionMethods.GetStableHashCode(((Object)FlashShield).name), FlashShield); __instance.m_prefabs.Add(FlashShield_Permit); __instance.m_namedPrefabs.Add(StringExtensionMethods.GetStableHashCode(((Object)FlashShield_Permit).name), FlashShield_Permit); __instance.m_prefabs.Add(FlashShield_Fuel); __instance.m_namedPrefabs.Add(StringExtensionMethods.GetStableHashCode(((Object)FlashShield_Fuel).name), FlashShield_Fuel); __instance.m_prefabs.Add(FlashShield_Activate); __instance.m_namedPrefabs.Add(StringExtensionMethods.GetStableHashCode(((Object)FlashShield_Activate).name), FlashShield_Activate); __instance.m_prefabs.Add(FlashShield_Deactivate); __instance.m_namedPrefabs.Add(StringExtensionMethods.GetStableHashCode(((Object)FlashShield_Deactivate).name), FlashShield_Deactivate); __instance.m_prefabs.Add(Ward_Prefab); __instance.m_namedPrefabs.Add(StringExtensionMethods.GetStableHashCode(((Object)Ward_Prefab).name), Ward_Prefab); __instance.m_prefabs.Add(Ward_Prefab_par); __instance.m_namedPrefabs.Add(StringExtensionMethods.GetStableHashCode(((Object)Ward_Prefab_par).name), Ward_Prefab_par); } private static void WardPlaced(long sender) { ZNetPeer peer = ZNet.instance.GetPeer(sender); if (peer != null) { string hostName = peer.m_socket.GetHostName(); if (_wardManager.PlayersWardData.ContainsKey(hostName)) { _wardManager.PlayersWardData[hostName]++; } else { _wardManager.PlayersWardData[hostName] = 1; } _wardManager.Save(); ZRoutedRpc.instance.InvokeRoutedRPC(peer.m_uid, "WackyWard Data", new object[1] { _wardManager.CanBuildWard(hostName) }); } } private static void ReceiveData_WackyWard(long sender, bool data) { _canPlaceWard = data; } } [HarmonyPatch(typeof(AudioMan), "Awake")] [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(0)] private static class AudioMan_Awake_Patch { [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(1)] private static void Postfix(AudioMan __instance) { GameObject[] array = asset.LoadAllAssets<GameObject>(); for (int i = 0; i < array.Length; i++) { AudioSource[] componentsInChildren = array[i].GetComponentsInChildren<AudioSource>(true); for (int j = 0; j < componentsInChildren.Length; j++) { componentsInChildren[j].outputAudioMixerGroup = __instance.m_masterMixer.outputAudioMixerGroup; } } array = asset_vfx.LoadAllAssets<GameObject>(); for (int i = 0; i < array.Length; i++) { AudioSource[] componentsInChildren = array[i].GetComponentsInChildren<AudioSource>(true); for (int j = 0; j < componentsInChildren.Length; j++) { componentsInChildren[j].outputAudioMixerGroup = __instance.m_masterMixer.outputAudioMixerGroup; } } } } [<f472345c-d5f2-44e4-a7a0-cb7c3f409e9c>Nullable(0)] public class WackyWard_Component : MonoBehaviour, Interactable, Hoverable { private static readonly List<WackyWard_Component> _instances = new List<WackyWard_Component>(); private ZNetView _znet; public Piece _piece; private CircleProjector _areaMarker_main; private Vector3 _pieceposition; private List<Material> _wardMaterials; private Container _container; private GameObject _fog; public List<Text> _text; private int LastFlashTime; public bool IsEnabled { get { if (_znet.IsValid()) { return _znet.m_zdo.GetBool("Enabled", true); } return false; } set { _znet.m_zdo.Set("Enabled", value); } } public string CustomString { get { if (!_znet.IsValid()) { return ""; } return _znet.m_zdo.GetString("CustomString", ""); } set { _znet.m_zdo.Set("CustomString", value); } } private float Fuel { get { if (!_znet.IsValid()) { return 0f; } return _znet.m_zdo.GetFloat("Fuel", 0f); } set { _znet.m_zdo.Set("Fuel", value); } } private int LastUpdateTime { get { if (!_znet.IsValid()) { return 0; } return _znet.m_zdo.GetInt("LastUpdateTime", 0); } set { _znet.m_zdo.Set("LastUpdateTime", value); } } private int Radius { get { if (!_znet.IsValid()) { return 0; } return _znet.m_zdo.GetInt("Radius", 0); } set { _znet.m_zdo.Set("Radius", value); } } public int AdminRadius { get { if (!_znet.IsValid()) { return 0; } return _znet.m_zdo.GetInt("AdminRadius", 0); } set { _znet.m_zdo.Set("AdminRadius", value); } } public static bool CanBuild(Vector3 pos) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) foreach (WackyWard_Component instance in _instances) { if (!instance._piece.IsCreator() && Vector3.Distance(((Component)instance._piece).transform.position, pos) <= 100f) { return false; } } return true; } private void OnDestroy() { _instances.Remove(this); } public int GetMainRadius() { return WardDefaultRadius.Value + AdminRadius + Radius; } public static WackyWard_Component TryFindWard(Vector3 objectPos, bool enabledOnly = true) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) foreach (WackyWard_Component instance in _instances) { if ((instance.IsEnabled || !enabledOnly) && instance.IsInside_Main(objectPos)) { return instance; } } return null; } private void Awake() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) _znet = ((Component)this).GetComponent<ZNetView>(); _areaMarker_main = ((Component)((Component)this).transform.Find("AreaMarket_Main")).GetComponent<CircleProjector>(); _pieceposition = ((Component)_areaMarker_main).transform.position; _text = ((Component)this).GetComponentsInChildren<Text>().ToList(); _text.ForEach(delegate(Text x) { x.text = ""; }); if (!_znet.IsValid()) { return; } _instances.Add(this); _piece = ((Component)this).GetComponent<Piece>(); _container = ((Component)this).GetComponentInChildren<Container>(); _wardMaterials = new List<Material>(); MeshRenderer[] componentsInChildren = ((Component)((Component)this).transform).GetComponentsInChildren<MeshRenderer>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Material[] materials = ((Renderer)componentsInChildren[i]).materials; if (materials == null || materials.Length == 0) { continue; } Material[] array = materials; foreach (Material val in array) { if ((Object)(object)val != (Object)null) { _wardMaterials.Add(val); } } } ((MonoBehaviour)this).InvokeRepeating("UpdateStatus", 1f, 1f); if (_znet.IsOwner() && GetCreatorName() == "") { string userID = ((IUser)PlatformManager.DistributionPlatform.LocalUser).PlatformUserID.m_userID; string id; if ((int)ZNet.m_onlineBackend == 0) { string[] array2 = userID.Split(new char[1] { '_' }); id = ((array2.Length > 1) ? array2[1] : array2[0]); } else { id = userID; } Setup(Game.instance.GetPlayerProfile().GetName(), id); } ((Component)_areaMarker_main).gameObject.SetActive(false); _text.ForEach(delegate(Text x) { x.text = CustomString; }); Transform val2 = ((Component)this).transform.Find("Scaler/Fog"); _fog = (((Object)(object)val2 != (Object)null) ? ((Component)val2).gameObject : null); } public void Flash() { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) if (!(EnvMan.instance.m_totalSeconds - (double)LastFlashTime <= 2.0)) { LastFlashTime = (int)EnvMan.instance.m_totalSeconds; GameObject val = null; if (((Object)_piece).name == "WackyWardEdge(Clone)") { Vector3 pieceposition = _pieceposition; pieceposition.x -= (float)GetMainRadius(); val = Object.Instantiate<GameObject>(FlashShield, pieceposition, Quaternion.identity); } else { val = Object.Instantiate<GameObject>(FlashShield, ((Component)this).transform.position, Quaternion.identity); } val.transform.Find("Dome").localScale = new Vector3((float)GetMainRadius(), (float)GetMainRadius(), (float)GetMainRadius()); } } private void CheckFuel() { if (Fuel / (float)WardMaxFuel.Value > 0.25f) { return; } Dictionary<string, int> dictionary = new Dictionary<string, int>(); string[] array = WardFuelPrefabs.Value.Replace(" ", "").Split(new char[1] { ',' }); for (int i = 0; i <= array.Length && i + 1 < array.Length; i += 2) { dictionary.Add(array[i], int.Parse(array[i + 1])); } foreach (KeyValuePair<string, int> item in dictionary) { ItemData val = ((IEnumerable<ItemData>)_container.GetInventory().GetAllItems()).FirstOrDefault((Func<ItemData, bool>)([<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(0)] (ItemData x) => ((Object)x.m_dropPrefab).name == item.Key)); if (val != null) { val.m_stack--; if (val.m_stack <= 0) { _container.GetInventory().RemoveItem(val); } Fuel += item.Value; if (Fuel / (float)WardMaxFuel.Value > 0.25f) { break; } } } } private void CheckRadius() { Dictionary<string, int> dictionary = new Dictionary<string, int>(); string[] array = WardRadiusPrefabs.Value.Replace(" ", "").Split(new char[1] { ',' }); for (int i = 0; i <= array.Length && i + 1 < array.Length; i += 2) { dictionary.Add(array[i], int.Parse(array[i + 1])); } int num = 0; foreach (KeyValuePair<string, int> item in dictionary) { if (((IEnumerable<ItemData>)_container.GetInventory().GetAllItems()).FirstOrDefault((Func<ItemData, bool>)([<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(0)] (ItemData x) => ((Object)x.m_dropPrefab).name == item.Key)) != null) { num += item.Value; } } Radius = num; } private void UpdateStatus() { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) bool isEnabled = IsEnabled; if (_wardMaterials != null) { foreach (Material wardMaterial in _wardMaterials) { if (!((Object)(object)wardMaterial == (Object)null)) { if (isEnabled) { wardMaterial.EnableKeyword("_EMISSION"); } else { wardMaterial.DisableKeyword("_EMISSION"); } } } } if ((Object)(object)_fog != (Object)null) { _fog.SetActive(isEnabled); } if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && IsInside_Main(((Component)Player.m_localPlayer).transform.position)) { ((Component)_areaMarker_main).gameObject.SetActive(true); } else { ((Component)_areaMarker_main).gameObject.SetActive(false); } _areaMarker_main.m_radius = GetMainRadius(); if (((Object)_piece).name == "WackyWardEdge(Clone)") { Vector3 pieceposition = _pieceposition; pieceposition.x -= (float)GetMainRadius(); ((Component)_areaMarker_main).transform.position = pieceposition; } if (!_znet.HasOwner() || !_znet.IsOwner()) { return; } CheckFuel(); CheckRadius(); int num = (int)EnvMan.instance.m_totalSeconds - LastUpdateTime; if (!IsEnabled) { Fuel -= num; if (Fuel < 0f) { Fuel = 0f; } } LastUpdateTime = (int)EnvMan.instance.m_totalSeconds; IsEnabled = Fuel <= 0f; if (isEnabled != IsEnabled) { Object.Instantiate<GameObject>(isEnabled ? FlashShield_Deactivate : FlashShield_Activate, ((Component)this).transform.position, Quaternion.identity); } if (!isEnabled) { return; } foreach (PrivateArea item in PrivateArea.m_allAreas.Where([<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(0)] (PrivateArea x) => x.IsEnabled())) { item.m_nview.InvokeRPC("ToggleEnabled", new object[1] { item.m_piece.GetCreator() }); } if (Chainloader.PluginInfos.ContainsKey("Azumatt.WardIsLove")) { new API().DisableWardPlayerIsIn(_pieceposition); } } private bool IsInside_Main(Vector3 point) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (((Object)_piece).name == "WackyWardEdge(Clone)") { Vector3 pieceposition = _pieceposition; pieceposition.x -= (float)GetMainRadius(); return Utils.DistanceXZ(pieceposition, point) < (float)GetMainRadius(); } return Utils.DistanceXZ(((Component)this).transform.position, point) < (float)GetMainRadius(); } public bool IsPermitted(long playerID) { return CheckPermitList(playerID); } private bool CheckPermitList(long playerID) { return GetPermittedPlayers().Any([<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(0)] (KeyValuePair<long, string> player) => player.Key == playerID); } [return: <f472345c-d5f2-44e4-a7a0-cb7c3f409e9c>Nullable(new byte[] { 1, 0, 1 })] public List<KeyValuePair<long, string>> GetPermittedPlayers() { List<KeyValuePair<long, string>> list = new List<KeyValuePair<long, string>>(); int @int = _znet.m_zdo.GetInt("permitted", 0); for (int i = 0; i < @int; i++) { long @long = _znet.m_zdo.GetLong("pu_id" + i, 0L); string @string = _znet.m_zdo.GetString("pu_name" + i, ""); if (@long != 0L) { list.Add(new KeyValuePair<long, string>(@long, @string)); } } return list; } private void SetPermittedPlayers([<f472345c-d5f2-44e4-a7a0-cb7c3f409e9c>Nullable(new byte[] { 1, 0, 1 })] IReadOnlyList<KeyValuePair<long, string>> users) { _znet.m_zdo.Set("permitted", users.Count); for (int i = 0; i < users.Count; i++) { KeyValuePair<long, string> keyValuePair = users[i]; _znet.m_zdo.Set("pu_id" + i, keyValuePair.Key); _znet.m_zdo.Set("pu_name" + i, keyValuePair.Value); } } public void AddPermitted(long playerID, string playerName) { List<KeyValuePair<long, string>> permittedPlayers = GetPermittedPlayers(); if (!permittedPlayers.Any([<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(0)] (KeyValuePair<long, string> keyValuePair) => keyValuePair.Key == playerID)) { permittedPlayers.Add(new KeyValuePair<long, string>(playerID, playerName)); SetPermittedPlayers(permittedPlayers); } } public void RemovePermitted(long playerID) { List<KeyValuePair<long, string>> permittedPlayers = GetPermittedPlayers(); if (permittedPlayers.RemoveAll(([<f472345c-d5f2-44e4-a7a0-cb7c3f409e9c>Nullable(new byte[] { 0, 1 })] KeyValuePair<long, string> x) => x.Key == playerID) > 0) { SetPermittedPlayers(permittedPlayers); } } private void AddUserList(StringBuilder text) { List<KeyValuePair<long, string>> permittedPlayers = GetPermittedPlayers(); text.Append("\n$piece_guardstone_additional: "); for (int i = 0; i < permittedPlayers.Count; i++) { text.Append(permittedPlayers[i].Value); if (i != permittedPlayers.Count - 1) { text.Append(", "); } } } public static bool AllowAction(Vector3 point, bool flash = true) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)Player.m_localPlayer)) { return false; } if (Player.m_debugMode) { return true; } long playerID = Player.m_localPlayer.GetPlayerID(); foreach (WackyWard_Component item in _instances.Where([<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(0)] (WackyWard_Component x) => x.IsEnabled && x.IsInside_Main(point))) { if (!item.IsPermitted(playerID)) { if (flash) { item.Flash(); } return false; } } return true; } public bool Interact(Humanoid user, bool hold, bool alt) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (Input.GetKey((KeyCode)304) && Player.m_debugMode) { _znet.ClaimOwnership(); scrollone = Vector2.zero; scrolltwo = Vector2.zero; currentWard = this; showGUI = true; return true; } return false; } public bool UseItem(Humanoid user, ItemData item) { return false; } private string GetCreatorName() { return _znet.m_zdo.GetString("creatorName", ""); } private void Setup(string name, string id) { LastUpdateTime = (int)EnvMan.instance.m_totalSeconds; _canPlaceWard = false; _znet.m_zdo.Set("creatorName", name); _znet.m_zdo.Set("WackyWard_id", id); if (ZNet.instance.GetServerPeer() != null) { ZRoutedRpc.instance.InvokeRoutedRPC(ZNet.instance.GetServerPeer().m_uid, "WackyWard wardplaced", new object[1]); } } public string GetHoverText() { if (!_znet.IsValid() || !Object.op_Implicit((Object)(object)Player.m_localPlayer)) { return ""; } StringBuilder stringBuilder = new StringBuilder(256); stringBuilder.Append("Charge: <color=green>" + ((int)Fuel).ToTime() + "</color> | <color=yellow>" + WardMaxFuel.Value.ToTimeNoS() + "</color>\n"); stringBuilder.Append(string.Concat(str2: (!(Fuel <= 0f)) ? "<color=#AF0000>Deactivated</color>" : "<color=green>Activated</color>", str0: _piece.m_name, str1: " ( ", str3: " )")); stringBuilder.Append("\n$piece_guardstone_owner " + GetCreatorName() + "\n"); AddUserList(stringBuilder); if (Player.m_debugMode) { stringBuilder.Append("\n [<color=yellow><b>L.Shift + $KEY_Use </b></color>] Open UI"); } return Localization.instance.Localize(stringBuilder.ToString()); } public string GetHoverName() { return "Ward"; } } [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(0)] private enum PlayerStatus { VIP, User } [<f472345c-d5f2-44e4-a7a0-cb7c3f409e9c>Nullable(0)] private class WardManager { private readonly string _path; public readonly Dictionary<string, int> PlayersWardData = new Dictionary<string, int>(); public WardManager(string path) { _path = path; if (!File.Exists(_path)) { File.Create(_path).Dispose(); return; } string text = File.ReadAllText(_path); if (!string.IsNullOrEmpty(text)) { PlayersWardData = JSON.ToObject<Dictionary<string, int>>(text); } } public bool CanBuildWard(string id) { if (!PlayersWardData.ContainsKey(id)) { return true; } return GetPlayerStatus(id) switch { PlayerStatus.VIP => PlayersWardData[id] < MaxAmountOfWards_VIP.Value, PlayerStatus.User => PlayersWardData[id] < MaxAmountOfWards.Value, _ => false, }; } public void Save() { File.WriteAllText(_path, JSON.ToNiceJSON(PlayersWardData)); } } [HarmonyPatch(typeof(Player), "CheckCanRemovePiece")] [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(0)] internal static class Player_CheckDebug { [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(1)] internal static bool Prefix(ref Player __instance, ref Piece piece) { if ((Object)(object)piece == (Object)null) { return true; } if ((Object)(object)((Component)piece).gameObject.GetComponent<WackyWard_Component>() != (Object)null && !Player.m_debugMode) { return false; } return true; } } [HarmonyPatch(typeof(ZDOMan), "HandleDestroyedZDO")] [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(0)] private static class ZDOMan_Patch { private static readonly int WackyWard_id = StringExtensionMethods.GetStableHashCode("WackyWard_id"); [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(1)] private static void Prefix(ZDOMan __instance, ZDOID uid) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (!isServer) { return; } ZDO zDO = __instance.GetZDO(uid); if (zDO == null || string.IsNullOrEmpty(zDO.GetString(WackyWard_id, ""))) { return; } string @string = zDO.GetString(WackyWard_id, ""); if (_wardManager.PlayersWardData.ContainsKey(@string)) { _wardManager.PlayersWardData[@string]--; if (_wardManager.PlayersWardData[@string] < 0) { _wardManager.PlayersWardData[@string] = 0; } ZNetPeer peerByHostName = ZNet.instance.GetPeerByHostName(@string); if (peerByHostName != null) { ZRoutedRpc.instance.InvokeRoutedRPC(peerByHostName.m_uid, "WackyWard Data", new object[1] { _wardManager.CanBuildWard(@string) }); } } _wardManager.Save(); } } [HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")] [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(0)] private static class ZnetSync { [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(1)] private static void Postfix(ZRpc rpc) { if (ZNet.instance.IsServer() && ZNet.instance.IsDedicated()) { ZNetPeer peer = ZNet.instance.GetPeer(rpc); string hostName = peer.m_socket.GetHostName(); ZRoutedRpc.instance.InvokeRoutedRPC(peer.m_uid, "WackyWard Data", new object[1] { _wardManager.CanBuildWard(hostName) }); } } } [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(0)] [HarmonyPatch(typeof(Game), "Start")] private static class Game_Start_Patch { private static void Postfix() { _canPlaceWard = false; } } [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(0)] [HarmonyPatch(typeof(Container), "Interact")] private static class Container_Interact_Patch { [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(1)] private static void Prefix(Container __instance) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)WackyWard_Component.TryFindWard(((Component)__instance).transform.position, enabledOnly: false))) { SKIP_ANY_CHECKS = true; } } private static void Postfix() { SKIP_ANY_CHECKS = false; } } [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(0)] [HarmonyPatch(typeof(Container), "GetHoverText")] private static class Container_GHT_Patch { [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(1)] private static void Prefix(Container __instance) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)WackyWard_Component.TryFindWard(((Component)__instance).transform.position, enabledOnly: false))) { SKIP_ANY_CHECKS = true; } } private static void Postfix() { SKIP_ANY_CHECKS = false; } } [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(0)] [HarmonyPatch(typeof(Door), "Interact")] private static class Door_Interact_Patch { [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(1)] private static void Prefix(Container __instance) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)WackyWard_Component.TryFindWard(((Component)__instance).transform.position, enabledOnly: false))) { SKIP_ANY_CHECKS = true; } } private static void Postfix() { SKIP_ANY_CHECKS = false; } } [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(0)] [HarmonyPatch(typeof(Door), "GetHoverText")] private static class Door_Hover_Patch { [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(1)] private static void Prefix(Container __instance) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)WackyWard_Component.TryFindWard(((Component)__instance).transform.position, enabledOnly: false))) { SKIP_ANY_CHECKS = true; } } private static void Postfix() { SKIP_ANY_CHECKS = false; } } [HarmonyPatch(typeof(PrivateArea), "CheckAccess")] [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(0)] private static class PrivateArea_CheckAccess_Patch { private static void Postfix(Vector3 point, bool flash, ref bool __result) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (!__result && Object.op_Implicit((Object)(object)WackyWard_Component.TryFindWard(point))) { __result = true; } if (SKIP_ANY_CHECKS) { __result = true; } else { __result &= WackyWard_Component.AllowAction(point, flash); } } } [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(0)] [HarmonyPatch(typeof(ItemDrop), "Interact")] private static class ItemDrop_Interact_Patch { [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(1)] private static bool Prefix(ItemDrop __instance) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return WackyWard_Component.AllowAction(((Component)__instance).transform.position); } } [HarmonyPatch(typeof(CraftingStation), "Interact")] [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(0)] private static class CraftingStation_Interact_Patch { [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(1)] private static bool Prefix(ItemDrop __instance) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return WackyWard_Component.AllowAction(((Component)__instance).transform.position); } } [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(0)] [HarmonyPatch(typeof(WearNTear), "Damage")] private static class WearNTear_Damage_Patch { [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(1)] private static bool Prefix(WearNTear __instance) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) WackyWard_Component component = ((Component)__instance).GetComponent<WackyWard_Component>(); if (component != null && component.IsEnabled) { return false; } return WackyWard_Component.AllowAction(((Component)__instance).transform.position, flash: false); } } [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(0)] [HarmonyPatch(typeof(WearNTear), "ApplyDamage")] private static class WearNTear_Damage_Patch2 { [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(1)] private static bool Prefix(WearNTear __instance) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return !Object.op_Implicit((Object)(object)WackyWard_Component.TryFindWard(((Component)__instance).transform.position)); } } [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(0)] [HarmonyPatch(typeof(TeleportWorld), "Teleport")] private static class TeleportWorld_Teleport_Patch { [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(1)] private static bool Prefix(ItemDrop __instance) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return WackyWard_Component.AllowAction(((Component)__instance).transform.position); } } [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(0)] [HarmonyPatch(typeof(StoreGui), "IsVisible")] private static class Store_IsVisible_Patch { [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(1)] private static void Postfix(StoreGui __instance, ref bool __result) { __result |= showGUI; } } [HarmonyPatch(typeof(ZNetScene), "Awake")] [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(0)] private static class ZNetScene_Awake_Patch_Recipe { [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(1)] private static void Postfix(ZNetScene __instance) { ResetRecipe(null, null); } } [CompilerGenerated] private sealed class <DelayReloadConfigFile>d__41 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; [<f472345c-d5f2-44e4-a7a0-cb7c3f409e9c>Nullable(0)] private object <>2__current; [<f472345c-d5f2-44e4-a7a0-cb7c3f409e9c>Nullable(0)] public ConfigFile file; object IEnumerator<object>.Current { [DebuggerHidden] [return: <f472345c-d5f2-44e4-a7a0-cb7c3f409e9c>Nullable(0)] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] [return: <f472345c-d5f2-44e4-a7a0-cb7c3f409e9c>Nullable(0)] get { return <>2__current; } } [DebuggerHidden] public <DelayReloadConfigFile>d__41(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSecondsRealtime(2.5f); <>1__state = 1; return true; case 1: <>1__state = -1; file.Reload(); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } internal const string ModName = "LegacyWard"; internal const string VERSION = "1.1.5"; internal const string Author = "WackyMole"; internal const string ModGUID = "WackyMole.LegacyWard"; private static AssetBundle asset; private static AssetBundle asset_vfx; private static GameObject Ward_Prefab; private static GameObject Ward_Prefab_par; private static GameObject FlashShield; private static GameObject FlashShield_Permit; private static GameObject FlashShield_Fuel; private static GameObject FlashShield_Activate; private static GameObject FlashShield_Deactivate; private static ConfigEntry<string> WardRecipe; private static ConfigEntry<int> WardDefaultRadius; private static ConfigEntry<string> WardRadiusPrefabs; private static ConfigEntry<string> WardFuelPrefabs; private static ConfigEntry<int> WardMaxFuel; private readonly ConfigSync configSync = new ConfigSync("WackyMole.LegacyWard") { DisplayName = "LegacyWard" }; private readonly Harmony _harmony = new Harmony("WackyMole.LegacyWard"); private static bool _canPlaceWard; private static SyncedList VIPplayersList; private static WardManager _wardManager; private static ConfigEntry<int> MaxAmountOfWards; private static ConfigEntry<int> MaxAmountOfWards_VIP; private static Wackyward _thistype; private static FileSystemWatcher fsw; private static bool SKIP_ANY_CHECKS; private static bool showGUI; private static WackyWard_Component currentWard; private static Vector2 scrollone; private static Vector2 scrolltwo; private static bool isServer => (int)SystemInfo.graphicsDeviceType == 4; private ConfigEntry<T> config<[<f472345c-d5f2-44e4-a7a0-cb7c3f409e9c>Nullable(2)] T>(string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true) { ConfigEntry<T> val = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, description); configSync.AddConfigEntry<T>(val).SynchronizedConfig = synchronizedSetting; return val; } private ConfigEntry<T> config<[<f472345c-d5f2-44e4-a7a0-cb7c3f409e9c>Nullable(2)] T>(string group, string name, T value, string description, bool synchronizedSetting = true) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), synchronizedSetting); } private void Awake() { _thistype = this; configSync.ModRequired = true; asset = GetAssetBundle("wackyward"); asset_vfx = GetAssetBundle("wackywardvfx"); WardMaxFuel = config("Ward", "WardMaxFuel", 1814400, "Ward Max Fuel - 3 Weeks or 21 days"); WardDefaultRadius = config("Ward", "WardDefaultRadius", 30, "Ward Default Radius"); WardRadiusPrefabs = config("Ward", "WardRadiusPrefabs", "Wood, 20", "Ward Radius Prefabs"); WardFuelPrefabs = config("Ward", "WardFuelPrefabs", "Stone, 100", "Ward Fuel Prefabs"); WardRecipe = config("Ward", "WardRecipe", "SwordCheat,1", "Ward Recipe"); WardRecipe.SettingChanged += ResetRecipe; JSON.Parameters = new JSONParameters { UseExtensions = false, SerializeNullValues = false, DateTimeMilliseconds = false, UseUTCDateTime = true, UseOptimizedDatasetSchema = true, UseValuesOfEnums = true }; Ward_Prefab = asset.LoadAsset<GameObject>("WackyWard"); Ward_Prefab.AddComponent<WackyWard_Component>(); Ward_Prefab.GetComponent<Piece>().m_name = "Legacy Ward"; Ward_Prefab.GetComponent<Piece>().m_description = "Legacy Ward sets in the Center"; Ward_Prefab_par = asset.LoadAsset<GameObject>("WackyWardEdge"); Ward_Prefab_par.AddComponent<WackyWard_Component>(); Ward_Prefab_par.GetComponent<Piece>().m_name = "Legacy Ward Edge"; Ward_Prefab_par.GetComponent<Piece>().m_description = "Legacy Ward Sets on the Parameter"; FlashShield = asset_vfx.LoadAsset<GameObject>("WackyWard_Explosion"); FlashShield_Permit = asset_vfx.LoadAsset<GameObject>("WackyWard_Permit"); FlashShield_Fuel = asset_vfx.LoadAsset<GameObject>("WackyWard_Fuel"); FlashShield_Activate = asset_vfx.LoadAsset<GameObject>("WackyWard_Activate"); FlashShield_Deactivate = asset_vfx.LoadAsset<GameObject>("WackyWard_Deactivate"); if (isServer) { ServerSideInit(); } _harmony.PatchAll(); } private static PlayerStatus GetPlayerStatus(string id) { if (!ZNet.instance.ListContainsId(VIPplayersList, id)) { return PlayerStatus.User; } return PlayerStatus.VIP; } private void ServerSideInit() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown string text = Path.Combine(Paths.ConfigPath, "WackyWard"); if (!Directory.Exists(text)) { Directory.CreateDirectory(text); } _wardManager = new WardManager(Path.Combine(text, "WardData.json")); VIPplayersList = new SyncedList(new FileLocation((FileSource)1, Path.Combine(text, "VIPplayers.txt")), ""); MaxAmountOfWards = ((BaseUnityPlugin)this).Config.Bind<int>("WardOne", "MaxAmountOfWards", 3, "Max amount of wards"); MaxAmountOfWards_VIP = ((BaseUnityPlugin)this).Config.Bind<int>("WardOne", "MaxAmountOfWards_VIP", 5, "Max amount of wards for VIP"); fsw = new FileSystemWatcher(Paths.ConfigPath) { Filter = Path.GetFileName(((BaseUnityPlugin)this).Config.ConfigFilePath), EnableRaisingEvents = true, IncludeSubdirectories = true, SynchronizingObject = ThreadingHelper.SynchronizingObject }; fsw.Changed += ConfigChanged; } private void ConfigChanged(object sender, FileSystemEventArgs e) { MonoBehaviour.print((object)"[Wacky Ward] Config changed..."); ((MonoBehaviour)_thistype).StartCoroutine(DelayReloadConfigFile(((BaseUnityPlugin)this).Config)); } [IteratorStateMachine(typeof(<DelayReloadConfigFile>d__41))] private static IEnumerator DelayReloadConfigFile(ConfigFile file) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DelayReloadConfigFile>d__41(0) { file = file }; } private static AssetBundle GetAssetBundle(string filename) { Assembly executingAssembly = Assembly.GetExecutingAssembly(); string name = executingAssembly.GetManifestResourceNames().Single([<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(0)] (string str) => str.EndsWith(filename)); using Stream stream = executingAssembly.GetManifestResourceStream(name); return AssetBundle.LoadFromStream(stream); } private void Update() { if (Input.GetKeyDown((KeyCode)27) && showGUI) { showGUI = false; } } private void OnGUI() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown //IL_0060: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) if (showGUI) { GUI.backgroundColor = Color.black; Rect val = default(Rect); ((Rect)(ref val))..ctor((float)Screen.width / 2f - 170f, (float)Screen.height / 2f - 165f, 340f, 330f); GUI.Window(2131293, val, new WindowFunction(GUIWindow), "Users"); GUI.Window(2131294, val, new WindowFunction(black), ""); GUI.Window(2131295, val, new WindowFunction(black), ""); } } private static void black(int winid) { } private static void GUIWindow(int id) { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)currentWard == (Object)null) { showGUI = false; return; } List<KeyValuePair<long, string>> permittedUsers = currentWard.GetPermittedPlayers(); GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); GUILayout.Label($"Additional Admin Radius: {currentWard.AdminRadius}", Array.Empty<GUILayoutOption>()); currentWard.AdminRadius = (int)GUILayout.HorizontalSlider((float)currentWard.AdminRadius, -100f, 100f, Array.Empty<GUILayoutOption>()); GUILayout.Label($"Permitted players ({permittedUsers.Count}): ", Array.Empty<GUILayoutOption>()); scrollone = GUILayout.BeginScrollView(scrollone, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(300f), GUILayout.Height(120f) }); foreach (KeyValuePair<long, string> item in permittedUsers) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label($"{item.Value} ({item.Key})", Array.Empty<GUILayoutOption>()); if (GUILayout.Button("<color=red>Remove</color>", Array.Empty<GUILayoutOption>())) { currentWard.RemovePermitted(item.Key); } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); IEnumerable<PlayerInfo> enumerable = from x in ZNet.instance.GetPlayerList() where ZDOMan.instance.GetZDO(x.m_characterID) != null && !permittedUsers.Any([<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(0)] (KeyValuePair<long, string> y) => y.Key == ZDOMan.instance.GetZDO(x.m_characterID).GetLong(ZDOVars.s_playerID, 0L)) select x; GUILayout.Label("All players:", Array.Empty<GUILayoutOption>()); scrolltwo = GUILayout.BeginScrollView(scrolltwo, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(300f), GUILayout.Height(120f) }); foreach (PlayerInfo item2 in enumerable) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label($"{item2.m_name} ({ZDOMan.instance.GetZDO(item2.m_characterID).GetLong(ZDOVars.s_playerID, 0L)})", Array.Empty<GUILayoutOption>()); if (GUILayout.Button("<color=yellow>Add</color>", Array.Empty<GUILayoutOption>())) { currentWard.AddPermitted(ZDOMan.instance.GetZDO(item2.m_characterID).GetLong(ZDOVars.s_playerID, 0L), item2.m_name); } GUILayout.EndHorizontal(); } GUILayout.Label("Custom Text:", Array.Empty<GUILayoutOption>()); currentWard.CustomString = GUILayout.TextField(currentWard.CustomString, Array.Empty<GUILayoutOption>()); currentWard._text.ForEach(delegate(Text x) { x.text = currentWard.CustomString; }); GUILayout.EndScrollView(); GUILayout.EndVertical(); } private static void ResetRecipe(object sender, EventArgs eventArgs) { //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Expected O, but got Unknown //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)ZNetScene.instance)) { return; } try { List<Requirement> list = new List<Requirement>(); string[] array = WardRecipe.Value.Split(new char[1] { ',' }); for (int i = 0; i < array.Length; i += 2) { string text = array[i]; int amount = int.Parse(array[i + 1]); list.Add(new Requirement { m_amount = amount, m_resItem = ObjectDB.instance.GetItemPrefab(StringExtensionMethods.GetStableHashCode(text)).GetComponent<ItemDrop>(), m_recover = (text != "SwordCheat") }); } Ward_Prefab.GetComponent<Piece>().m_resources = list.ToArray(); Ward_Prefab_par.GetComponent<Piece>().m_resources = list.ToArray(); } catch { Ward_Prefab.GetComponent<Piece>().m_resources = (Requirement[])(object)new Requirement[1] { new Requirement { m_amount = 1, m_resItem = ObjectDB.instance.GetItemPrefab("SwordCheat").GetComponent<ItemDrop>(), m_recover = false } }; Ward_Prefab_par.GetComponent<Piece>().m_resources = (Requirement[])(object)new Requirement[1] { new Requirement { m_amount = 1, m_resItem = ObjectDB.instance.GetItemPrefab("SwordCheat").GetComponent<ItemDrop>(), m_recover = false } }; } } } [<f472345c-d5f2-44e4-a7a0-cb7c3f409e9c>Nullable(0)] [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(1)] public static class EXTENTIONS { public static string ToTime(this int seconds) { TimeSpan timeSpan = TimeSpan.FromSeconds(seconds); string text = ""; if (timeSpan.Days > 0) { text += $"{timeSpan.Days:D2}d "; } if (timeSpan.Hours > 0) { text += $"{timeSpan.Hours:D2}h "; } if (timeSpan.Minutes > 0) { text += $"{timeSpan.Minutes:D2}m "; } return text + $"{timeSpan.Seconds:D2}s"; } public static string ToTimeNoS(this int seconds) { TimeSpan timeSpan = TimeSpan.FromSeconds(seconds); string text = ""; if (timeSpan.Days > 0) { text += $"{timeSpan.Days:D2}d "; } if (timeSpan.Hours > 0) { text += $"{timeSpan.Hours:D2}h "; } if (timeSpan.Minutes > 0) { text += $"{timeSpan.Minutes:D2}m "; } return text; } } } namespace WardIsLove.API { [PublicAPI] [<f472345c-d5f2-44e4-a7a0-cb7c3f409e9c>Nullable(0)] [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(2)] public class API { [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(0)] public delegate bool WardCheckHandler(Vector3 location); public static event Action<Vector3> OnWardEntered; public static event Action<Vector3> OnWardExited; public static event Action<Vector3> OnBubbleOn; public static event Action<Vector3> OnBubbleOff; public static event Action<Vector3, float> OnDamageTaken; public static event WardCheckHandler CheckWardPresence; public static bool IsLoaded() { return true; } public static bool IsInsideWard(Vector3 point) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) return API.CheckWardPresence?.Invoke(point) ?? false; } public void DisableWardPlayerIsIn(Vector3 point, bool destroyPiece = false) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) WardMonoscript val = default(WardMonoscript); WardMonoscript.CheckInWardOutWard(point, ref val, false); if ((Object)(object)val != (Object)null) { val.SetEnabled(false); if (destroyPiece) { DestroyWard(val.m_piece); } } } [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(1)] public GameObject GetWardObject(Vector3 point) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) WardMonoscript val = default(WardMonoscript); WardMonoscript.CheckInWardOutWard(point, ref val, false); if (val == null) { return null; } return ((Component)val).gameObject; } [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(1)] public GameObject GetWardBubble(Vector3 point) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) WardMonoscript val = default(WardMonoscript); WardMonoscript.CheckInWardOutWard(point, ref val, false); if (val == null) { return null; } return val.m_bubble.gameObject; } [<f88b0347-6279-4f89-acce-d59c0b6e1735>NullableContext(1)] public void DestroyWard(Piece piece) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) ZNetView component = ((Component)piece).GetComponent<ZNetView>(); if ((Object)(object)component != (Object)null) { WearNTear component2 = ((Component)piece).GetComponent<WearNTear>(); if (Object.op_Implicit((Object)(object)component2)) { component2.Remove(false); return; } ZLog.Log((object)("Removing non WNT object with hammer " + ((Object)piece).name)); component.ClaimOwnership(); piece.DropResources((HitData)null); piece.m_placeEffect.Create(((Component)piece).transform.position, ((Component)piece).transform.rotation, ((Component)piece).gameObject.transform, 1f, -1); Player.m_localPlayer.m_removeEffects.Create(((Component)piece).transform.position, Quaternion.identity, (Transform)null, 1f, -1); ZNetScene.instance.Destroy(((Component)piece).gameObject); } } internal static void WardEntered(Vector3 position) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) API.OnWardEntered?.Invoke(position); } internal static void WardExited(Vector3 position) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) API.OnWardExited?.Invoke(position); } internal static void BubbleOn(Vector3 position) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) API.OnBubbleOn?.Invoke(position); } internal static void BubbleOff(Vector3 position) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) API.OnBubbleOff?.Invoke(position); } internal static void DamageTaken(Vector3 position, float damage) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) API.OnDamageTaken?.Invoke(position, damage); } } } namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<a2f05e26-84a7-4f99-9b94-0e0588bbd3ee>Embedded] internal sealed class <a2f05e26-84a7-4f99-9b94-0e0588bbd3ee>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [<a2f05e26-84a7-4f99-9b94-0e0588bbd3ee>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class <8535e035-0e36-41ba-9121-a6c0546a37c5>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <8535e035-0e36-41ba-9121-a6c0546a37c5>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <8535e035-0e36-41ba-9121-a6c0546a37c5>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] [<a2f05e26-84a7-4f99-9b94-0e0588bbd3ee>Embedded] [CompilerGenerated] internal sealed class <96333303-3991-4a70-9b4c-65dcc637fcba>NullableContextAttribute : Attribute { public readonly byte Flag; public <96333303-3991-4a70-9b4c-65dcc637fcba>NullableContextAttribute(byte P_0) { Flag = P_0; } } [<a2f05e26-84a7-4f99-9b94-0e0588bbd3ee>Embedded] [CompilerGenerated] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ServerSync { [<96333303-3991-4a70-9b4c-65dcc637fcba>NullableContext(1)] [PublicAPI] [<8535e035-0e36-41ba-9121-a6c0546a37c5>Nullable(0)] internal abstract class OwnConfigEntryBase { [<8535e035-0e36-41ba-9121-a6c0546a37c5>Nullable(2)] public object LocalBaseValue; public bool SynchronizedConfig = true; public abstract ConfigEntryBase BaseConfig { get; } } [<96333303-3991-4a70-9b4c-65dcc637fcba>NullableContext(1)] [PublicAPI] [<8535e035-0e36-41ba-9121-a6c0546a37c5>Nullable(0)] internal class SyncedConfigEntry<[<8535e035-0e36-41ba-9121-a6c0546a37c5>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; base..ctor(); } public void AssignLocalValue(T value) { if (LocalBaseValue == null) { Value = value; } else { LocalBaseValue = value; } } } [<96333303-3991-4a70-9b4c-65dcc637fcba>NullableContext(2)] [<8535e035-0e36-41ba-9121-a6c0546a37c5>Nullable(0)] internal abstract class CustomSyncedValueBase { public object LocalBaseValue; [<8535e035-0e36-41ba-9121-a6c0546a37c5>Nullable(1)] public readonly string Identifier; [<8535e035-0e36-41ba-9121-a6c0546a37c5>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; [<96333303-3991-4a70-9b4c-65dcc637fcba>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; }; } } [<8535e035-0e36-41ba-9121-a6c0546a37c5>Nullable(0)] [PublicAPI] [<96333303-3991-4a70-9b4c-65dcc637fcba>NullableContext(1)] internal sealed class CustomSyncedValue<[<8535e035-0e36-41ba-9121-a6c0546a37c5>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] [<8535e035-0e36-41ba-9121-a6c0546a37c5>Nullable(0)] [<96333303-3991-4a70-9b4c-65dcc637fcba>NullableContext(1)] internal class ConfigSync { [<96333303-3991-4a70-9b4c-65dcc637fcba>NullableContext(0)] [HarmonyPatch(typeof(ZRpc), "HandlePackage")] private static class SnatchCurrentlyHandlingRPC { [<8535e035-0e36-41ba-9121-a6c0546a37c5>Nullable(2)] public static ZRpc currentRpc; [<96333303-3991-4a70-9b4c-65dcc637fcba>NullableContext(1)] [HarmonyPrefix] private static void Prefix(ZRpc __instance) { currentRpc = __instance; } } [<96333303-3991-4a70-9b4c-65dcc637fcba>NullableContext(0)] [HarmonyPatch(typeof(ZNet), "Awake")] internal static class RegisterRPCPatch { [<96333303-3991-4a70-9b4c-65dcc637fcba>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()); } [<96333303-3991-4a70-9b4c-65dcc637fcba>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)); } } [<96333303-3991-4a70-9b4c-65dcc637fcba>NullableContext(1)] static IEnumerator WatchAdminListChanges() { MethodInfo listContainsId = AccessTools.DeclaredMethod(typeof(ZNet), "ListContainsId", (Type[])null, (Type[])null); 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 = ZNet.instance.GetPeers().Where(delegate(ZNetPeer p) { string hostName = p.m_rpc.GetSocket().GetHostName(); return ((object)listContainsId == null) ? adminList.Contains(hostName) : ((bool)listContainsId.Invoke(ZNet.instance, new object[2] { adminList, hostName })); }).ToList(); List<ZNetPeer> nonAdminPeer = ZNet.instance.GetPeers().Except(adminPeer).ToList(); SendAdmin(nonAdminPeer, isAdmin: false); SendAdmin(adminPeer, isAdmin: true); } } } } } [<96333303-3991-4a70-9b4c-65dcc637fcba>NullableContext(0)] [HarmonyPatch(typeof(ZNet), "OnNewConnection")] private static class RegisterClientRPCPatch { [<96333303-3991-4a70-9b4c-65dcc637fcba>NullableContext(1)] [HarmonyPostfix] 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); } } } [<96333303-3991-4a70-9b4c-65dcc637fcba>NullableContext(0)] private class ParsedConfigs { [<8535e035-0e36-41ba-9121-a6c0546a37c5>Nullable(new byte[] { 1, 1, 2 })] public readonly Dictionary<OwnConfigEntryBase, object> configValues = new Dictionary<OwnConfigEntryBase, object>(); [<8535e035-0e36-41ba-9121-a6c0546a37c5>Nullable(new byte[] { 1, 1, 2 })] public readonly Dictionary<CustomSyncedValueBase, object> customValues = new Dictionary<CustomSyncedValueBase, object>(); } [<96333303-3991-4a70-9b4c-65dcc637fcba>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; } } [HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")] [<8535e035-0e36-41ba-9121-a6c0546a37c5>Nullable(0)] private class SendConfigsAfterLogin { [<8535e035-0e36-41ba-9121-a6c0546a37c5>Nullable(0)] private class BufferingSocket : ZPlayFabSocket, 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; ((ZPlayFabSocket)this)..ctor(); } 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); } } } [HarmonyPrefix] [HarmonyPriority(800)] private static void Prefix([<8535e035-0e36-41ba-9121-a6c0546a37c5>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()) { return; } BufferingSocket bufferingSocket = new BufferingSocket(rpc.GetSocket()); AccessTools.DeclaredField(typeof(ZRpc), "m_socket").SetValue(rpc, bufferingSocket); 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) { FieldInfo fieldInfo = AccessTools.DeclaredField(typeof(ZNetPeer), "m_socket"); object? value = fieldInfo.GetValue(val); ZPlayFabSocket val2 = (ZPlayFabSocket)((value is ZPlayFabSocket) ? value : null); if (val2 != null) { typeof(ZPlayFabSocket).GetField("m_remotePlayerId").SetValue(bufferingSocket, val2.m_remotePlayerId); } fieldInfo.SetValue(val, bufferingSocket); } if (__state == null) { __state = new Dictionary<Assembly, BufferingSocket>(); } __state[Assembly.GetExecutingAssembly()] = bufferingSocket; } [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([<96333303-3991-4a70-9b4c-65dcc637fcba>NullableContext(0)] (OwnConfigEntryBase c) => c.BaseConfig), configSync.allCustomValues, entries, partial: false); yield return ((MonoBehaviour)__instance).StartCoroutine(configSync.sendZPackage(new List<ZNetPeer> { peer }, package)); } SendBufferedData(); } } } [<8535e035-0e36-41ba-9121-a6c0546a37c5>Nullable(0)] private class PackageEntry { public string section = null; public string key = null; public Type type = null; [<8535e035-0e36-41ba-9121-a6c0546a37c5>Nullable(2)] public object value; } [HarmonyPatch(typeof(ConfigEntryBase), "GetSerializedValue")] [<96333303-3991-4a70-9b4c-65dcc637fcba>NullableContext(0)] private static class PreventSavingServerInfo { [<96333303-3991-4a70-9b4c-65dcc637fcba>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; } } [HarmonyPatch(typeof(ConfigEntryBase), "SetSerializedValue")] [<96333303-3991-4a70-9b4c-65dcc637fcba>NullableContext(0)] private static class PreventConfigRereadChangingValues { [HarmonyPrefix] [<96333303-3991-4a70-9b4c-65dcc637fcba>NullableContext(1)] 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; } } [<8535e035-0e36-41ba-9121-a6c0546a37c5>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; [<8535e035-0e36-41ba-9121-a6c0546a37c5>Nullable(2)] public string DisplayName; [<8535e035-0e36-41ba-9121-a6c0546a37c5>Nullable(2)] public string CurrentVersion; [<8535e035-0e36-41ba-9121-a6c0546a37c5>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; [<8535e035-0e36-41ba-9121-a6c0546a37c5>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[]>>(); [<8535e035-0e36-41ba-9121-a6c0546a37c5>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; [<8535e035-0e36-41ba-9121-a6c0546a37c5>Nullable(2)] [method: <96333303-3991-4a70-9b4c-65dcc637fcba>NullableContext(2)] [field: <8535e035-0e36-41ba-9121-a6c0546a37c5>Nullable(2)] public event Action<bool> SourceOfTruthChanged; [<8535e035-0e36-41ba-9121-a6c0546a37c5>Nullable(2)] [method: <96333303-3991-4a70-9b4c-65dcc637fcba>NullableContext(2)] [field: <8535e035-0e36-41ba-9121-a6c0546a37c5>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<[<8535e035-0e36-41ba-9121-a6c0546a37c5>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 += [<96333303-3991-4a70-9b4c-65dcc637fcba>NullableContext(0)] (object _, EventArgs _) => { if (!ProcessingServerUpdate && syncedEntry.SynchronizedConfig) { Broadcast(ZRoutedRpc.Everybody, (ConfigEntryBase)configEntry); } }; allConfigs.Add(syncedEntry); } return syncedEntry; } public SyncedConfigEntry<T> AddLockingConfigEntry<[<8535e035-0e36-41ba-9121-a6c0546a37c5>Nullable(0)] T>(ConfigEntry<T> lockingConfig) where T : IConvertible { if (lockedConfig != null) { throw new Exception("Cannot initialize locking ConfigEntry twice"); } lockedConfig = AddConfigEntry<T>(lockingConfig); lockingConfig.SettingChanged += [<96333303-3991-4a70-9b4c-65dcc637fcba>NullableContext(0)] (object _, EventArgs _) => { this.lockedConfigChanged?.Invoke(); }; return (SyncedConfigEntry<T>)lockedConfig; } internal void AddCustomValue(CustomSyncedValueBase customValue) { if (allCustomValues.Select([<96333303-3991-4a70-9b4c-65dcc637fcba>NullableContext(0)] (CustomSyncedValueBase v) => v.Identifier).Concat(new string[1] { "serverversion" }).Contains(customValue.Identifier)) { throw new Exception("Cannot have multiple settings with the same name or with a reserved name (serverversion)"); } allCustomValues.Add(customValue); allCustomValues = new HashSet<CustomSyncedValueBase>(allCustomValues.OrderByDescending([<96333303-3991-4a70-9b4c-65dcc637fcba>NullableContext(0)] (CustomSyncedValueBase v) => v.Priority)); customValue.ValueChanged += delegate { if (!ProcessingServerUpdate) { Broadcast(ZRoutedRpc.Everybody, customValue); } }; } private void RPC_FromServerConfigSync(ZRpc rpc, ZPackage package) { lockedConfigChanged += serverLockedSettingChanged; IsSourceOfTruth = false; if (HandleConfigSyncRPC(0L, package, clientUpdate: false)) { InitialSyncDone = true; } } private void RPC_FromOtherClientConfigSync(long sender, ZPackage package) { HandleConfigSyncRPC(sender, package, clientUpdate: true); } private bool HandleConfigSyncRPC(long sender, ZPackage package, bool clientUpdate) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Expected O, but got Unknown //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Expected O, but got Unknown try { if (isServer && IsLocked) { ZRpc currentRpc = SnatchCurrentlyHandlingRPC.currentRpc; object obj; if (currentRpc == null) { obj = null; } else { ISocket socket = currentRpc.GetSocket(); obj = ((socket != null) ? socket.GetHostName() : null); } string text = (string)obj; if (text != null) { MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(ZNet), "ListContainsId", (Type[])null, (Type[])null); SyncedList val = (SyncedList)AccessTools.DeclaredField(typeof(ZNet), "m_adminList").GetValue(ZNet.instance); if (!(((object)methodInfo == null) ? val.Contains(text) : ((bool)methodInfo.Invoke(ZNet.instance, new object[2] { val, text })))) { return false; } } } cacheExpirations.RemoveAll(([<8535e035-0e36-41ba-9121-a6c0546a37c5>Nullable(new byte[] { 0, 1 })] KeyValuePair<long, string> kv) => { if (kv.Key < DateTimeOffset.Now.Ticks) { configValueCache.Remove(kv.Value); return true; } return false; }); byte b = package.ReadByte(); if ((b & 2u) != 0) { long num = package.ReadLong(); string text2 = sender.ToString() + num; if (!configValueCache.TryGetValue(text2, out var value)) { value = new SortedDictionary<int, byte[]>(); configValueCache[text2] = value; cacheExpirations.Add(new KeyValuePair<long, string>(DateTimeOffset.Now.AddSeconds(60.0).Ticks, text2)); } int key = package.ReadInt(); int num2 = package.ReadInt(); value.Add(key, package.ReadByteArray()); if (value.Count < num2) { return false; } configValueCache.Remove(text2); package = new ZPackage(value.Values.SelectMany([<96333303-3991-4a70-9b4c-65dcc637fcba>NullableContext(0)] (byte[] a) => a).ToArray()); b = package.ReadByte(); } ProcessingServerUpdate = true; if ((b & 4u) != 0) { byte[] buffer = package.ReadByteArray(); MemoryStream stream = new MemoryStream(buffer); MemoryStream memoryStream = new MemoryStream(); using (DeflateStream deflateStream = new DeflateStream(stream, CompressionMode.Decompress)) { deflateStream.CopyTo(memoryStream); } package = new ZPackage(memoryStream.ToArray()); b = package.ReadByte(); } if ((b & 1) == 0) { resetConfigsFromServer(); } ParsedConfigs parsedConfigs = ReadConfigsFromPackage(package); ConfigFile val2 = null; bool saveOnConfigSet = false; foreach (KeyValuePair<OwnConfigEntryBase, object> configValue in parsedConfigs.configValues) { if (!isServer && configValue.Key.LocalBaseValue == null) { configValue.Key.LocalBaseValue = configValue.Key.BaseConfig.BoxedValue; } if (val2 == null) { val2 = configValue.Key.BaseConfig.ConfigFile; saveOnConfigSet = val2.SaveOnConfigSet; val2.SaveOnConfigSet = false; } configValue.Key.BaseConfig.BoxedValue = configValue.Value; } if (val2 != null) { val2.SaveOnConfigSet = saveOnConfigSet; } foreach (KeyValuePair<CustomSyncedValueBase, object> customValue in parsedConfigs.customValues) { if (!isServer) { CustomSyncedValueBase key2 = customValue.Key; if (key2.LocalBaseValue == null) { key2.LocalBaseValue = customValue.Key.BoxedValue; } } customValue.Key.BoxedValue = customValue.Value; } Debug.Log((object)string.Format("Received {0} configs and {1} custom values from {2} for mod {3}", parsedConfigs.configValues.Count, parsedConfigs.customValues.Count, (isServer || clientUpdate) ? $"client {sender}" : "the server", DisplayName ?? Name)); if (!isServer) { serverLockedSettingChanged(); } return true; } finally { ProcessingServerUpdate = false; } } private ParsedConfigs ReadConfigsFromPackage(ZPackage package) { ParsedConfigs parsedConfigs = new ParsedConfigs(); Dictionary<string, OwnConfigEntryBase> dictionary = allConfigs.Where([<96333303-3991-4a70-9b4c-65dcc637fcba>NullableContext(0)] (OwnConfigEntryBase c) => c.SynchronizedConfig).ToDictionary([<96333303-3991-4a70-9b4c-65dcc637fcba>NullableContext(0)] (OwnConfigEntryBase c) => c.BaseConfig.Definition.Section + "_" + c.BaseConfig.Definition.Key, [<96333303-3991-4a70-9b4c-65dcc637fcba>NullableContext(0)] (OwnConfigEntryBase c) => c); Dictionary<string, CustomSyncedValueBase> dictionary2 = allCustomValues.ToDictionary([<96333303-3991-4a70-9b4c-65dcc637fcba>NullableContext(0)] (CustomSyncedValueBase c) => c.Identifier, [<96333303-3991-4a70-9b4c-65dcc637fcba>NullableContext(0)] (CustomSyncedValueBase c) => c); int num = package.ReadInt(); for (int i = 0; i < num; i++) { string text = package.ReadString(); string text2 = package.ReadString(); string text3 = package.ReadString(); Type type = Type.GetType(text3); if (text3 == "" || type != null) { object obj; try { obj = ((text3 == "") ? null : ReadValueWithTypeFromZPackage(package, type)); } catch (InvalidDeserializationTypeException ex) { Debug.LogWarning((object)("Got unexpected struct internal type " + ex.received + " for field " + ex.field + " struct " + text3 + " for " + text2 + " in section " + text + " for mod " + (DisplayName ?? Name) + ", expecting " + ex.expected)); continue; } OwnConfigEntryBase value2; if (text == "Internal") { CustomSyncedValueBase value; if (text2 == "serverversion") { if (obj?.ToString() != CurrentVersion) { Debug.LogWarning((object)("Received server version is not equal: server version = " + (obj?.ToString() ?? "null") + "; local version = " + (CurrentVersion ?? "unknown"))); } } else if (text2 == "lockexempt") { if (obj is bool flag) { lockExempt = flag; } } else if (dictionary2.TryGetValue(text2, out value)) { if ((text3 == "" && (!value.Type.IsValueType || Nullable.GetUnderlyingType(value.Type) != null)) || GetZPackageTypeString(value.Type) == text3) { parsedConfigs.customValues[value] = obj; continue; } Debug.LogWarning((object)("Got unexpected type " + text3 + " for internal value " + text2 + " for mod " + (DisplayName ?? Name) + ", expecting " + value.Type.AssemblyQualifiedName)); } } else if (dictionary.TryGetValue(text + "_" + text2, out value2)) { Type type2 = configType(value2.BaseConfig); if ((text3 == "" && (!type2.IsValueType || Nullable.GetUnderlyingType(type2) != null)) || GetZPackageTypeString(type2) == text3) { parsedConfigs.configValues[value2] = obj; continue; } Debug.LogWarning((object)("Got unexpected type " + text3 + " for " + text2 + " in section " + text + " for mod " + (DisplayName ?? Name) + ", expecting " + type2.AssemblyQualifiedName)); } else { Debug.LogWarning((object)("Received unknown config entry " + text2 + " in section " + text + " for mod " + (DisplayName ?? Name) + ". This may happen if client and server versions of the mod do not match.")); } continue; } Debug.LogWarning((object)("Got invalid type " + text3 + ", abort reading of received configs")); return new ParsedConfigs(); } return parsedConfigs; } private static bool isWritableConfig(OwnConfigEntryBase config) { ConfigSync configSync = configSyncs.FirstOrDefault([<96333303-3991-4a70-9b4c-65dcc637fcba>NullableContext(0)] (ConfigSync cs) => cs.allConfigs.Contains(config)); if (configSync == null) { return true; } return configSync.IsSourceOfTruth || !config.SynchronizedConfig || config.LocalBaseValue == null || (!configSync.IsLocked && (config != configSync.lockedConfig || lockExempt)); } private void serverLockedSettingChanged() { foreach (OwnConfigEntryBase allConfig in allConfigs) { configAttribute<ConfigurationManagerAttributes>(allConfig.BaseConfig).ReadOnly = !isWritableConfig(allConfig); } } private void resetConfigsFromServer() { ConfigFile val = null; bool saveOnConfigSet = false; foreach (OwnConfigEntryBase item in allConfigs.Where([<96333303-3991-4a70-9b4c-65dcc637fcba>NullableContext(0)] (OwnConfigEntryBase config) => config.LocalBaseValue != null)) { if (val == null) { val = item.BaseConfig.ConfigFile; saveOnConfigSet = val.SaveOnConfigSet; val.SaveOnConfigSet = false; } item.BaseConfig.BoxedValue = item.LocalBaseValue; item.LocalBaseValue = null; } if (val != null) { val.SaveOnConfigSet = saveOnConfigSet; } foreach (CustomSyncedValueBase item2 in allCustomValues.Where([<96333303-3991-4a70-9b4c-65dcc637fcba>NullableContext(0)] (CustomSyncedValueBase config) => config.LocalBaseValue != null)) { item2.BoxedValue = item2.LocalBaseValue; item2.LocalBaseValue = null; } lockedConfigChanged -= serverLockedSettingChanged; serverLockedSettingChanged(); } private IEnumerator<bool> distributeConfigToPeers(ZNetPeer peer, ZPackage package) { ZRoutedRpc rpc = ZRoutedRpc.instance; if (rpc == null) { yield break; } byte[] data = package.GetArray(); if (data != null && data.LongLength > 250000) { int fragments = (int)(1 + (data.LongLength - 1) / 250000); long packageIdentifier = ++packageCounter; int fragment = 0; while (fragment < fragments) { foreach (bool item in waitForQueue()) { yield return item; } if (peer.m_socket.IsConnected()) { ZPackage fragmentedPackage = new ZPackage(); fragmentedPackage.Write((byte)2); fragmentedPackage.Write(packageIdentifier); fragmentedPackage.Write(fragment); fragmentedPackage.Write(fragments); fragmentedPackage.Write(data.Skip(250000 * fragment).Take(250000).ToArray()); SendPackage(fragmentedPackage); if (fragment != fragments - 1) { yield return true; } int num = fragment + 1; fragment = num; continue; } break; } yield break; } foreach (bool item2 in waitForQueue()) { yield return item2; } SendPackage(package); void SendPackage(ZPackage pkg) { string text = Name + " ConfigSync"; if (isServer) { peer.m_rpc.Invoke(text, new object[1] { pkg }); } else { rpc.InvokeRoutedRPC(peer.m_server ? 0 : peer.m_uid, text, new object[1] { pkg }); } } IEnumerable<bool> waitForQueue() { float timeout = Time.time + 30f; while (peer.m_socket.GetSendQueueSize() > 20000) { if (Time.time > timeout) { Debug.Log((object)$"Disconnecting {peer.m_uid} after 30 seconds config sending timeout"); peer.m_rpc.Invoke("Error", new object[1] { (object)(ConnectionStatus)5 }); ZNet.instance.Disconnect(peer); break; } yield return false; } } } private IEnumerator sendZPackage(long target, ZPackage package) { if (!Object.op_Implicit((Object)(object)ZNet.instance)) { return Enumerable.Empty<object>().GetEnumerator(); } List<ZNetPeer> list = (List<ZNetPeer>)AccessTools.DeclaredField(typeof(ZRoutedRpc), "m_peers").GetValue(ZRoutedRpc.instance); if (target != ZRoutedRpc.Everybody) { list = list.Where([<96333303-3991-4a70-9b4c-65dcc637fcba>NullableContext(0)] (ZNetPeer p) => p.m_uid == target).ToList(); } return sendZPackage(list, package); } private IEnumerator sendZPackage(List<ZNetPeer> peers, ZPackage package) { if (!Object.op_Implicit((Object)(object)ZNet.instance)) { yield break; } byte[] rawData = package.GetArray(); if (rawData != null && rawData.LongLength > 10000) { ZPackage compressedPackage = new ZPackage(); compressedPackage.Write((byte)4); MemoryStream output = new MemoryStream(); using (DeflateStream deflateStream = new DeflateStream(output, CompressionLevel.Optimal)) { deflateStream.Write(rawData, 0, rawData.Length); } compressedPackage.Write(output.ToArray()); package = compressedPackage; } List<IEnumerator<bool>> writers = (from peer in peers where peer.IsReady() select peer into p select distributeConfigToPeers(p, package)).ToList(); writers.RemoveAll((IEnumerator<bool> writer) => !writer.MoveNext()); while (writers.Count > 0) { yield return null; writers.RemoveAll((IEnumerator<bool> writer) => !writer.MoveNext()); } } private void Broadcast(long target, params ConfigEntryBase[] configs) { if (!IsLocked || isServer) { ZPackage package = ConfigsToPackage(configs); ZNet instance = ZNet.instance; if (instance != null) { ((MonoBehaviour)instance).StartCoroutine(sendZPackage(target, package)); } } } private void Broadcast(long target, params CustomSyncedValueBase[] customValues) { if (!IsLocked || isServer) { ZPackage package = ConfigsToPackage(null, customValues); ZNet instance = ZNet.instance; if (instance != null) { ((MonoBehaviour)instance).StartCoroutine(sendZPackage(target, package)); } } } [return: <8535e035-0e36-41ba-9121-a6c0546a37c5>Nullable(2)] private static OwnConfigEntryBase configData(ConfigEntryBase config) { return config.Description.Tags?.OfType<OwnConfigEntryBase>().SingleOrDefault(); } [return: <8535e035-0e36-41ba-9121-a6c0546a37c5>Nullable(new byte[] { 2, 1 })] public static SyncedConfigEntry<T> ConfigData<[<8535e035-0e36-41ba-9121-a6c0546a37c5>Nullable(2)] T>(ConfigEntry<T> config) { return ((ConfigEntryBase)config).Description.Tags?.OfType<SyncedConfigEntry<T>>().SingleOrDefault(); } private static T configAttribute<[<8535e035-0e36-41ba-9121-a6c0546a37c5>Nullable(2)] T>(ConfigEntryBase config) { return config.Description.Tags.OfType<T>().First(); } private static Type configType(ConfigEntryBase config) { return configType(config.SettingType); } private static Type configType(Type type) { return type.IsEnum ? Enum.GetUnderlyingType(type) : type; } private static ZPackage ConfigsToPackage([<8535e035-0e36-41ba-9121-a6c0546a37c5>Nullable(new byte[] { 2, 1 })] IEnumerable<ConfigEntryBase> configs = null, [<8535e035-0e36-41ba-9121-a6c0546a37c5>Nullable(new byte[] { 2, 1 })] IEnumerable<CustomSyncedValueBase> customValues = null, [<8535e035-0e36-41ba-9121-a6c0546a37c5>Nullable(new byte[] { 2, 1 })] IEnumerable<PackageEntry> packageEntries = null, bool partial = true) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown List<ConfigEntryBase> list = configs?.Where([<96333303-3991-4a70-9b4c-65dcc637fcba>NullableContext(0)] (ConfigEntryBase config) => configData(config).SynchronizedConfig).ToList() ?? new List<ConfigEntryBase>(); List<CustomSyncedValueBase> list2 = customValues?.ToList() ?? new List<CustomSyncedValueBase>(); ZPackage val = new ZPackage(); val.Write((byte)(partial ? 1 : 0)); val.Write(list.Count + list2.Count + (packageEntries?.Count() ?? 0)); foreach (PackageEntry item in packageEntries ?? Array.Empty<PackageEntry>()) { AddEntryToPackage(val, item); } foreach (CustomSyncedValueBase item2 in list2) { AddEntryToPackage(val, new PackageEntry { section = "Internal", key = item2.Identifier, type = item2.Type, value = item2.BoxedValue }); } foreach (ConfigEntryBase item3 in list) { AddEntryToPackage(val, new PackageEntry { section = item3.Definition.Section, key = item3.Definition.Key, type = configType(item3), value = item3.BoxedValue }); } return val; } private static void AddEntryToPackage(ZPackage package, PackageEntry entry) { package.Write(entry.section); package.Write(entry.key); package.Write((entry.value == null) ? "" : GetZPackageTypeString(entry.type)); AddValueToZPackage(package, entry.value); } private static string GetZPackageTypeString(Type type) { return type.AssemblyQualifiedName; } private static void AddValueToZPackage(ZPackage package, [<8535e035-0e36-41ba-9121-a6c0546a37c5>Nullable(2)] object value) { Type type = value?.GetType(); if (value is Enum) { value = ((IConvertible)value).ToType(Enum.GetUnderlyingType(value.GetType()), CultureInfo.InvariantCulture); } else { if (value is ICollection collection) { package.Write(collection.Count); { foreach (object item in collection) { AddValueToZPackage(package, item); } return; } } if ((object)type != null && type.IsValueType && !type.IsPrimitive) { FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); package.Write(fields.Length); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { package.Write(GetZPackageTypeString(fieldInfo.FieldType)); AddValueToZPackage(package, fieldInfo.GetValue(value)); } return; } } ZRpc.Serialize(new object[1] { value }, ref package); } private static object ReadValueWithTypeFromZPackage(ZPackage package, Type type) { if ((object)type != null && type.IsValueType && !type.IsPrimitive && !type.IsEnum) { FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); int num = package.ReadInt(); if (num != fields.Length) { throw new InvalidDeserializationTypeException { received = $"(field count: {num})", expected = $"(field count: {fields.Length})" }; } object uninitializedObject = FormatterServices.GetUninitializedObject(type); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { string text = package.ReadString(); if (text != GetZPackageTypeString(fieldInfo.FieldType)) { throw new InvalidDeserializationTypeException { received = text, expected = GetZPackageTypeString(fieldInfo.FieldType), field = fieldInfo.Name }; } fieldInfo.SetValue(uninitializedObject, ReadValueWithTypeFromZPackage(package, fieldI