Decompiled source of LegacyWard v1.1.1
LegacyWard.dll
Decompiled 6 hours 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 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.1")] [assembly: AssemblyCompany("WackyMole")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.1.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<4cdc6acb-0fc9-439d-a20f-3894cf6fb6cf>Embedded] internal sealed class <4cdc6acb-0fc9-439d-a20f-3894cf6fb6cf>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [<4cdc6acb-0fc9-439d-a20f-3894cf6fb6cf>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class <9d0d04f1-a0e7-49ae-b6e9-38aabb39616e>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <9d0d04f1-a0e7-49ae-b6e9-38aabb39616e>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <9d0d04f1-a0e7-49ae-b6e9-38aabb39616e>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [<4cdc6acb-0fc9-439d-a20f-3894cf6fb6cf>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class <9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContextAttribute : Attribute { public readonly byte Flag; public <9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace LegacyWard { [BepInPlugin("WackyMole.LegacyWard", "LegacyWard", "1.1.1")] [<9d0d04f1-a0e7-49ae-b6e9-38aabb39616e>Nullable(0)] [<9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContext(1)] public class Wackyward : BaseUnityPlugin { [HarmonyPatch(typeof(Player), "PlacePiece")] [<9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContext(0)] private static class PlacePiece_PatchLegacyWArd { [<9704865e-d91e-41d7-85d2-f1c3ea399eae>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); return false; } return true; } } [<9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContext(0)] [HarmonyPatch(typeof(ZNetScene), "Awake")] private static class ZNetScene_Awake_Patch { [<9704865e-d91e-41d7-85d2-f1c3ea399eae>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")] [<9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContext(0)] private static class AudioMan_Awake_Patch { [<9704865e-d91e-41d7-85d2-f1c3ea399eae>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; } } } } [<9d0d04f1-a0e7-49ae-b6e9-38aabb39616e>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_0128: 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()) { _instances.Add(this); _piece = ((Component)this).GetComponent<Piece>(); _container = ((Component)this).GetComponentInChildren<Container>(); _wardMaterials = (from x in ((Component)((Component)this).transform).GetComponentsInChildren<MeshRenderer>(true) select ((Renderer)x).material).ToList(); ((MonoBehaviour)this).InvokeRepeating("UpdateStatus", 1f, 1f); if (_znet.IsOwner() && GetCreatorName() == "") { Setup(Game.instance.GetPlayerProfile().GetName(), ((int)ZNet.m_onlineBackend == 0) ? PrivilegeManager.GetNetworkUserId().Split(new char[1] { '_' })[1] : PrivilegeManager.GetNetworkUserId()); } ((Component)_areaMarker_main).gameObject.SetActive(false); _text.ForEach(delegate(Text x) { x.text = CustomString; }); _fog = ((Component)((Component)this).transform.Find("Scaler/Fog")).gameObject; } } 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>)([<9704865e-d91e-41d7-85d2-f1c3ea399eae>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>)([<9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContext(0)] (ItemData x) => ((Object)x.m_dropPrefab).name == item.Key)) != null) { num += item.Value; } } Radius = num; } private void UpdateStatus() { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) bool isEnabled = IsEnabled; if (isEnabled) { _wardMaterials.ForEach(delegate(Material m) { m.EnableKeyword("_EMISSION"); }); _fog.SetActive(true); } else { _wardMaterials.ForEach(delegate(Material m) { m.DisableKeyword("_EMISSION"); }); _fog.SetActive(false); } 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([<9704865e-d91e-41d7-85d2-f1c3ea399eae>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([<9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContext(0)] (KeyValuePair<long, string> player) => player.Key == playerID); } [return: <9d0d04f1-a0e7-49ae-b6e9-38aabb39616e>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([<9d0d04f1-a0e7-49ae-b6e9-38aabb39616e>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([<9704865e-d91e-41d7-85d2-f1c3ea399eae>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(([<9d0d04f1-a0e7-49ae-b6e9-38aabb39616e>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([<9704865e-d91e-41d7-85d2-f1c3ea399eae>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"; } } [<9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContext(0)] private enum PlayerStatus { VIP, User } [<9d0d04f1-a0e7-49ae-b6e9-38aabb39616e>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)); } } [<9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContext(0)] [HarmonyPatch(typeof(Player), "CheckCanRemovePiece")] internal static class Player_CheckDebug { [<9704865e-d91e-41d7-85d2-f1c3ea399eae>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; } } [<9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContext(0)] [HarmonyPatch(typeof(ZDOMan), "HandleDestroyedZDO")] private static class ZDOMan_Patch { private static readonly int WackyWard_id = StringExtensionMethods.GetStableHashCode("WackyWard_id"); [<9704865e-d91e-41d7-85d2-f1c3ea399eae>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")] [<9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContext(0)] private static class ZnetSync { [<9704865e-d91e-41d7-85d2-f1c3ea399eae>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) }); } } } [HarmonyPatch(typeof(Game), "Start")] [<9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContext(0)] private static class Game_Start_Patch { private static void Postfix() { _canPlaceWard = false; } } [HarmonyPatch(typeof(Container), "Interact")] [<9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContext(0)] private static class Container_Interact_Patch { [<9704865e-d91e-41d7-85d2-f1c3ea399eae>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; } } [<9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContext(0)] [HarmonyPatch(typeof(Container), "GetHoverText")] private static class Container_GHT_Patch { [<9704865e-d91e-41d7-85d2-f1c3ea399eae>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; } } [<9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContext(0)] [HarmonyPatch(typeof(Door), "Interact")] private static class Door_Interact_Patch { [<9704865e-d91e-41d7-85d2-f1c3ea399eae>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; } } [<9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContext(0)] [HarmonyPatch(typeof(Door), "GetHoverText")] private static class Door_Hover_Patch { [<9704865e-d91e-41d7-85d2-f1c3ea399eae>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")] [<9704865e-d91e-41d7-85d2-f1c3ea399eae>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); } } } [HarmonyPatch(typeof(ItemDrop), "Interact")] [<9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContext(0)] private static class ItemDrop_Interact_Patch { [<9704865e-d91e-41d7-85d2-f1c3ea399eae>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); } } [<9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContext(0)] [HarmonyPatch(typeof(CraftingStation), "Interact")] private static class CraftingStation_Interact_Patch { [<9704865e-d91e-41d7-85d2-f1c3ea399eae>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); } } [<9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContext(0)] [HarmonyPatch(typeof(Player), "AutoPickup")] private static class Player_AutoPickup_Patch { [<9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContext(1)] private static bool Prefix(Player __instance) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return WackyWard_Component.AllowAction(((Component)__instance).transform.position, flash: false); } } [<9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContext(0)] [HarmonyPatch(typeof(WearNTear), "Damage")] private static class WearNTear_Damage_Patch { [<9704865e-d91e-41d7-85d2-f1c3ea399eae>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); } } [HarmonyPatch(typeof(WearNTear), "ApplyDamage")] [<9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContext(0)] private static class WearNTear_Damage_Patch2 { [<9704865e-d91e-41d7-85d2-f1c3ea399eae>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)); } } [<9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContext(0)] [HarmonyPatch(typeof(TeleportWorld), "Teleport")] private static class TeleportWorld_Teleport_Patch { [<9704865e-d91e-41d7-85d2-f1c3ea399eae>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); } } [<9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContext(0)] [HarmonyPatch(typeof(StoreGui), "IsVisible")] private static class Store_IsVisible_Patch { [<9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContext(1)] private static void Postfix(StoreGui __instance, ref bool __result) { __result |= showGUI; } } [HarmonyPatch(typeof(ZNetScene), "Awake")] [<9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContext(0)] private static class ZNetScene_Awake_Patch_Recipe { [<9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContext(1)] private static void Postfix(ZNetScene __instance) { ResetRecipe(null, null); } } internal const string ModName = "LegacyWard"; internal const string VERSION = "1.1.1"; 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<[<9d0d04f1-a0e7-49ae-b6e9-38aabb39616e>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<[<9d0d04f1-a0e7-49ae-b6e9-38aabb39616e>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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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(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)); } private static IEnumerator DelayReloadConfigFile(ConfigFile file) { yield return (object)new WaitForSecondsRealtime(2.5f); file.Reload(); } private static AssetBundle GetAssetBundle(string filename) { Assembly executingAssembly = Assembly.GetExecutingAssembly(); string name = executingAssembly.GetManifestResourceNames().Single([<9704865e-d91e-41d7-85d2-f1c3ea399eae>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([<9704865e-d91e-41d7-85d2-f1c3ea399eae>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 } }; } } } [<9d0d04f1-a0e7-49ae-b6e9-38aabb39616e>Nullable(0)] [<9704865e-d91e-41d7-85d2-f1c3ea399eae>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 LocalizationManager { [<9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContext(1)] [PublicAPI] [<9d0d04f1-a0e7-49ae-b6e9-38aabb39616e>Nullable(0)] public class Localizer { private static readonly Dictionary<string, Dictionary<string, Func<string>>> PlaceholderProcessors; private static readonly Dictionary<string, Dictionary<string, string>> loadedTexts; private static readonly ConditionalWeakTable<Localization, string> localizationLanguage; private static readonly List<WeakReference<Localization>> localizationObjects; [<9d0d04f1-a0e7-49ae-b6e9-38aabb39616e>Nullable(2)] private static BaseUnityPlugin _plugin; private static readonly List<string> fileExtensions; private static BaseUnityPlugin plugin { get { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown if (_plugin == null) { IEnumerable<TypeInfo> source; try { source = Assembly.GetExecutingAssembly().DefinedTypes.ToList(); } catch (ReflectionTypeLoadException ex) { source = from t in ex.Types where t != null select t.GetTypeInfo(); } _plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First([<9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t))); } return _plugin; } } private static void UpdatePlaceholderText(Localization localization, string key) { localizationLanguage.TryGetValue(localization, out var value); string text = loadedTexts[value][key]; if (PlaceholderProcessors.TryGetValue(key, out var value2)) { text = value2.Aggregate(text, [<9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContext(0)] (string current, KeyValuePair<string, Func<string>> kv) => current.Replace("{" + kv.Key + "}", kv.Value())); } localization.AddWord(key, text); } public static void AddPlaceholder<T>(string key, string placeholder, ConfigEntry<T> config, [<9d0d04f1-a0e7-49ae-b6e9-38aabb39616e>Nullable(new byte[] { 2, 1, 1 })] Func<T, string> convertConfigValue = null) { if (convertConfigValue == null) { convertConfigValue = (T val) => val.ToString(); } if (!PlaceholderProcessors.ContainsKey(key)) { PlaceholderProcessors[key] = new Dictionary<string, Func<string>>(); } config.SettingChanged += [<9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContext(0)] (object _, EventArgs _) => { UpdatePlaceholder(); }; if (loadedTexts.ContainsKey(Localization.instance.GetSelectedLanguage())) { UpdatePlaceholder(); } void UpdatePlaceholder() { PlaceholderProcessors[key][placeholder] = () => convertConfigValue(config.Value); UpdatePlaceholderText(Localization.instance, key); } } public static void AddText(string key, string text) { List<WeakReference<Localization>> list = new List<WeakReference<Localization>>(); foreach (WeakReference<Localization> localizationObject in localizationObjects) { if (localizationObject.TryGetTarget(out var target)) { Dictionary<string, string> dictionary = loadedTexts[localizationLanguage.GetOrCreateValue(target)]; if (!target.m_translations.ContainsKey(key)) { dictionary[key] = text; target.AddWord(key, text); } } else { list.Add(localizationObject); } } foreach (WeakReference<Localization> item in list) { localizationObjects.Remove(item); } } public static void Load() { LoadLocalization(Localization.instance, Localization.instance.GetSelectedLanguage()); } private static void LoadLocalization(Localization __instance, string language) { if (!localizationLanguage.Remove(__instance)) { localizationObjects.Add(new WeakReference<Localization>(__instance)); } localizationLanguage.Add(__instance, language); Dictionary<string, string> dictionary = new Dictionary<string, string>(); foreach (string item in from f in Directory.GetFiles(Path.GetDirectoryName(Paths.PluginPath), plugin.Info.Metadata.Name + ".*", SearchOption.AllDirectories) where fileExtensions.IndexOf(Path.GetExtension(f)) >= 0 select f) { string text = Path.GetFileNameWithoutExtension(item).Split(new char[1] { '.' })[1]; if (dictionary.ContainsKey(text)) { Debug.LogWarning((object)("Duplicate key " + text + " found for " + plugin.Info.Metadata.Name + ". The duplicate file found at " + item + " will be skipped.")); } else { dictionary[text] = item; } } byte[] array = LoadTranslationFromAssembly("English"); if (array == null) { throw new Exception("Found no English localizations in mod " + plugin.Info.Metadata.Name + ". Expected an embedded resource translations/English.json or translations/English.yml."); } Dictionary<string, string> dictionary2 = new DeserializerBuilder().IgnoreFields().Build().Deserialize<Dictionary<string, string>>(Encoding.UTF8.GetString(array)); if (dictionary2 == null) { throw new Exception("Localization for mod " + plugin.Info.Metadata.Name + " failed: Localization file was empty."); } string text2 = null; if (language != "English") { if (dictionary.ContainsKey(language)) { text2 = File.ReadAllText(dictionary[language]); } else { byte[] array2 = LoadTranslationFromAssembly(language); if (array2 != null) { text2 = Encoding.UTF8.GetString(array2); } } } if (text2 == null && dictionary.ContainsKey("English")) { text2 = File.ReadAllText(dictionary["English"]); } if (text2 != null) { foreach (KeyValuePair<string, string> item2 in new DeserializerBuilder().IgnoreFields().Build().Deserialize<Dictionary<string, string>>(text2) ?? new Dictionary<string, string>()) { dictionary2[item2.Key] = item2.Value; } } loadedTexts[language] = dictionary2; foreach (KeyValuePair<string, string> item3 in dictionary2) { UpdatePlaceholderText(__instance, item3.Key); } } static Localizer() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown PlaceholderProcessors = new Dictionary<string, Dictionary<string, Func<string>>>(); loadedTexts = new Dictionary<string, Dictionary<string, string>>(); localizationLanguage = new ConditionalWeakTable<Localization, string>(); localizationObjects = new List<WeakReference<Localization>>(); fileExtensions = new List<string> { ".json", ".yml" }; new Harmony("org.bepinex.helpers.LocalizationManager").Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "LoadCSV", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "LoadLocalization", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } [return: <9d0d04f1-a0e7-49ae-b6e9-38aabb39616e>Nullable(2)] private static byte[] LoadTranslationFromAssembly(string language) { foreach (string fileExtension in fileExtensions) { byte[] array = ReadEmbeddedFileBytes("translations." + language + fileExtension); if (array != null) { return array; } } return null; } [<9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContext(2)] public static byte[] ReadEmbeddedFileBytes([<9d0d04f1-a0e7-49ae-b6e9-38aabb39616e>Nullable(1)] string resourceFileName, Assembly containingAssembly = null) { using MemoryStream memoryStream = new MemoryStream(); if ((object)containingAssembly == null) { containingAssembly = Assembly.GetCallingAssembly(); } string text = containingAssembly.GetManifestResourceNames().FirstOrDefault([<9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContext(0)] (string str) => str.EndsWith(resourceFileName, StringComparison.Ordinal)); if (text != null) { containingAssembly.GetManifestResourceStream(text)?.CopyTo(memoryStream); } return (memoryStream.Length == 0L) ? null : memoryStream.ToArray(); } } } namespace WardIsLove.API { [<9704865e-d91e-41d7-85d2-f1c3ea399eae>NullableContext(2)] [<9d0d04f1-a0e7-49ae-b6e9-38aabb39616e>Nullable(0)] [PublicAPI] public class API { [<9704865e-d91e-41d7-85d2-f1c3ea399eae>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); } } } [<9704865e-d91e-41d7-85d2-f1c3ea399eae>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; } [<9704865e-d91e-41d7-85d2-f1c3ea399eae>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; } [<9704865e-d91e-41d7-85d2-f1c3ea399eae>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] [<4bf02b67-da62-4e8b-bf35-b714c8aedab3>Embedded] internal sealed class <4bf02b67-da62-4e8b-bf35-b714c8aedab3>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [<4bf02b67-da62-4e8b-bf35-b714c8aedab3>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] [CompilerGenerated] internal sealed class <eea401f7-f977-49e0-bce9-60760102f9f6>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <eea401f7-f977-49e0-bce9-60760102f9f6>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <eea401f7-f977-49e0-bce9-60760102f9f6>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [<4bf02b67-da62-4e8b-bf35-b714c8aedab3>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class <561af775-47e6-4b73-843f-53c61e9cd5de>NullableContextAttribute : Attribute { public readonly byte Flag; public <561af775-47e6-4b73-843f-53c61e9cd5de>NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [<4bf02b67-da62-4e8b-bf35-b714c8aedab3>Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ServerSync { [<561af775-47e6-4b73-843f-53c61e9cd5de>NullableContext(1)] [PublicAPI] [<eea401f7-f977-49e0-bce9-60760102f9f6>Nullable(0)] internal abstract class OwnConfigEntryBase { [<eea401f7-f977-49e0-bce9-60760102f9f6>Nullable(2)] public object LocalBaseValue; public bool SynchronizedConfig = true; public abstract ConfigEntryBase BaseConfig { get; } } [PublicAPI] [<eea401f7-f977-49e0-bce9-60760102f9f6>Nullable(0)] [<561af775-47e6-4b73-843f-53c61e9cd5de>NullableContext(1)] internal class SyncedConfigEntry<[<eea401f7-f977-49e0-bce9-60760102f9f6>Nullable(2)] T> : OwnConfigEntryBase { public readonly ConfigEntry<T> SourceConfig; public override ConfigEntryBase BaseConfig => (ConfigEntryBase)(object)SourceConfig; public T Value { get { return SourceConfig.Value; } set { SourceConfig.Value = value; } } public SyncedConfigEntry(ConfigEntry<T> sourceConfig) { SourceConfig = sourceConfig; } public void AssignLocalValue(T value) { if (LocalBaseValue == null) { Value = value; } else { LocalBaseValue = value; } } } [<eea401f7-f977-49e0-bce9-60760102f9f6>Nullable(0)] [<561af775-47e6-4b73-843f-53c61e9cd5de>NullableContext(2)] internal abstract class CustomSyncedValueBase { public object LocalBaseValue; [<eea401f7-f977-49e0-bce9-60760102f9f6>Nullable(1)] public readonly string Identifier; [<eea401f7-f977-49e0-bce9-60760102f9f6>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; [<561af775-47e6-4b73-843f-53c61e9cd5de>NullableContext(1)] protected CustomSyncedValueBase(ConfigSync configSync, string identifier, Type type, int priority) { Priority = priority; Identifier = identifier; Type = type; configSync.AddCustomValue(this); localIsOwner = configSync.IsSourceOfTruth; configSync.SourceOfTruthChanged += delegate(bool truth) { localIsOwner = truth; }; } } [PublicAPI] [<eea401f7-f977-49e0-bce9-60760102f9f6>Nullable(0)] [<561af775-47e6-4b73-843f-53c61e9cd5de>NullableContext(1)] internal sealed class CustomSyncedValue<[<eea401f7-f977-49e0-bce9-60760102f9f6>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; } [<561af775-47e6-4b73-843f-53c61e9cd5de>NullableContext(1)] [<eea401f7-f977-49e0-bce9-60760102f9f6>Nullable(0)] [PublicAPI] internal class ConfigSync { [<561af775-47e6-4b73-843f-53c61e9cd5de>NullableContext(0)] [HarmonyPatch(typeof(ZRpc), "HandlePackage")] private static class SnatchCurrentlyHandlingRPC { [<eea401f7-f977-49e0-bce9-60760102f9f6>Nullable(2)] public static ZRpc currentRpc; [<561af775-47e6-4b73-843f-53c61e9cd5de>NullableContext(1)] [HarmonyPrefix] private static void Prefix(ZRpc __instance) { currentRpc = __instance; } } [<561af775-47e6-4b73-843f-53c61e9cd5de>NullableContext(0)] [HarmonyPatch(typeof(ZNet), "Awake")] internal static class RegisterRPCPatch { [<561af775-47e6-4b73-843f-53c61e9cd5de>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()); } [<561af775-47e6-4b73-843f-53c61e9cd5de>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)); } } [<561af775-47e6-4b73-843f-53c61e9cd5de>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); } } } } } [<561af775-47e6-4b73-843f-53c61e9cd5de>NullableContext(0)] [HarmonyPatch(typeof(ZNet), "OnNewConnection")] private static class RegisterClientRPCPatch { [<561af775-47e6-4b73-843f-53c61e9cd5de>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); } } } [<561af775-47e6-4b73-843f-53c61e9cd5de>NullableContext(0)] private class ParsedConfigs { [<eea401f7-f977-49e0-bce9-60760102f9f6>Nullable(new byte[] { 1, 1, 2 })] public readonly Dictionary<OwnConfigEntryBase, object> configValues = new Dictionary<OwnConfigEntryBase, object>(); [<eea401f7-f977-49e0-bce9-60760102f9f6>Nullable(new byte[] { 1, 1, 2 })] public readonly Dictionary<CustomSyncedValueBase, object> customValues = new Dictionary<CustomSyncedValueBase, object>(); } [HarmonyPatch(typeof(ZNet), "Shutdown")] [<561af775-47e6-4b73-843f-53c61e9cd5de>NullableContext(0)] 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")] [<eea401f7-f977-49e0-bce9-60760102f9f6>Nullable(0)] private class SendConfigsAfterLogin { [<eea401f7-f977-49e0-bce9-60760102f9f6>Nullable(0)] private class BufferingSocket : ISocket { public volatile bool finished = false; public volatile int versionMatchQueued = -1; public readonly List<ZPackage> Package = new List<ZPackage>(); public readonly ISocket Original; public BufferingSocket(ISocket original) { Original = original; } public bool IsConnected() { return Original.IsConnected(); } public ZPackage Recv() { return Original.Recv(); } public int GetSendQueueSize() { return Original.GetSendQueueSize(); } public int GetCurrentSendRate() { return Original.GetCurrentSendRate(); } public bool IsHost() { return Original.IsHost(); } public void Dispose() { Original.Dispose(); } public bool GotNewData() { return Original.GotNewData(); } public void Close() { Original.Close(); } public string GetEndPointString() { return Original.GetEndPointString(); } public void GetAndResetStats(out int totalSent, out int totalRecv) { Original.GetAndResetStats(ref totalSent, ref totalRecv); } public void GetConnectionQuality(out float localQuality, out float remoteQuality, out int ping, out float outByteSec, out float inByteSec) { Original.GetConnectionQuality(ref localQuality, ref remoteQuality, ref ping, ref outByteSec, ref inByteSec); } public ISocket Accept() { return Original.Accept(); } public int GetHostPort() { return Original.GetHostPort(); } public bool Flush() { return Original.Flush(); } public string GetHostName() { return Original.GetHostName(); } public void VersionMatch() { if (finished) { Original.VersionMatch(); } else { versionMatchQueued = Package.Count; } } public void Send(ZPackage pkg) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown int pos = pkg.GetPos(); pkg.SetPos(0); int num = pkg.ReadInt(); if ((num == StringExtensionMethods.GetStableHashCode("PeerInfo") || num == StringExtensionMethods.GetStableHashCode("RoutedRPC") || num == StringExtensionMethods.GetStableHashCode("ZDOData")) && !finished) { ZPackage val = new ZPackage(pkg.GetArray()); val.SetPos(pos); Package.Add(val); } else { pkg.SetPos(pos); Original.Send(pkg); } } } [HarmonyPriority(800)] [HarmonyPrefix] private static void Prefix([<eea401f7-f977-49e0-bce9-60760102f9f6>Nullable(new byte[] { 2, 1, 1 })] ref Dictionary<Assembly, BufferingSocket> __state, ZNet __instance, ZRpc rpc) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Invalid comparison between Unknown and I4 if (__instance.IsServer()) { BufferingSocket value = new BufferingSocket(rpc.GetSocket()); AccessTools.DeclaredField(typeof(ZRpc), "m_socket").SetValue(rpc, value); object? obj = AccessTools.DeclaredMethod(typeof(ZNet), "GetPeer", new Type[1] { typeof(ZRpc) }, (Type[])null).Invoke(__instance, new object[1] { rpc }); ZNetPeer val = (ZNetPeer)((obj is ZNetPeer) ? obj : null); if (val != null && (int)ZNet.m_onlineBackend > 0) { AccessTools.DeclaredField(typeof(ZNetPeer), "m_socket").SetValue(val, value); } if (__state == null) { __state = new Dictionary<Assembly, BufferingSocket>(); } __state[Assembly.GetExecutingAssembly()] = value; } } [HarmonyPostfix] private static void Postfix(Dictionary<Assembly, BufferingSocket> __state, ZNet __instance, ZRpc rpc) { ZNetPeer peer; if (__instance.IsServer()) { object obj = AccessTools.DeclaredMethod(typeof(ZNet), "GetPeer", new Type[1] { typeof(ZRpc) }, (Type[])null).Invoke(__instance, new object[1] { rpc }); peer = (ZNetPeer)((obj is ZNetPeer) ? obj : null); if (peer == null) { SendBufferedData(); } else { ((MonoBehaviour)__instance).StartCoroutine(sendAsync()); } } void SendBufferedData() { if (rpc.GetSocket() is BufferingSocket bufferingSocket) { AccessTools.DeclaredField(typeof(ZRpc), "m_socket").SetValue(rpc, bufferingSocket.Original); object? obj2 = AccessTools.DeclaredMethod(typeof(ZNet), "GetPeer", new Type[1] { typeof(ZRpc) }, (Type[])null).Invoke(__instance, new object[1] { rpc }); ZNetPeer val = (ZNetPeer)((obj2 is ZNetPeer) ? obj2 : null); if (val != null) { AccessTools.DeclaredField(typeof(ZNetPeer), "m_socket").SetValue(val, bufferingSocket.Original); } } BufferingSocket bufferingSocket2 = __state[Assembly.GetExecutingAssembly()]; bufferingSocket2.finished = true; for (int i = 0; i < bufferingSocket2.Package.Count; i++) { if (i == bufferingSocket2.versionMatchQueued) { bufferingSocket2.Original.VersionMatch(); } bufferingSocket2.Original.Send(bufferingSocket2.Package[i]); } if (bufferingSocket2.Package.Count == bufferingSocket2.versionMatchQueued) { bufferingSocket2.Original.VersionMatch(); } } IEnumerator sendAsync() { foreach (ConfigSync configSync in configSyncs) { List<PackageEntry> entries = new List<PackageEntry>(); if (configSync.CurrentVersion != null) { entries.Add(new PackageEntry { section = "Internal", key = "serverversion", type = typeof(string), value = configSync.CurrentVersion }); } MethodInfo listContainsId = AccessTools.DeclaredMethod(typeof(ZNet), "ListContainsId", (Type[])null, (Type[])null); SyncedList adminList = (SyncedList)AccessTools.DeclaredField(typeof(ZNet), "m_adminList").GetValue(ZNet.instance); entries.Add(new PackageEntry { section = "Internal", key = "lockexempt", type = typeof(bool), value = (((object)listContainsId == null) ? ((object)adminList.Contains(rpc.GetSocket().GetHostName())) : listContainsId.Invoke(ZNet.instance, new object[2] { adminList, rpc.GetSocket().GetHostName() })) }); ZPackage package = ConfigsToPackage(configSync.allConfigs.Select([<561af775-47e6-4b73-843f-53c61e9cd5de>NullableContext(0)] (OwnConfigEntryBase c) => c.BaseConfig), configSync.allCustomValues, entries, partial: false); yield return ((MonoBehaviour)__instance).StartCoroutine(configSync.sendZPackage(new List<ZNetPeer> { peer }, package)); } SendBufferedData(); } } } [<eea401f7-f977-49e0-bce9-60760102f9f6>Nullable(0)] private class PackageEntry { public string section = null; public string key = null; public Type type = null; [<eea401f7-f977-49e0-bce9-60760102f9f6>Nullable(2)] public object value; } [<561af775-47e6-4b73-843f-53c61e9cd5de>NullableContext(0)] [HarmonyPatch(typeof(ConfigEntryBase), "GetSerializedValue")] private static class PreventSavingServerInfo { [<561af775-47e6-4b73-843f-53c61e9cd5de>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")] [<561af775-47e6-4b73-843f-53c61e9cd5de>NullableContext(0)] private static class PreventConfigRereadChangingValues { [HarmonyPrefix] [<561af775-47e6-4b73-843f-53c61e9cd5de>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; } } [<eea401f7-f977-49e0-bce9-60760102f9f6>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; [<eea401f7-f977-49e0-bce9-60760102f9f6>Nullable(2)] public string DisplayName; [<eea401f7-f977-49e0-bce9-60760102f9f6>Nullable(2)] public string CurrentVersion; [<eea401f7-f977-49e0-bce9-60760102f9f6>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; [<eea401f7-f977-49e0-bce9-60760102f9f6>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[]>>(); [<eea401f7-f977-49e0-bce9-60760102f9f6>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; [<eea401f7-f977-49e0-bce9-60760102f9f6>Nullable(2)] [method: <561af775-47e6-4b73-843f-53c61e9cd5de>NullableContext(2)] [field: <eea401f7-f977-49e0-bce9-60760102f9f6>Nullable(2)] public event Action<bool> SourceOfTruthChanged; [<eea401f7-f977-49e0-bce9-60760102f9f6>Nullable(2)] [method: <561af775-47e6-4b73-843f-53c61e9cd5de>NullableContext(2)] [field: <eea401f7-f977-49e0-bce9-60760102f9f6>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<[<eea401f7-f977-49e0-bce9-60760102f9f6>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 += [<561af775-47e6-4b73-843f-53c61e9cd5de>NullableContext(0)] (object _, EventArgs _) => { if (!ProcessingServerUpdate && syncedEntry.SynchronizedConfig) { Broadcast(ZRoutedRpc.Everybody, (ConfigEntryBase)configEntry); } }; allConfigs.Add(syncedEntry); } return syncedEntry; } public SyncedConfigEntry<T> AddLockingConfigEntry<[<eea401f7-f977-49e0-bce9-60760102f9f6>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 += [<561af775-47e6-4b73-843f-53c61e9cd5de>NullableContext(0)] (object _, EventArgs _) => { this.lockedConfigChanged?.Invoke(); }; return (SyncedConfigEntry<T>)lockedConfig; } internal void AddCustomValue(CustomSyncedValueBase customValue) { if (allCustomValues.Select([<561af775-47e6-4b73-843f-53c61e9cd5de>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([<561af775-47e6-4b73-843f-53c61e9cd5de>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(([<eea401f7-f977-49e0-bce9-60760102f9f6>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([<561af775-47e6-4b73-843f-53c61e9cd5de>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([<561af775-47e6-4b73-843f-53c61e9cd5de>NullableContext(0)] (OwnConfigEntryBase c) => c.SynchronizedConfig).ToDictionary([<561af775-47e6-4b73-843f-53c61e9cd5de>NullableContext(0)] (OwnConfigEntryBase c) => c.BaseConfig.Definition.Section + "_" + c.BaseConfig.Definition.Key, [<561af775-47e6-4b73-843f-53c61e9cd5de>NullableContext(0)] (OwnConfigEntryBase c) => c); Dictionary<string, CustomSyncedValueBase> dictionary2 = allCustomValues.ToDictionary([<561af775-47e6-4b73-843f-53c61e9cd5de>NullableContext(0)] (CustomSyncedValueBase c) => c.Identifier, [<561af775-47e6-4b73-843f-53c61e9cd5de>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([<561af775-47e6-4b73-843f-53c61e9cd5de>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([<561af775-47e6-4b73-843f-53c61e9cd5de>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([<561af775-47e6-4b73-843f-53c61e9cd5de>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([<561af775-47e6-4b73-843f-53c61e9cd5de>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(