Decompiled source of Simple Multi Player v1.2.0
WKMultiPlayerMod.dll
Decompiled 4 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Buffers; using System.Buffers.Binary; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Threading.Tasks; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Steamworks; using Steamworks.Data; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.SceneManagement; using WKMPMod.Component; using WKMPMod.Core; using WKMPMod.Data; using WKMPMod.MK_Component; using WKMPMod.NetWork; using WKMPMod.RemotePlayer; using WKMPMod.Test; using WKMPMod.Util; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("WKMultiPlayerMod")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.2.0.1")] [assembly: AssemblyInformationalVersion("1.2.0.1+cb3c66716b937a5ff34ee39cd1a2aee36b87685a")] [assembly: AssemblyProduct("WKMultiPlayerMod")] [assembly: AssemblyTitle("WKMultiPlayerMod")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.0.1")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } public abstract class Singleton<T> where T : Singleton<T> { private static readonly Lazy<T> _instance = new Lazy<T>(CreateInstance, isThreadSafe: true); public static T Instance => _instance.Value; public static bool IsCreated => _instance.IsValueCreated; private static T CreateInstance() { try { ConstructorInfo constructor = typeof(T).GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null); if (constructor == null) { throw new InvalidOperationException("Singleton<" + typeof(T).Name + ">: Type must have a parameterless constructor"); } return (T)constructor.Invoke(null); } catch (Exception innerException) { throw new InvalidOperationException("Singleton<" + typeof(T).Name + ">: Failed to create instance", innerException); } } protected Singleton() { if (_instance.IsValueCreated) { throw new InvalidOperationException("Singleton<" + typeof(T).Name + ">: Instance already exists. Use " + typeof(T).Name + ".Instance instead."); } } } namespace WKMPMod.Util { public static class Localization { private static Dictionary<string, Dictionary<string, string>> _table = new Dictionary<string, Dictionary<string, string>>(StringComparer.OrdinalIgnoreCase); private static Dictionary<string, string> _flatCache = null; private const string FILE_PREFIX = "texts"; public static void Load() { string path = MPMain.path; string gameLanguage = GetGameLanguage(); string text = "texts_" + gameLanguage.ToLower() + ".json"; string text2 = Path.Combine(path, text); if (!File.Exists(text2)) { MPMain.LogError("[Localization] " + text + " file not found at path: " + text2); text = "texts_en.json"; text2 = Path.Combine(path, text); if (!File.Exists(text2)) { MPMain.LogError("[Localization] Localization file not found, please confirm that texts_en.json file exists"); return; } } try { string text3 = File.ReadAllText(text2); _table = JsonConvert.DeserializeObject<Dictionary<string, Dictionary<string, string>>>(text3); _flatCache = null; int num = 0; foreach (KeyValuePair<string, Dictionary<string, string>> item in _table) { num += item.Value.Count; } MPMain.LogInfo($"[Localization] Successfully loaded {_table.Count} categories with {num} entries"); } catch (Exception ex) { MPMain.LogError("[Localization] Unable to parse localization file: " + ex.Message); } } public static string Get(string key, params object[] args) { if (_flatCache == null) { BuildFlatCache(); } if (!_flatCache.TryGetValue(key, out var value)) { MPMain.LogWarning("[Localization] Key not found: " + key); return key; } if (args == null || args.Length == 0) { return value; } try { return string.Format(value, args); } catch (FormatException ex) { MPMain.LogError("[Localization] Format error for key '" + key + "': " + ex.Message); return value; } } public static string Get(string category, string key, params object[] args) { if (string.IsNullOrEmpty(category)) { MPMain.LogWarning("[Localization] Category is null or empty"); return key; } if (!_table.TryGetValue(category, out var value)) { MPMain.LogWarning("[Localization] Category not found: " + category); return "[" + category + "] " + key; } if (!value.TryGetValue(key, out var value2)) { MPMain.LogWarning("[Localization] Key '" + key + "' not found in category '" + category + "'"); return "[" + category + "] " + key; } if (args == null || args.Length == 0) { return value2; } try { return string.Format(value2, args); } catch (FormatException ex) { MPMain.LogError("[Localization] Format error for '" + category + "." + key + "': " + ex.Message); return value2; } } public static bool HasKey(string key) { if (_flatCache == null) { BuildFlatCache(); } return _flatCache.ContainsKey(key); } public static bool HasKey(string category, string key) { if (_table.TryGetValue(category, out var value)) { return value.ContainsKey(key); } return false; } public static IEnumerable<string> GetAllCategories() { return _table.Keys; } public static IEnumerable<string> GetKeysInCategory(string category) { if (_table.TryGetValue(category, out var value)) { return value.Keys; } return new List<string>(); } private static void BuildFlatCache() { _flatCache = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); foreach (KeyValuePair<string, Dictionary<string, string>> item in _table) { foreach (KeyValuePair<string, string> item2 in item.Value) { string key = item.Key + "." + item2.Key; _flatCache[key] = item2.Value; } } } public static string GetGameLanguage() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Invalid comparison between Unknown and I4 //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Invalid comparison between Unknown and I4 //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Invalid comparison between Unknown and I4 //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Invalid comparison between Unknown and I4 //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Invalid comparison between Unknown and I4 //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Invalid comparison between Unknown and I4 //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Invalid comparison between Unknown and I4 //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Invalid comparison between Unknown and I4 SystemLanguage systemLanguage = Application.systemLanguage; SystemLanguage val = systemLanguage; if ((int)val <= 22) { if ((int)val <= 14) { if ((int)val == 6) { goto IL_0056; } if ((int)val == 14) { return "fr"; } } else { if ((int)val == 15) { return "de"; } if ((int)val == 22) { return "ja"; } } } else if ((int)val <= 30) { if ((int)val == 23) { return "ko"; } if ((int)val == 30) { return "ru"; } } else { if ((int)val == 34) { return "es"; } if ((int)val == 40) { goto IL_0056; } if ((int)val == 41) { return "zh_tw"; } } return "en"; IL_0056: return "zh"; } } public abstract class MonoSingleton<T> : MonoBehaviour where T : MonoSingleton<T> { private static T _instance; private static readonly object _lock = new object(); private static bool _applicationIsQuitting = false; public static T Instance { get { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown if (_applicationIsQuitting) { return null; } lock (_lock) { if ((Object)(object)_instance == (Object)null) { _instance = Object.FindObjectOfType<T>(); if ((Object)(object)_instance == (Object)null) { GameObject val = new GameObject(typeof(T).Name); _instance = val.AddComponent<T>(); Object.DontDestroyOnLoad((Object)(object)val); } } return _instance; } } } protected virtual void Awake() { if ((Object)(object)_instance == (Object)null) { _instance = (T)this; if ((Object)(object)((Component)this).transform.parent == (Object)null) { Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); } } else if ((Object)(object)_instance != (Object)(object)this) { Debug.LogWarning((object)("MonoSingleton<" + typeof(T).Name + ">: Duplicate components were found in the scene and have been automatically destroyed")); Object.Destroy((Object)(object)((Component)this).gameObject); } } protected virtual void OnApplicationQuit() { _applicationIsQuitting = true; } protected virtual void OnDestroy() { if ((Object)(object)_instance == (Object)(object)this) { _instance = null; } } } } namespace WKMPMod.Test { public class Test : MonoBehaviour { public const string NO_ITEM_PREFAB_NAME = "None"; public static float x; public static float y; public static float z; public static ulong id; public static void Main(string[] args) { if (args.Length == 0) { Debug.Log((object)"测试命令需要参数"); return; } string text = args[0]; if (1 == 0) { } switch (text) { case "0": RunCommand(GetGraphicsAPI); break; case "1": RunCommand(GetMPStatus); break; case "2": RunCommand(GetMassData); break; case "3": RunCommand(GetSystemLanguage); break; case "4": RunCommand(delegate { CreateRemotePlayer(args[1..]); }); break; case "5": RunCommand(delegate { RemoveRemotePlayer(args[1..]); }); break; case "6": RunCommand(delegate { UpdateRemoteTag(args[1..]); }); break; case "7": RunCommand(GetAllFactoryList); break; case "8": RunCommand(GetPath); break; case "9": RunCommand(CreateTestPrefab); break; case "10": RunCommand(GetHandCosmetic); break; case "11": RunCommand(CreateDontDestroyGameObject); break; case "12": RunCommand(TestSingleton); break; case "13": RunCommand(SimulationPlayerUpdata); break; default: RunCommand(delegate { Debug.Log((object)("未知命令: " + args[0])); }); break; } if (true) { } } private static bool RunCommand(Action action) { action(); return true; } public static void GetGraphicsAPI() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) Debug.Log((object)$"当前图形API: {SystemInfo.graphicsDeviceType}"); Debug.Log((object)("图形API版本: " + SystemInfo.graphicsDeviceVersion)); int graphicsShaderLevel = SystemInfo.graphicsShaderLevel; Debug.Log((object)$"Shader Model: {graphicsShaderLevel / 10}.{graphicsShaderLevel % 10}"); Debug.Log((object)$"支持计算着色器: {SystemInfo.supportsComputeShaders}"); Debug.Log((object)$"支持几何着色器: {SystemInfo.supportsGeometryShaders}"); Debug.Log((object)$"支持曲面细分: {SystemInfo.supportsTessellationShaders}"); Debug.Log((object)$"支持GPU实例化: {SystemInfo.supportsInstancing}"); } public static void GetMPStatus() { int multiPlayerStatus = (int)MPCore.MultiPlayerStatus; Debug.Log((object)(multiPlayerStatus.ToString() ?? "")); } public static void GetMassData() { SaveData saveData = DEN_DeathFloor.instance.GetSaveData(); Debug.Log((object)$"高度:{saveData.relativeHeight}, 是否活动:{saveData.active}, 速度:{saveData.speed}, 速度乘数:{saveData.speedMult}"); } public static void GetSystemLanguage() { Debug.Log((object)("系统语言:" + Localization.GetGameLanguage())); } public static void CreateRemotePlayer(string[] args) { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown id++; string prefab = "default"; if (args.Length >= 1 && ulong.TryParse(args[0], out var result)) { id = result; } if (args.Length >= 2) { prefab = string.Join(" ", args[1..]); } Singleton<RPManager>.Instance.PlayerCreate(id, prefab); Singleton<RPManager>.Instance.Players[id].HandlePlayerData(new PlayerData { Position = new Vector3(x, y, z) }); y += 4f; } public static void RemoveRemotePlayer(string[] args) { int num = 1; if (args.Length >= 1 && int.TryParse(args[0], out var result)) { num = result; } Singleton<RPManager>.Instance.PlayerRemove((ulong)num); } public static void UpdateRemoteTag(string[] args) { string text = ((args.Length != 0) ? string.Join(" ", args) : "中文测试: 斯卡利茨恐虐神选"); if (Singleton<RPManager>.Instance.Players.TryGetValue(1uL, out var value)) { value.HandleNameTag(text); } else { Debug.LogWarning((object)"玩家ID 1 不存在"); } } public static void GetPath() { MPMain.LogInfo(Paths.PluginPath); MPMain.LogInfo(Assembly.GetExecutingAssembly().Location); MPMain.LogInfo(AppDomain.CurrentDomain.BaseDirectory); MPMain.LogInfo(Application.dataPath); MPMain.LogInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty); MPMain.LogInfo(MPMain.path); } public static void CreateTestPrefab() { AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(MPMain.path, "playerprefab")); BaseRemoteFactory.ListAllAssetsInBundle(val); GameObject val2 = val.LoadAsset<GameObject>("cl_player"); Object.Instantiate<GameObject>(val2); } public static void GetAllFactoryList() { Singleton<RPFactoryManager>.Instance.ListAllFactory(); } public static void GetAllPlayerList() { } public static void GetHandCosmetic() { MPMain.LogWarning("左手皮肤id " + CL_CosmeticManager.GetCosmeticInHand(0).cosmeticData.id); MPMain.LogWarning("右手皮肤id " + CL_CosmeticManager.GetCosmeticInHand(1).cosmeticData.id); } public static void CreateDontDestroyGameObject() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown GameObject val = new GameObject("Test Game Object1"); Object.DontDestroyOnLoad((Object)(object)val); GameObject val2 = new GameObject("Test Game Object2"); } public static void TestSingleton() { MPMain.LogWarning(MonoSingleton<TestMonoSingleton>.Instance.TestString); } public static void SimulationPlayerUpdata() { byte[] array = new byte[1] { 1 }; ArraySegment<byte> data = new ArraySegment<byte>(array); MPEventBusNet.NotifyReceive(1uL, data); } } public class CheatsTest : MonoBehaviour { public static void Main(string[] args) { if (args.Length == 0) { Debug.Log((object)"测试命令需要参数"); return; } string text = args[0]; if (1 == 0) { } switch (text) { case "0": RunCommand(delegate { CreateItem(args[1..]); }); break; case "1": RunCommand(delegate { AddItemInInventory(args[1..]); }); break; case "2": RunCommand(GetInventoryItems); break; case "3": RunCommand(AddItemInInventoryQuaternionTest); break; default: RunCommand(delegate { Debug.Log((object)("未知命令: " + args[0])); }); break; } if (true) { } } private static bool RunCommand(Action action) { action(); return true; } public static void CreateItem(string[] args) { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) Vector3 val = default(Vector3); foreach (string text in args) { if (!(text != "None")) { continue; } GameObject assetGameObject = CL_AssetManager.GetAssetGameObject(text, ""); if ((Object)(object)assetGameObject != (Object)null) { ((Vector3)(ref val))..ctor(Random.Range(-1f, 1f), Random.Range(0f, 0.5f), Random.Range(-1f, 1f)); GameObject val2 = Object.Instantiate<GameObject>(assetGameObject, new Vector3(0f, 0.5f, 0f) + val, Random.rotation); Rigidbody component = val2.GetComponent<Rigidbody>(); if ((Object)(object)component != (Object)null) { Vector3 val3 = new Vector3(Random.Range(-1f, 1f), 1f, Random.Range(-1f, 1f)); Vector3 normalized = ((Vector3)(ref val3)).normalized; float num = Random.Range(3f, 8f); component.AddForce(normalized * num, (ForceMode)1); } } else { MPMain.LogInfo("[MP Debug] 生成物: " + text + " 不存在"); } } } public static void GetInventoryItems() { Inventory instance = Inventory.instance; if ((Object)(object)instance != (Object)null) { List<Item> items = instance.GetItems(true, true); { foreach (Item item in items) { MPMain.LogInfo("物品名称: " + item.itemName + ", 标签: " + item.itemTag + ", 预制体名称: " + item.prefabName); } return; } } MPMain.LogWarning("库存不存在"); } public static void AddItemInInventory(string[] args) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) Inventory instance = Inventory.instance; foreach (string text in args) { if (!(text != "None")) { continue; } GameObject assetGameObject = CL_AssetManager.GetAssetGameObject(text, ""); if ((Object)(object)assetGameObject != (Object)null) { GameObject val = Object.Instantiate<GameObject>(assetGameObject, new Vector3(0f, 0.5f, 0f), Quaternion.identity); Item_Object component = val.GetComponent<Item_Object>(); if ((Object)(object)component != (Object)null) { instance.AddItemToInventoryCenter(component.itemData); ((Component)component).gameObject.SetActive(false); } else { MPMain.LogInfo("[MP Debug] 生成物: " + ((Object)val).name + " 不可放入库存"); } } else { MPMain.LogInfo("[MP Debug] 生成物: " + text + " 不存在"); } } } public static void AddItemInInventoryQuaternionTest() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) Inventory inventory = Inventory.instance; AddItemInInventoryQuaternionTest("Item_Rebar", Quaternion.Euler(90f, 0f, 0f)); AddItemInInventoryQuaternionTest("Item_Rebar_Explosive", Quaternion.Euler(90f, 0f, 0f)); AddItemInInventoryQuaternionTest("Item_RebarRope", Quaternion.Euler(90f, 0f, 0f)); AddItemInInventoryQuaternionTest("Item_Rebar_Holiday", Quaternion.Euler(90f, 0f, 0f)); AddItemInInventoryQuaternionTest("Item_RebarRope_Holiday", Quaternion.Euler(90f, 0f, 0f)); void AddItemInInventoryQuaternionTest(string arg, Quaternion quaternion) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) GameObject assetGameObject = CL_AssetManager.GetAssetGameObject(arg, ""); GameObject val = Object.Instantiate<GameObject>(assetGameObject, new Vector3(0f, 0.5f, 0f), Quaternion.identity); Item_Object component = val.GetComponent<Item_Object>(); component.itemData.bagRotation = quaternion; inventory.AddItemToInventoryCenter(component.itemData); ((Component)component).gameObject.SetActive(false); } } } internal class TestMonoSingleton : MonoSingleton<TestMonoSingleton> { public string TestString = "这是一个测试单例组件类"; protected override void Awake() { base.Awake(); Debug.LogWarning((object)"测试单例组件类初始化"); } protected override void OnDestroy() { base.OnDestroy(); Debug.LogWarning((object)"测试单例组件类销毁"); } } } namespace WKMPMod.RemotePlayer { public abstract class BaseRemoteFactory { private GameObject _cachedPrefab; public string PrefabName { get; set; } public string FactoryId { get; set; } public GameObject Create(string bundlePath) { if ((Object)(object)_cachedPrefab == (Object)null) { _cachedPrefab = LoadAndPrepare(bundlePath); if ((Object)(object)_cachedPrefab == (Object)null) { MPMain.LogError(Localization.Get("RPBaseFactory", "PrefabNotLoaded", PrefabName)); return null; } } return Object.Instantiate<GameObject>(_cachedPrefab); } public GameObject LoadAndPrepare(string path) { AssetBundle val = null; GameObject val2 = null; try { val = AssetBundle.LoadFromFile(path); if ((Object)(object)val == (Object)null) { MPMain.LogError(Localization.Get("RPBaseFactory", "UnableToLoadResources")); return null; } val2 = val.LoadAsset<GameObject>(PrefabName); if ((Object)(object)val2 == (Object)null) { MPMain.LogError(Localization.Get("RPBaseFactory", "PrefabNotLoaded", PrefabName)); return null; } ProcessPrefabMarkers(val2); FixShaders(val2); AddFactoryId(val2); OnPrepare(val2, val); } catch (Exception ex) { MPMain.LogError(Localization.Get("RPBaseFactory", "PreFabProcessingError", ex.GetType().Name, ex.Message, ex.StackTrace)); val2 = null; } finally { if ((Object)(object)val != (Object)null) { val.Unload(false); } } return val2; } protected abstract void OnPrepare(GameObject prefab, AssetBundle bundle); public abstract void Cleanup(GameObject instance); private void FixShaders(GameObject prefab) { Renderer[] componentsInChildren = prefab.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if ((Object)(object)((Component)val).GetComponent<TMP_Text>() != (Object)null) { continue; } Material[] sharedMaterials = val.sharedMaterials; foreach (Material val2 in sharedMaterials) { if (!((Object)(object)val2 == (Object)null)) { MPMain.LogInfo(Localization.Get("RPBaseFactory", "MaterialShaderInfo", ((Object)val2).name, ((Object)val2.shader).name)); Shader val3 = Shader.Find(((Object)val2.shader).name); if ((Object)(object)val3 != (Object)null) { val2.shader = val3; continue; } MPMain.LogError(Localization.Get("RPBaseFactory", "ShaderNotFoundOnRenderer", ((Object)val2.shader).name, ((Object)val).name)); } } } } public void ProcessPrefabMarkers(GameObject prefab) { MK_RemoteEntity[] componentsInChildren = prefab.GetComponentsInChildren<MK_RemoteEntity>(true); MK_RemoteEntity[] array = componentsInChildren; foreach (MK_RemoteEntity val in array) { MapMarkersToRemoteEntity(((Component)val).gameObject, val); } MK_ObjectTagger[] componentsInChildren2 = prefab.GetComponentsInChildren<MK_ObjectTagger>(true); MK_ObjectTagger[] array2 = componentsInChildren2; foreach (MK_ObjectTagger val2 in array2) { MapMarkersToObjectTagger(((Component)val2).gameObject, val2); } MK_CL_Handhold[] componentsInChildren3 = prefab.GetComponentsInChildren<MK_CL_Handhold>(true); MK_CL_Handhold[] array3 = componentsInChildren3; foreach (MK_CL_Handhold val3 in array3) { MapMarkersToCL_Handhold(((Component)val3).gameObject, val3); } LookAt[] componentsInChildren4 = prefab.GetComponentsInChildren<LookAt>(true); LookAt[] array4 = componentsInChildren4; foreach (LookAt val4 in array4) { SetLookAt(((Component)val4).gameObject, val4); } } private void MapMarkersToRemoteEntity(GameObject go, MK_RemoteEntity mk) { RemoteEntity remoteEntity = go.AddComponent<RemoteEntity>(); if ((Object)(object)remoteEntity != (Object)null) { remoteEntity.AllActive = MPConfig.AllActive; remoteEntity.HammerActive = MPConfig.HammerActive; remoteEntity.RebarActive = MPConfig.RebarActive; remoteEntity.ReturnRebarActive = MPConfig.ReturnRebarActive; remoteEntity.RebarExplosionActive = MPConfig.RebarExplosionActive; remoteEntity.ExplosionActive = MPConfig.ExplosionActive; remoteEntity.PitonActive = MPConfig.PitonActive; remoteEntity.FlareActive = MPConfig.FlareActive; remoteEntity.IceActive = MPConfig.IceActive; remoteEntity.OtherActive = MPConfig.OtherActive; } else { MPMain.LogError(Localization.Get("RPBaseFactory", "RemoteEntityAddFailed")); } Object.DestroyImmediate((Object)(object)mk); } private void MapMarkersToObjectTagger(GameObject go, MK_ObjectTagger mk) { ObjectTagger val = go.GetComponent<ObjectTagger>() ?? go.AddComponent<ObjectTagger>(); if ((Object)(object)val != (Object)null) { foreach (string tag in mk.tags) { if (!val.tags.Contains(tag)) { val.tags.Add(tag); } } } else { MPMain.LogError(Localization.Get("RPBaseFactory", "ObjectTaggerAddFailed")); } Object.DestroyImmediate((Object)(object)mk); } private void MapMarkersToCL_Handhold(GameObject go, MK_CL_Handhold mk) { CL_Handhold val = go.AddComponent<CL_Handhold>(); if ((Object)(object)val != (Object)null) { val.activeEvent = mk.activeEvent; val.stopEvent = mk.stopEvent; val.handholdRenderer = mk.handholdRenderer ?? go.GetComponent<Renderer>(); } else { MPMain.LogError(Localization.Get("RPBaseFactory", "CL_HandholdAddFailed")); } Object.DestroyImmediate((Object)(object)mk); } private void SetLookAt(GameObject go, LookAt mk) { mk.userScale = MPConfig.NameTagScale; } private void AddFactoryId(GameObject prefab) { ObjectIdentity val = prefab.AddComponent<ObjectIdentity>(); val.FactoryKey = FactoryId; } public static void ListAllAssetsInBundle(AssetBundle bundle) { MPMain.LogInfo("--- 开始输出 AssetBundle 内容清单: [" + ((Object)bundle).name + "] ---"); string[] allAssetNames = bundle.GetAllAssetNames(); if (allAssetNames.Length == 0) { MPMain.LogWarning("警告:该 AssetBundle 是空的!"); return; } string[] array = allAssetNames; foreach (string text in array) { Object val = bundle.LoadAsset(text); string text2 = ((val != (Object)null) ? ((object)val).GetType().Name : "Unknown Type"); MPMain.LogInfo("[资源清单] 路径: " + text + " | 类型: " + text2); } MPMain.LogInfo($"--- 清单输出完毕,共计 {allAssetNames.Length} 个资源 ---"); } } public class SlugcatFactory : BaseRemoteFactory { private const string TMP_DISTANCE_FIELD_OVERLAY_MAT = "assets/projects/materials/textmeshpro_distance field overlay.mat"; private const string GAME_TMP_FONT_ASSET = "Ticketing SDF"; protected override void OnPrepare(GameObject prefab, AssetBundle bundle) { FixTMPComponent(prefab, bundle); } public override void Cleanup(GameObject instance) { if ((Object)(object)instance != (Object)null) { Object.Destroy((Object)(object)instance); } } private void FixTMPComponent(GameObject prefab, AssetBundle bundle) { TMP_Text[] componentsInChildren = prefab.GetComponentsInChildren<TMP_Text>(true); foreach (TMP_Text val in componentsInChildren) { MPMain.LogInfo(Localization.Get("RPSlugcatFactory", "SpecializingTMPComponent", ((Object)val).name)); TMP_FontAsset val2 = ((IEnumerable<TMP_FontAsset>)Resources.FindObjectsOfTypeAll<TMP_FontAsset>()).FirstOrDefault((Func<TMP_FontAsset, bool>)((TMP_FontAsset f) => ((Object)f).name == "Ticketing SDF")); if ((Object)(object)val2 == (Object)null) { MPMain.LogError(Localization.Get("RPSlugcatFactory", "FontAssetNotFound", "Ticketing SDF")); continue; } val.font = val2; Material val3 = bundle.LoadAsset<Material>("assets/projects/materials/textmeshpro_distance field overlay.mat"); Material fontMaterial = val.fontMaterial; if ((Object)(object)fontMaterial != (Object)null && (Object)(object)val3 != (Object)null) { fontMaterial.shader = val3.shader; MPMain.LogInfo(Localization.Get("RPSlugcatFactory", "ImplementOverlayViaShader")); } else { MPMain.LogError(Localization.Get("RPSlugcatFactory", "UnableToLoadMaterial", "assets/projects/materials/textmeshpro_distance field overlay.mat")); } } } } public class RPContainer { private RemotePlayer _remotePlayer; private RemoteHand _remoteLeftHand; private RemoteHand _remoteRightHand; private RemoteTag _remoteTag; private RemoteEntity[] _remoteEntities; private int _initializationCount = 5; private bool _isDead = false; public ulong PlayerId { get; set; } public string PlayerName { get; set; } public GameObject PlayerObject { get; private set; } public PlayerData PlayerData { get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) PlayerData val = new PlayerData { playId = PlayerId, TimestampTicks = DateTime.UtcNow.Ticks, IsTeleport = true }; val.Position = PlayerObject.transform.position; val.Rotation = PlayerObject.transform.rotation; val.LeftHand = default(HandData); val.RightHand = default(HandData); return val; } } public RPContainer(ulong playId) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) PlayerId = playId; Friend val = new Friend(SteamId.op_Implicit(PlayerId)); PlayerName = ((Friend)(ref val)).Name; } public bool Initialize(GameObject playerInstance, Transform persistentParent = null) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown if ((Object)(object)playerInstance == (Object)null) { return false; } try { PlayerObject = playerInstance; if ((Object)(object)persistentParent != (Object)null) { PlayerObject.transform.SetParent(persistentParent, false); } InitializeAllComponent(PlayerObject); InitializeAllComponentData(); HandlePlayerData(new PlayerData { IsTeleport = true, Position = new Vector3(0f, 0f, 0f) }); MPMain.LogInfo(Localization.Get("RPContainer", "MappingSucceeded", PlayerId.ToString())); return true; } catch (Exception ex) { MPMain.LogError(Localization.Get("RPContainer", "MappingFailed", PlayerId.ToString(), ex.Message)); if ((Object)(object)PlayerObject != (Object)null) { Object.Destroy((Object)(object)PlayerObject); } return false; } } public void InitializeAllComponent(GameObject instance) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Invalid comparison between Unknown and I4 //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Invalid comparison between Unknown and I4 _remotePlayer = instance.GetComponentInChildren<RemotePlayer>(); _remoteTag = instance.GetComponentInChildren<RemoteTag>(); _remoteEntities = instance.GetComponentsInChildren<RemoteEntity>(); RemoteHand[] componentsInChildren = instance.GetComponentsInChildren<RemoteHand>(); RemoteHand[] array = componentsInChildren; foreach (RemoteHand val in array) { if ((int)val.hand == 0) { _remoteLeftHand = val; } else if ((int)val.hand == 1) { _remoteRightHand = val; } } } private void InitializeAllComponentData() { _remoteTag.Initialize(PlayerId, PlayerName); if (_remoteEntities != null) { RemoteEntity[] remoteEntities = _remoteEntities; foreach (RemoteEntity remoteEntity in remoteEntities) { remoteEntity.PlayerId = PlayerId; } } } public void Destroy() { PlayerObject = null; _remotePlayer = null; _remoteLeftHand = null; _remoteRightHand = null; _remoteTag = null; _remoteEntities = null; } public void HandlePlayerData(PlayerData playerData) { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) if (_isDead) { PlayerObject.SetActive(true); _isDead = false; } if (playerData.IsTeleport || _initializationCount > 0) { playerData.IsTeleport = true; _initializationCount--; } if (playerData.IsTeleport) { _remotePlayer.Teleport(playerData.Position, (Quaternion?)playerData.Rotation); Vector3 position = ((HandData)(ref playerData.LeftHand)).Position; _remoteLeftHand.Teleport(position); Vector3 position2 = ((HandData)(ref playerData.RightHand)).Position; _remoteRightHand.Teleport(position2); } else { _remotePlayer.UpdateFromPlayerData(playerData.Position, playerData.Rotation); _remoteLeftHand.UpdateFromHandData(playerData.LeftHand); _remoteRightHand.UpdateFromHandData(playerData.RightHand); } } public void HandleNameTag(string text) { if (!string.IsNullOrEmpty(text)) { if ((Object)(object)_remoteTag == (Object)null) { MPMain.LogError(Localization.Get("RPContainer", "NameTagComponentMissing")); } else { _remoteTag.Message = text; } } } public void HandleDeath() { PlayerObject.SetActive(false); _isDead = true; } public static void AddHandHold(GameObject gameObject) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown ObjectTagger val = gameObject.AddComponent<ObjectTagger>(); if ((Object)(object)val != (Object)null) { val.tags.Add("Handhold"); } CL_Handhold val2 = gameObject.AddComponent<CL_Handhold>(); if ((Object)(object)val2 != (Object)null) { val2.stopEvent = new UnityEvent(); val2.activeEvent = new UnityEvent(); } Renderer component = gameObject.GetComponent<Renderer>(); if ((Object)(object)component != (Object)null) { gameObject.GetComponent<CL_Handhold>().handholdRenderer = component; } } } public class RPFactoryManager : Singleton<RPFactoryManager> { private class FactoryRegistration { public BaseRemoteFactory Factory { get; set; } public string BundlePath { get; set; } } private readonly object _lock = new object(); private Dictionary<string, FactoryRegistration> _factories = new Dictionary<string, FactoryRegistration>(); private RPFactoryManager() { RegisterDefaultFactories(); } public void RegisterFactory(string factoryId, BaseRemoteFactory factory, string prefabName, string bundlePath) { if (_factories.ContainsKey(factoryId)) { MPMain.LogWarning(Localization.Get("RPFactoryManager", "FactoryAlreadyRegistered", factoryId)); return; } factory.PrefabName = prefabName; factory.FactoryId = factoryId; _factories.Add(factoryId, new FactoryRegistration { Factory = factory, BundlePath = bundlePath }); MPMain.LogInfo(Localization.Get("RPFactoryManager", "FactoryRegistered", factoryId)); } public GameObject Create(string factoryId) { if (_factories.TryGetValue(factoryId, out var value)) { return value.Factory.Create(value.BundlePath); } MPMain.LogError(Localization.Get("RPFactoryManager", "FactoryNotFound", factoryId)); if (_factories.TryGetValue("default", out var value2)) { return value.Factory.Create(value2.BundlePath); } MPMain.LogError(Localization.Get("RPFactoryManager", "FactoryNotFound", "default")); return null; } public void Cleanup(GameObject instance) { if (!((Object)(object)instance == (Object)null)) { ObjectIdentity component = instance.GetComponent<ObjectIdentity>(); FactoryRegistration value; if ((Object)(object)component == (Object)null || string.IsNullOrEmpty(component.FactoryKey)) { MPMain.LogError(Localization.Get("RPFactoryManager", "CannotDetermineFactory")); Object.Destroy((Object)(object)instance); } else if (_factories.TryGetValue(component.FactoryKey, out value)) { value.Factory.Cleanup(instance); } else { MPMain.LogError(Localization.Get("RPFactoryManager", "FactoryNotFoundCleanup", ((Object)component).name)); Object.Destroy((Object)(object)instance); } } } private void RegisterDefaultFactories() { RegisterFactory("default", new SlugcatFactory(), "CapsulePlayerPrefab", Path.Combine(MPMain.path, "player_prefab")); RegisterFactory("slugcat", new SlugcatFactory(), "SlugcatPlayerPrefab", Path.Combine(MPMain.path, "player_prefab")); } public void ListAllFactory() { foreach (var (text2, factoryRegistration2) in _factories) { MPMain.LogWarning(Localization.Get("RPFactoryManager", "DebugFactoryInfo", text2, factoryRegistration2.Factory.PrefabName, factoryRegistration2.BundlePath)); } } } public class RPManager : Singleton<RPManager> { private TickTimer _debugTick = new TickTimer(5f); internal Dictionary<ulong, RPContainer> Players = new Dictionary<ulong, RPContainer>(); private Transform _remotePlayersRoot; private RPManager() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown _ = Singleton<RPFactoryManager>.Instance; } public void Initialize(Transform RootTransform) { _remotePlayersRoot = RootTransform; } public void ResetAll() { foreach (RPContainer value in Players.Values) { Singleton<RPFactoryManager>.Instance.Cleanup(value.PlayerObject); value.Destroy(); } Players.Clear(); } public RPContainer PlayerCreate(ulong playId, string prefab) { if (Players.TryGetValue(playId, out var value)) { return value; } RPContainer rPContainer = new RPContainer(playId); GameObject val = Singleton<RPFactoryManager>.Instance.Create(prefab); if ((Object)(object)val == (Object)null) { MPMain.LogError(Localization.Get("RPManager", "FactoryCreateObjectFailed")); return null; } rPContainer.Initialize(val, _remotePlayersRoot); Players[playId] = rPContainer; return rPContainer; } public void PlayerRemove(ulong playId) { if (Players.TryGetValue(playId, out var value)) { Singleton<RPFactoryManager>.Instance.Cleanup(value.PlayerObject); value.Destroy(); Players.Remove(playId); } } public void ProcessPlayerData(ulong playerId, PlayerData playerData) { if (Players.TryGetValue(playerId, out var value)) { value.HandlePlayerData(playerData); } else if (_debugTick.TryTick()) { MPMain.LogError(Localization.Get("RPManager", "RemotePlayerObjectNotFound", playerId.ToString())); } } public void ProcessPlayerTag(ulong playerId, string massage) { if (Players.TryGetValue(playerId, out var value)) { value.HandleNameTag(massage); return; } MPMain.LogError(Localization.Get("RPManager", "RemotePlayerObjectNotFound", playerId.ToString())); } public void ProcessPlayerDeath(ulong playerId) { if (Players.TryGetValue(playerId, out var value)) { value.HandleDeath(); return; } MPMain.LogError(Localization.Get("RPManager", "RemotePlayerObjectNotFound", playerId.ToString())); } public GameObject GetPlayerObject(ulong playerId) { if (Players.TryGetValue(playerId, out var value)) { return value.PlayerObject; } MPMain.LogError(Localization.Get("RPManager", "RemotePlayerObjectNotFound", playerId.ToString())); return null; } } } namespace WKMPMod.Patch { [HarmonyPatch(typeof(CL_ProgressionManager), "HasProgressionUnlock")] public class Patch_Progression_ForceUnlock { public static bool Prefix(ref bool __result) { if (MPCore.IsInLobby) { __result = true; return false; } return true; } } [HarmonyPatch(typeof(M_Level), "Awake")] public class Patch_M_Level_Awake { public static void Prefix(M_Level __instance) { if (MPCore.IsInLobby) { __instance.canFlip = false; } } } [HarmonyPatch(typeof(ENT_Player))] public class Patch_ENT_Player { [HarmonyPrefix] [HarmonyPatch("Kill")] public static void Prefix(ENT_Player __instance, string type) { if (MPCore.IsInLobby && !((GameEntity)__instance).dead) { MPEventBusGame.NotifyPlayerDeath(type); MPMain.LogInfo(Localization.Get("Patch", "PlayerDeath", type)); } } } [HarmonyPatch(typeof(SteamManager))] public class Patch_SteamManager { private static bool _hasCoreInjected; [HarmonyPostfix] [HarmonyPatch("Awake")] public static void Postfix(SteamManager __instance) { MPMain.LogInfo(Localization.Get("Patch", "PreparingToInjectCore")); if (_hasCoreInjected) { MPMain.LogWarning(Localization.Get("Patch", "CoreAlreadyInjected")); return; } MPCore mPCore = Object.FindObjectOfType<MPCore>(); if ((Object)(object)mPCore != (Object)null) { MPMain.LogWarning(Localization.Get("Patch", "CoreInstanceExists", ((Object)mPCore).name)); _hasCoreInjected = true; return; } try { _ = MonoSingleton<MPCore>.Instance; MPMain.LogInfo(Localization.Get("Patch", "CoreInjectionSuccess")); _hasCoreInjected = true; } catch (Exception ex) { MPMain.LogError(Localization.Get("Patch", "CoreInjectionFailed", ex.Message)); } } } } namespace WKMPMod.NetWork { public class MPPacketHandlers { public const string NO_ITEM_NAME = "None"; public const string ARTIFACT_NAME = "Artifact"; [MPPacketHandler(PacketType.WorldInitRequest)] private static void HandleWorldInitRequest(ulong senderId, DataReader reader) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) DataWriter writer = MPWriterPool.GetWriter(MonoSingleton<MPSteamworks>.Instance.UserSteamId, senderId, PacketType.WorldInitData); writer.Put(WorldLoader.instance.seed); MonoSingleton<MPSteamworks>.Instance.SendToPeer(SteamId.op_Implicit(senderId), writer, (SendType)8, 0); MPMain.LogInfo(Localization.Get("MPMessageHandlers", "SentInitData")); } [MPPacketHandler(PacketType.WorldInitData)] private static void HandleWorldInit(ulong senderId, DataReader reader) { int @int = reader.GetInt(); MPMain.LogInfo(Localization.Get("MPCore", "LoadingWorld", @int.ToString())); if (@int != WorldLoader.instance.seed) { WorldLoader.ReloadWithSeed(new string[1] { @int.ToString() }); } MPCore.MultiPlayerStatus.SetField(MPStatus.Initialized, MPStatus.Initialized); } [MPPacketHandler(PacketType.PlayerDataUpdate)] private static void HandlePlayerDataUpdate(ulong senderId, DataReader reader) { PlayerData val = MPDataSerializer.ReadFromNetData(reader); ulong playId = val.playId; if (playId != MonoSingleton<MPSteamworks>.Instance.UserSteamId) { Singleton<RPManager>.Instance.ProcessPlayerData(playId, val); } } [MPPacketHandler(PacketType.BroadcastMessage)] private static void HandlePlayerTagUpdate(ulong senderId, DataReader reader) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) string @string = reader.GetString(); Friend val = new Friend(SteamId.op_Implicit(senderId)); string name = ((Friend)(ref val)).Name; CommandConsole.Log(name + ": " + @string, false); Singleton<RPManager>.Instance.ProcessPlayerTag(senderId, @string); } [MPPacketHandler(PacketType.WorldStateSync)] private static void HandleWorldStateSync(ulong senderId, DataReader reader) { } [MPPacketHandler(PacketType.PlayerDamage)] private static void HandlePlayerDamage(ulong senderId, DataReader reader) { float @float = reader.GetFloat(); string @string = reader.GetString(); float num = @float * MPConfig.AllPassive; switch (@string) { case "Hammer": ((GameEntity)ENT_Player.GetPlayer()).Damage(num * MPConfig.HammerPassive, @string); break; case "rebar": ((GameEntity)ENT_Player.GetPlayer()).Damage(num * MPConfig.RebarPassive, @string); break; case "returnrebar": ((GameEntity)ENT_Player.GetPlayer()).Damage(num * MPConfig.ReturnRebarPassive, @string); break; case "rebarexplosion": ((GameEntity)ENT_Player.GetPlayer()).Damage(num * MPConfig.RebarExplosionPassive, @string); break; case "explosion": ((GameEntity)ENT_Player.GetPlayer()).Damage(num * MPConfig.ExplosionPassive, @string); break; case "piton": ((GameEntity)ENT_Player.GetPlayer()).Damage(num * MPConfig.PitonPassive, @string); break; case "flare": ((GameEntity)ENT_Player.GetPlayer()).Damage(num * MPConfig.FlarePassive, @string); break; case "ice": ((GameEntity)ENT_Player.GetPlayer()).Damage(num * MPConfig.IcePassive, @string); break; default: ((GameEntity)ENT_Player.GetPlayer()).Damage(num * MPConfig.OtherPassive, @string); break; } } [MPPacketHandler(PacketType.PlayerAddForce)] private static void HandlePlayerAddForce(ulong senderId, DataReader reader) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) Vector3 val = default(Vector3); val.x = reader.GetFloat(); val.y = reader.GetFloat(); val.z = reader.GetFloat(); Vector3 val2 = val; string @string = reader.GetString(); ((GameEntity)ENT_Player.GetPlayer()).AddForce(val2, @string); } [MPPacketHandler(PacketType.PlayerDeath)] private static void HandlePlayerDeath(ulong senderId, DataReader reader) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) string @string = reader.GetString(); Friend val = new Friend(SteamId.op_Implicit(senderId)); string name = ((Friend)(ref val)).Name; CommandConsole.Log(Localization.Get("CommandConsole", "PlayerDeath", name, @string), false); GameObject playerObject = Singleton<RPManager>.Instance.GetPlayerObject(senderId); if ((Object)(object)playerObject == (Object)null) { return; } Dictionary<string, byte> stringByteDict = reader.GetStringByteDict(); Vector3 position = playerObject.transform.position; Vector3 val2 = default(Vector3); Rigidbody val4 = default(Rigidbody); foreach (var (text2, b2) in stringByteDict) { if (text2 == "None") { continue; } GameObject assetGameObject = CL_AssetManager.GetAssetGameObject(text2, ""); if ((Object)(object)assetGameObject == (Object)null) { MPMain.LogInfo(Localization.Get("MPMessageHandlers", "PrefabDoesNotExist", text2)); continue; } for (int i = 0; i < b2; i++) { ((Vector3)(ref val2))..ctor(Random.Range(-1f, 1f), Random.Range(0f, 0.5f), Random.Range(-1f, 1f)); GameObject val3 = Object.Instantiate<GameObject>(assetGameObject, position + val2, Random.rotation); if (val3.TryGetComponent<Rigidbody>(ref val4)) { Vector3 val5 = new Vector3(Random.Range(-1f, 1f), 1f, Random.Range(-1f, 1f)); Vector3 normalized = ((Vector3)(ref val5)).normalized; val4.AddForce(normalized * Random.Range(1f, 2f), (ForceMode)1); } } } Singleton<RPManager>.Instance.ProcessPlayerDeath(senderId); } [MPPacketHandler(PacketType.PlayerCreateRequest)] private static void HandlePlayerCreateRequest(ulong senderId, DataReader reader) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) DataWriter writer = MPWriterPool.GetWriter(MonoSingleton<MPSteamworks>.Instance.UserSteamId, senderId, PacketType.PlayerCreateResponse); writer.Put(MonoSingleton<LocalPlayer>.Instance.FactoryId); MonoSingleton<MPSteamworks>.Instance.SendToPeer(SteamId.op_Implicit(senderId), writer, (SendType)8, 0); } [MPPacketHandler(PacketType.PlayerCreateResponse)] private static void HandlePlayerCreateResponse(ulong senderId, DataReader reader) { string @string = reader.GetString(); Singleton<RPManager>.Instance.PlayerCreate(senderId, @string); } [MPPacketHandler(PacketType.PlayerTeleportRequest)] private static void HandlePlayerTeleportRequest(ulong senderId, DataReader reader) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)ENT_Player.GetPlayer()).transform.position; DataWriter writer = MPWriterPool.GetWriter(MonoSingleton<MPSteamworks>.Instance.UserSteamId, senderId, PacketType.PlayerTeleportRespond); writer.Put(position.x); writer.Put(position.y); writer.Put(position.z); writer.Put(MPCore.GetGetInventoryItems()); if ((Object)(object)DEN_DeathFloor.instance == (Object)null) { writer.Put(value: false); } else { SaveData saveData = DEN_DeathFloor.instance.GetSaveData(); writer.Put(value: true); writer.Put(saveData.relativeHeight); writer.Put(saveData.active); writer.Put(saveData.speed); writer.Put(saveData.speedMult); } MonoSingleton<MPSteamworks>.Instance.SendToPeer(SteamId.op_Implicit(senderId), writer, (SendType)8, 0); } [MPPacketHandler(PacketType.PlayerTeleportRespond)] private static void HandlePlayerTeleportRespond(ulong senderId, DataReader reader) { //IL_0274: 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_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Expected O, but got Unknown //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) float @float = reader.GetFloat(); float float2 = reader.GetFloat(); float float3 = reader.GetFloat(); Dictionary<string, byte> stringByteDict = reader.GetStringByteDict(); Dictionary<string, byte> getInventoryItems = MPCore.GetGetInventoryItems(); Dictionary<string, byte> dictionary = DictionaryExtensions.SetDifference<string>(stringByteDict, getInventoryItems); Inventory instance = Inventory.instance; foreach (var (text2, b2) in dictionary) { if (text2 == "None" || text2.Contains("Artifact")) { continue; } GameObject assetGameObject = CL_AssetManager.GetAssetGameObject(text2, ""); if ((Object)(object)assetGameObject == (Object)null) { MPMain.LogInfo(Localization.Get("MPMessageHandlers", "PrefabDoesNotExist", text2)); continue; } for (int i = 0; i < b2; i++) { GameObject val = Object.Instantiate<GameObject>(assetGameObject, new Vector3(0f, 1f, 0f), Quaternion.identity); Item_Object component = val.GetComponent<Item_Object>(); if ((Object)(object)component != (Object)null) { instance.AddItemToInventoryCenter(component.itemData); component.itemData.bagRotation = Quaternion.Euler(90f, 0f, 0f); ((Component)component).gameObject.SetActive(false); } else { MPMain.LogInfo(Localization.Get("MPMessageHandlers", "PrefabIsNotItem", ((Object)val).name)); Object.Destroy((Object)(object)val); } } } if (reader.GetBool()) { SaveData val2 = new SaveData { relativeHeight = reader.GetFloat(), active = reader.GetBool(), speed = reader.GetFloat(), speedMult = reader.GetFloat() }; DEN_DeathFloor.instance.SetCanKill(new string[1] { "false" }); MonoSingleton<LocalPlayer>.Instance.TriggerTeleport(); ((GameEntity)ENT_Player.GetPlayer()).Teleport(new Vector3(@float, float2, float3)); DEN_DeathFloor.instance.LoadDataFromSave(val2); DEN_DeathFloor.instance.SetCanKill(new string[1] { "true" }); } else { MonoSingleton<LocalPlayer>.Instance.TriggerTeleport(); ((GameEntity)ENT_Player.GetPlayer()).Teleport(new Vector3(@float, float2, float3)); } } } public class MPPacketRouter { [CompilerGenerated] private sealed class <ProcessMethod>d__2 : IEnumerable<(PacketType, Action<ulong, DataReader>)>, IEnumerable, IEnumerator<(PacketType, Action<ulong, DataReader>)>, IEnumerator, IDisposable { private int <>1__state; private (PacketType, Action<ulong, DataReader>) <>2__current; private int <>l__initialThreadId; private MethodInfo method; public MethodInfo <>3__method; private IEnumerable<MPPacketHandlerAttribute> <attrs>5__1; private ParameterInfo[] <parameters>5__2; private Action<ulong, DataReader> <action>5__3; private IEnumerator<MPPacketHandlerAttribute> <>s__4; private MPPacketHandlerAttribute <attr>5__5; (PacketType, Action<ulong, DataReader>) IEnumerator<(PacketType, Action<ulong, DataReader>)>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ProcessMethod>d__2(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <attrs>5__1 = null; <parameters>5__2 = null; <action>5__3 = null; <>s__4 = null; <attr>5__5 = null; <>1__state = -2; } private bool MoveNext() { try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <attrs>5__1 = method.GetCustomAttributes<MPPacketHandlerAttribute>(); <parameters>5__2 = method.GetParameters(); <action>5__3 = CreateAction(method, <parameters>5__2); if (<action>5__3 == null) { return false; } <>s__4 = <attrs>5__1.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; <attr>5__5 = null; break; } if (<>s__4.MoveNext()) { <attr>5__5 = <>s__4.Current; <>2__current = (<attr>5__5.packetType, <action>5__3); <>1__state = 1; return true; } <>m__Finally1(); <>s__4 = null; return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>s__4 != null) { <>s__4.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator<(PacketType, Action<ulong, DataReader>)> IEnumerable<(PacketType, Action<ulong, DataReader>)>.GetEnumerator() { <ProcessMethod>d__2 <ProcessMethod>d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; <ProcessMethod>d__ = this; } else { <ProcessMethod>d__ = new <ProcessMethod>d__2(0); } <ProcessMethod>d__.method = <>3__method; return <ProcessMethod>d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable<(PacketType, Action<ulong, DataReader>)>)this).GetEnumerator(); } } private static readonly Action<ulong, DataReader>[] FastHandlers; static MPPacketRouter() { FastHandlers = new Action<ulong, DataReader>[64]; IEnumerable<(PacketType, Action<ulong, DataReader>)> enumerable = (from method in typeof(MPPacketHandlers).GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) where method.GetCustomAttributes(typeof(MPPacketHandlerAttribute), inherit: false).Length != 0 select method).SelectMany((MethodInfo method) => ProcessMethod(method)); int num = 0; foreach (var item3 in enumerable) { PacketType item = item3.Item1; Action<ulong, DataReader> item2 = item3.Item2; ushort num2 = (ushort)item; if (num2 >= 0 && num2 < FastHandlers.Length) { if (FastHandlers[num2] != null) { Localization.Get("MPPacketRouter", "PacketHandlerOverridden", item, FastHandlers[num2].Method.Name, item2.Method.Name); } FastHandlers[num2] = item2; num++; MPMain.LogInfo(Localization.Get("MPPacketRouter", "ShowAllRouteTable", item, item2.Method.Name)); } else { Localization.Get("MPPacketRouter", "PacketTypeOutOfRange", (ushort)item, FastHandlers.Length - 1); } } } [IteratorStateMachine(typeof(<ProcessMethod>d__2))] private static IEnumerable<(PacketType, Action<ulong, DataReader>)> ProcessMethod(MethodInfo method) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ProcessMethod>d__2(-2) { <>3__method = method }; } private static Action<ulong, DataReader> CreateAction(MethodInfo method, ParameterInfo[] parameters) { try { if (parameters.Length == 2 && parameters[0].ParameterType == typeof(ulong) && parameters[1].ParameterType == typeof(DataReader)) { return (Action<ulong, DataReader>)Delegate.CreateDelegate(typeof(Action<ulong, DataReader>), null, method); } throw new InvalidOperationException("Unsupported parameter signature for " + method.Name + ". Expected (ulong, DataReader)."); } catch (Exception ex) { MPMain.LogError(Localization.Get("MPPacketRouter", "FailedToBind", method.Name, ex.Message)); return null; } } public static void Initialize() { MPEventBusNet.OnReceiveData += Route; } public static void Route(ulong connectionId, ArraySegment<byte> data) { if (data.Array == null || data.Count < 18) { return; } ReadOnlySpan<byte> readOnlySpan = data; var (num, num2, num3) = MPReaderPool.PeekHeader(data); if (num2 != MonoSingleton<MPSteamworks>.Instance.UserSteamId && num2 != 0L && num2 != 1) { ProcessForwardToPeer(num2, data); return; } if (num2 == 0L && num != MonoSingleton<MPSteamworks>.Instance.UserSteamId) { ProcessBroadcastExcept(num, data); } if (num3 < 0 || num3 >= FastHandlers.Length || FastHandlers[num3] == null) { MPMain.LogError(Localization.Get("MPPacketRouter", "NoServiceFound", num3)); return; } DataReader reader = MPReaderPool.GetReader(data.Slice(18)); try { FastHandlers[num3](num, reader); } catch (Exception ex) { MPMain.LogError(Localization.Get("MPPacketRouter", "HandlerException", num3, ex.Message)); } } private static void ProcessForwardToPeer(ulong targetId, ArraySegment<byte> data) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) int offset = data.Offset; int count = data.Count; PacketType packetType = (PacketType)BinaryPrimitives.ReadUInt16LittleEndian(data.AsSpan(16, 2)); SendType sendType = (SendType)((packetType != PacketType.PlayerDataUpdate) ? 8 : 0); MonoSingleton<MPSteamworks>.Instance.SendToPeer(SteamId.op_Implicit(targetId), data.Array, offset, count, sendType, 0); } public static void ProcessBroadcast(ArraySegment<byte> data) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) int offset = data.Offset; int count = data.Count; PacketType packetType = (PacketType)BinaryPrimitives.ReadUInt16LittleEndian(data.AsSpan(16, 2)); SendType sendType = (SendType)((packetType != PacketType.PlayerDataUpdate) ? 8 : 0); MonoSingleton<MPSteamworks>.Instance.Broadcast(data.Array, offset, count, sendType, 0); } public static void ProcessBroadcastExcept(ulong senderId, ArraySegment<byte> data) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) int offset = data.Offset; int count = data.Count; PacketType packetType = (PacketType)BinaryPrimitives.ReadUInt16LittleEndian(data.AsSpan(16, 2)); SendType sendType = (SendType)((packetType != PacketType.PlayerDataUpdate) ? 8 : 0); MonoSingleton<MPSteamworks>.Instance.BroadcastExcept(senderId, data.Array, offset, count, sendType, 0); } } [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] public class MPPacketHandlerAttribute : Attribute { public PacketType packetType { get; } public MPPacketHandlerAttribute(PacketType packetType) { this.packetType = packetType; } } public class MPSteamworks : MonoSingleton<MPSteamworks>, ISocketManager { private struct NetworkMessage { public SteamId SenderId; public byte[] Data; public int Length; public DateTime ReceiveTime; } internal class SteamConnectionManager : ConnectionManager, IConnectionManager { private MPSteamworks _instance; public MPSteamworks Instance { get { return _instance; } set { _instance = value; } } public override void OnConnecting(ConnectionInfo info) { } public override void OnConnected(ConnectionInfo info) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) NetIdentity identity = ((ConnectionInfo)(ref info)).Identity; SteamId steamId = ((NetIdentity)(ref identity)).SteamId; MPMain.LogInfo(Localization.Get("MPSteamworks", "AlreadyActiveConnected", ((object)(SteamId)(ref steamId)).ToString(), ((ConnectionInfo)(ref info)).State)); } public override void OnMessage(IntPtr data, int size, long messageNum, long recvTime, int channel) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) MPSteamworks instance = Instance; if (instance != null) { ConnectionInfo connectionInfo = ((ConnectionManager)this).ConnectionInfo; NetIdentity identity = ((ConnectionInfo)(ref connectionInfo)).Identity; instance.HandleIncomingRawData(((NetIdentity)(ref identity)).SteamId, data, size); } } public override void OnDisconnected(ConnectionInfo info) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) MPSteamworks instance = Instance; if (instance != null) { NetIdentity identity = ((ConnectionInfo)(ref info)).Identity; instance.OnPlayerDisconnected(((NetIdentity)(ref identity)).SteamId); } } } [CompilerGenerated] private sealed class <>c__DisplayClass59_0 { public MPSteamworks <>4__this; public SteamId targetId; } [CompilerGenerated] private sealed class <>c__DisplayClass66_0 { public Task<bool> task; internal bool <RunAsync>b__0() { return !task.IsCompleted; } } [CompilerGenerated] private sealed class <ConnectionController>d__59 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public SteamId targetId; public bool isReconnect; public MPSteamworks <>4__this; private <>c__DisplayClass59_0 <>8__1; private bool <isInitiator>5__2; private float <waitTimer>5__3; private bool <alreadyConnected>5__4; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ConnectionController>d__59(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Expected O, but got Unknown //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass59_0(); <>8__1.<>4__this = <>4__this; <>8__1.targetId = targetId; <>2__current = (object)new WaitForSeconds(isReconnect ? 1.5f : 0.2f); <>1__state = 1; return true; case 1: <>1__state = -1; if (!<>4__this.IsInLobby || !<>4__this.IsMemberInLobby(<>8__1.targetId)) { return false; } <isInitiator>5__2 = <>4__this.UserSteamId < SteamId.op_Implicit(<>8__1.targetId); if (<isInitiator>5__2) { MPMain.LogInfo(Localization.Get("MPSteamworks", "ConnectionInitiator", <>8__1.targetId)); <>2__current = AttemptAndVerify(3); <>1__state = 2; return true; } MPMain.LogInfo(Localization.Get("MPSteamworks", "ConnectionEeceiver", <>8__1.targetId)); <waitTimer>5__3 = 0f; <alreadyConnected>5__4 = false; goto IL_0254; case 2: <>1__state = -1; break; case 3: <>1__state = -1; if (!<>4__this._allConnections.ContainsKey(<>8__1.targetId)) { goto IL_022a; } <>4__this.HasConnections = true; MPEventBusNet.NotifyPlayerConnected(<>8__1.targetId); <alreadyConnected>5__4 = true; goto IL_026a; case 4: <>1__state = -1; goto IL_0254; case 5: { <>1__state = -1; break; } IL_0254: if (<waitTimer>5__3 < 10f) { if (<>4__this._allConnections.ContainsKey(<>8__1.targetId)) { <>2__current = (object)new WaitForSeconds(1f); <>1__state = 3; return true; } goto IL_022a; } goto IL_026a; IL_026a: if (!<alreadyConnected>5__4) { MPMain.LogWarning(Localization.Get("MPSteamworks", "ReverseConnectionAttempt")); <>2__current = AttemptAndVerify(3); <>1__state = 5; return true; } break; IL_022a: <waitTimer>5__3 += Time.deltaTime; <>2__current = null; <>1__state = 4; return true; } if (!<>4__this._allConnections.ContainsKey(<>8__1.targetId) && <>4__this.IsInLobby && <>4__this.IsMemberInLobby(<>8__1.targetId)) { MPMain.LogError(Localization.Get("MPSteamworks", "ConnectionProcessFailed")); return false; } return false; [IteratorStateMachine(typeof(<>c__DisplayClass59_0.<<ConnectionController>g__AttemptAndVerify|0>d))] IEnumerator AttemptAndVerify(int maxAttempts) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <>c__DisplayClass59_0.<<ConnectionController>g__AttemptAndVerify|0>d(0) { <>4__this = this, maxAttempts = maxAttempts }; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <RunAsync>d__66 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Task<bool> task; public Action<bool> callback; public MPSteamworks <>4__this; private <>c__DisplayClass66_0 <>8__1; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <RunAsync>d__66(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass66_0(); <>8__1.task = task; <>2__current = (object)new WaitWhile((Func<bool>)(() => !<>8__1.task.IsCompleted)); <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = null; <>1__state = 2; return true; case 2: <>1__state = -1; if (<>8__1.task.IsFaulted) { MPMain.LogError(Localization.Get("MPSteamworks", "AsyncTaskFailed", <>8__1.task.Exception.InnerException.Message)); callback?.Invoke(obj: false); } else { callback?.Invoke(<>8__1.task.Result); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private TickTimer _debugTick = new TickTimer(5f); private Lobby _currentLobby; internal SocketManager _socketManager; internal Dictionary<SteamId, SteamConnectionManager> _outgoingConnections = new Dictionary<SteamId, SteamConnectionManager>(); internal Dictionary<SteamId, Connection> _allConnections = new Dictionary<SteamId, Connection>(); private ConcurrentQueue<NetworkMessage> _messageQueue = new ConcurrentQueue<NetworkMessage>(); private static readonly ArrayPool<byte> _messagePool = ArrayPool<byte>.Shared; public ulong CurrentLobbyId => ((Lobby)(ref _currentLobby)).Id.Value; public bool IsInLobby { get { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) SteamId id = ((Lobby)(ref _currentLobby)).Id; return ((SteamId)(ref id)).IsValid; } } public ulong UserSteamId { get; private set; } public ulong HostSteamId { get; private set; } public bool HasConnections { get; private set; } public bool IsHost { get { //IL_0007: 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_0032: Unknown result type (might be due to invalid IL or missing references) if (SteamId.op_Implicit(((Lobby)(ref _currentLobby)).Id) == 0) { return false; } return SteamId.op_Implicit(((Lobby)(ref _currentLobby)).Owner.Id) == SteamId.op_Implicit(SteamClient.SteamId); } } public ulong LobbyId => ((Lobby)(ref _currentLobby)).Id.Value; public IEnumerable<Friend> Members => ((Lobby)(ref _currentLobby)).Members; public bool IsMemberInLobby(SteamId targetId) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) foreach (Friend member in ((Lobby)(ref _currentLobby)).Members) { if (SteamId.op_Implicit(member.Id) == SteamId.op_Implicit(targetId)) { return true; } } return false; } protected override void Awake() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) base.Awake(); try { if (!SteamClient.IsValid) { MPMain.LogError(Localization.Get("MPSteamworks", "SteamworksInitFailed")); return; } UserSteamId = SteamId.op_Implicit(SteamClient.SteamId); object[] obj = new object[2] { SteamClient.Name, null }; SteamId steamId = SteamClient.SteamId; obj[1] = ((object)(SteamId)(ref steamId)).ToString(); MPMain.LogInfo(Localization.Get("MPSteamworks", "SteamworksInitSuccess", obj)); } catch (Exception ex) { MPMain.LogError(Localization.Get("MPSteamworks", "SteamworksInitException", ex.Message)); } } private void Start() { SteamMatchmaking.OnLobbyEntered += HandleLobbyEntered; SteamMatchmaking.OnLobbyMemberJoined += HandleLobbyMemberJoined; SteamMatchmaking.OnLobbyMemberLeave += HandleLobbyMemberLeft; SteamMatchmaking.OnLobbyMemberDisconnected += HandleLobbyMemberDisconnected; SteamMatchmaking.OnLobbyMemberDataChanged += HandleLobbyMemberDataChanged; SteamNetworkingUtils.InitRelayNetworkAccess(); } private void LateUpdate() { SteamClient.RunCallbacks(); SocketManager socketManager = _socketManager; if (socketManager != null) { socketManager.Receive(32, true); } foreach (SteamConnectionManager value in _outgoingConnections.Values) { ((ConnectionManager)value).Receive(32, true); } ProcessMessageQueue(); } protected override void OnDestroy() { SteamMatchmaking.OnLobbyEntered -= HandleLobbyEntered; SteamMatchmaking.OnLobbyMemberJoined -= HandleLobbyMemberJoined; SteamMatchmaking.OnLobbyMemberLeave -= HandleLobbyMemberLeft; SteamMatchmaking.OnLobbyMemberDisconnected -= HandleLobbyMemberDisconnected; SteamMatchmaking.OnLobbyMemberDataChanged -= HandleLobbyMemberDataChanged; DisconnectAll(); base.OnDestroy(); } public void DisconnectAll() { //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) foreach (SteamConnectionManager value in _outgoingConnections.Values) { if (value != null) { ((ConnectionManager)value).Close(false, 0, "Closing Connection"); } } _outgoingConnections.Clear(); SocketManager socketManager = _socketManager; if (socketManager != null) { socketManager.Close(); } _socketManager = null; _allConnections.Clear(); HasConnections = false; HostSteamId = 0uL; SteamId id = ((Lobby)(ref _currentLobby)).Id; if (((SteamId)(ref id)).IsValid) { try { ((Lobby)(ref _currentLobby)).Leave(); } catch { } _currentLobby = default(Lobby); } NetworkMessage result; while (_messageQueue.TryDequeue(out result)) { } MPMain.LogInfo(Localization.Get("MPSteamworks", "AllConnectionsDisconnected")); } public void SendToHost(DataWriter writer, SendType sendType = 8, ushort laneIndex = 0) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) ArraySegment<byte> data = writer.Data; SendToHost(data.Array, data.Offset, data.Count, sendType, laneIndex); } public void SendToHost(byte[] data, int offset, int length, SendType sendType = 8, ushort laneIndex = 0) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) SteamId id = ((Lobby)(ref _currentLobby)).Id; if (((SteamId)(ref id)).IsValid) { SteamId id2 = ((Lobby)(ref _currentLobby)).Owner.Id; if (SteamId.op_Implicit(id2) != SteamId.op_Implicit(SteamClient.SteamId) && _allConnections.TryGetValue(id2, out var value)) { ((Connection)(ref value)).SendMessage(data, offset, length, sendType, laneIndex); } } } public void Broadcast(DataWriter writer, SendType sendType = 8, ushort laneIndex = 0) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) ArraySegment<byte> data = writer.Data; Broadcast(data.Array, data.Offset, data.Count, sendType, laneIndex); } public void Broadcast(byte[] data, int offset, int length, SendType sendType = 8, ushort laneIndex = 0) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair<SteamId, Connection> allConnection in _allConnections) { var (val3, val4) = (KeyValuePair<SteamId, Connection>)(ref allConnection); try { ((Connection)(ref val4)).SendMessage(data, offset, length, sendType, laneIndex); } catch (Exception ex) { MPMain.LogError(Localization.Get("MPSteamworks", "BroadcastingException", ex.Message)); } } } public void SendToPeer(SteamId steamId, DataWriter writer, SendType sendType = 8, ushort laneIndex = 0) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) ArraySegment<byte> data = writer.Data; SendToPeer(steamId, data.Array, data.Offset, data.Count, sendType, laneIndex); } public void SendToPeer(SteamId steamId, byte[] data, int offset, int length, SendType sendType = 8, ushort laneIndex = 0) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) try { Connection val = _allConnections[steamId]; ((Connection)(ref val)).SendMessage(data, offset, length, sendType, laneIndex); } catch (Exception ex) { MPMain.LogError(Localization.Get("MPSteamworks", "UnicastException", ex.Message, ((object)(SteamId)(ref steamId)).ToString())); } } internal void BroadcastExcept(ulong steamId, byte[] data, int offset, int length, SendType sendType = 8, ushort laneIndex = 0) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair<SteamId, Connection> allConnection in _allConnections) { var (val3, val4) = (KeyValuePair<SteamId, Connection>)(ref allConnection); if (steamId != SteamId.op_Implicit(val3)) { try { ((Connection)(ref val4)).SendMessage(data, offset, length, sendType, laneIndex); } catch (Exception ex) { MPMain.LogError(Localization.Get("MPSteamworks", "BroadcastingException", ex.Message)); } } } } private void HandleIncomingRawData(SteamId senderId, IntPtr data, int size) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) byte[] array = _messagePool.Rent(size); Marshal.Copy(data, array, 0, size); _messageQueue.Enqueue(new NetworkMessage { SenderId = SteamId.op_Implicit(senderId.Value), Data = array, Length = size, ReceiveTime = DateTime.UtcNow }); } private void ProcessMessageQueue() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) int num = 0; NetworkMessage result; while (num < 50 && _messageQueue.TryDequeue(out result)) { try { MPEventBusNet.NotifyReceive(data: new ArraySegment<byte>(result.Data, 0, result.Length), steamId: SteamId.op_Implicit(result.SenderId)); num++; } catch (Exception ex) { MPMain.LogError(Localization.Get("MPSteamworks", "MessageQueueException", ex.Message)); } finally { _messagePool.Return(result.Data); } } } public void OnPlayerConnected(SteamId steamId, Connection connection, bool isIncoming) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) MPEventBusNet.NotifyPlayerConnected(steamId); } public void OnPlayerDisconnected(SteamId steamId) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) if (_allConnections.ContainsKey(steamId)) { _allConnections.Remove(steamId); _outgoingConnections.Remove(steamId); if (IsInLobby || IsMemberInLobby(steamId)) { ((MonoBehaviour)this).StartCoroutine(ConnectionController(steamId, isReconnect: true)); } MPMain.LogInfo(Localization.Get("MPSteamworks", "PlayerDisconnectedCleaned", ((object)(SteamId)(ref steamId)).ToString())); HasConnections = _allConnections.Count > 0; if (!_allConnections.ContainsKey(steamId)) { MPEventBusNet.NotifyPlayerDisconnected(steamId); } } } public void CreateListeningSocket() { try { _socketManager = SteamNetworkingSockets.CreateRelaySocket<SocketManager>(1); _socketManager.Interface = (ISocketManager)(object)this; } catch (Exception ex) { MPMain.LogError(Localization.Get("MPSteamworks", "SocketCreateException", ex.Message)); } } public void ConnectToPlayer(SteamId steamId) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) try { if (_outgoingConnections.ContainsKey(steamId)) { MPMain.LogWarning(Localization.Get("MPSteamworks", "AlreadyConnected", ((object)(SteamId)(ref steamId)).ToString())); return; } SteamConnectionManager steamConnectionManager = SteamNetworkingSockets.ConnectRelay<SteamConnectionManager>(steamId, 1); ((ConnectionManager)steamConnectionManager).Interface = (IConnectionManager)(object)steamConnectionManager; steamConnectionManager.Instance = this; _outgoingConnections[steamId] = steamConnectionManager; _allConnections[steamId] = ((ConnectionManager)steamConnectionManager).Connection; MPMain.LogInfo(Localization.Get("MPSteamworks", "ConnectingToPlayer", ((object)(SteamId)(ref steamId)).ToString())); } catch (Exception ex) { MPMain.LogError(Localization.Get("MPSteamworks", "ConnectToPlayerException", ex.Message)); } } public async Task<bool> ConnectToPlayerAsync(SteamId steamId) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) float timeout = 5f; float startTime = Time.time; if (_outgoingConnections.ContainsKey(steamId) || _allConnections.ContainsKey(steamId)) { MPMain.LogWarning(Localization.Get("MPSteamworks", "AlreadyConnected", ((object)(SteamId)(ref steamId)).ToString())); return true; } SteamConnectionManager connectionManager; try { MPMain.LogInfo(Localization.Get("MPSteamworks", "ConnectingToPlayer", ((object)(SteamId)(ref steamId)).ToString())); connectionManager = SteamNetworkingSockets.ConnectRelay<SteamConnectionManager>(steamId, 1); connectionManager.Instance = this; _outgoingConnections[steamId] = connectionManager; _allConnections[steamId] = ((ConnectionManager)connectionManager).Connection; } catch (Exception ex) { MPMain.LogError(Localization.Get("MPSteamworks", "ConnectToPlayerException", ex.Message)); return false; } if (connectionManager != null) { while (true) { ConnectionInfo connectionInfo = ((ConnectionManager)connectionManager).ConnectionInfo; if ((int)((ConnectionInfo)(ref connectionInfo)).State != 3) { if (Time.time - startTime > timeout) { MPMain.LogError(Localization.Get("MPSteamworks", "ConnectionTimeout", ((object)(SteamId)(ref steamId)).ToString())); _outgoingConnections.Remove(steamId); _allConnections.Remove(steamId); return false; } await Task.Yield(); continue; } break; } MPMain.LogInfo(Localization.Get("MPSteamworks", "ConnectSuccess", ((object)(SteamId)(ref steamId)).ToString())); return true; } return false; } public async Task<bool> CreateRoomAsync(string roomName, int maxPlayers) { DisconnectAll(); try { if (!SteamClient.IsValid) { MPMain.LogError(Localization.Get("MPSteamworks", "SteamClientInvalid")); return false; } Lobby? lobbyResult = await SteamMatchmaking.CreateLobbyAsync(maxPlayers); if (!lobbyResult.HasValue) { MPMain.LogError(Localization.Get("MPSteamworks", "CreateLobbyFailed")); return false; } _currentLobby = lobbyResult.Value; object[] array = new object[1]; SteamId val = ((Lobby)(ref _currentLobby)).Id; array[0] = ((object)(SteamId)(ref val)).ToString(); MPMain.LogInfo(Localization.Get("MPSteamworks", "LobbyCreatedSuccess", array)); ((Lobby)(ref _currentLobby)).SetData("name", roomName); ((Lobby)(ref _currentLobby)).SetData("game_version", Application.version); ref Lobby currentLobby = ref _currentLobby; val = SteamClient.SteamId; ((Lobby)(ref currentLobby)).SetData("owner", ((object)(SteamId)(ref val)).ToString()); ((Lobby)(ref _currentLobby)).SetPublic(); ((Lobby)(ref _currentLobby)).SetJoinable(true); ((Lobby)(ref _currentLobby)).Owner = new Friend(SteamClient.SteamId); CreateListeningSocket(); return true; } catch (Exception ex2) { Exception ex = ex2; MPMain.LogError(Localization.Get("MPSteamworks", "CreateLobbyException", ex.Message)); return false; } } public void CreateRoom(string roomName, int maxPlayers, Action<bool> callback) { ((MonoBehaviour)this).StartCoroutine(RunAsync(CreateRoomAsync(roomName, maxPlayers), callback)); } public async Task<bool> JoinRoomAsync(Lobby lobby) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) DisconnectAll(); try { RoomEnter result = await ((Lobby)(ref lobby)).Join(); if ((int)result != 1) { throw new Exception("[MPSW] Failed to join Steam lobby: " + ((object)(RoomEnter)(ref result)).ToString()); } _currentLobby = lobby; string roomName = ((Lobby)(ref _currentLobby)).GetData("name") ?? Localization.Get("MPSteamworks", "NullLobbyName"); MPMain.LogInfo(Localization.Get("MPSteamworks", "JoinLobbySuccess", roomName)); CreateListeningSocket(); return true; } catch (Exception ex2) { Exception ex = ex2; MPMain.LogError(Localization.Get("MPSteamworks", "JoinLobbyException", ex.Message)); return false; } } public void JoinRoom(ulong lobbyId, Action<bool> callback) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) Lobby lobby = default(Lobby); ((Lobby)(ref lobby))..ctor(SteamId.op_Implicit(lobbyId)); ((MonoBehaviour)this).StartCoroutine(RunAsync(JoinRoomAsync(lobby), callback)); } private void HandleLobbyEntered(Lobby lobby) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) _currentLobby = lobby; HostSteamId = SteamId.op_Implicit(((Lobby)(ref lobby)).Owner.Id); object[] array = new object[1]; SteamId id = ((Lobby)(ref lobby)).Id; array[0] = ((object)(SteamId)(ref id)).ToString(); MPMain.LogInfo(Localization.Get("MPSteamworks", "EnteredLobby", array)); foreach (Friend member in ((Lobby)(ref lobby)).Members) { Friend current = member; if (
WKMultiPlayerMod.Shared.dll
Decompiled 4 days agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.Events; using WKMPMod.Data; using WKMPMod.Util; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("WKMultiPlayerMod.Shared")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+cb3c66716b937a5ff34ee39cd1a2aee36b87685a")] [assembly: AssemblyProduct("WKMultiPlayerMod.Shared")] [assembly: AssemblyTitle("WKMultiPlayerMod.Shared")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace WKMPMod.Util { public static class DictionaryExtensions { public static List<ulong> FindByKeySuffix<T>(this Dictionary<ulong, T> dictionary, ulong suffix) { List<ulong> list = new List<ulong>(); if (dictionary == null || dictionary.Count == 0) { return list; } ulong num = CalculateDivisor(suffix); foreach (KeyValuePair<ulong, T> item in dictionary) { if (item.Key % num == suffix) { list.Add(item.Key); } } return list; } private static ulong CalculateDivisor(ulong suffix) { if (suffix == 0) { return 10uL; } ulong num; for (num = 1uL; num <= suffix; num *= 10) { } return num; } public static Dictionary<K, byte> SetDifference<K>(Dictionary<K, byte> minuend, Dictionary<K, byte> subtrahend) { Dictionary<K, byte> dictionary = new Dictionary<K, byte>(); foreach (var (key, b2) in minuend) { if (subtrahend.TryGetValue(key, out var value) && b2 > value) { dictionary[key] = (byte)(b2 - value); } else { dictionary[key] = b2; } } return dictionary; } } public class TickTimer { private float _interval; private float _lastTickTime; public float Progress => Mathf.Clamp01((Time.time - _lastTickTime) / _interval); public float TimeRemaining => Mathf.Max(0f, _interval - (Time.time - _lastTickTime)); public bool IsTickReached => Time.time - _lastTickTime >= _interval; public TickTimer(float tick) { _interval = tick; _lastTickTime = 0f - _interval; } public TickTimer(int hz) { _interval = 1f / (float)hz; _lastTickTime = 0f - _interval; } public void SetInterval(float tick) { _interval = tick; } public void SetFrequency(float hz) { _interval = 1f / hz; } public void Reset() { _lastTickTime = Time.time; } public bool TryTick() { if (Time.time - _lastTickTime >= _interval) { _lastTickTime = Time.time; return true; } return false; } public void ForceTick() { _lastTickTime = Time.time; } } } namespace WKMPMod.MK_Component { public class MK_CL_Handhold : MonoBehaviour { public UnityEvent activeEvent = new UnityEvent(); public UnityEvent stopEvent = new UnityEvent(); public Renderer handholdRenderer; } public class MK_ObjectTagger : MonoBehaviour { public List<string> tags = new List<string>(); } public class MK_RemoteEntity : MonoBehaviour { public ulong PlayerId; public float AllActive = 1f; public float HammerActive = 1f; public float RebarActive = 1f; public float ReturnRebarActive = 1f; public float RebarExplosionActive = 1f; public float ExplosionActive = 1f; public float PitonActive = 1f; public float FlareActive = 1f; public float IceActive = 1f; public float OtherActive = 1f; } } namespace WKMPMod.Data { [Serializable] public struct HandData { public HandType handType; public float PosX; public float PosY; public float PosZ; public Vector3 Position { get { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vector3(PosX, PosY, PosZ); } set { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) PosX = value.x; PosY = value.y; PosZ = value.z; } } } public enum HandType { Left, Right } [Serializable] public class PlayerData { public ulong playId; public long TimestampTicks; public float PosX; public float PosY; public float PosZ; public float RotX; public float RotY; public float RotZ; public float RotW; public HandData LeftHand; public HandData RightHand; public bool IsTeleport; public static int CalculateSize => 69; public Vector3 Position { get { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vector3(PosX, PosY, PosZ); } set { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) PosX = value.x; PosY = value.y; PosZ = value.z; } } public Quaternion Rotation { get { //IL_0018: Unknown result type (might be due to invalid IL or missing references) return new Quaternion(RotX, RotY, RotZ, RotW); } set { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) RotX = value.x; RotY = value.y; RotZ = value.z; RotW = value.w; } } public DateTime Timestamp { get { return new DateTime(TimestampTicks); } set { TimestampTicks = value.Ticks; } } public PlayerData() { LeftHand = new HandData { handType = HandType.Left }; RightHand = new HandData { handType = HandType.Right }; } } } namespace WKMPMod.Component { public class LookAt : MonoBehaviour { private Camera? mainCamera; [Header("锁定大小")] public bool maintainScreenSize = true; [Header("初始缩放比例")] public float baseScale = 0.1f; [Header("用户设置缩放比例")] public float userScale = 1f; private void LateUpdate() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)mainCamera == (Object)null) { mainCamera = Camera.main; if ((Object)(object)mainCamera == (Object)null) { return; } } ((Component)this).transform.rotation = ((Component)mainCamera).transform.rotation; if (maintainScreenSize) { float num = Vector3.Distance(((Component)this).transform.position, ((Component)mainCamera).transform.position); float num2 = ((!(num < 10f)) ? num : (0.8f * num + 2f)); float num3 = num2 * baseScale * userScale; ((Component)this).transform.localScale = new Vector3(num3, num3, num3); } } } public class ObjectIdentity : MonoBehaviour { public string FactoryKey = ""; } public class RemoteHand : MonoBehaviour { [CompilerGenerated] private sealed class <ResetTeleportFlag>d__10 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public RemoteHand <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ResetTeleportFlag>d__10(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; <>4__this._isTeleporting = false; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [Header("左右手")] public HandType hand; [Header("距离设置")] [Tooltip("当当前位置与目标位置超过此距离时直接瞬移")] public float teleportThreshold = 50f; [Tooltip("平滑移动的最大距离限制")] public float maxSmoothDistance = 10f; private bool _isTeleporting = false; private Vector3 _targetPosition; private Vector3 _velocity = Vector3.zero; private void LateUpdate() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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) if (_isTeleporting) { return; } float num = Vector3.Distance(((Component)this).transform.position, _targetPosition); if (num > teleportThreshold) { Teleport(_targetPosition); } else if (((Component)this).transform.position != _targetPosition) { float num2 = CalculateSmoothTime(num); ((Component)this).transform.position = Vector3.SmoothDamp(((Component)this).transform.position, _targetPosition, ref _velocity, num2, float.MaxValue, Time.deltaTime); if (((Vector3)(ref _velocity)).magnitude < 0.5f && num > 0.05f) { Vector3 val = _targetPosition - ((Component)this).transform.position; Vector3 normalized = ((Vector3)(ref val)).normalized; _velocity = normalized * 0.5f; } } } private float CalculateSmoothTime(float distance) { if (distance > maxSmoothDistance) { return Mathf.Clamp(Mathf.Log(distance) * 0.1f, 0.05f, 0.3f); } return Mathf.Clamp(distance / 10f, 0.05f, 0.1f); } public void UpdateFromHandData(HandData handData) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) _isTeleporting = false; _targetPosition = handData.Position; } public void Teleport(Vector3 position) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) _isTeleporting = true; ((Component)this).transform.position = position; _targetPosition = position; _velocity = Vector3.zero; ((MonoBehaviour)this).StartCoroutine(ResetTeleportFlag()); } [IteratorStateMachine(typeof(<ResetTeleportFlag>d__10))] private IEnumerator ResetTeleportFlag() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ResetTeleportFlag>d__10(0) { <>4__this = this }; } } public class RemotePlayer : MonoBehaviour { [CompilerGenerated] private sealed class <ResetTeleportFlag>d__10 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public RemotePlayer <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ResetTeleportFlag>d__10(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; <>4__this._isTeleporting = false; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [Header("距离设置")] [Tooltip("当当前位置与目标位置超过此距离时直接瞬移")] public float teleportThreshold = 50f; [Tooltip("平滑移动的最大距离限制")] public float maxSmoothDistance = 10f; private bool _isTeleporting = false; private Vector3 _targetPosition; private Vector3 _velocity = Vector3.zero; private void LateUpdate() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) if (_isTeleporting) { return; } float num = Vector3.Distance(((Component)this).transform.position, _targetPosition); if (num > teleportThreshold) { Teleport(_targetPosition); } else if (((Component)this).transform.position != _targetPosition) { float num2 = CalculateSmoothTime(num); ((Component)this).transform.position = Vector3.SmoothDamp(((Component)this).transform.position, _targetPosition, ref _velocity, num2, float.MaxValue, Time.deltaTime); if (((Vector3)(ref _velocity)).magnitude < 0.5f && num > 0.05f) { Vector3 val = _targetPosition - ((Component)this).transform.position; Vector3 normalized = ((Vector3)(ref val)).normalized; _velocity = normalized * 0.5f; } } } private float CalculateSmoothTime(float distance) { if (distance > maxSmoothDistance) { return Mathf.Clamp(Mathf.Log(distance) * 0.1f, 0.05f, 0.3f); } return Mathf.Clamp(distance / 10f, 0.05f, 0.1f); } public void UpdateFromPlayerData(Vector3 position, Quaternion rotation) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) _isTeleporting = false; _targetPosition = position; ((Component)this).transform.rotation = rotation; } public void UpdateFromPlayerData(PlayerData playerData) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) _isTeleporting = false; _targetPosition = playerData.Position; ((Component)this).transform.rotation = playerData.Rotation; } public void Teleport(Vector3 position, Quaternion? rotation = null) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) _isTeleporting = true; ((Component)this).transform.position = position; _targetPosition = position; _velocity = Vector3.zero; if (rotation.HasValue) { ((Component)this).transform.rotation = rotation.Value; } ((MonoBehaviour)this).StartCoroutine(ResetTeleportFlag()); } [IteratorStateMachine(typeof(<ResetTeleportFlag>d__10))] private IEnumerator ResetTeleportFlag() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ResetTeleportFlag>d__10(0) { <>4__this = this }; } } public class RemoteTag : MonoBehaviour { [CompilerGenerated] private sealed class <MessageTimeoutRoutine>d__20 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public RemoteTag <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <MessageTimeoutRoutine>d__20(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(15f); <>1__state = 1; return true; case 1: <>1__state = -1; <>4__this._message = ""; <>4__this.RefreshName(); <>4__this._messageTimeoutCoroutine = null; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private Transform? _cameraTransform; private TextMeshPro? _textMeshPro; private float _lastUpdateDistance; private TickTimer updateTick = new TickTimer(1); [Header("Settings")] public const float MIN_DISTANCE_LABEL = 10f; public const float DISTANCE_CHANGE_THRESHOLD = 1f; public const float MESSAGE_TIMEOUT = 15f; [Header("Id")] public ulong PlayerId; [Header("名字")] public string PlayerName = ""; [Header("Message")] public string _message = ""; private Coroutine? _messageTimeoutCoroutine; public string Message { get { return _message; } set { string text = ((value.Length <= 15) ? value : value.Substring(0, 15)); if (!(_message == text)) { _message = text; if (_messageTimeoutCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(_messageTimeoutCoroutine); } _messageTimeoutCoroutine = ((MonoBehaviour)this).StartCoroutine(MessageTimeoutRoutine()); RefreshName(); } } } private void Awake() { _textMeshPro = ((Component)this).GetComponent<TextMeshPro>(); if ((Object)(object)Camera.main != (Object)null) { _cameraTransform = ((Component)Camera.main).transform; } } private void OnDestroy() { if (_messageTimeoutCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(_messageTimeoutCoroutine); } } private void LateUpdate() { //IL_005f: 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) if (!updateTick.TryTick()) { return; } if ((Object)(object)_cameraTransform == (Object)null) { if (!((Object)(object)Camera.main != (Object)null)) { Debug.LogError((object)"[MP RemoteTag]No main camera found"); return; } _cameraTransform = ((Component)Camera.main).transform; } float num = Vector3.Distance(((Component)this).transform.position, _cameraTransform.position); if (Mathf.Abs(num - _lastUpdateDistance) >= 1f) { RefreshName(num); } } public void Initialize(ulong playerId, string playerName) { PlayerId = playerId; PlayerName = playerName; } public void RefreshName() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_cameraTransform == (Object)null)) { RefreshName(Vector3.Distance(((Component)this).transform.position, _cameraTransform.position)); } } private void RefreshName(float currentDistance) { _lastUpdateDistance = currentDistance; if (!((Object)(object)_textMeshPro == (Object)null)) { string text = currentDistance.ToString("F0"); if (currentDistance < 10f) { ((TMP_Text)_textMeshPro).text = (string.IsNullOrEmpty(_message) ? PlayerName : (PlayerName + "\n" + _message)); return; } ((TMP_Text)_textMeshPro).text = (string.IsNullOrEmpty(_message) ? (PlayerName + " (" + text + "m)") : (PlayerName + " (" + text + "m)\n" + _message)); } } [IteratorStateMachine(typeof(<MessageTimeoutRoutine>d__20))] private IEnumerator MessageTimeoutRoutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <MessageTimeoutRoutine>d__20(0) { <>4__this = this }; } } public class SimpleArmIK : MonoBehaviour { [Header("目标设置")] public Transform? target; public float originalLength = 1f; [Header("限制")] public float minScale = 0.1f; public float maxScale = 10f; private void Start() { //IL_0029: 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 (originalLength <= 0f && (Object)(object)target != (Object)null) { originalLength = Vector3.Distance(((Component)this).transform.position, target.position); } } private void LateUpdate() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)target == (Object)null)) { Vector3 val = target.position - ((Component)this).transform.position; float magnitude = ((Vector3)(ref val)).magnitude; if (!(magnitude < 0.0001f)) { ((Component)this).transform.rotation = Quaternion.FromToRotation(Vector3.up, val); float num = magnitude / originalLength; num = Mathf.Clamp(num, minScale, maxScale); ((Component)this).transform.localScale = new Vector3(1f, num, 1f); } } } } }