Decompiled source of Fraxalotls HD Mod Pack v0.1.1
Lethal Company Mod - HD/BepInEx/plugins/BiggerLobby.dll
Decompiled 11 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BiggerLobby.Models; using BiggerLobby.Patches; using BiggerLobby.UI; using Dissonance.Audio.Playback; using GameNetcodeStuff; using HarmonyLib; using LC_API.BundleAPI; using LC_API.ServerAPI; using Microsoft.CodeAnalysis; using Steamworks; using Steamworks.Data; using TMPro; using Unity.Netcode; using UnityEngine; using UnityEngine.Audio; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("BiggerLobby")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Increase the max players to 50 in Lethal Company")] [assembly: AssemblyFileVersion("2.6.0.0")] [assembly: AssemblyInformationalVersion("2.6.0")] [assembly: AssemblyProduct("BiggerLobby")] [assembly: AssemblyTitle("BiggerLobby")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.6.0.0")] [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.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; } } [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; } } } namespace BiggerLobby { public static class Helper { public static T[] ResizeArray<T>(T[] oldArray, int newSize) { if (oldArray.Length >= newSize) { return oldArray; } T[] array = new T[newSize]; oldArray.CopyTo(array, 0); return array; } public static void ResizeList<T>(this List<T> list, int size, T element = default(T)) { int count = list.Count; if (size < count) { list.RemoveRange(size, count - size); } else if (size > count) { if (size > list.Capacity) { list.Capacity = size; } list.AddRange(Enumerable.Repeat(element, size - count)); } } } [BepInPlugin("BiggerLobby", "BiggerLobby", "2.6.0")] public class Plugin : BaseUnityPlugin { public static Plugin Instance; public static bool oldhastime; public static int MaxPlayers = 16; public static bool instantiating; public static NetworkObject[] PlayerObjects = (NetworkObject[])(object)new NetworkObject[0]; public static Harmony _harmony; public static Harmony _harmony2; public static ConfigEntry<int>? _LoudnessMultiplier; public static bool Initialized = false; public static IDictionary<uint, NetworkObject> CustomNetObjects = new Dictionary<uint, NetworkObject>(); private void Awake() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Expected O, but got Unknown //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Expected O, but got Unknown Instance = this; _LoudnessMultiplier = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Player loudness", 1, "Default player loudness"); _harmony = new Harmony("BiggerLobby"); _harmony2 = new Harmony("BiggerLobbyA"); _harmony.PatchAll(typeof(NonGamePatches)); _harmony.PatchAll(typeof(NonGamePatches.InternalPatches)); _harmony.PatchAll(typeof(NonGamePatches.InternalPatches2)); CustomNetObjects.Clear(); _harmony2.PatchAll(typeof(InternalPatch3)); _harmony2.PatchAll(typeof(ListSizeTranspilers)); _harmony2.PatchAll(typeof(PlayerObjects)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"BiggerLobby loaded"); BundleLoader.OnLoadedAssets = (OnLoadedAssetsDelegate)Delegate.Combine((Delegate?)(object)BundleLoader.OnLoadedAssets, (Delegate?)new OnLoadedAssetsDelegate(OnLoaded)); } private void Start() { Initialize(); } private void OnDestroy() { Initialize(); } private void Initialize() { if (!Initialized) { Initialized = true; ModdedServer.SetServerModdedOnly(); } } private void OnLoaded() { Object.op_Implicit((Object)(object)BundleLoader.GetLoadedAsset<AudioMixer>("assets/diagetic.mixer")); } public static int GetPlayerCount() { return MaxPlayers; } public static int GetPlayerCountMinusOne() { return MaxPlayers - 1; } public static PlayerControllerB[] GetRealPlayerScripts(StartOfRound startOfRound) { if ((Object)(object)startOfRound == (Object)null || startOfRound.allPlayerScripts == null) { return (PlayerControllerB[])(object)new PlayerControllerB[0]; } return startOfRound.allPlayerScripts.Where((PlayerControllerB x) => x.isPlayerDead || x.isPlayerControlled).ToArray(); } } public static class PluginInfo { public const string PLUGIN_GUID = "BiggerLobby"; public const string PLUGIN_NAME = "BiggerLobby"; public const string PLUGIN_VERSION = "2.6.0"; } } namespace BiggerLobby.UI { public class ExpandedStatsUI : MonoBehaviour { private bool _initialized; private bool _debugStatsUI; private static StatsUIReferences? _statsUIReferences; private PlayerStatsList _fourPlayersList; private PlayerStatsList _eightPlayersList; private PlayerStatsList _moreThanEightPlayersList; private List<GameObject> _moreThanEightPlayersPages = new List<GameObject>(); public int UpperPlayerLimit = 40; public float SecondsPanelVisible = 8.5f; private Sprite FourPlayerStatBoxes; private Sprite EightPlayerStatBoxes; private void Start() { if (!_initialized) { if (_debugStatsUI) { DebugStats(); } SetupFourPlayerSlots(); SetupEightPlayerSlots(); SetupMoreThanEightPlayersSlots(); EightPlayerStatBoxes = _statsUIReferences.StatsBoxesThin; FourPlayerStatBoxes = ((Component)((Component)this).transform.GetChild(1)).GetComponent<Image>().sprite; ((Component)this).transform.GetChild(2).Find("AllDead").SetAsLastSibling(); _initialized = true; } } private void DebugStats() { ((Behaviour)((Component)this).gameObject.GetComponent<Animator>()).enabled = false; ((Component)((Component)this).transform.GetChild(0)).GetComponent<CanvasGroup>().alpha = 1f; ((Component)((Component)this).transform.GetChild(1)).GetComponent<CanvasGroup>().alpha = 1f; ((Component)((Component)this).transform.GetChild(2)).GetComponent<CanvasGroup>().alpha = 1f; ((Component)((Component)this).transform.GetChild(2).Find("AllDead")).gameObject.SetActive(false); } private void SetupFourPlayerSlots() { _fourPlayersList = new PlayerStatsList(CreateTransformAtParentOrigin("FourPlayersList", ((Component)this).transform.GetChild(2))); for (int i = 0; i < 4; i++) { Transform val = ((Component)this).transform.GetChild(2).Find($"PlayerSlot{i + 1}"); val.SetParent(_fourPlayersList.transform); _fourPlayersList.AddPlayerSlotTransform(val); } } private void SetupEightPlayerSlots() { _eightPlayersList = new PlayerStatsList(CreateTransformAtParentOrigin("EightPlayersList", ((Component)this).transform.GetChild(2))); List<Transform> playerSlots = SetupEightPlayerPage(_eightPlayersList.transform); _eightPlayersList.AddPlayerSlotTransforms(playerSlots); } private void SetupMoreThanEightPlayersSlots() { _moreThanEightPlayersList = new PlayerStatsList(CreateTransformAtParentOrigin("MoreThanEightPlayersList", ((Component)this).transform.GetChild(2))); int num = (int)Math.Ceiling((float)UpperPlayerLimit / 8f); for (int i = 0; i < num; i++) { Transform val = CreateTransformAtParentOrigin($"Page{i}", _moreThanEightPlayersList.transform); _moreThanEightPlayersPages.Add(((Component)val).gameObject); List<Transform> playerSlots = SetupEightPlayerPage(val); _moreThanEightPlayersList.AddPlayerSlotTransforms(playerSlots); if (i != 0) { ((Component)val).gameObject.SetActive(false); } } } private List<Transform> SetupEightPlayerPage(Transform parent) { //IL_002c: 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_0049: Unknown result type (might be due to invalid IL or missing references) List<Transform> list = new List<Transform>(); for (int i = 0; i < 8; i++) { Transform val = Object.Instantiate<Transform>(_fourPlayersList.transform.GetChild(0), parent, true); SetupPlayerSlot(val); val.localPosition = new Vector3(val.localPosition.x, -26.1f * (float)i, val.localPosition.z); list.Add(val); } return list; } private void SetupPlayerSlot(Transform playerSlot) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI component = ((Component)playerSlot.Find("Notes")).GetComponent<TextMeshProUGUI>(); TextMeshProUGUI component2 = ((Component)playerSlot.GetChild(0)).GetComponent<TextMeshProUGUI>(); RectTransform component3 = ((Component)component2).GetComponent<RectTransform>(); Image component4 = ((Component)playerSlot.GetChild(1)).GetComponent<Image>(); RectTransform component5 = ((Component)component4).GetComponent<RectTransform>(); ((TMP_Text)component).text = "* Most lazy employee\n* Most paranoid employee\n* Sustained the most injuries"; ((TMP_Text)component).fontSize = 9f; ((TMP_Text)component2).text = "CrazyDude12WW"; ((Transform)component3).localPosition = new Vector3(((Transform)component3).localPosition.x, 101.5f, ((Transform)component3).localPosition.z); component4.sprite = _statsUIReferences.CheckmarkThin; component5.sizeDelta = new Vector2(component5.sizeDelta.x, 31.235f); ((Transform)component5).localPosition = new Vector3(((Transform)component5).localPosition.x, 101.5f, ((Transform)component5).localPosition.z); } private Transform CreateTransformAtParentOrigin(string name, Transform parent) { //IL_0001: 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_001e: 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) Transform transform = new GameObject(name).transform; transform.SetParent(parent); transform.localPosition = Vector3.zero; transform.localRotation = Quaternion.identity; transform.localScale = Vector3.one; return transform; } public void LoadStatsUIBundle() { AssetBundle obj = AssetBundle.LoadFromFile(Path.Join((ReadOnlySpan<char>)Path.GetDirectoryName(((BaseUnityPlugin)Plugin.Instance).Info.Location), (ReadOnlySpan<char>)"statsuireferences")); _statsUIReferences = obj.LoadAsset<GameObject>("assets/prefabs/statsuireferences.prefab").GetComponent<StatsUIReferences>(); obj.Unload(false); } public PlayerStatsList GetStatsListFromPlayerCount(int playerCount) { _fourPlayersList.gameObject.SetActive(false); _eightPlayersList.gameObject.SetActive(false); _moreThanEightPlayersList.gameObject.SetActive(false); PlayerStatsList playerStatsList = _fourPlayersList; if (playerCount > 8) { playerStatsList = _moreThanEightPlayersList; } else if (playerCount > 4) { playerStatsList = _eightPlayersList; } SetupStatsList(playerStatsList, playerCount); return playerStatsList; } private void SetupStatsList(PlayerStatsList playerStatsList, int playerCount) { playerStatsList.gameObject.SetActive(true); ((Component)((Component)this).transform.GetChild(1)).GetComponent<Image>().sprite = ((playerCount <= 4) ? FourPlayerStatBoxes : EightPlayerStatBoxes); if (playerCount > 8) { ((MonoBehaviour)this).StartCoroutine(PaginatePlayers(playerCount)); } for (int i = 0; i < playerStatsList.Names.Count; i++) { ((TMP_Text)playerStatsList.Names[i]).text = ""; ((TMP_Text)playerStatsList.Notes[i]).text = ""; ((Behaviour)playerStatsList.States[i]).enabled = false; } } private IEnumerator PaginatePlayers(int playerCount) { int maxPageCount = (int)Math.Ceiling((float)playerCount / 8f); float pageDuration = SecondsPanelVisible / (float)maxPageCount; foreach (GameObject moreThanEightPlayersPage in _moreThanEightPlayersPages) { moreThanEightPlayersPage.SetActive(false); } for (int i = 0; i < maxPageCount; i++) { _moreThanEightPlayersPages[i].SetActive(true); if (i > 0) { _moreThanEightPlayersPages[i - 1].SetActive(false); } yield return (object)new WaitForSeconds(pageDuration); } } public static ExpandedStatsUI GetFromAnimator(Animator endgameStatsAnimator) { ExpandedStatsUI result = default(ExpandedStatsUI); if (((Component)endgameStatsAnimator).TryGetComponent<ExpandedStatsUI>(ref result)) { return result; } ExpandedStatsUI expandedStatsUI = ((Component)endgameStatsAnimator).gameObject.AddComponent<ExpandedStatsUI>(); if ((Object)(object)_statsUIReferences == (Object)null) { expandedStatsUI.LoadStatsUIBundle(); } return expandedStatsUI; } public static Sprite? GetReplacementCheckmark() { return _statsUIReferences?.CheckmarkThin; } } } namespace BiggerLobby.Patches { [HarmonyPatch(typeof(HUDManager))] internal class InternalPatch3 { private static MethodInfo TargetMethod() { return typeof(HUDManager).GetMethod("AddChatMessage", BindingFlags.Instance | BindingFlags.NonPublic); } [HarmonyPrefix] private static void Prefix(HUDManager __instance, string chatMessage, string nameOfUserWhoTyped = "") { if (!(__instance.lastChatMessage == chatMessage)) { __instance.lastChatMessage = chatMessage; __instance.PingHUDElement(__instance.Chat, 4f, 1f, 0.2f); if (__instance.ChatMessageHistory.Count >= 4) { ((TMP_Text)__instance.chatText).text.Remove(0, __instance.ChatMessageHistory[0].Length); __instance.ChatMessageHistory.Remove(__instance.ChatMessageHistory[0]); } StringBuilder stringBuilder = new StringBuilder(chatMessage); for (int i = 1; i < StartOfRound.Instance.allPlayerScripts.Length; i++) { stringBuilder.Replace("[playerNum" + i + "]", StartOfRound.Instance.allPlayerScripts[i].playerUsername); } stringBuilder.Replace("bizzlemip", "<color=#008282>bizzlemip</color>"); chatMessage = stringBuilder.ToString(); nameOfUserWhoTyped = nameOfUserWhoTyped.Replace("bizzlemip", "<color=#008282>bizzlemip</color>"); string item = ((!string.IsNullOrEmpty(nameOfUserWhoTyped)) ? ("<color=#FF0000>" + nameOfUserWhoTyped + "</color>: <color=#FFFF00>'" + chatMessage + "'</color>") : ("<color=#7069ff>" + chatMessage + "</color>")); __instance.ChatMessageHistory.Add(item); ((TMP_Text)__instance.chatText).text = ""; for (int j = 0; j < __instance.ChatMessageHistory.Count; j++) { TextMeshProUGUI chatText = __instance.chatText; ((TMP_Text)chatText).text = ((TMP_Text)chatText).text + "\n" + __instance.ChatMessageHistory[j]; } } } } [HarmonyPatch] public class ListSizeTranspilers { private static MethodInfo _playerCountMethod = AccessTools.Method(typeof(Plugin), "GetPlayerCount", (Type[])null, (Type[])null); private static MethodInfo _playerCountMinusOneMethod = AccessTools.Method(typeof(Plugin), "GetPlayerCountMinusOne", (Type[])null, (Type[])null); private static MethodInfo _realPlayerScriptsMethod = AccessTools.Method(typeof(Plugin), "GetRealPlayerScripts", (Type[])null, (Type[])null); private static void CheckAndReplace(List<CodeInstruction> codes, int index) { if (codes[index].opcode == OpCodes.Ldc_I4_4) { codes[index].opcode = OpCodes.Call; codes[index].operand = _playerCountMethod; } } [HarmonyPatch(typeof(HUDManager), "SyncAllPlayerLevelsServerRpc", new Type[] { })] [HarmonyPatch(typeof(DressGirlAI), "ChoosePlayerToHaunt")] [HarmonyPatch(typeof(CrawlerAI), "Start")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> SyncLevelsRpc(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Newarr) { CheckAndReplace(list, i - 1); } } return list.AsEnumerable(); } [HarmonyPatch(typeof(PlayerControllerB), "SendNewPlayerValuesServerRpc")] [HarmonyPatch(typeof(StartOfRound), "SyncShipUnlockablesClientRpc")] [HarmonyPatch(typeof(DressGirlAI), "ChoosePlayerToHaunt")] [HarmonyPatch(typeof(EnemyAI), "GetClosestPlayer")] [HarmonyPatch(typeof(SpringManAI), "DoAIInterval")] [HarmonyPatch(typeof(SpringManAI), "Update")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> SendNewPlayerValuesServerRpc(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Blt) { CheckAndReplace(list, i - 1); } } return list.AsEnumerable(); } [HarmonyPatch(typeof(QuickMenuManager), "ConfirmKickUserFromServer")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> ConfirmKickUserFromServer(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Ldc_I4_3) { list[i].opcode = OpCodes.Call; list[i].operand = _playerCountMinusOneMethod; Debug.Log((object)"Kick Fix Applied"); break; } } return list.AsEnumerable(); } [HarmonyPatch(typeof(HUDManager), "FillEndGameStats")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> FillEndGameStatsPatch(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Ldfld && list[i].operand is FieldInfo fieldInfo && fieldInfo.Name == "allPlayerScripts") { list[i].opcode = OpCodes.Call; list[i].operand = _realPlayerScriptsMethod; } } return list.Where((CodeInstruction x) => x.opcode != OpCodes.Nop).AsEnumerable(); } [HarmonyPatch(typeof(StartOfRound), "SyncShipUnlockablesServerRpc")] [HarmonyPatch(typeof(StartOfRound), "OnClientConnect")] [HarmonyPatch(typeof(PlayerControllerB), "SpectateNextPlayer")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> SyncShipUnlockablesServerRpc(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Ldc_I4_4) { list[i].opcode = OpCodes.Call; list[i].operand = _playerCountMethod; } } return list.AsEnumerable(); } } [HarmonyPatch] public class NonGamePatches { [HarmonyPatch(typeof(GameNetworkManager))] internal class InternalPatches { private static MethodInfo TargetMethod() { return typeof(GameNetworkManager).GetMethod("ConnectionApproval", BindingFlags.Instance | BindingFlags.NonPublic); } [HarmonyPrefix] private static bool PostFix(GameNetworkManager __instance, ConnectionApprovalRequest request, ConnectionApprovalResponse response) { //IL_000a: 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_004d: 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) Debug.Log((object)("Connection approval callback! Game version of client request: " + Encoding.ASCII.GetString(request.Payload).ToString())); Debug.Log((object)$"Joining client id: {request.ClientNetworkId}; Local/host client id: {NetworkManager.Singleton.LocalClientId}"); if (request.ClientNetworkId == NetworkManager.Singleton.LocalClientId) { Debug.Log((object)"Stopped connection approval callback, as the client in question was the host!"); return false; } bool flag = !__instance.disallowConnection; if (flag) { string @string = Encoding.ASCII.GetString(request.Payload); string[] array = @string.Split(","); if (string.IsNullOrEmpty(@string)) { response.Reason = "Unknown; please verify your game files."; flag = false; } else if (__instance.gameHasStarted) { response.Reason = "Game has already started!"; flag = false; } else if (__instance.gameVersionNum.ToString() != array[0]) { response.Reason = $"Game version mismatch! Their version: {__instance.gameVersionNum}. Your version: {array[0]}"; flag = false; } else if (!__instance.disableSteam && ((Object)(object)StartOfRound.Instance == (Object)null || array.Length < 2 || StartOfRound.Instance.KickedClientIds.Contains((ulong)Convert.ToInt64(array[1])))) { response.Reason = "You cannot rejoin after being kicked."; flag = false; } else if (!@string.Contains("BiggerLobbyVersion2.5.0")) { response.Reason = "You need to have <color=#008282>BiggerLobby V2.5.0</color> to join this server!"; flag = false; } } else { response.Reason = "The host was not accepting connections."; } Debug.Log((object)$"Approved connection?: {flag}. Connected players #: {__instance.connectedPlayers}"); Debug.Log((object)("Disapproval reason: " + response.Reason)); response.CreatePlayerObject = false; response.Approved = flag; response.Pending = false; return false; } } [HarmonyPatch(typeof(GameNetworkManager))] internal class InternalPatches2 { private static MethodInfo TargetMethod() { return typeof(GameNetworkManager).GetMethod("SteamMatchmaking_OnLobbyCreated", BindingFlags.Instance | BindingFlags.NonPublic); } [HarmonyPostfix] private static void PostFix(GameNetworkManager __instance, Result result, Lobby lobby) { ((Lobby)(ref lobby)).SetData("name", "[BiggerLobby]" + ((Lobby)(ref lobby)).GetData("name")); } } private static PropertyInfo _playbackVolumeProperty = typeof(VoicePlayback).GetInterface("IVoicePlaybackInternal").GetProperty("PlaybackVolume"); private static FieldInfo _lobbyListField = AccessTools.Field(typeof(SteamLobbyManager), "currentLobbyList"); [HarmonyPatch(typeof(StartOfRound), "UpdatePlayerVoiceEffects")] [HarmonyPrefix] public static void UpdatePlayerVoiceEffects(StartOfRound __instance) { if ((Object)(object)GameNetworkManager.Instance == (Object)null || (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null) { return; } typeof(StartOfRound).GetField("updatePlayerVoiceInterval", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, 2f); PlayerControllerB val = ((!GameNetworkManager.Instance.localPlayerController.isPlayerDead || !((Object)(object)GameNetworkManager.Instance.localPlayerController.spectatedPlayerScript != (Object)null)) ? GameNetworkManager.Instance.localPlayerController : GameNetworkManager.Instance.localPlayerController.spectatedPlayerScript); for (int i = 0; i < __instance.allPlayerScripts.Length; i++) { PlayerControllerB val2 = __instance.allPlayerScripts[i]; if ((!val2.isPlayerControlled && !val2.isPlayerDead) || (Object)(object)val2 == (Object)(object)GameNetworkManager.Instance.localPlayerController) { continue; } if (val2.voicePlayerState == null || val2.currentVoiceChatIngameSettings._playerState == null || (Object)(object)val2.currentVoiceChatAudioSource == (Object)null) { __instance.RefreshPlayerVoicePlaybackObjects(); if (val2.voicePlayerState == null || (Object)(object)val2.currentVoiceChatAudioSource == (Object)null) { Debug.Log((object)$"Was not able to access voice chat object for player #{i}; {val2.voicePlayerState == null}; {(Object)(object)val2.currentVoiceChatAudioSource == (Object)null}"); continue; } } AudioSource currentVoiceChatAudioSource = __instance.allPlayerScripts[i].currentVoiceChatAudioSource; bool flag = val2.speakingToWalkieTalkie && val.holdingWalkieTalkie && (Object)(object)val2 != (Object)(object)val; if (val2.isPlayerDead) { ((Behaviour)((Component)currentVoiceChatAudioSource).GetComponent<AudioLowPassFilter>()).enabled = false; ((Behaviour)((Component)currentVoiceChatAudioSource).GetComponent<AudioHighPassFilter>()).enabled = false; currentVoiceChatAudioSource.panStereo = 0f; SoundManager.Instance.playerVoicePitchTargets[val2.playerClientId] = 1f; SoundManager.Instance.SetPlayerPitch(1f, (int)val2.playerClientId); if (GameNetworkManager.Instance.localPlayerController.isPlayerDead) { currentVoiceChatAudioSource.spatialBlend = 0f; val2.currentVoiceChatIngameSettings.set2D = true; if ((Object)(object)val2.currentVoiceChatIngameSettings != (Object)null && (Object)(object)val2.currentVoiceChatIngameSettings._playbackComponent != (Object)null) { _playbackVolumeProperty.SetValue(val2.currentVoiceChatIngameSettings._playbackComponent, Mathf.Clamp((SoundManager.Instance.playerVoiceVolumes[i] + 1f) * (float)(2 * Plugin._LoudnessMultiplier.Value), 0f, 1f)); } } else { currentVoiceChatAudioSource.spatialBlend = 1f; val2.currentVoiceChatIngameSettings.set2D = false; if ((Object)(object)val2.currentVoiceChatIngameSettings != (Object)null && (Object)(object)val2.currentVoiceChatIngameSettings._playbackComponent != (Object)null) { _playbackVolumeProperty.SetValue(val2.currentVoiceChatIngameSettings._playbackComponent, 0); } } continue; } AudioLowPassFilter component = ((Component)currentVoiceChatAudioSource).GetComponent<AudioLowPassFilter>(); OccludeAudio component2 = ((Component)currentVoiceChatAudioSource).GetComponent<OccludeAudio>(); ((Behaviour)component).enabled = true; component2.overridingLowPass = flag || __instance.allPlayerScripts[i].voiceMuffledByEnemy; ((Behaviour)((Component)currentVoiceChatAudioSource).GetComponent<AudioHighPassFilter>()).enabled = flag; if (!flag) { currentVoiceChatAudioSource.spatialBlend = 1f; val2.currentVoiceChatIngameSettings.set2D = false; currentVoiceChatAudioSource.bypassListenerEffects = false; currentVoiceChatAudioSource.bypassEffects = false; currentVoiceChatAudioSource.outputAudioMixerGroup = SoundManager.Instance.playerVoiceMixers[val2.playerClientId]; component.lowpassResonanceQ = 1f; } else { currentVoiceChatAudioSource.spatialBlend = 0f; val2.currentVoiceChatIngameSettings.set2D = true; if (GameNetworkManager.Instance.localPlayerController.isPlayerDead) { currentVoiceChatAudioSource.panStereo = 0f; currentVoiceChatAudioSource.outputAudioMixerGroup = SoundManager.Instance.playerVoiceMixers[val2.playerClientId]; currentVoiceChatAudioSource.bypassListenerEffects = false; currentVoiceChatAudioSource.bypassEffects = false; } else { currentVoiceChatAudioSource.panStereo = 0.4f; currentVoiceChatAudioSource.bypassListenerEffects = false; currentVoiceChatAudioSource.bypassEffects = false; currentVoiceChatAudioSource.outputAudioMixerGroup = SoundManager.Instance.playerVoiceMixers[val2.playerClientId]; } component2.lowPassOverride = 4000f; component.lowpassResonanceQ = 3f; } if ((Object)(object)val2.currentVoiceChatIngameSettings != (Object)null && (Object)(object)val2.currentVoiceChatIngameSettings._playbackComponent != (Object)null) { _playbackVolumeProperty.SetValue(val2.currentVoiceChatIngameSettings._playbackComponent, Mathf.Clamp((SoundManager.Instance.playerVoiceVolumes[i] + 1f) * (float)(2 * Plugin._LoudnessMultiplier.Value), 0f, 1f)); } } } [HarmonyPatch(typeof(StartOfRound), "Awake")] [HarmonyPrefix] public static void ResizeLists(ref StartOfRound __instance) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown __instance.allPlayerObjects = Helper.ResizeArray(__instance.allPlayerObjects, Plugin.MaxPlayers); __instance.allPlayerScripts = Helper.ResizeArray(__instance.allPlayerScripts, Plugin.MaxPlayers); __instance.gameStats.allPlayerStats = Helper.ResizeArray(__instance.gameStats.allPlayerStats, Plugin.MaxPlayers); __instance.playerSpawnPositions = Helper.ResizeArray(__instance.playerSpawnPositions, Plugin.MaxPlayers); for (int i = 4; i < Plugin.MaxPlayers; i++) { __instance.gameStats.allPlayerStats[i] = new PlayerStats(); __instance.playerSpawnPositions[i] = __instance.playerSpawnPositions[0]; } } [HarmonyPatch(typeof(HUDManager), "Awake")] [HarmonyPrefix] public static void ResizeHUD(ref HUDManager __instance) { ExpandedStatsUI.GetFromAnimator(__instance.endgameStatsAnimator); } [HarmonyPatch(typeof(SoundManager), "SetPlayerVoiceFilters")] [HarmonyPrefix] public static bool SetPlayerVoiceFilters(ref SoundManager __instance) { for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++) { if (!StartOfRound.Instance.allPlayerScripts[i].isPlayerControlled && !StartOfRound.Instance.allPlayerScripts[i].isPlayerDead) { __instance.playerVoicePitches[i] = 1f; __instance.playerVoiceVolumes[i] = 1f; continue; } if (StartOfRound.Instance.allPlayerScripts[i].voicePlayerState != null) { typeof(VoicePlayback).GetProperty("Dissonance.Audio.Playback.IVoicePlaybackInternal.PlaybackVolume", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(StartOfRound.Instance.allPlayerScripts[i].currentVoiceChatIngameSettings._playbackComponent, Mathf.Clamp((SoundManager.Instance.playerVoiceVolumes[i] + 1f) * (float)(2 * Plugin._LoudnessMultiplier.Value), 0f, 1f)); } if (Mathf.Abs(__instance.playerVoicePitches[i] - __instance.playerVoicePitchTargets[i]) > 0.025f) { __instance.playerVoicePitches[i] = Mathf.Lerp(__instance.playerVoicePitches[i], __instance.playerVoicePitchTargets[i], 3f * Time.deltaTime); } else if (__instance.playerVoicePitches[i] != __instance.playerVoicePitchTargets[i]) { __instance.playerVoicePitches[i] = __instance.playerVoicePitchTargets[i]; } } return false; } [HarmonyPatch(typeof(MenuManager), "OnEnable")] [HarmonyPostfix] public static void CustomMenu(ref MenuManager __instance) { //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: 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_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) GameObject p2; RectTransform rt9 = default(RectTransform); if (!__instance.isInitScene) { GameObject gameObject = ((Component)__instance.HostSettingsOptionsNormal.transform.parent.parent).gameObject; Component component = gameObject.GetComponent(typeof(RectTransform)); RectTransform val = (RectTransform)(object)((component is RectTransform) ? component : null); p2 = ((Component)gameObject.transform.Find("PrivatePublicDescription")).gameObject; Component component2 = p2.GetComponent(typeof(RectTransform)); RectTransform val2 = (RectTransform)(object)((component2 is RectTransform) ? component2 : null); Component component3 = ((Component)__instance.HostSettingsOptionsNormal.transform.Find("EnterAName")).gameObject.GetComponent(typeof(RectTransform)); RectTransform val3 = (RectTransform)(object)((component3 is RectTransform) ? component3 : null); GameObject gameObject2 = ((Component)__instance.HostSettingsOptionsNormal.transform.Find("ServerNameField")).gameObject; Component component4 = gameObject2.GetComponent(typeof(RectTransform)); RectTransform val4 = (RectTransform)(object)((component4 is RectTransform) ? component4 : null); Component component5 = ((Component)gameObject.transform.Find("Confirm")).gameObject.GetComponent(typeof(RectTransform)); RectTransform val5 = (RectTransform)(object)((component5 is RectTransform) ? component5 : null); Component component6 = ((Component)gameObject.transform.Find("Back")).gameObject.GetComponent(typeof(RectTransform)); RectTransform val6 = (RectTransform)(object)((component6 is RectTransform) ? component6 : null); Component component7 = ((Component)__instance.HostSettingsOptionsNormal.transform.Find("Public")).gameObject.GetComponent(typeof(RectTransform)); RectTransform val7 = (RectTransform)(object)((component7 is RectTransform) ? component7 : null); Component component8 = ((Component)__instance.HostSettingsOptionsNormal.transform.Find("Private")).gameObject.GetComponent(typeof(RectTransform)); Component obj = ((component8 is RectTransform) ? component8 : null); GameObject val8 = Object.Instantiate<GameObject>(gameObject2, gameObject2.transform.parent); ref RectTransform reference = ref rt9; Component component9 = val8.GetComponent(typeof(RectTransform)); reference = (RectTransform)(object)((component9 is RectTransform) ? component9 : null); val.sizeDelta = new Vector2(val.sizeDelta.x, 200f); val2.anchoredPosition = new Vector2(val2.anchoredPosition.x, -50f); val3.anchoredPosition = new Vector2(val3.anchoredPosition.x, 40f); val4.anchoredPosition = new Vector2(val4.anchoredPosition.x, 55f); val5.anchoredPosition = new Vector2(val5.anchoredPosition.x, -60f); val6.anchoredPosition = new Vector2(val6.anchoredPosition.x, -85f); val7.anchoredPosition = new Vector2(val7.anchoredPosition.x, -23f); ((RectTransform)obj).anchoredPosition = new Vector2(((RectTransform)obj).anchoredPosition.x, -23f); rt9.anchoredPosition = new Vector2(rt9.anchoredPosition.x, 21f); ((Object)rt9).name = "ServerPlayersField"; ((Component)rt9).GetComponent<TMP_InputField>().contentType = (ContentType)2; ((TMP_Text)((Component)((Component)rt9).transform.Find("Text Area").Find("Placeholder")).gameObject.GetComponent<TextMeshProUGUI>()).text = "Max players (16)..."; ((Component)rt9).transform.parent = __instance.HostSettingsOptionsNormal.transform; ((UnityEvent<string>)(object)((Component)rt9).GetComponent<TMP_InputField>().onValueChanged).AddListener((UnityAction<string>)delegate { OnChange(); }); } void OnChange() { string text = Regex.Replace(((Component)rt9).GetComponent<TMP_InputField>().text, "[^0-9]", ""); Debug.Log((object)text); if (!int.TryParse(text, out var result)) { result = 16; } result = Math.Min(Math.Max(result, 4), 40); Debug.Log((object)result); if (result > 16) { ((TMP_Text)p2.GetComponent<TextMeshProUGUI>()).text = "Notice: High max player counts\nmay cause lag."; } else if (((TMP_Text)p2.GetComponent<TextMeshProUGUI>()).text == "Notice: High max player counts\nmay cause lag.") { ((TMP_Text)p2.GetComponent<TextMeshProUGUI>()).text = "yeah you should be good now lol"; } } } [HarmonyPatch(typeof(MenuManager), "StartHosting")] [HarmonyPrefix] public static bool StartHost(MenuManager __instance) { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) if (!GameNetworkManager.Instance.currentLobby.HasValue) { return true; } if (!int.TryParse(Regex.Replace(((TMP_Text)((Component)((Component)__instance.HostSettingsOptionsNormal.transform.Find("ServerPlayersField")).gameObject.transform.Find("Text Area").Find("Text")).gameObject.GetComponent<TextMeshProUGUI>()).text, "[^0-9]", ""), out var result)) { result = 16; } result = Math.Min(Math.Max(result, 4), 40); Lobby valueOrDefault = GameNetworkManager.Instance.currentLobby.GetValueOrDefault(); ((Lobby)(ref valueOrDefault)).SetData("MaxPlayers", result.ToString()); Debug.Log((object)$"SETTING MAX PLAYERS TO {result}!"); Plugin.MaxPlayers = result; if ((Object)(object)GameNetworkManager.Instance != (Object)null) { GameNetworkManager.Instance.maxAllowedPlayers = Plugin.MaxPlayers; } return true; } [HarmonyPatch(typeof(HUDManager), "FillEndGameStats")] [HarmonyPrefix] public static void FillEndGameStats(HUDManager __instance) { ExpandedStatsUI fromAnimator = ExpandedStatsUI.GetFromAnimator(__instance.endgameStatsAnimator); if (!((Object)(object)fromAnimator == (Object)null) && !((Object)(object)StartOfRound.Instance == (Object)null)) { PlayerStatsList statsListFromPlayerCount = fromAnimator.GetStatsListFromPlayerCount(Plugin.GetRealPlayerScripts(StartOfRound.Instance).Length); __instance.statsUIElements.playerNamesText = statsListFromPlayerCount.Names.ToArray(); __instance.statsUIElements.playerStates = statsListFromPlayerCount.States.ToArray(); __instance.statsUIElements.playerNotesText = statsListFromPlayerCount.Notes.ToArray(); Debug.Log((object)"Adding EXPANDED stats!"); } } [HarmonyPatch(typeof(HUDManager), "FillEndGameStats")] [HarmonyPostfix] public static void FillEndGameStatsPostfix(HUDManager __instance) { if ((Object)(object)StartOfRound.Instance == (Object)null || Plugin.GetRealPlayerScripts(StartOfRound.Instance).Length <= 4) { return; } TextMeshProUGUI[] playerNotesText = __instance.statsUIElements.playerNotesText; foreach (TextMeshProUGUI val in playerNotesText) { if (!(((TMP_Text)val).text == "")) { ((TMP_Text)val).text = ((TMP_Text)val).text.Replace("Notes:", "").Trim(); } } Sprite replacementCheckmark = ExpandedStatsUI.GetReplacementCheckmark(); if ((Object)(object)replacementCheckmark == (Object)null) { return; } Image[] playerStates = __instance.statsUIElements.playerStates; foreach (Image val2 in playerStates) { if (!((Object)(object)val2.sprite != (Object)(object)__instance.statsUIElements.aliveIcon)) { val2.sprite = replacementCheckmark; } } } [HarmonyPatch(typeof(GameNetworkManager), "StartHost")] [HarmonyPrefix] public static bool DoTheThe() { Plugin.CustomNetObjects.Clear(); return true; } [HarmonyPatch(typeof(GameNetworkManager), "StartClient")] [HarmonyPrefix] public static bool StartClient(GameNetworkManager __instance) { Plugin.CustomNetObjects.Clear(); return true; } [HarmonyPatch(typeof(MenuManager), "StartAClient")] [HarmonyPrefix] public static bool StartAClient() { Plugin.CustomNetObjects.Clear(); Debug.Log((object)"LanRunningggg!"); return true; } [HarmonyPatch(typeof(SteamLobbyManager), "loadLobbyListAndFilter")] [HarmonyPostfix] public static IEnumerator LoadLobbyListAndFilter(IEnumerator result, SteamLobbyManager __instance) { while (result.MoveNext()) { yield return result.Current; } Debug.Log((object)"Injecting BL playercounts into lobby list."); LobbySlot[] componentsInChildren = ((Component)__instance.levelListContainer).GetComponentsInChildren<LobbySlot>(true); foreach (LobbySlot val in componentsInChildren) { try { ((TMP_Text)val.LobbyName).text = ((TMP_Text)val.LobbyName).text.Replace("[BiggerLobby]", "[BL]"); if (!int.TryParse(((Lobby)(ref val.thisLobby)).GetData("MaxPlayers"), out var result2)) { result2 = 4; } ((TMP_Text)val.playerCount).text = ((TMP_Text)val.playerCount).text.Replace("/ 4", $"/ {result2}"); } catch (Exception ex) { Debug.LogWarning((object)"Exception while injecting BL lobby metadata:"); Debug.LogWarning((object)ex); } } } [HarmonyPatch(typeof(SteamMatchmaking), "CreateLobbyAsync")] [HarmonyPrefix] public static void SetMaxMembers(ref int maxMembers) { maxMembers = Plugin.MaxPlayers; } [HarmonyPatch(typeof(GameNetworkManager), "SetConnectionDataBeforeConnecting")] [HarmonyPrefix] public static bool SetConnectionDataBeforeConnecting(GameNetworkManager __instance) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) __instance.localClientWaitingForApproval = true; Debug.Log((object)("Game version: " + __instance.gameVersionNum)); if (__instance.disableSteam) { NetworkManager.Singleton.NetworkConfig.ConnectionData = Encoding.ASCII.GetBytes(__instance.gameVersionNum + ",BiggerLobbyVersion2.5.0"); } else { NetworkManager.Singleton.NetworkConfig.ConnectionData = Encoding.ASCII.GetBytes(__instance.gameVersionNum + "," + SteamId.op_Implicit(SteamClient.SteamId) + ",BiggerLobbyVersion2.5.0"); } return false; } [HarmonyPatch(typeof(GameNetworkManager), "LobbyDataIsJoinable")] [HarmonyPrefix] public static bool SkipLobbySizeCheck(ref GameNetworkManager __instance, ref bool __result, Lobby lobby) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) string data = ((Lobby)(ref lobby)).GetData("vers"); if (!int.TryParse(((Lobby)(ref lobby)).GetData("MaxPlayers"), out var result)) { result = 16; } result = Math.Min(Math.Max(result, 4), 40); if (((Lobby)(ref lobby)).MemberCount >= result || ((Lobby)(ref lobby)).MemberCount < 1) { Debug.Log((object)$"Lobby join denied! Too many members in lobby! {((Lobby)(ref lobby)).Id}"); Object.FindObjectOfType<MenuManager>().SetLoadingScreen(false, (RoomEnter)4, "The server is full!"); __result = false; return false; } if (data != __instance.gameVersionNum.ToString()) { Debug.Log((object)$"Lobby join denied! Attempted to join vers.{data} lobby id: {((Lobby)(ref lobby)).Id}"); Object.FindObjectOfType<MenuManager>().SetLoadingScreen(false, (RoomEnter)2, $"The server host is playing on version {data} while you are on version {__instance.gameVersionNum}."); __result = false; return false; } if (((Lobby)(ref lobby)).GetData("joinable") == "false") { Debug.Log((object)"Lobby join denied! Host lobby is not joinable"); Object.FindObjectOfType<MenuManager>().SetLoadingScreen(false, (RoomEnter)2, "The server host has already landed their ship, or they are still loading in."); __result = false; return false; } Plugin.MaxPlayers = result; Debug.Log((object)$"SETTING MAX PLAYERS TO {result}!"); if ((Object)(object)__instance != (Object)null) { __instance.maxAllowedPlayers = Plugin.MaxPlayers; } __result = true; return false; } } [HarmonyPatch] internal class PlayerObjects { private static StartOfRound startOfRound; private static bool instantiating; private static int nextClientId; private static PlayerControllerB referencePlayer; [HarmonyPatch(typeof(StartOfRound), "Awake")] [HarmonyPrefix] public static void ResizeLists(ref StartOfRound __instance) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown __instance.allPlayerObjects = Helper.ResizeArray(__instance.allPlayerObjects, Plugin.MaxPlayers); __instance.allPlayerScripts = Helper.ResizeArray(__instance.allPlayerScripts, Plugin.MaxPlayers); __instance.gameStats.allPlayerStats = Helper.ResizeArray(__instance.gameStats.allPlayerStats, Plugin.MaxPlayers); __instance.playerSpawnPositions = Helper.ResizeArray(__instance.playerSpawnPositions, Plugin.MaxPlayers); for (int i = 4; i < Plugin.MaxPlayers; i++) { __instance.gameStats.allPlayerStats[i] = new PlayerStats(); __instance.playerSpawnPositions[i] = __instance.playerSpawnPositions[0]; } } [HarmonyPatch(typeof(ForestGiantAI), "Start")] [HarmonyPrefix] public static bool ResizeLists2(ref ForestGiantAI __instance) { __instance.playerStealthMeters = Helper.ResizeArray(__instance.playerStealthMeters, Plugin.MaxPlayers); return true; } [HarmonyPatch(typeof(HUDManager), "Awake")] [HarmonyPostfix] public static void ResizeLists2(ref HUDManager __instance) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown __instance.playerLevels = Helper.ResizeArray(__instance.playerLevels, Plugin.MaxPlayers + 1); for (int i = 4; i < Plugin.MaxPlayers; i++) { __instance.playerLevels[i] = new PlayerLevel(); } } [HarmonyPatch(typeof(SoundManager), "Awake")] [HarmonyPostfix] public static void SoundWake(ref SoundManager __instance) { __instance.playerVoiceMixers = Helper.ResizeArray(__instance.playerVoiceMixers, Plugin.MaxPlayers); for (int i = 0; i < Plugin.MaxPlayers; i++) { __instance.playerVoiceMixers[i] = __instance.diageticMixer.outputAudioMixerGroup; } } [HarmonyPatch(typeof(SoundManager), "Start")] [HarmonyPostfix] public static void ResizeSoundManagerLists(ref SoundManager __instance) { __instance.playerVoicePitchLerpSpeed = new float[Plugin.MaxPlayers + 1]; __instance.playerVoicePitchTargets = new float[Plugin.MaxPlayers + 1]; __instance.playerVoiceVolumes = new float[Plugin.MaxPlayers + 1]; __instance.playerVoicePitches = new float[Plugin.MaxPlayers + 1]; for (int i = 1; i < Plugin.MaxPlayers + 1; i++) { __instance.playerVoicePitchLerpSpeed[i] = 3f; __instance.playerVoicePitchTargets[i] = 1f; __instance.playerVoicePitches[i] = 1f; __instance.playerVoiceVolumes[i] = 1f; } } [HarmonyPatch(typeof(EnemyAI), "EnableEnemyMesh")] [HarmonyPrefix] public static bool EnableEnemyMesh(EnemyAI __instance, bool enable, bool overrideDoNotSet = false) { int layer = ((!enable) ? 23 : 19); for (int i = 0; i < __instance.skinnedMeshRenderers.Length; i++) { if (Object.op_Implicit((Object)(object)__instance.skinnedMeshRenderers[i]) && (!((Component)__instance.skinnedMeshRenderers[i]).CompareTag("DoNotSet") || overrideDoNotSet)) { ((Component)__instance.skinnedMeshRenderers[i]).gameObject.layer = layer; } } for (int j = 0; j < __instance.meshRenderers.Length; j++) { if (Object.op_Implicit((Object)(object)__instance.meshRenderers[j]) && (!((Component)__instance.meshRenderers[j]).CompareTag("DoNotSet") || overrideDoNotSet)) { ((Component)__instance.meshRenderers[j]).gameObject.layer = layer; } } return false; } [HarmonyPatch(typeof(ShipTeleporter), "Awake")] [HarmonyPrefix] public static bool Awake2(ShipTeleporter __instance) { int[] array = new int[Plugin.MaxPlayers]; for (int i = 0; i < Plugin.MaxPlayers; i++) { array[i] = -1; } typeof(ShipTeleporter).GetField("playersBeingTeleported", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, array); __instance.buttonTrigger.interactable = false; typeof(ShipTeleporter).GetField("cooldownTime", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, __instance.cooldownAmount); return false; } [HarmonyPatch(typeof(NetworkSceneManager), "PopulateScenePlacedObjects")] [HarmonyPrefix] public static bool AddPlayers(NetworkSceneManager __instance) { //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) startOfRound = StartOfRound.Instance; if ((Object)(object)startOfRound.allPlayerObjects[Plugin.MaxPlayers - 1] != (Object)null) { return true; } referencePlayer = startOfRound.allPlayerObjects[0].GetComponent<PlayerControllerB>(); GameObject playerPrefab = startOfRound.playerPrefab; Transform transform = ((Component)startOfRound.playersContainer).transform; FieldInfo field = typeof(NetworkObject).GetField("GlobalObjectIdHash", BindingFlags.Instance | BindingFlags.NonPublic); PropertyInfo property = typeof(NetworkObject).GetProperty("NetworkObjectId", BindingFlags.Instance | BindingFlags.Public); typeof(NetworkSceneManager).GetField("ScenePlacedObjects", BindingFlags.Instance | BindingFlags.NonPublic); instantiating = true; typeof(NetworkSpawnManager).GetMethod("SpawnNetworkObjectLocally", BindingFlags.Instance | BindingFlags.NonPublic, null, CallingConventions.Any, new Type[6] { typeof(NetworkObject), typeof(ulong), typeof(bool), typeof(bool), typeof(ulong), typeof(bool) }, null); for (int i = 4; i < Plugin.MaxPlayers; i++) { nextClientId = i; GameObject val = Object.Instantiate<GameObject>(playerPrefab, transform); PlayerControllerB component = val.GetComponent<PlayerControllerB>(); NetworkObject component2 = val.GetComponent<NetworkObject>(); NetworkObject component3 = ((Component)val.transform.Find("PlayerPhysicsBox")).gameObject.GetComponent<NetworkObject>(); NetworkObject component4 = ((Component)val.transform.Find("ScavengerModel/metarig/ScavengerModelArmsOnly/metarig/spine.003/shoulder.R/arm.R_upper/arm.R_lower/hand.R/LocalItemHolder")).gameObject.GetComponent<NetworkObject>(); NetworkObject component5 = ((Component)val.transform.Find("ScavengerModel/metarig/spine/spine.001/spine.002/spine.003/shoulder.R/arm.R_upper/arm.R_lower/hand.R/ServerItemHolder")).gameObject.GetComponent<NetworkObject>(); component.TeleportPlayer(StartOfRound.Instance.notSpawnedPosition.position, false, 0f, false, true); startOfRound.allPlayerObjects[i] = val; startOfRound.allPlayerScripts[i] = component; uint num = (uint)(6942069 + i); ulong num2 = 6942069uL + (ulong)i; uint num3 = (uint)(123456789 + i); uint num4 = (uint)(987654321 + i); uint num5 = (uint)(124585949 + i); ulong num6 = 123456789uL + (ulong)i; ulong num7 = 987654321uL + (ulong)i; ulong num8 = 124585949uL + (ulong)i; Scene scene = ((Component)component2).gameObject.scene; _ = ((Scene)(ref scene)).handle; field.SetValue(component2, num); property.SetValue(component2, num2); field.SetValue(component3, num3); property.SetValue(component3, num6); field.SetValue(component4, num4); property.SetValue(component4, num7); field.SetValue(component5, num5); property.SetValue(component5, num8); ManualCameraRenderer[] array = Object.FindObjectsByType<ManualCameraRenderer>((FindObjectsInactive)1, (FindObjectsSortMode)0); for (int j = 0; j < array.Length; j++) { array[j].AddTransformAsTargetToRadar(((Component)component).transform, "Player #" + j, false); } } instantiating = false; return true; } [HarmonyPatch(typeof(QuickMenuManager), "AddUserToPlayerList")] [HarmonyPrefix] public static bool AddUserToPlayerList(QuickMenuManager __instance, ulong steamId, string playerName, int playerObjectId) { if (playerObjectId >= 0 && playerObjectId <= Plugin.MaxPlayers) { __instance.playerListSlots[playerObjectId].KickUserButton.SetActive(((NetworkBehaviour)StartOfRound.Instance).IsServer); __instance.playerListSlots[playerObjectId].slotContainer.SetActive(true); __instance.playerListSlots[playerObjectId].isConnected = true; __instance.playerListSlots[playerObjectId].playerSteamId = steamId; ((TMP_Text)__instance.playerListSlots[playerObjectId].usernameHeader).text = playerName.Replace("bizzlemip", "<color=#008282>bizzlemip</color>"); if ((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null) { __instance.playerListSlots[playerObjectId].volumeSliderContainer.SetActive(playerObjectId != (int)GameNetworkManager.Instance.localPlayerController.playerClientId); } } return false; } [HarmonyPatch(typeof(QuickMenuManager), "Update")] [HarmonyPrefix] private static bool Update(QuickMenuManager __instance) { for (int i = 0; i < __instance.playerListSlots.Length; i++) { if (__instance.playerListSlots[i].isConnected) { float num = __instance.playerListSlots[i].volumeSlider.value / __instance.playerListSlots[i].volumeSlider.maxValue; if (num == -1f) { SoundManager.Instance.playerVoiceVolumes[i] = -1f; } else { SoundManager.Instance.playerVoiceVolumes[i] = num; } } } return false; } [HarmonyPatch(typeof(QuickMenuManager), "Start")] [HarmonyPrefix] public static bool FixPlayerList(ref QuickMenuManager __instance) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0173: 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_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Expected O, but got Unknown //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Expected O, but got Unknown GameObject val = null; GameObject gameObject = ((Component)__instance.playerListPanel.transform.Find("Image")).gameObject; if (Object.op_Implicit((Object)(object)gameObject.transform.Find("Mask"))) { val = ((Component)gameObject.transform.Find("Mask")).gameObject; } GameObject val2 = new GameObject("Mask"); GameObject val3 = new GameObject("ScrollViewport"); GameObject val4 = new GameObject("BGCollision"); GameObject val5 = new GameObject("ScrollContent"); val2.transform.SetParent(gameObject.transform); val3.transform.SetParent(val2.transform); val4.transform.SetParent(val3.transform); val5.transform.SetParent(val3.transform); val2.transform.localScale = Vector3.one; val3.transform.localScale = Vector3.one; val5.transform.localScale = Vector3.one; val2.AddComponent<RectTransform>().sizeDelta = new Vector2(300f, 280f); val2.transform.localPosition = new Vector3(-10f, 110f, 0f); val3.transform.localPosition = new Vector3(0f, -10f, 0f); val5.AddComponent<RectTransform>().pivot = new Vector2(0.5f, 1f); val2.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 1f); val2.transform.localPosition = new Vector3(-10f, 110f, 0f); val2.AddComponent<RectMask2D>(); VerticalLayoutGroup val6 = val5.AddComponent<VerticalLayoutGroup>(); ContentSizeFitter obj = val5.AddComponent<ContentSizeFitter>(); ScrollRect obj2 = val3.AddComponent<ScrollRect>(); obj2.viewport = val3.AddComponent<RectTransform>(); obj2.content = val5.GetComponent<RectTransform>(); obj2.horizontal = false; Image val7 = val4.AddComponent<Image>(); val4.GetComponent<RectTransform>().anchorMin = new Vector2(0f, 0f); val4.GetComponent<RectTransform>().anchorMax = new Vector2(1f, 1f); ((Graphic)val7).color = new Color(255f, 255f, 255f, 0f); ((HorizontalOrVerticalLayoutGroup)val6).spacing = 50f; obj.horizontalFit = (FitMode)0; obj.verticalFit = (FitMode)2; __instance.playerListSlots = Helper.ResizeArray(__instance.playerListSlots, Plugin.MaxPlayers); for (int i = 0; i < Plugin.MaxPlayers; i++) { if (i < 4) { __instance.playerListSlots[i].slotContainer.transform.SetParent(val5.transform); continue; } PlayerListSlot val8 = new PlayerListSlot(); GameObject val9 = (val8.slotContainer = Object.Instantiate<GameObject>(__instance.playerListSlots[0].slotContainer)); val8.volumeSliderContainer = ((Component)val9.transform.Find("VoiceVolumeSlider")).gameObject; val8.KickUserButton = ((Component)val9.transform.Find("KickButton")).gameObject; QuickMenuManager yeahoriginal = __instance; int localI = i; ((UnityEvent)val8.KickUserButton.GetComponent<Button>().onClick).AddListener((UnityAction)delegate { yeahoriginal.KickUserFromServer(localI); }); val8.isConnected = false; val8.usernameHeader = ((Component)val9.transform.Find("PlayerNameButton").Find("PName")).gameObject.GetComponent<TextMeshProUGUI>(); val8.volumeSlider = ((Component)val9.transform.Find("VoiceVolumeSlider").Find("Slider")).gameObject.GetComponent<Slider>(); val8.playerSteamId = __instance.playerListSlots[0].playerSteamId; val9.transform.SetParent(val5.transform, false); __instance.playerListSlots[i] = val8; } if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } return true; } [HarmonyPatch(typeof(ManualCameraRenderer), "Awake")] [HarmonyPrefix] public static bool Mawake(ref ManualCameraRenderer __instance) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown for (int i = 0; i < 4; i++) { __instance.radarTargets.Add(new TransformAndName(((Component)StartOfRound.Instance.allPlayerScripts[i]).transform, StartOfRound.Instance.allPlayerScripts[i].playerUsername, false)); } __instance.targetTransformIndex = 0; __instance.targetedPlayer = StartOfRound.Instance.allPlayerScripts[0]; return false; } [HarmonyPatch(typeof(PlayerControllerB), "Awake")] [HarmonyPrefix] public static bool FixPlayerObject(ref PlayerControllerB __instance) { if (!instantiating) { return true; } ((Object)((Component)__instance).gameObject).name = $"ExtraPlayer{nextClientId}"; __instance.playerClientId = (ulong)nextClientId; __instance.actualClientId = (ulong)nextClientId; StartOfRound.Instance.allPlayerObjects[nextClientId] = ((Component)((Component)__instance).transform.parent).gameObject; StartOfRound.Instance.allPlayerScripts[nextClientId] = __instance; FieldInfo[] fields = typeof(PlayerControllerB).GetFields(); foreach (FieldInfo fieldInfo in fields) { object value = fieldInfo.GetValue(__instance); object value2 = fieldInfo.GetValue(referencePlayer); if (value == null && value2 != null) { fieldInfo.SetValue(__instance, value2); } } ((Behaviour)__instance).enabled = true; return true; } [HarmonyPatch(typeof(StartOfRound), "GetPlayerSpawnPosition")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> GetPlayerSpawnPosition(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); list[0].opcode = OpCodes.Ldc_I4_1; return list.AsEnumerable(); } } } namespace BiggerLobby.Models { public class PlayerStatsList { public Transform transform; public List<TextMeshProUGUI> Names = new List<TextMeshProUGUI>(); public List<Image> States = new List<Image>(); public List<TextMeshProUGUI> Notes = new List<TextMeshProUGUI>(); public GameObject gameObject => ((Component)transform).gameObject; public PlayerStatsList(Transform transform) { this.transform = transform; } public void AddPlayerSlotTransform(Transform playerSlot) { TextMeshProUGUI component = ((Component)playerSlot.GetChild(0)).GetComponent<TextMeshProUGUI>(); Image component2 = ((Component)playerSlot.GetChild(1)).GetComponent<Image>(); TextMeshProUGUI component3 = ((Component)playerSlot.Find("Notes")).GetComponent<TextMeshProUGUI>(); Names.Add(component); States.Add(component2); Notes.Add(component3); } public void AddPlayerSlotTransforms(List<Transform> playerSlots) { foreach (Transform playerSlot in playerSlots) { AddPlayerSlotTransform(playerSlot); } } } public enum StatsScreenType { FourPlayers, EightPlayers, MoreThanEightPlayers } public class StatsUIReferences : MonoBehaviour { public Sprite StatsBoxesThin; public Sprite StatsBoxesGradeOnly; public Sprite CheckmarkThin; public ScrollRect ThinScrollRect; } }
Lethal Company Mod - HD/BepInEx/plugins/FasterItemDropship.dll
Decompiled 11 months agousing System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("FasterItemDropship")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("Mod made by flipf17")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("FasterItemDropship")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("a5a250fd-b706-48b9-9be9-da360fd939dc")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace FasterItemDropship { public static class ConfigSettings { public static ConfigEntry<int> dropshipDeliveryTime; public static ConfigEntry<int> dropshipMaxStayDuration; public static ConfigEntry<int> dropshipLeaveAfterSecondsOpenDoors; public static void BindConfigSettings() { Plugin.Log("BindingConfigs"); dropshipDeliveryTime = ((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("FasterItemDropship", "DeliveryTime", 10, "How long it takes (in seconds) for the item dropship to arrive."); dropshipMaxStayDuration = ((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("FasterItemDropship", "MaxLandDuration", 40, "The max duration (in seconds) the item dropship will stay."); dropshipLeaveAfterSecondsOpenDoors = ((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("FasterItemDropship", "LeaveAfterSecondsOpenDoors", 3, "How long (in seconds) the item dropship will stay for after opening its doors."); } } [BepInPlugin("FlipMods.FasterItemDropship", "FasterItemDropship", "1.2.0")] public class Plugin : BaseUnityPlugin { private Harmony _harmony; public static Plugin instance; private void Awake() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown instance = this; ConfigSettings.BindConfigSettings(); _harmony = new Harmony("FasterItemDropship"); _harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"FasterItemDropship loaded"); } public static void Log(string message) { ((BaseUnityPlugin)instance).Logger.LogInfo((object)message); } } public static class PluginInfo { public const string PLUGIN_GUID = "FlipMods.FasterItemDropship"; public const string PLUGIN_NAME = "FasterItemDropship"; public const string PLUGIN_VERSION = "1.2.0"; } } namespace FasterItemDropship.Patches { [HarmonyPatch] internal class FasterItemDropshipPatcher { private static Terminal terminalScript; private static StartOfRound playersManager; private static List<int> itemsToDeliver; private static List<int> orderedItemsFromTerminal; [HarmonyPatch(typeof(ItemDropship), "Start")] [HarmonyPrefix] public static void InitializeDropship(ItemDropship __instance) { playersManager = Object.FindObjectOfType<StartOfRound>(); terminalScript = Object.FindObjectOfType<Terminal>(); itemsToDeliver = (List<int>)Traverse.Create((object)__instance).Field("itemsToDeliver").GetValue(); } [HarmonyPatch(typeof(Terminal), "Start")] [HarmonyPrefix] public static void InitializeTerminal(Terminal __instance) { orderedItemsFromTerminal = __instance.orderedItemsFromTerminal; } [HarmonyPatch(typeof(ItemDropship), "Update")] [HarmonyPrefix] public static void DropshipUpdate(ItemDropship __instance) { if (((NetworkBehaviour)__instance).IsServer && !__instance.deliveringOrder && terminalScript.orderedItemsFromTerminal.Count > 0 && !playersManager.shipHasLanded) { __instance.shipTimer += Time.deltaTime; } } [HarmonyPatch(typeof(ItemDropship), "Update")] private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Ldc_R4) { if ((float)list[i].operand == 20f) { list[i].operand = (float)ConfigSettings.dropshipMaxStayDuration.Value; } else if ((float)list[i].operand == 40f) { list[i].operand = (float)(ConfigSettings.dropshipMaxStayDuration.Value + ConfigSettings.dropshipDeliveryTime.Value); } else if ((float)list[i].operand == 30f) { list[i].operand = (float)ConfigSettings.dropshipMaxStayDuration.Value; break; } } } return list.AsEnumerable(); } [HarmonyPatch(typeof(ItemDropship), "OpenShipDoorsOnServer")] [HarmonyPostfix] public static void OnOpenShipDoors(ItemDropship __instance) { if (((NetworkBehaviour)__instance).IsServer) { __instance.shipTimer = Mathf.Max(__instance.shipTimer, (float)(ConfigSettings.dropshipMaxStayDuration.Value - ConfigSettings.dropshipLeaveAfterSecondsOpenDoors.Value)); } } [HarmonyPatch(typeof(ItemDropship), "ShipLandedAnimationEvent")] [HarmonyPrefix] public static void AddLateItemsServer(ItemDropship __instance) { if (((NetworkBehaviour)__instance).IsServer && __instance.shipLanded && !__instance.shipDoorsOpened) { while (orderedItemsFromTerminal.Count > 0 && itemsToDeliver.Count < 12) { itemsToDeliver.Add(orderedItemsFromTerminal[0]); orderedItemsFromTerminal.RemoveAt(0); } } } } }
Lethal Company Mod - HD/BepInEx/plugins/FlashlightToggle.dll
Decompiled 11 months agousing System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; [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("Control")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("My first plugin")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+0465852cfa101b431accf8b751972dc96a66f057")] [assembly: AssemblyProduct("Control")] [assembly: AssemblyTitle("Control")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [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; } } } namespace Control { public static class PluginInfo { public const string PLUGIN_GUID = "Control"; public const string PLUGIN_NAME = "Control"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace Flashlight { [BepInPlugin("rr.Flashlight", "Flashlight", "1.4.0")] public class Plugin : BaseUnityPlugin { private static string path = Application.persistentDataPath + "/flashlightbutton.txt"; internal static ManualLogSource logSource; private static InputActionAsset asset; private static string defaultkey = "/Keyboard/f"; private Harmony _harmony = new Harmony("Flashlight"); private void Awake() { _harmony.PatchAll(typeof(Plugin)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"------Flashlight done.------"); logSource = ((BaseUnityPlugin)this).Logger; } public static void setAsset(string thing) { asset = InputActionAsset.FromJson("\r\n {\r\n \"maps\" : [\r\n {\r\n \"name\" : \"Flashlight\",\r\n \"actions\": [\r\n {\"name\": \"togglef\", \"type\" : \"button\"}\r\n ],\r\n \"bindings\" : [\r\n {\"path\" : \"" + thing + "\", \"action\": \"togglef\"}\r\n ]\r\n }\r\n ]\r\n }"); } [HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")] [HarmonyPostfix] public static void ClearFlashlight(PlayerControllerB __instance) { __instance.pocketedFlashlight = null; } [HarmonyPatch(typeof(IngamePlayerSettings), "CompleteRebind")] [HarmonyPrefix] public static void SavingToFile(IngamePlayerSettings __instance) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (!(__instance.rebindingOperation.action.name != "togglef")) { File.WriteAllText(path, __instance.rebindingOperation.action.controls[0].path); string text = defaultkey; if (File.Exists(path)) { text = File.ReadAllText(path); } setAsset(text); } } [HarmonyPatch(typeof(KepRemapPanel), "LoadKeybindsUI")] [HarmonyPrefix] public static void Testing(KepRemapPanel __instance) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown string text = defaultkey; if (!File.Exists(path)) { File.WriteAllText(path, defaultkey); } else { text = File.ReadAllText(path); } for (int i = 0; i < __instance.remappableKeys.Count; i++) { if (__instance.remappableKeys[i].ControlName == "Flashlight") { return; } } RemappableKey val = new RemappableKey(); setAsset(text); InputActionReference currentInput = InputActionReference.Create(asset.FindAction("Flashlight/togglef", false)); val.ControlName = "Flashlight"; val.currentInput = currentInput; __instance.remappableKeys.Add(val); } [HarmonyPatch(typeof(PlayerControllerB), "Update")] [HarmonyPostfix] public static void ReadInput(PlayerControllerB __instance) { if (((!((NetworkBehaviour)__instance).IsOwner || !__instance.isPlayerControlled || (((NetworkBehaviour)__instance).IsServer && !__instance.isHostPlayerObject)) && !__instance.isTestingPlayer) || __instance.inTerminalMenu || __instance.isTypingChat || !Application.isFocused) { return; } if (__instance.currentlyHeldObjectServer is FlashlightItem && (Object)(object)__instance.currentlyHeldObjectServer != (Object)(object)__instance.pocketedFlashlight) { __instance.pocketedFlashlight = __instance.currentlyHeldObjectServer; } if ((Object)(object)__instance.pocketedFlashlight == (Object)null) { return; } string text = defaultkey; if (!File.Exists(path)) { File.WriteAllText(path, defaultkey); } else { text = File.ReadAllText(path); } if (!Object.op_Implicit((Object)(object)asset) || !asset.enabled) { setAsset(text); asset.Enable(); } if (!asset.FindAction("Flashlight/togglef", false).triggered || !(__instance.pocketedFlashlight is FlashlightItem) || !__instance.pocketedFlashlight.isHeld) { return; } try { __instance.pocketedFlashlight.UseItemOnClient(true); if (!(__instance.currentlyHeldObjectServer is FlashlightItem)) { GrabbableObject pocketedFlashlight = __instance.pocketedFlashlight; ((Behaviour)((FlashlightItem)((pocketedFlashlight is FlashlightItem) ? pocketedFlashlight : null)).flashlightBulbGlow).enabled = false; GrabbableObject pocketedFlashlight2 = __instance.pocketedFlashlight; ((Behaviour)((FlashlightItem)((pocketedFlashlight2 is FlashlightItem) ? pocketedFlashlight2 : null)).flashlightBulb).enabled = false; GrabbableObject pocketedFlashlight3 = __instance.pocketedFlashlight; if (((pocketedFlashlight3 is FlashlightItem) ? pocketedFlashlight3 : null).isBeingUsed) { ((Behaviour)__instance.helmetLight).enabled = true; GrabbableObject pocketedFlashlight4 = __instance.pocketedFlashlight; ((FlashlightItem)((pocketedFlashlight4 is FlashlightItem) ? pocketedFlashlight4 : null)).usingPlayerHelmetLight = true; GrabbableObject pocketedFlashlight5 = __instance.pocketedFlashlight; ((FlashlightItem)((pocketedFlashlight5 is FlashlightItem) ? pocketedFlashlight5 : null)).PocketFlashlightServerRpc(true); } else { ((Behaviour)__instance.helmetLight).enabled = false; GrabbableObject pocketedFlashlight6 = __instance.pocketedFlashlight; ((FlashlightItem)((pocketedFlashlight6 is FlashlightItem) ? pocketedFlashlight6 : null)).usingPlayerHelmetLight = false; GrabbableObject pocketedFlashlight7 = __instance.pocketedFlashlight; ((FlashlightItem)((pocketedFlashlight7 is FlashlightItem) ? pocketedFlashlight7 : null)).PocketFlashlightServerRpc(false); } } } catch { } } } }
Lethal Company Mod - HD/BepInEx/plugins/HDLethalCompany.dll
Decompiled 11 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using GameNetcodeStuff; using HDLethalCompany.Patch; using HDLethalCompany.Tools; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("HDLethalCompanyRemake")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("HDLethalCompanyRemake")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("7f379bc1-1fd4-4c72-9247-a181862eec6b")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace HDLethalCompany { [BepInPlugin("HDLethalCompany", "HDLethalCompany-Sligili", "1.5.5")] public class HDLethalCompanyInitialization : BaseUnityPlugin { private static ConfigEntry<float> config_ResMult; private static ConfigEntry<bool> config_EnablePostProcessing; private static ConfigEntry<bool> config_EnableFog; private static ConfigEntry<bool> config_EnableAntialiasing; private static ConfigEntry<bool> config_EnableResolution; private static ConfigEntry<bool> config_EnableFoliage; private static ConfigEntry<int> config_FogQuality; private static ConfigEntry<int> config_TextureQuality; private static ConfigEntry<int> config_LOD; private static ConfigEntry<int> config_ShadowmapQuality; private Harmony _harmony; private void Awake() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown ((BaseUnityPlugin)this).Logger.LogInfo((object)"HDLethalCompany loaded"); ConfigFile(); GraphicsPatch.assetBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "HDLethalCompany/hdlethalcompany")); _harmony = new Harmony("HDLethalCompany"); _harmony.PatchAll(typeof(GraphicsPatch)); } private void ConfigFile() { config_ResMult = ((BaseUnityPlugin)this).Config.Bind<float>("RESOLUTION", "Value", 2.233f, "Resolution Scale Multiplier - <EXAMPLES -> | 1.000 = 860x520p | 2.233 =~ 1920x1080p | 2.977 = 2560x1440p | 4.465 = 3840x2060p > - The UI scanned elements have slightly incorrect offsets after 3.000"); config_EnableResolution = ((BaseUnityPlugin)this).Config.Bind<bool>("RESOLUTION", "EnableRes", true, "Resolution Fix - In case you wanna use another resolution mod or apply any widescreen mod while keeping the graphics settings"); config_EnableAntialiasing = ((BaseUnityPlugin)this).Config.Bind<bool>("EFFECTS", "EnableAA", false, "Anti-Aliasing (Unity's SMAA)"); config_EnablePostProcessing = ((BaseUnityPlugin)this).Config.Bind<bool>("EFFECTS", "EnablePP", true, "Post-Processing (Color grading)"); config_TextureQuality = ((BaseUnityPlugin)this).Config.Bind<int>("EFFECTS", "TextureQuality", 3, "Texture Resolution Quality - <PRESETS -> | 0 = VERY LOW (1/8) | 1 = LOW (1/4) | 2 = MEDIUM (1/2) | 3 = HIGH (1/1 VANILLA) >"); config_FogQuality = ((BaseUnityPlugin)this).Config.Bind<int>("EFFECTS", "FogQuality", 1, "Volumetric Fog Quality - <PRESETS -> | 0 = VERY LOW | 1 = VANILLA FOG | 2 = MEDIUM | 3 = HIGH >"); config_EnableFog = ((BaseUnityPlugin)this).Config.Bind<bool>("EFFECTS", "EnableFOG", true, "Volumetric Fog Toggle - Use this as a last resource in case lowering the fog quality is not enough to get decent performance"); config_LOD = ((BaseUnityPlugin)this).Config.Bind<int>("EFFECTS", "LOD", 1, "Level Of Detail - <PRESETS -> | 0 = LOW (HALF DISTANCE) | 1 = VANILLA | 2 = HIGH (TWICE THE DISTANCE) >"); config_ShadowmapQuality = ((BaseUnityPlugin)this).Config.Bind<int>("EFFECTS", "ShadowQuality", 3, "Shadows Resolution - <PRESETS -> 0 = VERY LOW (SHADOWS DISABLED)| 1 = LOW (256) | 2 = MEDIUM (1024) | 3 = VANILLA (2048) > - Shadowmap max resolution"); config_EnableFoliage = ((BaseUnityPlugin)this).Config.Bind<bool>("EFFECTS", "EnableF", true, "Foliage Toggle - If the game camera should or not render bushes/grass (trees won't be affected)"); GraphicsPatch.m_enableFoliage = config_EnableFoliage.Value; GraphicsPatch.m_enableResolutionFix = config_EnableResolution.Value; GraphicsPatch.m_setShadowQuality = config_ShadowmapQuality.Value; GraphicsPatch.m_setLOD = config_LOD.Value; GraphicsPatch.m_setTextureResolution = config_TextureQuality.Value; GraphicsPatch.m_setFogQuality = config_FogQuality.Value; GraphicsPatch.multiplier = config_ResMult.Value; GraphicsPatch.anchorOffsetZ = 0.123f * config_ResMult.Value + 0.877f; GraphicsPatch.m_widthResolution = 860f * config_ResMult.Value; GraphicsPatch.m_heightResolution = 520f * config_ResMult.Value; GraphicsPatch.m_enableAntiAliasing = config_EnableAntialiasing.Value; GraphicsPatch.m_enableFog = config_EnableFog.Value; GraphicsPatch.m_enablePostProcessing = config_EnablePostProcessing.Value; } } public static class PluginInfo { public const string Guid = "HDLethalCompany"; public const string Name = "HDLethalCompany-Sligili"; public const string Ver = "1.5.5"; } } namespace HDLethalCompany.Tools { public class Reflection { public static object GetInstanceField(Type type, object instance, string fieldName) { BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; FieldInfo field = type.GetField(fieldName, bindingAttr); return field.GetValue(instance); } public static object CallMethod(object instance, string methodName, params object[] args) { MethodInfo method = instance.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.NonPublic); if (method != null) { return method.Invoke(instance, args); } return null; } } } namespace HDLethalCompany.Patch { internal class GraphicsPatch { public static bool m_enablePostProcessing; public static bool m_enableFog; public static bool m_enableAntiAliasing; public static bool m_enableResolutionFix; public static bool m_enableFoliage = true; public static int m_setFogQuality; public static int m_setTextureResolution; public static int m_setLOD; public static int m_setShadowQuality; private static HDRenderPipelineAsset myAsset; public static AssetBundle assetBundle; public static float anchorOffsetX = 439.48f; public static float anchorOffsetY = 244.8f; public static float anchorOffsetZ; public static float multiplier; public static float m_widthResolution; public static float m_heightResolution; [HarmonyPatch(typeof(PlayerControllerB), "Start")] [HarmonyPrefix] private static void StartPrefix(PlayerControllerB __instance) { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) Object[] array = Resources.FindObjectsOfTypeAll(typeof(HDAdditionalCameraData)); foreach (Object obj in array) { HDAdditionalCameraData val = (HDAdditionalCameraData)(object)((obj is HDAdditionalCameraData) ? obj : null); if (!(((Object)((Component)val).gameObject).name == "MapCamera")) { val.customRenderingSettings = true; ToggleCustomPass(val, m_enablePostProcessing); SetLevelOfDetail(val); ToggleVolumetricFog(val, m_enableFog); if (!m_enableFoliage) { LayerMask val2 = LayerMask.op_Implicit(((Component)val).GetComponent<Camera>().cullingMask); val2 = LayerMask.op_Implicit(LayerMask.op_Implicit(val2) & -1025); ((Component)val).GetComponent<Camera>().cullingMask = LayerMask.op_Implicit(val2); } SetShadowQuality(assetBundle, val); if (!(((Object)((Component)val).gameObject).name == "SecurityCamera") && !(((Object)((Component)val).gameObject).name == "ShipCamera")) { SetAntiAliasing(val); } } } array = null; SetTextureQuality(); SetFogQuality(); if (m_enableResolutionFix && multiplier != 1f) { int width = (int)Math.Round(m_widthResolution, 0); int height = (int)Math.Round(m_heightResolution, 0); ((Texture)__instance.gameplayCamera.targetTexture).width = width; ((Texture)__instance.gameplayCamera.targetTexture).height = height; } } [HarmonyPatch(typeof(RoundManager), "GenerateNewFloor")] [HarmonyPrefix] private static void RoundPostFix() { SetFogQuality(); if (m_setLOD == 0) { RemoveLodFromGameObject("CatwalkStairs"); } } [HarmonyPatch(typeof(HUDManager), "UpdateScanNodes")] [HarmonyPostfix] private static void UpdateScanNodesPostfix(PlayerControllerB playerScript, HUDManager __instance) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) if (anchorOffsetZ > 1.238f) { anchorOffsetZ = 1.238f; } if (!m_enableResolutionFix || multiplier == 1f) { return; } Vector3 zero = Vector3.zero; bool flag = false; for (int i = 0; i < __instance.scanElements.Length; i++) { if ((Traverse.Create((object)__instance).Field("scanNodes").GetValue() as Dictionary<RectTransform, ScanNodeProperties>).Count > 0 && (Traverse.Create((object)__instance).Field("scanNodes").GetValue() as Dictionary<RectTransform, ScanNodeProperties>).TryGetValue(__instance.scanElements[i], out var value) && (Object)(object)value != (Object)null) { try { if ((bool)Reflection.CallMethod(__instance, "NodeIsNotVisible", value, i)) { continue; } if (!((Component)__instance.scanElements[i]).gameObject.activeSelf) { ((Component)__instance.scanElements[i]).gameObject.SetActive(true); ((Component)__instance.scanElements[i]).GetComponent<Animator>().SetInteger("colorNumber", value.nodeType); if (value.creatureScanID != -1) { Traverse.Create((object)__instance).Method("AttemptScanNewCreature", new object[1] { value.creatureScanID }); } } goto IL_0186; } catch (Exception arg) { Debug.LogError((object)$"Error in updatescanNodes A: {arg}"); goto IL_0186; } } (Traverse.Create((object)__instance).Field("scanNodes").GetValue() as Dictionary<RectTransform, ScanNodeProperties>).Remove(__instance.scanElements[i]); ((Component)__instance.scanElements[i]).gameObject.SetActive(false); continue; IL_0186: try { Traverse.Create((object)__instance).Field("scanElementText").SetValue((object)((Component)__instance.scanElements[i]).gameObject.GetComponentsInChildren<TextMeshProUGUI>()); if ((Traverse.Create((object)__instance).Field("scanElementText").GetValue() as TextMeshProUGUI[]).Length > 1) { ((TMP_Text)(Traverse.Create((object)__instance).Field("scanElementText").GetValue() as TextMeshProUGUI[])[0]).text = value.headerText; ((TMP_Text)(Traverse.Create((object)__instance).Field("scanElementText").GetValue() as TextMeshProUGUI[])[1]).text = value.subText; } if (value.nodeType == 2) { flag = true; } zero = playerScript.gameplayCamera.WorldToScreenPoint(((Component)value).transform.position); ((Transform)__instance.scanElements[i]).position = new Vector3(((Transform)__instance.scanElements[i]).position.x, ((Transform)__instance.scanElements[i]).position.y, 12.17f * anchorOffsetZ); __instance.scanElements[i].anchoredPosition = Vector2.op_Implicit(new Vector3(zero.x - anchorOffsetX * multiplier, zero.y - anchorOffsetY * multiplier)); if (!(multiplier > 3f)) { ((Transform)__instance.scanElements[i]).localScale = new Vector3(multiplier, multiplier, multiplier); } else { ((Transform)__instance.scanElements[i]).localScale = new Vector3(3f, 3f, 3f); } } catch (Exception arg2) { Debug.LogError((object)$"Error in updatescannodes B: {arg2}"); } } try { if (!flag) { __instance.totalScrapScanned = 0; Traverse.Create((object)__instance).Field("totalScrapScannedDisplayNum").SetValue((object)0); Traverse.Create((object)__instance).Field("addToDisplayTotalInterval").SetValue((object)0.35f); } __instance.scanInfoAnimator.SetBool("display", (int)Reflection.GetInstanceField(typeof(HUDManager), __instance, "scannedScrapNum") >= 2 && flag); } catch (Exception arg3) { Debug.LogError((object)$"Error in updatescannodes C: {arg3}"); } } public static void SetShadowQuality(AssetBundle assetBundle, HDAdditionalCameraData cameraData) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)assetBundle == (Object)null) { Debug.LogError((object)"HDLETHALCOMPANY: Something is wrong with the Asset Bundle - Null"); return; } ((BitArray128)(ref cameraData.renderingPathCustomFrameSettingsOverrideMask.mask))[20u] = true; ((FrameSettings)(ref cameraData.renderingPathCustomFrameSettings)).SetEnabled((FrameSettingsField)20, (m_setShadowQuality != 0) ? true : false); myAsset = (HDRenderPipelineAsset)((m_setShadowQuality != 1) ? ((m_setShadowQuality != 2) ? ((object)(HDRenderPipelineAsset)QualitySettings.renderPipeline) : ((object)(myAsset = assetBundle.LoadAsset<HDRenderPipelineAsset>("Assets/HDLethalCompany/MediumShadowsAsset.asset")))) : (myAsset = assetBundle.LoadAsset<HDRenderPipelineAsset>("Assets/HDLethalCompany/VeryLowShadowsAsset.asset"))); QualitySettings.renderPipeline = (RenderPipelineAsset)(object)myAsset; } public static void SetLevelOfDetail(HDAdditionalCameraData cameraData) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) if (m_setLOD != 1) { ((BitArray128)(ref cameraData.renderingPathCustomFrameSettingsOverrideMask.mask))[60u] = true; ((BitArray128)(ref cameraData.renderingPathCustomFrameSettingsOverrideMask.mask))[61u] = true; ((FrameSettings)(ref cameraData.renderingPathCustomFrameSettings)).SetEnabled((FrameSettingsField)60, true); ((FrameSettings)(ref cameraData.renderingPathCustomFrameSettings)).SetEnabled((FrameSettingsField)61, true); cameraData.renderingPathCustomFrameSettings.lodBiasMode = (LODBiasMode)2; cameraData.renderingPathCustomFrameSettings.lodBias = ((m_setLOD == 0) ? 0.6f : 2.3f); if (m_setLOD == 0 && ((Component)cameraData).GetComponent<Camera>().farClipPlane > 180f) { ((Component)cameraData).GetComponent<Camera>().farClipPlane = 170f; } } } public static void SetTextureQuality() { if (m_setTextureResolution < 3) { int globalTextureMipmapLimit = 3 - m_setTextureResolution; QualitySettings.globalTextureMipmapLimit = globalTextureMipmapLimit; } } public static void SetAntiAliasing(HDAdditionalCameraData cameraData) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) if (m_enableAntiAliasing) { cameraData.antialiasing = (AntialiasingMode)3; } } public static void ToggleCustomPass(HDAdditionalCameraData cameraData, bool enable) { ((BitArray128)(ref cameraData.renderingPathCustomFrameSettingsOverrideMask.mask))[6u] = true; ((FrameSettings)(ref cameraData.renderingPathCustomFrameSettings)).SetEnabled((FrameSettingsField)6, enable); } public static void ToggleVolumetricFog(HDAdditionalCameraData cameraData, bool enable) { ((BitArray128)(ref cameraData.renderingPathCustomFrameSettingsOverrideMask.mask))[28u] = true; ((FrameSettings)(ref cameraData.renderingPathCustomFrameSettings)).SetEnabled((FrameSettingsField)28, enable); } public static void SetFogQuality() { Object[] array = Resources.FindObjectsOfTypeAll(typeof(Volume)); if (array.Length == 0) { Debug.LogError((object)"No volumes found"); return; } Fog val2 = default(Fog); foreach (Object obj in array) { Volume val = (Volume)(object)((obj is Volume) ? obj : null); if (!val.sharedProfile.TryGet<Fog>(ref val2)) { continue; } ((VolumeParameter<int>)(object)((VolumeComponentWithQuality)val2).quality).Override(3); switch (m_setFogQuality) { case -1: if (val2.volumetricFogBudget > 0.05f) { val2.volumetricFogBudget = 0.05f; } if (val2.resolutionDepthRatio > 0.5f) { val2.resolutionDepthRatio = 0.5f; } break; case 0: if (val2.volumetricFogBudget > 0.05f) { val2.volumetricFogBudget = 0.05f; } if (val2.resolutionDepthRatio > 0.5f) { val2.resolutionDepthRatio = 0.5f; } break; case 2: if (val2.volumetricFogBudget > 0.333f) { val2.volumetricFogBudget = 0.333f; } if (val2.resolutionDepthRatio > 0.666f) { val2.resolutionDepthRatio = 0.666f; } break; case 3: if (val2.volumetricFogBudget > 0.666f) { val2.volumetricFogBudget = 0.666f; } if (val2.resolutionDepthRatio > 0.5f) { val2.resolutionDepthRatio = 0.5f; } break; } } } public static void RemoveLodFromGameObject(string name) { Object[] array = Resources.FindObjectsOfTypeAll(typeof(LODGroup)); foreach (Object obj in array) { LODGroup val = (LODGroup)(object)((obj is LODGroup) ? obj : null); if (((Object)((Component)val).gameObject).name == name) { val.enabled = false; } } } } }
Lethal Company Mod - HD/BepInEx/plugins/LC_API.dll
Decompiled 11 months agousing System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LC_API.BundleAPI; using LC_API.ClientAPI; using LC_API.Comp; using LC_API.Data; using LC_API.Extensions; using LC_API.GameInterfaceAPI; using LC_API.ManualPatches; using LC_API.ServerAPI; using Microsoft.CodeAnalysis; using Steamworks; using Steamworks.Data; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.InputSystem; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")] [assembly: AssemblyCompany("LC_API")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Utilities for plugin devs")] [assembly: AssemblyFileVersion("2.1.4.0")] [assembly: AssemblyInformationalVersion("2.1.4")] [assembly: AssemblyProduct("LC_API")] [assembly: AssemblyTitle("LC_API")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.1.4.0")] [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; } } } namespace LC_API { internal static class CheatDatabase { private const string DAT_CD_BROADCAST = "LC_API_CD_Broadcast"; private const string SIG_REQ_GUID = "LC_API_ReqGUID"; private const string SIG_SEND_MODS = "LC_APISendMods"; private static Dictionary<string, PluginInfo> PluginsLoaded = new Dictionary<string, PluginInfo>(); public static void RunLocalCheatDetector() { PluginsLoaded = Chainloader.PluginInfos; using Dictionary<string, PluginInfo>.ValueCollection.Enumerator enumerator = PluginsLoaded.Values.GetEnumerator(); while (enumerator.MoveNext()) { switch (enumerator.Current.Metadata.GUID) { case "mikes.lethalcompany.mikestweaks": case "mom.llama.enhancer": case "Posiedon.GameMaster": case "LethalCompanyScalingMaster": case "verity.amberalert": ModdedServer.SetServerModdedOnly(); break; } } } public static void OtherPlayerCheatDetector() { Plugin.Log.LogWarning((object)"Asking all other players for their mod list.."); GameTips.ShowTip("Mod List:", "Asking all other players for installed mods.."); GameTips.ShowTip("Mod List:", "Check the logs for more detailed results.\n<size=13>(Note that if someone doesnt show up on the list, they may not have LC_API installed)</size>"); Networking.Broadcast("LC_API_CD_Broadcast", "LC_API_ReqGUID"); } internal static void CDNetGetString(string data, string signature) { if (data == "LC_API_CD_Broadcast" && signature == "LC_API_ReqGUID") { string text = ""; foreach (PluginInfo value in PluginsLoaded.Values) { text = text + "\n" + value.Metadata.GUID; } Networking.Broadcast(GameNetworkManager.Instance.localPlayerController.playerUsername + " responded with these mods:" + text, "LC_APISendMods"); } if (signature == "LC_APISendMods") { GameTips.ShowTip("Mod List:", data); Plugin.Log.LogWarning((object)data); } } } [BepInPlugin("LC_API", "LC_API", "2.1.4")] public sealed class Plugin : BaseUnityPlugin { internal static ManualLogSource Log; private ConfigEntry<bool> configOverrideModServer; private ConfigEntry<bool> configLegacyAssetLoading; private ConfigEntry<bool> configDisableBundleLoader; public static bool Initialized { get; private set; } private void Awake() { //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Expected O, but got Unknown //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Expected O, but got Unknown //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Expected O, but got Unknown //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Expected O, but got Unknown configOverrideModServer = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Force modded server browser", false, "Should the API force you into the modded server browser?"); configLegacyAssetLoading = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Legacy asset bundle loading", false, "Should the BundleLoader use legacy asset loading? Turning this on may help with loading assets from older plugins."); configDisableBundleLoader = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Disable BundleLoader", false, "Should the BundleLoader be turned off? Enable this if you are having problems with mods that load assets using a different method from LC_API's BundleLoader."); CommandHandler.commandPrefix = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Prefix", "/", "Command prefix"); Log = ((BaseUnityPlugin)this).Logger; ((BaseUnityPlugin)this).Logger.LogWarning((object)"\n.____ _________ _____ __________ .___ \r\n| | \\_ ___ \\ / _ \\ \\______ \\| | \r\n| | / \\ \\/ / /_\\ \\ | ___/| | \r\n| |___\\ \\____ / | \\| | | | \r\n|_______ \\\\______ /______\\____|__ /|____| |___| \r\n \\/ \\//_____/ \\/ \r\n "); ((BaseUnityPlugin)this).Logger.LogInfo((object)"LC_API Starting up.."); if (configOverrideModServer.Value) { ModdedServer.SetServerModdedOnly(); } Harmony val = new Harmony("ModAPI"); MethodInfo methodInfo = AccessTools.Method(typeof(GameNetworkManager), "SteamMatchmaking_OnLobbyCreated", (Type[])null, (Type[])null); AccessTools.Method(typeof(GameNetworkManager), "LobbyDataIsJoinable", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(ServerPatch), "OnLobbyCreate", (Type[])null, (Type[])null); MethodInfo methodInfo3 = AccessTools.Method(typeof(MenuManager), "Awake", (Type[])null, (Type[])null); MethodInfo methodInfo4 = AccessTools.Method(typeof(ServerPatch), "CacheMenuManager", (Type[])null, (Type[])null); MethodInfo methodInfo5 = AccessTools.Method(typeof(HUDManager), "AddChatMessage", (Type[])null, (Type[])null); MethodInfo methodInfo6 = AccessTools.Method(typeof(ServerPatch), "ChatInterpreter", (Type[])null, (Type[])null); MethodInfo methodInfo7 = AccessTools.Method(typeof(HUDManager), "SubmitChat_performed", (Type[])null, (Type[])null); MethodInfo methodInfo8 = AccessTools.Method(typeof(CommandHandler.SubmitChatPatch), "Transpiler", (Type[])null, (Type[])null); val.Patch((MethodBase)methodInfo3, new HarmonyMethod(methodInfo4), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)methodInfo5, new HarmonyMethod(methodInfo6), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)methodInfo7, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(methodInfo8), (HarmonyMethod)null, (HarmonyMethod)null); Networking.GetString = (Action<string, string>)Delegate.Combine(Networking.GetString, new Action<string, string>(CheatDatabase.CDNetGetString)); Networking.GetListString = (Action<List<string>, string>)Delegate.Combine(Networking.GetListString, new Action<List<string>, string>(Networking.LCAPI_NET_SYNCVAR_SET)); } internal void Start() { Initialize(); } internal void OnDestroy() { Initialize(); } internal void Initialize() { //IL_002f: 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_003a: Expected O, but got Unknown if (!Initialized) { Initialized = true; if (!configDisableBundleLoader.Value) { BundleLoader.Load(configLegacyAssetLoading.Value); } GameObject val = new GameObject("API"); Object.DontDestroyOnLoad((Object)val); val.AddComponent<LC_APIManager>(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"LC_API Started!"); CheatDatabase.RunLocalCheatDetector(); } } internal static void PatchMethodManual(MethodInfo method, MethodInfo patch, Harmony harmony) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown harmony.Patch((MethodBase)method, new HarmonyMethod(patch), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "LC_API"; public const string PLUGIN_NAME = "LC_API"; public const string PLUGIN_VERSION = "2.1.4"; } } namespace LC_API.ServerAPI { public static class ModdedServer { private static bool moddedOnly; [Obsolete("Use SetServerModdedOnly() instead. This will be removed/private in a future update.")] public static bool setModdedOnly; public static bool ModdedOnly => moddedOnly; public static void SetServerModdedOnly() { moddedOnly = true; Plugin.Log.LogMessage((object)"A plugin has set your game to only allow you to play with other people who have mods!"); } public static void OnSceneLoaded() { if (Object.op_Implicit((Object)(object)GameNetworkManager.Instance) && ModdedOnly) { GameNetworkManager instance = GameNetworkManager.Instance; instance.gameVersionNum += 16440; setModdedOnly = true; } } } public static class Networking { public static Action<string, string> GetString = delegate { }; public static Action<List<string>, string> GetListString = delegate { }; public static Action<int, string> GetInt = delegate { }; public static Action<float, string> GetFloat = delegate { }; public static Action<Vector3, string> GetVector3 = delegate { }; private static Dictionary<string, string> syncStringVars = new Dictionary<string, string>(); public static void Broadcast(string data, string signature) { if (data.Contains("/")) { Plugin.Log.LogError((object)"Invalid character in broadcasted string event! ( / )"); return; } HUDManager.Instance.AddTextToChatOnServer("<size=0>NWE/" + data + "/" + signature + "/" + NetworkBroadcastDataType.BDstring.ToString() + "/" + GameNetworkManager.Instance.localPlayerController.playerClientId + "/</size>", -1); } public static void Broadcast(List<string> data, string signature) { string text = ""; foreach (string datum in data) { if (datum.Contains("/")) { Plugin.Log.LogError((object)"Invalid character in broadcasted string event! ( / )"); return; } if (datum.Contains("\n")) { Plugin.Log.LogError((object)"Invalid character in broadcasted string event! ( NewLine )"); return; } text = text + datum + "\n"; } HUDManager.Instance.AddTextToChatOnServer("<size=0>NWE/" + data?.ToString() + "/" + signature + "/" + NetworkBroadcastDataType.BDlistString.ToString() + "/" + GameNetworkManager.Instance.localPlayerController.playerClientId + "/</size>", -1); } public static void Broadcast(int data, string signature) { HUDManager.Instance.AddTextToChatOnServer("<size=0>NWE/" + data + "/" + signature + "/" + NetworkBroadcastDataType.BDint.ToString() + "/" + GameNetworkManager.Instance.localPlayerController.playerClientId + "/</size>", -1); } public static void Broadcast(float data, string signature) { HUDManager.Instance.AddTextToChatOnServer("<size=0>NWE/" + data + "/" + signature + "/" + NetworkBroadcastDataType.BDfloat.ToString() + "/" + GameNetworkManager.Instance.localPlayerController.playerClientId + "/</size>", -1); } public static void Broadcast(Vector3 data, string signature) { //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) HUDManager instance = HUDManager.Instance; string[] obj = new string[9] { "<size=0>NWE/", null, null, null, null, null, null, null, null }; Vector3 val = data; obj[1] = ((object)(Vector3)(ref val)).ToString(); obj[2] = "/"; obj[3] = signature; obj[4] = "/"; obj[5] = NetworkBroadcastDataType.BDvector3.ToString(); obj[6] = "/"; obj[7] = GameNetworkManager.Instance.localPlayerController.playerClientId.ToString(); obj[8] = "/</size>"; instance.AddTextToChatOnServer(string.Concat(obj), -1); } public static void RegisterSyncVariable(string name) { if (!syncStringVars.ContainsKey(name)) { syncStringVars.Add(name, ""); } else { Plugin.Log.LogError((object)("Cannot register Sync Variable! A Sync Variable has already been registered with name " + name)); } } public static void SetSyncVariable(string name, string value) { if (syncStringVars.ContainsKey(name)) { syncStringVars[name] = value; Broadcast(new List<string> { name, value }, "LCAPI_NET_SYNCVAR_SET"); } else { Plugin.Log.LogError((object)("Cannot set the value of Sync Variable " + name + " as it is not registered!")); } } private static void SetSyncVariableB(string name, string value) { if (syncStringVars.ContainsKey(name)) { syncStringVars[name] = value; } else { Plugin.Log.LogError((object)("Cannot set the value of Sync Variable " + name + " as it is not registered!")); } } internal static void LCAPI_NET_SYNCVAR_SET(List<string> list, string arg2) { if (arg2 == "LCAPI_NET_SYNCVAR_SET") { SetSyncVariableB(list[0], list[1]); } } public static string GetSyncVariable(string name) { if (syncStringVars.ContainsKey(name)) { return syncStringVars[name]; } Plugin.Log.LogError((object)("Cannot get the value of Sync Variable " + name + " as it is not registered!")); return ""; } private static void GotString(string data, string signature) { } private static void GotInt(int data, string signature) { } private static void GotFloat(float data, string signature) { } private static void GotVector3(Vector3 data, string signature) { } } } namespace LC_API.ManualPatches { internal static class ServerPatch { internal static bool OnLobbyCreate(GameNetworkManager __instance, Result result, Lobby lobby) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0009: Unknown result type (might be due to invalid IL or missing references) if ((int)result != 1) { Debug.LogError((object)$"Lobby could not be created! {result}", (Object)(object)__instance); } __instance.lobbyHostSettings.lobbyName = "[MODDED]" + __instance.lobbyHostSettings.lobbyName.ToString(); Plugin.Log.LogMessage((object)"server pre-setup success"); return true; } internal static bool CacheMenuManager(MenuManager __instance) { LC_APIManager.MenuManager = __instance; return true; } internal static bool ChatInterpreter(HUDManager __instance, string chatMessage) { //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_03a2: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) if (!chatMessage.Contains("NWE") || !chatMessage.Contains("<size=0>")) { return true; } string[] array = chatMessage.Split(new char[1] { '/' }); if (array.Length < 5) { if (array.Length >= 3) { if (!int.TryParse(array[4], out var result)) { Plugin.Log.LogWarning((object)"Failed to parse player ID!!"); return false; } if ((result == (int)GameNetworkManager.Instance.localPlayerController.playerClientId) & !LC_APIManager.netTester) { return false; } Enum.TryParse<NetworkBroadcastDataType>(array[3], out var result2); switch (result2) { case NetworkBroadcastDataType.BDstring: Networking.GetString(array[1], array[2]); break; case NetworkBroadcastDataType.BDint: Networking.GetInt(int.Parse(array[1]), array[2]); break; case NetworkBroadcastDataType.BDfloat: Networking.GetFloat(float.Parse(array[1]), array[2]); break; case NetworkBroadcastDataType.BDvector3: { string[] array2 = array[1].Replace("(", "").Replace(")", "").Split(new char[1] { ',' }); Vector3 arg = default(Vector3); if (array2.Length == 3) { if (float.TryParse(array2[0], out var result3) && float.TryParse(array2[1], out var result4) && float.TryParse(array2[2], out var result5)) { arg.x = result3; arg.y = result4; arg.z = result5; } else { Plugin.Log.LogError((object)"Vector3 Network receive fail. This is a failure of the API, and it should be reported as a bug."); } } else { Plugin.Log.LogError((object)"Vector3 Network receive fail. This is a failure of the API, and it should be reported as a bug."); } Networking.GetVector3(arg, array[2]); break; } case NetworkBroadcastDataType.BDlistString: { string[] source = array[1].Split(new char[1] { '\n' }); Networking.GetListString(source.ToList(), array[2]); break; } } _ = LC_APIManager.netTester; return false; } Plugin.Log.LogError((object)"Generic Network receive fail. This is a failure of the API, and it should be reported as a bug."); Plugin.Log.LogError((object)$"Generic Network receive fail (expected 5+ data fragments, got {array.Length}). This is a failure of the API, and it should be reported as a bug."); return true; } if (!int.TryParse(array[4], out var result6)) { Plugin.Log.LogWarning((object)("Failed to parse player ID '" + array[4] + "'!!")); return false; } if ((result6 == (int)GameNetworkManager.Instance.localPlayerController.playerClientId) & !LC_APIManager.netTester) { return false; } if (!Enum.TryParse<NetworkBroadcastDataType>(array[3], out var result7)) { Plugin.Log.LogError((object)("Unknown datatype - unable to parse '" + array[3] + "' into a known data type!")); return false; } switch (result7) { case NetworkBroadcastDataType.BDstring: Networking.GetString.InvokeActionSafe(array[1], array[2]); break; case NetworkBroadcastDataType.BDint: Networking.GetInt.InvokeActionSafe(int.Parse(array[1]), array[2]); break; case NetworkBroadcastDataType.BDfloat: Networking.GetFloat.InvokeActionSafe(float.Parse(array[1]), array[2]); break; case NetworkBroadcastDataType.BDvector3: { string text = array[1].Trim('(', ')'); string[] array3 = text.Split(new char[1] { ',' }); Vector3 param = default(Vector3); float result8; float result9; float result10; if (array3.Length != 3) { Plugin.Log.LogError((object)$"Vector3 Network receive fail (expected 3 numbers, got {array3.Length} number(?)(s) instead). This is a failure of the API, and it should be reported as a bug. (passing an empty Vector3 in its place)"); } else if (float.TryParse(array3[0], out result8) && float.TryParse(array3[1], out result9) && float.TryParse(array3[2], out result10)) { param.x = result8; param.y = result9; param.z = result10; } else { Plugin.Log.LogError((object)("Vector3 Network receive fail (failed to parse '" + text + "' as numbers). This is a failure of the API, and it should be reported as a bug.")); } Networking.GetVector3.InvokeActionSafe(param, array[2]); break; } } _ = LC_APIManager.netTester; return false; } internal static bool ChatCommands(HUDManager __instance, CallbackContext context) { if (__instance.chatTextField.text.ToLower().Contains("/modcheck")) { CheatDatabase.OtherPlayerCheatDetector(); return false; } return true; } } } namespace LC_API.GameInterfaceAPI { public static class GameState { private static readonly Action NothingAction = delegate { }; public static int AlivePlayerCount { get; private set; } public static ShipState ShipState { get; private set; } public static event Action PlayerDied; public static event Action LandOnMoon; public static event Action WentIntoOrbit; public static event Action ShipStartedLeaving; internal static void GSUpdate() { if (!((Object)(object)StartOfRound.Instance == (Object)null)) { if (StartOfRound.Instance.shipHasLanded && ShipState != ShipState.OnMoon) { ShipState = ShipState.OnMoon; GameState.LandOnMoon.InvokeActionSafe(); } if (StartOfRound.Instance.inShipPhase && ShipState != 0) { ShipState = ShipState.InOrbit; GameState.WentIntoOrbit.InvokeActionSafe(); } if (StartOfRound.Instance.shipIsLeaving && ShipState != ShipState.LeavingMoon) { ShipState = ShipState.LeavingMoon; GameState.ShipStartedLeaving.InvokeActionSafe(); } if (AlivePlayerCount < StartOfRound.Instance.livingPlayers) { GameState.PlayerDied.InvokeActionSafe(); } AlivePlayerCount = StartOfRound.Instance.livingPlayers; } } static GameState() { GameState.PlayerDied = NothingAction; GameState.LandOnMoon = NothingAction; GameState.WentIntoOrbit = NothingAction; GameState.ShipStartedLeaving = NothingAction; } } public class GameTips { private static List<string> tipHeaders = new List<string>(); private static List<string> tipBodys = new List<string>(); private static float lastMessageTime; public static void ShowTip(string header, string body) { tipHeaders.Add(header); tipBodys.Add(body); } public static void UpdateInternal() { lastMessageTime -= Time.deltaTime; if ((tipHeaders.Count > 0) & (lastMessageTime < 0f)) { lastMessageTime = 5f; if ((Object)(object)HUDManager.Instance != (Object)null) { HUDManager.Instance.DisplayTip(tipHeaders[0], tipBodys[0], false, false, "LC_Tip1"); } tipHeaders.RemoveAt(0); tipBodys.RemoveAt(0); } } } } namespace LC_API.Extensions { public static class DelegateExtensions { private static readonly PropertyInfo PluginGetLogger = AccessTools.Property(typeof(BaseUnityPlugin), "Logger"); public static void InvokeActionSafe(this Action action) { //IL_009e: Unknown result type (might be due to invalid IL or missing references) if (action == null) { return; } Delegate[] invocationList = action.GetInvocationList(); foreach (Delegate @delegate in invocationList) { try { ((Action)@delegate)(); } catch (Exception ex) { Plugin.Log.LogError((object)"Exception while invoking hook callback!"); string asmName = @delegate.GetMethodInfo().DeclaringType.Assembly.FullName; PluginInfo val = ((IEnumerable<PluginInfo>)Chainloader.PluginInfos.Values).FirstOrDefault((Func<PluginInfo, bool>)((PluginInfo pi) => ((object)pi.Instance).GetType().Assembly.FullName == asmName)); if (val == null) { Plugin.Log.LogError((object)ex.ToString()); break; } ((ManualLogSource)PluginGetLogger.GetValue(val.Instance)).LogError((object)ex.ToString()); } } } public static void InvokeActionSafe<T>(this Action<T> action, T param) { //IL_009f: Unknown result type (might be due to invalid IL or missing references) if (action == null) { return; } Delegate[] invocationList = action.GetInvocationList(); foreach (Delegate @delegate in invocationList) { try { ((Action<T>)@delegate)(param); } catch (Exception ex) { Plugin.Log.LogError((object)"Exception while invoking hook callback!"); string asmName = @delegate.GetMethodInfo().DeclaringType.Assembly.FullName; PluginInfo val = ((IEnumerable<PluginInfo>)Chainloader.PluginInfos.Values).FirstOrDefault((Func<PluginInfo, bool>)((PluginInfo pi) => ((object)pi.Instance).GetType().Assembly.FullName == asmName)); if (val == null) { Plugin.Log.LogError((object)ex.ToString()); break; } ((ManualLogSource)PluginGetLogger.GetValue(val.Instance)).LogError((object)ex.ToString()); } } } public static void InvokeActionSafe<T1, T2>(this Action<T1, T2> action, T1 param1, T2 param2) { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) if (action == null) { return; } Delegate[] invocationList = action.GetInvocationList(); foreach (Delegate @delegate in invocationList) { try { ((Action<T1, T2>)@delegate)(param1, param2); } catch (Exception ex) { Plugin.Log.LogError((object)"Exception while invoking hook callback!"); string asmName = @delegate.GetMethodInfo().DeclaringType.Assembly.FullName; PluginInfo val = ((IEnumerable<PluginInfo>)Chainloader.PluginInfos.Values).FirstOrDefault((Func<PluginInfo, bool>)((PluginInfo pi) => ((object)pi.Instance).GetType().Assembly.FullName == asmName)); if (val == null) { Plugin.Log.LogError((object)ex.ToString()); break; } ((ManualLogSource)PluginGetLogger.GetValue(val.Instance)).LogError((object)ex.ToString()); } } } internal static void InvokeParameterlessDelegate<T>(this T paramlessDelegate) where T : Delegate { //IL_00b9: Unknown result type (might be due to invalid IL or missing references) if ((Delegate?)paramlessDelegate == (Delegate?)null) { return; } Delegate[] invocationList = paramlessDelegate.GetInvocationList(); foreach (Delegate @delegate in invocationList) { try { ((T)@delegate).DynamicInvoke(); } catch (Exception ex) { Plugin.Log.LogError((object)"Exception while invoking hook callback!"); string asmName = @delegate.GetMethodInfo().DeclaringType.Assembly.FullName; PluginInfo val = ((IEnumerable<PluginInfo>)Chainloader.PluginInfos.Values).FirstOrDefault((Func<PluginInfo, bool>)((PluginInfo pi) => ((object)pi.Instance).GetType().Assembly.FullName == asmName)); if (val == null) { Plugin.Log.LogError((object)ex.ToString()); break; } ((ManualLogSource)PluginGetLogger.GetValue(val.Instance)).LogError((object)ex.ToString()); } } } } } namespace LC_API.Data { internal enum NetworkBroadcastDataType { Unknown, BDint, BDfloat, BDvector3, BDstring, BDlistString } public enum ShipState { InOrbit, OnMoon, LeavingMoon } } namespace LC_API.Comp { internal class LC_APIManager : MonoBehaviour { public static MenuManager MenuManager; public static bool netTester; private static int playerCount; private static bool wanttoCheckMods; private static float lobbychecktimer; public void Update() { GameState.GSUpdate(); GameTips.UpdateInternal(); if ((((Object)(object)HUDManager.Instance != (Object)null) & netTester) && (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null) { Networking.Broadcast("testerData", "testerSignature"); } if (!ModdedServer.setModdedOnly) { ModdedServer.OnSceneLoaded(); } else if (ModdedServer.ModdedOnly && (Object)(object)MenuManager != (Object)null && Object.op_Implicit((Object)(object)MenuManager.versionNumberText)) { ((TMP_Text)MenuManager.versionNumberText).text = $"v{GameNetworkManager.Instance.gameVersionNum - 16440}\nMOD"; } if ((Object)(object)GameNetworkManager.Instance != (Object)null) { if (playerCount < GameNetworkManager.Instance.connectedPlayers) { lobbychecktimer = -4.5f; wanttoCheckMods = true; } playerCount = GameNetworkManager.Instance.connectedPlayers; } if (lobbychecktimer < 0f) { lobbychecktimer += Time.deltaTime; } else if (wanttoCheckMods && (Object)(object)HUDManager.Instance != (Object)null) { wanttoCheckMods = false; CD(); } } private void CD() { CheatDatabase.OtherPlayerCheatDetector(); } } } namespace LC_API.ClientAPI { public static class CommandHandler { internal static class SubmitChatPatch { private static bool HandleMessage(HUDManager manager) { string text = manager.chatTextField.text; if (!Utility.IsNullOrWhiteSpace(text) && text.StartsWith(commandPrefix.Value)) { string[] array = text.Split(new char[1] { ' ' }); string text2 = array[0].Substring(commandPrefix.Value.Length); if (TryGetCommandHandler(text2, out var handler)) { string[] obj = array.Skip(1).ToArray(); try { handler(obj); } catch (Exception ex) { Plugin.Log.LogError((object)("Error handling command: " + text2)); Plugin.Log.LogError((object)ex); } } manager.localPlayer.isTypingChat = false; manager.chatTextField.text = ""; EventSystem.current.SetSelectedGameObject((GameObject)null); ((Behaviour)manager.typingIndicator).enabled = false; return true; } return false; } internal static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { List<CodeInstruction> newInstructions = new List<CodeInstruction>(instructions); Label label = generator.DefineLabel(); newInstructions[newInstructions.Count - 1].labels.Add(label); int index = newInstructions.FindIndex((CodeInstruction i) => i.opcode == OpCodes.Ldfld && (FieldInfo)i.operand == AccessTools.Field(typeof(PlayerControllerB), "isPlayerDead")) - 2; newInstructions.InsertRange(index, (IEnumerable<CodeInstruction>)(object)new CodeInstruction[3] { CodeInstructionExtensions.MoveLabelsFrom(new CodeInstruction(OpCodes.Ldarg_0, (object)null), newInstructions[index]), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(SubmitChatPatch), "HandleMessage", (Type[])null, (Type[])null)), new CodeInstruction(OpCodes.Brtrue, (object)label) }); for (int z = 0; z < newInstructions.Count; z++) { yield return newInstructions[z]; } } } internal static ConfigEntry<string> commandPrefix; internal static Dictionary<string, Action<string[]>> CommandHandlers = new Dictionary<string, Action<string[]>>(); internal static Dictionary<string, List<string>> CommandAliases = new Dictionary<string, List<string>>(); public static bool RegisterCommand(string command, Action<string[]> handler) { if (command.Contains(" ") || CommandHandlers.ContainsKey(command)) { return false; } CommandHandlers.Add(command, handler); return true; } public static bool RegisterCommand(string command, List<string> aliases, Action<string[]> handler) { if (command.Contains(" ") || GetCommandHandler(command) != null) { return false; } foreach (string alias in aliases) { if (alias.Contains(" ") || GetCommandHandler(alias) != null) { return false; } } CommandHandlers.Add(command, handler); CommandAliases.Add(command, aliases); return true; } public static bool UnregisterCommand(string command) { CommandAliases.Remove(command); return CommandHandlers.Remove(command); } internal static Action<string[]> GetCommandHandler(string command) { if (CommandHandlers.TryGetValue(command, out var value)) { return value; } foreach (KeyValuePair<string, List<string>> commandAlias in CommandAliases) { if (commandAlias.Value.Contains(command)) { return CommandHandlers[commandAlias.Key]; } } return null; } internal static bool TryGetCommandHandler(string command, out Action<string[]> handler) { handler = GetCommandHandler(command); return handler != null; } } } namespace LC_API.BundleAPI { public static class BundleLoader { [Obsolete("Use OnLoadedBundles instead. This will be removed/private in a future update.")] public delegate void OnLoadedAssetsDelegate(); [Obsolete("Use GetLoadedAsset instead. This will be removed/private in a future update.")] public static ConcurrentDictionary<string, Object> assets = new ConcurrentDictionary<string, Object>(); [Obsolete("Use OnLoadedBundles instead. This will be removed/private in a future update.")] public static OnLoadedAssetsDelegate OnLoadedAssets = LoadAssetsCompleted; public static bool AssetsInLegacyDirectory { get; private set; } public static bool LegacyLoadingEnabled { get; private set; } public static event Action OnLoadedBundles; internal static void Load(bool legacyLoading) { LegacyLoadingEnabled = legacyLoading; Plugin.Log.LogMessage((object)"BundleAPI will now load all asset bundles..."); string path = Path.Combine(Paths.BepInExRootPath, "Bundles"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); Plugin.Log.LogMessage((object)"BundleAPI Created legacy bundle directory in BepInEx/Bundles"); } string[] array = (from x in Directory.GetFiles(path, "*", SearchOption.AllDirectories) where !x.EndsWith(".manifest", StringComparison.CurrentCultureIgnoreCase) select x).ToArray(); AssetsInLegacyDirectory = array.Length != 0; if (!AssetsInLegacyDirectory) { Plugin.Log.LogMessage((object)"BundleAPI got no assets to load from legacy directory"); } if (AssetsInLegacyDirectory) { Plugin.Log.LogWarning((object)"The path BepInEx > Bundles is outdated and should not be used anymore! Bundles will be loaded from BepInEx > plugins from now on"); LoadAllAssetsFromDirectory(array, legacyLoading); } string[] invalidEndings = new string[8] { ".dll", ".json", ".png", ".md", ".old", ".txt", ".exe", ".lem" }; path = Path.Combine(Paths.BepInExRootPath, "plugins"); array = (from file in Directory.GetFiles(path, "*", SearchOption.AllDirectories) where !invalidEndings.Any((string ending) => file.EndsWith(ending, StringComparison.CurrentCultureIgnoreCase)) select file).ToArray(); byte[] bytes = Encoding.ASCII.GetBytes("UnityFS"); List<string> list = new List<string>(); string[] array2 = array; foreach (string text in array2) { byte[] array3 = new byte[bytes.Length]; using (FileStream fileStream = File.Open(text, FileMode.Open)) { fileStream.Read(array3, 0, array3.Length); } if (array3.SequenceEqual(bytes)) { list.Add(text); } } array = list.ToArray(); if (array.Length == 0) { Plugin.Log.LogMessage((object)"BundleAPI got no assets to load from plugins folder"); } else { LoadAllAssetsFromDirectory(array, legacyLoading); } OnLoadedAssets.InvokeParameterlessDelegate(); BundleLoader.OnLoadedBundles.InvokeActionSafe(); } private static void LoadAllAssetsFromDirectory(string[] array, bool legacyLoading) { if (legacyLoading) { Plugin.Log.LogMessage((object)("BundleAPI got " + array.Length + " AssetBundles to load!")); for (int i = 0; i < array.Length; i++) { try { SaveAsset(array[i], legacyLoading); } catch (Exception) { Plugin.Log.LogError((object)("Failed to load an assetbundle! Path: " + array[i])); } } return; } Plugin.Log.LogMessage((object)("BundleAPI got " + array.Length + " AssetBundles to load!")); for (int j = 0; j < array.Length; j++) { try { SaveAsset(array[j], legacyLoading); } catch (Exception) { Plugin.Log.LogError((object)("Failed to load an assetbundle! Path: " + array[j])); } } } public static void SaveAsset(string path, bool legacyLoad) { AssetBundle val = AssetBundle.LoadFromFile(path); try { string[] allAssetNames = val.GetAllAssetNames(); foreach (string text in allAssetNames) { Plugin.Log.LogMessage((object)("Got asset for load: " + text)); Object val2 = val.LoadAsset(text); if (val2 == (Object)null) { Plugin.Log.LogWarning((object)$"Skipped/failed loading an asset (from bundle '{((Object)val).name}') - Asset path: {val2}"); continue; } string key = (legacyLoad ? text.ToUpper() : text.ToLower()); if (assets.ContainsKey(key)) { Plugin.Log.LogError((object)"BundleAPI got duplicate asset!"); break; } assets.TryAdd(key, val2); Plugin.Log.LogMessage((object)("Loaded asset: " + val2.name)); } } finally { if (val != null) { val.Unload(false); } } } public static TAsset GetLoadedAsset<TAsset>(string itemPath) where TAsset : Object { Object value = null; if (LegacyLoadingEnabled) { assets.TryGetValue(itemPath.ToUpper(), out value); } if (value == (Object)null) { assets.TryGetValue(itemPath.ToLower(), out value); } return (TAsset)(object)value; } private static void LoadAssetsCompleted() { Plugin.Log.LogMessage((object)"BundleAPI finished loading all assets."); } static BundleLoader() { BundleLoader.OnLoadedBundles = LoadAssetsCompleted; } } }
Lethal Company Mod - HD/BepInEx/plugins/ShipLoot/ShipLoot.dll
Decompiled 11 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; 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 BepInEx; using BepInEx.Logging; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.InputSystem; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("ShipLoot")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyProduct("ShipLoot")] [assembly: AssemblyCopyright("Copyright © tinyhoot 2023")] [assembly: ComVisible(false)] [assembly: AssemblyFileVersion("1.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace ShipLoot { [BepInPlugin("com.github.tinyhoot.ShipLoot", "ShipLoot", "1.0")] internal class ShipLoot : BaseUnityPlugin { public const string GUID = "com.github.tinyhoot.ShipLoot"; public const string NAME = "ShipLoot"; public const string VERSION = "1.0"; internal static ManualLogSource Log; private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; new Harmony("com.github.tinyhoot.ShipLoot").PatchAll(Assembly.GetExecutingAssembly()); } } } namespace ShipLoot.Patches { [HarmonyPatch] internal class HudManagerPatcher { private static GameObject _totalCounter; private static TextMeshProUGUI _textMesh; private static float _displayTimeLeft; private const float DisplayTime = 5f; [HarmonyPrefix] [HarmonyPatch(typeof(HUDManager), "PingScan_performed")] private static void OnScan(HUDManager __instance, CallbackContext context) { if (!((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null) && ((CallbackContext)(ref context)).performed && __instance.CanPlayerScan() && !(__instance.playerPingingScan > -0.5f) && (StartOfRound.Instance.inShipPhase || GameNetworkManager.Instance.localPlayerController.isInHangarShipRoom)) { if (!Object.op_Implicit((Object)(object)_totalCounter)) { CopyValueCounter(); } float num = CalculateLootValue(); ((TMP_Text)_textMesh).text = $"SHIP: ${num:F0}"; _displayTimeLeft = 5f; if (!_totalCounter.activeSelf) { ((MonoBehaviour)GameNetworkManager.Instance).StartCoroutine(ShipLootCoroutine()); } } } private static IEnumerator ShipLootCoroutine() { _totalCounter.SetActive(true); while (_displayTimeLeft > 0f) { float displayTimeLeft = _displayTimeLeft; _displayTimeLeft = 0f; yield return (object)new WaitForSeconds(displayTimeLeft); } _totalCounter.SetActive(false); } private static float CalculateLootValue() { List<GrabbableObject> list = (from obj in GameObject.Find("/Environment/HangarShip").GetComponentsInChildren<GrabbableObject>() where ((Object)obj).name != "ClipboardManual" && ((Object)obj).name != "StickyNoteItem" select obj).ToList(); ShipLoot.Log.LogDebug((object)"Calculating total ship scrap value."); CollectionExtensions.Do<GrabbableObject>((IEnumerable<GrabbableObject>)list, (Action<GrabbableObject>)delegate(GrabbableObject scrap) { ShipLoot.Log.LogDebug((object)$"{((Object)scrap).name} - ${scrap.scrapValue}"); }); return list.Sum((GrabbableObject scrap) => scrap.scrapValue); } private static void CopyValueCounter() { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.Find("/Systems/UI/Canvas/IngamePlayerHUD/BottomMiddle/ValueCounter"); if (!Object.op_Implicit((Object)(object)val)) { ShipLoot.Log.LogError((object)"Failed to find ValueCounter object to copy!"); } _totalCounter = Object.Instantiate<GameObject>(val.gameObject, val.transform.parent, false); _totalCounter.transform.Translate(0f, 1f, 0f); Vector3 localPosition = _totalCounter.transform.localPosition; _totalCounter.transform.localPosition = new Vector3(localPosition.x + 50f, -50f, localPosition.z); _textMesh = _totalCounter.GetComponentInChildren<TextMeshProUGUI>(); } } }
Lethal Company Mod - HD/BepInEx/plugins/Walkie.dll
Decompiled 11 months agousing System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; [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("Walkie")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("My first plugin")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+343d6574f91124fc6d07c26b80f76f9a052bb1f2")] [assembly: AssemblyProduct("Walkie")] [assembly: AssemblyTitle("Walkie")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [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; } } } namespace Walkie { [BepInPlugin("rr.Walkie", "WalkieUse", "1.3.0")] [HarmonyPatch(typeof(PlayerControllerB))] public class WalkieToggle : BaseUnityPlugin { private static string path = Application.persistentDataPath + "/walkiebutton.txt"; internal static ManualLogSource logSource; private static InputActionAsset asset; private static string defaultkey = "/Keyboard/r"; private Harmony _harmony = new Harmony("Walkie"); private void Awake() { _harmony.PatchAll(typeof(WalkieToggle)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"------Walkie done.------"); logSource = ((BaseUnityPlugin)this).Logger; } public static void setAsset(string thing) { asset = InputActionAsset.FromJson("\r\n {\r\n \"maps\" : [\r\n {\r\n \"name\" : \"Walkie\",\r\n \"actions\": [\r\n {\"name\": \"togglew\", \"type\" : \"button\"}\r\n ],\r\n \"bindings\" : [\r\n {\"path\" : \"" + thing + "\", \"action\": \"togglew\"}\r\n ]\r\n }\r\n ]\r\n }"); } [HarmonyPatch(typeof(IngamePlayerSettings), "CompleteRebind")] [HarmonyPrefix] public static void SavingToFile(IngamePlayerSettings __instance) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (!(__instance.rebindingOperation.action.name != "togglew")) { File.WriteAllText(path, __instance.rebindingOperation.action.controls[0].path); string text = defaultkey; if (File.Exists(path)) { text = File.ReadAllText(path); } setAsset(text); } } [HarmonyPatch(typeof(KepRemapPanel), "LoadKeybindsUI")] [HarmonyPrefix] public static void Testing(KepRemapPanel __instance) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown string text = defaultkey; if (!File.Exists(path)) { File.WriteAllText(path, defaultkey); } else { text = File.ReadAllText(path); } for (int i = 0; i < __instance.remappableKeys.Count; i++) { if (__instance.remappableKeys[i].ControlName == "Walkie") { return; } } RemappableKey val = new RemappableKey(); setAsset(text); InputActionReference currentInput = InputActionReference.Create(asset.FindAction("Walkie/togglew", false)); val.ControlName = "Walkie"; val.currentInput = currentInput; __instance.remappableKeys.Add(val); } [HarmonyPatch(typeof(PlayerControllerB), "Update")] [HarmonyPostfix] public static void ReadInput(PlayerControllerB __instance) { GrabbableObject val = null; if (((!((NetworkBehaviour)__instance).IsOwner || !__instance.isPlayerControlled || (((NetworkBehaviour)__instance).IsServer && !__instance.isHostPlayerObject)) && !__instance.isTestingPlayer) || __instance.inTerminalMenu || __instance.isTypingChat || ShipBuildModeManager.Instance.InBuildMode || !Application.isFocused) { return; } for (int i = 0; i < __instance.ItemSlots.Length; i++) { if (__instance.ItemSlots[i] is WalkieTalkie && __instance.ItemSlots[i].isBeingUsed) { val = __instance.ItemSlots[i]; break; } } if ((Object)(object)val == (Object)null) { return; } string text = defaultkey; if (!File.Exists(path)) { File.WriteAllText(path, defaultkey); } else { text = File.ReadAllText(path); } if (!Object.op_Implicit((Object)(object)asset) || !asset.enabled) { setAsset(text); asset.Enable(); } if (asset.FindAction("Walkie/togglew", false).WasPressedThisFrame()) { try { if (__instance.currentlyHeldObjectServer is WalkieTalkie) { __instance.currentlyHeldObjectServer.UseItemOnClient(true); } else if ((Object)(object)val != (Object)null) { val.UseItemOnClient(true); } } catch { } } if (!asset.FindAction("Walkie/togglew", false).WasReleasedThisFrame()) { return; } try { if (__instance.currentlyHeldObjectServer is WalkieTalkie) { __instance.currentlyHeldObjectServer.UseItemOnClient(false); } else if ((Object)(object)val != (Object)null) { val.UseItemOnClient(false); } } catch { } } } public static class PluginInfo { public const string PLUGIN_GUID = "Walkie"; public const string PLUGIN_NAME = "Walkie"; public const string PLUGIN_VERSION = "1.0.0"; } }