Please disclose if any significant portion of your mod was created 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 CameraPlus v0.0.1
CameraPlus.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.Logging; using CameraPlus; using GameNetcodeStuff; using HarmonyLib; using MelonLoader; using Microsoft.CodeAnalysis; using UnityEngine; 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: MelonInfo(typeof(Mod), "Camera Plus", "0.0.1", "Cyconi", null)] [assembly: MelonGame(null, "Lethal Company")] [assembly: AssemblyTitle("CameraPlus")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("CameraPlus")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("8e221419-e60f-4d18-a6c2-49b5948a9a4c")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [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 CameraPlus { internal class CameraPatch { public static Harmony instance = new Harmony("Cyconi"); public static float zoomFov = 30f; private static float originalFov = 0f; private static Vector3 visorScale; public static void StartPatch() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown //IL_00c1: Expected O, but got Unknown try { instance.Patch((MethodBase)typeof(PlayerControllerB).GetMethod("Awake", AccessTools.all), (HarmonyMethod)null, new HarmonyMethod(typeof(CameraPatch).GetMethod("Awake", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); CLog.L("Awake Patched!"); } catch (Exception) { CLog.L("Failed to Patch Awake"); } try { instance.Patch((MethodBase)typeof(PlayerControllerB).GetMethod("Update", AccessTools.all), new HarmonyMethod(typeof(CameraPatch).GetMethod("Prefix", BindingFlags.Static | BindingFlags.NonPublic)), new HarmonyMethod(typeof(CameraPatch).GetMethod("Postfix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); CLog.L("Update Patched!"); } catch (Exception) { CLog.L("Failed to Patch Update"); } } private static void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) visorScale = new Vector3(0f, 0f, 0f); } private static void Prefix(PlayerControllerB __instance) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) originalFov = __instance.gameplayCamera.fieldOfView; __instance.localVisor.localScale = visorScale; Keyboard current = Keyboard.current; if ((((ButtonControl)current.leftCtrlKey).isPressed && ((ButtonControl)current.tKey).wasPressedThisFrame) || ((ButtonControl)current.upArrowKey).wasPressedThisFrame || ((ButtonControl)current.downArrowKey).wasPressedThisFrame) { ThirdPerson.On3rdPersonStart(); } ThirdPerson.Camera3rdUpdate(); } internal static void Postfix(PlayerControllerB __instance) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) Mouse current = Mouse.current; if (current.middleButton.isPressed || current.forwardButton.wasPressedThisFrame) { zoomFov = 30f; } try { if (current.forwardButton.isPressed) { float y = ((InputControl<Vector2>)(object)current.scroll).ReadValue().y; if (y > 0f && zoomFov > 10f) { zoomFov -= 5f; } else if (y < 0f && zoomFov < 140f && zoomFov >= 10f) { zoomFov += 5f; } else if (y > 0f && zoomFov <= 10f && zoomFov > 1f) { zoomFov -= 1f; } else if (y < 0f && zoomFov <= 10f) { zoomFov += 1f; } __instance.gameplayCamera.fieldOfView = Mathf.Lerp(originalFov, zoomFov, Time.deltaTime * 10f); } else if (!current.forwardButton.isPressed) { if (__instance.inTerminalMenu) { zoomFov = 60f; } else if (__instance.IsInspectingItem) { zoomFov = 46f; } else { zoomFov = ThirdPerson.fov; } __instance.gameplayCamera.fieldOfView = Mathf.Lerp(originalFov, zoomFov, Time.deltaTime * 10f); } } catch { } } } internal class CLog { internal static bool Melon; internal static bool Bepin; internal static void L(string MessageToLog) { if (Melon) { MelonLogger.Msg(ConsoleColor.White, "[~>] " + MessageToLog); } if (Bepin) { Plugin.Log.Log((LogLevel)63, (object)("[~>] " + MessageToLog)); } } } public class Mod : MelonMod { public static bool isPlayerInit; public override void OnApplicationStart() { CLog.Melon = true; CLog.L("Updated for Lethal Company v45"); CLog.L("MelonLoader Detected! \n\n\t\t\t - Cyconi \n"); CameraPatch.StartPatch(); StartMsg.Msg(); } public override void OnSceneWasInitialized(int buildIndex, string sceneName) { if (isPlayerInit) { ThirdPerson.On3rdPersonStart(); } } } [BepInPlugin("cyconi.cameraplus", "Camera Plus", "0.0.1")] internal class Plugin : BaseUnityPlugin { internal static Plugin instance; internal static ManualLogSource Log; public void Awake() { CLog.Bepin = true; instance = this; Log = ((BaseUnityPlugin)this).Logger; CLog.L("Updated for Lethal Company v45"); CLog.L("BepInEx Detected! \n\n\t\t\t - Cyconi \n"); CameraPatch.StartPatch(); StartMsg.Msg(); } } internal class StartMsg { internal static void Msg() { CLog.L(""); CLog.L("================== Keybinds =================="); CLog.L("Mouse5 | zoom"); CLog.L("Middle Mouse | reset FOV"); CLog.L("Scroll (Zoom) | adjust zoom FOV"); CLog.L("Scroll (3rd) | adjust the camera distance"); CLog.L("Crtl + T | cycle camera (1st, 3rd)"); CLog.L("Arrow Up / Down | adjust FOV for all cameras"); CLog.L("Will add keybinds later"); CLog.L("================== Keybinds ================="); CLog.L(""); } } internal class ThirdPerson { public static bool InThird = false; private static GameObject MainCamera; private static GameObject BackCamera; private static GameObject FrontCamera; private static int LastCamera; internal static bool isUpdating; internal static float fov = 66f; public static float proxThresh = 1.3f; public static float proxThreshF = 0.4f; public static float proxThreshB = 1f; public static void On3rdPersonStart() { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)BackCamera != (Object)null) && !((Object)(object)FrontCamera != (Object)null)) { if ((Object)(object)MainCamera == (Object)null) { MainCamera = ((Component)GameNetworkManager.Instance.localPlayerController.gameplayCamera).gameObject; } BackCamera = GameObject.CreatePrimitive((PrimitiveType)3); Object.Destroy((Object)(object)BackCamera.GetComponent<MeshRenderer>()); FrontCamera = GameObject.CreatePrimitive((PrimitiveType)3); Object.Destroy((Object)(object)FrontCamera.GetComponent<MeshRenderer>()); BackCamera.transform.localScale = MainCamera.transform.localScale; Rigidbody val = BackCamera.AddComponent<Rigidbody>(); val.isKinematic = true; val.useGravity = false; if (Object.op_Implicit((Object)(object)BackCamera.GetComponent<Collider>())) { BackCamera.GetComponent<Collider>().enabled = false; } BackCamera.GetComponent<Renderer>().enabled = false; BackCamera.AddComponent<Camera>(); BackCamera.transform.parent = MainCamera.transform; BackCamera.transform.rotation = MainCamera.transform.rotation; BackCamera.transform.position = MainCamera.transform.position; Transform transform = BackCamera.transform; transform.position -= BackCamera.transform.forward * 4f; ((Behaviour)MainCamera.GetComponent<Camera>()).enabled = false; BackCamera.GetComponent<Camera>().fieldOfView = fov; FrontCamera.transform.localScale = MainCamera.transform.localScale; Rigidbody val2 = FrontCamera.AddComponent<Rigidbody>(); val2.isKinematic = true; val2.useGravity = false; if (Object.op_Implicit((Object)(object)FrontCamera.GetComponent<Collider>())) { FrontCamera.GetComponent<Collider>().enabled = false; } FrontCamera.GetComponent<Renderer>().enabled = false; FrontCamera.AddComponent<Camera>(); FrontCamera.transform.parent = MainCamera.transform; FrontCamera.transform.rotation = MainCamera.transform.rotation; FrontCamera.transform.Rotate(0f, 180f, 0f); FrontCamera.transform.position = MainCamera.transform.position; Transform transform2 = FrontCamera.transform; transform2.position += -FrontCamera.transform.forward * 4f; ((Behaviour)MainCamera.GetComponent<Camera>()).enabled = false; FrontCamera.GetComponent<Camera>().fieldOfView = fov; ((Behaviour)BackCamera.GetComponent<Camera>()).enabled = false; ((Behaviour)FrontCamera.GetComponent<Camera>()).enabled = false; ((Behaviour)((Component)GameNetworkManager.Instance.localPlayerController.gameplayCamera).GetComponent<Camera>()).enabled = true; isUpdating = true; } } public static void Switch() { switch (LastCamera) { case 0: LastCamera = 1; ((Behaviour)MainCamera.GetComponent<Camera>()).enabled = false; ((Behaviour)BackCamera.GetComponent<Camera>()).enabled = true; ((Behaviour)FrontCamera.GetComponent<Camera>()).enabled = false; InThird = true; ColliderToggles(); break; case 1: LastCamera = 2; ((Behaviour)MainCamera.GetComponent<Camera>()).enabled = false; ((Behaviour)BackCamera.GetComponent<Camera>()).enabled = false; ((Behaviour)FrontCamera.GetComponent<Camera>()).enabled = true; InThird = true; ColliderToggles(); break; case 2: LastCamera = 0; ((Behaviour)MainCamera.GetComponent<Camera>()).enabled = true; ((Behaviour)BackCamera.GetComponent<Camera>()).enabled = false; ((Behaviour)FrontCamera.GetComponent<Camera>()).enabled = false; InThird = false; ColliderToggles(); break; } } internal static void ColliderToggles() { try { if (InThird) { GameObject obj = GameObject.Find("Environment/HangarShip/Player/Misc/MapDot"); if (obj != null) { obj.SetActive(false); } GameObject obj2 = GameObject.Find("PlayersContainer/Player/Misc/MapDot"); if (obj2 != null) { obj2.SetActive(false); } GameObject obj3 = GameObject.Find("PlayersContainer/Player (1)/Misc/MapDot"); if (obj3 != null) { obj3.SetActive(false); } GameObject obj4 = GameObject.Find("PlayersContainer/Player (2)/Misc/MapDot"); if (obj4 != null) { obj4.SetActive(false); } GameObject obj5 = GameObject.Find("PlayersContainer/Player (3)/Misc/MapDot"); if (obj5 != null) { obj5.SetActive(false); } GameObject obj6 = GameObject.Find("Environment/HangarShip/Player/ScavengerModel/metarig/ScavengerModelArmsOnly"); if (obj6 != null) { obj6.SetActive(false); } GameObject obj7 = GameObject.Find("PlayersContainer/Player/ScavengerModel/metarig/ScavengerModelArmsOnly"); if (obj7 != null) { obj7.SetActive(false); } GameObject obj8 = GameObject.Find("PlayersContainer/Player (1)/ScavengerModel/metarig/ScavengerModelArmsOnly"); if (obj8 != null) { obj8.SetActive(false); } GameObject obj9 = GameObject.Find("PlayersContainer/Player (2)/ScavengerModel/metarig/ScavengerModelArmsOnly"); if (obj9 != null) { obj9.SetActive(false); } GameObject obj10 = GameObject.Find("PlayersContainer/Player (3)/ScavengerModel/metarig/ScavengerModelArmsOnly"); if (obj10 != null) { obj10.SetActive(false); } } else { GameObject obj11 = GameObject.Find("Environment/HangarShip/Player/Misc/MapDot"); if (obj11 != null) { obj11.SetActive(true); } GameObject obj12 = GameObject.Find("PlayersContainer/Player/Misc/MapDot"); if (obj12 != null) { obj12.SetActive(true); } GameObject obj13 = GameObject.Find("PlayersContainer/Player (1)/Misc/MapDot"); if (obj13 != null) { obj13.SetActive(true); } GameObject obj14 = GameObject.Find("PlayersContainer/Player (2)/Misc/MapDot"); if (obj14 != null) { obj14.SetActive(true); } GameObject obj15 = GameObject.Find("PlayersContainer/Player (3)/Misc/MapDot"); if (obj15 != null) { obj15.SetActive(true); } GameObject obj16 = GameObject.Find("Environment/HangarShip/Player/ScavengerModel/metarig/ScavengerModelArmsOnly"); if (obj16 != null) { obj16.SetActive(true); } GameObject obj17 = GameObject.Find("PlayersContainer/Player/ScavengerModel/metarig/ScavengerModelArmsOnly"); if (obj17 != null) { obj17.SetActive(true); } GameObject obj18 = GameObject.Find("PlayersContainer/Player (1)/ScavengerModel/metarig/ScavengerModelArmsOnly"); if (obj18 != null) { obj18.SetActive(true); } GameObject obj19 = GameObject.Find("PlayersContainer/Player (2)/ScavengerModel/metarig/ScavengerModelArmsOnly"); if (obj19 != null) { obj19.SetActive(true); } GameObject obj20 = GameObject.Find("PlayersContainer/Player (3)/ScavengerModel/metarig/ScavengerModelArmsOnly"); if (obj20 != null) { obj20.SetActive(true); } } } catch (Exception arg) { CLog.L($"{arg}"); } } public static void Camera3rdUpdate() { //IL_0179: 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_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0153: 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_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0239: 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_025e: 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_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)MainCamera == (Object)null) { return; } Mouse current = Mouse.current; Keyboard current2 = Keyboard.current; try { FrontCamera.GetComponent<Camera>().fieldOfView = fov; FrontCamera.GetComponent<Camera>().nearClipPlane = 0.01f; BackCamera.GetComponent<Camera>().fieldOfView = fov; BackCamera.GetComponent<Camera>().nearClipPlane = 0.01f; if ((Object)(object)BackCamera != (Object)null && (Object)(object)FrontCamera != (Object)null && InThird && LastCamera != 0) { if (current.middleButton.isPressed) { BackCamera.transform.position = MainCamera.transform.position; Transform transform = BackCamera.transform; transform.position -= BackCamera.transform.forward * 4f; FrontCamera.transform.position = MainCamera.transform.position; Transform transform2 = FrontCamera.transform; transform2.position += -FrontCamera.transform.forward * 4f; } float y = ((InputControl<Vector2>)(object)current.scroll).ReadValue().y; float num = Vector3.Distance(FrontCamera.transform.position, BackCamera.transform.position); float num2 = Vector3.Distance(FrontCamera.transform.position, MainCamera.transform.position); float num3 = Vector3.Distance(BackCamera.transform.position, MainCamera.transform.position); if (y > 0f && num > proxThreshB) { Transform transform3 = BackCamera.transform; transform3.position += BackCamera.transform.forward * 0.1f; Transform transform4 = FrontCamera.transform; transform4.position -= BackCamera.transform.forward * 0.1f; } else if (y < 0f) { Transform transform5 = BackCamera.transform; transform5.position -= BackCamera.transform.forward * 0.1f; Transform transform6 = FrontCamera.transform; transform6.position += BackCamera.transform.forward * 0.1f; } } if (((ButtonControl)current2.leftCtrlKey).isPressed && ((ButtonControl)current2.tKey).wasPressedThisFrame) { Switch(); } } catch (Exception ex) { CLog.L("Error\n" + ex); } if (current.middleButton.wasPressedThisFrame) { fov = 66f; } if (((ButtonControl)current2.upArrowKey).wasPressedThisFrame) { fov += 1f; } else if (((ButtonControl)current2.downArrowKey).wasPressedThisFrame) { fov -= 1f; } } } }