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 EasyBuildCam v1.0.1
EasyBuildCam.dll
Decompiled 5 days 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 HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("EasyBuildCam")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1+ff7e674a5822f7bed26aad6a40110d2cf7be5a9c")] [assembly: AssemblyProduct("EasyBuildCam")] [assembly: AssemblyTitle("EasyBuildCam")] [assembly: AssemblyVersion("1.0.1.0")] namespace EasyBuildCam; [BepInPlugin("com.morda.easybuildcam", "EasyBuildCam", "1.0.1")] public class Plugin : BaseUnityPlugin { public const string ModGuid = "com.morda.easybuildcam"; public const string ModName = "EasyBuildCam"; public const string ModVersion = "1.0.1"; internal static ConfigEntry<KeyCode> ToggleKey; internal static ConfigEntry<KeyCode> FasterKey; internal static ConfigEntry<KeyCode> SlowerKey; internal static ConfigEntry<KeyCode> UpKey; internal static ConfigEntry<KeyCode> DownKey; internal static ConfigEntry<KeyCode> BoostKey; internal static ConfigEntry<float> Speed; internal static ConfigEntry<float> SpeedStep; internal static ConfigEntry<float> BoostMultiplier; internal static ConfigEntry<float> MouseSensitivity; internal static bool Active; private static float _origPlaceDistance = -1f; internal const float HugeRange = 100000f; private static float _yaw; private static float _pitch; private static Vector3 _pos; private void Awake() { //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Expected O, but got Unknown //IL_0183: Unknown result type (might be due to invalid IL or missing references) ToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keys", "Toggle", (KeyCode)287, "Turn the build camera on or off."); FasterKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keys", "Faster", (KeyCode)270, "Increase the flying speed."); SlowerKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keys", "Slower", (KeyCode)269, "Decrease the flying speed."); UpKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keys", "Up", (KeyCode)32, "Fly up."); DownKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keys", "Down", (KeyCode)306, "Fly down."); BoostKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keys", "Boost", (KeyCode)304, "Hold to fly faster."); Speed = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "Speed", 10f, new ConfigDescription("Flying speed in meters per second.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 500f), Array.Empty<object>())); SpeedStep = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "SpeedStep", 1.25f, "Each +/- press multiplies / divides the speed by this."); BoostMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "BoostMultiplier", 3f, "Speed multiplier while the boost key is held."); MouseSensitivity = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "MouseSensitivity", 2f, "Mouse look sensitivity."); new Harmony("com.morda.easybuildcam").PatchAll(typeof(Plugin).Assembly); } private static bool UiBlocksInput() { if ((!((Object)(object)Chat.instance != (Object)null) || !Chat.instance.HasFocus()) && !Console.IsVisible() && !Menu.IsVisible() && !TextInput.IsVisible() && (!((Object)(object)InventoryGui.instance != (Object)null) || !InventoryGui.IsVisible())) { return Hud.IsPieceSelectionVisible(); } return true; } private void Update() { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_025c: 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_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: 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_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0345: 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_0352: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.m_localPlayer == (Object)null) { Active = false; _origPlaceDistance = -1f; return; } if (Active && !((Character)Player.m_localPlayer).InPlaceMode()) { Active = false; SetPlaceDistance(Player.m_localPlayer, on: false); ((Character)Player.m_localPlayer).Message((MessageType)2, "Build Cam OFF", 0, (Sprite)null, false); } if (UiBlocksInput()) { return; } if (Input.GetKeyDown(ToggleKey.Value) && (Active || ((Character)Player.m_localPlayer).InPlaceMode())) { Active = !Active; if (Active && (Object)(object)GameCamera.instance != (Object)null) { Transform transform = ((Component)GameCamera.instance).transform; _pos = transform.position; Quaternion rotation = transform.rotation; Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles; _yaw = eulerAngles.y; _pitch = ((eulerAngles.x > 180f) ? (eulerAngles.x - 360f) : eulerAngles.x); } SetPlaceDistance(Player.m_localPlayer, Active); ((Character)Player.m_localPlayer).Message((MessageType)2, Active ? "Build Cam ON" : "Build Cam OFF", 0, (Sprite)null, false); } if (Active) { bool keyDown = Input.GetKeyDown(FasterKey.Value); bool keyDown2 = Input.GetKeyDown(SlowerKey.Value); if (keyDown) { Speed.Value = Mathf.Min(500f, Speed.Value * SpeedStep.Value); } if (keyDown2) { Speed.Value = Mathf.Max(0.5f, Speed.Value / SpeedStep.Value); } if (keyDown || keyDown2) { ((Character)Player.m_localPlayer).Message((MessageType)1, "Cam speed: " + Speed.Value.ToString("0.0") + " m/s", 0, (Sprite)null, false); } _yaw += Input.GetAxisRaw("Mouse X") * MouseSensitivity.Value; _pitch = Mathf.Clamp(_pitch - Input.GetAxisRaw("Mouse Y") * MouseSensitivity.Value, -89f, 89f); Quaternion val = Quaternion.Euler(_pitch, _yaw, 0f); Vector3 val2 = Vector3.zero; if (Input.GetKey((KeyCode)119)) { val2 += Vector3.forward; } if (Input.GetKey((KeyCode)115)) { val2 += Vector3.back; } if (Input.GetKey((KeyCode)100)) { val2 += Vector3.right; } if (Input.GetKey((KeyCode)97)) { val2 += Vector3.left; } if (Input.GetKey(UpKey.Value)) { val2 += Vector3.up; } if (Input.GetKey(DownKey.Value)) { val2 += Vector3.down; } float num = Speed.Value * (Input.GetKey(BoostKey.Value) ? BoostMultiplier.Value : 1f); Vector3 val3 = val * new Vector3(val2.x, 0f, val2.z) + Vector3.up * val2.y; _pos += val3 * (num * Time.unscaledDeltaTime); } } private static void SetPlaceDistance(Player player, bool on) { if (on) { _origPlaceDistance = player.m_maxPlaceDistance; player.m_maxPlaceDistance = 100000f; } else if (_origPlaceDistance > 0f) { player.m_maxPlaceDistance = _origPlaceDistance; _origPlaceDistance = -1f; } } internal static void Apply(Transform cam) { //IL_0001: 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) cam.position = _pos; cam.rotation = Quaternion.Euler(_pitch, _yaw, 0f); } } [HarmonyPatch(typeof(GameCamera), "LateUpdate")] internal static class GameCamera_LateUpdate { private static void Postfix(GameCamera __instance) { if (Plugin.Active) { Plugin.Apply(((Component)__instance).transform); } } } [HarmonyPatch(typeof(PlayerController), "TakeInput")] internal static class PlayerController_TakeInput { private static bool Prefix(ref bool __result) { if (!Plugin.Active) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(Player), "SetMouseLook")] internal static class Player_SetMouseLook { private static bool Prefix() { return !Plugin.Active; } } [HarmonyPatch] internal static class Player_RangeEnforce { private static IEnumerable<MethodBase> TargetMethods() { string[] array = new string[5] { "PieceRayTest", "UpdatePlacementGhost", "RemovePiece", "CopyPiece", "UpdateWearNTearHover" }; foreach (string text in array) { yield return AccessTools.Method(typeof(Player), text, (Type[])null, (Type[])null); } } [HarmonyPriority(0)] private static void Prefix(Player __instance) { if (Plugin.Active && (Object)(object)__instance == (Object)(object)Player.m_localPlayer) { __instance.m_maxPlaceDistance = 100000f; } } }