using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Net; using System.Net.Sockets; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Timers; using Anvil; using BepInEx; using BepInEx.Bootstrap; using FistVR; using FistVR.BTrap; using FistVR.MG; using H3MP.Networking; using H3MP.Patches; using H3MP.Scripts; using H3MP.Tracking; using HarmonyLib; using HarmonyLib.Public.Patching; using Mono.Cecil.Cil; using Open.Nat; using UnityEngine; using UnityEngine.Audio; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; using Valve.Newtonsoft.Json.Linq; using Valve.VR; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("H3MP")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("H3MP")] [assembly: AssemblyCopyright("Copyright © 2022")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("4e60aee7-baed-4e40-8c9c-2edc0a12f580")] [assembly: AssemblyFileVersion("1.14.0.0")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.14.0.0")] [module: UnverifiableCode] namespace H3MP { public class GameManager : MonoBehaviour { public delegate void OnUpdatePlayerHiddenDelegate(PlayerManager player, ref bool visible); public delegate void OnPlayerDamageDelegate(float damageMultiplier, Damage damage, ref bool processDamage); public delegate void OnSpectatorHostsChangedDelegate(); public delegate void OnSpectatorHostToggledDelegate(bool spectatorHost); public delegate void OnInstanceLeftDelegate(int instance, int destination); public delegate void OnInstanceJoinedDelegate(int instance, int source); public delegate void OnPlayerInstanceChangedDelegate(int ID, int instance, int destination); public delegate void OnSceneLeftDelegate(string scene, string destination); public delegate void OnSceneJoinedDelegate(string scene, string source); public delegate void OnPlayerBodyInitDelegate(FVRPlayerBody playerBody); public delegate void OnPlayerAddedDelegate(PlayerManager player); private static GameManager _singleton; public static Dictionary players = new Dictionary(); public static List objects = new List(); public static Dictionary trackedObjectByObject = new Dictionary(); public static Dictionary trackedObjectByInteractive = new Dictionary(); public static Dictionary trackedObjectByDamageable = new Dictionary(); public static Dictionary trackedObjectByShatterable = new Dictionary(); public static Dictionary trackedItemByItem = new Dictionary(); public static Dictionary trackedItemBySosigWeapon = new Dictionary(); public static Dictionary trackedSosigBySosig = new Dictionary(); public static Dictionary trackedAutoMeaterByAutoMeater = new Dictionary(); public static Dictionary trackedEncryptionByEncryption = new Dictionary(); public static Dictionary trackedBreakableGlassByBreakableGlass = new Dictionary(); public static Dictionary trackedBreakableGlassByBreakableGlassDamager = new Dictionary(); public static Dictionary trackedGatlingGunByGatlingGun = new Dictionary(); public static Dictionary trackedBrutBlockSystemByBrutBlockSystem = new Dictionary(); public static Dictionary trackedBlisterByBlister = new Dictionary(); public static Dictionary trackedFloaterByFloater = new Dictionary(); public static Dictionary trackedIrisByIris = new Dictionary(); public static Dictionary trackedSentinelBySentinel = new Dictionary(); public static Dictionary trackedNodeByNode = new Dictionary(); public static Dictionary trackedHazeByHaze = new Dictionary(); public static Dictionary activeInstances = new Dictionary(); public static Dictionary TNHInstances = new Dictionary(); public static List playersAtLoadStart; public static Dictionary>> playersByInstanceByScene = new Dictionary>>(); public static Dictionary>> objectsByInstanceByScene = new Dictionary>>(); public static List retrack = new List(); public static bool spectatorHost; public static List spectatorHosts = new List(); public static int controlledSpectatorHost = -1; public static int spectatorHostControlledBy = -1; public static bool resetSpectatorHost; public static bool instanceBringItems; public static long ping = -1L; public static int reconnectionInstance = -1; public static Dictionary nonSynchronizedScenes = new Dictionary(); public static int giveControlOfDestroyed; public static bool controlOverride; public static bool firstPlayerInSceneInstance; public static bool dontAddToInstance; public static bool inPostSceneLoadTrack; public static int ID = 0; public static Vector3 torsoOffset = new Vector3(0f, -0.4f, 0f); public static Vector3 overheadDisplayOffset = new Vector3(0f, 0.25f, 0f); public static List playersPresent = new List(); public static int playerStateAddtionalDataSize = -1; public static int instance = 0; public static string scene = "MainMenu3"; public static bool sceneLoading; public static int instanceAtSceneLoadStart; public static string sceneAtSceneLoadStart; public static bool connectedAtLoadStart; public static int colorIndex = 0; public static readonly string[] colorNames = new string[7] { "White", "Red", "Green", "Blue", "Black", "Desert", "Forest" }; public static readonly Color[] colors = (Color[])(object)new Color[7] { Color.white, Color.red, Color.green, Color.blue, Color.black, new Color(0.98431f, 0.86275f, 0.71373f), new Color(0.31373f, 0.31373f, 0.15294f) }; public static bool colorByIFF = false; public static int nameplateMode = 1; public static int radarMode = 0; public static bool radarColor = true; public static bool overrideMaxHealthSetting = false; public static float[] maxHealths = new float[9] { 1f, 500f, 1000f, 2000f, 3000f, 4000f, 5000f, 7500f, 10000f }; public static int maxHealthIndex = -1; public static Dictionary>> maxHealthByInstanceByScene = new Dictionary>>(); public static string playerPrefabID = "None"; public static int playerPrefabIndex = -1; public static TrackedPlayerBody currentTrackedPlayerBody; public static bool playerModelAwaitingInstantiation = false; public static PlayerBody currentPlayerBody = null; public static bool bodyVisible = true; public static bool handsVisible = true; public static Dictionary playerPrefabs = new Dictionary(); public static List playerPrefabIDs = new List(); public static GameManager singleton { get { return _singleton; } private set { if ((Object)(object)_singleton == (Object)null) { _singleton = value; } else if ((Object)(object)_singleton != (Object)(object)value) { Mod.LogInfo("GameManager instance already exists, destroying duplicate!", debug: false); Object.Destroy((Object)(object)value); } } } public static event OnUpdatePlayerHiddenDelegate OnUpdatePlayerHidden; public static event OnPlayerDamageDelegate OnPlayerDamage; public static event OnSpectatorHostsChangedDelegate OnSpectatorHostsChanged; public static event OnSpectatorHostToggledDelegate OnSpectatorHostToggled; public static event OnInstanceLeftDelegate OnInstanceLeft; public static event OnInstanceJoinedDelegate OnInstanceJoined; public static event OnPlayerInstanceChangedDelegate OnPlayerInstanceChanged; public static event OnSceneLeftDelegate OnSceneLeft; public static event OnSceneJoinedDelegate OnSceneJoined; public static event OnPlayerBodyInitDelegate OnPlayerBodyInit; public static event OnPlayerAddedDelegate OnPlayerAdded; private void Awake() { singleton = this; activeInstances.Add(instance, 1); } private void Update() { if (!Input.GetKeyDown((KeyCode)287) || sceneLoading) { return; } spectatorHost = !spectatorHost; if ((Object)(object)GM.CurrentPlayerBody != (Object)null) { ((Behaviour)GM.CurrentPlayerBody.EyeCam).enabled = !spectatorHost; } if (ThreadManager.host) { if (spectatorHost) { spectatorHosts.Add(0); Server.availableSpectatorHosts.Add(0); } else { spectatorHosts.Remove(0); Server.availableSpectatorHosts.Remove(0); } ServerSend.SpectatorHost(0, spectatorHost); } else { spectatorHosts.Add(ID); ClientSend.SpectatorHost(spectatorHost); } if (spectatorHost) { Mod.LogWarning("Player is now a spectator host!"); if (!scene.Equals("MainMenu3")) { SteamVR_LoadLevel.Begin("MainMenu3", false, 0.5f, 0f, 0f, 0f, 1f); } } else { Mod.LogWarning("Player is no longer a spectator host!"); spectatorHostControlledBy = -1; Mod.spectatorHostWaitingForTNHSetup = false; } if (GameManager.OnSpectatorHostToggled != null) { GameManager.OnSpectatorHostToggled(spectatorHost); } } public static void OnSpectatorHostsChangedInvoke() { if (GameManager.OnSpectatorHostsChanged != null) { GameManager.OnSpectatorHostsChanged(); } } public void SpawnPlayer(int ID, string username, string scene, int instance, int IFF, int colorIndex, bool join = false) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown if ((Object)(object)Client.singleton != (Object)null && ID == Client.singleton.ID) { return; } Mod.LogInfo($"Spawn player called with ID: {ID}", debug: false); GameObject val = new GameObject("PlayerRoot" + ID); Object.DontDestroyOnLoad((Object)(object)val); PlayerManager playerManager = val.AddComponent(); playerManager.Init(ID, username, scene, instance, IFF, colorIndex); players.Add(ID, playerManager); bool flag = false; if (playersByInstanceByScene.TryGetValue(scene, out var value)) { if (value.TryGetValue(instance, out var value2)) { value2.Add(ID); flag = value2.Count == 1; } else { value.Add(instance, new List { ID }); flag = true; } } else { Dictionary> dictionary = new Dictionary>(); dictionary.Add(instance, new List { ID }); playersByInstanceByScene.Add(scene, dictionary); flag = true; } flag = (playerManager.firstInSceneInstance = flag & (sceneLoading || !scene.Equals(GameManager.scene) || instance != GameManager.instance)); if (ThreadManager.host) { Server.clients[ID].player.firstInSceneInstance = flag; } if (activeInstances.ContainsKey(instance)) { Dictionary dictionary2 = activeInstances; int value3 = dictionary2[instance] + 1; dictionary2[instance] = value3; } else { activeInstances.Add(instance, 1); } UpdatePlayerHidden(playerManager); if (!nonSynchronizedScenes.ContainsKey(scene) && scene.Equals(GameManager.scene) && instance == GameManager.instance) { playersPresent.Add(ID); if (join) { firstPlayerInSceneInstance = false; } } if (GameManager.OnPlayerAdded != null) { GameManager.OnPlayerAdded(playerManager); } } public static IEnumerator InstantiatePlayerBody(FVRObject playerModelFVRObject, string playerPrefabID) { yield return ((AnvilAsset)playerModelFVRObject).GetGameObjectAsync(); GameObject prefab = ((AnvilAsset)playerModelFVRObject).GetGameObject(); if ((Object)(object)prefab == (Object)null) { Mod.LogWarning("Attempted to instantiate player model \"" + playerPrefabID + "\" but failed to get prefab. Using Default instead."); GameManager.playerPrefabID = "Default"; } currentPlayerBody = Object.Instantiate(prefab).GetComponent(); playerModelAwaitingInstantiation = false; } public static void Reset() { foreach (KeyValuePair player in players) { Object.Destroy((Object)(object)((Component)player.Value).gameObject); } players.Clear(); objects.Clear(); spectatorHosts.Clear(); trackedObjectByObject.Clear(); trackedObjectByInteractive.Clear(); trackedObjectByDamageable.Clear(); trackedItemByItem.Clear(); trackedSosigBySosig.Clear(); trackedItemBySosigWeapon.Clear(); trackedAutoMeaterByAutoMeater.Clear(); trackedEncryptionByEncryption.Clear(); trackedBreakableGlassByBreakableGlass.Clear(); trackedBreakableGlassByBreakableGlassDamager.Clear(); trackedBlisterByBlister.Clear(); trackedFloaterByFloater.Clear(); trackedGatlingGunByGatlingGun.Clear(); trackedBrutBlockSystemByBrutBlockSystem.Clear(); trackedIrisByIris.Clear(); trackedSentinelBySentinel.Clear(); trackedNodeByNode.Clear(); trackedObjectByShatterable.Clear(); if (playersAtLoadStart != null) { playersAtLoadStart.Clear(); } activeInstances.Clear(); TNHInstances.Clear(); playersByInstanceByScene.Clear(); objectsByInstanceByScene.Clear(); ID = 0; instance = 0; giveControlOfDestroyed = 0; controlOverride = false; firstPlayerInSceneInstance = false; dontAddToInstance = false; playersPresent.Clear(); playerStateAddtionalDataSize = -1; sceneLoading = false; instanceAtSceneLoadStart = 0; ping = -1L; colorByIFF = false; nameplateMode = 1; radarMode = 0; radarColor = true; maxHealthIndex = -1; maxHealthByInstanceByScene.Clear(); spectatorHost = false; ((Behaviour)GM.CurrentPlayerBody.EyeCam).enabled = true; spectatorHostControlledBy = -1; controlledSpectatorHost = -1; for (int i = 0; i < TrackedObject.trackedReferenceObjects.Length; i++) { if ((Object)(object)TrackedObject.trackedReferenceObjects[i] != (Object)null) { Object.Destroy((Object)(object)TrackedObject.trackedReferenceObjects[i]); } } TrackedObject.trackedReferenceObjects = (GameObject[])(object)new GameObject[100]; TrackedObject.trackedReferences = new TrackedObject[100]; TrackedObject.availableTrackedRefIndices = new List { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 }; TrackedObject.unknownTrackedIDs.Clear(); TrackedObject.unknownParentWaitList.Clear(); TrackedObject.unknownControlTrackedIDs.Clear(); TrackedObject.unknownDestroyTrackedIDs.Clear(); TrackedObject.unknownParentTrackedIDs.Clear(); TrackedItem.unknownCrateHolding.Clear(); TrackedItem.unknownSosigInventoryItems.Clear(); TrackedItem.unknownSosigInventoryObjects.Clear(); TrackedItem.unknownGasCuboidGout.Clear(); TrackedItem.unknownGasCuboidDamageHandle.Clear(); TrackedSosig.unknownBodyStates.Clear(); TrackedSosig.unknownIFFChart.Clear(); TrackedSosig.unknownItemInteract.Clear(); TrackedSosig.unknownSetIFFs.Clear(); TrackedSosig.unknownSetOriginalIFFs.Clear(); TrackedSosig.unknownTNHKills.Clear(); TrackedSosig.unknownCurrentOrder.Clear(); TrackedSosig.unknownConfiguration.Clear(); TrackedSosig.unknownWearable.Clear(); TrackedEncryption.unknownDisableSubTarg.Clear(); TrackedEncryption.unknownInit.Clear(); TrackedEncryption.unknownResetGrowth.Clear(); TrackedEncryption.unknownSpawnGrowth.Clear(); TrackedEncryption.unknownSpawnSubTarg.Clear(); TrackedEncryption.unknownSpawnSubTargGeo.Clear(); TrackedEncryption.unknownUpdateDisplay.Clear(); TrackedEncryption.unknownPreviewPos.Clear(); TrackedEncryption.unknownShieldRot.Clear(); TrackedFloater.unknownFloaterBeginExploding.Clear(); TrackedFloater.unknownFloaterBeginDefusing.Clear(); TrackedFloater.unknownFloaterExplode.Clear(); TrackedIris.unknownIrisShatter.Clear(); TrackedIris.unknownIrisSetState.Clear(); TrackedNode.unknownInit.Clear(); TrackedSentinel.unknownInit.Clear(); } public static void UpdatePlayerState(int ID, Vector3 position, Quaternion rotation, Vector3 headPos, Quaternion headRot, Vector3 torsoPos, Quaternion torsoRot, Vector3 leftHandPos, Quaternion leftHandRot, Vector3 rightHandPos, Quaternion rightHandRot, float health, int maxHealth, byte[] additionalData) { //IL_0045: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) if (!players.ContainsKey(ID)) { Mod.LogWarning($"Received UDP order to update player {ID} state but player of this ID hasnt been spawned yet"); return; } PlayerManager playerManager = players[ID]; Transform transform = ((Component)playerManager).transform; transform.position = position; transform.rotation = rotation; playerManager.head.position = headPos; playerManager.head.rotation = headRot; playerManager.leftHand.position = leftHandPos; playerManager.leftHand.rotation = leftHandRot; playerManager.rightHand.position = rightHandPos; playerManager.rightHand.rotation = rightHandRot; float health2 = playerManager.health; playerManager.health = health; int maxHealth2 = playerManager.maxHealth; playerManager.maxHealth = maxHealth; if ((Object)(object)playerManager.playerBody != (Object)null && (health != health2 || maxHealth != maxHealth2)) { playerManager.playerBody.UpdateHealthLabel(); } if ((health <= 0f && playerManager.visible) || (health > 0f && !playerManager.visible)) { UpdatePlayerHidden(playerManager); } } public static void UpdatePlayerScene(int playerID, string sceneName) { Mod.LogInfo("Player " + playerID + " joining scene " + sceneName, debug: false); PlayerManager value = null; if (!players.TryGetValue(playerID, out value)) { return; } playersByInstanceByScene[value.scene][value.instance].Remove(value.ID); if (playersByInstanceByScene[value.scene][value.instance].Count == 0) { playersByInstanceByScene[value.scene].Remove(value.instance); } if (playersByInstanceByScene[value.scene].Count == 0) { playersByInstanceByScene.Remove(value.scene); } if (value.scene.Equals(scene) && !nonSynchronizedScenes.ContainsKey(value.scene) && instance == value.instance) { playersPresent.Remove(playerID); } value.scene = sceneName; bool flag = false; if (playersByInstanceByScene.TryGetValue(value.scene, out var value2)) { if (value2.TryGetValue(value.instance, out var value3)) { value3.Add(value.ID); flag = value3.Count == 1; } else { value2.Add(value.instance, new List { value.ID }); flag = true; } } else { Dictionary> dictionary = new Dictionary>(); dictionary.Add(value.instance, new List { value.ID }); playersByInstanceByScene.Add(value.scene, dictionary); flag = true; } flag = (value.firstInSceneInstance = flag & (sceneLoading || !value.scene.Equals(scene) || value.instance != instance)); if (ThreadManager.host) { Server.clients[playerID].player.scene = sceneName; Server.clients[playerID].player.firstInSceneInstance = flag; } UpdatePlayerHidden(value); if (sceneName.Equals(scene) && !nonSynchronizedScenes.ContainsKey(sceneName) && instance == value.instance) { playersPresent.Add(playerID); } } public static bool UpdatePlayerHidden(PlayerManager player) { bool flag = true; flag &= !nonSynchronizedScenes.ContainsKey(player.scene) && player.scene.Equals(scene) && player.instance == instance && !spectatorHosts.Contains(player.ID) && player.health > 0f; if (flag && Mod.currentTNHInstance != null) { flag &= !Mod.currentTNHInstance.dead.Contains(player.ID); if (!flag && (Object)(object)player.reticleContact != (Object)null) { if ((Object)(object)Mod.currentTNHInstance.manager != (Object)null && (Object)(object)Mod.currentTNHInstance.manager.TAHReticle != (Object)null) { for (int i = 0; i < Mod.currentTNHInstance.manager.TAHReticle.Contacts.Count; i++) { if ((Object)(object)Mod.currentTNHInstance.manager.TAHReticle.Contacts[i] == (Object)(object)player.reticleContact) { GM.TNH_Manager.TAHReticle.m_trackedTransforms.Remove(GM.TNH_Manager.TAHReticle.Contacts[i].TrackedTransform); Object.Destroy((Object)(object)((Component)Mod.currentTNHInstance.manager.TAHReticle.Contacts[i]).gameObject); Mod.currentTNHInstance.manager.TAHReticle.Contacts.RemoveAt(i); player.reticleContact = null; break; } } } } else if (flag && (Object)(object)player.reticleContact == (Object)null && (Object)(object)Mod.currentTNHInstance.manager != (Object)null && Mod.currentTNHInstance.currentlyPlaying.Contains(player.ID)) { switch (radarMode) { case 0: player.reticleContact = GM.TNH_Manager.TAHReticle.RegisterTrackedObject(player.head, (ContactType)((!radarColor) ? (player.colorIndex - 4) : ((player.IFF == GM.CurrentPlayerBody.GetPlayerIFF()) ? (-2) : (-3)))); break; case 1: if (player.IFF == GM.CurrentPlayerBody.GetPlayerIFF()) { player.reticleContact = GM.TNH_Manager.TAHReticle.RegisterTrackedObject(player.head, (ContactType)((!radarColor) ? (player.colorIndex - 4) : ((player.IFF == GM.CurrentPlayerBody.GetPlayerIFF()) ? (-2) : (-3)))); } break; } } } if (GameManager.OnUpdatePlayerHidden != null) { GameManager.OnUpdatePlayerHidden(player, ref flag); } player.SetVisible(flag); return flag; } public static void UpdatePlayerInstance(int playerID, int instance) { //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) Mod.LogInfo("Player " + playerID + " joining instance " + instance, debug: false); PlayerManager playerManager = players[playerID]; if (activeInstances.ContainsKey(playerManager.instance)) { Dictionary dictionary = activeInstances; int key = playerManager.instance; int value = dictionary[key] - 1; dictionary[key] = value; if (activeInstances[playerManager.instance] == 0) { activeInstances.Remove(playerManager.instance); } } if (TNHInstances.TryGetValue(playerManager.instance, out var value2)) { int num = value2.playerIDs[0]; value2.playerIDs.Remove(playerID); if (value2.playerIDs.Count == 0) { TNHInstances.Remove(playerManager.instance); if ((Object)(object)Mod.TNHInstanceList != (Object)null && Mod.joinTNHInstances != null && Mod.joinTNHInstances.ContainsKey(instance)) { Object.Destroy((Object)(object)Mod.joinTNHInstances[instance]); Mod.joinTNHInstances.Remove(instance); } if (Mod.currentTNHInstance != null && Mod.currentTNHInstance.instance == playerManager.instance) { Mod.TNHSpectating = false; if ((Object)(object)GM.CurrentPlayerBody != (Object)null) { GM.CurrentPlayerBody.SetPlayerIFF(GM.CurrentSceneSettings.DefaultPlayerIFF); if ((Object)(object)GM.CurrentPlayerBody.RightHand != (Object)null && (Object)(object)GM.CurrentPlayerBody.LeftHand != (Object)null) { ((Component)GM.CurrentPlayerBody.RightHand).GetComponent().Mode = (HandMode)0; ((Component)GM.CurrentPlayerBody.LeftHand).GetComponent().Mode = (HandMode)0; } } } } else { if ((Object)(object)Mod.TNHMenu != (Object)null && (Object)(object)Mod.TNHPlayerList != (Object)null && (Object)(object)Mod.TNHPlayerPrefab != (Object)null && Mod.currentTNHInstancePlayers != null && Mod.currentTNHInstancePlayers.ContainsKey(playerID)) { Object.Destroy((Object)(object)Mod.currentTNHInstancePlayers[playerID]); Mod.currentTNHInstancePlayers.Remove(playerID); if (num != value2.playerIDs[0]) { Text component = ((Component)Mod.currentTNHInstancePlayers[value2.playerIDs[0]].transform.GetChild(0)).GetComponent(); component.text += " (Host)"; } } value2.currentlyPlaying.Remove(playerID); value2.played.Remove(playerID); value2.dead.Remove(playerID); } } if (GameManager.OnPlayerInstanceChanged != null) { GameManager.OnPlayerInstanceChanged(playerManager.ID, playerManager.instance, instance); } playersByInstanceByScene[playerManager.scene][playerManager.instance].Remove(playerManager.ID); if (playersByInstanceByScene[playerManager.scene][playerManager.instance].Count == 0) { playersByInstanceByScene[playerManager.scene].Remove(playerManager.instance); } if (playerManager.scene.Equals(scene) && !nonSynchronizedScenes.ContainsKey(playerManager.scene) && GameManager.instance == playerManager.instance) { playersPresent.Remove(playerID); } playerManager.instance = instance; bool flag = false; if (playersByInstanceByScene[playerManager.scene].TryGetValue(instance, out var value3)) { value3.Add(playerManager.ID); flag = value3.Count == 1; } else { playersByInstanceByScene[playerManager.scene].Add(instance, new List { playerManager.ID }); flag = true; } flag = (playerManager.firstInSceneInstance = flag & (sceneLoading || !playerManager.scene.Equals(scene) || playerManager.instance != GameManager.instance)); if (ThreadManager.host) { Server.clients[playerID].player.instance = instance; Server.clients[playerID].player.firstInSceneInstance = flag; } UpdatePlayerHidden(playerManager); if (playerManager.scene.Equals(scene) && !nonSynchronizedScenes.ContainsKey(playerManager.scene) && GameManager.instance == playerManager.instance) { playersPresent.Add(playerID); } if (activeInstances.ContainsKey(instance)) { Dictionary dictionary2 = activeInstances; int value = instance; int key = dictionary2[value] + 1; dictionary2[value] = key; } else { activeInstances.Add(instance, 1); } if (TNHInstances.ContainsKey(instance) && !TNHInstances[instance].playerIDs.Contains(playerID)) { TNHInstances[instance].playerIDs.Add(playerID); if ((Object)(object)Mod.TNHMenu != (Object)null && (Object)(object)Mod.TNHPlayerList != (Object)null && (Object)(object)Mod.TNHPlayerPrefab != (Object)null && Mod.currentTNHInstancePlayers != null && !Mod.currentTNHInstancePlayers.ContainsKey(playerID)) { GameObject val = Object.Instantiate(Mod.TNHPlayerPrefab, Mod.TNHPlayerList.transform); ((Component)val.transform.GetChild(0)).GetComponent().text = playerManager.username; val.SetActive(true); Mod.currentTNHInstancePlayers.Add(playerID, val); } } } public static void SetPlayerColor(int ID, int index, bool received = false, int clientID = 0, bool send = true) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Mod.managerObject == (Object)null) { colorIndex = index; if ((Object)(object)BodyWristMenuSection.colorText != (Object)null) { BodyWristMenuSection.colorText.text = "Current color: " + colorNames[colorIndex]; } return; } if (GameManager.ID == ID) { colorIndex = index; if ((Object)(object)currentPlayerBody != (Object)null) { currentPlayerBody.SetColor(colors[colorIndex]); } if ((Object)(object)BodyWristMenuSection.colorText != (Object)null) { BodyWristMenuSection.colorText.text = "Current color: " + colorNames[colorIndex]; } } else { players[ID].SetColor(index); if (ThreadManager.host) { Server.clients[ID].player.colorIndex = index; } } if (send) { if (ThreadManager.host) { ServerSend.PlayerColor(ID, index, clientID); } else if (!received) { ClientSend.PlayerColor(ID, index); } } } public static void SetPlayerPrefab(string prefabID) { string text = playerPrefabID; if (playerPrefabs.ContainsKey(prefabID)) { playerPrefabID = prefabID; } else if ((Object)(object)Mod.managerObject == (Object)null) { playerPrefabID = "None"; } else { playerPrefabID = "Default"; } if (text.Equals(playerPrefabID) && (Object)(object)currentPlayerBody != (Object)null) { return; } if ((Object)(object)currentPlayerBody != (Object)null) { Object.Destroy((Object)(object)((Component)currentPlayerBody).gameObject); } if (playerPrefabID.Equals("None")) { return; } if (playerPrefabID.Equals("Default")) { Object obj = playerPrefabs["Default"]; currentPlayerBody = Object.Instantiate((GameObject)(object)((obj is GameObject) ? obj : null)).GetComponent(); } else { bool flag = false; if (playerPrefabs.TryGetValue(playerPrefabID, out var value)) { if (value == (Object)null) { if (IM.OD.TryGetValue(playerPrefabID, out var value2) && (Object)(object)value2 != (Object)null) { flag = true; playerModelAwaitingInstantiation = true; AnvilManager.Run(InstantiatePlayerBody(value2, playerPrefabID)); } } else if (value is FVRObject) { flag = true; playerModelAwaitingInstantiation = true; AnvilManager.Run(InstantiatePlayerBody((FVRObject)(object)((value is FVRObject) ? value : null), playerPrefabID)); } } if (!flag) { Mod.LogWarning("Attempt to set player prefab to \"" + playerPrefabID + "\" failed, could not obtain prefab, using default"); playerPrefabID = "Default"; Object obj2 = playerPrefabs[playerPrefabID]; currentPlayerBody = Object.Instantiate((GameObject)(object)((obj2 is GameObject) ? obj2 : null)).GetComponent(); } } if ((Object)(object)BodyWristMenuSection.playerBodyText != (Object)null) { BodyWristMenuSection.playerBodyText.text = "Body: " + playerPrefabID; } } public static void AddPlayerPrefabID(string newPlayerPrefabID) { if (newPlayerPrefabID.Equals("Default")) { Mod.LogError("A mod attempted to register \"Default\" player prefab ID:\n" + Environment.StackTrace); return; } playerPrefabs.Add(newPlayerPrefabID, null); playerPrefabIDs.Add(newPlayerPrefabID); } public static void SyncTrackedObjects(bool init = false, bool inControl = false) { //IL_0022: 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_0066: Unknown result type (might be due to invalid IL or missing references) if (!ThreadManager.host && !Client.singleton.gotConnectSync) { return; } Scene activeScene = SceneManager.GetActiveScene(); GameObject[] rootGameObjects = ((Scene)(ref activeScene)).GetRootGameObjects(); GameObject[] array = rootGameObjects; foreach (GameObject val in array) { SyncTrackedObjects(val.transform, init ? inControl : controlOverride, null); } _ = Mod.DDOLScene; if (true) { rootGameObjects = ((Scene)(ref Mod.DDOLScene)).GetRootGameObjects(); GameObject[] array2 = rootGameObjects; foreach (GameObject val2 in array2) { SyncTrackedObjects(val2.transform, init ? inControl : controlOverride, null); } } } public static void SyncTrackedObjects(Transform root, bool controlEverything, TrackedObjectData parent) { //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Expected O, but got Unknown //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Expected O, but got Unknown if (!ThreadManager.host && !Client.singleton.gotConnectSync) { return; } if (GetTrackedObjectType(root, out var trackedObjectType)) { TrackedObject component = ((Component)root).GetComponent(); if ((Object)(object)component == (Object)null) { if (controlEverything || IsControlled(root, trackedObjectType)) { TrackedObject trackedObject = MakeObjectTracked(root, parent, trackedObjectType); if (!((Object)(object)trackedObject != (Object)null)) { return; } if (trackedObject.awoken) { if (ThreadManager.host) { Mod.LogInfo("Server made new object tracked with type ID: " + trackedObject.data.typeIdentifier, debug: false); Server.AddTrackedObject(trackedObject.data, 0); } else { trackedObject.data.localWaitingIndex = Client.localObjectCounter++; Mod.LogInfo("Client made new object tracked with local waiting index: " + trackedObject.data.localWaitingIndex + " and type ID: " + trackedObject.data.typeIdentifier, debug: false); Client.waitingLocalObjects.Add(trackedObject.data.localWaitingIndex, trackedObject.data); ClientSend.TrackedObject(trackedObject.data); } trackedObject.data.OnTracked(); } else { trackedObject.sendOnAwake = true; } { foreach (Transform item in root) { Transform root2 = item; SyncTrackedObjects(root2, controlEverything, trackedObject.data); } return; } } if (TrackSkipped(root, trackedObjectType)) { Object.Destroy((Object)(object)((Component)root).gameObject); } } else { parent?.children.Add(component.data); } return; } foreach (Transform item2 in root) { Transform root3 = item2; SyncTrackedObjects(root3, controlEverything, parent); } } private static TrackedObject MakeObjectTracked(Transform root, TrackedObjectData parent, Type trackedObjectType) { Mod.LogInfo("Making tracked object from " + ((Object)root).name, debug: false); return (TrackedObject)trackedObjectType.GetMethod("MakeTracked", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).Invoke(null, new object[2] { root, parent }); } public static TNHInstance AddNewTNHInstance(int hostID, bool letPeopleJoin, int progressionTypeSetting, int healthModeSetting, int equipmentModeSetting, int targetModeSetting, int AIDifficultyModifier, int radarModeModifier, int itemSpawnerMode, int backpackMode, int healthMult, int sosiggunShakeReloading, int TNHSeed, string levelID) { //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Expected O, but got Unknown if (ThreadManager.host) { int freeInstance = 1; while (activeInstances.ContainsKey(freeInstance)) { int num = freeInstance + 1; freeInstance = num; } TNHInstance tNHInstance = new TNHInstance(freeInstance, hostID, letPeopleJoin, progressionTypeSetting, healthModeSetting, equipmentModeSetting, targetModeSetting, AIDifficultyModifier, radarModeModifier, itemSpawnerMode, backpackMode, healthMult, sosiggunShakeReloading, TNHSeed, levelID); TNHInstances.Add(freeInstance, tNHInstance); if ((tNHInstance.letPeopleJoin || tNHInstance.currentlyPlaying.Count == 0) && (Object)(object)Mod.TNHInstanceList != (Object)null && Mod.joinTNHInstances != null && !Mod.joinTNHInstances.ContainsKey(freeInstance)) { GameObject val = Object.Instantiate(Mod.TNHInstancePrefab, Mod.TNHInstanceList.transform); ((Component)val.transform.GetChild(0)).GetComponent().text = "Instance " + freeInstance; val.SetActive(true); FVRPointableButton val2 = val.AddComponent(); val2.SetButton(); ((FVRPointable)val2).MaxPointingRange = 5f; ((UnityEvent)val2.Button.onClick).AddListener((UnityAction)delegate { Mod.OnTNHInstanceClicked(freeInstance); }); Mod.joinTNHInstances.Add(freeInstance, val); } activeInstances.Add(freeInstance, 0); Mod.modInstance.OnTNHInstanceReceived(tNHInstance); return tNHInstance; } ClientSend.AddTNHInstance(hostID, letPeopleJoin, progressionTypeSetting, healthModeSetting, equipmentModeSetting, targetModeSetting, AIDifficultyModifier, radarModeModifier, itemSpawnerMode, backpackMode, healthMult, sosiggunShakeReloading, TNHSeed, levelID); return null; } public static int AddNewInstance() { if (ThreadManager.host) { int i; for (i = 1; activeInstances.ContainsKey(i); i++) { } activeInstances.Add(i, 0); Mod.modInstance.OnInstanceReceived(i); ServerSend.AddInstance(i); return i; } ClientSend.AddInstance(); return -1; } public static void AddTNHInstance(TNHInstance instance) { //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Expected O, but got Unknown if (!activeInstances.ContainsKey(instance.instance)) { activeInstances.Add(instance.instance, instance.playerIDs.Count); } TNHInstances.Add(instance.instance, instance); if ((instance.letPeopleJoin || instance.currentlyPlaying.Count == 0) && (Object)(object)Mod.TNHInstanceList != (Object)null && Mod.joinTNHInstances != null && !Mod.joinTNHInstances.ContainsKey(instance.instance)) { GameObject val = Object.Instantiate(Mod.TNHInstancePrefab, Mod.TNHInstanceList.transform); ((Component)val.transform.GetChild(0)).GetComponent().text = "Instance " + instance.instance; val.SetActive(true); FVRPointableButton val2 = val.AddComponent(); val2.SetButton(); ((FVRPointable)val2).MaxPointingRange = 5f; ((UnityEvent)val2.Button.onClick).AddListener((UnityAction)delegate { Mod.OnTNHInstanceClicked(instance.instance); }); Mod.joinTNHInstances.Add(instance.instance, val); } dontAddToInstance = Mod.setLatestInstance; Mod.modInstance.OnTNHInstanceReceived(instance); } public static void AddInstance(int instance) { if (!activeInstances.ContainsKey(instance)) { activeInstances.Add(instance, 0); } Mod.modInstance.OnInstanceReceived(instance); } public static void SetInstance(int instance) { //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) Mod.LogInfo("Changing instance from " + GameManager.instance + " to " + instance + ":\n" + Environment.StackTrace, debug: false); if (activeInstances.ContainsKey(GameManager.instance)) { Dictionary dictionary = activeInstances; int key = GameManager.instance; int value = dictionary[key] - 1; dictionary[key] = value; if (activeInstances[GameManager.instance] == 0) { activeInstances.Remove(GameManager.instance); } } else { Mod.LogError("Instance we are leaving is missing from active instances!"); } if (GameManager.OnInstanceLeft != null) { GameManager.OnInstanceLeft(GameManager.instance, instance); } if (TNHInstances.TryGetValue(GameManager.instance, out var value2)) { value2.playerIDs.Remove(ID); if (value2.playerIDs.Count == 0) { TNHInstances.Remove(GameManager.instance); if ((Object)(object)Mod.TNHInstanceList != (Object)null && Mod.joinTNHInstances.ContainsKey(instance)) { Object.Destroy((Object)(object)Mod.joinTNHInstances[instance]); Mod.joinTNHInstances.Remove(instance); } Mod.TNHSpectating = false; if ((Object)(object)GM.CurrentPlayerBody != (Object)null) { GM.CurrentPlayerBody.SetPlayerIFF(GM.CurrentSceneSettings.DefaultPlayerIFF); if ((Object)(object)GM.CurrentPlayerBody.RightHand != (Object)null && (Object)(object)GM.CurrentPlayerBody.LeftHand != (Object)null) { ((Component)GM.CurrentPlayerBody.RightHand).GetComponent().Mode = (HandMode)0; ((Component)GM.CurrentPlayerBody.LeftHand).GetComponent().Mode = (HandMode)0; } } } value2.currentlyPlaying.Remove(ID); value2.dead.Remove(ID); if (controlledSpectatorHost != -1 && value2.currentlyPlaying.Count > 1 && value2.currentlyPlaying.Contains(controlledSpectatorHost)) { if (ThreadManager.host) { ReassignSpectatorHost(0, new List { 0 }); } else { ClientSend.ReassignSpectatorHost(new List { ID }); } Mod.OnSpectatorHostGiveUpInvoke(); } } if (!sceneLoading) { if (playersByInstanceByScene.TryGetValue(scene, out var value3)) { if (value3.TryGetValue(GameManager.instance, out var value4)) { playersAtLoadStart = value4; } else { playersAtLoadStart = null; } } else { playersAtLoadStart = null; } } int source = GameManager.instance; GameManager.instance = instance; if (!activeInstances.ContainsKey(instance)) { activeInstances.Add(instance, 0); } if (dontAddToInstance) { dontAddToInstance = false; } else { Dictionary dictionary2 = activeInstances; int value = instance; int key = dictionary2[value] + 1; dictionary2[value] = key; } instanceBringItems = !playersByInstanceByScene.TryGetValue(sceneLoading ? LoadLevelBeginPatch.loadingLevel : scene, out var value5) || !value5.TryGetValue(instance, out var value6) || value6.Count == 0; if (GameManager.OnInstanceJoined != null) { GameManager.OnInstanceJoined(instance, source); } if (TNHInstances.ContainsKey(instance)) { if (!TNHInstances[instance].playerIDs.Contains(ID)) { TNHInstances[instance].playerIDs.Add(ID); } if ((Object)(object)Mod.currentTNHUIManager != (Object)null) { Mod.InitTNHUIManager(TNHInstances[instance]); } else { Mod.currentTNHUIManager = Object.FindObjectOfType(); Mod.currentTNHSceneLoader = Object.FindObjectOfType(); if ((Object)(object)Mod.currentTNHUIManager != (Object)null) { Mod.InitTNHUIManager(TNHInstances[instance]); } } } if (sceneLoading) { controlOverride = instanceBringItems; firstPlayerInSceneInstance = instanceBringItems; } if (ThreadManager.host) { ServerSend.PlayerInstance(0, instance); } else { ClientSend.PlayerInstance(instance, sceneLoading); } playersPresent.Clear(); if (!nonSynchronizedScenes.ContainsKey(scene)) { foreach (KeyValuePair player in players) { if (player.Value.scene.Equals(scene) && player.Value.instance == instance) { playersPresent.Add(player.Key); if (ThreadManager.host && !sceneLoading) { if (Server.clientsWaitingUpDate.TryGetValue(player.Key, out var value7)) { value7.Add(0); } else { Server.clientsWaitingUpDate.Add(player.Key, new List { 0 }); } if (Server.loadingClientsWaitingFrom.TryGetValue(0, out var value8)) { value8.Add(player.Key); } else { Server.loadingClientsWaitingFrom.Add(0, new List { player.Key }); } ServerSend.RequestUpToDateObjects(player.Key, instantiateOnReceive: true, 0); } } UpdatePlayerHidden(player.Value); } } else { foreach (KeyValuePair player2 in players) { UpdatePlayerHidden(player2.Value); } } H3MPWristMenuSection.UpdateMaxHealth(scene, instance, -2, -1f); } public static void DestroyTrackedScripts(TrackedObjectData trackedObjectData) { if (trackedObjectData.children != null) { for (int i = 0; i < trackedObjectData.children.Count; i++) { DestroyTrackedScripts(trackedObjectData.children[i]); } } if ((Object)(object)trackedObjectData.physical != (Object)null) { Object.DestroyImmediate((Object)(object)trackedObjectData.physical); } } public static void ReassignSpectatorHost(int clientID, List debounce) { if (!Server.spectatorHostByController.TryGetValue(clientID, out var value)) { return; } List list = new List(); if (scene.Equals(Server.clients[clientID].player.scene) && instance == Server.clients[clientID].player.instance) { list.Add(0); } if (playersByInstanceByScene.TryGetValue(Server.clients[clientID].player.scene, out var value2) && value2.TryGetValue(Server.clients[clientID].player.instance, out var value3)) { list.AddRange(value3); } list.RemoveRange(0, debounce.Count); int num = -1; if (list.Count > 0) { num = Mod.GetBestPotentialObjectHost(clientID, forUs: false); } if (num == -1) { Server.spectatorHostByController.Remove(clientID); Server.spectatorHostControllers.Remove(value); if (spectatorHosts.Contains(value)) { Server.availableSpectatorHosts.Add(value); } if (value == ID) { spectatorHostControlledBy = -1; if (!sceneLoading) { if (!scene.Equals("MainMenu3")) { SteamVR_LoadLevel.Begin("MainMenu3", false, 0.5f, 0f, 0f, 0f, 1f); } } else { resetSpectatorHost = true; } } else { ServerSend.UnassignSpectatorHost(value); } } else { Server.spectatorHostByController.Remove(clientID); Server.spectatorHostControllers.Remove(value); Server.spectatorHostByController.Add(num, value); Server.spectatorHostControllers.Add(value, num); if (value == 0) { spectatorHostControlledBy = num; } else if (num == 0) { Mod.OnSpectatorHostReceivedInvoke(value, reassignment: true); } ServerSend.SpectatorHostAssignment(value, num, reassignment: true); } } public static bool GetTrackedObjectType(Transform t, out Type trackedObjectType) { List list = new List(); foreach (KeyValuePair> trackedObjectType2 in Mod.trackedObjectTypes) { for (int num = trackedObjectType2.Value.Count - 1; num >= 0; num--) { MethodInfo method = trackedObjectType2.Value[num].GetMethod("IsOfType", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if ((bool)method.Invoke(null, new object[1] { t })) { list.Add(trackedObjectType2.Value[num]); break; } } } if (list.Count == 0) { trackedObjectType = null; return false; } if (list.Count == 1) { trackedObjectType = list[0]; return true; } Type type = list[0]; for (int i = 0; i < list.Count; i++) { MethodInfo method2 = list[i].GetMethod("GetTypeOverrides", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if ((object)method2 != null && method2.Invoke(null, null) is Type[] array) { int num2 = 0; while (num2 < array.Length) { list.Remove(array[i]); i++; } } } if (list.Count == 0) { Mod.LogWarning(((Object)t).name + " had conflicting possible tracked types overriding each other. Tracked as: " + type.Name); trackedObjectType = type; } else if (list.Count == 1) { trackedObjectType = list[0]; } else { Mod.LogWarning(((Object)t).name + " had conflicting possible tracked types missing override. Tracked as: " + list[0].Name); trackedObjectType = list[0]; } return true; } public static bool IsControlled(Transform root, Type trackedObjectType) { MethodInfo method = trackedObjectType.GetMethod("IsControlled", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if ((object)method != null && (object)method.ReturnType == typeof(bool) && (object)method.GetParameters()[0].ParameterType == typeof(Transform)) { return (bool)method.Invoke(null, new object[1] { root }); } return false; } public static bool TrackSkipped(Transform root, Type trackedObjectType) { MethodInfo method = trackedObjectType.GetMethod("TrackSkipped", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if ((object)method != null && (object)method.ReturnType == typeof(bool) && (object)method.GetParameters()[0].ParameterType == typeof(Transform)) { return (bool)method.Invoke(null, new object[1] { root }); } return true; } public static void OnSceneLoadedVR(bool loading) { //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) if (loading) { Mod.LogInfo("Switching scene, from " + scene + " to " + LoadLevelBeginPatch.loadingLevel, debug: false); sceneLoading = true; instanceAtSceneLoadStart = instance; sceneAtSceneLoadStart = scene; if ((Object)(object)Mod.managerObject == (Object)null) { connectedAtLoadStart = false; return; } connectedAtLoadStart = true; giveControlOfDestroyed++; Mod.skipAllInstantiates++; if (playersByInstanceByScene.TryGetValue(scene, out var value)) { if (value.TryGetValue(instance, out var value2)) { playersAtLoadStart = value2; } else { playersAtLoadStart = null; } } else { playersAtLoadStart = null; } if (LoadLevelBeginPatch.loadingLevel.Equals("MainMenu3") && Mod.currentTNHInstance != null) { SetInstance(0); if (Mod.currentlyPlayingTNH) { Mod.currentTNHInstance.RemoveCurrentlyPlaying(send: true, ID, ThreadManager.host); Mod.currentlyPlayingTNH = false; } Mod.currentTNHInstance = null; Mod.TNHSpectating = false; if ((Object)(object)GM.CurrentPlayerBody != (Object)null) { GM.CurrentPlayerBody.SetPlayerIFF(GM.CurrentSceneSettings.DefaultPlayerIFF); if ((Object)(object)GM.CurrentPlayerBody.RightHand != (Object)null && (Object)(object)GM.CurrentPlayerBody.LeftHand != (Object)null) { ((Component)GM.CurrentPlayerBody.RightHand).GetComponent().Mode = (HandMode)0; ((Component)GM.CurrentPlayerBody.LeftHand).GetComponent().Mode = (HandMode)0; } } Mod.currentlyPlayingTNH = false; } if (LoadLevelBeginPatch.loadingLevel.Equals("TakeAndHold_Lobby_2") && Mod.currentTNHInstance != null) { Mod.TNHSpectating = false; if ((Object)(object)GM.CurrentPlayerBody != (Object)null) { GM.CurrentPlayerBody.SetPlayerIFF(GM.CurrentSceneSettings.DefaultPlayerIFF); if ((Object)(object)GM.CurrentPlayerBody.RightHand != (Object)null && (Object)(object)GM.CurrentPlayerBody.LeftHand != (Object)null) { ((Component)GM.CurrentPlayerBody.RightHand).GetComponent().Mode = (HandMode)0; ((Component)GM.CurrentPlayerBody.LeftHand).GetComponent().Mode = (HandMode)0; } } } if (playersByInstanceByScene.TryGetValue(LoadLevelBeginPatch.loadingLevel, out var value3)) { if (value3.TryGetValue(instance, out var value4)) { controlOverride = value4.Count == 0; firstPlayerInSceneInstance = controlOverride; } else { controlOverride = true; firstPlayerInSceneInstance = true; } } else { controlOverride = true; firstPlayerInSceneInstance = true; } ClearUnawoken(); if (GameManager.OnSceneLeft != null) { GameManager.OnSceneLeft(sceneAtSceneLoadStart, LoadLevelBeginPatch.loadingLevel); } return; } scene = LoadLevelBeginPatch.loadingLevel; sceneLoading = false; Mod.LogInfo("Arrived in scene: " + scene, debug: false); if ((Object)(object)Mod.managerObject != (Object)null) { if (ThreadManager.host) { ServerSend.PlayerScene(0, LoadLevelBeginPatch.loadingLevel); } else { ClientSend.PlayerScene(LoadLevelBeginPatch.loadingLevel); } if (connectedAtLoadStart) { Mod.skipAllInstantiates--; giveControlOfDestroyed--; } playersPresent.Clear(); if (!nonSynchronizedScenes.ContainsKey(scene)) { controlOverride = true; firstPlayerInSceneInstance = true; foreach (KeyValuePair player in players) { if (player.Value.scene.Equals(scene) && player.Value.instance == instance) { playersPresent.Add(player.Key); controlOverride = false; firstPlayerInSceneInstance = false; if (ThreadManager.host) { if (Server.clientsWaitingUpDate.TryGetValue(player.Key, out var value5)) { value5.Add(0); } else { Server.clientsWaitingUpDate.Add(player.Key, new List { 0 }); } if (Server.loadingClientsWaitingFrom.TryGetValue(0, out var value6)) { value6.Add(player.Key); } else { Server.loadingClientsWaitingFrom.Add(0, new List { player.Key }); } ServerSend.RequestUpToDateObjects(player.Key, instantiateOnReceive: true, 0); } } UpdatePlayerHidden(player.Value); } controlOverride &= connectedAtLoadStart; firstPlayerInSceneInstance &= connectedAtLoadStart; inPostSceneLoadTrack = true; SyncTrackedObjects(); inPostSceneLoadTrack = false; controlOverride = false; for (int i = 0; i < objects.Count; i++) { if ((Object)(object)objects[i].physical == (Object)null && !objects[i].awaitingInstantiation) { objects[i].awaitingInstantiation = true; AnvilManager.Run(objects[i].Instantiate()); } } if (Mod.spectatorHostWaitingForTNHSetup) { if (scene.Equals("TakeAndHold_Lobby_2")) { if (spectatorHostControlledBy != -1) { Mod.OnTNHHostClicked(); Mod.TNHOnDeathSpectate = Mod.TNHRequestHostOnDeathSpectate; Mod.OnTNHHostConfirmClicked(); if (ThreadManager.host) { ServerSend.TNHSpectatorHostReady(spectatorHostControlledBy, instance); } else { Mod.spectatorHostWaitingForTNHInstance = true; } } Mod.spectatorHostWaitingForTNHSetup = false; } else if (scene.Equals("MainMenu3")) { SteamVR_LoadLevel.Begin("TakeAndHold_Lobby_2", false, 0.5f, 0f, 0f, 0f, 1f); Mod.spectatorHostWaitingForTNHSetup = true; } else { SteamVR_LoadLevel.Begin("MainMenu3", false, 0.5f, 0f, 0f, 0f, 1f); Mod.spectatorHostWaitingForTNHSetup = true; } } } else { foreach (KeyValuePair player2 in players) { UpdatePlayerHidden(player2.Value); } } H3MPWristMenuSection.UpdateMaxHealth(scene, instance, -2, -1f); if (resetSpectatorHost) { if (!scene.Equals("MainMenu3")) { SteamVR_LoadLevel.Begin("MainMenu3", false, 0.5f, 0f, 0f, 0f, 1f); } resetSpectatorHost = false; } if (GameManager.OnSceneJoined != null) { GameManager.OnSceneJoined(scene, sceneAtSceneLoadStart); } TrackedGatlingGunData.firstInScene = true; for (int j = 0; j < retrack.Count; j++) { if ((Object)(object)retrack[j] != (Object)null) { SyncTrackedObjects(retrack[j].transform, controlEverything: true, null); } } retrack.Clear(); } Mod.LogInfo("Setting player prefab to " + playerPrefabID); SetPlayerPrefab(playerPrefabID); } public static void ClearUnawoken() { for (int num = objects.Count - 1; num >= 0; num--) { if (((Object)(object)objects[num].physical != (Object)null && !objects[num].physical.awoken) || ((Object)(object)objects[num].physical == (Object)null && !objects[num].awaitingInstantiation)) { objects[num].RemoveFromLocal(); } } } public static void ProcessPlayerDamage(float damageMult, bool head, Damage damage) { bool processDamage = true; if (GameManager.OnPlayerDamage != null) { GameManager.OnPlayerDamage(damageMult, damage, ref processDamage); } if (processDamage) { damage.Dam_TotalEnergetic *= damageMult; damage.Dam_TotalKinetic *= damageMult; if (head) { GM.CurrentPlayerBody.Hitboxes[0].Damage(damage); } else { GM.CurrentPlayerBody.Hitboxes[2].Damage(damage); } } } public static void DistributeAllControl(int clientID, int overrideController = -1, List types = null) { int num = ((overrideController == -1) ? Mod.GetBestPotentialObjectHost(clientID, forUs: false) : overrideController); for (int i = 0; i < Server.objects.Length; i++) { if (Server.objects[i] == null || (types != null && !types.Contains(Server.objects[i].GetType())) || Server.objects[i].controller != clientID) { continue; } TrackedObjectData trackedObjectData = Server.objects[i]; bool flag = num == -1; if (flag) { if ((Object)(object)trackedObjectData.physical == (Object)null) { ServerSend.DestroyObject(trackedObjectData.trackedID); Server.objects[trackedObjectData.trackedID] = null; if (Server.connectedClients.Count > 0) { if (Server.availableIndexBufferWaitingFor.TryGetValue(trackedObjectData.trackedID, out var value)) { for (int j = 0; j < Server.connectedClients.Count; j++) { if (!value.Contains(Server.connectedClients[j])) { value.Add(Server.connectedClients[j]); } } } else { Server.availableIndexBufferWaitingFor.Add(trackedObjectData.trackedID, new List(Server.connectedClients)); } for (int k = 0; k < Server.connectedClients.Count; k++) { if (Server.availableIndexBufferClients.TryGetValue(Server.connectedClients[k], out var value2)) { value2.Add(trackedObjectData.trackedID); continue; } Server.availableIndexBufferClients.Add(Server.connectedClients[k], new List { trackedObjectData.trackedID }); } if (Server.IDsToConfirm.TryGetValue(trackedObjectData.trackedID, out var value3)) { for (int l = 0; l < Server.connectedClients.Count; l++) { if (!value3.Contains(Server.connectedClients[l])) { value3.Add(Server.connectedClients[l]); } } } else { Server.IDsToConfirm.Add(trackedObjectData.trackedID, new List(Server.connectedClients)); } Mod.LogInfo("Added " + trackedObjectData.trackedID + " to ID buffer"); } else { Server.availableObjectIndices.Add(trackedObjectData.trackedID); } if (objectsByInstanceByScene.TryGetValue(trackedObjectData.scene, out var value4) && value4.TryGetValue(trackedObjectData.instance, out var value5)) { value5.Remove(trackedObjectData.trackedID); } trackedObjectData.awaitingInstantiation = false; if (clientID == ID) { trackedObjectData.RemoveFromLocal(); } } else { Object.Destroy((Object)(object)((Component)trackedObjectData.physical).gameObject); } } else if (clientID != 0 && num == 0) { trackedObjectData.localTrackedID = objects.Count; objects.Add(trackedObjectData); if ((Object)(object)trackedObjectData.physical == (Object)null && !sceneLoading) { if (trackedObjectData.scene.Equals(scene) && trackedObjectData.instance == instance) { if (!trackedObjectData.awaitingInstantiation) { trackedObjectData.awaitingInstantiation = true; AnvilManager.Run(trackedObjectData.Instantiate()); } } else { if ((Object)(object)trackedObjectData.physical != (Object)null) { Object.Destroy((Object)(object)((Component)trackedObjectData.physical).gameObject); } else { ServerSend.DestroyObject(trackedObjectData.trackedID); trackedObjectData.RemoveFromLocal(); Server.objects[trackedObjectData.trackedID] = null; if (Server.connectedClients.Count > 0) { if (Server.availableIndexBufferWaitingFor.TryGetValue(trackedObjectData.trackedID, out var value6)) { for (int m = 0; m < Server.connectedClients.Count; m++) { if (!value6.Contains(Server.connectedClients[m])) { value6.Add(Server.connectedClients[m]); } } } else { Server.availableIndexBufferWaitingFor.Add(trackedObjectData.trackedID, new List(Server.connectedClients)); } for (int n = 0; n < Server.connectedClients.Count; n++) { if (Server.availableIndexBufferClients.TryGetValue(Server.connectedClients[n], out var value7)) { value7.Add(trackedObjectData.trackedID); continue; } Server.availableIndexBufferClients.Add(Server.connectedClients[n], new List { trackedObjectData.trackedID }); } if (Server.IDsToConfirm.TryGetValue(trackedObjectData.trackedID, out var value8)) { for (int num2 = 0; num2 < Server.connectedClients.Count; num2++) { if (!value8.Contains(Server.connectedClients[num2])) { value8.Add(Server.connectedClients[num2]); } } } else { Server.IDsToConfirm.Add(trackedObjectData.trackedID, new List(Server.connectedClients)); } Mod.LogInfo("Added " + trackedObjectData.trackedID + " to ID buffer"); } else { Server.availableObjectIndices.Add(trackedObjectData.trackedID); } if (objectsByInstanceByScene.TryGetValue(trackedObjectData.scene, out var value9) && value9.TryGetValue(trackedObjectData.instance, out var value10)) { value10.Remove(trackedObjectData.trackedID); } trackedObjectData.awaitingInstantiation = false; } flag = true; } } } if (!flag) { trackedObjectData.SetController(num); ServerSend.GiveObjectControl(trackedObjectData.trackedID, num, null); } } } public static void TakeAllPhysicalControl(bool destroyTrackedScript) { TrackedObjectData[] array = null; array = ((!ThreadManager.host) ? Client.objects : Server.objects); TrackedObjectData[] array2 = array; foreach (TrackedObjectData trackedObjectData in array2) { if (trackedObjectData != null && (Object)(object)trackedObjectData.physical != (Object)null) { trackedObjectData.controller = ID; if (destroyTrackedScript) { trackedObjectData.physical.skipFullDestroy = true; Object.Destroy((Object)(object)trackedObjectData.physical); } } } } public static void RaisePlayerBodyInit(FVRPlayerBody playerBody) { if (GameManager.OnPlayerBodyInit != null) { GameManager.OnPlayerBodyInit(playerBody); } } public static bool InSceneInit() { return SpawnVaultFileRoutinePatch.inInitSpawnVaultFileRoutine || AnvilPrefabSpawnPatch.inInitPrefabSpawn || inPostSceneLoadTrack || BrutPlacerPatch.inInitBrutPlacer; } } [BepInPlugin("VIP.TommySoucy.H3MP", "H3MP", "1.14.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Mod : BaseUnityPlugin { public delegate void CustomPacketHandler(int clientID, Packet packet); public delegate void CustomPacketHandlerReceivedDelegate(string ID, int index); public delegate void GenericCustomPacketReceivedDelegate(int clientID, string ID, Packet packet); public delegate void OnGetBestPotentialObjectHostDelegate(int currentController, bool forUs, bool hasWhiteList, List whiteList, string sceneOverride, int instanceOverride, ref int bestPotentialObjectHost); public delegate void OnRemovePlayerFromSpecificListsDelegate(PlayerManager player); public delegate void OnSpectatorHostReceivedDelegate(int host, ref bool confirmed); public delegate void OnSpectatorHostGiveUpDelegate(); public delegate void OnInstantiationTrackDelegate(GameObject gameObject); public delegate void OnConnectionDelegate(); public delegate void OnPlayerRemovedDelegate(PlayerManager player); public const string pluginGuid = "VIP.TommySoucy.H3MP"; public const string pluginName = "H3MP"; public const string pluginVersion = "1.14.0"; public static JObject config; public static GameObject TNHMenuPrefab; public static GameObject TNHStartEquipButtonPrefab; public static GameObject playerPrefab; public static GameObject keyboardPrefab; public static GameObject serverListPrefab; public static Material reticleFriendlyContactArrowMat; public static Material reticleFriendlyContactIconMat; public static Dictionary sosigWearableMap; public static string H3MPPath; public static GameObject glassPrefab; public static GameObject glassPFXPrefab; public static MatDef glassMatDef; public static AudioEvent glassShotEvent; public static AudioEvent glassThudHeadEvent; public static AudioEvent glassThudTailEvent; public static AudioEvent glassTotalMediumEvent; public static AudioEvent glassGroundShatterEvent; public static Dictionary distantShotSets; public static SosigSpeechSet defaultSosigSpeechSet; public static AudioEvent sosigAlertAlarm; public static Text mainStatusText; public static Text statusLocationText; public static Text statusPlayerCountText; public GameObject hostButton; public GameObject connectButton; public GameObject joinButton; public static GameObject TNHMenu; public static GameObject[] TNHMenuPages; public static Text TNHStatusText; public static GameObject TNHInstanceList; public static GameObject TNHInstancePrefab; public static GameObject TNHInstanceListScrollUpArrow; public static GameObject TNHInstanceListScrollDownArrow; public static Scrollbar TNHInstanceListScrollBar; public static GameObject TNHHostButton; public static GameObject TNHJoinButton; public static GameObject TNHLPJCheck; public static GameObject TNHHostOnDeathSpectateRadio; public static GameObject TNHHostOnDeathLeaveRadio; public static GameObject TNHHostConfirmButton; public static GameObject TNHHostCancelButton; public static GameObject TNHJoinCancelButton; public static GameObject TNHJoinInstanceCancelButton; public static GameObject TNHJoinOptionsCancelButton; public static GameObject TNHJoinOnDeathSpectateRadio; public static GameObject TNHJoinOnDeathLeaveRadio; public static GameObject TNHJoinConfirmButton; public static GameObject TNHPlayerList; public static GameObject TNHPlayerPrefab; public static GameObject TNHPlayerListScrollUpArrow; public static GameObject TNHPlayerListScrollDownArrow; public static Scrollbar TNHPlayerListScrollBar; public static GameObject TNHLPJCheckMark; public static GameObject TNHHostOnDeathSpectateCheckMark; public static GameObject TNHHostOnDeathLeaveCheckMark; public static GameObject TNHJoinOnDeathSpectateCheckMark; public static GameObject TNHJoinOnDeathLeaveCheckMark; public static GameObject TNHRequestHostButton; public static GameObject TNHRequestHostConfirmButton; public static GameObject TNHRequestHostCancelButton; public static GameObject TNHRequestHostWaitingCancelButton; public static GameObject TNHRequestHostOnDeathSpectateRadio; public static GameObject TNHRequestHostOnDeathLeaveRadio; public static GameObject TNHRequestHostOnDeathSpectateCheckMark; public static GameObject TNHRequestHostOnDeathLeaveCheckMark; public static Text TNHInstanceTitle; public static Mod modInstance; public static GameObject managerObject; public static int skipNextFires = 0; public static int skipAllInstantiates = 0; public static AudioEvent sosigFootstepAudioEvent; public static bool TNHMenuLPJ; public static bool TNHOnDeathSpectate; public static bool TNHRequestHostOnDeathSpectate; public static bool TNHSpectating; public static bool setLatestInstance; public static TNHInstance currentTNHInstance; public static bool currentlyPlayingTNH; public static Dictionary joinTNHInstances; public static Dictionary currentTNHInstancePlayers; public static TNH_UIManager currentTNHUIManager; public static TNH_LevelLoader currentTNHSceneLoader; public static bool waitingForTNHHost; public static int TNHHostedInstance; public static GameObject TNHStartEquipButton; public static Dictionary> trackedObjectTypes; public static Dictionary trackedObjectTypesByName; public static CustomPacketHandler[] customPacketHandlers = new CustomPacketHandler[10]; public static List availableCustomPacketIndices = new List { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; public static Dictionary registeredCustomPacketIDs = new Dictionary(); public static bool spectatorHostWaitingForTNHInstance; public static bool spectatorHostWaitingForTNHSetup; public static bool waitingForTNHGameStart; public static Scene DDOLScene; public static bool waitingForDebugCode; public static string debugCode; public static Vector3 TNHSpawnPoint; public static bool nullDriverControls; public static Vector3 nullDriverMovement = Vector3.zero; public static float defaultNullDriverMovementMultiplier = 0.2f; public static float defaultNullDriverRotationMultiplier = 0.4f; public static float nullDriverVerticalRot = 0f; public static float nullDriverHorzontalRot = 0f; public static int testCustomPacketID; public static event CustomPacketHandlerReceivedDelegate CustomPacketHandlerReceived; public static event GenericCustomPacketReceivedDelegate GenericCustomPacketReceived; public static event OnGetBestPotentialObjectHostDelegate OnGetBestPotentialObjectHost; public static event OnRemovePlayerFromSpecificListsDelegate OnRemovePlayerFromSpecificLists; public static event OnSpectatorHostReceivedDelegate OnSpectatorHostReceived; public static event OnSpectatorHostGiveUpDelegate OnSpectatorHostGiveUp; public static event OnInstantiationTrackDelegate OnInstantiationTrack; public static event OnConnectionDelegate OnConnection; public static event OnPlayerRemovedDelegate OnPlayerRemoved; private void Start() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"H3MP Started"); modInstance = this; Init(); } public static void Reset() { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) LogInfo("Mod reset called", debug: false); skipNextFires = 0; skipAllInstantiates = 0; TNHMenuLPJ = true; TNHOnDeathSpectate = true; TNHSpectating = false; if ((Object)(object)GM.CurrentPlayerBody != (Object)null) { SetPlayerIFFPatch.skip++; GM.CurrentPlayerBody.SetPlayerIFF(GM.CurrentSceneSettings.DefaultPlayerIFF); SetPlayerIFFPatch.skip--; if ((Object)(object)GM.CurrentPlayerBody.RightHand != (Object)null && (Object)(object)GM.CurrentPlayerBody.LeftHand != (Object)null) { ((Component)GM.CurrentPlayerBody.RightHand).GetComponent().Mode = (HandMode)0; ((Component)GM.CurrentPlayerBody.LeftHand).GetComponent().Mode = (HandMode)0; } } setLatestInstance = false; currentTNHInstance = null; currentlyPlayingTNH = false; customPacketHandlers = new CustomPacketHandler[10]; registeredCustomPacketIDs.Clear(); availableCustomPacketIndices = new List { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; spectatorHostWaitingForTNHSetup = false; Object.DestroyImmediate((Object)(object)managerObject); managerObject = null; } private void Update() { //IL_116c: Unknown result type (might be due to invalid IL or missing references) //IL_1171: Unknown result type (might be due to invalid IL or missing references) //IL_1184: Unknown result type (might be due to invalid IL or missing references) //IL_1193: Unknown result type (might be due to invalid IL or missing references) //IL_119d: Unknown result type (might be due to invalid IL or missing references) //IL_11a2: Unknown result type (might be due to invalid IL or missing references) //IL_11a7: Unknown result type (might be due to invalid IL or missing references) //IL_11bb: Unknown result type (might be due to invalid IL or missing references) //IL_11ca: Unknown result type (might be due to invalid IL or missing references) //IL_11d4: Unknown result type (might be due to invalid IL or missing references) //IL_11d9: Unknown result type (might be due to invalid IL or missing references) //IL_11de: Unknown result type (might be due to invalid IL or missing references) //IL_11f2: Unknown result type (might be due to invalid IL or missing references) //IL_1201: Unknown result type (might be due to invalid IL or missing references) //IL_120b: Unknown result type (might be due to invalid IL or missing references) //IL_1210: Unknown result type (might be due to invalid IL or missing references) //IL_1215: Unknown result type (might be due to invalid IL or missing references) //IL_1229: Unknown result type (might be due to invalid IL or missing references) //IL_1238: Unknown result type (might be due to invalid IL or missing references) //IL_1242: Unknown result type (might be due to invalid IL or missing references) //IL_1247: Unknown result type (might be due to invalid IL or missing references) //IL_124c: Unknown result type (might be due to invalid IL or missing references) //IL_08f7: Unknown result type (might be due to invalid IL or missing references) //IL_0906: Unknown result type (might be due to invalid IL or missing references) //IL_0910: Unknown result type (might be due to invalid IL or missing references) //IL_0915: Unknown result type (might be due to invalid IL or missing references) //IL_091a: Unknown result type (might be due to invalid IL or missing references) //IL_0947: Unknown result type (might be due to invalid IL or missing references) //IL_0956: Unknown result type (might be due to invalid IL or missing references) //IL_095b: Unknown result type (might be due to invalid IL or missing references) //IL_0960: Unknown result type (might be due to invalid IL or missing references) //IL_0e91: Unknown result type (might be due to invalid IL or missing references) //IL_0e98: Expected O, but got Unknown //IL_0ece: Unknown result type (might be due to invalid IL or missing references) //IL_0edc: Expected O, but got Unknown //IL_0ef5: Unknown result type (might be due to invalid IL or missing references) //IL_0f57: Unknown result type (might be due to invalid IL or missing references) //IL_0f62: Unknown result type (might be due to invalid IL or missing references) //IL_0f69: Expected O, but got Unknown //IL_0f69: Unknown result type (might be due to invalid IL or missing references) //IL_0f70: Expected O, but got Unknown //IL_1040: Unknown result type (might be due to invalid IL or missing references) //IL_1047: Expected O, but got Unknown //IL_1047: Unknown result type (might be due to invalid IL or missing references) //IL_104e: Expected O, but got Unknown //IL_1260: Unknown result type (might be due to invalid IL or missing references) //IL_126f: Unknown result type (might be due to invalid IL or missing references) //IL_1279: Unknown result type (might be due to invalid IL or missing references) //IL_127e: Unknown result type (might be due to invalid IL or missing references) //IL_1283: Unknown result type (might be due to invalid IL or missing references) //IL_0cd5: Unknown result type (might be due to invalid IL or missing references) //IL_0cda: Unknown result type (might be due to invalid IL or missing references) //IL_0cdf: Unknown result type (might be due to invalid IL or missing references) //IL_0ce4: Unknown result type (might be due to invalid IL or missing references) //IL_0cfa: Unknown result type (might be due to invalid IL or missing references) //IL_0d04: Unknown result type (might be due to invalid IL or missing references) //IL_0d06: Unknown result type (might be due to invalid IL or missing references) //IL_0d0b: Unknown result type (might be due to invalid IL or missing references) //IL_0d20: Unknown result type (might be due to invalid IL or missing references) //IL_0d22: Unknown result type (might be due to invalid IL or missing references) //IL_12ce: Unknown result type (might be due to invalid IL or missing references) //IL_12d8: Unknown result type (might be due to invalid IL or missing references) //IL_12dd: Unknown result type (might be due to invalid IL or missing references) //IL_129a: Unknown result type (might be due to invalid IL or missing references) //IL_12a9: Unknown result type (might be due to invalid IL or missing references) //IL_12b3: Unknown result type (might be due to invalid IL or missing references) //IL_12b8: Unknown result type (might be due to invalid IL or missing references) //IL_12bd: Unknown result type (might be due to invalid IL or missing references) //IL_12fa: Unknown result type (might be due to invalid IL or missing references) //IL_1304: Unknown result type (might be due to invalid IL or missing references) //IL_1309: Unknown result type (might be due to invalid IL or missing references) //IL_1419: Unknown result type (might be due to invalid IL or missing references) //IL_142f: Unknown result type (might be due to invalid IL or missing references) //IL_1434: Unknown result type (might be due to invalid IL or missing references) //IL_1439: Unknown result type (might be due to invalid IL or missing references) //IL_159e: Unknown result type (might be due to invalid IL or missing references) //IL_15a3: Unknown result type (might be due to invalid IL or missing references) if (waitingForDebugCode) { if (Input.GetKeyDown((KeyCode)256)) { debugCode += "0"; LogInfo("DebugCode: " + debugCode); } else if (Input.GetKeyDown((KeyCode)257)) { debugCode += "1"; LogInfo("DebugCode: " + debugCode); } else if (Input.GetKeyDown((KeyCode)258)) { debugCode += "2"; LogInfo("DebugCode: " + debugCode); } else if (Input.GetKeyDown((KeyCode)259)) { debugCode += "3"; LogInfo("DebugCode: " + debugCode); } else if (Input.GetKeyDown((KeyCode)260)) { debugCode += "4"; LogInfo("DebugCode: " + debugCode); } else if (Input.GetKeyDown((KeyCode)261)) { debugCode += "5"; LogInfo("DebugCode: " + debugCode); } else if (Input.GetKeyDown((KeyCode)262)) { debugCode += "6"; LogInfo("DebugCode: " + debugCode); } else if (Input.GetKeyDown((KeyCode)263)) { debugCode += "7"; LogInfo("DebugCode: " + debugCode); } else if (Input.GetKeyDown((KeyCode)264)) { debugCode += "8"; LogInfo("DebugCode: " + debugCode); } else if (Input.GetKeyDown((KeyCode)265)) { debugCode += "9"; LogInfo("DebugCode: " + debugCode); } } if (Input.GetKeyDown((KeyCode)292)) { waitingForDebugCode = !waitingForDebugCode; if (waitingForDebugCode) { debugCode = string.Empty; } else { LogInfo("Activating DebugCode: " + debugCode); if (debugCode != string.Empty && int.TryParse(debugCode, out var result)) { switch (result) { case 0: LogInfo("\tDebug: Start hosting"); OnHostClicked(); break; case 1: LogInfo("\tDebug: Connect"); OnConnectClicked(null); break; case 2: LogInfo("\tDebug: Load config"); LoadConfig(); break; case 3: LogInfo("\tDebug: Disconnect/Close server"); if ((Object)(object)managerObject != (Object)null) { if (ThreadManager.host) { Server.Close(); } else { Client.singleton.Disconnect(sendToServer: true, 0); } } break; case 4: LogInfo("\tDebug: Load to main menu"); SteamVR_LoadLevel.Begin("MainMenu3", false, 0.5f, 0f, 0f, 0f, 1f); break; case 5: LogInfo("\tDebug: Load to proving grounds"); SteamVR_LoadLevel.Begin("ProvingGround", false, 0.5f, 0f, 0f, 0f, 1f); break; case 6: { LogInfo("\tDebug: Build sosig wearable map"); Dictionary dictionary = new Dictionary(); foreach (KeyValuePair item in IM.OD) { LogInfo("Checking " + item.Key); GameObject val9 = null; try { val9 = ((AnvilAsset)item.Value).GetGameObject(); } catch (Exception) { LogError("There was an error trying to retrieve prefab with ID: " + item.Key); continue; } try { SosigWearable component = val9.GetComponent(); if ((Object)(object)component != (Object)null) { if (dictionary.ContainsKey(((Object)val9).name)) { LogWarning("Sosig wearable with name: " + ((Object)val9).name + " is already in the map with value: " + dictionary[((Object)val9).name] + " and wewanted to add value: " + item.Key); } else { dictionary.Add(((Object)val9).name, item.Key); LogWarning("\tAdded"); } } } catch (Exception ex2) { LogError("There was an error trying to check if prefab with ID: " + item.Key + " is wearable or adding it to the list: " + ex2.Message + "\n" + ex2.StackTrace); } } LogInfo("\tGot wearables, writing..."); JObject val10 = JObject.FromObject((object)dictionary); File.WriteAllText(H3MPPath + "/SosigWearableMap.json", ((object)val10).ToString()); LogInfo("\tNew wearables map written"); break; } case 7: LogInfo("\tDebug: Load to TNH lobby"); SteamVR_LoadLevel.Begin("TakeAndHold_Lobby_2", false, 0.5f, 0f, 0f, 0f, 1f); break; case 8: LogInfo("\tDebug: Join first TNH instance"); if (currentTNHInstance == null) { OnTNHJoinClicked(); OnTNHJoinConfirmClicked(); OnTNHInstanceClicked(1); } break; case 9: LogInfo("\tDebug: Create new TNH instance"); if (currentTNHInstance == null) { OnTNHHostClicked(); OnTNHHostConfirmClicked(); } break; case 10: LogInfo("\tDebug: Begin TNH hold"); GM.TNH_Manager.m_curHoldPoint.m_systemNode.m_hasActivated = true; GM.TNH_Manager.m_curHoldPoint.m_systemNode.m_hasInitiatedHold = true; GM.TNH_Manager.m_curHoldPoint.BeginHoldChallenge(); break; case 11: LogInfo("\tDebug: Trigger first scene loader we can find in the scene"); Object.FindObjectOfType().LoadMG(); break; case 12: { LogInfo("\tDebug: Write PatchHashes"); string destFileName = H3MPPath + "/PatchHashes" + DateTimeOffset.Now.ToString().Replace("/", ".").Replace(":", ".") + ".json"; File.Copy(H3MPPath + "/PatchHashes.json", destFileName); LogWarning("Writing new hashes to file!"); File.WriteAllText(H3MPPath + "/PatchHashes.json", ((object)JObject.FromObject((object)PatchController.hashes)).ToString()); break; } case 13: LogInfo("\tDebug: Load to friendly 45"); SteamVR_LoadLevel.Begin("Friendly45_New", false, 0.5f, 0f, 0f, 0f, 1f); break; case 14: { LogInfo("\tDebug: Send packet with size > MTU"); using (Packet packet = new Packet(ThreadManager.host ? 170 : 164)) { byte[] value = new byte[2048]; packet.Write(value); if (ThreadManager.host) { ServerSend.SendTCPDataToAll(packet); } else { ClientSend.SendTCPData(packet); } } break; } case 15: { LogInfo("\tDebug: Spawning items"); GameObject gameObject = ((AnvilAsset)IM.OD["ModulAR300LowerFDEdupe"]).GetGameObject(); Object.Instantiate(gameObject, GM.CurrentPlayerBody.Head.position + GM.CurrentPlayerBody.Head.forward * 0.5f, Quaternion.identity); GameObject gameObject2 = ((AnvilAsset)IM.OD["AR15UpperM4FDE"]).GetGameObject(); Object.Instantiate(gameObject2, GM.CurrentPlayerBody.Head.position + GM.CurrentPlayerBody.Head.forward, Quaternion.identity); break; } case 16: LogInfo("\tDebug: Dumping item IDs"); foreach (KeyValuePair item2 in IM.OD) { LogInfo(item2.Key); } break; case 17: nullDriverControls = !nullDriverControls; LogInfo("\tDebug: Null driver controls: " + nullDriverControls); if (nullDriverControls) { nullDriverVerticalRot = 0f; nullDriverHorzontalRot = 0f; } break; case 18: LogInfo("\tDebug: Sub domain h3mp.tommysoucy.vip resolved to: " + Dns.GetHostAddresses("h3mp.tommysoucy.vip")[0].ToString()); break; case 19: LogInfo("\tDebug: Load to grillhouse"); SteamVR_LoadLevel.Begin("Grillhouse_2Story", false, 0.5f, 0f, 0f, 0f, 1f); break; case 20: LogInfo("\tDebug: Spawn SMG AutoMeater"); SpawnItem("Turburgert_SMG"); break; case 21: LogInfo("\tDebug: Spawn Flak AutoMeater"); SpawnItem("Turburgert_Flak"); break; case 22: LogInfo("\tDebug: Spawn Flamethrower AutoMeater"); SpawnItem("Turburgert_Flamethrower"); break; case 23: LogInfo("\tDebug: Spawn MachineGun AutoMeater"); SpawnItem("Turburgert_MachineGun"); break; case 24: LogInfo("\tDebug: Spawn Suppression AutoMeater"); SpawnItem("Turburgert_Suppression"); break; case 25: LogInfo("\tDebug: Spawn blue MF AutoMeater"); SpawnItem("TurburgertMFBlue"); break; case 26: LogInfo("\tDebug: Spawn red MF AutoMeater"); SpawnItem("TurburgertMFRed"); break; case 27: LogInfo("\tDebug: Load to SamplerPlatter"); SteamVR_LoadLevel.Begin("SamplerPlatter", false, 0.5f, 0f, 0f, 0f, 1f); break; case 28: { LogInfo("\tDebug: Register test custom packet"); int value3; if (ThreadManager.host) { if (registeredCustomPacketIDs.TryGetValue("TestCustomPacketID", out var value2)) { testCustomPacketID = value2; } else { testCustomPacketID = Server.RegisterCustomPacketType("TestCustomPacketID"); } customPacketHandlers[testCustomPacketID] = TestCustomPacketIDServerHandler; } else if (registeredCustomPacketIDs.TryGetValue("TestCustomPacketID", out value3)) { testCustomPacketID = value3; customPacketHandlers[testCustomPacketID] = TestCustomPacketIDClientHandler; } else { ClientSend.RegisterCustomPacketType("TestCustomPacketID"); CustomPacketHandlerReceived += TestCustomPacketIDReceived; } break; } case 29: LogInfo("\tDebug: Send test custom packet"); if (ThreadManager.host) { using Packet packet2 = new Packet(testCustomPacketID); ServerSend.SendTCPDataToAll(packet2, custom: true); } else { using Packet packet3 = new Packet(testCustomPacketID); ClientSend.SendTCPData(packet3, custom: true); } break; case 30: LogInfo("\tDebug: Toggle server list"); if ((Object)(object)ServerListController.instance == (Object)null) { Object.Instantiate(serverListPrefab); Vector3 val8 = Vector3.ProjectOnPlane(GM.CurrentPlayerBody.Head.forward, Vector3.up); ((Component)ServerListController.instance).transform.position = GM.CurrentPlayerBody.Head.position + 2f * val8; ((Component)ServerListController.instance).transform.rotation = Quaternion.LookRotation(val8); } else { Object.Destroy((Object)(object)((Component)ServerListController.instance).gameObject); } break; case 31: LogInfo("\tDebug: Server list, host"); if ((Object)(object)ServerListController.instance != (Object)null) { ServerListController.instance.OnHostClicked(); ServerListController.instance.hostServerName.text = "Debug server"; ServerListController.instance.hostLimit.text = "5"; ServerListController.instance.hostUsername.text = "Debug host"; ServerListController.instance.hostPort.text = "7863"; ServerListController.instance.OnHostConfirmClicked(); } break; case 32: LogInfo("\tDebug: Server list, join first host"); if ((Object)(object)ServerListController.instance != (Object)null) { ((UnityEvent)((Component)ServerListController.instance.main.transform.GetChild(2).GetChild(1).GetChild(1)).GetComponent