using 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.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("FreeCam")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("FreeCam")] [assembly: AssemblyTitle("FreeCam")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 FreeCam { public static class FreeCamController { private static float _roll; private static float _lastZTap = -999f; private static float _lastCTap = -999f; private static float _savedFov = 65f; public static float Roll => _roll; public static void Toggle() { GameCamera instance = GameCamera.instance; if ((Object)(object)instance == (Object)null) { return; } if (!GameCamera.InFreeFly()) { InitFromCamera(instance); _savedFov = Traverse.Create((object)instance).Field("m_fov").Value; Camera value = Traverse.Create((object)instance).Field("m_camera").Value; if ((Object)(object)value != (Object)null) { value.fieldOfView = _savedFov; } instance.ToggleFreeFly(); FreeCamPlugin.ModFreeCamActive = true; FreeCamPlugin.Message("Freecam ON"); FreeCamPlugin.Log("Freecam enabled"); } else { Disable(instance); } } public static void Disable(GameCamera cam = null) { cam = cam ?? GameCamera.instance; if (!((Object)(object)cam == (Object)null)) { if (GameCamera.InFreeFly()) { cam.ToggleFreeFly(); } RestoreFov(cam); _roll = 0f; FreeCamPlugin.ModFreeCamActive = false; FreeCamPlugin.Message("Freecam OFF"); FreeCamPlugin.Log("Freecam disabled"); } } private static void InitFromCamera(GameCamera cam) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_0024: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) Vector3 forward = ((Component)cam).transform.forward; float num = Mathf.Atan2(forward.x, forward.z) * 57.29578f; float num2 = (0f - Mathf.Asin(Mathf.Clamp(forward.y, -1f, 1f))) * 57.29578f; Traverse obj = Traverse.Create((object)cam); obj.Field("m_freeFlyYaw").SetValue((object)num); obj.Field("m_freeFlyPitch").SetValue((object)num2); obj.Field("m_freeFlyVel").SetValue((object)Vector3.zero); obj.Field("m_freeFlyAcc").SetValue((object)Vector3.zero); obj.Field("m_freeFlySavedVel").SetValue((object)Vector3.zero); obj.Field("m_freeFlyTarget").SetValue((object)null); obj.Field("m_freeFlyLockon").SetValue((object)null); _roll = 0f; } private static void RestoreFov(GameCamera cam) { Traverse obj = Traverse.Create((object)cam); obj.Field("m_fov").SetValue((object)_savedFov); Camera value = obj.Field("m_camera").Value; Camera value2 = obj.Field("m_skyCamera").Value; if ((Object)(object)value != (Object)null) { value.fieldOfView = _savedFov; } if ((Object)(object)value2 != (Object)null) { value2.fieldOfView = _savedFov; } } public static bool UpdateFreeFly(GameCamera cam, float dt) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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) //IL_0080: 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) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015b: 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) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: 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_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_033c: 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_0347: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_0380: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03c8: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Unknown result type (might be due to invalid IL or missing references) //IL_03ff: Unknown result type (might be due to invalid IL or missing references) //IL_0404: Unknown result type (might be due to invalid IL or missing references) //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_042a: Unknown result type (might be due to invalid IL or missing references) //IL_042c: Unknown result type (might be due to invalid IL or missing references) //IL_042f: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_0445: Unknown result type (might be due to invalid IL or missing references) //IL_0447: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_043f: 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_0461: Unknown result type (might be due to invalid IL or missing references) //IL_0466: Unknown result type (might be due to invalid IL or missing references) //IL_0469: Unknown result type (might be due to invalid IL or missing references) //IL_046e: Unknown result type (might be due to invalid IL or missing references) //IL_048d: Unknown result type (might be due to invalid IL or missing references) //IL_0492: Unknown result type (might be due to invalid IL or missing references) //IL_0497: Unknown result type (might be due to invalid IL or missing references) //IL_04bd: Unknown result type (might be due to invalid IL or missing references) //IL_04c2: Unknown result type (might be due to invalid IL or missing references) //IL_04ce: Unknown result type (might be due to invalid IL or missing references) //IL_04a8: Unknown result type (might be due to invalid IL or missing references) //IL_0528: Unknown result type (might be due to invalid IL or missing references) //IL_0540: Unknown result type (might be due to invalid IL or missing references) //IL_0558: Unknown result type (might be due to invalid IL or missing references) if (!FreeCamPlugin.ModFreeCamActive) { return false; } if (Console.IsVisible()) { return true; } Traverse val = Traverse.Create((object)cam); float num = val.Field("m_freeFlyYaw").Value; float num2 = val.Field("m_freeFlyPitch").Value; float num3 = val.Field("m_freeFlySpeed").Value; float value = val.Field("m_freeFlySmooth").Value; Vector3 value2 = val.Field("m_freeFlyVel").Value; Vector3 value3 = val.Field("m_freeFlyAcc").Value; Quaternion value4 = val.Field("m_freeFlyRef").Value; Camera value5 = val.Field("m_camera").Value; Camera value6 = val.Field("m_skyCamera").Value; float num4 = Mathf.Min(FreeCamPlugin.MinFov.Value, val.Field("m_freeFlyMinFov").Value); float num5 = Mathf.Max(FreeCamPlugin.MaxFov.Value, val.Field("m_freeFlyMaxFov").Value); if (!FreeCamPlugin.RequireRmbToLook.Value || ZInput.GetKey((KeyCode)324, true)) { Vector2 mouseDelta = ZInput.GetMouseDelta(); mouseDelta.x += ZInput.GetJoyRightStickX(true) * 110f * dt; mouseDelta.y += (0f - ZInput.GetJoyRightStickY(true)) * 110f * dt; num += mouseDelta.x; num2 -= mouseDelta.y; num2 = Mathf.Clamp(num2, -89.9f, 89.9f); } float mouseScrollWheel = ZInput.GetMouseScrollWheel(); if (Mathf.Abs(mouseScrollWheel) > 0.0001f && (Object)(object)value5 != (Object)null) { float num6 = value5.fieldOfView - mouseScrollWheel * FreeCamPlugin.FovStep.Value * 10f; num6 = (value5.fieldOfView = Mathf.Clamp(num6, FreeCamPlugin.MinFov.Value, FreeCamPlugin.MaxFov.Value)); if ((Object)(object)value6 != (Object)null) { value6.fieldOfView = num6; } } if (ZInput.GetKey((KeyCode)273, true)) { num3 += num3 * FreeCamPlugin.SpeedStep.Value * dt * 10f; } if (ZInput.GetKey((KeyCode)274, true)) { num3 -= num3 * FreeCamPlugin.SpeedStep.Value * dt * 10f; } num3 = Mathf.Clamp(num3, FreeCamPlugin.MinSpeed.Value, FreeCamPlugin.MaxSpeed.Value); if (ZInput.GetButton("JoyTabLeft") && (Object)(object)value5 != (Object)null) { value5.fieldOfView = Mathf.Max(num4, value5.fieldOfView - dt * 20f); if ((Object)(object)value6 != (Object)null) { value6.fieldOfView = value5.fieldOfView; } } if (ZInput.GetButton("JoyTabRight") && (Object)(object)value5 != (Object)null) { value5.fieldOfView = Mathf.Min(num5, value5.fieldOfView + dt * 20f); if ((Object)(object)value6 != (Object)null) { value6.fieldOfView = value5.fieldOfView; } } Vector3 val2 = Vector3.zero; if (HeldForward()) { val2 += Vector3.forward; } if (HeldBackward()) { val2 -= Vector3.forward; } if (HeldLeft()) { val2 -= Vector3.right; } if (HeldRight()) { val2 += Vector3.right; } if (HeldUp()) { val2 += Vector3.up; } if (HeldDown()) { val2 -= Vector3.up; } val2 += Vector3.up * ZInput.GetJoyRTrigger(); val2 -= Vector3.up * ZInput.GetJoyLTrigger(); val2 += Vector3.right * ZInput.GetJoyLeftStickX(false); val2 += -Vector3.forward * ZInput.GetJoyLeftStickY(true); if (((Vector3)(ref val2)).magnitude > 1f) { ((Vector3)(ref val2)).Normalize(); } Quaternion val3 = Quaternion.Euler(0f, num, 0f) * Quaternion.Euler(num2, 0f, 0f); val2 = val3 * Quaternion.Euler(0f, 0f, _roll) * val2; val2 *= num3; value2 = ((!(value <= 0f)) ? Vector3.SmoothDamp(value2, val2, ref value3, value, 99f, dt) : val2); Transform transform = ((Component)cam).transform; transform.position += value2 * dt; HandleTilt(dt); Quaternion val4 = val3 * Quaternion.Euler(0f, 0f, _roll); if (value <= 0f) { ((Component)cam).transform.rotation = val4; } else { ((Component)cam).transform.rotation = Utils.SmoothDamp(((Component)cam).transform.rotation, val4, ref value4, value, 9999f, dt); } val.Field("m_freeFlyYaw").SetValue((object)num); val.Field("m_freeFlyPitch").SetValue((object)num2); val.Field("m_freeFlySpeed").SetValue((object)num3); val.Field("m_freeFlyVel").SetValue((object)value2); val.Field("m_freeFlyAcc").SetValue((object)value3); val.Field("m_freeFlyRef").SetValue((object)value4); return true; } private static void HandleTilt(float dt) { float value = FreeCamPlugin.DoubleTapWindow.Value; float value2 = FreeCamPlugin.TiltSpeed.Value; bool flag = false; if (ZInput.GetKeyDown((KeyCode)122, true)) { if (Time.unscaledTime - _lastZTap <= value) { _roll = 0f; flag = true; } _lastZTap = Time.unscaledTime; } if (ZInput.GetKeyDown((KeyCode)99, true)) { if (Time.unscaledTime - _lastCTap <= value) { _roll = 0f; flag = true; } _lastCTap = Time.unscaledTime; } if (!flag) { if (ZInput.GetKey((KeyCode)122, true)) { _roll += value2 * dt; } if (ZInput.GetKey((KeyCode)99, true)) { _roll -= value2 * dt; } } _roll = Mathf.Clamp(_roll, -180f, 180f); } private static bool HeldForward() { if (!ZInput.GetButton("Forward") && !ZInput.GetKey((KeyCode)119, true)) { return ZInput.GetKey((KeyCode)117, true); } return true; } private static bool HeldBackward() { if (!ZInput.GetButton("Backward") && !ZInput.GetKey((KeyCode)115, true)) { return ZInput.GetKey((KeyCode)106, true); } return true; } private static bool HeldLeft() { if (!ZInput.GetButton("Left") && !ZInput.GetKey((KeyCode)97, true)) { return ZInput.GetKey((KeyCode)104, true); } return true; } private static bool HeldRight() { if (!ZInput.GetButton("Right") && !ZInput.GetKey((KeyCode)100, true)) { return ZInput.GetKey((KeyCode)107, true); } return true; } private static bool HeldUp() { if (!ZInput.GetButton("Jump") && !ZInput.GetKey((KeyCode)101, true) && !ZInput.GetKey((KeyCode)105, true)) { return ZInput.GetKey((KeyCode)32, true); } return true; } private static bool HeldDown() { if (!ZInput.GetButton("Crouch") && !ZInput.GetKey((KeyCode)113, true) && !ZInput.GetKey((KeyCode)121, true)) { return ZInput.GetKey((KeyCode)306, true); } return true; } } public class FreeCamHelpUI : MonoBehaviour { private static FreeCamHelpUI _instance; private GUIStyle _panelStyle; private GUIStyle _titleStyle; private GUIStyle _keyStyle; private GUIStyle _keyBoxStyle; private GUIStyle _descStyle; private GUIStyle _footerStyle; private GUIStyle _hintStyle; private Texture2D _panelTex; private Texture2D _keyTex; private Texture2D _accentTex; private bool _stylesReady; private static readonly List<(string key, string desc)> LeftBindings = new List<(string, string)> { ("W / U", "Forward"), ("A / H", "Left"), ("S / J", "Back"), ("D / K", "Right"), ("E / I", "Up"), ("Q / Y", "Down"), ("Up / Down", "Faster / slower") }; private static readonly List<(string key, string desc)> RightBindings = new List<(string, string)> { ("RMB + mouse", "Look around"), ("Scroll", "FOV (zoom / wide)"), ("Z / C", "Tilt left / right"), ("2x Z or C", "Reset tilt to 0"), ("O", "Toggle HUD"), ("P", "Hide hints"), ("F11", "Screenshot") }; public static void EnsureExists() { //IL_0013: 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: Expected O, but got Unknown if (!((Object)(object)_instance != (Object)null)) { GameObject val = new GameObject("FreeCamHelpUI"); Object.DontDestroyOnLoad((Object)val); _instance = val.AddComponent(); } } private void OnDestroy() { if ((Object)(object)_instance == (Object)(object)this) { _instance = null; } DestroyTex(ref _panelTex); DestroyTex(ref _keyTex); DestroyTex(ref _accentTex); } private static void DestroyTex(ref Texture2D tex) { if (!((Object)(object)tex == (Object)null)) { Object.Destroy((Object)(object)tex); tex = null; } } private void Update() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (FreeCamPlugin.ModFreeCamActive && FreeCamPlugin.CanProcessHotkeys() && FreeCamPlugin.ToggleHelpKey != null) { KeyboardShortcut value = FreeCamPlugin.ToggleHelpKey.Value; if (((KeyboardShortcut)(ref value)).IsDown() && !Input.GetKey((KeyCode)304) && !Input.GetKey((KeyCode)303)) { bool flag = !FreeCamPlugin.ShowHelpUi.Value; FreeCamPlugin.ShowHelpUi.Value = flag; FreeCamPlugin.Log("Help UI " + (flag ? "ON" : "OFF")); } } } private void OnGUI() { //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) if (FreeCamPlugin.ModFreeCamActive) { EnsureStyles(); if (FreeCamPlugin.ShowHelpUi != null && FreeCamPlugin.ShowHelpUi.Value) { float num = Mathf.Clamp((float)Screen.width * 0.22f, 260f, 340f); float num2 = 32f; float num3 = 36f; float num4 = 14f; float num5 = 48f + (float)LeftBindings.Count * num2 + num3 + num4; float num6 = 48f + (float)RightBindings.Count * num2 + num3 + num4; float num7 = Mathf.Max(num5, num6); float num8 = Mathf.Max(40f, ((float)Screen.height - num7) * 0.5f); DrawPanel(new Rect(16f, num8, num, num7), "MOVEMENT", LeftBindings, "Mod by Mekhusha"); DrawPanel(new Rect((float)Screen.width - num - 16f, num8, num, num7), "CAMERA", RightBindings, "Shift+P — exit"); } } } private void DrawPanel(Rect rect, string title, List<(string key, string desc)> rows, string footer) { //IL_0000: 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) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) GUI.Box(rect, GUIContent.none, _panelStyle); GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, 4f, ((Rect)(ref rect)).height), (Texture)(object)_accentTex); float num = ((Rect)(ref rect)).x + 16f; float num2 = ((Rect)(ref rect)).y + 12f; float num3 = ((Rect)(ref rect)).width - 28f; GUI.Label(new Rect(num, num2, num3, 28f), title, _titleStyle); num2 += 36f; foreach (var row in rows) { float num4 = Mathf.Min(118f, num3 * 0.42f); Rect val = new Rect(num, num2, num4, 26f); GUI.Box(val, GUIContent.none, _keyBoxStyle); GUI.Label(val, row.key, _keyStyle); GUI.Label(new Rect(num + num4 + 10f, num2, num3 - num4 - 10f, 26f), row.desc, _descStyle); num2 += 32f; } num2 = ((Rect)(ref rect)).yMax - 30f; GUI.Label(new Rect(num, num2, num3, 22f), footer, _footerStyle); } private void EnsureStyles() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown //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_00c2: Expected O, but got Unknown //IL_00c7: Expected O, but got Unknown //IL_00d2: 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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown //IL_00f7: 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_0106: Expected O, but got Unknown //IL_010b: Expected O, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Expected O, but got Unknown //IL_0165: 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_0172: 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_0180: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Expected O, but got Unknown //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Expected O, but got Unknown //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Expected O, but got Unknown //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0250: 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_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Expected O, but got Unknown if (!_stylesReady || _panelStyle == null) { _panelTex = MakeTex(4, 4, new Color(0.06f, 0.07f, 0.08f, 0.82f)); _keyTex = MakeTex(4, 4, new Color(0.16f, 0.14f, 0.11f, 0.95f)); _accentTex = MakeTex(2, 2, new Color(0.78f, 0.58f, 0.28f, 0.95f)); GUIStyle val = new GUIStyle(GUI.skin.box); val.normal.background = _panelTex; val.border = new RectOffset(8, 8, 8, 8); val.padding = new RectOffset(0, 0, 0, 0); _panelStyle = val; GUIStyle val2 = new GUIStyle(GUI.skin.box); val2.normal.background = _keyTex; val2.border = new RectOffset(4, 4, 4, 4); val2.padding = new RectOffset(0, 0, 0, 0); _keyBoxStyle = val2; GUIStyle val3 = new GUIStyle(GUI.skin.label) { fontSize = 16, fontStyle = (FontStyle)1, alignment = (TextAnchor)3 }; val3.normal.textColor = new Color(0.92f, 0.82f, 0.55f, 1f); _titleStyle = val3; GUIStyle val4 = new GUIStyle(GUI.skin.label) { fontSize = 12, fontStyle = (FontStyle)1, alignment = (TextAnchor)4 }; val4.normal.textColor = new Color(0.95f, 0.9f, 0.75f, 1f); _keyStyle = val4; GUIStyle val5 = new GUIStyle(GUI.skin.label) { fontSize = 13, alignment = (TextAnchor)3 }; val5.normal.textColor = new Color(0.85f, 0.85f, 0.82f, 1f); val5.wordWrap = true; _descStyle = val5; GUIStyle val6 = new GUIStyle(GUI.skin.label) { fontSize = 11, alignment = (TextAnchor)3 }; val6.normal.textColor = new Color(0.65f, 0.62f, 0.55f, 1f); _footerStyle = val6; GUIStyle val7 = new GUIStyle(GUI.skin.label) { fontSize = 12, alignment = (TextAnchor)0 }; val7.normal.textColor = new Color(0.8f, 0.78f, 0.7f, 0.75f); _hintStyle = val7; _stylesReady = true; } } private static Texture2D MakeTex(int w, int h, Color color) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(w, h, (TextureFormat)4, false); Color[] array = (Color[])(object)new Color[w * h]; for (int i = 0; i < array.Length; i++) { array[i] = color; } val.SetPixels(array); val.Apply(); ((Object)val).hideFlags = (HideFlags)61; return val; } } public static class HudToggle { public static bool IsHidden { get { if ((Object)(object)Hud.instance != (Object)null) { return Hud.instance.m_userHidden; } return false; } } public static void Toggle() { Hud instance = Hud.instance; if (!((Object)(object)instance == (Object)null)) { instance.m_userHidden = !instance.m_userHidden; ApplyMinimapVisibility(); string text = (instance.m_userHidden ? "OFF" : "ON"); FreeCamPlugin.Log("HUD " + text); if ((Object)(object)MessageHud.instance != (Object)null) { MessageHud.instance.ShowMessage((MessageType)1, instance.m_userHidden ? "HUD hidden (O)" : "HUD shown (O)", 0, (Sprite)null, true); } } } public static void ApplyMinimapVisibility() { Minimap instance = Minimap.instance; if ((Object)(object)instance == (Object)null) { return; } if (IsHidden) { if ((Object)(object)instance.m_smallRoot != (Object)null && instance.m_smallRoot.activeSelf) { instance.m_smallRoot.SetActive(false); } return; } object value = Traverse.Create((object)instance).Field("m_mode").GetValue(); if (value != null && value.ToString() == "Small" && (Object)(object)instance.m_smallRoot != (Object)null && !instance.m_smallRoot.activeSelf) { instance.m_smallRoot.SetActive(true); } } } [BepInPlugin("com.valheimtools.freecam", "FreeCam", "1.2.1")] public class FreeCamPlugin : BaseUnityPlugin { public const string ModGuid = "com.valheimtools.freecam"; public const string ModName = "FreeCam"; public const string ModVersion = "1.2.1"; public static ConfigEntry ToggleKey; public static ConfigEntry ToggleHudKey; public static ConfigEntry ToggleHelpKey; public static ConfigEntry ShowHelpUi; public static ConfigEntry FovStep; public static ConfigEntry MinFov; public static ConfigEntry MaxFov; public static ConfigEntry SpeedStep; public static ConfigEntry MinSpeed; public static ConfigEntry MaxSpeed; public static ConfigEntry TiltSpeed; public static ConfigEntry DoubleTapWindow; public static ConfigEntry RequireRmbToLook; public static ConfigEntry ShowMessages; private Harmony _harmony; public static FreeCamPlugin Instance { get; private set; } public static bool ModFreeCamActive { get; set; } private void Awake() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Expected O, but got Unknown //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_026a: 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) Instance = this; ToggleKey = ((BaseUnityPlugin)this).Config.Bind("Controls", "ToggleKey", new KeyboardShortcut((KeyCode)112, (KeyCode[])(object)new KeyCode[1] { (KeyCode)304 }), "Toggle freecam (default: Shift+P)"); ToggleHudKey = ((BaseUnityPlugin)this).Config.Bind("Controls", "ToggleHudKey", new KeyboardShortcut((KeyCode)111, Array.Empty()), "Toggle full HUD / UI including crosshair, health, status effects and minimap (default: O)"); ToggleHelpKey = ((BaseUnityPlugin)this).Config.Bind("Controls", "ToggleHelpKey", new KeyboardShortcut((KeyCode)112, Array.Empty()), "Toggle freecam help panels on the sides (default: P, only while freecam is on)"); ShowHelpUi = ((BaseUnityPlugin)this).Config.Bind("UI", "ShowHelpUi", true, "Show control help panels on the sides while freecam is active"); RequireRmbToLook = ((BaseUnityPlugin)this).Config.Bind("Controls", "RequireRmbToLook", true, "Hold right mouse button to rotate the camera"); FovStep = ((BaseUnityPlugin)this).Config.Bind("Camera", "FovStep", 3f, "FOV change per mouse-wheel tick"); MinFov = ((BaseUnityPlugin)this).Config.Bind("Camera", "MinFov", 5f, "Minimum FOV (zoom in)"); MaxFov = ((BaseUnityPlugin)this).Config.Bind("Camera", "MaxFov", 120f, "Maximum FOV (wide angle)"); SpeedStep = ((BaseUnityPlugin)this).Config.Bind("Camera", "SpeedStep", 0.15f, "Relative speed change when pressing Up/Down arrow"); MinSpeed = ((BaseUnityPlugin)this).Config.Bind("Camera", "MinSpeed", 0.5f, "Minimum freecam move speed"); MaxSpeed = ((BaseUnityPlugin)this).Config.Bind("Camera", "MaxSpeed", 1000f, "Maximum freecam move speed"); TiltSpeed = ((BaseUnityPlugin)this).Config.Bind("Camera", "TiltSpeed", 60f, "Camera roll speed for Z/C (degrees per second)"); DoubleTapWindow = ((BaseUnityPlugin)this).Config.Bind("Camera", "DoubleTapWindow", 0.3f, "Seconds for double-tap Z/C to reset tilt"); ShowMessages = ((BaseUnityPlugin)this).Config.Bind("General", "ShowMessages", true, "Show on-screen toggle messages"); _harmony = new Harmony("com.valheimtools.freecam"); _harmony.PatchAll(); FreeCamHelpUI.EnsureExists(); ((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("{0} {1} loaded. Freecam: {2}, HUD: {3}, Help: {4}", "FreeCam", "1.2.1", ToggleKey.Value, ToggleHudKey.Value, ToggleHelpKey.Value)); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } private void Update() { //IL_000d: 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_0026: 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) if (CanProcessHotkeys()) { KeyboardShortcut value = ToggleHudKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { HudToggle.Toggle(); } value = ToggleKey.Value; if (((KeyboardShortcut)(ref value)).IsDown() && !Minimap.IsOpen()) { FreeCamController.Toggle(); } } } internal static bool CanProcessHotkeys() { if ((Object)(object)Player.m_localPlayer == (Object)null) { return false; } if (Console.IsVisible() || ((Object)(object)Chat.instance != (Object)null && Chat.instance.HasFocus())) { return false; } if (TextInput.IsVisible() || Menu.IsVisible()) { return false; } if (InventoryGui.IsVisible() || StoreGui.IsVisible()) { return false; } return true; } internal static void Log(string message) { FreeCamPlugin instance = Instance; if (instance != null) { ((BaseUnityPlugin)instance).Logger.LogInfo((object)message); } } internal static void Message(string text) { if (ShowMessages != null && ShowMessages.Value) { Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)1, text, 0, (Sprite)null); } } } } } namespace FreeCam.Patches { [HarmonyPatch(typeof(GameCamera))] internal static class GameCameraPatches { [HarmonyPrefix] [HarmonyPatch("UpdateFreeFly")] private static bool UpdateFreeFlyPrefix(GameCamera __instance, float dt) { return !FreeCamController.UpdateFreeFly(__instance, dt); } [HarmonyPrefix] [HarmonyPatch("ScreenShot")] private static bool ScreenShotPrefix() { if (!FreeCamPlugin.ModFreeCamActive) { return true; } if (ZInput.GetKeyDown((KeyCode)324, true) && !ZInput.GetKeyDown((KeyCode)292, true)) { return false; } return true; } } [HarmonyPatch(typeof(Minimap))] internal static class MinimapPatches { [HarmonyPostfix] [HarmonyPatch("Update")] private static void UpdatePostfix(Minimap __instance) { if (Hud.IsUserHidden() && (Object)(object)__instance.m_smallRoot != (Object)null && __instance.m_smallRoot.activeSelf) { __instance.m_smallRoot.SetActive(false); } } } }