Please disclose if your mod was created primarily using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of boyz pacc v1.4.0
plugins/LCBetterSaves.dll
Decompiled 2 years agousing System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using HarmonyLib; using LCBetterSaves; using LCBetterSaves.Properties; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [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("LCBetterSaves")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Better save files for Lethal Company")] [assembly: AssemblyFileVersion("1.4.0.0")] [assembly: AssemblyInformationalVersion("1.4.0+c4704fdbef04f8b1a1445fc922475f8ee41eee5e")] [assembly: AssemblyProduct("LCBetterSaves")] [assembly: AssemblyTitle("LCBetterSaves")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.4.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; } } } public class NewFileUISlot_BetterSaves : MonoBehaviour { public Animator buttonAnimator; public Button button; public bool isSelected; public void Awake() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown buttonAnimator = ((Component)this).GetComponent<Animator>(); button = ((Component)this).GetComponent<Button>(); ((UnityEvent)button.onClick).AddListener(new UnityAction(SetFileToThis)); } public void SetFileToThis() { string currentSaveFileName = "LCSaveFile" + Plugin.newSaveFileNum; GameNetworkManager.Instance.currentSaveFileName = currentSaveFileName; GameNetworkManager.Instance.saveFileNum = Plugin.newSaveFileNum; SetButtonColorForAllFileSlots(); isSelected = true; SetButtonColor(); } public void SetButtonColorForAllFileSlots() { SaveFileUISlot_BetterSaves[] array = Object.FindObjectsOfType<SaveFileUISlot_BetterSaves>(); SaveFileUISlot_BetterSaves[] array2 = array; foreach (SaveFileUISlot_BetterSaves saveFileUISlot_BetterSaves in array2) { saveFileUISlot_BetterSaves.SetButtonColor(); saveFileUISlot_BetterSaves.deleteButton.SetActive(false); saveFileUISlot_BetterSaves.renameButton.SetActive(false); } } public void SetButtonColor() { buttonAnimator.SetBool("isPressed", isSelected); } } public class SaveFileUISlot_BetterSaves : MonoBehaviour { public Animator buttonAnimator; public Button button; public TextMeshProUGUI fileStatsText; public int fileNum; public string fileString; public TextMeshProUGUI fileNotCompatibleAlert; public GameObject deleteButton; public GameObject renameButton; public void Awake() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown buttonAnimator = ((Component)this).GetComponent<Animator>(); button = ((Component)this).GetComponent<Button>(); ((UnityEvent)button.onClick).AddListener(new UnityAction(SetFileToThis)); fileStatsText = ((Component)((Component)this).transform.GetChild(2)).GetComponent<TextMeshProUGUI>(); fileNotCompatibleAlert = ((Component)((Component)this).transform.GetChild(4)).GetComponent<TextMeshProUGUI>(); deleteButton = ((Component)((Component)this).transform.GetChild(3)).gameObject; } public void Start() { UpdateStats(); } private void OnEnable() { if (!Object.FindObjectOfType<MenuManager>().filesCompatible[fileNum]) { ((Behaviour)fileNotCompatibleAlert).enabled = true; } } public void UpdateStats() { try { if (ES3.FileExists(fileString)) { int num = ES3.Load<int>("GroupCredits", fileString, 30); int num2 = ES3.Load<int>("Stats_DaysSpent", fileString, 0); ((TMP_Text)fileStatsText).text = $"${num}\nDays: {num2}"; } else { ((TMP_Text)fileStatsText).text = ""; } } catch (Exception ex) { Debug.LogError((object)("Error updating stats: " + ex.Message)); } } public void SetButtonColor() { buttonAnimator.SetBool("isPressed", GameNetworkManager.Instance.currentSaveFileName == fileString); } public void SetFileToThis() { Plugin.fileToModify = fileNum; GameNetworkManager.Instance.currentSaveFileName = fileString; GameNetworkManager.Instance.saveFileNum = fileNum; SetButtonColorForAllFileSlots(); } public void SetButtonColorForAllFileSlots() { SaveFileUISlot_BetterSaves[] array = Object.FindObjectsOfType<SaveFileUISlot_BetterSaves>(); SaveFileUISlot_BetterSaves[] array2 = array; foreach (SaveFileUISlot_BetterSaves saveFileUISlot_BetterSaves in array2) { saveFileUISlot_BetterSaves.SetButtonColor(); saveFileUISlot_BetterSaves.deleteButton.SetActive((Object)(object)saveFileUISlot_BetterSaves == (Object)(object)this); saveFileUISlot_BetterSaves.renameButton.SetActive((Object)(object)saveFileUISlot_BetterSaves == (Object)(object)this); } NewFileUISlot_BetterSaves newFileUISlot_BetterSaves = Object.FindObjectOfType<NewFileUISlot_BetterSaves>(); newFileUISlot_BetterSaves.isSelected = false; newFileUISlot_BetterSaves.SetButtonColor(); } } public class RenameFileButton_BetterSaves : MonoBehaviour { public void RenameFile() { string text = $"LCSaveFile{Plugin.fileToModify}"; string text2 = GameObject.Find("Canvas/MenuContainer/LobbyHostSettings/Panel/LobbyHostOptions/OptionsNormal/ServerNameField/Text Area/Text").GetComponent<TMP_Text>().text; if (ES3.FileExists(text)) { ES3.Save<string>("Alias_BetterSaves", text2, text); Debug.Log((object)("Granted alias " + text2 + " to file " + text)); } Plugin.RefreshNameFields(); } } public class DeleteFileButton_BetterSaves : MonoBehaviour { public int fileToDelete; public AudioClip deleteFileSFX; public TextMeshProUGUI deleteFileText; public void UpdateFileToDelete() { fileToDelete = Plugin.fileToModify; if (ES3.Load<string>("Alias_BetterSaves", $"LCSaveFile{fileToDelete}", "") != "") { ((TMP_Text)deleteFileText).text = "Do you want to delete file (" + ES3.Load<string>("Alias_BetterSaves", $"LCSaveFile{fileToDelete}", "") + ")?"; } else { ((TMP_Text)deleteFileText).text = $"Do you want to delete File {fileToDelete + 1}?"; } } public void DeleteFile() { string text = $"LCSaveFile{fileToDelete}"; if (ES3.FileExists(text)) { ES3.DeleteFile(text); Object.FindObjectOfType<MenuManager>().MenuAudio.PlayOneShot(deleteFileSFX); } SaveFileUISlot_BetterSaves[] array = Object.FindObjectsOfType<SaveFileUISlot_BetterSaves>(true); SaveFileUISlot_BetterSaves[] array2 = array; foreach (SaveFileUISlot_BetterSaves saveFileUISlot_BetterSaves in array2) { Debug.Log((object)$"Deleted {fileToDelete}"); if (saveFileUISlot_BetterSaves.fileNum == fileToDelete) { ((Behaviour)saveFileUISlot_BetterSaves.fileNotCompatibleAlert).enabled = false; Object.FindObjectOfType<MenuManager>().filesCompatible[fileToDelete] = true; } } Plugin.InitializeBetterSaves(); } } namespace LCBetterSaves { [BepInPlugin("LCBetterSaves", "LCBetterSaves", "1.4.0")] public class Plugin : BaseUnityPlugin { private Harmony _harmony = new Harmony("BetterSaves"); public static int fileToModify = -1; public static int newSaveFileNum; public static Sprite renameSprite; public static MenuManager menuManager; public static AudioClip deleteFileSFX; public static TextMeshProUGUI deleteFileText; public static float buttonBaseY; public void Awake() { _harmony.PatchAll(typeof(Plugin)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin LCBetterSaves is loaded!"); } [HarmonyPatch(typeof(MenuManager), "Start")] public static void Postfix(MenuManager __instance) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) menuManager = __instance; if ((Object)(object)renameSprite == (Object)null) { AssetBundle val = AssetBundle.LoadFromMemory(Resources.lcbettersaves); Texture2D val2 = val.LoadAsset<Texture2D>("Assets/RenameSprite.png"); renameSprite = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f)); } InitializeBetterSaves(); } public static void InitializeBetterSaves() { try { DestroyBetterSavesButtons(); DestroyOriginalSaveButtons(); UpdateTopText(); CreateModdedDeleteFileButton(); CreateBetterSaveButtons(); UpdateFilesPanelRect(CountSaveFiles()); } catch (Exception ex) { Debug.LogError((object)("An error occurred during initialization: " + ex.Message)); } } public static void DestroyBetterSavesButtons() { try { SaveFileUISlot_BetterSaves[] array = Object.FindObjectsOfType<SaveFileUISlot_BetterSaves>(); foreach (SaveFileUISlot_BetterSaves saveFileUISlot_BetterSaves in array) { Object.Destroy((Object)(object)((Component)saveFileUISlot_BetterSaves).gameObject); } NewFileUISlot_BetterSaves[] array2 = Object.FindObjectsOfType<NewFileUISlot_BetterSaves>(); foreach (NewFileUISlot_BetterSaves newFileUISlot_BetterSaves in array2) { Object.Destroy((Object)(object)((Component)newFileUISlot_BetterSaves).gameObject); } } catch (Exception ex) { Debug.LogError((object)("Error occurred while destroying better saves buttons: " + ex.Message)); } } public static void UpdateTopText() { GameObject val = GameObject.Find("Canvas/MenuContainer/LobbyHostSettings/FilesPanel/EnterAName"); if ((Object)(object)val == (Object)null) { Debug.LogError((object)"Panel label not found."); } else { ((TMP_Text)val.GetComponent<TextMeshProUGUI>()).text = "BetterSaves"; } } public static void CreateModdedDeleteFileButton() { //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown GameObject val = GameObject.Find("Canvas/MenuContainer/DeleteFileConfirmation/Panel/Delete"); if ((Object)(object)val == (Object)null) { Debug.LogError((object)"Delete file game object not found."); return; } if ((Object)(object)val.GetComponent<DeleteFileButton_BetterSaves>() != (Object)null) { Debug.LogWarning((object)"DeleteFileButton_BetterSaves component already exists on deleteFileGO"); return; } DeleteFileButton component = val.GetComponent<DeleteFileButton>(); if ((Object)(object)component == (Object)null) { Debug.LogError((object)"DeleteFileButton component not found on deleteFileGO"); return; } if ((Object)(object)deleteFileSFX == (Object)null) { deleteFileSFX = component.deleteFileSFX; } if ((Object)(object)deleteFileText == (Object)null) { deleteFileText = component.deleteFileText; } Object.Destroy((Object)(object)component); if ((Object)(object)val.GetComponent<DeleteFileButton_BetterSaves>() == (Object)null) { DeleteFileButton_BetterSaves deleteFileButton_BetterSaves = val.AddComponent<DeleteFileButton_BetterSaves>(); deleteFileButton_BetterSaves.deleteFileSFX = deleteFileSFX; deleteFileButton_BetterSaves.deleteFileText = deleteFileText; Button component2 = val.GetComponent<Button>(); if ((Object)(object)component2 != (Object)null) { ((UnityEventBase)component2.onClick).RemoveAllListeners(); ((UnityEvent)component2.onClick).AddListener(new UnityAction(deleteFileButton_BetterSaves.DeleteFile)); } else { Debug.LogError((object)"Button component not found on deleteFileGO"); } } else { Debug.LogWarning((object)"DeleteFileButton_BetterSaves component already exists on deleteFileGO"); } } public static void CreateBetterSaveButtons() { try { GameObject val = GameObject.Find("Canvas/MenuContainer/LobbyHostSettings/FilesPanel/File1"); val.SetActive(true); int numSaves = CountSaveFiles(); Debug.Log((object)("Positioning based on " + numSaves + " saves.")); NewFileUISlot_BetterSaves newFileUISlot_BetterSaves = CreateNewFileNode(numSaves); List<string> list = NormalizeFileNames(); newSaveFileNum = list.Count; menuManager.filesCompatible = new bool[16]; for (int i = 0; i < menuManager.filesCompatible.Length; i++) { menuManager.filesCompatible[i] = true; } for (int j = 0; j < list.Count; j++) { CreateModdedSaveNode(int.Parse(list[j].Replace("LCSaveFile", "")), j, ((Component)newFileUISlot_BetterSaves).gameObject); } val.SetActive(false); } catch (Exception ex) { Debug.LogError((object)("Error occurred while refreshing save buttons: " + ex.Message)); } } public static NewFileUISlot_BetterSaves CreateNewFileNode(int numSaves) { //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.Find("Canvas/MenuContainer/LobbyHostSettings/FilesPanel/File1"); if ((Object)(object)val == (Object)null) { Debug.LogError((object)"Original GameObject not found."); return null; } Transform parent = val.transform.parent; SaveFileUISlot component = val.GetComponent<SaveFileUISlot>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } GameObject val2 = Object.Instantiate<GameObject>(val, parent); ((Object)val2).name = "NewFile"; TMP_Text component2 = ((Component)val2.transform.GetChild(1)).GetComponent<TMP_Text>(); if ((Object)(object)component2 != (Object)null) { component2.text = "New File"; NewFileUISlot_BetterSaves newFileUISlot_BetterSaves = val2.AddComponent<NewFileUISlot_BetterSaves>(); if ((Object)(object)newFileUISlot_BetterSaves == (Object)null) { Debug.LogError((object)"Failed to add NewFileUISlot_BetterSaves component."); return null; } Transform child = val2.transform.GetChild(3); if ((Object)(object)child != (Object)null) { Object.Destroy((Object)(object)((Component)child).gameObject); try { RectTransform component3 = val2.GetComponent<RectTransform>(); if (!((Object)(object)component3 != (Object)null)) { Debug.LogError((object)"RectTransform component not found."); return null; } float x = component3.anchoredPosition.x; if (buttonBaseY == 0f) { buttonBaseY = component3.anchoredPosition.y - component3.sizeDelta.y * 1.75f; } float num = buttonBaseY + component3.sizeDelta.y * (float)numSaves / 2f; component3.anchoredPosition = new Vector2(x, num); } catch (Exception ex) { Debug.LogError((object)("Error setting anchored position: " + ex.Message)); return null; } return newFileUISlot_BetterSaves; } Debug.LogError((object)"Delete button not found."); return null; } Debug.LogError((object)"Text component not found."); return null; } private static int CountSaveFiles() { int num = 0; string[] files = ES3.GetFiles(); foreach (string text in files) { if (ES3.FileExists(text) && text.StartsWith("LCSaveFile")) { num++; } } return num; } public static void DestroyOriginalSaveButtons() { Object.Destroy((Object)(object)GameObject.Find("Canvas/MenuContainer/LobbyHostSettings/FilesPanel/File2")); Object.Destroy((Object)(object)GameObject.Find("Canvas/MenuContainer/LobbyHostSettings/FilesPanel/File3")); } public static List<string> NormalizeFileNames() { List<string> list = new List<string>(); List<string> list2 = new List<string>(); string[] files = ES3.GetFiles(); foreach (string text in files) { if (ES3.FileExists(text) && text.StartsWith("LCSaveFile")) { Debug.Log((object)("Found file: " + text)); list.Add(text); } if (ES3.FileExists(text) && text.StartsWith("LGU")) { Debug.Log((object)("Found LGU file: " + text)); list2.Add(text); } else if (ES3.FileExists(text) && text.StartsWith("LCSaveFile")) { list2.Add("placeholder"); } } int num = 0; foreach (string item in list) { string text2 = "TempFile" + num; ES3.RenameFile(item, text2); Debug.Log((object)("Renamed " + item + " to " + text2)); num++; } num = 0; foreach (string item2 in list2) { if (item2 == "placeholder") { num++; continue; } string text3 = "LGUTempFile" + num; ES3.RenameFile(item2, text3); Debug.Log((object)("Renamed " + item2 + " to " + text3)); num++; } int num2 = 0; List<string> list3 = new List<string>(); foreach (string item3 in list) { string text4 = "TempFile" + num2; string text5 = "LCSaveFile" + num2; if (ES3.FileExists(text4)) { ES3.RenameFile(text4, text5); list3.Add(text5); Debug.Log((object)("Renamed " + text4 + " to " + text5)); } else { Debug.Log((object)("Temporary file " + text4 + " not found. It might have been moved or deleted.")); } num2++; } num2 = 0; List<string> list4 = new List<string>(); foreach (string item4 in list2) { string text6 = "LGUTempFile" + num2; string text7 = "LGU_" + num2; if (item4 == "placeholder") { num2++; continue; } if (ES3.FileExists(text6)) { ES3.RenameFile(text6, text7); list3.Add(text7); Debug.Log((object)("Renamed " + text6 + " to " + text7)); } else { Debug.Log((object)("Temporary file " + text6 + " not found. It might have been moved or deleted.")); } num2++; } return list3; } public static void CreateModdedSaveNode(int fileIndex, int listIndex, GameObject newFileButton) { //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Expected O, but got Unknown //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) int num = fileIndex + 1; GameObject val = GameObject.Find("Canvas/MenuContainer/LobbyHostSettings/FilesPanel/File1"); if ((Object)(object)val == (Object)null) { Debug.LogError((object)"Original GameObject not found."); return; } Transform parent = val.transform.parent; GameObject val2 = Object.Instantiate<GameObject>(val, parent); ((Object)val2).name = "File" + num + "_BetterSaves"; string text = ES3.Load<string>("Alias_BetterSaves", "LCSaveFile" + fileIndex, ""); if (text == "") { ((Component)val2.transform.GetChild(1)).GetComponent<TMP_Text>().text = "File " + num; } else { ((Component)val2.transform.GetChild(1)).GetComponent<TMP_Text>().text = text; } val2.AddComponent<SaveFileUISlot_BetterSaves>(); SaveFileUISlot_BetterSaves component = val2.GetComponent<SaveFileUISlot_BetterSaves>(); if ((Object)(object)component != (Object)null) { component.fileNum = fileIndex; component.fileString = "LCSaveFile" + fileIndex; RectTransform component2 = val2.GetComponent<RectTransform>(); if ((Object)(object)component2 != (Object)null) { float x = component2.anchoredPosition.x; float y = newFileButton.GetComponent<RectTransform>().anchoredPosition.y; float num2 = y - component2.sizeDelta.y * (float)num; component2.anchoredPosition = new Vector2(x, num2); } GameObject gameObject = ((Component)val2.transform.GetChild(3)).gameObject; DeleteFileButton_BetterSaves component3 = GameObject.Find("Canvas/MenuContainer/DeleteFileConfirmation/Panel/Delete").GetComponent<DeleteFileButton_BetterSaves>(); ((UnityEvent)gameObject.gameObject.GetComponent<Button>().onClick).AddListener(new UnityAction(component3.UpdateFileToDelete)); gameObject.SetActive(false); component.renameButton = CreateRenameFileButton(val2); } else { Debug.LogError((object)"SaveFileUISlot_BetterSaves component not found on the cloned GameObject."); Object.Destroy((Object)(object)val2); } } public static GameObject CreateRenameFileButton(GameObject fileNode) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) try { GameObject gameObject = ((Component)fileNode.transform.GetChild(3)).gameObject; GameObject val = Object.Instantiate<GameObject>(gameObject, fileNode.transform); ((Object)val).name = "RenameButton"; val.GetComponent<Image>().sprite = renameSprite; Button component = val.GetComponent<Button>(); component.onClick = new ButtonClickedEvent(); val.AddComponent<RenameFileButton_BetterSaves>(); RenameFileButton_BetterSaves component2 = val.GetComponent<RenameFileButton_BetterSaves>(); if ((Object)(object)component2 != (Object)null) { ((UnityEvent)component.onClick).AddListener(new UnityAction(component2.RenameFile)); } else { Debug.LogError((object)"RenameFileButton_BetterSaves component not found on renameButton"); } RectTransform component3 = val.GetComponent<RectTransform>(); if ((Object)(object)component3 != (Object)null) { float num = ((Transform)component3).localPosition.x + 20f; float y = ((Transform)component3).localPosition.y; ((Transform)component3).localPosition = Vector2.op_Implicit(new Vector2(num, y)); } val.SetActive(false); return val; } catch (Exception ex) { Debug.LogError((object)("Error occurred while creating rename file button: " + ex.Message)); return null; } } public static void UpdateFilesPanelRect(int numSaves) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) try { GameObject obj = GameObject.Find("Canvas/MenuContainer/LobbyHostSettings/FilesPanel"); RectTransform val = ((obj != null) ? obj.GetComponent<RectTransform>() : null); if ((Object)(object)val == (Object)null) { throw new Exception("Failed to find FilesPanel RectTransform."); } Vector2 sizeDelta = val.sizeDelta; GameObject obj2 = GameObject.Find("Canvas/MenuContainer/LobbyHostSettings/FilesPanel/File1"); RectTransform val2 = ((obj2 != null) ? obj2.GetComponent<RectTransform>() : null); if ((Object)(object)val2 == (Object)null) { throw new Exception("Failed to find File1 RectTransform."); } float y = val2.sizeDelta.y; sizeDelta.y = y * (float)(numSaves + 3); val.sizeDelta = sizeDelta; } catch (Exception ex) { Debug.LogError((object)("Error occurred while updating files panel rect: " + ex.Message)); } } public static void RefreshNameFields() { SaveFileUISlot_BetterSaves[] array = Object.FindObjectsOfType<SaveFileUISlot_BetterSaves>(); SaveFileUISlot_BetterSaves[] array2 = array; foreach (SaveFileUISlot_BetterSaves saveFileUISlot_BetterSaves in array2) { string text = ES3.Load<string>("Alias_BetterSaves", saveFileUISlot_BetterSaves.fileString, ""); if (text == "") { ((Component)((Component)saveFileUISlot_BetterSaves).transform.GetChild(1)).GetComponent<TMP_Text>().text = "File " + (saveFileUISlot_BetterSaves.fileNum + 1); } else { ((Component)((Component)saveFileUISlot_BetterSaves).transform.GetChild(1)).GetComponent<TMP_Text>().text = text; } } } } public static class PluginInfo { public const string PLUGIN_GUID = "LCBetterSaves"; public const string PLUGIN_NAME = "LCBetterSaves"; public const string PLUGIN_VERSION = "1.4.0"; } } namespace LCBetterSaves.Properties { [GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [DebuggerNonUserCode] [CompilerGenerated] public class Resources { private static ResourceManager resourceMan; private static CultureInfo resourceCulture; [EditorBrowsable(EditorBrowsableState.Advanced)] public static ResourceManager ResourceManager { get { if (resourceMan == null) { ResourceManager resourceManager = new ResourceManager("LCBetterSaves.Properties.Resources", typeof(Resources).Assembly); resourceMan = resourceManager; } return resourceMan; } } [EditorBrowsable(EditorBrowsableState.Advanced)] public static CultureInfo Culture { get { return resourceCulture; } set { resourceCulture = value; } } public static byte[] lcbettersaves { get { object @object = ResourceManager.GetObject("lcbettersaves", resourceCulture); return (byte[])@object; } } internal Resources() { } } }
plugins/VoiceHUD.dll
Decompiled 2 years 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.Configuration; using BepInEx.Logging; using Dissonance; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.UI; using VoiceHUD.Configuration; [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("VoiceHUD")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Displays push-to-talk icon on voice activation")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1+f1e0a0cfa0a629002418c9e0aa3a753676e33192")] [assembly: AssemblyProduct("VoiceHUD")] [assembly: AssemblyTitle("VoiceHUD")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.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 VoiceHUD { [BepInPlugin("5Bit.VoiceHUD", "VoiceHUD", "1.0.4")] public class VoiceHUD : BaseUnityPlugin { private const string modGUID = "5Bit.VoiceHUD"; private const string modName = "VoiceHUD"; private const string modVersion = "1.0.4"; private readonly Harmony harmony = new Harmony("5Bit.VoiceHUD"); private static VoiceHUD Instance; internal static ManualLogSource mls; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } mls = Logger.CreateLogSource("5Bit.VoiceHUD"); Config.Init(); harmony.PatchAll(); } } public static class PluginInfo { public const string PLUGIN_GUID = "VoiceHUD"; public const string PLUGIN_NAME = "VoiceHUD"; public const string PLUGIN_VERSION = "1.0.1"; } } namespace VoiceHUD.Patches { [HarmonyPatch(typeof(HUDManager))] internal class VoiceHUDPatch { private static Color Start = new Color(0f, 255f, 0f, 255f); private static Color Center = new Color(165f, 255f, 0f, 255f); private static Color End = new Color(255f, 0f, 0f, 255f); [HarmonyPatch("Update")] [HarmonyPostfix] private static void Update() { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) if (!IngamePlayerSettings.Instance.settings.micEnabled || IngamePlayerSettings.Instance.settings.pushToTalk || (Object)(object)StartOfRound.Instance.voiceChatModule == (Object)null) { return; } VoicePlayerState val = StartOfRound.Instance.voiceChatModule.FindPlayer(StartOfRound.Instance.voiceChatModule.LocalPlayerName); if (val.IsSpeaking) { float num = Mathf.Clamp(val.Amplitude * 35f, 0f, 1f); if (Config.ColorsEnabled) { ((Graphic)HUDManager.Instance.PTTIcon).color = GetColorByVolume(num * 100f); } ((Behaviour)HUDManager.Instance.PTTIcon).enabled = num > 0.01f; } } public static Color GetColorByVolume(float volume) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (volume < 20f) { return Start; } if (volume > 70f) { return End; } return Center; } } } namespace VoiceHUD.Configuration { internal static class Config { private const string CONFIG_FILE_NAME = "VoiceHUD.cfg"; private static ConfigFile config; private static ConfigEntry<bool> colorsEnabled; public static bool ColorsEnabled => colorsEnabled.Value; public static void Init() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown string text = Path.Combine(Paths.ConfigPath, "VoiceHUD.cfg"); config = new ConfigFile(text, true); colorsEnabled = config.Bind<bool>("Config", "Colors enabled", false, "Change icon color based on volume."); } } }
plugins/AdditionalSuits.dll
Decompiled 2 years 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.Logging; using HarmonyLib; 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("AdditionalSuits")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("AdditionalSuits")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("0c25b026-8574-4dd2-9af2-4265f618ef8a")] [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 AdditionalSuits; [Serializable] public class UnlockableSuitDef { public string suitID; public string suitName; public string suitTexture; } public class UnlockableSuitDefListing { public List<UnlockableSuitDef> unlockableSuits = new List<UnlockableSuitDef>(); } [BepInPlugin("ACS.AdditionalSuits", "AdditionalSuits", "1.1.1")] public class AdditionalSuitsBase : BaseUnityPlugin { [HarmonyPatch(typeof(StartOfRound))] internal class StartOfRoundPatch { [HarmonyPatch("Start")] [HarmonyPrefix] private static void StartPatch(ref StartOfRound __instance) { //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Expected O, but got Unknown try { if (SuitsLoaded) { return; } UnlockableItem val = null; for (int i = 0; i < __instance.unlockablesList.unlockables.Count; i++) { UnlockableItem val2 = __instance.unlockablesList.unlockables[i]; if (!((Object)(object)val2.suitMaterial == (Object)null) && val2.alreadyUnlocked) { val = val2; break; } } string text = Path.Combine(ModResourceFolder, "suit-defs.json"); mls.LogInfo((object)("AdditionalSuits - attempting to parse json file: " + text)); string text2 = File.ReadAllText(text); if (text2 == null) { mls.LogInfo((object)"AdditionalSuits - ERROR: json file was not found"); return; } mls.LogInfo((object)"AdditionalSuits - converting json file to manifest..."); string[] array = text2.Split(new char[1] { '[' }); array = array[1].Split(new char[1] { ']' }); array = array[0].Split(new char[1] { '{' }); SuitDefManifest = new UnlockableSuitDefListing(); for (int j = 1; j < array.Length; j++) { string text3 = "{" + array[j].Trim(); if (j != array.Length - 1) { text3 = text3.Substring(0, text3.Length - 1); } UnlockableSuitDef item = JsonUtility.FromJson<UnlockableSuitDef>(text3); SuitDefManifest.unlockableSuits.Add(item); } mls.LogInfo((object)("AdditionalSuits - loading item defs from manifest, " + SuitDefManifest.unlockableSuits.Count + " items were found...")); foreach (UnlockableSuitDef unlockableSuit in SuitDefManifest.unlockableSuits) { mls.LogInfo((object)("AdditionalSuits - processing custom suit {id=" + unlockableSuit.suitID + ", name=" + unlockableSuit.suitName + "}...")); UnlockableItem val3 = JsonUtility.FromJson<UnlockableItem>(JsonUtility.ToJson((object)val)); Texture2D val4 = new Texture2D(2, 2); ImageConversion.LoadImage(val4, File.ReadAllBytes(Path.Combine(ModResourceFolder, unlockableSuit.suitTexture))); Material val5 = Object.Instantiate<Material>(val3.suitMaterial); val5.mainTexture = (Texture)(object)val4; val3.suitMaterial = val5; val3.unlockableName = unlockableSuit.suitName; __instance.unlockablesList.unlockables.Add(val3); mls.LogInfo((object)("AdditionalSuits - added custom suit {id=" + unlockableSuit.suitID + ", name=" + unlockableSuit.suitName + "}!")); } mls.LogInfo((object)"AdditionalSuits - loaded item defs from json file!"); SuitsLoaded = true; } catch (Exception ex) { mls.LogInfo((object)("AdditionalSuits - initialization failed!\nERROR: " + ex)); } } } private static AdditionalSuitsBase Instance; private const string modGUID = "ACS.AdditionalSuits"; private const string modName = "AdditionalSuits"; private const string modVersion = "1.1.1"; private readonly Harmony harmony = new Harmony("ACS.AdditionalSuits"); public static ManualLogSource mls; public static bool SuitsLoaded; public static string ModResourceFolder; public static UnlockableSuitDefListing SuitDefManifest; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } mls = Logger.CreateLogSource("ACS.AdditionalSuits"); mls.LogInfo((object)"AdditionalSuits - initializing..."); ModResourceFolder = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "resAdditionalSuits"); harmony.PatchAll(); mls.LogInfo((object)"AdditionalSuits - initialized!"); } }
plugins/AlwaysHearWalkie.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; 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 LCAlwaysHearWalkieMod.Patches; using Microsoft.CodeAnalysis; using UnityEngine; [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("AlwaysHearWalkie")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.4.3.0")] [assembly: AssemblyInformationalVersion("1.4.3+b44d9dd67954bb9cf96dd2ba0e84393e7774a6a0")] [assembly: AssemblyProduct("Always Hear Active Walkies")] [assembly: AssemblyTitle("AlwaysHearWalkie")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.4.3.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 BepInEx5.PluginTemplate { [BepInPlugin("suskitech.LCAlwaysHearActiveWalkie", "LC Always Hear Active Walkies", "1.4.3")] public class LCAlwaysHearWalkieMod : BaseUnityPlugin { public static ManualLogSource Log; private const string modGUID = "suskitech.LCAlwaysHearActiveWalkie"; private const string modName = "LC Always Hear Active Walkies"; private const string modVersion = "1.4.3"; private readonly Harmony harmony = new Harmony("suskitech.LCAlwaysHearActiveWalkie"); private static LCAlwaysHearWalkieMod Instance; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } Log = Logger.CreateLogSource("suskitech.LCAlwaysHearActiveWalkie"); Log.LogInfo((object)"\\ /"); Log.LogInfo((object)"/|\\"); Log.LogInfo((object)" |----|"); Log.LogInfo((object)" |[__]| Always Hear Active Walkies"); Log.LogInfo((object)" |. .| Version 1.4.3 Loaded"); Log.LogInfo((object)" |____|"); harmony.PatchAll(typeof(LCAlwaysHearWalkieMod)); harmony.PatchAll(typeof(PlayerControllerBPatch)); harmony.PatchAll(typeof(WalkieTalkiePatch)); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "AlwaysHearWalkie"; public const string PLUGIN_NAME = "Always Hear Active Walkies"; public const string PLUGIN_VERSION = "1.4.3"; } } namespace LCAlwaysHearWalkieMod.Patches { [HarmonyPatch(typeof(PlayerControllerB))] internal class PlayerControllerBPatch { private static float AudibleDistance = 20f; private static float throttleInterval = 0.35f; private static float throttle = 0f; private static float AverageDistanceToHeldWalkie = 2f; private static float WalkieRecordingRange = 20f; private static float PlayerToPlayerSpatialHearingRange = 20f; [HarmonyPatch("Update")] [HarmonyPostfix] private static void alwaysHearWalkieTalkiesPatch(ref bool ___holdingWalkieTalkie, ref PlayerControllerB __instance) { //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) throttle += Time.deltaTime; if (throttle < throttleInterval) { return; } throttle = 0f; if ((Object)(object)__instance == (Object)null || (Object)(object)GameNetworkManager.Instance == (Object)null || (Object)(object)__instance != (Object)(object)GameNetworkManager.Instance.localPlayerController || (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null) { return; } if (!GameNetworkManager.Instance.localPlayerController.isPlayerDead) { List<WalkieTalkie> list = new List<WalkieTalkie>(); List<WalkieTalkie> list2 = new List<WalkieTalkie>(); for (int i = 0; i < WalkieTalkie.allWalkieTalkies.Count; i++) { float num = Vector3.Distance(((Component)WalkieTalkie.allWalkieTalkies[i]).transform.position, ((Component)__instance).transform.position); if (num <= AudibleDistance) { if (((GrabbableObject)WalkieTalkie.allWalkieTalkies[i]).isBeingUsed) { list.Add(WalkieTalkie.allWalkieTalkies[i]); } } else { list2.Add(WalkieTalkie.allWalkieTalkies[i]); } } bool flag = list.Count > 0; if (flag != __instance.holdingWalkieTalkie) { ___holdingWalkieTalkie = flag; for (int j = 0; j < list2.Count; j++) { if (j < list.Count) { list2[j].thisAudio.Stop(); } } } if (!flag) { return; } } PlayerControllerB val = ((!GameNetworkManager.Instance.localPlayerController.isPlayerDead || !((Object)(object)GameNetworkManager.Instance.localPlayerController.spectatedPlayerScript != (Object)null)) ? GameNetworkManager.Instance.localPlayerController : GameNetworkManager.Instance.localPlayerController.spectatedPlayerScript); for (int k = 0; k < StartOfRound.Instance.allPlayerScripts.Length; k++) { PlayerControllerB val2 = StartOfRound.Instance.allPlayerScripts[k]; if ((!val2.isPlayerControlled && !val2.isPlayerDead) || (Object)(object)val2 == (Object)(object)GameNetworkManager.Instance.localPlayerController || val2.isPlayerDead || !val2.holdingWalkieTalkie) { continue; } float num2 = Vector3.Distance(((Component)val).transform.position, ((Component)val2).transform.position); float num3 = float.MaxValue; float num4 = float.MaxValue; for (int l = 0; l < WalkieTalkie.allWalkieTalkies.Count; l++) { if (!((GrabbableObject)WalkieTalkie.allWalkieTalkies[l]).isBeingUsed) { continue; } float num5 = Vector3.Distance(((Component)WalkieTalkie.allWalkieTalkies[l].target).transform.position, ((Component)val).transform.position); if (num5 < num4) { num4 = num5; } if (!WalkieTalkie.allWalkieTalkies[l].speakingIntoWalkieTalkie) { float num6 = Vector3.Distance(((Component)WalkieTalkie.allWalkieTalkies[l]).transform.position, ((Component)val2).transform.position); if (num6 < num3) { num3 = num6; } } } float num7 = Mathf.Min(1f - Mathf.InverseLerp(AverageDistanceToHeldWalkie, WalkieRecordingRange, num3), 1f - Mathf.InverseLerp(AverageDistanceToHeldWalkie, WalkieRecordingRange, num4)); float num8 = 1f - Mathf.InverseLerp(0f, PlayerToPlayerSpatialHearingRange, num2); val2.voicePlayerState.Volume = Mathf.Max(num7, num8); if (val2.speakingToWalkieTalkie && num7 > num8) { makePlayerSoundWalkieTalkie(val2); } else { makePlayerSoundSpatial(val2); } } } private static void makePlayerSoundWalkieTalkie(PlayerControllerB playerController) { AudioSource currentVoiceChatAudioSource = playerController.currentVoiceChatAudioSource; AudioLowPassFilter component = ((Component)currentVoiceChatAudioSource).GetComponent<AudioLowPassFilter>(); AudioHighPassFilter component2 = ((Component)currentVoiceChatAudioSource).GetComponent<AudioHighPassFilter>(); OccludeAudio component3 = ((Component)currentVoiceChatAudioSource).GetComponent<OccludeAudio>(); ((Behaviour)component2).enabled = true; ((Behaviour)component).enabled = true; component3.overridingLowPass = true; currentVoiceChatAudioSource.spatialBlend = 0f; playerController.currentVoiceChatIngameSettings.set2D = true; currentVoiceChatAudioSource.outputAudioMixerGroup = SoundManager.Instance.playerVoiceMixers[playerController.playerClientId]; currentVoiceChatAudioSource.bypassListenerEffects = false; currentVoiceChatAudioSource.bypassEffects = false; currentVoiceChatAudioSource.panStereo = (GameNetworkManager.Instance.localPlayerController.isPlayerDead ? 0f : 0.4f); component3.lowPassOverride = 4000f; component.lowpassResonanceQ = 3f; } private static void makePlayerSoundSpatial(PlayerControllerB playerController) { AudioSource currentVoiceChatAudioSource = playerController.currentVoiceChatAudioSource; AudioLowPassFilter component = ((Component)currentVoiceChatAudioSource).GetComponent<AudioLowPassFilter>(); AudioHighPassFilter component2 = ((Component)currentVoiceChatAudioSource).GetComponent<AudioHighPassFilter>(); OccludeAudio component3 = ((Component)currentVoiceChatAudioSource).GetComponent<OccludeAudio>(); ((Behaviour)component2).enabled = false; ((Behaviour)component).enabled = true; component3.overridingLowPass = playerController.voiceMuffledByEnemy; currentVoiceChatAudioSource.spatialBlend = 1f; playerController.currentVoiceChatIngameSettings.set2D = false; currentVoiceChatAudioSource.bypassListenerEffects = false; currentVoiceChatAudioSource.bypassEffects = false; currentVoiceChatAudioSource.outputAudioMixerGroup = SoundManager.Instance.playerVoiceMixers[playerController.playerClientId]; component.lowpassResonanceQ = 1f; } } [HarmonyPatch(typeof(WalkieTalkie))] internal class WalkieTalkiePatch { [HarmonyPatch("EnableWalkieTalkieListening")] [HarmonyPrefix] private static bool alwaysHearWalkieTalkiesEnableWalkieTalkieListeningPatch(bool enable) { if (!enable) { return false; } return true; } } }
plugins/FovAdjust.dll
Decompiled 2 years agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Unity.Netcode; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("FovAdjust")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("FovAdjust")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("dfb6681a-9f25-4737-a7fe-10b3c23f65b3")] [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 FovAdjust; [BepInPlugin("Rozebud.FovAdjust", "FOV Adjust", "1.1.1")] public class FovAdjustBase : BaseUnityPlugin { private const string modGUID = "Rozebud.FovAdjust"; private const string modName = "FOV Adjust"; private const string modVer = "1.1.1"; private readonly Harmony harmony = new Harmony("Rozebud.FovAdjust"); private static FovAdjustBase Instance; public static ManualLogSource log; public static ConfigEntry<float> configFov; public static ConfigEntry<bool> configHideVisor; public static bool inDebugMode; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } log = Logger.CreateLogSource("Rozebud.FovAdjust"); log.LogInfo((object)"Starting."); configFov = ((BaseUnityPlugin)this).Config.Bind<float>("General", "fov", 66f, "Change the field of view of the camera. Clamped from 66 to 130 for my sanity. Also keep in mind that this is vertical FOV."); configHideVisor = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "hideVisor", false, "Changes whether the first person visor is visible."); PlayerControllerBPatches.newTargetFovBase = Mathf.Clamp(configFov.Value, 66f, 130f); PlayerControllerBPatches.hideVisor = configHideVisor.Value; log.LogInfo((object)"Configs DONE!"); PlayerControllerBPatches.calculateVisorStuff(); harmony.PatchAll(typeof(PlayerControllerBPatches)); harmony.PatchAll(typeof(HUDManagerPatches)); log.LogInfo((object)"All FOV Adjust patches have loaded successfully."); } } public class PlayerControllerBPatches { public static float newTargetFovBase = 66f; private static float prefixCamFov = 0f; public static bool hideVisor = false; private static Vector3 visorScale; public static Vector3 visorScaleBottom = new Vector3(0.68f, 0.8f, 0.95f); public static Vector3 visorScaleTop = new Vector3(0.68f, 0.35f, 0.99f); public static float linToSinLerp = 0.6f; public static float visorScaleTopRefFOV = 130f; [HarmonyPatch(typeof(PlayerControllerB), "Awake")] [HarmonyPostfix] private static void Awake_Postfix(PlayerControllerB __instance) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (!filterPlayerControllers(__instance)) { __instance.localVisor.localScale = visorScale; } } [HarmonyPatch(typeof(PlayerControllerB), "Update")] [HarmonyPrefix] private static void Update_Prefix(PlayerControllerB __instance) { //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) if (filterPlayerControllers(__instance)) { return; } prefixCamFov = __instance.gameplayCamera.fieldOfView; if (FovAdjustBase.inDebugMode) { if (((ButtonControl)Keyboard.current.minusKey).wasPressedThisFrame) { visorScale.x -= 0.00049999997f; FovAdjustBase.log.LogMessage((object)visorScale); } else if (((ButtonControl)Keyboard.current.equalsKey).wasPressedThisFrame) { visorScale.x += 0.00049999997f; FovAdjustBase.log.LogMessage((object)visorScale); } if (((ButtonControl)Keyboard.current.leftBracketKey).wasPressedThisFrame) { visorScale.y -= 0.00049999997f; FovAdjustBase.log.LogMessage((object)visorScale); } else if (((ButtonControl)Keyboard.current.rightBracketKey).wasPressedThisFrame) { visorScale.y += 0.00049999997f; FovAdjustBase.log.LogMessage((object)visorScale); } if (((ButtonControl)Keyboard.current.semicolonKey).wasPressedThisFrame) { visorScale.z -= 0.00049999997f; FovAdjustBase.log.LogMessage((object)visorScale); } else if (((ButtonControl)Keyboard.current.quoteKey).wasPressedThisFrame) { visorScale.z += 0.00049999997f; FovAdjustBase.log.LogMessage((object)visorScale); } } if (__instance.localVisor.localScale != visorScale) { __instance.localVisor.localScale = visorScale; } } [HarmonyPatch(typeof(PlayerControllerB), "Update")] [HarmonyPostfix] private static void Update_Postfix(PlayerControllerB __instance) { if (!filterPlayerControllers(__instance)) { float num = newTargetFovBase; if (__instance.inTerminalMenu) { num = 60f; } else if (__instance.IsInspectingItem) { num = 46f; } else if (__instance.isSprinting) { num *= 1.03f; } __instance.gameplayCamera.fieldOfView = Mathf.Lerp(prefixCamFov, num, 6f * Time.deltaTime); } } [HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")] [HarmonyPostfix] private static void LateUpdate_Postfix(PlayerControllerB __instance) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) if (!filterPlayerControllers(__instance) && (newTargetFovBase > 66f || FovAdjustBase.inDebugMode)) { __instance.localVisor.position = __instance.localVisor.position + __instance.localVisor.rotation * new Vector3(0f, 0f, -0.06f); } } private static float easeOutSine(float x) { return Mathf.Sin(x * (float)Math.PI / 2f); } public static void calculateVisorStuff() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) if (hideVisor) { visorScale = new Vector3(0f, 0f, 0f); } else if (newTargetFovBase > 66f || FovAdjustBase.inDebugMode) { float num = (newTargetFovBase - 66f) / (visorScaleTopRefFOV - 66f); num = Mathf.Lerp(num, easeOutSine(num), linToSinLerp); visorScale = Vector3.LerpUnclamped(visorScaleBottom, visorScaleTop, num); } else { visorScale = new Vector3(0.36f, 0.49f, 0.49f); } } private static bool filterPlayerControllers(PlayerControllerB player) { return !((NetworkBehaviour)player).IsOwner || !player.isPlayerControlled || (((NetworkBehaviour)player).IsServer && !player.isHostPlayerObject && !player.isTestingPlayer); } } public class HUDManagerPatches { [HarmonyPatch(typeof(HUDManager), "SubmitChat_performed")] [HarmonyPrefix] public static bool SubmitChat_performed_Prefix(HUDManager __instance) { //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: 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_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) string text = __instance.chatTextField.text; if (text.StartsWith("/fov")) { string[] array = text.Split(new char[1] { ' ' }); if (array.Length > 1 && float.TryParse(array[1], out var result)) { result = Mathf.Clamp(result, 66f, 130f); PlayerControllerBPatches.newTargetFovBase = result; if (!FovAdjustBase.inDebugMode) { PlayerControllerBPatches.calculateVisorStuff(); } } } else if (text.StartsWith("/toggleVisor")) { PlayerControllerBPatches.hideVisor = !PlayerControllerBPatches.hideVisor; PlayerControllerBPatches.calculateVisorStuff(); } else if (text.StartsWith("/recalcVisor") && FovAdjustBase.inDebugMode) { PlayerControllerBPatches.calculateVisorStuff(); } else if (text.StartsWith("/setScaleBottom") && FovAdjustBase.inDebugMode) { string[] array2 = text.Split(new char[1] { ' ' }); PlayerControllerBPatches.visorScaleBottom = new Vector3(float.Parse(array2[1]), float.Parse(array2[2]), float.Parse(array2[3])); } else if (text.StartsWith("/setScaleTop") && FovAdjustBase.inDebugMode) { string[] array3 = text.Split(new char[1] { ' ' }); PlayerControllerBPatches.visorScaleTop = new Vector3(float.Parse(array3[1]), float.Parse(array3[2]), float.Parse(array3[3])); } else if (text.StartsWith("/setSinAmount") && FovAdjustBase.inDebugMode) { string[] array4 = text.Split(new char[1] { ' ' }); PlayerControllerBPatches.linToSinLerp = float.Parse(array4[1]); } else if (text.StartsWith("/setTopRef") && FovAdjustBase.inDebugMode) { string[] array5 = text.Split(new char[1] { ' ' }); PlayerControllerBPatches.visorScaleTopRefFOV = float.Parse(array5[1]); } else { if (!text.StartsWith("/gimmeMyValues") || !FovAdjustBase.inDebugMode) { return true; } ManualLogSource log = FovAdjustBase.log; Vector3 val = PlayerControllerBPatches.visorScaleBottom; log.LogMessage((object)("visorScaleBottom: " + ((object)(Vector3)(ref val)).ToString())); ManualLogSource log2 = FovAdjustBase.log; val = PlayerControllerBPatches.visorScaleTop; log2.LogMessage((object)("visorScaleTop: " + ((object)(Vector3)(ref val)).ToString())); FovAdjustBase.log.LogMessage((object)("linToSinLerp: " + PlayerControllerBPatches.linToSinLerp)); FovAdjustBase.log.LogMessage((object)("visorScaleTopRefFOV: " + PlayerControllerBPatches.visorScaleTopRefFOV)); } __instance.localPlayer = GameNetworkManager.Instance.localPlayerController; __instance.localPlayer.isTypingChat = false; __instance.chatTextField.text = ""; EventSystem.current.SetSelectedGameObject((GameObject)null); ((Behaviour)__instance.typingIndicator).enabled = false; return false; } }
plugins/ScanFix.dll
Decompiled 2 years agousing System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using ScanFix.Patches; using UnityEngine; [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 = "")] [assembly: AssemblyCompany("ScanFix")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Fixes the scan command so it will show the true value of scrap, instead of the max value")] [assembly: AssemblyFileVersion("1.0.3.0")] [assembly: AssemblyInformationalVersion("1.0.3")] [assembly: AssemblyProduct("ScanFix")] [assembly: AssemblyTitle("ScanFix")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.3.0")] [module: UnverifiableCode] namespace ScanFix { [BepInPlugin("ScanFix", "ScanFix", "1.0.3")] public class Plugin : BaseUnityPlugin { private bool _patched; public static string textStored = "[scanForItems]"; public static ManualLogSource Logger { get; set; } private void Awake() { if (_patched) { Logger.LogWarning((object)"Already Patched"); return; } Harmony.CreateAndPatchAll(typeof(TerminalPatch), "ScanFix"); Logger = ((BaseUnityPlugin)this).Logger; Logger.LogInfo((object)"ScanFix is loaded!"); _patched = true; } } public static class PluginInfo { public const string PLUGIN_GUID = "ScanFix"; public const string PLUGIN_NAME = "ScanFix"; public const string PLUGIN_VERSION = "1.0.3"; } } namespace ScanFix.Patches { internal class TerminalPatch { [HarmonyPostfix] [HarmonyPatch(typeof(Terminal), "BeginUsingTerminal")] internal static void ScanFixPatch(Terminal __instance) { Plugin.Logger.LogInfo((object)"Entered Patch"); List<TerminalKeyword> list = __instance.terminalNodes.allKeywords.ToList(); TerminalKeyword val = list.Find((TerminalKeyword keyword) => keyword.word == "scan"); if ((Object)(object)val != (Object)null) { GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>(); if (!val.specialKeywordResult.displayText.Contains(Plugin.textStored)) { return; } int num = 0; int num2 = 0; int num3 = 0; int num4 = 0; for (int i = 0; i < array.Length; i++) { if (array[i].itemProperties.isScrap && !array[i].isInShipRoom && !array[i].isInElevator && !array[i].scrapPersistedThroughRounds) { num++; num3 += array[i].scrapValue; } else if (array[i].itemProperties.isScrap && array[i].isInShipRoom && array[i].isInElevator) { num2++; num4 += array[i].scrapValue; } } string text = $"There are {num} objects outside the ship, totalling at an exact value of {num3}."; string text2 = $"There are {num2} objects inside the ship, totalling at an exact value of {num4}."; if (num3 == 0) { val.specialKeywordResult.displayText = val.specialKeywordResult.displayText.Replace(Plugin.textStored, text2); Plugin.textStored = text2; } else { val.specialKeywordResult.displayText = val.specialKeywordResult.displayText.Replace(Plugin.textStored, text); Plugin.textStored = text; } __instance.terminalNodes.allKeywords = list.ToArray(); Plugin.Logger.LogInfo((object)"Replaced Scan"); } else { Plugin.Logger.LogWarning((object)"WHERE IS SCAN!!!!"); } } } }
plugins/LethalCompanyInputUtils.dll
Decompiled 2 years agousing System; 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 BepInEx; using BepInEx.Logging; using HarmonyLib; using LethalCompanyInputUtils.Api; using LethalCompanyInputUtils.Data; using LethalCompanyInputUtils.Utils; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.SceneManagement; [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("LethalCompanyInputUtils")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+52afbf7207fdde49ac33037091301a50725deb67")] [assembly: AssemblyProduct("LethalCompanyInputUtils")] [assembly: AssemblyTitle("LethalCompanyInputUtils")] [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.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 LethalCompanyInputUtils { public static class LcInputActionApi { private static readonly Dictionary<string, LcInputActions> InputActionsMap = new Dictionary<string, LcInputActions>(); private static IReadOnlyCollection<LcInputActions> InputActions => InputActionsMap.Values; internal static void LoadIntoUI(KepRemapPanel panel) { //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: 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_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_0090: 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) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown List<RemappableKey> remappableKeys = panel.remappableKeys; int num = remappableKeys.Count((RemappableKey key) => !key.gamepadOnly); foreach (LcInputActions inputAction in InputActions) { if (inputAction.Loaded) { continue; } foreach (InputActionReference actionRef in inputAction.ActionRefs) { InputBinding val = ((IEnumerable<InputBinding>)(object)actionRef.action.bindings).First(); string name = ((InputBinding)(ref val)).name; RemappableKey item = new RemappableKey { ControlName = name, currentInput = actionRef, gamepadOnly = false }; remappableKeys.Insert(num++, item); RemappableKey item2 = new RemappableKey { ControlName = name, currentInput = actionRef, rebindingIndex = 1, gamepadOnly = true }; remappableKeys.Add(item2); } inputAction.Loaded = true; } float horizontalOffset = panel.horizontalOffset; Rect rect = ((Component)((Transform)panel.keyRemapContainer).parent).GetComponent<RectTransform>().rect; float num2 = Mathf.Floor(((Rect)(ref rect)).width / horizontalOffset); panel.maxVertical = (float)num / num2; } internal static void CalculateVerticalMaxForGamepad(KepRemapPanel panel) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) int num = panel.remappableKeys.Count((RemappableKey key) => key.gamepadOnly); float horizontalOffset = panel.horizontalOffset; Rect rect = ((Component)((Transform)panel.keyRemapContainer).parent).GetComponent<RectTransform>().rect; float num2 = Mathf.Floor(((Rect)(ref rect)).width / horizontalOffset); panel.maxVertical = (float)num / num2; } internal static void ResetLoadedInputActions() { foreach (LcInputActions inputAction in InputActions) { inputAction.Loaded = false; } } internal static void RegisterInputActions(LcInputActions lcInputActions, InputActionMapBuilder builder) { if (!InputActionsMap.TryAdd(lcInputActions.Id, lcInputActions)) { Logging.Logger.LogWarning((object)("The mod [" + lcInputActions.Plugin.GUID + "] instantiated an Actions class [" + lcInputActions.GetType().Name + "] more than once!\n\t These classes should be treated as singletons!, do not instantiate more than once!")); } else { lcInputActions.CreateInputActions(in builder); InputActionSetupExtensions.AddActionMap(lcInputActions.GetAsset(), builder.Build()); lcInputActions.GetAsset().Enable(); lcInputActions.OnAssetLoaded(); lcInputActions.Load(); lcInputActions.BuildActionRefs(); } } internal static void DisableForRebind() { foreach (LcInputActions inputAction in InputActions) { if (inputAction.Enabled) { inputAction.Disable(); } } } internal static void ReEnableFromRebind() { foreach (LcInputActions inputAction in InputActions) { if (inputAction.WasEnabled) { inputAction.Enable(); } } } internal static void SaveOverrides() { foreach (LcInputActions inputAction in InputActions) { inputAction.Save(); } } } [BepInPlugin("com.rune580.LethalCompanyInputUtils", "Lethal Company Input Utils", "0.4.3")] public class LethalCompanyInputUtilsPlugin : BaseUnityPlugin { public const string ModId = "com.rune580.LethalCompanyInputUtils"; public const string ModName = "Lethal Company Input Utils"; public const string ModVersion = "0.4.3"; private Harmony? _harmony; private void Awake() { Logging.SetLogSource(((BaseUnityPlugin)this).Logger); _harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.rune580.LethalCompanyInputUtils"); SceneManager.activeSceneChanged += OnSceneChanged; FsUtils.EnsureControlsDir(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin com.rune580.LethalCompanyInputUtils is loaded!"); } private static void OnSceneChanged(Scene current, Scene next) { LcInputActionApi.ResetLoadedInputActions(); } } } namespace LethalCompanyInputUtils.Utils { internal static class AssemblyUtils { public static BepInPlugin? GetBepInPlugin(this Assembly assembly) { Type[] exportedTypes = assembly.GetExportedTypes(); for (int i = 0; i < exportedTypes.Length; i++) { BepInPlugin customAttribute = ((MemberInfo)exportedTypes[i]).GetCustomAttribute<BepInPlugin>(); if (customAttribute != null) { return customAttribute; } } return null; } } internal static class FsUtils { public static string SaveDir { get; } = GetSaveDir(); public static string Pre041ControlsDir { get; } = Path.Combine(Paths.BepInExRootPath, "controls"); public static string ControlsDir { get; } = Path.Combine(Paths.ConfigPath, "controls"); private static string GetSaveDir() { string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); return Path.Combine(folderPath, "AppData", "LocalLow", "ZeekerssRBLX", "Lethal Company"); } public static void EnsureControlsDir() { if (!Directory.Exists(ControlsDir)) { Directory.CreateDirectory(ControlsDir); } } } internal static class Logging { private static ManualLogSource? _logSource; internal static ManualLogSource Logger { get; } = _logSource; internal static void SetLogSource(ManualLogSource logSource) { _logSource = logSource; } } } namespace LethalCompanyInputUtils.Patches { public static class InputControlPathPatches { [HarmonyPatch] public static class ToHumanReadableStringPatch { public static IEnumerable<MethodBase> TargetMethods() { return from method in AccessTools.GetDeclaredMethods(typeof(InputControlPath)) where method.Name == "ToHumanReadableString" && method.ReturnType == typeof(string) select method; } public static void Postfix(ref string __result) { string text = __result; if ((text == "<InputUtils-Gamepad-Not-Bound>" || text == "<InputUtils-Kbm-Not-Bound>") ? true : false) { __result = ""; } } } } public static class KeyRemapPanelPatches { [HarmonyPatch(typeof(KepRemapPanel), "LoadKeybindsUI")] public static class LoadKeybindsUIPatch { public static void Prefix(KepRemapPanel __instance) { LcInputActionApi.DisableForRebind(); LcInputActionApi.LoadIntoUI(__instance); } public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Expected O, but got Unknown //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Expected O, but got Unknown //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Expected O, but got Unknown //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); FieldInfo maxVerticalField = AccessTools.Field(typeof(KepRemapPanel), "maxVertical"); val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[6] { new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction code) => CodeInstructionExtensions.IsLdarg(code, (int?)0)), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction code) => CodeInstructionExtensions.LoadsField(code, maxVerticalField, false)), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction code) => code.opcode == OpCodes.Ldc_R4 && (float)code.operand == 2f), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction code) => code.opcode == OpCodes.Add), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction code) => code.opcode == OpCodes.Conv_I4), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction code) => CodeInstructionExtensions.IsStloc(code, (LocalBuilder)null)), (string)null) }); val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldarg_0, (object)null) }).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(LcInputActionApi), "CalculateVerticalMaxForGamepad", new Type[1] { typeof(KepRemapPanel) }, (Type[])null)) }); return val.InstructionEnumeration(); } } [HarmonyPatch(typeof(KepRemapPanel), "UnloadKeybindsUI")] public static class UnloadKeybindsUIPatch { public static void Prefix() { LcInputActionApi.SaveOverrides(); LcInputActionApi.ReEnableFromRebind(); } } } } namespace LethalCompanyInputUtils.Data { [Serializable] public struct BindingOverride { public string? action; public string? origPath; public string? path; } [Serializable] public class BindingOverrides { public List<BindingOverride> overrides; private BindingOverrides() { overrides = new List<BindingOverride>(); } public BindingOverrides(IEnumerable<InputBinding> bindings) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) overrides = new List<BindingOverride>(); foreach (InputBinding binding in bindings) { InputBinding current = binding; if (((InputBinding)(ref current)).hasOverrides) { BindingOverride item = new BindingOverride { action = ((InputBinding)(ref current)).action, origPath = ((InputBinding)(ref current)).path, path = ((InputBinding)(ref current)).overridePath }; overrides.Add(item); } } } public void LoadInto(InputActionAsset asset) { foreach (BindingOverride @override in overrides) { InputAction obj = asset.FindAction(@override.action, false); if (obj != null) { InputActionRebindingExtensions.ApplyBindingOverride(obj, @override.path, (string)null, @override.origPath); } } } public static BindingOverrides FromJson(string json) { BindingOverrides bindingOverrides = new BindingOverrides(); JToken value = JsonConvert.DeserializeObject<JObject>(json).GetValue("overrides"); bindingOverrides.overrides = value.ToObject<List<BindingOverride>>(); return bindingOverrides; } } } namespace LethalCompanyInputUtils.Api { [AttributeUsage(AttributeTargets.Property)] public class InputActionAttribute : Attribute { public readonly string KbmPath; public string? ActionId { get; set; } public string? GamepadPath { get; set; } public InputActionType ActionType { get; set; } = (InputActionType)1; public string? KbmInteractions { get; set; } public string? GamepadInteractions { get; set; } public string? Name { get; set; } [Obsolete("Prefer using the named optional params instead.")] public InputActionAttribute(string action, string kbmPath, string gamepadPath) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) ActionId = action; KbmPath = kbmPath; GamepadPath = gamepadPath; } public InputActionAttribute(string kbmPath) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) KbmPath = kbmPath; } } public class InputActionBindingBuilder { private readonly InputActionMapBuilder _mapBuilder; private string? _actionId; private string? _kbmPath; private string? _gamepadPath; private string? _kbmInteractions; private string? _gamepadInteractions; private InputActionType _actionType; private string? _name; internal InputActionBindingBuilder(InputActionMapBuilder mapBuilder) { _mapBuilder = mapBuilder; } public InputActionBindingBuilder WithActionId(string actionId) { _actionId = actionId; return this; } public InputActionBindingBuilder WithKbmPath(string kbmPath) { _kbmPath = kbmPath; return this; } public InputActionBindingBuilder WithGamepadPath(string gamepadPath) { _gamepadPath = gamepadPath; return this; } public InputActionBindingBuilder WithKbmInteractions(string? kbmInteractions) { _kbmInteractions = kbmInteractions; return this; } public InputActionBindingBuilder WithGamepadInteractions(string? gamepadInteractions) { _gamepadInteractions = gamepadInteractions; return this; } public InputActionBindingBuilder WithActionType(InputActionType actionType) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) _actionType = actionType; return this; } public InputActionBindingBuilder WithBindingName(string? name) { _name = name; return this; } public InputAction Finish() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) if (_name == null) { _name = _actionId; } InputAction val = new InputAction(_actionId, _actionType, (string)null, (string)null, (string)null, (string)null); _mapBuilder.WithAction(val); if (_kbmPath != null) { _mapBuilder.WithBinding(new InputBinding(_kbmPath, _actionId, (string)null, (string)null, _kbmInteractions, _name)); } if (_gamepadPath != null) { _mapBuilder.WithBinding(new InputBinding(_gamepadPath, _actionId, (string)null, (string)null, _gamepadInteractions, _name)); } return val; } } public class InputActionMapBuilder { private readonly InputActionMap _actionMap = new InputActionMap(mapName); public InputActionMapBuilder(string mapName) { }//IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown public InputActionMapBuilder WithAction(InputAction action) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) InputActionSetupExtensions.AddAction(_actionMap, action.name, action.type, (string)null, (string)null, (string)null, (string)null, (string)null); return this; } public InputActionMapBuilder WithBinding(InputBinding binding) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) InputActionSetupExtensions.AddBinding(_actionMap, binding); return this; } public InputActionBindingBuilder NewActionBinding() { return new InputActionBindingBuilder(this); } internal InputActionMap Build() { return _actionMap; } } public abstract class LcInputActions { public const string UnboundKeyboardAndMouseIdentifier = "<InputUtils-Kbm-Not-Bound>"; public const string UnboundGamepadIdentifier = "<InputUtils-Gamepad-Not-Bound>"; private readonly string _jsonPath; private readonly List<InputActionReference> _actionRefs = new List<InputActionReference>(); internal bool Loaded; private readonly Dictionary<PropertyInfo, InputActionAttribute> _inputProps; public InputActionAsset Asset { get; } internal bool WasEnabled { get; private set; } public bool Enabled => Asset.enabled; internal IReadOnlyCollection<InputActionReference> ActionRefs => _actionRefs; internal string Id => Plugin.GUID + "." + MapName; public BepInPlugin Plugin { get; } protected virtual string MapName => GetType().Name; internal InputActionAsset GetAsset() { return Asset; } protected LcInputActions() { //IL_0118: Unknown result type (might be due to invalid IL or missing references) Asset = ScriptableObject.CreateInstance<InputActionAsset>(); Plugin = Assembly.GetCallingAssembly().GetBepInPlugin() ?? throw new InvalidOperationException(); _jsonPath = Path.Combine(FsUtils.ControlsDir, Id + ".json"); InputActionMapBuilder inputActionMapBuilder = new InputActionMapBuilder(Id); PropertyInfo[] properties = GetType().GetProperties(); _inputProps = new Dictionary<PropertyInfo, InputActionAttribute>(); PropertyInfo[] array = properties; foreach (PropertyInfo propertyInfo in array) { InputActionAttribute customAttribute = propertyInfo.GetCustomAttribute<InputActionAttribute>(); if (customAttribute != null && !(propertyInfo.PropertyType != typeof(InputAction))) { InputActionAttribute inputActionAttribute = customAttribute; if (inputActionAttribute.ActionId == null) { string text = (inputActionAttribute.ActionId = propertyInfo.Name); } inputActionAttribute = customAttribute; if (inputActionAttribute.GamepadPath == null) { string text = (inputActionAttribute.GamepadPath = "<InputUtils-Gamepad-Not-Bound>"); } string kbmPath = (string.IsNullOrEmpty(customAttribute.KbmPath) ? "<InputUtils-Kbm-Not-Bound>" : customAttribute.KbmPath); inputActionMapBuilder.NewActionBinding().WithActionId(customAttribute.ActionId).WithActionType(customAttribute.ActionType) .WithBindingName(customAttribute.Name) .WithKbmPath(kbmPath) .WithGamepadPath(customAttribute.GamepadPath) .WithKbmInteractions(customAttribute.KbmInteractions) .WithGamepadInteractions(customAttribute.GamepadInteractions) .Finish(); _inputProps[propertyInfo] = customAttribute; } } LcInputActionApi.RegisterInputActions(this, inputActionMapBuilder); } public virtual void CreateInputActions(in InputActionMapBuilder builder) { } public virtual void OnAssetLoaded() { } internal void BuildActionRefs() { //IL_0061: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair<PropertyInfo, InputActionAttribute> inputProp in _inputProps) { inputProp.Deconstruct(out var key, out var value); PropertyInfo propertyInfo = key; InputActionAttribute inputActionAttribute = value; InputAction value2 = Asset.FindAction(inputActionAttribute.ActionId, false); propertyInfo.SetValue(this, value2); } IEnumerable<InputActionReference> collection = ((IEnumerable<InputActionMap>)(object)Asset.actionMaps).SelectMany((InputActionMap map) => (IEnumerable<InputAction>)(object)map.actions).Select((Func<InputAction, InputActionReference>)InputActionReference.Create); _actionRefs.AddRange(collection); } public void Enable() { WasEnabled = Asset.enabled; Asset.Enable(); } public void Disable() { WasEnabled = Asset.enabled; Asset.Disable(); } internal void Save() { BindingOverrides bindingOverrides = new BindingOverrides(Asset.bindings); File.WriteAllText(_jsonPath, JsonConvert.SerializeObject((object)bindingOverrides)); } internal void Load() { try { ApplyMigrations(); } catch (Exception ex) { Logging.Logger.LogError((object)"Got error when applying migrations, skipping..."); Logging.Logger.LogError((object)ex); } if (!File.Exists(_jsonPath)) { return; } try { BindingOverrides.FromJson(File.ReadAllText(_jsonPath)).LoadInto(Asset); } catch (Exception ex2) { Logging.Logger.LogError((object)ex2); } } private void ApplyMigrations() { string text = Path.Combine(FsUtils.Pre041ControlsDir, Id + ".json"); if (File.Exists(text) && !File.Exists(_jsonPath)) { File.Move(text, _jsonPath); } if (!File.Exists(_jsonPath) || !File.ReadAllText(_jsonPath).Replace(" ", "").Contains("\"origPath\":\"\"")) { return; } BindingOverrides bindingOverrides = BindingOverrides.FromJson(File.ReadAllText(_jsonPath)); for (int i = 0; i < bindingOverrides.overrides.Count; i++) { BindingOverride value = bindingOverrides.overrides[i]; if (string.IsNullOrEmpty(value.origPath) && value.path != null) { if (value.path.StartsWith("<Keyboard>") || value.path.StartsWith("<Mouse>")) { value.origPath = "<InputUtils-Kbm-Not-Bound>"; } else { value.origPath = "<InputUtils-Gamepad-Not-Bound>"; } bindingOverrides.overrides[i] = value; } } File.WriteAllText(_jsonPath, JsonConvert.SerializeObject((object)bindingOverrides)); } } }
plugins/FlashlightToggle.dll
Decompiled 2 years 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 { } } } }
plugins/SpectateEnemy.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; 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("SpectateEnemy")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("My first plugin")] [assembly: AssemblyFileVersion("1.5.0.0")] [assembly: AssemblyInformationalVersion("1.5.0+fedd7299567cd8f4569b5f35b2cc9b6f25f17c2f")] [assembly: AssemblyProduct("SpectateEnemy")] [assembly: AssemblyTitle("SpectateEnemy")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.5.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 SpectateEnemy { [BepInPlugin("SpectateEnemy", "SpectateEnemy", "1.5.0")] public class Plugin : BaseUnityPlugin { public static int spectatedEnemyIndex = -1; public static bool spectatingEnemies = false; public static MethodInfo raycastSpectate = null; public static MethodInfo displaySpectatorTip = null; private ConfigEntry<bool> spectateTurrets; private ConfigEntry<bool> spectateLandmines; private ConfigEntry<bool> spectatePassives; public static bool doSpectateTurrets; public static bool doSpectateLandmines; public static bool doSpectatePassives; private Harmony harmony; private void Awake() { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown spectateTurrets = ((BaseUnityPlugin)this).Config.Bind<bool>("Config", "Spectate Turrets", false, "Enables spectating turrets."); doSpectateTurrets = spectateTurrets.Value; spectateLandmines = ((BaseUnityPlugin)this).Config.Bind<bool>("Config", "Spectate Landmines", false, "Enables spectating landmines."); doSpectateLandmines = spectateLandmines.Value; spectatePassives = ((BaseUnityPlugin)this).Config.Bind<bool>("Config", "Spectate Passives", false, "Enables spectating passive enemies, such as Docile Locust Bees and Manticoils."); doSpectatePassives = spectatePassives.Value; harmony = new Harmony("SpectateEnemy"); harmony.PatchAll(); raycastSpectate = AccessTools.Method(typeof(PlayerControllerB), "RaycastSpectateCameraAroundPivot", (Type[])null, (Type[])null); displaySpectatorTip = AccessTools.Method(typeof(HUDManager), "DisplaySpectatorTip", (Type[])null, (Type[])null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"SpectateEnemy loaded!"); } } public class Spectatable : MonoBehaviour { public SpectatableType type = SpectatableType.Enemy; public string enemyName = "Enemy"; } public enum SpectatableType { Enemy, Turret, Landmine } public static class MyPluginInfo { public const string PLUGIN_GUID = "SpectateEnemy"; public const string PLUGIN_NAME = "SpectateEnemy"; public const string PLUGIN_VERSION = "1.5.0"; } } namespace SpectateEnemy.Patches { [HarmonyPatch(typeof(EnemyAI), "Start")] public class EnemyAI_Patches { private static void Postfix(EnemyAI __instance) { if (Plugin.doSpectatePassives || (!(__instance.enemyType.enemyName == "Docile Locust Bees") && !(__instance.enemyType.enemyName == "Manticoil"))) { Spectatable spectatable = ((Component)__instance).gameObject.AddComponent<Spectatable>(); spectatable.enemyName = __instance.enemyType.enemyName; } } } [HarmonyPatch(typeof(GameNetworkManager), "Disconnect")] public class GameNetworkManager_Patches { private static void Postfix() { Plugin.spectatedEnemyIndex = -1; Plugin.spectatingEnemies = false; } } [HarmonyPatch(typeof(HUDManager), "Update")] public class HUDManager_Patches { private static void Postfix(HUDManager __instance) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) if (!GameNetworkManager.Instance.localPlayerController.isPlayerDead) { return; } if (StartOfRound.Instance.shipIsLeaving) { Light component = ((Component)__instance.playersManager.spectateCamera).GetComponent<Light>(); if ((Object)(object)component != (Object)null) { ((Behaviour)component).enabled = false; } return; } MovementActions movement = __instance.playerActions.Movement; InputBinding val = ((MovementActions)(ref movement)).Interact.bindings[0]; string text = InputControlPath.ToHumanReadableString(((InputBinding)(ref val)).effectivePath, (HumanReadableStringOptions)2, (InputControl)null); TextMeshProUGUI holdButtonToEndGameEarlyText = __instance.holdButtonToEndGameEarlyText; ((TMP_Text)holdButtonToEndGameEarlyText).text = ((TMP_Text)holdButtonToEndGameEarlyText).text + "\n\n\n\n\nSwitch to " + (Plugin.spectatingEnemies ? "Players" : "Enemies") + ": [" + text + "]\nToggle Flashlight : [RMB] (Click)"; movement = __instance.playerActions.Movement; if (((MovementActions)(ref movement)).PingScan.WasReleasedThisFrame()) { Light component2 = ((Component)__instance.playersManager.spectateCamera).GetComponent<Light>(); if ((Object)(object)component2 != (Object)null) { ((Behaviour)component2).enabled = !((Behaviour)component2).enabled; } } } } [HarmonyPatch(typeof(Landmine), "Start")] public class Landmine_Patches { private static void Postfix(Landmine __instance) { if (Plugin.doSpectateLandmines) { Spectatable spectatable = ((Component)__instance).gameObject.AddComponent<Spectatable>(); spectatable.type = SpectatableType.Landmine; spectatable.enemyName = "Landmine"; } } } [HarmonyPatch(typeof(MaskedPlayerEnemy), "Start")] public class MaskedPlayerEnemy_Patches { private static void Postfix(MaskedPlayerEnemy __instance) { Spectatable spectatable = ((Component)__instance).gameObject.AddComponent<Spectatable>(); if ((Object)(object)__instance.mimickingPlayer != (Object)null) { spectatable.enemyName = __instance.mimickingPlayer.playerUsername; } else { spectatable.enemyName = ((EnemyAI)__instance).enemyType.enemyName; } } } internal class Handler { public static Spectatable[] spectatorList; public static bool Spectate() { if (Plugin.spectatingEnemies) { if (spectatorList.Length == 0) { Plugin.spectatingEnemies = false; return true; } Plugin.spectatedEnemyIndex++; if (Plugin.spectatedEnemyIndex >= spectatorList.Length) { Plugin.spectatedEnemyIndex = 0; } return false; } return true; } } [HarmonyPatch(typeof(PlayerControllerB), "Interact_performed")] public class PlayerControllerB_Interact { private static bool Prefix(PlayerControllerB __instance) { //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerDead && !StartOfRound.Instance.shipIsLeaving && (!((NetworkBehaviour)__instance).IsServer || __instance.isHostPlayerObject)) { Plugin.spectatingEnemies = !Plugin.spectatingEnemies; if (Plugin.spectatingEnemies) { Handler.spectatorList = Object.FindObjectsByType<Spectatable>((FindObjectsSortMode)0); if (Handler.spectatorList.Length == 0) { Plugin.spectatingEnemies = false; Plugin.displaySpectatorTip.Invoke(HUDManager.Instance, new object[1] { "No enemies to spectate" }); return false; } if (Plugin.spectatedEnemyIndex == -1 || Plugin.spectatedEnemyIndex >= Handler.spectatorList.Length) { if ((Object)(object)__instance.spectatedPlayerScript == (Object)null) { Plugin.spectatedEnemyIndex = 0; } else { float num = 999999f; int spectatedEnemyIndex = 0; for (int i = 0; i < Handler.spectatorList.Length; i++) { Vector3 val = ((Component)Handler.spectatorList[i]).transform.position - ((Component)__instance.spectatedPlayerScript).transform.position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < num * num) { num = sqrMagnitude; spectatedEnemyIndex = i; } } Plugin.spectatedEnemyIndex = spectatedEnemyIndex; } } __instance.spectatedPlayerScript = null; } else { __instance.spectatedPlayerScript = ((IEnumerable<PlayerControllerB>)__instance.playersManager.allPlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB x) => !x.isPlayerDead)); } } return true; } } [HarmonyPatch(typeof(PlayerControllerB), "ActivateItem_performed")] public class PlayerControllerB_Use { private static bool Prefix(PlayerControllerB __instance) { if (((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerDead && !StartOfRound.Instance.shipIsLeaving && (!((NetworkBehaviour)__instance).IsServer || __instance.isHostPlayerObject)) { return Handler.Spectate(); } return true; } } [HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")] public class PlayerControllerB_LateUpdate { private static void Postfix(PlayerControllerB __instance) { //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.spectatingEnemies) { return; } if (Handler.spectatorList.Length == 0) { Plugin.spectatingEnemies = false; return; } if (Plugin.spectatedEnemyIndex >= Handler.spectatorList.Length) { Plugin.spectatedEnemyIndex = 0; } Spectatable obj = Handler.spectatorList[Plugin.spectatedEnemyIndex]; if ((Object)(object)obj == (Object)null) { Plugin.spectatedEnemyIndex++; if (Plugin.spectatedEnemyIndex >= Handler.spectatorList.Length) { Plugin.spectatedEnemyIndex = 0; } return; } Vector3? spectatePosition = GetSpectatePosition(obj); if (!spectatePosition.HasValue) { Plugin.spectatedEnemyIndex++; if (Plugin.spectatedEnemyIndex >= Handler.spectatorList.Length) { Plugin.spectatedEnemyIndex = 0; } return; } if (obj.enemyName == "Enemy") { TryFixName(ref obj); } __instance.spectateCameraPivot.position = spectatePosition.Value + GetZoomDistance(obj); ((TMP_Text)HUDManager.Instance.spectatingPlayerText).text = "(Spectating: " + obj.enemyName + ")"; Plugin.raycastSpectate.Invoke(__instance, Array.Empty<object>()); } private static void TryFixName(ref Spectatable obj) { EnemyAI val = default(EnemyAI); Turret val2 = default(Turret); Landmine val3 = default(Landmine); if (((Component)obj).gameObject.TryGetComponent<EnemyAI>(ref val)) { obj.enemyName = val.enemyType.enemyName; } else if (((Component)obj).gameObject.TryGetComponent<Turret>(ref val2)) { obj.enemyName = "Turret"; } else if (((Component)obj).gameObject.TryGetComponent<Landmine>(ref val3)) { obj.enemyName = "Landmine"; } } private static Vector3 GetZoomDistance(Spectatable obj) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) if (obj.enemyName == "ForestGiant") { return Vector3.up * 3f; } if (obj.enemyName == "MouthDog" || obj.enemyName == "Jester") { return Vector3.up * 2f; } return Vector3.up; } private static Vector3? GetSpectatePosition(Spectatable obj) { //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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 (obj.type == SpectatableType.Enemy) { EnemyAI component = ((Component)obj).GetComponent<EnemyAI>(); if ((Object)(object)component != (Object)null) { return ((Object)(object)component.eye == (Object)null) ? ((Component)component).transform.position : component.eye.position; } } else if (obj.type == SpectatableType.Turret) { Turret component2 = ((Component)obj).GetComponent<Turret>(); if ((Object)(object)component2 != (Object)null) { return ((Component)component2.centerPoint).transform.position; } } else { if (obj.type == SpectatableType.Landmine) { return ((Component)obj).transform.position; } Debug.LogError((object)("[SpectateEnemy]: Error when spectating: no handler for SpectatableType " + obj.type)); } return null; } } [HarmonyPatch(typeof(PlayerControllerB), "SpectateNextPlayer")] public class PlayerControllerB_SpectateNext { private static bool Prefix() { return !Plugin.spectatingEnemies; } } [HarmonyPatch(typeof(StartOfRound), "ShipLeave")] public class StartOfRound_Patches { private static void Postfix() { Plugin.spectatedEnemyIndex = -1; Plugin.spectatingEnemies = false; } } [HarmonyPatch(typeof(Turret), "Start")] public class Turret_Patches { private static void Postfix(Turret __instance) { if (Plugin.doSpectateTurrets) { Spectatable spectatable = ((Component)__instance).gameObject.AddComponent<Spectatable>(); spectatable.type = SpectatableType.Turret; spectatable.enemyName = "Turret"; } } } }
plugins/LC_API.dll
Decompiled 2 years 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; } } }
plugins/Walkie.dll
Decompiled 2 years 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"; } }
plugins/ToggleMute.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalCompanyInputUtils.Api; using Microsoft.CodeAnalysis; 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(".NETFramework,Version=v4.6", FrameworkDisplayName = "")] [assembly: AssemblyCompany("ToggleMute")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("A mod for Lethal Company that adds a customizable toggle mute hotkey")] [assembly: AssemblyFileVersion("1.3.0.0")] [assembly: AssemblyInformationalVersion("1.3.0")] [assembly: AssemblyProduct("ToggleMute")] [assembly: AssemblyTitle("ToggleMute")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.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 ToggleMute { public class Config { public static ConfigEntry<bool> allowMuteInTerminal; public static void Load() { allowMuteInTerminal = Plugin.config.Bind<bool>("General", "Allow Mute In Terminal", false, "Will you be able to use the toggle mute hotkey while in the terminal or while typing in chat?"); } } [HarmonyPatch(typeof(HUDManager), "Awake")] internal class HUDPatch { private static void Postfix() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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) ToggleMuteManager instance = ToggleMuteManager.instance; instance.micDisabledImagePrefab = Plugin.Bundle.LoadAsset<GameObject>("Assets/ToggleMute/MicDisabled.prefab"); Transform transform = new GameObject("ToggleMuteUI").transform; transform.SetParent(HUDManager.Instance.HUDContainer.transform.parent, false); instance.micDisabledImage = Object.Instantiate<GameObject>(instance.micDisabledImagePrefab, Vector3.zero, Quaternion.identity); instance.micDisabledImage.transform.SetParent(transform, false); instance.micDisabledImage.transform.localPosition = new Vector3(-420f, -230f, 6.5f); instance.micDisabledImage.SetActive(false); } } [HarmonyPatch(typeof(IngamePlayerSettings), "Awake")] internal class PlayerSettingsPatch { private static void Postfix(ref IngamePlayerSettings __instance) { ToggleMuteManager toggleMuteManager = default(ToggleMuteManager); if (!((Component)__instance).gameObject.TryGetComponent<ToggleMuteManager>(ref toggleMuteManager)) { ToggleMuteManager toggleMuteManager2 = ((Component)__instance).gameObject.AddComponent<ToggleMuteManager>(); toggleMuteManager2.playerSettings = __instance; } } } [BepInPlugin("quackandcheese.togglemute", "ToggleMute", "1.3.0")] [BepInProcess("Lethal Company.exe")] public class Plugin : BaseUnityPlugin { public const string ModGUID = "quackandcheese.togglemute"; public const string ModName = "ToggleMute"; public const string ModVersion = "1.3.0"; public static AssetBundle Bundle; public static ConfigFile config; public static ManualLogSource logger; private void Awake() { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown Type[] types = Assembly.GetExecutingAssembly().GetTypes(); Type[] array = types; foreach (Type type in array) { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); MethodInfo[] array2 = methods; foreach (MethodInfo methodInfo in array2) { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { methodInfo.Invoke(null, null); } } } Bundle = QuickLoadAssetBundle("togglemute.assets"); logger = ((BaseUnityPlugin)this).Logger; config = ((BaseUnityPlugin)this).Config; Config.Load(); Harmony val = new Harmony("quackandcheese.togglemute"); val.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin ToggleMute is loaded!"); } public static T FindAsset<T>(string name) where T : Object { return Resources.FindObjectsOfTypeAll<T>().ToList().Find((T x) => ((Object)x).name == name); } public static AssetBundle QuickLoadAssetBundle(string assetBundleName) { string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), assetBundleName); return AssetBundle.LoadFromFile(text); } } [HarmonyPatch(typeof(HUDManager), "UpdateSpectateBoxSpeakerIcons")] internal class SpectateBoxHUDPatch { private static void Postfix(ref HUDManager __instance) { KeyValuePair<Animator, PlayerControllerB> keyValuePair = __instance.spectatingPlayerBoxes.FirstOrDefault((KeyValuePair<Animator, PlayerControllerB> x) => (Object)(object)x.Value == (Object)(object)GameNetworkManager.Instance.localPlayerController); if (StartOfRound.Instance.voiceChatModule.IsMuted) { keyValuePair.Key.SetBool("speaking", false); } } } public class ToggleMuteInputActions : LcInputActions { public static ToggleMuteInputActions Instance = new ToggleMuteInputActions(); [InputAction(/*Could not decode attribute arguments.*/)] public InputAction ToggleMuteKey { get; set; } } public class ToggleMuteManager : MonoBehaviour { public IngamePlayerSettings playerSettings; public GameObject micDisabledImagePrefab; public GameObject micDisabledImage; public static ToggleMuteManager instance; public void Awake() { instance = this; ToggleMuteInputActions.Instance.ToggleMuteKey.performed += OnToggleMuteKeyPressed; } public void OnDestroy() { ToggleMuteInputActions.Instance.ToggleMuteKey.performed -= OnToggleMuteKeyPressed; } private void OnToggleMuteKeyPressed(CallbackContext ctx) { if (!((CallbackContext)(ref ctx)).performed || !Object.op_Implicit((Object)(object)playerSettings) || !Object.op_Implicit((Object)(object)StartOfRound.Instance) || !Object.op_Implicit((Object)(object)StartOfRound.Instance.voiceChatModule) || !Application.isFocused) { return; } if (Object.op_Implicit((Object)(object)GameNetworkManager.Instance)) { PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if (Object.op_Implicit((Object)(object)localPlayerController) && !Config.allowMuteInTerminal.Value && (localPlayerController.inTerminalMenu || localPlayerController.isTypingChat)) { return; } } IngamePlayerSettings.Instance.settings.micEnabled = !IngamePlayerSettings.Instance.settings.micEnabled; IngamePlayerSettings.Instance.SetMicrophoneEnabled(); SettingsOption val = Object.FindObjectsOfType<SettingsOption>(true).ToList().Find((SettingsOption x) => ((Object)x).name == "SpeakerButton"); val.ToggleEnabledImage(4); } public void Update() { if ((Object)(object)micDisabledImage != (Object)null && Object.op_Implicit((Object)(object)playerSettings)) { micDisabledImage.SetActive(!playerSettings.settings.micEnabled); } } } public static class PluginInfo { public const string PLUGIN_GUID = "ToggleMute"; public const string PLUGIN_NAME = "ToggleMute"; public const string PLUGIN_VERSION = "1.3.0"; } }
plugins/MoreEmotes1.2.2.dll
Decompiled 2 years agousing System; using System.Collections; 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.Bootstrap; using BepInEx.Configuration; using GameNetcodeStuff; using HarmonyLib; using MoreEmotes.Patch; using Tools; using Unity.Netcode; using UnityEngine; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.InputSystem.Utilities; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("FuckYouMod")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("FuckYouMod")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("5ecc2bf2-af12-4e83-a6f1-cf2eacbf3060")] [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 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 MoreEmotes { [BepInPlugin("MoreEmotes", "MoreEmotes-Sligili", "1.2.2")] public class FuckYouModInitialization : BaseUnityPlugin { private Harmony _harmony; private ConfigEntry<string> config_KeyWheel; private ConfigEntry<bool> config_InventoryCheck; private ConfigEntry<string> config_KeyEmote3; private ConfigEntry<string> config_KeyEmote4; private ConfigEntry<string> config_KeyEmote5; private ConfigEntry<string> config_KeyEmote6; private ConfigEntry<string> config_KeyEmote7; private ConfigEntry<string> config_KeyEmote8; private void Awake() { //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Expected O, but got Unknown ((BaseUnityPlugin)this).Logger.LogInfo((object)"MoreEmotes loaded"); EmotePatch.animationsBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "MoreEmotes/animationsbundle")); EmotePatch.animatorBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "MoreEmotes/animatorbundle")); EmotePatch.local = EmotePatch.animatorBundle.LoadAsset<RuntimeAnimatorController>("Assets/MoreEmotes/NEWmetarig.controller"); EmotePatch.others = EmotePatch.animatorBundle.LoadAsset<RuntimeAnimatorController>("Assets/MoreEmotes/NEWmetarigOtherPlayers.controller"); CustomAudioAnimationEvent.claps[0] = EmotePatch.animationsBundle.LoadAsset<AudioClip>("Assets/MoreEmotes/SingleClapEmote1.wav"); CustomAudioAnimationEvent.claps[1] = EmotePatch.animationsBundle.LoadAsset<AudioClip>("Assets/MoreEmotes/SingleClapEmote2.wav"); ConfigFile(); IncompatibilityAids(); _harmony = new Harmony("MoreEmotes"); _harmony.PatchAll(typeof(EmotePatch)); } private void IncompatibilityAids() { foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos) { BepInPlugin metadata = pluginInfo.Value.Metadata; if (metadata.GUID.Equals("com.malco.lethalcompany.moreshipupgrades") || metadata.GUID.Equals("Stoneman.LethalProgression")) { EmotePatch.IncompatibleStuff = true; break; } } } private void ConfigFile() { EmotePatch.keybinds = new string[9]; config_KeyWheel = ((BaseUnityPlugin)this).Config.Bind<string>("EMOTE WHEEL", "Key", "v", (ConfigDescription)null); EmotePatch.wheelKeybind = config_KeyWheel.Value; config_InventoryCheck = ((BaseUnityPlugin)this).Config.Bind<bool>("OTHERS", "InventoryCheck", true, "Prevents some emotes from performing while holding any item/scrap"); EmotePatch.InvCheck = config_InventoryCheck.Value; config_KeyEmote3 = ((BaseUnityPlugin)this).Config.Bind<string>("QUICK EMOTES", "Middle Finger", "3", (ConfigDescription)null); EmotePatch.keybinds[2] = config_KeyEmote3.Value.Replace(" ", ""); config_KeyEmote4 = ((BaseUnityPlugin)this).Config.Bind<string>("QUICK EMOTES", "The Griddy", "6", (ConfigDescription)null); EmotePatch.keybinds[5] = config_KeyEmote4.Value.Replace(" ", ""); config_KeyEmote5 = ((BaseUnityPlugin)this).Config.Bind<string>("QUICK EMOTES", "Shy", "5", (ConfigDescription)null); EmotePatch.keybinds[4] = config_KeyEmote5.Value.Replace(" ", ""); config_KeyEmote6 = ((BaseUnityPlugin)this).Config.Bind<string>("QUICK EMOTES", "Clap", "4", (ConfigDescription)null); EmotePatch.keybinds[3] = config_KeyEmote6.Value.Replace(" ", ""); config_KeyEmote7 = ((BaseUnityPlugin)this).Config.Bind<string>("QUICK EMOTES", "Twerk", "7", (ConfigDescription)null); EmotePatch.keybinds[6] = config_KeyEmote7.Value.Replace(" ", ""); config_KeyEmote8 = ((BaseUnityPlugin)this).Config.Bind<string>("QUICK EMOTES", "Salute", "8", (ConfigDescription)null); EmotePatch.keybinds[7] = config_KeyEmote8.Value.Replace(" ", ""); } } public static class PluginInfo { public const string Guid = "MoreEmotes"; public const string Name = "MoreEmotes-Sligili"; public const string Ver = "1.2.2"; } } namespace MoreEmotes.Patch { internal class EmotePatch { public static AssetBundle animationsBundle; public static AssetBundle animatorBundle; public static string[] keybinds; public static string wheelKeybind; private static CallbackContext context; public static RuntimeAnimatorController local; public static RuntimeAnimatorController others; private static int currentEmoteID; private static float svMovSpeed; public static bool IncompatibleStuff; public static bool InvCheck; public static bool emoteWheelIsOpened; public static GameObject wheel; public static GameObject rebindmenu; public static GameObject btn; private static SelectionWheel selectionWheel; [HarmonyPatch(typeof(MenuManager), "Start")] [HarmonyPostfix] private static void MenuStart(MenuManager __instance) { GameObject val = animationsBundle.LoadAsset<GameObject>("Assets/MoreEmotes/Resources/MoreEmotesPanel.prefab"); GameObject val2 = animationsBundle.LoadAsset<GameObject>("Assets/MoreEmotes/Resources/MoreEmotesButton.prefab"); GameObject gameObject = ((Component)((Component)__instance).transform.parent).gameObject; GameObject gameObject2 = ((Component)((Component)gameObject.transform.Find("MenuContainer")).transform.Find("SettingsPanel")).gameObject; if ((Object)(object)btn != (Object)null) { Object.Destroy((Object)(object)btn.gameObject); } btn = Object.Instantiate<GameObject>(val2, gameObject2.transform); btn.transform.SetSiblingIndex(7); if ((Object)(object)rebindmenu != (Object)null) { Object.Destroy((Object)(object)rebindmenu.gameObject); } rebindmenu = Object.Instantiate<GameObject>(val, gameObject2.transform); RebindBtn.defaultKeys = keybinds; BasicToggle.configValueInv = InvCheck; if ((Object)(object)gameObject2.GetComponent<SetupEverything>() == (Object)null) { gameObject2.AddComponent<SetupEverything>(); } SetupEverything.configValue = InvCheck; } [HarmonyPatch(typeof(PlayerControllerB), "Start")] [HarmonyPostfix] private static void StartPostfix(PlayerControllerB __instance) { GameObject gameObject = ((Component)((Component)((Component)__instance).gameObject.transform.Find("ScavengerModel")).transform.Find("metarig")).gameObject; CustomAudioAnimationEvent customAudioAnimationEvent = gameObject.AddComponent<CustomAudioAnimationEvent>(); svMovSpeed = __instance.movementSpeed; customAudioAnimationEvent.player = __instance; if (Object.FindObjectsOfType(typeof(SelectionWheel)).Length == 0) { GameObject val = animationsBundle.LoadAsset<GameObject>("Assets/MoreEmotes/Resources/MoreEmotesMenu.prefab"); GameObject gameObject2 = ((Component)((Component)GameObject.Find("Systems").gameObject.transform.Find("UI")).gameObject.transform.Find("Canvas")).gameObject; GameObject val2 = animationsBundle.LoadAsset<GameObject>("Assets/MoreEmotes/Resources/MoreEmotesPanel.prefab"); GameObject val3 = animationsBundle.LoadAsset<GameObject>("Assets/MoreEmotes/Resources/MoreEmotesButton.prefab"); GameObject gameObject3 = ((Component)((Component)gameObject2.transform.Find("QuickMenu")).transform.Find("SettingsPanel")).gameObject; if ((Object)(object)btn != (Object)null) { Object.Destroy((Object)(object)btn.gameObject); } btn = Object.Instantiate<GameObject>(val3, gameObject3.transform); btn.transform.SetSiblingIndex(7); if ((Object)(object)rebindmenu != (Object)null) { Object.Destroy((Object)(object)rebindmenu.gameObject); } rebindmenu = Object.Instantiate<GameObject>(val2, gameObject3.transform); RebindBtn.defaultKeys = keybinds; BasicToggle.configValueInv = InvCheck; if ((Object)(object)wheel != (Object)null) { Object.Destroy((Object)(object)wheel.gameObject); } wheel = Object.Instantiate<GameObject>(val, gameObject2.transform); selectionWheel = wheel.AddComponent<SelectionWheel>(); SelectionWheel.emotes_Keybinds = new string[keybinds.Length + 1]; SelectionWheel.emotes_Keybinds = keybinds; if ((Object)(object)gameObject3.GetComponent<SetupEverything>() == (Object)null) { gameObject3.AddComponent<SetupEverything>(); } SetupEverything.configValue = InvCheck; } } [HarmonyPatch(typeof(PlayerControllerB), "Update")] [HarmonyPostfix] private static void UpdatePostfix(PlayerControllerB __instance) { //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) if (!__instance.isPlayerControlled || !((NetworkBehaviour)__instance).IsOwner) { __instance.playerBodyAnimator.runtimeAnimatorController = others; return; } if ((Object)(object)__instance.playerBodyAnimator != (Object)(object)local) { __instance.playerBodyAnimator.runtimeAnimatorController = local; } if (__instance.performingEmote) { currentEmoteID = __instance.playerBodyAnimator.GetInteger("emoteNumber"); } if (!IncompatibleStuff) { bool flag = (bool)Reflection.CallMethod(__instance, "CheckConditionsForEmote") && currentEmoteID == 6 && __instance.performingEmote; __instance.movementSpeed = (flag ? (svMovSpeed / 2f) : svMovSpeed); } if (!PlayerPrefs.HasKey("InvCheck")) { PlayerPrefs.SetInt("InvCheck", InvCheck ? 1 : 0); } else { InvCheck = PlayerPrefs.GetInt("InvCheck") == 1; } if (!PlayerPrefs.HasKey("Emote_Wheel")) { PlayerPrefs.SetString("Emote_Wheel", wheelKeybind); } if (InputControlExtensions.IsPressed(((InputControl)Keyboard.current)[PlayerPrefs.GetString("Emote_Wheel")], 0f) && !emoteWheelIsOpened && !__instance.isPlayerDead && !__instance.inTerminalMenu && !__instance.quickMenuManager.isMenuOpen) { emoteWheelIsOpened = true; Cursor.visible = true; Cursor.lockState = (CursorLockMode)2; wheel.SetActive(emoteWheelIsOpened); __instance.disableLookInput = true; } else if ((!InputControlExtensions.IsPressed(((InputControl)Keyboard.current)[PlayerPrefs.GetString("Emote_Wheel")], 0f) && emoteWheelIsOpened) || __instance.quickMenuManager.isMenuOpen) { if (!__instance.quickMenuManager.isMenuOpen || __instance.isPlayerDead) { int selectedEmoteID = selectionWheel.selectedEmoteID; if (selectedEmoteID <= 3 || selectedEmoteID == 6 || !InvCheck) { __instance.PerformEmote(context, selectedEmoteID); } else if (!__instance.isHoldingObject) { __instance.PerformEmote(context, selectedEmoteID); } Cursor.visible = false; Cursor.lockState = (CursorLockMode)1; } if (__instance.isPlayerDead && !__instance.quickMenuManager.isMenuOpen) { Cursor.visible = false; Cursor.lockState = (CursorLockMode)1; } __instance.disableLookInput = false; emoteWheelIsOpened = false; wheel.SetActive(emoteWheelIsOpened); } if (!emoteWheelIsOpened && !__instance.quickMenuManager.isMenuOpen) { EmoteInput(keybinds[2], needsEmptyHands: false, 3, __instance); EmoteInput(keybinds[3], needsEmptyHands: true, 4, __instance); EmoteInput(keybinds[4], needsEmptyHands: true, 5, __instance); EmoteInput(keybinds[5], needsEmptyHands: false, 6, __instance); EmoteInput(keybinds[6], needsEmptyHands: true, 7, __instance); EmoteInput(keybinds[7], needsEmptyHands: true, 8, __instance); } } private static void EmoteInput(string keyBind, bool needsEmptyHands, int emoteID, PlayerControllerB player) { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) bool flag = PlayerPrefs.GetInt("InvCheck") == 1; Emotes emotes = (Emotes)emoteID; string text = emotes.ToString(); if (PlayerPrefs.HasKey(text)) { keyBind = PlayerPrefs.GetString(text); } else { PlayerPrefs.SetString(text, keyBind); } if (!keyBind.Equals(string.Empty) && InputControlExtensions.IsPressed(((InputControl)Keyboard.current)[keyBind], 0f) && (!player.isHoldingObject || !needsEmptyHands || !flag) && (!player.performingEmote || currentEmoteID != emoteID)) { Debug.Log((object)text); player.PerformEmote(context, emoteID); } } [HarmonyPatch(typeof(PlayerControllerB), "CheckConditionsForEmote")] [HarmonyPrefix] private static bool prefixCheckConditions(ref bool __result, PlayerControllerB __instance) { bool flag = (bool)Reflection.GetInstanceField(typeof(PlayerControllerB), __instance, "isJumping"); if (currentEmoteID == 6) { __result = !__instance.inSpecialInteractAnimation && !__instance.isPlayerDead && !flag && __instance.moveInputVector.x == 0f && !__instance.isSprinting && !__instance.isCrouching && !__instance.isClimbingLadder && !__instance.isGrabbingObjectAnimation && !__instance.inTerminalMenu && !__instance.isTypingChat; return false; } return true; } [HarmonyPatch(typeof(PlayerControllerB), "PerformEmote")] [HarmonyPrefix] private static void PerformEmotePrefix(CallbackContext context, int emoteID, PlayerControllerB __instance) { if ((emoteID >= 3 || emoteWheelIsOpened || ((CallbackContext)(ref context)).performed) && ((((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerControlled && (!((NetworkBehaviour)__instance).IsServer || __instance.isHostPlayerObject)) || __instance.isTestingPlayer) && (bool)Reflection.CallMethod(__instance, "CheckConditionsForEmote") && !(__instance.timeSinceStartingEmote < 0.5f)) { __instance.timeSinceStartingEmote = 0f; __instance.performingEmote = true; __instance.playerBodyAnimator.SetInteger("emoteNumber", emoteID); __instance.StartPerformingEmoteServerRpc(); } } } public class CustomAudioAnimationEvent : MonoBehaviour { private Animator animator; private AudioSource SoundsSource; public static AudioClip[] claps = (AudioClip[])(object)new AudioClip[2]; public PlayerControllerB player; private void Start() { animator = ((Component)this).GetComponent<Animator>(); SoundsSource = player.movementAudio; } public void PlayClapSound() { //IL_0087: Unknown result type (might be due to invalid IL or missing references) if (player.performingEmote && (!((NetworkBehaviour)player).IsOwner || !player.isPlayerControlled || animator.GetInteger("emoteNumber") == 4)) { bool flag = player.isInHangarShipRoom && player.playersManager.hangarDoorsClosed; RoundManager.Instance.PlayAudibleNoise(((Component)player).transform.position, 22f, 0.6f, 0, flag, 6); SoundsSource.pitch = Random.Range(0.59f, 0.79f); SoundsSource.PlayOneShot(claps[Random.Range(0, claps.Length)]); } } public void PlayFootstepSound() { if (player.performingEmote && (!((NetworkBehaviour)player).IsOwner || !player.isPlayerControlled || animator.GetInteger("emoteNumber") == 6 || animator.GetInteger("emoteNumber") == 8) && ((Vector2)(ref player.moveInputVector)).sqrMagnitude == 0f) { player.PlayFootstepLocal(); player.PlayFootstepServer(); } } } public enum Emotes { Dance = 1, Point, Middle_Finger, Clap, Shy, The_Griddy, Twerk, Salute } public class SelectionWheel : MonoBehaviour { public RectTransform selectionBlock; public Text emoteInformation; public Text pageInformation; private int blocksNumber = 8; private int currentBlock = 1; public int pageNumber; public int selectedEmoteID; private float angle; private float pageCooldown = 0.1f; public GameObject[] Pages; private int cuadrante = 0; public string selectedEmoteName; public float wheelMovementOffset = 3.3f; public static string[] emotes_Keybinds; private Vector2 center; private void OnEnable() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) center = new Vector2((float)(Screen.width / 2), (float)(Screen.height / 2)); PlayerInput component = GameObject.Find("PlayerSettingsObject").GetComponent<PlayerInput>(); emotes_Keybinds[0] = InputActionRebindingExtensions.GetBindingDisplayString(component.currentActionMap.FindAction("Emote1", false), 0, (DisplayStringOptions)0); emotes_Keybinds[1] = InputActionRebindingExtensions.GetBindingDisplayString(component.currentActionMap.FindAction("Emote2", false), 0, (DisplayStringOptions)0); Cursor.visible = true; selectionBlock = ((Component)((Component)this).gameObject.transform.Find("SelectedEmote")).gameObject.GetComponent<RectTransform>(); GameObject gameObject = ((Component)((Component)this).gameObject.transform.Find("FunctionalContent")).gameObject; emoteInformation = ((Component)((Component)((Component)this).gameObject.transform.Find("Graphics")).gameObject.transform.Find("EmoteInfo")).GetComponent<Text>(); Pages = (GameObject[])(object)new GameObject[gameObject.transform.childCount]; pageInformation = ((Component)((Component)((Component)this).gameObject.transform.Find("Graphics")).gameObject.transform.Find("PageNumber")).GetComponent<Text>(); pageInformation.text = "Page " + Pages.Length + "/" + (pageNumber + 1); for (int i = 0; i < gameObject.transform.childCount; i++) { Pages[i] = ((Component)gameObject.transform.GetChild(i)).gameObject; } Mouse.current.WarpCursorPosition(center); } private void Update() { wheelSelection(); pageSelection(); selectedEmoteID = currentBlock + Mathf.RoundToInt((float)(blocksNumber / 4)) + blocksNumber * pageNumber; displayEmoteInfo(); } private void wheelSelection() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) if (!(Vector2.Distance(center, ((InputControl<Vector2>)(object)((Pointer)Mouse.current).position).ReadValue()) < wheelMovementOffset)) { bool flag = ((InputControl<float>)(object)((Pointer)Mouse.current).position.x).ReadValue() > center.x; bool flag2 = ((InputControl<float>)(object)((Pointer)Mouse.current).position.y).ReadValue() > center.y; cuadrante = ((!flag) ? (flag2 ? 2 : 3) : (flag2 ? 1 : 4)); float num = (((InputControl<float>)(object)((Pointer)Mouse.current).position.y).ReadValue() - center.y) / (((InputControl<float>)(object)((Pointer)Mouse.current).position.x).ReadValue() - center.x); float num2 = 180 * (cuadrante - ((cuadrante <= 2) ? 1 : 2)); angle = Mathf.Atan(num) * (180f / (float)Math.PI) + num2; if (angle == 90f) { angle = 270f; } else if (angle == 270f) { angle = 90f; } float num3 = 360 / blocksNumber; currentBlock = Mathf.RoundToInt((angle - num3 * 1.5f) / num3); ((Transform)selectionBlock).localRotation = Quaternion.Euler(((Component)this).transform.rotation.z, ((Component)this).transform.rotation.y, num3 * (float)currentBlock); } } private void pageSelection() { pageInformation.text = "Page " + Pages.Length + "/" + (pageNumber + 1); if (pageCooldown > 0f) { pageCooldown -= Time.deltaTime; } else if (((InputControl<float>)(object)((Vector2Control)Mouse.current.scroll).y).ReadValue() != 0f) { GameObject[] pages = Pages; foreach (GameObject val in pages) { val.SetActive(false); } int num = ((((InputControl<float>)(object)((Vector2Control)Mouse.current.scroll).y).ReadValue() > 0f) ? 1 : (-1)); if (pageNumber + 1 > Pages.Length - 1 && num > 0) { pageNumber = 0; } else if (pageNumber - 1 < 0 && num < 0) { pageNumber = Pages.Length - 1; } else { pageNumber += num; } Pages[pageNumber].SetActive(true); pageCooldown = 0.1f; } } private void displayEmoteInfo() { string text = ((selectedEmoteID > emotes_Keybinds.Length) ? "" : emotes_Keybinds[selectedEmoteID - 1]); object obj; if (selectedEmoteID <= Enum.GetValues(typeof(Emotes)).Length) { Emotes emotes = (Emotes)selectedEmoteID; obj = emotes.ToString().Replace("_", " "); } else { obj = "EMPTY"; } string text2 = (string)obj; if (!PlayerPrefs.HasKey(text2.Replace(" ", "_"))) { PlayerPrefs.SetString(text2.Replace(" ", "_"), (selectedEmoteID > emotes_Keybinds.Length) ? "" : emotes_Keybinds[selectedEmoteID - 1]); } else { text = PlayerPrefs.GetString(text2.Replace(" ", "_")); } emoteInformation.text = text2 + "\n[" + text.ToUpper() + "]"; } } public class RebindBtn : MonoBehaviour { public string defaultKey; public static string[] defaultKeys; public string playerPrefs; public GameObject waitingForInput; public Text keyInfo; public Text description; private void Start() { //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Expected O, but got Unknown string text = ((Component)((Component)this).gameObject.transform.Find("Description")).GetComponent<Text>().text; try { int num = (int)(Emotes)Enum.Parse(typeof(Emotes), text.Replace(" ", "_")); defaultKey = defaultKeys[num - 1]; } catch { defaultKey = "V"; } playerPrefs = ((Component)((Component)this).gameObject.transform.Find("Description")).GetComponent<Text>().text.Replace(" ", "_"); ((Component)((Component)((Component)this).transform.parent).transform.Find("Delete")).gameObject.AddComponent<DeleteBtn>(); keyInfo = ((Component)((Component)this).transform.Find("InputText")).GetComponent<Text>(); waitingForInput = ((Component)((Component)this).transform.Find("wait")).gameObject; ((UnityEvent)((Component)this).GetComponent<Button>().onClick).AddListener(new UnityAction(GetKey)); if (!PlayerPrefs.HasKey(playerPrefs)) { PlayerPrefs.SetString(playerPrefs, defaultKey); } SetKeybind(PlayerPrefs.GetString(playerPrefs)); } public void SetKeybind(string key) { PlayerPrefs.SetString(playerPrefs, key); keyInfo.text = key; ((MonoBehaviour)this).StopAllCoroutines(); waitingForInput.SetActive(false); } public void GetKey() { waitingForInput.SetActive(true); ((MonoBehaviour)this).StartCoroutine(WaitForKey(delegate(string key) { SetKeybind(key); })); } private IEnumerator WaitForKey(Action<string> callback) { while (!((ButtonControl)Keyboard.current.anyKey).wasPressedThisFrame) { yield return (object)new WaitForEndOfFrame(); Observable.CallOnce<InputControl>(InputSystem.onAnyButtonPress, (Action<InputControl>)delegate(InputControl ctrl) { callback((ctrl.device == Keyboard.current) ? ctrl.name : defaultKey); }); } } } public class DeleteBtn : MonoBehaviour { private RebindBtn rebindBtn; private void Start() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown rebindBtn = ((Component)((Component)((Component)this).transform.parent).transform.Find("Button")).GetComponent<RebindBtn>(); Button component = ((Component)this).GetComponent<Button>(); ((UnityEvent)component.onClick).AddListener(new UnityAction(deleteKey)); } public void deleteKey() { rebindBtn.SetKeybind(string.Empty); } } public class BasicToggle : MonoBehaviour { private Toggle tog; public static bool configValueInv; public string playerPrefs; private void Start() { tog = ((Component)this).GetComponent<Toggle>(); ((UnityEvent<bool>)(object)tog.onValueChanged).AddListener((UnityAction<bool>)SetNewValue); if (!PlayerPrefs.HasKey(playerPrefs)) { PlayerPrefs.SetInt(playerPrefs, configValueInv ? 1 : 0); } } public void SetNewValue(bool arg) { PlayerPrefs.SetInt(playerPrefs, tog.isOn ? 1 : 0); } } public class ButtonBasic : MonoBehaviour { public GameObject[] alternateActive = (GameObject[])(object)new GameObject[1]; private void Start() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown ((UnityEvent)((Component)this).GetComponent<Button>().onClick).AddListener(new UnityAction(onButtonTrigger)); if (((Object)((Component)this).gameObject).name.Equals("BackButton")) { alternateActive[0] = ((Component)((Component)this).transform.parent).gameObject; } if (((Object)((Component)this).gameObject).name.Equals("MoreEmotesButton(Clone)")) { alternateActive[0] = ((Component)((Component)((Component)this).transform.parent).gameObject.transform.Find("MoreEmotesPanel(Clone)")).gameObject; } } public void onButtonTrigger() { GameObject[] array = alternateActive; foreach (GameObject val in array) { val.SetActive((!val.activeInHierarchy) ? true : false); } } } public class SetupEverything : MonoBehaviour { private GameObject panel; public static bool configValue; private void Start() { panel = ((Component)((Component)this).transform.Find("MoreEmotesPanel(Clone)")).gameObject; ((Component)panel.transform.Find("Version")).GetComponent<Text>().text = "Sligili - 1.2.2"; if (!PlayerPrefs.HasKey("InvCheck")) { PlayerPrefs.SetInt("InvCheck", configValue ? 1 : 0); } SetupMenuButton(); BackButton(); KeybindButtons(); Others(); } private void SetupMenuButton() { GameObject gameObject = ((Component)((Component)this).transform.Find("MoreEmotesButton(Clone)")).gameObject; gameObject.AddComponent<ButtonBasic>(); } private void BackButton() { GameObject gameObject = ((Component)panel.transform.Find("BackButton")).gameObject; gameObject.AddComponent<ButtonBasic>(); } private void KeybindButtons() { GameObject gameObject = ((Component)panel.transform.Find("KeybindButtons")).gameObject; GameObject[] array = (GameObject[])(object)new GameObject[gameObject.transform.childCount]; for (int i = 0; i < gameObject.transform.childCount; i++) { array[i] = ((Component)gameObject.transform.GetChild(i)).gameObject; } GameObject[] array2 = array; foreach (GameObject val in array2) { ((Component)val.transform.Find("Button")).gameObject.AddComponent<RebindBtn>(); } } private void Others() { GameObject gameObject = ((Component)panel.transform.Find("Inv")).gameObject; gameObject.AddComponent<BasicToggle>(); BasicToggle basicToggle = gameObject.AddComponent<BasicToggle>(); basicToggle.playerPrefs = "InvCheck"; } } }
plugins/Suit Saver.dll
Decompiled 2 years agousing System.Collections; 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 GameNetcodeStuff; using HarmonyLib; 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("Suit Saver")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Suit Saver")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("cb7cfb30-b06e-4e41-9de7-03640e1662ea")] [assembly: AssemblyFileVersion("1.1.2.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")] [assembly: AssemblyVersion("1.0.0.0")] namespace SuitSaver { [BepInPlugin("Hexnet.lethalcompany.suitsaver", "Suit Saver", "1.1.2")] public class SuitSaver : BaseUnityPlugin { private const string modGUID = "Hexnet.lethalcompany.suitsaver"; private const string modName = "Suit Saver"; private const string modVersion = "1.1.2"; private readonly Harmony harmony = new Harmony("Hexnet.lethalcompany.suitsaver"); private void Awake() { harmony.PatchAll(); Debug.Log((object)"[SS]: Suit Saver loaded successfully!"); } } } namespace SuitSaver.Patches { [HarmonyPatch] internal class Patches { [HarmonyPatch(typeof(StartOfRound))] internal class StartPatch { [HarmonyPatch("ResetShip")] [HarmonyPostfix] private static void ResetShipPatch() { Debug.Log((object)"[SS]: Ship has been reset!"); Debug.Log((object)"[SS]: Reloading suit..."); LoadSuitFromFile(); } } [HarmonyPatch(typeof(UnlockableSuit))] internal class SuitPatch { [HarmonyPatch("SwitchSuitClientRpc")] [HarmonyPostfix] private static void SyncSuit(ref UnlockableSuit __instance, int playerID) { PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; int num = (int)localPlayerController.playerClientId; if (playerID != num) { UnlockableSuit.SwitchSuitForPlayer(StartOfRound.Instance.allPlayerScripts[playerID], __instance.syncedSuitID.Value, true); } } [HarmonyPatch("SwitchSuitToThis")] [HarmonyPostfix] private static void EquipSuitPatch() { PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; string unlockableName = StartOfRound.Instance.unlockablesList.unlockables[localPlayerController.currentSuitID].unlockableName; SaveToFile(unlockableName); Debug.Log((object)("[SS]: Successfully saved current suit. (" + unlockableName + ")")); } } [HarmonyPatch(typeof(PlayerControllerB))] internal class JoinGamePatch { [HarmonyPatch("ConnectClientToPlayerObject")] [HarmonyPostfix] private static void LoadSuitPatch(ref PlayerControllerB __instance) { ((Component)GameNetworkManager.Instance.localPlayerController).gameObject.AddComponent<EquipAfterSyncPatch>(); } } internal class EquipAfterSyncPatch : MonoBehaviour { private void Start() { ((MonoBehaviour)this).StartCoroutine(LoadSuit()); } private IEnumerator LoadSuit() { Debug.Log((object)"[SS]: Waiting for suits to sync..."); yield return (object)new WaitForSeconds(1f); LoadSuitFromFile(); } } public static string SavePath = Application.persistentDataPath + "\\suitsaver.txt"; private static void SaveToFile(string suitName) { File.WriteAllText(SavePath, suitName); } private static string LoadFromFile() { if (File.Exists(SavePath)) { return File.ReadAllText(SavePath); } return "-1"; } private static UnlockableSuit GetSuitByName(string Name) { List<UnlockableItem> unlockables = StartOfRound.Instance.unlockablesList.unlockables; UnlockableSuit[] array = Resources.FindObjectsOfTypeAll<UnlockableSuit>(); foreach (UnlockableSuit val in array) { if (val.syncedSuitID.Value >= 0) { string unlockableName = unlockables[val.syncedSuitID.Value].unlockableName; if (unlockableName == Name) { return val; } } } return null; } private static void LoadSuitFromFile() { string text = LoadFromFile(); PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if (!(text == "-1")) { UnlockableSuit suitByName = GetSuitByName(text); if ((Object)(object)suitByName != (Object)null) { UnlockableSuit.SwitchSuitForPlayer(localPlayerController, suitByName.syncedSuitID.Value, false); suitByName.SwitchSuitServerRpc((int)localPlayerController.playerClientId); Debug.Log((object)("[SS]: Successfully loaded saved suit. (" + text + ")")); } else { Debug.Log((object)("[SS]: Failed to load saved suit. Perhaps it's locked? (" + text + ")")); } } } } }
plugins/MoreItems.dll
Decompiled 2 years agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using MoreItems.Patches; [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("MoreItems")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("My first plugin")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("MoreItems")] [assembly: AssemblyTitle("MoreItems")] [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 MoreItems { [BepInPlugin("MoreItems", "MoreItems", "1.0.0")] public class Plugin : BaseUnityPlugin { private readonly Harmony harmony = new Harmony("MoreItems"); private void Awake() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin MoreItems is loaded!"); harmony.PatchAll(typeof(StartOfRoundPatch)); } } public static class PluginInfo { public const string PLUGIN_GUID = "MoreItems"; public const string PLUGIN_NAME = "MoreItems"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace MoreItems.Patches { [HarmonyPatch(typeof(StartOfRound))] internal class StartOfRoundPatch { private const int newMaxItemCapacity = 999; [HarmonyPatch("Awake")] [HarmonyPostfix] private static void IncreaseShipItemCapacity(ref int ___maxShipItemCapacity) { ___maxShipItemCapacity = 999; Logger.CreateLogSource("MoreItems").LogInfo((object)$"Maximum amount of items that can be saved set to {999}."); } } }
plugins/ShipLoot.dll
Decompiled 2 years 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>(); } } }
plugins/Coroner.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Coroner.LCAPI; using GameNetcodeStuff; using HarmonyLib; using LC_API.ServerAPI; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; [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("EliteMasterEric")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Rework the Performance Report with new info, including cause of death.")] [assembly: AssemblyFileVersion("1.4.2.0")] [assembly: AssemblyInformationalVersion("1.4.2+57d4bb87a701adc39b5551b5ba1ecaf239a1871c")] [assembly: AssemblyProduct("Coroner")] [assembly: AssemblyTitle("Coroner")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.4.2.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 Coroner { internal class AdvancedDeathTracker { public const int PLAYER_CAUSE_OF_DEATH_DROPSHIP = 300; public static readonly string[] FUNNY_NOTES = new string[20] { "The goofiest goober.", "The cutest employee.", "Had the most fun.", "Had the least fun.", "The bravest employee.", "Did a sick flip.", "Stubbed their toe.", "The most likely to die next time.", "The least likely to die next time.", "Dislikes smoke.", "A team player.", "A real go-getter.", "Ate the most snacks.", "Passed GO and collected $200.", "Got freaky on a Friday night.", "I think this one's a serial killer.", "Perfectly unremarkable.", "Hasn't called their mother in a while.", "Has IP address 127.0.0.1.", "Secretly a lizard" }; private static readonly Dictionary<int, AdvancedCauseOfDeath> PlayerCauseOfDeath = new Dictionary<int, AdvancedCauseOfDeath>(); private static readonly Dictionary<int, string> PlayerNotes = new Dictionary<int, string>(); public static void ClearDeathTracker() { PlayerCauseOfDeath.Clear(); PlayerNotes.Clear(); } public static void SetCauseOfDeath(int playerIndex, AdvancedCauseOfDeath causeOfDeath, bool broadcast = true) { PlayerCauseOfDeath[playerIndex] = causeOfDeath; if (broadcast) { DeathBroadcaster.BroadcastCauseOfDeath(playerIndex, causeOfDeath); } } public static void SetCauseOfDeath(int playerIndex, CauseOfDeath causeOfDeath, bool broadcast = true) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) SetCauseOfDeath(playerIndex, ConvertCauseOfDeath(causeOfDeath), broadcast); } public static void SetCauseOfDeath(PlayerControllerB playerController, CauseOfDeath causeOfDeath, bool broadcast = true) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) SetCauseOfDeath((int)playerController.playerClientId, ConvertCauseOfDeath(causeOfDeath), broadcast); } public static void SetCauseOfDeath(PlayerControllerB playerController, AdvancedCauseOfDeath causeOfDeath, bool broadcast = true) { SetCauseOfDeath((int)playerController.playerClientId, causeOfDeath, broadcast); } public static AdvancedCauseOfDeath GetCauseOfDeath(int playerIndex) { PlayerControllerB playerController = StartOfRound.Instance.allPlayerScripts[playerIndex]; return GetCauseOfDeath(playerController); } public static AdvancedCauseOfDeath GetCauseOfDeath(PlayerControllerB playerController) { if (!PlayerCauseOfDeath.ContainsKey((int)playerController.playerClientId)) { Plugin.Instance.PluginLogger.LogDebug((object)$"Player {playerController.playerClientId} has no custom cause of death stored! Using fallback..."); return GuessCauseOfDeath(playerController); } Plugin.Instance.PluginLogger.LogDebug((object)$"Player {playerController.playerClientId} has custom cause of death stored! {PlayerCauseOfDeath[(int)playerController.playerClientId]}"); return PlayerCauseOfDeath[(int)playerController.playerClientId]; } public static AdvancedCauseOfDeath GuessCauseOfDeath(PlayerControllerB playerController) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Invalid comparison between Unknown and I4 if (playerController.isPlayerDead) { if (IsHoldingJetpack(playerController)) { if ((int)playerController.causeOfDeath == 2) { return AdvancedCauseOfDeath.Player_Jetpack_Gravity; } if ((int)playerController.causeOfDeath == 3) { return AdvancedCauseOfDeath.Player_Jetpack_Blast; } } return ConvertCauseOfDeath(playerController.causeOfDeath); } return AdvancedCauseOfDeath.Unknown; } public static bool IsHoldingJetpack(PlayerControllerB playerController) { GrabbableObject currentlyHeldObjectServer = playerController.currentlyHeldObjectServer; if ((Object)(object)currentlyHeldObjectServer == (Object)null) { return false; } GameObject gameObject = ((Component)currentlyHeldObjectServer).gameObject; if ((Object)(object)gameObject == (Object)null) { return false; } GrabbableObject component = gameObject.GetComponent<GrabbableObject>(); if ((Object)(object)component == (Object)null) { return false; } if (component is JetpackItem) { return true; } return false; } public static AdvancedCauseOfDeath ConvertCauseOfDeath(CauseOfDeath causeOfDeath) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected I4, but got Unknown return (int)causeOfDeath switch { 0 => AdvancedCauseOfDeath.Unknown, 1 => AdvancedCauseOfDeath.Bludgeoning, 2 => AdvancedCauseOfDeath.Gravity, 3 => AdvancedCauseOfDeath.Blast, 4 => AdvancedCauseOfDeath.Strangulation, 5 => AdvancedCauseOfDeath.Suffocation, 6 => AdvancedCauseOfDeath.Mauling, 7 => AdvancedCauseOfDeath.Gunshots, 8 => AdvancedCauseOfDeath.Crushing, 9 => AdvancedCauseOfDeath.Drowning, 10 => AdvancedCauseOfDeath.Abandoned, 11 => AdvancedCauseOfDeath.Electrocution, _ => AdvancedCauseOfDeath.Unknown, }; } public static string StringifyCauseOfDeath(CauseOfDeath causeOfDeath) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return StringifyCauseOfDeath(ConvertCauseOfDeath(causeOfDeath), Plugin.RANDOM); } public static string StringifyCauseOfDeath(AdvancedCauseOfDeath? causeOfDeath) { return StringifyCauseOfDeath(causeOfDeath, Plugin.RANDOM); } public static string StringifyCauseOfDeath(AdvancedCauseOfDeath? causeOfDeath, Random random) { string[] array = SelectCauseOfDeath(causeOfDeath); if (array.Length == 1 || Plugin.Instance.PluginConfig.ShouldUseSeriousDeathMessages()) { return array[0]; } return array[random.Next(array.Length)]; } public static string[] SelectCauseOfDeath(AdvancedCauseOfDeath? causeOfDeath) { if (!causeOfDeath.HasValue) { return FUNNY_NOTES; } return causeOfDeath switch { AdvancedCauseOfDeath.Bludgeoning => new string[1] { "Bludgeoned to death." }, AdvancedCauseOfDeath.Gravity => new string[2] { "Fell to their death.", "Fell off a cliff." }, AdvancedCauseOfDeath.Blast => new string[3] { "Exploded.", "Went out with a bang.", "Was blown to smithereens." }, AdvancedCauseOfDeath.Strangulation => new string[1] { "Strangled to death." }, AdvancedCauseOfDeath.Suffocation => new string[1] { "Suffocated to death." }, AdvancedCauseOfDeath.Mauling => new string[1] { "Mauled to death." }, AdvancedCauseOfDeath.Gunshots => new string[2] { "Shot to death.", "Filled to the brim with bullets." }, AdvancedCauseOfDeath.Crushing => new string[1] { "Crushed to death." }, AdvancedCauseOfDeath.Drowning => new string[1] { "Drowned to death." }, AdvancedCauseOfDeath.Abandoned => new string[1] { "Abandoned by their coworkers." }, AdvancedCauseOfDeath.Electrocution => new string[1] { "Electrocuted to death." }, AdvancedCauseOfDeath.Kicking => new string[1] { "Kicked to death." }, AdvancedCauseOfDeath.Enemy_Bracken => new string[2] { "Had their neck snapped by a Bracken.", "Stared at a Bracken too long." }, AdvancedCauseOfDeath.Enemy_EyelessDog => new string[3] { "Was eaten by an Eyeless Dog.", "Got caught using a mechanical keyboard.", "Wasn't quiet around an Eyeless Dog." }, AdvancedCauseOfDeath.Enemy_ForestGiant => new string[1] { "Swallowed whole by a Forest Giant." }, AdvancedCauseOfDeath.Enemy_CircuitBees => new string[1] { "Electro-stung to death by Circuit Bees." }, AdvancedCauseOfDeath.Enemy_GhostGirl => new string[4] { "Died a mysterious death.", "Lost their mind.", "Got a real bad headache.", "???" }, AdvancedCauseOfDeath.Enemy_EarthLeviathan => new string[1] { "Swallowed whole by an Earth Leviathan." }, AdvancedCauseOfDeath.Enemy_BaboonHawk => new string[2] { "Was eaten by a Baboon Hawk.", "Was mauled by a Baboon Hawk." }, AdvancedCauseOfDeath.Enemy_Jester => new string[4] { "Mauled to death by a Jester.", "Was the butt of the Jester's joke.", "Got pranked by the Jester.", "Got popped like a weasel." }, AdvancedCauseOfDeath.Enemy_CoilHead => new string[3] { "Mauled to death by a Coil Head.", "Got in a staring contest with a Coil Head.", "Lost a staring contest with a Coil Head." }, AdvancedCauseOfDeath.Enemy_SnareFlea => new string[1] { "Was suffocated by a Snare Flea." }, AdvancedCauseOfDeath.Enemy_Hygrodere => new string[3] { "Was absorbed by a Hygrodere.", "Got lost in the sauce.", "Had an oopsie with a Hygrodere." }, AdvancedCauseOfDeath.Enemy_HoarderBug => new string[4] { "Was mauled by a Hoarder Bug.", "Was swarmed by a Hoarder Bug.", "Was hoarded by a Hoarder Bug.", "Tried to steal from a Hoarder Bug." }, AdvancedCauseOfDeath.Enemy_SporeLizard => new string[2] { "Was bitten by a Spore Lizard.", "Was puffed by a Spore Lizard." }, AdvancedCauseOfDeath.Enemy_BunkerSpider => new string[1] { "Ensnared in the Bunker Spider's web." }, AdvancedCauseOfDeath.Enemy_Thumper => new string[2] { "Was ravaged by a Thumper.", "Got thumped by a Thumper." }, AdvancedCauseOfDeath.Enemy_MaskedPlayer_Wear => new string[2] { "Donned the Mask.", "Nobody cared who they were until they put on the Mask." }, AdvancedCauseOfDeath.Enemy_MaskedPlayer_Victim => new string[2] { "Was killed by a Masked coworker.", "Became a tragedy at the hands of the Mask." }, AdvancedCauseOfDeath.Enemy_Nutcracker_Kicked => new string[2] { "Was kicked to death by a Nutcracker.", "Got their nuts cracked by a Nutcracker." }, AdvancedCauseOfDeath.Enemy_Nutcracker_Shot => new string[2] { "Got shot by a Nutcracker.", "Was at the wrong end of a 21-gun salute." }, AdvancedCauseOfDeath.Player_Jetpack_Gravity => new string[3] { "Fell while using a jetpack.", "Flew too close to the sun.", "Ran out of fuel." }, AdvancedCauseOfDeath.Player_Jetpack_Blast => new string[2] { "Blew up while using a Jetpack.", "Turned into a firework." }, AdvancedCauseOfDeath.Player_Murder_Melee => new string[4] { "Was bludgeoned to death by a coworker.", "Was the victim of a murder.", "Got murdered.", "Got backstabbed by a coworker." }, AdvancedCauseOfDeath.Player_Murder_Shotgun => new string[5] { "Was shot to death by a coworker.", "Was the victim of a murder.", "Got murdered.", "Got one-pumped by a coworker.", "Got 360-noscoped by a coworker." }, AdvancedCauseOfDeath.Player_Quicksand => new string[2] { "Got stuck in quicksand.", "Drowned in quicksand" }, AdvancedCauseOfDeath.Player_StunGrenade => new string[2] { "Got flashbanged by a coworker.", "Was the victim of a murder." }, AdvancedCauseOfDeath.Other_DepositItemsDesk => new string[2] { "Received a demotion.", "Was put on disciplinary leave." }, AdvancedCauseOfDeath.Other_Dropship => new string[3] { "Was crushed by the Item Dropship.", "Couldn't wait for their items.", "Got too impatient for their items." }, AdvancedCauseOfDeath.Other_Landmine => new string[1] { "Stepped on a landmine." }, AdvancedCauseOfDeath.Other_Turret => new string[1] { "Got shot by a turret." }, AdvancedCauseOfDeath.Other_Lightning => new string[1] { "Was struck by lightning." }, _ => new string[3] { "Died somehow.", "Most sincerely dead.", "Expired in an inexplicable manner." }, }; } internal static void SetCauseOfDeath(PlayerControllerB playerControllerB, object enemy_BaboonHawk) { throw new NotImplementedException(); } } internal enum AdvancedCauseOfDeath { Unknown, Bludgeoning, Gravity, Blast, Strangulation, Suffocation, Mauling, Gunshots, Crushing, Drowning, Abandoned, Electrocution, Kicking, Enemy_BaboonHawk, Enemy_Bracken, Enemy_CircuitBees, Enemy_CoilHead, Enemy_EarthLeviathan, Enemy_EyelessDog, Enemy_ForestGiant, Enemy_GhostGirl, Enemy_Hygrodere, Enemy_Jester, Enemy_SnareFlea, Enemy_SporeLizard, Enemy_HoarderBug, Enemy_Thumper, Enemy_BunkerSpider, Enemy_MaskedPlayer_Wear, Enemy_MaskedPlayer_Victim, Enemy_Nutcracker_Kicked, Enemy_Nutcracker_Shot, Player_Jetpack_Gravity, Player_Jetpack_Blast, Player_Quicksand, Player_Murder_Melee, Player_Murder_Shotgun, Player_StunGrenade, Other_Landmine, Other_Turret, Other_Lightning, Other_DepositItemsDesk, Other_Dropship } internal class DeathBroadcaster { private const string SIGNATURE_DEATH = "com.elitemastereric.coroner.death"; public static void Initialize() { if (Plugin.Instance.IsLCAPIPresent) { DeathBroadcasterLCAPI.Initialize(); } else { Plugin.Instance.PluginLogger.LogInfo((object)"LC_API is not present! Skipping registration..."); } } public static void BroadcastCauseOfDeath(int playerId, AdvancedCauseOfDeath causeOfDeath) { AttemptBroadcast(BuildDataCauseOfDeath(playerId, causeOfDeath), "com.elitemastereric.coroner.death"); } private static string BuildDataCauseOfDeath(int playerId, AdvancedCauseOfDeath causeOfDeath) { string text = playerId.ToString(); int num = (int)causeOfDeath; return text + "|" + num; } private static void AttemptBroadcast(string data, string signature) { if (Plugin.Instance.IsLCAPIPresent) { DeathBroadcasterLCAPI.AttemptBroadcast(data, signature); } else { Plugin.Instance.PluginLogger.LogInfo((object)"LC_API is not present! Skipping broadcast..."); } } } public static class PluginInfo { public const string PLUGIN_ID = "Coroner"; public const string PLUGIN_NAME = "Coroner"; public const string PLUGIN_VERSION = "1.4.2"; public const string PLUGIN_GUID = "com.elitemastereric.coroner"; } [BepInPlugin("com.elitemastereric.coroner", "Coroner", "1.4.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public static readonly Random RANDOM = new Random(); public ManualLogSource PluginLogger; public PluginConfig PluginConfig; public bool IsLCAPIPresent = false; public static Plugin Instance { get; private set; } private void Awake() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown Instance = this; PluginLogger = ((BaseUnityPlugin)this).Logger; Harmony val = new Harmony("com.elitemastereric.coroner"); val.PatchAll(); PluginLogger.LogInfo((object)"Plugin Coroner (com.elitemastereric.coroner) is loaded!"); LoadConfig(); QueryLCAPI(); DeathBroadcaster.Initialize(); } private void QueryLCAPI() { PluginLogger.LogInfo((object)"Checking for LC_API..."); if (Chainloader.PluginInfos.ContainsKey("LC_API")) { Chainloader.PluginInfos.TryGetValue("LC_API", out var value); if (value == null) { PluginLogger.LogError((object)"Detected LC_API, but could not get plugin info!"); IsLCAPIPresent = false; } else { PluginLogger.LogInfo((object)("LCAPI is present! " + value.Metadata.GUID + ":" + value.Metadata.Version)); IsLCAPIPresent = true; } } else { PluginLogger.LogInfo((object)"LCAPI is not present."); IsLCAPIPresent = false; } } private void LoadConfig() { PluginConfig = new PluginConfig(); PluginConfig.BindConfig(((BaseUnityPlugin)this).Config); } } public class PluginConfig { private ConfigEntry<bool> DisplayCauseOfDeath; private ConfigEntry<bool> SeriousDeathMessages; private ConfigEntry<bool> DisplayFunnyNotes; private ConfigEntry<bool> DeathReplacesNotes; public void BindConfig(ConfigFile _config) { DisplayCauseOfDeath = _config.Bind<bool>("General", "DisplayCauseOfDeath", true, "Display the cause of death in the player notes."); SeriousDeathMessages = _config.Bind<bool>("General", "SeriousDeathMessages", false, "Cause of death messages are more to-the-point."); DisplayFunnyNotes = _config.Bind<bool>("General", "DisplayFunnyNotes", true, "Display a random note when the player has no notes."); DeathReplacesNotes = _config.Bind<bool>("General", "DeathReplacesNotes", true, "True to replace notes when the player dies, false to append."); } public bool ShouldDisplayCauseOfDeath() { return DisplayCauseOfDeath.Value; } public bool ShouldUseSeriousDeathMessages() { return SeriousDeathMessages.Value; } public bool ShouldDisplayFunnyNotes() { return DisplayFunnyNotes.Value; } public bool ShouldDeathReplaceNotes() { return DeathReplacesNotes.Value; } } } namespace Coroner.Patch { [HarmonyPatch(typeof(PlayerControllerB))] [HarmonyPatch("KillPlayer")] internal class PlayerControllerBKillPlayerPatch { public static void Prefix(PlayerControllerB __instance, ref CauseOfDeath causeOfDeath) { try { if ((int)causeOfDeath == 300) { Plugin.Instance.PluginLogger.LogDebug((object)"Player died from item dropship! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(__instance, AdvancedCauseOfDeath.Other_Dropship); causeOfDeath = (CauseOfDeath)8; } else if (__instance.isSinking && (int)causeOfDeath == 5) { Plugin.Instance.PluginLogger.LogDebug((object)"Player died of suffociation while sinking in quicksand! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(__instance, AdvancedCauseOfDeath.Player_Quicksand); } else if ((int)causeOfDeath != 3) { Plugin.Instance.PluginLogger.LogDebug((object)"Player is dying! No cause of death registered in hook..."); } } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in PlayerControllerBKillPlayerPatch.Prefix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(DepositItemsDesk))] [HarmonyPatch("AnimationGrabPlayer")] internal class DepositItemsDeskAnimationGrabPlayerPatch { public static void Postfix(int playerID) { try { Plugin.Instance.PluginLogger.LogDebug((object)"Accessing state after tentacle devouring..."); PlayerControllerB playerController = StartOfRound.Instance.allPlayerScripts[playerID]; Plugin.Instance.PluginLogger.LogDebug((object)"Player is dying! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(playerController, AdvancedCauseOfDeath.Other_DepositItemsDesk); } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in DepositItemsDeskAnimationGrabPlayerPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(JesterAI))] [HarmonyPatch("killPlayerAnimation")] internal class JesterAIKillPlayerAnimationPatch { public static void Postfix(int playerId) { try { Plugin.Instance.PluginLogger.LogDebug((object)"Accessing state after Jester mauling..."); PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerId]; if ((Object)(object)val == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access player after death!"); return; } Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(val, AdvancedCauseOfDeath.Enemy_Jester); } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in JesterAIKillPlayerAnimationPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(SandWormAI))] [HarmonyPatch("EatPlayer")] internal class SandWormAIEatPlayerPatch { public static void Postfix(PlayerControllerB playerScript) { try { Plugin.Instance.PluginLogger.LogDebug((object)"Accessing state after Sand Worm devouring..."); if ((Object)(object)playerScript == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access player after death!"); return; } Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(playerScript, AdvancedCauseOfDeath.Enemy_EarthLeviathan); } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in SandWormAIEatPlayerPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(RedLocustBees))] [HarmonyPatch("BeeKillPlayerOnLocalClient")] internal class RedLocustBeesBeeKillPlayerOnLocalClientPatch { public static void Postfix(int playerId) { try { Plugin.Instance.PluginLogger.LogDebug((object)"Accessing state after Circuit Bee electrocution..."); PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerId]; if ((Object)(object)val == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access player after death!"); } else if (val.isPlayerDead) { Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(val, AdvancedCauseOfDeath.Enemy_CircuitBees); } else { Plugin.Instance.PluginLogger.LogDebug((object)"Player is somehow still alive! Skipping..."); } } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in RedLocustBeesBeeKillPlayerOnLocalClientPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(DressGirlAI))] [HarmonyPatch("OnCollideWithPlayer")] internal class DressGirlAIOnCollideWithPlayerPatch { public static void Postfix(DressGirlAI __instance) { try { Plugin.Instance.PluginLogger.LogDebug((object)"Processing Ghost Girl player collision..."); if ((Object)(object)__instance.hauntingPlayer == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access player after collision!"); } else if (__instance.hauntingPlayer.isPlayerDead) { Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(__instance.hauntingPlayer, AdvancedCauseOfDeath.Enemy_GhostGirl); } } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in DressGirlAIOnCollideWithPlayerPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(FlowermanAI))] [HarmonyPatch("killAnimation")] internal class FlowermanAIKillAnimationPatch { public static void Postfix(FlowermanAI __instance) { try { Plugin.Instance.PluginLogger.LogDebug((object)"Accessing state after Bracken snapping neck..."); if ((Object)(object)((EnemyAI)__instance).inSpecialAnimationWithPlayer == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access player after snapping neck!"); return; } Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(((EnemyAI)__instance).inSpecialAnimationWithPlayer, AdvancedCauseOfDeath.Enemy_Bracken); } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in FlowermanAIKillAnimationPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(ForestGiantAI))] [HarmonyPatch("EatPlayerAnimation")] internal class ForestGiantAIEatPlayerAnimationPatch { public static void Postfix(PlayerControllerB playerBeingEaten) { try { Plugin.Instance.PluginLogger.LogDebug((object)"Accessing state after Forest Giant devouring..."); if ((Object)(object)playerBeingEaten == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access player after death!"); return; } Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(playerBeingEaten, AdvancedCauseOfDeath.Enemy_ForestGiant); } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in ForestGiantAIEatPlayerAnimationPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(MouthDogAI))] [HarmonyPatch("KillPlayer")] internal class MouthDogAIKillPlayerPatch { public static void Postfix(int playerId) { try { Plugin.Instance.PluginLogger.LogDebug((object)"Accessing state after dog devouring..."); PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerId]; if ((Object)(object)val == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access player after death!"); return; } Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(val, AdvancedCauseOfDeath.Enemy_EyelessDog); } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in MouthDogAIKillPlayerPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(CentipedeAI))] [HarmonyPatch("DamagePlayerOnIntervals")] internal class CentipedeAIDamagePlayerOnIntervalsPatch { public static void Postfix(CentipedeAI __instance) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Invalid comparison between Unknown and I4 try { Plugin.Instance.PluginLogger.LogDebug((object)"Handling Snare Flea damage..."); if ((Object)(object)__instance.clingingToPlayer == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access player being clung to!"); } else if (__instance.clingingToPlayer.isPlayerDead && (int)__instance.clingingToPlayer.causeOfDeath == 5) { Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(__instance.clingingToPlayer, AdvancedCauseOfDeath.Enemy_SnareFlea); } else if (__instance.clingingToPlayer.isPlayerDead) { Plugin.Instance.PluginLogger.LogDebug((object)"Player somehow died while attacked by Snare Flea! Skipping..."); } } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in CentipedeAIDamagePlayerOnIntervalsPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(BaboonBirdAI))] [HarmonyPatch("OnCollideWithPlayer")] internal class BaboonBirdAIOnCollideWithPlayerPatch { public static void Postfix(Collider other) { try { Plugin.Instance.PluginLogger.LogDebug((object)"Handling Baboon Hawk damage..."); PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>(); if ((Object)(object)component == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access player after death!"); } else if (component.isPlayerDead) { Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(component, AdvancedCauseOfDeath.Enemy_BaboonHawk); } else { Plugin.Instance.PluginLogger.LogDebug((object)"Player is somehow still alive! Skipping..."); } } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in BaboonBirdAIOnCollideWithPlayerPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(PlayerControllerB))] [HarmonyPatch("DamagePlayerFromOtherClientClientRpc")] internal class PlayerControllerBDamagePlayerFromOtherClientClientRpcPatch { public static void Postfix(PlayerControllerB __instance) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Invalid comparison between Unknown and I4 //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Invalid comparison between Unknown and I4 //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Invalid comparison between Unknown and I4 try { Plugin.Instance.PluginLogger.LogDebug((object)"Handling friendly fire damage..."); if ((Object)(object)__instance == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access victim after death!"); } else if (__instance.isPlayerDead) { if ((int)__instance.causeOfDeath == 1) { Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(__instance, AdvancedCauseOfDeath.Player_Murder_Melee); } else if ((int)__instance.causeOfDeath == 6) { Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(__instance, AdvancedCauseOfDeath.Player_Murder_Melee); } else if ((int)__instance.causeOfDeath == 7) { Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(__instance, AdvancedCauseOfDeath.Player_Murder_Shotgun); } else { Plugin.Instance.PluginLogger.LogWarning((object)("Player was killed by someone else but we don't know how! " + ((object)(CauseOfDeath)(ref __instance.causeOfDeath)).ToString())); } } else { Plugin.Instance.PluginLogger.LogDebug((object)"Player is somehow still alive! Skipping..."); } } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in PlayerControllerBDamagePlayerFromOtherClientClientRpcPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(PufferAI))] [HarmonyPatch("OnCollideWithPlayer")] internal class PufferAIOnCollideWithPlayerPatch { public static void Postfix(Collider other) { try { Plugin.Instance.PluginLogger.LogDebug((object)"Handling Spore Lizard damage..."); PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>(); if ((Object)(object)component == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access player after death!"); } else if (component.isPlayerDead) { Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(component, AdvancedCauseOfDeath.Enemy_SporeLizard); } else { Plugin.Instance.PluginLogger.LogDebug((object)"Player is somehow still alive! Skipping..."); } } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in PufferAIOnCollideWithPlayerPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(SpringManAI))] [HarmonyPatch("OnCollideWithPlayer")] internal class SpringManAIOnCollideWithPlayerPatch { public static void Postfix(Collider other) { try { Plugin.Instance.PluginLogger.LogDebug((object)"Handling Coil Head damage..."); PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>(); if ((Object)(object)component == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access player after death!"); } else if (component.isPlayerDead) { Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(component, AdvancedCauseOfDeath.Enemy_CoilHead); } else { Plugin.Instance.PluginLogger.LogDebug((object)"Player is somehow still alive! Skipping..."); } } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in SpringManAIOnCollideWithPlayerPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(BlobAI))] [HarmonyPatch("SlimeKillPlayerEffectServerRpc")] internal class BlobAISlimeKillPlayerEffectServerRpcPatch { public static void Postfix(int playerKilled) { try { PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerKilled]; if ((Object)(object)val == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access player after death!"); } else if (val.isPlayerDead) { Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(val, AdvancedCauseOfDeath.Enemy_Hygrodere); } else { Plugin.Instance.PluginLogger.LogDebug((object)"Player is somehow still alive! Skipping..."); } } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in BlobAISlimeKillPlayerEffectServerRpcPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(HoarderBugAI))] [HarmonyPatch("OnCollideWithPlayer")] internal class HoarderBugAIOnCollideWithPlayerPatch { public static void Postfix(Collider other) { try { Plugin.Instance.PluginLogger.LogDebug((object)"Handling Hoarder Bug damage..."); PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>(); if ((Object)(object)component == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access player after death!"); } else if (component.isPlayerDead) { Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(component, AdvancedCauseOfDeath.Enemy_HoarderBug); } else { Plugin.Instance.PluginLogger.LogDebug((object)"Player is somehow still alive! Skipping..."); } } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in HoarderBugAIOnCollideWithPlayerPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(CrawlerAI))] [HarmonyPatch("OnCollideWithPlayer")] internal class CrawlerAIOnCollideWithPlayerPatch { public static void Postfix(Collider other) { try { Plugin.Instance.PluginLogger.LogDebug((object)"Handling Thumper damage..."); PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>(); if ((Object)(object)component == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access player after death!"); } else if (component.isPlayerDead) { Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(component, AdvancedCauseOfDeath.Enemy_Thumper); } else { Plugin.Instance.PluginLogger.LogDebug((object)"Player is somehow still alive! Skipping..."); } } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in CrawlerAIOnCollideWithPlayerPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(SandSpiderAI))] [HarmonyPatch("OnCollideWithPlayer")] internal class SandSpiderAIOnCollideWithPlayerPatch { public static void Postfix(Collider other) { try { Plugin.Instance.PluginLogger.LogDebug((object)"Handling Bunker Spider damage..."); PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>(); if ((Object)(object)component == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access player after death!"); } else if (component.isPlayerDead) { Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(component, AdvancedCauseOfDeath.Enemy_BunkerSpider); } else { Plugin.Instance.PluginLogger.LogDebug((object)"Player is somehow still alive! Skipping..."); } } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in SandSpiderAIOnCollideWithPlayerPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(NutcrackerEnemyAI))] [HarmonyPatch("LegKickPlayer")] internal class NutcrackerEnemyAILegKickPlayerPatch { public static void Postfix(int playerId) { try { Plugin.Instance.PluginLogger.LogDebug((object)"Nutcracker kicked a player to death!"); PlayerControllerB playerController = StartOfRound.Instance.allPlayerScripts[playerId]; Plugin.Instance.PluginLogger.LogDebug((object)"Player is dying! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(playerController, AdvancedCauseOfDeath.Enemy_Nutcracker_Kicked); } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in NutcrackerEnemyAILegKickPlayerPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(ShotgunItem))] [HarmonyPatch("ShootGun")] internal class ShotgunItemShootGunPatch { public static void Postfix(ShotgunItem __instance) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Invalid comparison between Unknown and I4 try { Plugin.Instance.PluginLogger.LogDebug((object)"Handling shotgun shot..."); PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if ((Object)(object)localPlayerController == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access local player after shotgun shot!"); } else if (localPlayerController.isPlayerDead && (int)localPlayerController.causeOfDeath == 7) { if (((GrabbableObject)__instance).isHeldByEnemy) { Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(localPlayerController, AdvancedCauseOfDeath.Enemy_Nutcracker_Shot); } else { Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(localPlayerController, AdvancedCauseOfDeath.Player_Murder_Shotgun); } } else if (localPlayerController.isPlayerDead) { Plugin.Instance.PluginLogger.LogWarning((object)("Player died while attacked by shotgun? Skipping... " + ((object)(CauseOfDeath)(ref localPlayerController.causeOfDeath)).ToString())); } } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in ShotgunItemShootGunPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(MaskedPlayerEnemy))] [HarmonyPatch("killAnimation")] internal class MaskedPlayerEnemykillAnimationPatch { public static void Postfix(MaskedPlayerEnemy __instance) { try { Plugin.Instance.PluginLogger.LogDebug((object)"Masked Player killed someone..."); PlayerControllerB inSpecialAnimationWithPlayer = ((EnemyAI)__instance).inSpecialAnimationWithPlayer; if ((Object)(object)inSpecialAnimationWithPlayer == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access player after death!"); return; } Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(inSpecialAnimationWithPlayer, AdvancedCauseOfDeath.Enemy_MaskedPlayer_Victim); } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in MaskedPlayerEnemykillAnimationPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(HauntedMaskItem))] [HarmonyPatch("FinishAttaching")] internal class HauntedMaskItemFinishAttachingPatch { public static void Postfix(HauntedMaskItem __instance) { try { Plugin.Instance.PluginLogger.LogDebug((object)"Masked Player killed someone..."); PlayerControllerB value = Traverse.Create((object)__instance).Field("previousPlayerHeldBy").GetValue<PlayerControllerB>(); if ((Object)(object)value == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access player after death!"); } else if (value.isPlayerDead) { Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(value, AdvancedCauseOfDeath.Enemy_MaskedPlayer_Wear); } else { Plugin.Instance.PluginLogger.LogDebug((object)"Player is somehow still alive! Skipping..."); } } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in HauntedMaskItemFinishAttachingPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(ExtensionLadderItem))] [HarmonyPatch("StartLadderAnimation")] internal class ExtensionLadderItemStartLadderAnimationPatch { public static void Postfix(ExtensionLadderItem __instance) { //IL_00cf: Unknown result type (might be due to invalid IL or missing references) try { Plugin.Instance.PluginLogger.LogDebug((object)"Extension ladder started animation! Modifying kill trigger..."); GameObject gameObject = ((Component)__instance).gameObject; if ((Object)(object)gameObject == (Object)null) { Plugin.Instance.PluginLogger.LogError((object)"Could not fetch GameObject from ExtensionLadderItem."); } Transform val = gameObject.transform.Find("AnimContainer/MeshContainer/LadderMeshContainer/BaseLadder/LadderSecondPart/KillTrigger"); if ((Object)(object)val == (Object)null) { Plugin.Instance.PluginLogger.LogError((object)"Could not fetch KillTrigger Transform from ExtensionLadderItem."); } GameObject gameObject2 = ((Component)val).gameObject; if ((Object)(object)gameObject2 == (Object)null) { Plugin.Instance.PluginLogger.LogError((object)"Could not fetch KillTrigger GameObject from ExtensionLadderItem."); } KillLocalPlayer component = gameObject2.GetComponent<KillLocalPlayer>(); if ((Object)(object)component == (Object)null) { Plugin.Instance.PluginLogger.LogError((object)"Could not fetch KillLocalPlayer from KillTrigger GameObject."); } component.causeOfDeath = (CauseOfDeath)8; } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in ExtensionLadderItemStartLadderAnimationPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(ItemDropship))] [HarmonyPatch("Start")] internal class ItemDropshipStartPatch { public static void Postfix(ItemDropship __instance) { //IL_00d3: Unknown result type (might be due to invalid IL or missing references) try { Plugin.Instance.PluginLogger.LogDebug((object)"Item dropship spawned! Modifying kill trigger..."); GameObject gameObject = ((Component)__instance).gameObject; if ((Object)(object)gameObject == (Object)null) { Plugin.Instance.PluginLogger.LogError((object)"Could not fetch GameObject from ItemDropship."); } Transform val = gameObject.transform.Find("ItemShip/KillTrigger"); if ((Object)(object)val == (Object)null) { Plugin.Instance.PluginLogger.LogError((object)"Could not fetch KillTrigger Transform from ItemDropship."); } GameObject gameObject2 = ((Component)val).gameObject; if ((Object)(object)gameObject2 == (Object)null) { Plugin.Instance.PluginLogger.LogError((object)"Could not fetch KillTrigger GameObject from ItemDropship."); } KillLocalPlayer component = gameObject2.GetComponent<KillLocalPlayer>(); if ((Object)(object)component == (Object)null) { Plugin.Instance.PluginLogger.LogError((object)"Could not fetch KillLocalPlayer from KillTrigger GameObject."); } component.causeOfDeath = (CauseOfDeath)300; } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in ItemDropshipStartPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(Turret))] [HarmonyPatch("Update")] public class TurretUpdatePatch { public static void Postfix(Turret __instance) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Invalid comparison between Unknown and I4 if ((int)__instance.turretMode == 2) { PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if (localPlayerController.isPlayerDead && (int)localPlayerController.causeOfDeath == 7) { Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(localPlayerController, AdvancedCauseOfDeath.Other_Turret); } } } } [HarmonyPatch(typeof(Landmine))] [HarmonyPatch("SpawnExplosion")] public class LandmineSpawnExplosionPatch { private const string KILL_PLAYER_SIGNATURE = "Void KillPlayer(UnityEngine.Vector3, Boolean, CauseOfDeath, Int32)"; private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator, MethodBase method) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); List<CodeInstruction> list2 = BuildInstructionsToInsert(method); if (list2 == null) { Plugin.Instance.PluginLogger.LogError((object)"Could not build instructions to insert in LandmineSpawnExplosionPatch! Safely aborting..."); return instructions; } int num = -1; for (int i = 0; i < list.Count; i++) { CodeInstruction val = list[i]; if (val.opcode == OpCodes.Callvirt && val.operand.ToString() == "Void KillPlayer(UnityEngine.Vector3, Boolean, CauseOfDeath, Int32)") { num = i; break; } } if (num == -1) { Plugin.Instance.PluginLogger.LogError((object)"Could not find PlayerControllerB.KillPlayer call in LandmineSpawnExplosionPatch! Safely aborting..."); return instructions; } Plugin.Instance.PluginLogger.LogInfo((object)"Injecting patch into Landmine.SpawnExplosion..."); list.InsertRange(num, list2); Plugin.Instance.PluginLogger.LogInfo((object)"Done."); return list; } private static List<CodeInstruction> BuildInstructionsToInsert(MethodBase method) { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(); int num = 2; IList<LocalVariableInfo> localVariables = method.GetMethodBody().LocalVariables; LocalVariableInfo localVariableInfo = null; for (int i = 0; i < localVariables.Count; i++) { LocalVariableInfo localVariableInfo2 = localVariables[i]; if (localVariableInfo2.LocalType == typeof(PlayerControllerB)) { if (localVariableInfo != null) { Plugin.Instance.PluginLogger.LogError((object)"Found multiple PlayerControllerB local variables in LandmineSpawnExplosionPatch!"); return null; } localVariableInfo = localVariableInfo2; break; } } list.Add(new CodeInstruction(OpCodes.Ldloc_S, (object)localVariableInfo.LocalIndex)); list.Add(new CodeInstruction(OpCodes.Ldarg, (object)num)); list.Add(new CodeInstruction(OpCodes.Call, (object)typeof(LandmineSpawnExplosionPatch).GetMethod("RewriteCauseOfDeath"))); return list; } public static void RewriteCauseOfDeath(PlayerControllerB targetPlayer, float killRange) { AdvancedCauseOfDeath causeOfDeath = AdvancedCauseOfDeath.Blast; if (killRange == 5f) { causeOfDeath = AdvancedCauseOfDeath.Player_Jetpack_Blast; } else if (killRange == 5.7f) { causeOfDeath = AdvancedCauseOfDeath.Other_Landmine; } else if (killRange == 2.4f) { causeOfDeath = AdvancedCauseOfDeath.Other_Lightning; } AdvancedDeathTracker.SetCauseOfDeath(targetPlayer, causeOfDeath); } } [HarmonyPatch(typeof(HUDManager))] [HarmonyPatch("FillEndGameStats")] internal class HUDManagerFillEndGameStatsPatch { public static void Postfix(HUDManager __instance) { try { OverridePerformanceReport(__instance); } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in HUDManagerFillEndGameStatsPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } private static Random BuildSyncedRandom(HUDManager __instance) { int randomMapSeed = StartOfRound.Instance.randomMapSeed; Plugin.Instance.PluginLogger.LogDebug((object)("Syncing randomization to map seed: '" + randomMapSeed + "'")); return new Random(randomMapSeed); } private static void OverridePerformanceReport(HUDManager __instance) { Plugin.Instance.PluginLogger.LogDebug((object)"Applying Coroner patches to player notes..."); Random random = BuildSyncedRandom(__instance); for (int i = 0; i < __instance.statsUIElements.playerNotesText.Length; i++) { PlayerControllerB val = __instance.playersManager.allPlayerScripts[i]; if (!val.disconnectedMidGame && !val.isPlayerDead && !val.isPlayerControlled) { Plugin.Instance.PluginLogger.LogInfo((object)("Player " + i + " is not controlled by a player. Skipping...")); continue; } TextMeshProUGUI val2 = __instance.statsUIElements.playerNotesText[i]; if (val.isPlayerDead) { if (Plugin.Instance.PluginConfig.ShouldDisplayCauseOfDeath()) { if (Plugin.Instance.PluginConfig.ShouldDeathReplaceNotes()) { Plugin.Instance.PluginLogger.LogInfo((object)("[REPORT] Player " + i + " is dead! Replacing notes with Cause of Death...")); ((TMP_Text)val2).text = "Cause of Death: \n"; } else { Plugin.Instance.PluginLogger.LogInfo((object)("[REPORT] Player " + i + " is dead! Appending notes with Cause of Death...")); } AdvancedCauseOfDeath causeOfDeath = AdvancedDeathTracker.GetCauseOfDeath(val); string text = "* " + AdvancedDeathTracker.StringifyCauseOfDeath(causeOfDeath, random) + "\n"; ((TMP_Text)val2).text = ((TMP_Text)val2).text + text; } else { Plugin.Instance.PluginLogger.LogInfo((object)("[REPORT] Player " + i + " is dead, but Config says leave it be...")); } } else if (Plugin.Instance.PluginConfig.ShouldDisplayFunnyNotes()) { Plugin.Instance.PluginLogger.LogInfo((object)("[REPORT] Player " + i + " has no notes! Injecting something funny...")); string text2 = "* " + AdvancedDeathTracker.StringifyCauseOfDeath(null, random) + "\n"; ((TMP_Text)val2).text = ((TMP_Text)val2).text + text2; ((TMP_Text)val2).text = "Notes: \n"; ((TMP_Text)val2).text = ((TMP_Text)val2).text + text2; } else { Plugin.Instance.PluginLogger.LogInfo((object)("[REPORT] Player " + i + " has no notes, but Config says leave it be...")); } } AdvancedDeathTracker.ClearDeathTracker(); } } } namespace Coroner.LCAPI { internal class DeathBroadcasterLCAPI { private const string SIGNATURE_DEATH = "com.elitemastereric.coroner.death"; public static void Initialize() { Plugin.Instance.PluginLogger.LogDebug((object)"Initializing DeathBroadcaster..."); if (Plugin.Instance.IsLCAPIPresent) { Plugin.Instance.PluginLogger.LogDebug((object)"LC_API is present! Registering signature..."); Networking.GetString = (Action<string, string>)Delegate.Combine(Networking.GetString, new Action<string, string>(OnBroadcastString)); } else { Plugin.Instance.PluginLogger.LogError((object)"LC_API is not present! Why did you try to register the DeathBroadcaster?"); } } private static void OnBroadcastString(string data, string signature) { if (signature == "com.elitemastereric.coroner.death") { Plugin.Instance.PluginLogger.LogDebug((object)"Broadcast has been received from LC_API!"); string[] array = data.Split('|'); int playerIndex = int.Parse(array[0]); int num = int.Parse(array[1]); AdvancedCauseOfDeath advancedCauseOfDeath = (AdvancedCauseOfDeath)num; Plugin.Instance.PluginLogger.LogDebug((object)("Player " + playerIndex + " died of " + AdvancedDeathTracker.StringifyCauseOfDeath((AdvancedCauseOfDeath?)advancedCauseOfDeath))); AdvancedDeathTracker.SetCauseOfDeath(playerIndex, advancedCauseOfDeath, broadcast: false); } } public static void AttemptBroadcast(string data, string signature) { if (Plugin.Instance.IsLCAPIPresent) { Plugin.Instance.PluginLogger.LogDebug((object)"LC_API is present! Broadcasting..."); Networking.Broadcast(data, signature); } else { Plugin.Instance.PluginLogger.LogDebug((object)"LC_API is not present! Skipping broadcast..."); } } } }
plugins/LethalPosters.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7", FrameworkDisplayName = ".NET Framework 4.7")] [assembly: AssemblyCompany("LethalPosters")] [assembly: AssemblyConfiguration("release")] [assembly: AssemblyDescription("LethalCopmany posters API")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("LethalPosters")] [assembly: AssemblyTitle("LethalPosters")] [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 LethalPosters { internal class Config { private static ConfigFile ConfigFile { get; set; } static Config() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown ConfigFile = new ConfigFile(Paths.ConfigPath + "\\LethalPosters.cfg", true); foreach (string posterFolder in Plugin.PosterFolders) { int num = posterFolder.IndexOf("plugins\\", StringComparison.Ordinal) + "plugins\\".Length; int num2 = posterFolder.IndexOf("\\LethalPosters", num, StringComparison.Ordinal); string text = posterFolder.Substring(num, num2 - num); if (!ConfigFile.Bind<bool>(text, "Enabled", true, "Enable or disable " + text).Value) { Directory.Move(posterFolder, posterFolder + ".Disabled"); } } } } internal class Patches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(StartOfRound), "Start")] [HarmonyPostfix] private static void StartPatch() { Logger.LogInfo((object)"Patching Start in StartOfRound"); UpdateMaterials(0); } [HarmonyPatch(typeof(RoundManager), "GenerateNewLevelClientRpc")] [HarmonyPostfix] private static void GenerateNewLevelClientRpcPatch(int randomSeed) { Logger.LogInfo((object)"Patching GenerateNewLevelClientRpc in RoundManager"); UpdateMaterials(randomSeed); } private static void UpdateMaterials(int seed) { Logger.LogInfo((object)"Patching the textures"); Plugin.Rand = new Random(seed); Material[] materials = ((Renderer)GameObject.Find("HangarShip/Plane.001").GetComponent<MeshRenderer>()).materials; UpdateTexture(Plugin.PosterFiles, materials[0]); UpdateTexture(Plugin.TipFiles, materials[1]); } private static void UpdateTexture(IReadOnlyList<string> files, Material material) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown if (files.Count != 0) { int index = Plugin.Rand.Next(files.Count); Texture2D val = new Texture2D(2, 2); Logger.LogInfo((object)("Patching " + ((Object)material).name + " with " + files[index])); ImageConversion.LoadImage(val, File.ReadAllBytes(files[index])); material.mainTexture = (Texture)(object)val; } } } [BepInPlugin("LethalPosters", "LethalPosters", "1.0.0")] public class Plugin : BaseUnityPlugin { public static List<string> PosterFolders = new List<string>(); public static readonly List<string> PosterFiles = new List<string>(); public static readonly List<string> TipFiles = new List<string>(); public static Random Rand = new Random(); private void Awake() { //IL_00e4: Unknown result type (might be due to invalid IL or missing references) PosterFolders = Directory.GetDirectories(Paths.PluginPath, "LethalPosters", SearchOption.AllDirectories).ToList(); foreach (string posterFolder in PosterFolders) { string[] files = Directory.GetFiles(Path.Combine(posterFolder, "posters")); foreach (string text in files) { if (Path.GetExtension(text) != ".old") { PosterFiles.Add(text); } } files = Directory.GetFiles(Path.Combine(posterFolder, "tips")); foreach (string text2 in files) { if (Path.GetExtension(text2) != ".old") { TipFiles.Add(text2); } } } Patches.Init(((BaseUnityPlugin)this).Logger); new Harmony("LethalPosters").PatchAll(typeof(Patches)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin LethalPosters (1.0.0) is loaded!"); } } public static class PluginInfo { public const string PLUGIN_GUID = "LethalPosters"; public const string PLUGIN_NAME = "LethalPosters"; public const string PLUGIN_VERSION = "1.0.0"; } }
plugins/ScannablePlayerItems.dll
Decompiled 2 years agousing System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; using UnityEngine; [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("ScannablePlayerItems")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+a6d9df5fba9dbc11359b52099c6517c5b83d3bbf")] [assembly: AssemblyProduct("ScannablePlayerItems")] [assembly: AssemblyTitle("ScannablePlayerItems")] [assembly: AssemblyVersion("1.0.0.0")] namespace ScannablePlayerItems { public class HarmonyPatches { private static Harmony instance; public const string InstanceId = "com.graze.scannableplayeritems"; public static bool IsPatched { get; private set; } internal static void ApplyHarmonyPatches() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown if (!IsPatched) { if (instance == null) { instance = new Harmony("com.graze.scannableplayeritems"); } instance.PatchAll(Assembly.GetExecutingAssembly()); IsPatched = true; } } internal static void RemoveHarmonyPatches() { if (instance != null && IsPatched) { instance.UnpatchAll("com.graze.scannableplayeritems"); IsPatched = false; } } } [BepInPlugin("com.graze.scannableplayeritems", "ScannablePlayerItems", "1.0.3")] public class Plugin : BaseUnityPlugin { public static Plugin bugin; private Plugin() { HarmonyPatches.ApplyHarmonyPatches(); bugin = this; } private void Init() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ScanNodeSetUp.instance == (Object)null) { HarmonyPatches.ApplyHarmonyPatches(); ScanNodeSetUp.instance = new GameObject("CustomScanNodeScript").AddComponent<ScanNodeSetUp>(); Object.DontDestroyOnLoad((Object)(object)((Component)ScanNodeSetUp.instance).gameObject); } } private void Start() { HarmonyPatches.ApplyHarmonyPatches(); Init(); } } internal class NodeHider : MonoBehaviour { private GrabbableObject obj; public GameObject node; private void Start() { obj = ((Component)this).gameObject.GetComponent<GrabbableObject>(); } private void Update() { if (obj.isHeld || obj.isPocketed || obj.isHeldByEnemy || obj.isInShipRoom || obj.isInElevator) { node.SetActive(false); } else { node.SetActive(true); } } } public class ScanNodeSetUp : MonoBehaviour { public static volatile ScanNodeSetUp instance; private static GameObject ScanNode; public static bool hide; private void Start() { HarmonyPatches.ApplyHarmonyPatches(); } private void Update() { if ((Object)(object)Plugin.bugin == (Object)null) { Plugin.bugin = ((Component)this).gameObject.AddComponent<Plugin>(); } } public static void AddNode(GrabbableObject obj) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_0441: Unknown result type (might be due to invalid IL or missing references) //IL_0446: Unknown result type (might be due to invalid IL or missing references) //IL_044b: Unknown result type (might be due to invalid IL or missing references) //IL_04e4: Unknown result type (might be due to invalid IL or missing references) //IL_04e9: Unknown result type (might be due to invalid IL or missing references) //IL_04ee: Unknown result type (might be due to invalid IL or missing references) //IL_0587: Unknown result type (might be due to invalid IL or missing references) //IL_058c: Unknown result type (might be due to invalid IL or missing references) //IL_0591: Unknown result type (might be due to invalid IL or missing references) //IL_062a: Unknown result type (might be due to invalid IL or missing references) //IL_062f: Unknown result type (might be due to invalid IL or missing references) //IL_0634: Unknown result type (might be due to invalid IL or missing references) //IL_06cd: Unknown result type (might be due to invalid IL or missing references) //IL_06d2: Unknown result type (might be due to invalid IL or missing references) //IL_06d7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ScanNode == (Object)null) { ScanNode = ((Component)Object.FindObjectOfType<ScanNodeProperties>()).gameObject; } if (((object)obj).GetType() == typeof(Shovel)) { GameObject val = Object.Instantiate<GameObject>(ScanNode, ((Component)obj).transform.position, Quaternion.Euler(Vector3.zero), ((Component)obj).transform); ScanNodeProperties component = val.GetComponent<ScanNodeProperties>(); ((Component)obj).gameObject.AddComponent<NodeHider>().node = val; component.nodeType = 0; component.headerText = "Shovel"; component.subText = "Hit Enemys"; component.scrapValue = 0; component.minRange = 1; component.maxRange = 13; component.creatureScanID = -1; } if (((object)obj).GetType() == typeof(SprayPaintItem)) { GameObject val2 = Object.Instantiate<GameObject>(ScanNode, ((Component)obj).transform.position, Quaternion.Euler(Vector3.zero), ((Component)obj).transform); ScanNodeProperties component2 = val2.GetComponent<ScanNodeProperties>(); ((Component)obj).gameObject.AddComponent<NodeHider>().node = val2; component2.nodeType = 0; component2.headerText = "Spary Paint"; component2.subText = "Mark A Trail"; component2.scrapValue = 0; component2.minRange = 1; component2.maxRange = 13; component2.creatureScanID = -1; } if (((object)obj).GetType() == typeof(FlashlightItem)) { GameObject val3 = Object.Instantiate<GameObject>(ScanNode, ((Component)obj).transform.position, Quaternion.Euler(Vector3.zero), ((Component)obj).transform); ScanNodeProperties component3 = val3.GetComponent<ScanNodeProperties>(); ((Component)obj).gameObject.AddComponent<NodeHider>().node = val3; component3.nodeType = 0; if (((Object)obj).name.Contains("BB")) { component3.headerText = "Flashlight"; component3.subText = "Make Sure to Charge me!"; } else { component3.headerText = "Pro Flashlight"; component3.subText = "Flashlight But Better"; } component3.scrapValue = 0; component3.minRange = 1; component3.maxRange = 13; component3.creatureScanID = -1; } if (((object)obj).GetType() == typeof(BoomboxItem)) { GameObject val4 = Object.Instantiate<GameObject>(ScanNode, ((Component)obj).transform.position, Quaternion.Euler(Vector3.zero), ((Component)obj).transform); ScanNodeProperties component4 = val4.GetComponent<ScanNodeProperties>(); ((Component)obj).gameObject.AddComponent<NodeHider>().node = val4; component4.nodeType = 0; component4.headerText = "BoomBox"; component4.subText = "Boots'n-cats'n.."; component4.scrapValue = 0; component4.minRange = 1; component4.maxRange = 13; component4.creatureScanID = -1; } if (((object)obj).GetType() == typeof(PatcherTool)) { GameObject val5 = Object.Instantiate<GameObject>(ScanNode, ((Component)obj).transform.position, Quaternion.Euler(Vector3.zero), ((Component)obj).transform); ScanNodeProperties component5 = val5.GetComponent<ScanNodeProperties>(); ((Component)obj).gameObject.AddComponent<NodeHider>().node = val5; component5.nodeType = 0; component5.headerText = "ZapGun"; component5.subText = "Stun Enemies"; component5.scrapValue = 0; component5.minRange = 1; component5.maxRange = 13; component5.creatureScanID = -1; } if (((object)obj).GetType() == typeof(StunGrenadeItem)) { GameObject val6 = Object.Instantiate<GameObject>(ScanNode, ((Component)obj).transform.position, Quaternion.Euler(Vector3.zero), ((Component)obj).transform); ScanNodeProperties component6 = val6.GetComponent<ScanNodeProperties>(); ((Component)obj).gameObject.AddComponent<NodeHider>().node = val6; component6.nodeType = 1; component6.headerText = "Stun Grenade"; component6.subText = "KABOOM!"; component6.scrapValue = 0; component6.minRange = 1; component6.maxRange = 13; component6.creatureScanID = -1; } if (((object)obj).GetType() == typeof(TetraChemicalItem)) { GameObject val7 = Object.Instantiate<GameObject>(ScanNode, ((Component)obj).transform.position, Quaternion.Euler(Vector3.zero), ((Component)obj).transform); ScanNodeProperties component7 = val7.GetComponent<ScanNodeProperties>(); ((Component)obj).gameObject.AddComponent<NodeHider>().node = val7; component7.nodeType = 0; component7.headerText = "TZP"; component7.subText = "Good for Headaches"; component7.scrapValue = 0; component7.minRange = 1; component7.maxRange = 13; component7.creatureScanID = -1; } if (((object)obj).GetType() == typeof(ExtensionLadderItem)) { GameObject val8 = Object.Instantiate<GameObject>(ScanNode, ((Component)obj).transform.position, Quaternion.Euler(Vector3.zero), ((Component)obj).transform); ScanNodeProperties component8 = val8.GetComponent<ScanNodeProperties>(); ((Component)obj).gameObject.AddComponent<NodeHider>().node = val8; component8.nodeType = 1; component8.headerText = "Extendable Ladder"; component8.subText = "Deploy With Care"; component8.scrapValue = 0; component8.minRange = 1; component8.maxRange = 13; component8.creatureScanID = -1; } if (((object)obj).GetType() == typeof(WalkieTalkie)) { GameObject val9 = Object.Instantiate<GameObject>(ScanNode, ((Component)obj).transform.position, Quaternion.Euler(Vector3.zero), ((Component)obj).transform); ScanNodeProperties component9 = val9.GetComponent<ScanNodeProperties>(); ((Component)obj).gameObject.AddComponent<NodeHider>().node = val9; component9.nodeType = 0; component9.headerText = "Walkie-Talkie"; component9.subText = "Communicate Easy"; component9.scrapValue = 0; component9.minRange = 1; component9.maxRange = 13; component9.creatureScanID = -1; } if (((object)obj).GetType() == typeof(LockPicker)) { GameObject val10 = Object.Instantiate<GameObject>(ScanNode, ((Component)obj).transform.position, Quaternion.Euler(Vector3.zero), ((Component)obj).transform); ScanNodeProperties component10 = val10.GetComponent<ScanNodeProperties>(); ((Component)obj).gameObject.AddComponent<NodeHider>().node = val10; component10.nodeType = 0; component10.headerText = "Lock Pick"; component10.subText = "Who Needs Keys?"; component10.scrapValue = 0; component10.minRange = 1; component10.maxRange = 13; component10.creatureScanID = -1; } if (((object)obj).GetType() == typeof(JetpackItem)) { GameObject val11 = Object.Instantiate<GameObject>(ScanNode, ((Component)obj).transform.position, Quaternion.Euler(Vector3.zero), ((Component)obj).transform); ScanNodeProperties component11 = val11.GetComponent<ScanNodeProperties>(); ((Component)obj).gameObject.AddComponent<NodeHider>().node = val11; component11.nodeType = 1; component11.headerText = "JetPack"; component11.subText = "WEEEE!"; component11.scrapValue = 0; component11.minRange = 1; component11.maxRange = 13; component11.creatureScanID = -1; } } } internal class PluginInfo { public const string GUID = "com.graze.scannableplayeritems"; public const string Name = "ScannablePlayerItems"; public const string Version = "1.0.3"; } } namespace ScannablePlayerItems.Patches { [HarmonyPatch(typeof(GrabbableObject))] [HarmonyPatch(/*Could not decode attribute arguments.*/)] internal class ItemPatches { private static void Postfix(GrabbableObject __instance) { if ((Object)(object)((Component)__instance).GetComponentInChildren<ScanNodeProperties>() == (Object)null) { ScanNodeSetUp.AddNode(__instance); } } } }
plugins/HelmetCamera.dll
Decompiled 2 years agousing System; using System.Collections; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("HelmetCamera")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("HelmetCamera")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("b99c4d46-5f13-47b3-a5af-5e3f37772e77")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace HelmetCamera { [BepInPlugin("RickArg.lethalcompany.helmetcameras", "Helmet_Cameras", "2.1.5")] public class PluginInit : BaseUnityPlugin { public static Harmony _harmony; public static ConfigEntry<int> config_isHighQuality; public static ConfigEntry<int> config_renderDistance; public static ConfigEntry<int> config_cameraFps; private void Awake() { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown config_isHighQuality = ((BaseUnityPlugin)this).Config.Bind<int>("MONITOR QUALITY", "monitorResolution", 0, "Low FPS affection. High Quality mode. 0 - vanilla (48x48), 1 - vanilla+ (128x128), 2 - mid quality (256x256), 3 - high quality (512x512), 4 - Very High Quality (1024x1024)"); config_renderDistance = ((BaseUnityPlugin)this).Config.Bind<int>("MONITOR QUALITY", "renderDistance", 20, "Low FPS affection. Render distance for helmet camera."); config_cameraFps = ((BaseUnityPlugin)this).Config.Bind<int>("MONITOR QUALITY", "cameraFps", 30, "Very high FPS affection. FPS for helmet camera. To increase YOUR fps, you should low cameraFps value."); _harmony = new Harmony("HelmetCamera"); _harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Helmet_Cameras is loaded with version 2.1.5!"); ((BaseUnityPlugin)this).Logger.LogInfo((object)"--------Helmet camera patch done.---------"); } } public static class PluginInfo { public const string PLUGIN_GUID = "RickArg.lethalcompany.helmetcameras"; public const string PLUGIN_NAME = "Helmet_Cameras"; public const string PLUGIN_VERSION = "2.1.5"; } public class Plugin : MonoBehaviour { private RenderTexture renderTexture; private bool isMonitorChanged = false; private GameObject helmetCameraNew; private bool isSceneLoaded = false; private bool isCoroutineStarted = false; private int currentTransformIndex; private int resolution = 0; private int renderDistance = 50; private float cameraFps = 30f; private float elapsed; private void Awake() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown resolution = PluginInit.config_isHighQuality.Value; renderDistance = PluginInit.config_renderDistance.Value; cameraFps = PluginInit.config_cameraFps.Value; switch (resolution) { case 0: renderTexture = new RenderTexture(48, 48, 24); break; case 1: renderTexture = new RenderTexture(128, 128, 24); break; case 2: renderTexture = new RenderTexture(256, 256, 24); break; case 3: renderTexture = new RenderTexture(512, 512, 24); break; case 4: renderTexture = new RenderTexture(1024, 1024, 24); break; } } public void Start() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) isCoroutineStarted = false; while ((Object)(object)helmetCameraNew == (Object)null) { helmetCameraNew = new GameObject("HelmetCamera"); } Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name != "MainMenu") { activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name != "InitScene") { activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name != "InitSceneLaunchOptions") { isSceneLoaded = true; Debug.Log((object)"[HELMET_CAMERAS] Starting coroutine..."); ((MonoBehaviour)this).StartCoroutine(LoadSceneEnter()); return; } } } isSceneLoaded = false; isMonitorChanged = false; } private IEnumerator LoadSceneEnter() { Debug.Log((object)"[HELMET_CAMERAS] 5 seconds for init mode... Please wait..."); yield return (object)new WaitForSeconds(5f); isCoroutineStarted = true; if ((Object)(object)GameObject.Find("Environment/HangarShip/Cameras/ShipCamera") != (Object)null) { Debug.Log((object)"[HELMET_CAMERAS] Ship camera founded..."); if (!isMonitorChanged) { ((Renderer)GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall/Cube").GetComponent<MeshRenderer>()).materials[2].mainTexture = ((Renderer)GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall/Cube.001").GetComponent<MeshRenderer>()).materials[2].mainTexture; ((Renderer)GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall/Cube.001").GetComponent<MeshRenderer>()).materials[2].mainTexture = (Texture)(object)renderTexture; helmetCameraNew.AddComponent<Camera>(); ((Behaviour)helmetCameraNew.GetComponent<Camera>()).enabled = false; helmetCameraNew.GetComponent<Camera>().targetTexture = renderTexture; helmetCameraNew.GetComponent<Camera>().cullingMask = 20649983; helmetCameraNew.GetComponent<Camera>().farClipPlane = renderDistance; helmetCameraNew.GetComponent<Camera>().nearClipPlane = 0.55f; isMonitorChanged = true; Debug.Log((object)"[HELMET_CAMERAS] Monitors were changed..."); Debug.Log((object)"[HELMET_CAMERAS] Turning off vanilla internal ship camera"); ((Behaviour)GameObject.Find("Environment/HangarShip/Cameras/ShipCamera").GetComponent<Camera>()).enabled = false; } } } public void Update() { //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) bool flag = isSceneLoaded && isCoroutineStarted; if (flag && StartOfRound.Instance.localPlayerController.isInHangarShipRoom) { helmetCameraNew.SetActive(true); elapsed += Time.deltaTime; if (elapsed > 1f / cameraFps) { elapsed = 0f; ((Behaviour)helmetCameraNew.GetComponent<Camera>()).enabled = true; } else { ((Behaviour)helmetCameraNew.GetComponent<Camera>()).enabled = false; } GameObject val = GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall/Cube.001/CameraMonitorScript"); currentTransformIndex = val.GetComponent<ManualCameraRenderer>().targetTransformIndex; TransformAndName val2 = val.GetComponent<ManualCameraRenderer>().radarTargets[currentTransformIndex]; if (!val2.isNonPlayer) { try { helmetCameraNew.transform.SetPositionAndRotation(val2.transform.Find("ScavengerModel/metarig/CameraContainer/MainCamera/HelmetLights").position + new Vector3(0f, 0f, 0f), val2.transform.Find("ScavengerModel/metarig/CameraContainer/MainCamera/HelmetLights").rotation * Quaternion.Euler(0f, 0f, 0f)); DeadBodyInfo[] array = Object.FindObjectsOfType<DeadBodyInfo>(); for (int i = 0; i < array.Length; i++) { if (array[i].playerScript.playerUsername == val2.name) { helmetCameraNew.transform.SetPositionAndRotation(((Component)array[i]).gameObject.transform.Find("spine.001/spine.002/spine.003").position, ((Component)array[i]).gameObject.transform.Find("spine.001/spine.002/spine.003").rotation * Quaternion.Euler(0f, 0f, 0f)); } } return; } catch (NullReferenceException) { Debug.Log((object)"[HELMET_CAMERAS] ERROR NULL REFERENCE"); return; } } helmetCameraNew.transform.SetPositionAndRotation(val2.transform.position + new Vector3(0f, 1.6f, 0f), val2.transform.rotation * Quaternion.Euler(0f, -90f, 0f)); } else if (flag && !StartOfRound.Instance.localPlayerController.isInHangarShipRoom) { helmetCameraNew.SetActive(false); } } } } namespace HelmetCamera.Patches { [HarmonyPatch] internal class HelmetCamera { public static void InitCameras() { GameObject val = GameObject.Find("Environment/HangarShip/Cameras/ShipCamera"); val.AddComponent<Plugin>(); } [HarmonyPatch(typeof(StartOfRound), "Start")] [HarmonyPostfix] public static void InitCamera(ref ManualCameraRenderer __instance) { InitCameras(); } } }
plugins/LateCompanyV1.0.6.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; 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: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")] [assembly: AssemblyCompany("LateCompany")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+31dbb98cfa5670c23f3ffb21c05582c54159b82d")] [assembly: AssemblyProduct("LateCompany")] [assembly: AssemblyTitle("LateCompany")] [assembly: AssemblyVersion("1.0.0.0")] [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 LateCompany { public static class PluginInfo { public const string GUID = "twig.latecompany"; public const string PrintName = "Late Company"; public const string Version = "1.0.6"; } [BepInPlugin("twig.latecompany", "Late Company", "1.0.6")] internal class Plugin : BaseUnityPlugin { private ConfigEntry<bool> configLateJoinOrbitOnly; public static bool OnlyLateJoinInOrbit = false; public static bool LobbyJoinable = true; public void Awake() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown configLateJoinOrbitOnly = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Late join orbit only", true, "Don't allow joining while the ship is not in orbit."); OnlyLateJoinInOrbit = configLateJoinOrbitOnly.Value; Harmony val = new Harmony("twig.latecompany"); val.PatchAll(typeof(Plugin).Assembly); ((BaseUnityPlugin)this).Logger.Log((LogLevel)16, (object)"Late Company loaded!"); } public static void SetLobbyJoinable(bool joinable) { LobbyJoinable = joinable; GameNetworkManager.Instance.SetLobbyJoinable(joinable); QuickMenuManager val = Object.FindObjectOfType<QuickMenuManager>(); if (Object.op_Implicit((Object)(object)val)) { val.inviteFriendsTextAlpha.alpha = (joinable ? 1f : 0.2f); } } } } namespace LateCompany.Patches { [HarmonyPatch(typeof(GameNetworkManager), "LeaveLobbyAtGameStart")] [HarmonyWrapSafe] internal static class LeaveLobbyAtGameStart_Patch { [HarmonyPrefix] private static bool Prefix() { return false; } } [HarmonyPatch(typeof(GameNetworkManager), "ConnectionApproval")] [HarmonyWrapSafe] internal static class ConnectionApproval_Patch { [HarmonyPostfix] private static void Postfix(ConnectionApprovalRequest request, ConnectionApprovalResponse response) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if (request.ClientNetworkId != NetworkManager.Singleton.LocalClientId && response.Reason.Contains("Game has already started") && Plugin.LobbyJoinable) { response.Reason = ""; response.CreatePlayerObject = false; response.Approved = true; response.Pending = false; } } } [HarmonyPatch(typeof(QuickMenuManager), "DisableInviteFriendsButton")] [HarmonyWrapSafe] internal static class DisableInviteFriendsButton_Patch { [HarmonyPrefix] private static bool Prefix() { return false; } } [HarmonyPatch(typeof(QuickMenuManager), "InviteFriendsButton")] [HarmonyWrapSafe] internal static class InviteFriendsButton_Patch { [HarmonyPrefix] private static bool Prefix() { if (Plugin.LobbyJoinable) { GameNetworkManager.Instance.InviteFriendsUI(); } return false; } } internal class RpcEnum : NetworkBehaviour { public static int None => 0; public static int Client => 2; public static int Server => 1; } internal static class WeatherSync { public static bool DoOverride = false; public static LevelWeatherType CurrentWeather = (LevelWeatherType)(-1); } [HarmonyPatch(typeof(RoundManager), "__rpc_handler_1193916134")] [HarmonyWrapSafe] internal static class __rpc_handler_1193916134_Patch { public static FieldInfo RPCExecStage = typeof(NetworkBehaviour).GetField("__rpc_exec_stage", BindingFlags.Instance | BindingFlags.NonPublic); [HarmonyPrefix] private static bool Prefix(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; try { int num = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref num); int num2 = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref num2); int num3 = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref num3); WeatherSync.DoOverride = true; WeatherSync.CurrentWeather = (LevelWeatherType)num3; RPCExecStage.SetValue(target, RpcEnum.Client); ((RoundManager)((target is RoundManager) ? target : null)).GenerateNewLevelClientRpc(num, num2); RPCExecStage.SetValue(target, RpcEnum.None); } catch { ((FastBufferReader)(ref reader)).Seek(0); return true; } return false; } } [HarmonyPatch(typeof(RoundManager), "SetToCurrentLevelWeather")] [HarmonyWrapSafe] internal static class SetToCurrentLevelWeather_Patch { [HarmonyPrefix] private static bool Prefix() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) if (!WeatherSync.DoOverride) { return true; } WeatherSync.DoOverride = false; TimeOfDay.Instance.currentLevelWeather = WeatherSync.CurrentWeather; return false; } } [HarmonyPatch(typeof(StartOfRound), "OnPlayerConnectedClientRpc")] [HarmonyWrapSafe] internal class OnPlayerConnectedClientRpc_Patch { public static MethodInfo BeginSendClientRpc = typeof(RoundManager).GetMethod("__beginSendClientRpc", BindingFlags.Instance | BindingFlags.NonPublic); public static MethodInfo EndSendClientRpc = typeof(RoundManager).GetMethod("__endSendClientRpc", BindingFlags.Instance | BindingFlags.NonPublic); [HarmonyPostfix] private static void Postfix(ulong clientId, int connectedPlayers, ulong[] connectedPlayerIdsOrdered, int assignedPlayerObjectId, int serverMoneyAmount, int levelID, int profitQuota, int timeUntilDeadline, int quotaFulfilled, int randomSeed) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) StartOfRound instance = StartOfRound.Instance; PlayerControllerB val = instance.allPlayerScripts[assignedPlayerObjectId]; if (instance.connectedPlayersAmount + 1 >= instance.allPlayerScripts.Length) { Plugin.SetLobbyJoinable(joinable: false); } val.DisablePlayerModel(instance.allPlayerObjects[assignedPlayerObjectId], true, true); if (((NetworkBehaviour)instance).IsServer && !instance.inShipPhase) { RoundManager instance2 = RoundManager.Instance; ClientRpcParams val2 = default(ClientRpcParams); val2.Send = new ClientRpcSendParams { TargetClientIds = new List<ulong> { clientId } }; ClientRpcParams val3 = val2; FastBufferWriter val4 = (FastBufferWriter)BeginSendClientRpc.Invoke(instance2, new object[3] { 1193916134u, val3, 0 }); BytePacker.WriteValueBitPacked(val4, StartOfRound.Instance.randomMapSeed); BytePacker.WriteValueBitPacked(val4, StartOfRound.Instance.currentLevelID); BytePacker.WriteValueBitPacked(val4, (short)instance2.currentLevel.currentWeather); EndSendClientRpc.Invoke(instance2, new object[4] { val4, 1193916134u, val3, 0 }); FastBufferWriter val5 = (FastBufferWriter)BeginSendClientRpc.Invoke(instance2, new object[3] { 2729232387u, val3, 0 }); EndSendClientRpc.Invoke(instance2, new object[4] { val5, 2729232387u, val3, 0 }); } instance.livingPlayers = instance.connectedPlayersAmount + 1; for (int i = 0; i < instance.allPlayerScripts.Length; i++) { PlayerControllerB val6 = instance.allPlayerScripts[i]; if (val6.isPlayerControlled && val6.isPlayerDead) { instance.livingPlayers--; } } } } [HarmonyPatch(typeof(StartOfRound), "OnPlayerDC")] [HarmonyWrapSafe] internal class OnPlayerDC_Patch { [HarmonyPostfix] public static void Postfix() { if (StartOfRound.Instance.inShipPhase || !Plugin.OnlyLateJoinInOrbit) { Plugin.SetLobbyJoinable(joinable: true); } } } [HarmonyPatch(typeof(StartOfRound), "StartGame")] [HarmonyWrapSafe] internal class StartGame_Patch { [HarmonyPrefix] public static void Prefix() { if (Plugin.OnlyLateJoinInOrbit) { Plugin.SetLobbyJoinable(joinable: false); } } } [HarmonyPatch(typeof(StartOfRound), "SetShipReadyToLand")] [HarmonyWrapSafe] internal class SetShipReadyToLand_Patch { [HarmonyPrefix] public static void Postfix() { if (Plugin.OnlyLateJoinInOrbit && StartOfRound.Instance.connectedPlayersAmount + 1 < StartOfRound.Instance.allPlayerScripts.Length) { Plugin.SetLobbyJoinable(joinable: true); } } } }