Decompiled source of CameraUnlock v1.1.2
CameraUnlock.dll
Decompiled a month ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Cinemachine; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Localization; using UnityEngine.Localization.Settings; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("CameraUnlock")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.2.0")] [assembly: AssemblyInformationalVersion("1.1.2+55ee596555ea4a4c80668ae305e4a7ef087eab5e")] [assembly: AssemblyProduct("CameraUnlock")] [assembly: AssemblyTitle("CameraUnlock")] [assembly: AssemblyVersion("1.1.2.0")] namespace CameraUnlock; internal sealed class ConfigMenu : MonoBehaviour { private ConfigFile _config; private string _title; private string _symbol; private ConfigEntryBase[] _entries; private string[] _tabs; private int _tab; private int _pendingTab = -1; private Rect _rect; private bool _placed; private UiSkin _skin; private GUISkin _guiSkin; private WindowInputShield _shield; private ModDock _dock; private Vector2[] _scroll; private readonly Dictionary<ConfigEntryBase, string> _drafts = new Dictionary<ConfigEntryBase, string>(); private readonly HashSet<string> _expanded = new HashSet<string>(); private readonly Dictionary<string, bool> _pendingExpand = new Dictionary<string, bool>(); private string _error; private int _hotControl; internal Action ExtraControls { get; set; } internal bool IsOpen => ((Behaviour)this).enabled; internal static ConfigMenu Create(GameObject parent, string title, string symbol, ConfigFile config, Func<bool> visible = null) { ConfigMenu menu = parent.AddComponent<ConfigMenu>(); ((Behaviour)menu).enabled = false; menu._title = title; menu._symbol = symbol; menu._config = config; menu._entries = ((IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)config).Select((KeyValuePair<ConfigDefinition, ConfigEntryBase> p) => p.Value).ToArray(); menu._tabs = menu._entries.Select((ConfigEntryBase e) => Root(e.Definition.Section)).Distinct().ToArray(); menu._scroll = (Vector2[])(object)new Vector2[menu._tabs.Length]; menu._shield = new WindowInputShield(title); menu._dock = ModDock.Register(title, symbol, menu.Toggle, () => ((Behaviour)menu).enabled, () => title + " · " + UiEnvironment.L("Settings", "Настройки"), visible); return menu; } internal void Toggle() { SetOpen(!((Behaviour)this).enabled); } internal void SetOpen(bool open) { ((Behaviour)this).enabled = open; _shield?.Set(open); if (!open && _hotControl != 0 && GUIUtility.hotControl == _hotControl) { GUIUtility.hotControl = 0; } if (!open) { _hotControl = 0; GUI.FocusControl((string)null); } } private void Update() { if (Input.GetKeyDown((KeyCode)27)) { SetOpen(open: false); } } private void OnDisable() { _shield?.Set(open: false); } private void OnGUI() { //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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_010b: 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_0140: Expected O, but got Unknown //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_01c3: Unknown result type (might be due to invalid IL or missing references) if (UiEnvironment.PreviewRendering) { return; } if (_skin == null) { _skin = new UiSkin(); _guiSkin = _skin.CreateGuiSkin(GUI.skin); } float scale = UiEnvironment.Scale; float num = Mathf.Min(600f, (float)Screen.width / scale - 24f); float num2 = (float)Screen.height / scale; if (!_placed) { _rect = new Rect(((float)Screen.width / scale - num) * 0.5f, num2 * 0.06f, num, 0f); _placed = true; } ((Rect)(ref _rect)).width = num; Matrix4x4 matrix = GUI.matrix; GUISkin skin = GUI.skin; try { GUI.matrix = Matrix4x4.Scale(new Vector3(scale, scale, 1f)); GUI.skin = _guiSkin; GUI.skin.settings.selectionColor = new Color(0.95f, 0.72f, 0.58f, 0.7f); _rect = GUILayout.Window((_title.GetHashCode() & 0x3FFFFFFF) + 3000, _rect, new WindowFunction(DrawWindow), GUIContent.none, _skin.Window, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(num) }); ((Rect)(ref _rect)).x = Mathf.Clamp(((Rect)(ref _rect)).x, 12f, Mathf.Max(12f, (float)Screen.width / scale - num - 12f)); ((Rect)(ref _rect)).y = Mathf.Clamp(((Rect)(ref _rect)).y, 8f, Mathf.Max(8f, num2 - ((Rect)(ref _rect)).height - 8f)); _shield.Place(_rect, scale); } finally { GUI.skin = skin; GUI.matrix = matrix; } } private void DrawWindow(int id) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0294: 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_047c: Unknown result type (might be due to invalid IL or missing references) if ((int)Event.current.type == 8) { if (_pendingTab >= 0) { _tab = _pendingTab; _pendingTab = -1; GUI.FocusControl((string)null); } foreach (KeyValuePair<string, bool> item in _pendingExpand) { if (item.Value) { _expanded.Add(item.Key); } else { _expanded.Remove(item.Key); } } _pendingExpand.Clear(); } int hotControl = GUIUtility.hotControl; GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label((_symbol == "camera") ? "CU" : ((_symbol == "range") ? "LR" : "PV"), _skin.Logo, Array.Empty<GUILayoutOption>()); GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); GUILayout.Label(_title, _skin.Title, Array.Empty<GUILayoutOption>()); GUILayout.Label(UiEnvironment.L("Settings", "Настройки"), _skin.Subtitle, Array.Empty<GUILayoutOption>()); GUILayout.EndVertical(); GUILayout.FlexibleSpace(); if (GUILayout.Button("×", _skin.CloseButton, Array.Empty<GUILayoutOption>())) { SetOpen(open: false); } GUILayout.EndHorizontal(); GUILayout.Space(8f); int num = ((((Rect)(ref _rect)).width < 480f) ? 2 : 4); for (int i = 0; i < _tabs.Length; i += num) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); for (int j = i; j < Mathf.Min(i + num, _tabs.Length); j++) { if (GUILayout.Button(UiLabels.Name(_tabs[j]), (j == _tab) ? _skin.SelectedTab : _skin.Tab, Array.Empty<GUILayoutOption>())) { _pendingTab = j; } } GUILayout.EndHorizontal(); } GUILayout.Space(8f); float num2 = Mathf.Min(520f, Mathf.Max(80f, (float)Screen.height / UiEnvironment.Scale - 220f - (float)(34 * ((_tabs.Length + num - 1) / num)))); _scroll[_tab] = GUILayout.BeginScrollView(_scroll[_tab], (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(num2) }); foreach (IGrouping<string, ConfigEntryBase> item2 in from e in _entries where Root(e.Definition.Section) == _tabs[_tab] group e by e.Definition.Section) { bool num3 = item2.Key.Contains(".") || item2.Key == "Quality"; GUILayout.BeginVertical(_skin.Panel, Array.Empty<GUILayoutOption>()); bool flag = !num3 || _expanded.Contains(item2.Key); if (num3) { if (GUILayout.Button((flag ? "▼ " : "► ") + UiLabels.Name(item2.Key), _skin.SectionTitle, Array.Empty<GUILayoutOption>())) { _pendingExpand[item2.Key] = !flag; } } else { GUILayout.Label(UiLabels.Name(item2.Key), _skin.SectionTitle, Array.Empty<GUILayoutOption>()); } if (flag) { foreach (ConfigEntryBase item3 in item2) { DrawEntry(item3); } } GUILayout.EndVertical(); } ExtraControls?.Invoke(); GUILayout.EndScrollView(); GUILayout.Space(8f); GUILayout.Label(_error ?? UiEnvironment.L("Changes save automatically. Fields: Apply to save.", "Изменения сохраняются сразу. Для полей нажмите «Применить»."), _skin.Hint, Array.Empty<GUILayoutOption>()); GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref _rect)).width - 48f, 62f)); if (hotControl != GUIUtility.hotControl) { _hotControl = GUIUtility.hotControl; } } private void DrawEntry(ConfigEntryBase entry) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0490: Unknown result type (might be due to invalid IL or missing references) //IL_0495: Unknown result type (might be due to invalid IL or missing references) //IL_04b0: Unknown result type (might be due to invalid IL or missing references) //IL_04b5: Unknown result type (might be due to invalid IL or missing references) //IL_04bc: Unknown result type (might be due to invalid IL or missing references) //IL_04c2: Invalid comparison between Unknown and I4 //IL_04cf: Unknown result type (might be due to invalid IL or missing references) //IL_04da: 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_04ff: Unknown result type (might be due to invalid IL or missing references) //IL_0506: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) string text = UiLabels.Name(entry.Definition.Key); GUILayout.BeginHorizontal(_skin.Row, Array.Empty<GUILayoutOption>()); GUIContent val = new GUIContent(text, entry.Description.Description); if (entry.SettingType == typeof(bool)) { bool flag = GUILayout.Toggle((bool)entry.BoxedValue, GUIContent.none, _skin.Check, Array.Empty<GUILayoutOption>()); if (GUILayout.Button(val, _skin.ToggleLabel, Array.Empty<GUILayoutOption>())) { flag = !(bool)entry.BoxedValue; } if (flag != (bool)entry.BoxedValue) { entry.BoxedValue = flag; } } else { GUILayout.Label(val, _skin.Label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(Mathf.Clamp((((Rect)(ref _rect)).width - 64f) * 0.4f, 105f, 190f)) }); bool num = entry.SettingType == typeof(float) || entry.SettingType == typeof(int); AcceptableValueBase acceptableValues = entry.Description.AcceptableValues; PropertyInfo propertyInfo = ((object)acceptableValues)?.GetType().GetProperty("MinValue"); PropertyInfo propertyInfo2 = ((object)acceptableValues)?.GetType().GetProperty("MaxValue"); if (num && propertyInfo != null && propertyInfo2 != null) { float num2 = Convert.ToSingle(entry.BoxedValue, CultureInfo.InvariantCulture); float num3 = GUILayout.HorizontalSlider(num2, Convert.ToSingle(propertyInfo.GetValue(acceptableValues), CultureInfo.InvariantCulture), Convert.ToSingle(propertyInfo2.GetValue(acceptableValues), CultureInfo.InvariantCulture), _skin.Slider, _skin.Thumb, Array.Empty<GUILayoutOption>()); GUILayout.Label(num2.ToString((entry.SettingType == typeof(int)) ? "0" : "0.##", CultureInfo.InvariantCulture), _skin.Value, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(54f) }); if (num3 != num2) { entry.BoxedValue = ((entry.SettingType == typeof(int)) ? ((object)Mathf.RoundToInt(num3)) : ((object)(float)Math.Round(num3, 3))); } } else if (entry.SettingType.IsEnum && entry.SettingType != typeof(KeyCode)) { Array values = Enum.GetValues(entry.SettingType); int num4 = Array.IndexOf(values.Cast<object>().ToArray(), entry.BoxedValue); if (GUILayout.Button("◄", _skin.SmallButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(26f) })) { entry.BoxedValue = values.GetValue((num4 + values.Length - 1) % values.Length); } GUILayout.Label(UiLabels.Name(entry.BoxedValue.ToString()), _skin.Field, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (GUILayout.Button("►", _skin.SmallButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(26f) })) { entry.BoxedValue = values.GetValue((num4 + 1) % values.Length); } } else { if (!_drafts.TryGetValue(entry, out var value)) { value = ((entry.SettingType == typeof(Color)) ? ("#" + ColorUtility.ToHtmlStringRGBA((Color)entry.BoxedValue)) : entry.GetSerializedValue()); } string text2 = GUILayout.TextField(value, _skin.EditorHex, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.MinWidth(40f), GUILayout.ExpandWidth(true) }); if (text2 != value) { _drafts[entry] = text2; } if (GUILayout.Button(UiEnvironment.L("Apply", "Применить"), _skin.SmallButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width((float)(UiEnvironment.Russian ? 86 : 54)) })) { Apply(entry, text2); } } } GUILayout.EndHorizontal(); if (entry.SettingType == typeof(Color)) { Color val2 = (Color)entry.BoxedValue; Rect rect = GUILayoutUtility.GetRect(0f, 24f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if ((int)Event.current.type == 7) { _skin.PreviewPaper.Draw(rect, false, false, false, false); GUI.DrawTexture(rect, (Texture)(object)_skin.White, (ScaleMode)0, true, 0f, val2, 0f, 6f); GUI.Label(rect, "#" + ColorUtility.ToHtmlStringRGBA(val2), _skin.Value); } } } private void Apply(ConfigEntryBase entry, string text) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) try { if (entry.SettingType == typeof(Color)) { Color val = default(Color); if (!ColorUtility.TryParseHtmlString("#" + text.Trim().TrimStart('#'), ref val)) { throw new FormatException(); } entry.BoxedValue = val; } else if (entry.SettingType == typeof(KeyCode)) { entry.BoxedValue = Enum.Parse(typeof(KeyCode), text.Trim(), ignoreCase: true); } else if (entry.SettingType == typeof(KeyboardShortcut)) { string[] array = text.Split('+'); for (int i = 0; i < array.Length; i++) { if (!Enum.TryParse<KeyCode>(array[i].Trim(), ignoreCase: true, out KeyCode result) || !Enum.IsDefined(typeof(KeyCode), result)) { throw new FormatException(); } } entry.BoxedValue = KeyboardShortcut.Deserialize(text.Trim()); } else if (entry.SettingType == typeof(float)) { if (!float.TryParse(text.Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out var result2) || float.IsNaN(result2) || float.IsInfinity(result2)) { throw new FormatException(); } entry.BoxedValue = result2; } else if (entry.SettingType == typeof(int)) { entry.BoxedValue = int.Parse(text, NumberStyles.Integer, CultureInfo.InvariantCulture); } else { if (!(entry.SettingType == typeof(string))) { throw new FormatException(); } entry.BoxedValue = text; } _drafts.Remove(entry); _error = null; } catch (Exception) { _error = UiEnvironment.L("Invalid value. The saved setting is unchanged.", "Некорректное значение. Сохранённая настройка не изменена."); } } private static string Root(string section) { return section.Split('.')[0]; } private void OnDestroy() { _shield?.Dispose(); if ((Object)(object)_dock != (Object)null) { Object.Destroy((Object)(object)((Component)_dock).gameObject); } _skin?.Destroy(); if ((Object)(object)_guiSkin != (Object)null) { Object.Destroy((Object)(object)_guiSkin); } } } internal static class DockLayout { internal readonly struct Box { internal readonly float X; internal readonly float Y; internal readonly float Width; internal readonly float Height; internal Box(float x, float y, float width, float height) { X = x; Y = y; Width = width; Height = height; } internal bool Overlaps(Box b) { if (X < b.X + b.Width && X + Width > b.X && Y < b.Y + b.Height) { return Y + Height > b.Y; } return false; } } internal static bool Find(float width, float height, float scale, int count, IReadOnlyList<Box> obstacles, out Box result) { return Find(width, height, 36f * scale, 36f * scale, 6f * scale, 12f * scale, count, obstacles, out result); } internal static bool FindRight(float width, float height, float x, float buttonWidth, float buttonHeight, float gap, float preferredTop, float margin, int count, IReadOnlyList<Box> obstacles, out Box result) { result = default(Box); float num = buttonHeight + gap; float num2 = (float)count * num - gap; if (count <= 0 || buttonWidth <= 0f || buttonHeight <= 0f || gap < 0f || x < 0f || x >= width || x + buttonWidth < width || num2 + 2f * margin > height) { return false; } int num3 = (int)Math.Ceiling((margin - preferredTop) / num); int num4 = (int)Math.Floor((height - margin - num2 - preferredTop) / num); List<int> list = new List<int>(); for (int i = Math.Max(0, num3); i <= num4; i++) { list.Add(i); } for (int num5 = Math.Min(-1, num4); num5 >= num3; num5--) { list.Add(num5); } foreach (int item in list) { float y = preferredTop + (float)item * num; Box b = new Box(x, y, width - x, num2); bool flag = false; foreach (Box obstacle in obstacles) { if (obstacle.Overlaps(b)) { flag = true; break; } } if (!flag) { result = new Box(x, y, buttonWidth, num2); return true; } } return false; } internal static bool Find(float width, float height, float buttonWidth, float buttonHeight, float gap, float margin, int count, IReadOnlyList<Box> obstacles, out Box result) { float num = (float)count * (buttonHeight + gap) - gap; result = default(Box); if (count <= 0 || width < buttonWidth + 2f * margin || height < num + 24f || buttonWidth <= 0f || buttonHeight <= 0f) { return false; } bool[] array = new bool[2] { true, false }; for (int i = 0; i < array.Length; i++) { float x = (array[i] ? (width - margin - buttonWidth) : margin); float num2 = Math.Max(12f, Math.Min((height - num) * 0.5f, height - num - 12f)); for (int j = 0; (float)j < height / (buttonHeight + gap) + 2f; j++) { int[] array2 = new int[2] { 1, -1 }; foreach (int num3 in array2) { float num4 = num2 + (float)j * (buttonHeight + gap) * (float)num3; if (num4 < 12f || num4 + num > height - 12f) { continue; } Box box = new Box(x, num4, buttonWidth, num); bool flag = false; foreach (Box obstacle in obstacles) { if (obstacle.Overlaps(box)) { flag = true; break; } } if (!flag) { result = box; return true; } } } } return false; } } internal static class SidebarVisibility { internal static bool Show(bool desktop, bool nativeActive, bool canvasEnabled, float alpha) { if (!desktop && nativeActive && canvasEnabled) { return alpha > 0.01f; } return false; } } internal sealed class FreeCamera { private const float MaxPitch = 89f; private const float SpeedStepPerNotch = 1.2f; private const float MinSpeedScale = 0.05f; private const float MaxSpeedScale = 20f; private Camera _camera; private CinemachineBrain _brain; private bool _brainWasEnabled; private float _gameFov; private Vector3 _position; private Vector3 _targetPosition; private float _yaw; private float _targetYaw; private float _pitch; private float _targetPitch; private float _fov; private float _speedScale = 1f; public static bool IsActive { get; private set; } private static Plugin Settings => Plugin.Instance; public bool TryEnter(out string error) { //IL_0087: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) error = null; if ((Object)(object)GameAccess.LocalPlayer == (Object)null) { error = "join a world first"; return false; } if (GameAccess.IsPlayerOnSwan()) { error = "not available on the swan boat"; return false; } Camera main = Camera.main; CinemachineBrain val = (((Object)(object)main != (Object)null) ? ((Component)main).GetComponent<CinemachineBrain>() : null); if ((Object)(object)val == (Object)null || !((Behaviour)val).enabled) { error = "the game camera is not available right now"; return false; } _camera = main; _brain = val; _brainWasEnabled = ((Behaviour)val).enabled; ((Behaviour)val).enabled = false; Transform transform = ((Component)main).transform; _position = (_targetPosition = transform.position); Quaternion rotation = transform.rotation; Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles; _yaw = (_targetYaw = eulerAngles.y); _pitch = (_targetPitch = Mathf.Clamp(Mathf.DeltaAngle(0f, eulerAngles.x), -89f, 89f)); _fov = (_gameFov = main.fieldOfView); IsActive = true; return true; } public void Exit() { if (IsActive) { IsActive = false; if ((Object)(object)_camera != (Object)null) { _camera.fieldOfView = _gameFov; } if ((Object)(object)_brain != (Object)null) { ((Behaviour)_brain).enabled = _brainWasEnabled; } _camera = null; _brain = null; } } public void ResetFov() { _fov = _gameFov; Plugin.Toast($"Field of view: {_fov:0}° (default)"); } public bool LateTick() { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_00fe: Unknown result type (might be due to invalid IL or missing references) if (!IsActive) { return true; } if ((Object)(object)_camera == (Object)null || (Object)(object)_brain == (Object)null || (Object)(object)GameAccess.LocalPlayer == (Object)null) { Exit(); return false; } ((Behaviour)_brain).enabled = false; float unscaledDeltaTime = Time.unscaledDeltaTime; if (!UiEnvironment.AnyWindowOpen && !GameAccess.IsAnyTextFieldFocused()) { ReadInput(unscaledDeltaTime); } float value = Settings.FreeCamSmoothing.Value; float num = ((value <= 0f) ? 1f : (1f - Mathf.Pow(value, unscaledDeltaTime * 10f))); _position = Vector3.Lerp(_position, _targetPosition, num); _yaw = Mathf.Lerp(_yaw, _targetYaw, num); _pitch = Mathf.Lerp(_pitch, _targetPitch, num); ((Component)_camera).transform.SetPositionAndRotation(_position, Quaternion.Euler(_pitch, _yaw, 0f)); _camera.fieldOfView = _fov; return true; } private void ReadInput(float deltaTime) { //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0150: 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_0160: 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_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0267: 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_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: 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_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: 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_02f6: Unknown result type (might be due to invalid IL or missing references) bool flag = Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303); if (Input.GetMouseButton(1)) { float value = Settings.FreeCamLookSensitivity.Value; float num = (Settings.FreeCamInvertY.Value ? (-1f) : 1f); _targetYaw += Input.GetAxisRaw("Mouse X") * value; _targetPitch = Mathf.Clamp(_targetPitch - Input.GetAxisRaw("Mouse Y") * value * num, -89f, 89f); } float y = Input.mouseScrollDelta.y; if (Mathf.Abs(y) > 0.001f && !GameAccess.IsPointerOverUi()) { if (flag) { _fov = Mathf.Clamp(_fov - y * 2f, 10f, 120f); Plugin.Toast($"Field of view: {_fov:0}°"); } else { _speedScale = Mathf.Clamp(_speedScale * Mathf.Pow(1.2f, y), 0.05f, 20f); Plugin.Toast($"Camera speed: {Settings.FreeCamSpeed.Value * _speedScale:0.##} m/s"); } } Vector3 zero = Vector3.zero; if (Input.GetKey(Settings.FreeCamForward.Value)) { zero.z += 1f; } if (Input.GetKey(Settings.FreeCamBack.Value)) { zero.z -= 1f; } if (Input.GetKey(Settings.FreeCamRight.Value)) { zero.x += 1f; } if (Input.GetKey(Settings.FreeCamLeft.Value)) { zero.x -= 1f; } float num2 = 0f; if (Input.GetKey(Settings.FreeCamUp.Value)) { num2 += 1f; } if (Input.GetKey(Settings.FreeCamDown.Value)) { num2 -= 1f; } if (((Vector3)(ref zero)).sqrMagnitude > 1f) { ((Vector3)(ref zero)).Normalize(); } float num3 = Settings.FreeCamSpeed.Value * _speedScale; if (Input.GetKey(Settings.FreeCamFast.Value)) { num3 *= Settings.FreeCamFastMultiplier.Value; } if (Input.GetKey(Settings.FreeCamSlow.Value)) { num3 *= Settings.FreeCamSlowMultiplier.Value; } Vector3 val = Quaternion.Euler(_targetPitch, _targetYaw, 0f) * zero + Vector3.up * num2; _targetPosition += val * (num3 * deltaTime); } } internal static class InputBlocker { private static readonly string[] KeptInputs = new string[5] { "IsMouseButton1", "IsMouseButton1Up", "IsEscapeKeyDown", "EnterKeyDown", "EnterKeyUp" }; private static List<FieldInfo> _fields; internal static void AfterInputUpdate(InputManager input) { if (!FreeCamera.IsActive) { return; } if (_fields == null) { _fields = FindInputFields(); } foreach (FieldInfo field in _fields) { field.SetValue(input, (field.FieldType == typeof(bool)) ? ((object)false) : ((object)0f)); } } private static List<FieldInfo> FindInputFields() { List<FieldInfo> list = new List<FieldInfo>(); FieldInfo[] fields = typeof(InputManager).GetFields(BindingFlags.Instance | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (fieldInfo.Name.StartsWith("<") && fieldInfo.Name.EndsWith(">k__BackingField") && (!(fieldInfo.FieldType != typeof(bool)) || !(fieldInfo.FieldType != typeof(float)))) { string value = fieldInfo.Name.Substring(1, fieldInfo.Name.IndexOf('>') - 1); if (Array.IndexOf(KeptInputs, value) < 0) { list.Add(fieldInfo); } } } return list; } } internal static class GameAccess { private const float LookupInterval = 1f; private static TextChannelManager _chat; private static float _nextChatLookup; private static TextChannelManager Chat { get { if ((Object)(object)_chat == (Object)null && Time.unscaledTime >= _nextChatLookup) { _nextChatLookup = Time.unscaledTime + 1f; _chat = NetworkSingleton<TextChannelManager>.I; } return _chat; } } public static Transform LocalPlayer { get { TextChannelManager chat = Chat; if (!((Object)(object)chat != (Object)null)) { return null; } return chat.MainPlayer; } } public static bool IsPlayerOnSwan() { if ((Object)(object)LocalPlayer == (Object)null) { return false; } SwanManager i = NetworkSingleton<SwanManager>.I; if ((Object)(object)i != (Object)null) { return i.IsPlayerOnSwan(); } return false; } public static bool IsAnyTextFieldFocused() { EventSystem current = EventSystem.current; if ((Object)(object)current == (Object)null) { return false; } GameObject currentSelectedGameObject = current.currentSelectedGameObject; if ((Object)(object)currentSelectedGameObject == (Object)null) { return false; } TMP_InputField component = currentSelectedGameObject.GetComponent<TMP_InputField>(); if ((Object)(object)component != (Object)null && component.isFocused) { return true; } InputField component2 = currentSelectedGameObject.GetComponent<InputField>(); if ((Object)(object)component2 != (Object)null) { return component2.isFocused; } return false; } public static bool IsPointerOverUi() { EventSystem current = EventSystem.current; if ((Object)(object)current != (Object)null) { return current.IsPointerOverGameObject(); } return false; } public static bool GameWouldZoom() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 if ((int)MonoSingleton<OverlayManager>.I.ResolutionMode == 3) { return false; } GameObject mouseOverUIObject = MonoSingleton<InputManager>.I.MouseOverUIObject; if (!((Object)(object)mouseOverUIObject == (Object)null)) { return MonoSingleton<UIManager>.I.OverlayMasks.Contains(mouseOverUIObject.transform); } return true; } } internal static class Lens { public const float MinFov = 10f; public const float MaxFov = 120f; public const float StepPerNotch = 2f; private static CinemachineVirtualCamera _vcam; private static float _gameFov; private static float? _wheelFov; private static bool _modified; private static Plugin Settings => Plugin.Instance; public static void Adjust(CinemachineVirtualCamera vcam, float scroll) { if (!((Object)(object)vcam == (Object)null)) { Capture(vcam); _wheelFov = Mathf.Clamp(TargetFov() - scroll * 2f, 10f, 120f); Plugin.Toast($"Field of view: {_wheelFov.Value:0}°"); } } public static void Reset() { _wheelFov = null; if ((Object)(object)_vcam != (Object)null) { Plugin.Toast($"Field of view: {TargetFov():0}° (default)"); } } public static void Tick(CinemachineVirtualCamera vcam) { if (!((Object)(object)vcam == (Object)null)) { Capture(vcam); float num = TargetFov(); if (_modified || !Mathf.Approximately(num, _gameFov)) { SetFov(vcam, num); _modified = !Mathf.Approximately(num, _gameFov); } } } public static void Restore() { _wheelFov = null; if ((Object)(object)_vcam != (Object)null && _modified) { SetFov(_vcam, _gameFov); } _modified = false; } private static void Capture(CinemachineVirtualCamera vcam) { if (!((Object)(object)vcam == (Object)(object)_vcam)) { _vcam = vcam; _gameFov = vcam.m_Lens.FieldOfView; _modified = false; } } private static float TargetFov() { if (_wheelFov.HasValue) { return _wheelFov.Value; } float value = Settings.FieldOfView.Value; if (!(value >= 10f)) { return _gameFov; } return Mathf.Min(value, 120f); } private static void SetFov(CinemachineVirtualCamera vcam, float fov) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //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) //IL_001f: 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) LensSettings lens = vcam.m_Lens; if (!Mathf.Approximately(lens.FieldOfView, fov)) { lens.FieldOfView = fov; vcam.m_Lens = lens; } } } internal sealed class ModDock : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler { private Func<string> _hint; private Func<bool> _isOpen; private Func<bool> _visible; private Image _image; private Image _iconImage; private Image _outlineImage; private Button _control; private Button _native; private Image _nativeBackground; private Image _nativeIcon; private Image _nativeOutline; private Text _tooltip; private RectTransform _tooltipRect; private Sprite _background; private Sprite _icon; private Texture2D _backgroundTexture; private Texture2D _iconTexture; private CanvasGroup _group; private float _nextLayout; private bool _hover; private readonly List<DockLayout.Box> _obstacles = new List<DockLayout.Box>(); private readonly Vector3[] _corners = (Vector3[])(object)new Vector3[4]; internal static ModDock Register(string name, string symbol, Action toggle, Func<bool> open, Func<string> hint, Func<bool> visible = null) { //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0177: 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_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0255: 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_0274: Expected O, but got Unknown //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Expected O, but got Unknown //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Expected O, but got Unknown //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_0343: 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_034e: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_0389: 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_03cf: 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_042c: Expected O, but got Unknown //IL_0473: Unknown result type (might be due to invalid IL or missing references) //IL_047d: Expected O, but got Unknown //IL_04a2: Unknown result type (might be due to invalid IL or missing references) //IL_04a9: Expected O, but got Unknown //IL_04c4: Unknown result type (might be due to invalid IL or missing references) //IL_04c9: Unknown result type (might be due to invalid IL or missing references) //IL_04ca: Unknown result type (might be due to invalid IL or missing references) //IL_04d4: Unknown result type (might be due to invalid IL or missing references) //IL_04d5: Unknown result type (might be due to invalid IL or missing references) //IL_04df: Unknown result type (might be due to invalid IL or missing references) //IL_04ea: Unknown result type (might be due to invalid IL or missing references) //IL_04fe: Unknown result type (might be due to invalid IL or missing references) //IL_0546: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.Find("LightShaper.ModDock.v1"); if ((Object)(object)val == (Object)null) { val = new GameObject("LightShaper.ModDock.v1", new Type[3] { typeof(RectTransform), typeof(Canvas), typeof(GraphicRaycaster) }); Object.DontDestroyOnLoad((Object)(object)val); Canvas component = val.GetComponent<Canvas>(); component.renderMode = (RenderMode)0; component.sortingOrder = 32765; } GameObject val2 = new GameObject(name, new Type[4] { typeof(RectTransform), typeof(Image), typeof(Button), typeof(CanvasGroup) }); val2.transform.SetParent(val.transform, false); ModDock modDock = val2.AddComponent<ModDock>(); modDock._hint = hint; modDock._isOpen = open; modDock._visible = visible ?? ((Func<bool>)(() => true)); modDock._group = val2.GetComponent<CanvasGroup>(); modDock._group.alpha = 0f; ((RectTransform)val2.transform).anchoredPosition = new Vector2(-10000f, -10000f); modDock._image = val2.GetComponent<Image>(); modDock._backgroundTexture = RoundedTexture(); modDock._background = Sprite.Create(modDock._backgroundTexture, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4(16f, 16f, 16f, 16f)); modDock._image.sprite = modDock._background; modDock._image.type = (Type)1; Button val3 = (modDock._control = val2.GetComponent<Button>()); ((Selectable)val3).targetGraphic = (Graphic)(object)modDock._image; Navigation navigation = default(Navigation); ((Navigation)(ref navigation)).mode = (Mode)0; ((Selectable)val3).navigation = navigation; ColorBlock colors = ((Selectable)val3).colors; ((ColorBlock)(ref colors)).normalColor = Color.white; ((ColorBlock)(ref colors)).highlightedColor = new Color(1f, 0.88f, 0.8f); ((ColorBlock)(ref colors)).pressedColor = new Color(0.95f, 0.8f, 0.68f); ((Selectable)val3).colors = colors; ((UnityEvent)val3.onClick).AddListener((UnityAction)delegate { toggle(); EventSystem current = EventSystem.current; if (current != null) { current.SetSelectedGameObject((GameObject)null); } }); GameObject val4 = new GameObject("Outline", new Type[2] { typeof(RectTransform), typeof(Image) }); val4.transform.SetParent(val2.transform, false); modDock._outlineImage = val4.GetComponent<Image>(); ((Graphic)modDock._outlineImage).raycastTarget = false; ((Behaviour)modDock._outlineImage).enabled = false; GameObject val5 = new GameObject("Icon", new Type[2] { typeof(RectTransform), typeof(Image) }); val5.transform.SetParent(val2.transform, false); RectTransform val6 = (RectTransform)val5.transform; val6.anchorMin = new Vector2(0.19f, 0.19f); val6.anchorMax = new Vector2(0.81f, 0.81f); Vector2 offsetMin = (val6.offsetMax = Vector2.zero); val6.offsetMin = offsetMin; modDock._iconTexture = IconTexture(symbol); modDock._icon = Sprite.Create(modDock._iconTexture, new Rect(0f, 0f, 32f, 32f), new Vector2(0.5f, 0.5f)); val5.GetComponent<Image>().sprite = modDock._icon; ((Graphic)val5.GetComponent<Image>()).color = new Color(0.67f, 0.31f, 0.24f); ((Graphic)val5.GetComponent<Image>()).raycastTarget = false; val5.GetComponent<Image>().preserveAspect = true; modDock._iconImage = val5.GetComponent<Image>(); GameObject val7 = new GameObject("Tooltip", new Type[2] { typeof(RectTransform), typeof(Image) }); val7.transform.SetParent(val2.transform, false); val7.GetComponent<Image>().sprite = modDock._background; val7.GetComponent<Image>().type = (Type)1; ((Graphic)val7.GetComponent<Image>()).raycastTarget = false; modDock._tooltipRect = (RectTransform)val7.transform; GameObject val8 = new GameObject("Text", new Type[2] { typeof(RectTransform), typeof(Text) }); val8.transform.SetParent(val7.transform, false); RectTransform val9 = (RectTransform)val8.transform; val9.anchorMin = Vector2.zero; val9.anchorMax = Vector2.one; val9.offsetMin = new Vector2(10f, 4f); val9.offsetMax = new Vector2(-10f, -4f); modDock._tooltip = val8.GetComponent<Text>(); modDock._tooltip.font = UiEnvironment.GameFont ?? Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf"); modDock._tooltip.fontSize = 13; ((Graphic)modDock._tooltip).color = UiSkin.TextColor; modDock._tooltip.alignment = (TextAnchor)4; ((Graphic)modDock._tooltip).raycastTarget = false; modDock._tooltip.supportRichText = false; val7.SetActive(false); Transform[] array = ((IEnumerable)val.transform).Cast<Transform>().OrderBy<Transform, string>((Transform t) => ((Object)t).name, StringComparer.Ordinal).ToArray(); for (int num = 0; num < array.Length; num++) { array[num].SetAsLastSibling(); } return modDock; } private void Update() { //IL_0027: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: 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) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Expected O, but got Unknown //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0240: 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_0282: Unknown result type (might be due to invalid IL or missing references) ApplyNativeStyle(); float opacity = NativeSidebar.Opacity; bool flag = _visible() && opacity > 0.01f && ((RectTransform)((Component)this).transform).anchoredPosition.x > -9000f; _group.alpha = (flag ? opacity : 0f); _group.blocksRaycasts = flag; _group.interactable = flag; if (!flag) { _hover = false; } ((Graphic)_image).color = (((Object)(object)_native != (Object)null) ? NativeSidebar.SurfaceColor(_hover || _isOpen()) : Color.white); ((Graphic)_iconImage).color = (Color)(((Object)(object)_nativeOutline != (Object)null) ? ((Graphic)_nativeOutline).color : new Color(0.43f, 0.34f, 0.35f, 1f)); if (((Component)this).transform.GetSiblingIndex() == 0 && Time.unscaledTime >= _nextLayout) { _nextLayout = Time.unscaledTime + 0.15f; LayoutGroup(); } bool flag2 = _hover && _group.alpha > 0f && _group.blocksRaycasts; ((Component)_tooltipRect).gameObject.SetActive(flag2); if (flag2) { float scale = UiEnvironment.Scale; _tooltip.text = _hint(); _tooltip.fontSize = Mathf.RoundToInt(13f * scale); float num = Mathf.Min((float)Screen.width - 24f, Mathf.Max(140f * scale, _tooltip.preferredWidth + 24f)); RectTransform val = (RectTransform)((Component)this).transform; _tooltipRect.pivot = new Vector2(1f, 0.5f); RectTransform tooltipRect = _tooltipRect; RectTransform tooltipRect2 = _tooltipRect; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0f, 0.5f); tooltipRect2.anchorMax = val2; tooltipRect.anchorMin = val2; _tooltipRect.sizeDelta = new Vector2(num, 32f * scale); float num2 = Mathf.Min((float)Screen.width - 12f, val.anchoredPosition.x - 8f); num2 = Mathf.Max(num + 12f, num2); _tooltipRect.anchoredPosition = new Vector2(num2 - val.anchoredPosition.x, 0f); } } private void ApplyNativeStyle() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Invalid comparison between Unknown and I4 //IL_005a: 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_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: 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) Button button = NativeSidebar.Button; if ((Object)(object)button == (Object)null) { return; } Image val = NativeSidebar.Background(button); if (!((Object)(object)val == (Object)null)) { _native = button; _nativeBackground = val; _nativeIcon = NativeSidebar.Icon(button); _nativeOutline = NativeSidebar.Outline(button); ((Selectable)_control).transition = (Transition)(((int)((Selectable)button).transition == 1) ? ((int)((Selectable)button).transition) : 0); ((Selectable)_control).colors = ((Selectable)button).colors; NativeSidebar.CopyImage(_nativeBackground, _image); float num = NativeSidebar.PixelScale(val); if ((Object)(object)_nativeOutline != (Object)null) { ((Behaviour)_outlineImage).enabled = true; NativeSidebar.CopyImage(_nativeOutline, _outlineImage); NativeSidebar.CopyRect(((Graphic)_nativeOutline).rectTransform, ((Graphic)_outlineImage).rectTransform, num); } else { ((Behaviour)_outlineImage).enabled = false; } if ((Object)(object)_nativeIcon != (Object)null) { NativeSidebar.CopyRect(((Graphic)_nativeIcon).rectTransform, ((Graphic)_iconImage).rectTransform, num); Rect rect = ((Graphic)_nativeIcon).rectTransform.rect; float width = ((Rect)(ref rect)).width; rect = ((Graphic)_nativeIcon).rectTransform.rect; float num2 = Mathf.Min(width, ((Rect)(ref rect)).height) * num; ((Graphic)_iconImage).rectTransform.sizeDelta = new Vector2(num2, num2); } } } private void LayoutGroup() { //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Invalid comparison between Unknown and I4 //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_032d: 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_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_0346: 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_034f: Unknown result type (might be due to invalid IL or missing references) //IL_0350: 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) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_038d: 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_0374: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_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_016c: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018e: 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_01a2: 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_01bb: 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_01cd: Unknown result type (might be due to invalid IL or missing references) _obstacles.Clear(); Graphic[] array = GraphicRegistryAll(); foreach (Graphic val in array) { if (!((Behaviour)val).isActiveAndEnabled || (Object)(object)val.canvas == (Object)null || (int)val.canvas.renderMode == 2 || ((Component)val).transform.IsChildOf(((Component)this).transform.parent)) { continue; } bool flag = false; Transform val2 = ((Component)val).transform; while ((Object)(object)val2 != (Object)null) { if (((Object)val2).name.IndexOf("chat", StringComparison.OrdinalIgnoreCase) >= 0) { flag = true; break; } val2 = val2.parent; } if (!val.raycastTarget && !flag) { continue; } bool flag2 = ((Object)((Component)val).transform.root).name == "LightShaper.ModWindows.v1"; if (flag2 || (!((flag ? 1f : val.color.a) * val.canvasRenderer.GetInheritedAlpha() < 0.03f) && !val.canvasRenderer.cull)) { val.rectTransform.GetWorldCorners(_corners); Camera obj = (((int)val.canvas.renderMode == 0) ? null : val.canvas.worldCamera); Vector2 val3 = RectTransformUtility.WorldToScreenPoint(obj, _corners[0]); Vector2 val4 = RectTransformUtility.WorldToScreenPoint(obj, _corners[2]); Rect val5 = Rect.MinMaxRect(Mathf.Min(val3.x, val4.x), (float)Screen.height - Mathf.Max(val3.y, val4.y), Mathf.Max(val3.x, val4.x), (float)Screen.height - Mathf.Min(val3.y, val4.y)); if (!(((Rect)(ref val5)).width > (float)Screen.width * 0.95f) || !(((Rect)(ref val5)).height > (float)Screen.height * 0.95f) || flag2) { ((Rect)(ref val5)).xMin = ((Rect)(ref val5)).xMin - 6f; ((Rect)(ref val5)).yMin = ((Rect)(ref val5)).yMin - 6f; ((Rect)(ref val5)).xMax = ((Rect)(ref val5)).xMax + 6f; ((Rect)(ref val5)).yMax = ((Rect)(ref val5)).yMax + 6f; _obstacles.Add(new DockLayout.Box(((Rect)(ref val5)).x, ((Rect)(ref val5)).y, ((Rect)(ref val5)).width, ((Rect)(ref val5)).height)); } } } Transform[] array2 = (from Transform t in (IEnumerable)((Component)this).transform.parent where (Object)(object)((Component)t).GetComponent<Button>() != (Object)null select t).ToArray(); float scale = UiEnvironment.Scale; Rect bounds; float gap; float preferredTop; bool num = NativeSidebar.TryGeometry(out bounds, out gap, out preferredTop); Vector2 size = ((Rect)(ref bounds)).size; DockLayout.Box result = default(DockLayout.Box); bool flag3 = num && DockLayout.FindRight(Screen.width, Screen.height, ((Rect)(ref bounds)).x, size.x, size.y, gap, preferredTop, 6f * scale, array2.Length, _obstacles, out result); Vector2 val7 = default(Vector2); for (int num2 = 0; num2 < array2.Length; num2++) { RectTransform val6 = (RectTransform)array2[num2]; ((Vector2)(ref val7))..ctor(0f, 1f); val6.pivot = val7; Vector2 anchorMin = (val6.anchorMax = val7); val6.anchorMin = anchorMin; val6.sizeDelta = size; val6.anchoredPosition = (flag3 ? new Vector2(result.X, 0f - result.Y - (float)num2 * (size.y + gap)) : new Vector2(-10000f, -10000f)); } } private static Graphic[] GraphicRegistryAll() { return Object.FindObjectsByType<Graphic>((FindObjectsInactive)0, (FindObjectsSortMode)0); } public void OnPointerEnter(PointerEventData data) { _hover = true; } public void OnPointerExit(PointerEventData data) { _hover = false; } private void OnDestroy() { Object.Destroy((Object)(object)_background); Object.Destroy((Object)(object)_icon); Object.Destroy((Object)(object)_backgroundTexture); Object.Destroy((Object)(object)_iconTexture); if ((Object)(object)((Component)this).transform.parent != (Object)null && ((Component)this).transform.parent.childCount == 1) { Object.Destroy((Object)(object)((Component)((Component)this).transform.parent).gameObject); } } private static Texture2D RoundedTexture() { //IL_0065: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) Color[] array = (Color[])(object)new Color[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { float num = Mathf.Abs((float)j + 0.5f - 32f) - 18f; float num2 = Mathf.Abs((float)i + 0.5f - 32f) - 18f; Vector2 val = new Vector2(Mathf.Max(num, 0f), Mathf.Max(num2, 0f)); float num3 = ((Vector2)(ref val)).magnitude + Mathf.Min(Mathf.Max(num, num2), 0f) - 14f; Color val2 = Color.Lerp(new Color(0.43f, 0.34f, 0.35f, 1f), new Color(1f, 0.95f, 0.86f, 1f), Mathf.Clamp01(0.5f - num3 - 4f)); val2.a = Mathf.Clamp01(0.5f - num3); array[i * 64 + j] = val2; } } return Texture(array, 64); } private static Texture2D IconTexture(string symbol) { //IL_0484: Unknown result type (might be due to invalid IL or missing references) //IL_0489: 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_0494: Unknown result type (might be due to invalid IL or missing references) //IL_04a0: Unknown result type (might be due to invalid IL or missing references) //IL_04a7: Unknown result type (might be due to invalid IL or missing references) //IL_04ae: Unknown result type (might be due to invalid IL or missing references) //IL_04b3: Unknown result type (might be due to invalid IL or missing references) //IL_04b5: Unknown result type (might be due to invalid IL or missing references) //IL_04ba: Unknown result type (might be due to invalid IL or missing references) //IL_04be: Unknown result type (might be due to invalid IL or missing references) //IL_04c0: 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_04c7: Unknown result type (might be due to invalid IL or missing references) //IL_04c9: Unknown result type (might be due to invalid IL or missing references) //IL_04cb: Unknown result type (might be due to invalid IL or missing references) //IL_04cd: Unknown result type (might be due to invalid IL or missing references) //IL_04d2: Unknown result type (might be due to invalid IL or missing references) //IL_04e6: Unknown result type (might be due to invalid IL or missing references) //IL_04eb: Unknown result type (might be due to invalid IL or missing references) //IL_04f0: Unknown result type (might be due to invalid IL or missing references) //IL_053f: Unknown result type (might be due to invalid IL or missing references) //IL_0544: Unknown result type (might be due to invalid IL or missing references) List<Vector4> lines = new List<Vector4>(); switch (symbol) { case "camera": Box(4f, 9f, 24f, 17f); Box(10f, 5f, 10f, 4f); Circle(lines, 16f, 17f, 6f); break; case "sound": Box(4f, 13f, 6f, 8f); Line(10f, 13f, 17f, 7f); Line(17f, 7f, 17f, 26f); Line(17f, 26f, 10f, 21f); Line(22f, 11f, 26f, 15f); Line(26f, 15f, 26f, 19f); Line(26f, 19f, 22f, 23f); break; case "range": Circle(lines, 16f, 16f, 11f); Line(16f, 2f, 16f, 9f); Line(16f, 23f, 16f, 30f); Line(2f, 16f, 9f, 16f); Line(23f, 16f, 30f, 16f); break; case "voice": Box(12f, 4f, 8f, 17f); Line(7f, 16f, 7f, 23f); Line(7f, 23f, 25f, 23f); Line(25f, 23f, 25f, 16f); Line(16f, 23f, 16f, 29f); Line(10f, 29f, 22f, 29f); break; case "move": Line(16f, 29f, 16f, 3f); Line(16f, 3f, 10f, 9f); Line(16f, 3f, 22f, 9f); Line(16f, 29f, 10f, 23f); Line(16f, 29f, 22f, 23f); Line(3f, 16f, 29f, 16f); Line(3f, 16f, 9f, 10f); Line(3f, 16f, 9f, 22f); Line(29f, 16f, 23f, 10f); Line(29f, 16f, 23f, 22f); break; default: Box(4f, 5f, 24f, 18f); Line(9f, 23f, 9f, 28f); Line(9f, 28f, 15f, 23f); Line(10f, 11f, 22f, 11f); Line(10f, 17f, 18f, 17f); break; } Color[] array = (Color[])(object)new Color[1024]; Vector2 val = default(Vector2); Vector2 val2 = default(Vector2); for (int i = 0; i < 32; i++) { for (int j = 0; j < 32; j++) { ((Vector2)(ref val))..ctor((float)j + 0.5f, 31.5f - (float)i); float num = 100f; foreach (Vector4 item in lines) { ((Vector2)(ref val2))..ctor(item.x, item.y); Vector2 val3 = new Vector2(item.z, item.w) - val2; float num2 = num; Vector2 val4 = val - val2 - val3 * Mathf.Clamp01(Vector2.Dot(val - val2, val3) / ((Vector2)(ref val3)).sqrMagnitude); num = Mathf.Min(num2, ((Vector2)(ref val4)).magnitude); } array[i * 32 + j] = new Color(1f, 1f, 1f, Mathf.Clamp01(2.2f - num)); } } return Texture(array); void Box(float x, float y, float w, float h) { Line(x, y, x + w, y); Line(x + w, y, x + w, y + h); Line(x + w, y + h, x, y + h); Line(x, y + h, x, y); } void Line(float x, float y, float a, float b) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) lines.Add(new Vector4(x, y, a, b)); } } private static void Circle(List<Vector4> lines, float x, float y, float radius) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < 32; i++) { float num = (float)i * MathF.PI / 16f; float num2 = (float)(i + 1) * MathF.PI / 16f; lines.Add(new Vector4(x + Mathf.Cos(num) * radius, y + Mathf.Sin(num) * radius, x + Mathf.Cos(num2) * radius, y + Mathf.Sin(num2) * radius)); } } private static Texture2D Texture(Color[] pixels, int size = 32) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0018: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown Texture2D val = new Texture2D(size, size, (TextureFormat)4, false) { hideFlags = (HideFlags)61, filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1 }; val.SetPixels(pixels); val.Apply(false, true); return val; } } internal static class NativeSidebar { private static readonly FieldInfo RightButtons = AccessTools.Field(typeof(OverlayManager), "_rightTopButtons"); private static readonly FieldInfo IdleColor = AccessTools.Field(typeof(UIManager), "_extraButtonColor"); private static readonly FieldInfo HoverColor = AccessTools.Field(typeof(UIManager), "_extraButtonHoverColor"); private static UIManager _ui; private static OverlayManager _overlay; private static Button _button; private static float _retry; private static readonly Vector3[] Corners = (Vector3[])(object)new Vector3[4]; internal static Button Button { get { if (((Object)(object)_overlay == (Object)null || (Object)(object)_button == (Object)null) && Time.unscaledTime >= _retry) { _retry = Time.unscaledTime + 0.5f; _overlay = Object.FindAnyObjectByType<OverlayManager>(); if ((Object)(object)_overlay != (Object)null && RightButtons?.GetValue(_overlay) is List<GameObject> list) { foreach (GameObject item in list) { if ((Object)(object)item == (Object)null) { continue; } Button componentInChildren = item.GetComponentInChildren<Button>(true); if (!((Object)(object)componentInChildren == (Object)null)) { Image obj = Background(componentInChildren); if (!((Object)(object)((obj != null) ? obj.sprite : null) == (Object)null)) { _button = componentInChildren; break; } } } } } return _button; } } internal static float Opacity { get { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Invalid comparison between Unknown and I4 Button button = Button; Image val = Background(button); if ((Object)(object)_overlay == (Object)null || (Object)(object)button == (Object)null || (Object)(object)val == (Object)null) { return 0f; } Canvas canvas = ((Graphic)val).canvas; float inheritedAlpha = ((Graphic)val).canvasRenderer.GetInheritedAlpha(); if (!SidebarVisibility.Show((int)_overlay.ResolutionMode == 3, ((Component)button).gameObject.activeInHierarchy, (Object)(object)canvas != (Object)null && ((Behaviour)canvas).isActiveAndEnabled, inheritedAlpha)) { return 0f; } return inheritedAlpha; } } internal static Vector2 Size { get { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) Button button = Button; Image val = Background(button); if ((Object)(object)button == (Object)null || (Object)(object)val == (Object)null || (Object)(object)((Graphic)val).canvas == (Object)null) { return Vector2.zero; } Rect val2 = ScreenRect((RectTransform)((Component)button).transform, ((Graphic)val).canvas); return ((Rect)(ref val2)).size; } } internal static Image Background(Button button) { object obj; if (!((Object)(object)button == (Object)null)) { obj = ((Component)button).GetComponent<Image>(); if (obj == null) { Graphic targetGraphic = ((Selectable)button).targetGraphic; return (Image)(object)((targetGraphic is Image) ? targetGraphic : null); } } else { obj = null; } return (Image)obj; } internal static Image Outline(Button button) { if (!((Object)(object)button == (Object)null)) { Transform obj = ((Component)button).transform.Find("Image_Outline"); if (obj == null) { return null; } return ((Component)obj).GetComponent<Image>(); } return null; } internal static Image Icon(Button button) { if (!((Object)(object)button == (Object)null)) { Transform obj = ((Component)button).transform.Find("Image_Icon"); if (obj == null) { return null; } return ((Component)obj).GetComponent<Image>(); } return null; } internal static Color SurfaceColor(bool highlighted) { //IL_0075: 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_0055: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_ui == (Object)null) { _ui = Object.FindAnyObjectByType<UIManager>(); } FieldInfo fieldInfo = (highlighted ? HoverColor : IdleColor); if ((Object)(object)_ui != (Object)null) { object obj = fieldInfo?.GetValue(_ui); if (obj is Color) { return (Color)obj; } } return new Color(0.9608f, 0.9294f, 0.8824f, highlighted ? 1f : 0.749f); } internal static Rect ScreenRect(RectTransform rect, Canvas canvas) { //IL_000c: 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_002d: 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_0039: 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_003f: 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_0056: 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) //IL_0068: 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_007f: 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_0091: Unknown result type (might be due to invalid IL or missing references) rect.GetWorldCorners(Corners); Camera obj = (((int)canvas.renderMode == 0) ? null : canvas.worldCamera); Vector2 val = RectTransformUtility.WorldToScreenPoint(obj, Corners[0]); Vector2 val2 = RectTransformUtility.WorldToScreenPoint(obj, Corners[2]); return Rect.MinMaxRect(Mathf.Min(val.x, val2.x), (float)Screen.height - Mathf.Max(val.y, val2.y), Mathf.Max(val.x, val2.x), (float)Screen.height - Mathf.Min(val.y, val2.y)); } internal static float PixelScale(Image image) { //IL_000c: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) Rect val = ScreenRect(((Graphic)image).rectTransform, ((Graphic)image).canvas); float height = ((Rect)(ref val)).height; val = ((Graphic)image).rectTransform.rect; return height / Mathf.Max(1f, ((Rect)(ref val)).height); } internal static void CopyImage(Image source, Image target) { //IL_000e: 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) target.sprite = source.sprite; target.type = source.type; ((Graphic)target).material = ((Graphic)source).material; ((Graphic)target).color = ((Graphic)source).color; target.preserveAspect = source.preserveAspect; target.fillCenter = source.fillCenter; ((MaskableGraphic)target).maskable = ((MaskableGraphic)source).maskable; float num = ((Graphic)target).canvas.referencePixelsPerUnit / ((Graphic)source).canvas.referencePixelsPerUnit; target.pixelsPerUnitMultiplier = source.pixelsPerUnitMultiplier * num / Mathf.Max(0.01f, PixelScale(source)); } internal static void CopyRect(RectTransform source, RectTransform target, float scale) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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) //IL_0026: 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_0038: 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_004a: 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) target.anchorMin = source.anchorMin; target.anchorMax = source.anchorMax; target.pivot = source.pivot; target.sizeDelta = source.sizeDelta * scale; target.anchoredPosition = source.anchoredPosition * scale; ((Transform)target).localScale = ((Transform)source).localScale; ((Transform)target).localRotation = ((Transform)source).localRotation; } internal static bool TryGeometry(out Rect bounds, out float gap, out float preferredTop) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown //IL_004d: 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_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Expected O, but got Unknown //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) bounds = default(Rect); gap = (preferredTop = 0f); Button button = Button; Image val = Background(button); if ((Object)(object)val == (Object)null || (Object)(object)((Graphic)val).canvas == (Object)null) { return false; } bounds = ScreenRect((RectTransform)((Component)button).transform, ((Graphic)val).canvas); if (((Rect)(ref bounds)).width < 1f || ((Rect)(ref bounds)).height < 1f) { return false; } float num = float.MaxValue; float num2 = ((Rect)(ref bounds)).y; if ((Object)(object)_overlay != (Object)null && RightButtons?.GetValue(_overlay) is List<GameObject> list) { foreach (GameObject item in list) { if ((Object)(object)item == (Object)null) { continue; } Button[] componentsInChildren = item.GetComponentsInChildren<Button>(true); foreach (Button val2 in componentsInChildren) { Image val3 = Background(val2); if (!((Component)val2).gameObject.activeInHierarchy || (Object)(object)val3 == (Object)null || (Object)(object)((Graphic)val3).canvas == (Object)null || (Object)(object)val3.sprite != (Object)(object)val.sprite) { continue; } Rect val4 = ScreenRect((RectTransform)((Component)val2).transform, ((Graphic)val3).canvas); if (!(Mathf.Abs(((Rect)(ref val4)).x - ((Rect)(ref bounds)).x) > ((Rect)(ref bounds)).height * 0.15f) && !(Mathf.Abs(((Rect)(ref val4)).height - ((Rect)(ref bounds)).height) > ((Rect)(ref bounds)).height * 0.15f)) { num2 = Mathf.Max(num2, ((Rect)(ref val4)).y); float num3 = Mathf.Abs(((Rect)(ref val4)).y - ((Rect)(ref bounds)).y); if (num3 > ((Rect)(ref bounds)).height) { num = Mathf.Min(num, num3); } } } } } gap = ((num < float.MaxValue) ? (num - ((Rect)(ref bounds)).height) : (((Rect)(ref bounds)).height * 0.35f)); preferredTop = num2 + ((Rect)(ref bounds)).height + gap; return true; } } internal static class OrbitCamera { private const float GameShoulderRadius = 2f; private const float GameMouseToY = 0.05f; private const float DegreesPerY = 28.64789f; private static readonly FieldRef<PlayerMovementController, float> CurrentZoomRef = AccessTools.FieldRefAccess<PlayerMovementController, float>("_currentZoom"); private static readonly FieldRef<PlayerMovementController, CinemachineVirtualCamera> VcamRef = AccessTools.FieldRefAccess<PlayerMovementController, CinemachineVirtualCamera>("_cinemachineVC"); private static PlayerMovementController _controller; private static bool _engaged; private static float _pitch; private static float _distance; private static float _lastGameY; public static CinemachineVirtualCamera Vcam { get; private set; } private static Plugin Settings => Plugin.Instance; internal static void BeforeRotation(PlayerMovementController controller, Vector2 mouseDelta) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) if (UiEnvironment.AnyWindowOpen) { return; } Vcam = VcamRef.Invoke(controller); if (Settings.OrbitEnabled.Value) { if (!_engaged || (Object)(object)controller != (Object)(object)_controller) { Engage(controller); } else if (!Mathf.Approximately(controller.RotationXPosY, _lastGameY)) { FollowGameTilt(controller); } float num = (0f - mouseDelta.y) * ScriptableSingleton<GameSettings>.I.CameraRotateSpeed * 0.05f; _pitch = ClampPitch(_pitch + num * 28.64789f * Settings.PitchSensitivity.Value); } } internal static void OnZoom(PlayerMovementController controller) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (UiEnvironment.AnyWindowOpen) { return; } float y = Input.mouseScrollDelta.y; if (Mathf.Abs(y) < 0.001f || !GameAccess.GameWouldZoom()) { return; } if (MonoSingleton<InputManager>.I.IsShiftKey) { if (Settings.ShiftScrollFov.Value) { Lens.Adjust(VcamRef.Invoke(controller), y); } } else if (Settings.OrbitEnabled.Value && _engaged && !((Object)(object)controller != (Object)(object)_controller)) { float num = 1f + Settings.ZoomStep.Value / 100f; _distance = ClampDistance(_distance * Mathf.Pow(num, 0f - y)); } } internal static void Apply(PlayerMovementController controller) { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) if (Settings.OrbitEnabled.Value && _engaged && !((Object)(object)controller != (Object)(object)_controller)) { Cinemachine3rdPersonFollow val = FollowOf(controller); if (!((Object)(object)val == (Object)null)) { _pitch = ClampPitch(_pitch); _distance = ClampDistance(_distance); float num = _pitch * (MathF.PI / 180f); val.ShoulderOffset = new Vector3(val.ShoulderOffset.x, _distance * Mathf.Sin(num), (0f - _distance) * Mathf.Cos(num)); val.CameraDistance = 0f; _lastGameY = controller.RotationXPosY; } } } internal static void Disengage() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (!_engaged) { return; } _engaged = false; PlayerMovementController controller = _controller; _controller = null; if (!((Object)(object)controller == (Object)null)) { Cinemachine3rdPersonFollow val = FollowOf(controller); if ((Object)(object)val != (Object)null) { val.CameraDistance = CurrentZoomRef.Invoke(controller); } controller.SetCameraRotation(Vector2.zero); } } private static void Engage(PlayerMovementController controller) { _controller = controller; _engaged = true; float rotationXPosY = controller.RotationXPosY; float num = VanillaBackOffset(controller, rotationXPosY); _pitch = ClampPitch(Mathf.Atan2(rotationXPosY, num) * 57.29578f); _distance = ClampDistance(Mathf.Sqrt(rotationXPosY * rotationXPosY + num * num)); _lastGameY = rotationXPosY; } private static void FollowGameTilt(PlayerMovementController controller) { float rotationXPosY = controller.RotationXPosY; _pitch = ClampPitch(Mathf.Atan2(rotationXPosY, VanillaBackOffset(controller, rotationXPosY)) * 57.29578f); _lastGameY = rotationXPosY; } private static float VanillaBackOffset(PlayerMovementController controller, float y) { return Mathf.Sqrt(Mathf.Max(0f, 4f - y * y)) + Mathf.Max(0f, CurrentZoomRef.Invoke(controller)); } private static Cinemachine3rdPersonFollow FollowOf(PlayerMovementController controller) { CinemachineVirtualCamera val = VcamRef.Invoke(controller); if (!((Object)(object)val != (Object)null)) { return null; } return val.GetCinemachineComponent<Cinemachine3rdPersonFollow>(); } private static float ClampPitch(float pitch) { float value = Settings.MinPitch.Value; float num = Mathf.Max(value, Settings.MaxPitch.Value); return Mathf.Clamp(pitch, value, num); } private static float ClampDistance(float distance) { float value = Settings.MinDistance.Value; float num = Mathf.Max(value, Settings.MaxDistance.Value); return Mathf.Clamp(distance, value, num); } } [BepInPlugin("ontogether.cameraunlock", "CameraUnlock", "1.1.2")] [BepInProcess("OnTogether.exe")] public sealed class Plugin : BaseUnityPlugin { public const string PluginGuid = "ontogether.cameraunlock"; public const string PluginName = "CameraUnlock"; public const string PluginVersion = "1.1.2"; private const float ToastDuration = 2f; private const float FreeCamHintDuration = 7f; internal ConfigEntry<bool> OrbitEnabled; internal ConfigEntry<float> MinDistance; internal ConfigEntry<float> MaxDistance; internal ConfigEntry<float> MinPitch; internal ConfigEntry<float> MaxPitch; internal ConfigEntry<float> ZoomStep; internal ConfigEntry<float> PitchSensitivity; internal ConfigEntry<bool> CameraCollision; internal ConfigEntry<float> FieldOfView; internal ConfigEntry<bool> ShiftScrollFov; internal ConfigEntry<KeyboardShortcut> FreeCamToggleKey; internal ConfigEntry<float> FreeCamSpeed; internal ConfigEntry<float> FreeCamFastMultiplier; internal ConfigEntry<float> FreeCamSlowMultiplier; internal ConfigEntry<float> FreeCamLookSensitivity; internal ConfigEntry<bool> FreeCamInvertY; internal ConfigEntry<float> FreeCamSmoothing; internal ConfigEntry<bool> HideUiInFreeCam; internal ConfigEntry<KeyCode> FreeCamForward; internal ConfigEntry<KeyCode> FreeCamBack; internal ConfigEntry<KeyCode> FreeCamLeft; internal ConfigEntry<KeyCode> FreeCamRight; internal ConfigEntry<KeyCode> FreeCamUp; internal ConfigEntry<KeyCode> FreeCamDown; internal ConfigEntry<KeyCode> FreeCamFast; internal ConfigEntry<KeyCode> FreeCamSlow; internal ConfigEntry<KeyboardShortcut> HideUiKey; internal ConfigEntry<bool> HideWorldSpaceUi; internal ConfigEntry<bool> ShowHints; private Harmony _harmony; private readonly FreeCamera _freeCamera = new FreeCamera(); private readonly UiHider _uiHider = new UiHider(); private bool _uiHiddenByFreeCam; private readonly ColliderSwitch _collider = new ColliderSwitch(); private static string _toast; private static float _toastUntil; private float _hintUntil; private GUIStyle _hintStyle; private UiSkin _toastSkin; private static string _lastError; internal static Plugin Instance { get; private set; } internal static ManualLogSource Log { get; private set; } private void Awake() { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) Instance = this; Log = ((BaseUnityPlugin)this).Logger; BindConfig(); ConfigMenu.Create(((Component)this).gameObject, "CameraUnlock", "camera", ((BaseUnityPlugin)this).Config, () => (Object)(object)GameAccess.LocalPlayer != (Object)null && !_uiHider.IsHidden); _harmony = new Harmony("ontogether.cameraunlock"); UiEnvironment.InstallInputGuard(_harmony); TryPatch(typeof(SetCameraRotationPatch), "camera tilt"); TryPatch(typeof(ZoomPatch), "camera zoom"); TryPatch(typeof(InputManagerUpdatePatch), "input blocking for the free camera"); OrbitEnabled.SettingChanged += delegate { if (!OrbitEnabled.Value) { OrbitCamera.Disengage(); } }; Log.LogInfo((object)string.Format("{0} {1} loaded. Free camera: {2}, hide UI: {3}", "CameraUnlock", "1.1.2", FreeCamToggleKey.Value, HideUiKey.Value)); } private void BindConfig() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Expected O, but got Unknown //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Expected O, but got Unknown //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Expected O, but got Unknown //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Expected O, but got Unknown //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Expected O, but got Unknown //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Expected O, but got Unknown //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Expected O, but got Unknown //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Expected O, but got Unknown //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Expected O, but got Unknown //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Expected O, but got Unknown //IL_04ed: Unknown result type (might be due to invalid IL or missing references) OrbitEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Orbit", "Enabled", true, "Replace the game's short zoom and tilt range with a free orbit around your character (mouse wheel = distance, right mouse button = tilt). Off: the game's own camera."); MinDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Orbit", "MinDistance", 0.4f, new ConfigDescription("Closest camera distance in metres (the game: about 2.3).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>())); MaxDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Orbit", "MaxDistance", 40f, new ConfigDescription("Farthest camera distance in metres (the game: about 4.3).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(3f, 300f), Array.Empty<object>())); MinPitch = ((BaseUnityPlugin)this).Config.Bind<float>("Orbit", "MinPitch", -75f, new ConfigDescription("Lowest camera angle in degrees; negative looks up at your character from below.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-89f, 0f), Array.Empty<object>())); MaxPitch = ((BaseUnityPlugin)this).Config.Bind<float>("Orbit", "MaxPitch", 89f, new ConfigDescription("Highest camera angle in degrees; 89 is a straight top-down view.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 89f), Array.Empty<object>())); ZoomStep = ((BaseUnityPlugin)this).Config.Bind<float>("Orbit", "ZoomStepPercent", 12f, new ConfigDescription("How much one wheel notch changes the distance, in percent.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 50f), Array.Empty<object>())); PitchSensitivity = ((BaseUnityPlugin)this).Config.Bind<float>("Orbit", "TiltSensitivity", 1f, new ConfigDescription("Multiplier for vertical mouse movement (1 = like the game near the horizon).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>())); CameraCollision = ((BaseUnityPlugin)this).Config.Bind<bool>("Orbit", "CameraCollision", true, "Keep the camera in front of walls and the ground, as the game does. Turn off to see through walls."); FieldOfView = ((BaseUnityPlugin)this).Config.Bind<float>("Lens", "FieldOfView", 0f, new ConfigDescription("Vertical field of view of the normal camera in degrees; 0 = the game's default.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 120f), Array.Empty<object>())); ShiftScrollFov = ((BaseUnityPlugin)this).Config.Bind<bool>("Lens", "ShiftWheelChangesFov", true, "Shift + mouse wheel changes the field of view (both cameras); Shift + middle click resets it."); FreeCamToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("FreeCamera", "ToggleKey", new KeyboardShortcut((KeyCode)287, Array.Empty<KeyCode>()), "Turns the free camera on/off (ignored while typing). Your character stays in place."); FreeCamSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("FreeCamera", "Speed", 4f, new ConfigDescription("Flying speed in metres per second (the mouse wheel scales it while flying).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 100f), Array.Empty<object>())); FreeCamFastMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("FreeCamera", "FastMultiplier", 4f, new ConfigDescription("Speed multiplier while the Fast key is held.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 50f), Array.Empty<object>())); FreeCamSlowMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("FreeCamera", "SlowMultiplier", 0.25f, new ConfigDescription("Speed multiplier while the Slow key is held.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 1f), Array.Empty<object>())); FreeCamLookSensitivity = ((BaseUnityPlugin)this).Config.Bind<float>("FreeCamera", "LookSensitivity", 2f, new ConfigDescription("Mouse look sensitivity.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 20f), Array.Empty<object>())); FreeCamInvertY = ((BaseUnityPlugin)this).Config.Bind<bool>("FreeCamera", "InvertY", false, "Invert vertical mouse look."); FreeCamSmoothing = ((BaseUnityPlugin)this).Config.Bind<float>("FreeCamera", "Smoothing", 0f, new ConfigDescription("Smooth, cinematic movement: 0 = none, 0.9 = very smooth.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 0.98f), Array.Empty<object>())); HideUiInFreeCam = ((BaseUnityPlugin)this).Config.Bind<bool>("FreeCamera", "HideUiWhileFlying", false, "Hide the interface automatically while the free camera is on."); FreeCamForward = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("FreeCamera.Keys", "Forward", (KeyCode)119, "Fly forward."); FreeCamBack = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("FreeCamera.Keys", "Back", (KeyCode)115, "Fly back."); FreeCamLeft = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("FreeCamera.Keys", "Left", (KeyCode)97, "Fly left."); FreeCamRight = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("FreeCamera.Keys", "Right", (KeyCode)100, "Fly right."); FreeCamUp = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("FreeCamera.Keys", "Up", (KeyCode)101, "Fly straight up."); FreeCamDown = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("FreeCamera.Keys", "Down", (KeyCode)113, "Fly straight down."); FreeCamFast = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("FreeCamera.Keys", "Fast", (KeyCode)304, "Hold to fly faster."); FreeCamSlow = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("FreeCamera.Keys", "Slow", (KeyCode)306, "Hold to fly slower."); HideUiKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Screenshots", "HideUiKey", new KeyboardShortcut((KeyCode)288, Array.Empty<KeyCode>()), "Hides/shows the game's interface (ignored while typing)."); HideWorldSpaceUi = ((BaseUnityPlugin)this).Config.Bind<bool>("Screenshots", "HideWorldSpaceUi", false, "Also hide interface elements placed in the world (signs, screens and labels drawn with canvases)."); ShowHints = ((BaseUnityPlugin)this).Config.Bind<bool>("Screenshots", "ShowHints", true, "Show short on-screen hints (controls, field of view, speed). Never drawn while the interface is hidden."); } private void TryPatch(Type patch, string feature) { try { _harmony.CreateClassProcessor(patch).Patch(); } catch (Exception arg) { Log.LogError((object)$"Could not patch the game for {feature}; that part will not work: {arg}"); } } private void Update() { //IL_0015: 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) if (UiEnvironment.AnyWindowOpen || GameAccess.IsAnyTextFieldFocused()) { return; } ReadShortcuts(FreeCamToggleKey.Value, HideUiKey.Value, out var firstPressed, out var secondPressed); if (firstPressed) { ToggleFreeCamera(); } if (secondPressed) { if (_uiHider.IsHidden) { _uiHider.Show(); } else { _uiHider.Hide(); } _uiHiddenByFreeCam = false; } if (ShiftScrollFov.Value && Input.GetMouseButtonDown(2) && (Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303))) { if (FreeCamera.IsActive) { _freeCamera.ResetFov(); } else { Lens.Reset(); } } } private static void ReadShortcuts(KeyboardShortcut first, KeyboardShortcut second, out bool firstPressed, out bool secondPressed) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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) //IL_0021: Unknown result type (might be due to invalid IL or missing references) firstPressed = Pressed(first); secondPressed = Pressed(second); if (firstPressed && secondPressed && ((KeyboardShortcut)(ref first)).MainKey == ((KeyboardShortcut)(ref second)).MainKey) { int num = ((KeyboardShortcut)(ref first)).Modifiers.Count() - ((KeyboardShortcut)(ref second)).Modifiers.Count(); firstPressed = num >= 0; secondPressed = num <= 0; } } private static bool Pressed(KeyboardShortcut shortcut) { //IL_0002: 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) //IL_0008: 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_0025: Unknown result type (might be due to invalid IL or missing references) KeyCode mainKey = ((KeyboardShortcut)(ref shortcut)).MainKey; if ((int)mainKey == 0 || !Input.GetKeyDown(mainKey)) { return false; } foreach (KeyCode modifier in ((KeyboardShortcut)(ref shortcut)).Modifiers) { if (!Input.GetKey(modifier)) { return false; } } return true; } private void LateUpdate() { try { if (!_freeCamera.LateTick()) { OnFreeCameraEnded("Free camera: off (the camera changed)"); } Lens.Tick(OrbitCamera.Vcam); _collider.Apply(OrbitCamera.Vcam, CameraCollision.Value); _uiHider.Tick(); } catch (Exception e) { LogOnce(e); } } internal static void LogOnce(Exception e) { string text = e.GetType().Name + ": " + e.Message; if (!(text == _lastError)) { _lastError = text; Log.LogError((object)e); } } private void ToggleFreeCamera() { if (FreeCamera.IsActive) { _freeCamera.Exit(); OnFreeCameraEnded("Free camera: off"); return; } if (!_freeCamera.TryEnter(out var error)) { Toast("Free camera: " + error); return; } if (HideUiInFreeCam.Value && !_uiHider.IsHidden) { _uiHider.Hide(); _uiHiddenByFreeCam = true; } _hintUntil = Time.unscaledTime + 7f; _toastUntil = 0f; } private void OnFreeCameraEnded(string message) { if (_uiHiddenByFreeCam) { _uiHider.Show(); } _uiHiddenByFreeCam = false; _hintUntil = 0f; Toast(message); } internal static void Toast(string message) { _toast = message; _toastUntil = Time.unscaledTime + 2f; } private string FreeCamHint() { //IL_0013: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0077: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) return $"Free camera — {FreeCamForward.Value}/{FreeCamLeft.Value}/{FreeCamBack.Value}/{FreeCamRight.Value} fly, " + $"{FreeCamUp.Value}/{FreeCamDown.Value} up/down, hold right mouse to look, " + $"{FreeCamFast.Value} fast, {FreeCamSlow.Value} slow, wheel = speed, Shift + wheel = zoom (FOV), " + $"{HideUiKey.Value} hide UI, {FreeCamToggleKey.Value} back to the character"; } private void OnGUI() { //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Expected O, but got Unknown //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Expected O, but got Unknown //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) if (UiEnvironment.PreviewRendering || !ShowHints.Value || _uiHider.IsHidden) { return; } float unscaledTime = Time.unscaledTime; string text = ((unscaledTime < _toastUntil) ? _toast : ((unscaledTime < _hintUntil) ? FreeCamHint() : null)); if (!string.IsNullOrEmpty(text)) { if (_hintStyle == null) { _toastSkin = new UiSkin(); _hintStyle = new GUIStyle(_toastSkin.Panel) { alignment = (TextAnchor)4, wordWrap = true, richText = false }; _hintStyle.normal.textColor = UiSkin.TextColor; } float num = Mathf.Max(1f, (float)Screen.height / 1080f); _hintStyle.fontSize = Mathf.RoundToInt(16f * num); _hintStyle.padding = new RectOffset(Mathf.RoundToInt(12f * num), Mathf.RoundToInt(12f * num), Mathf.RoundToInt(8f * num), Mathf.RoundToInt(8f * num)); float num2 = Mathf.Min((float)Screen.width - 32f, 900f * num); float num3 = _hintStyle.CalcHeight(new GUIContent(text), num2); GUI.Box(new Rect(((float)Screen.width - num2) / 2f, 24f * num, num2, num3), text, _hintStyle); } } private void OnDestroy() { _toastSkin?.Destroy(); try { _freeCamera.Exit(); _uiHider.Show(); OrbitCamera.Disengage(); Lens.Restore(); _collider.Restore(); } catch (Exception ex) { Log.LogDebug((object)("Cleanup skipped: " + ex.Message)); } if (_harmony != null) { _harmony.UnpatchSelf(); } } } internal sealed class ColliderSwitch { private CinemachineCollider _collider; private bool _gameEnabled; public void Apply(CinemachineVirtualCamera vcam, bool enabled) { if ((Object)(object)vcam == (Object)null) { return; } if ((Object)(object)_collider == (Object)null || (Object)(object)((Component)_collider).gameObject != (Object)(object)((Component)vcam).gameObject) { _collider = ((Component)vcam).GetComponent<CinemachineCollider>(); if ((Object)(object)_collider == (Object)null) { return; } _gameEnabled = ((Behaviour)_collider).enabled; } bool flag = enabled && _gameEnabled; if (((Behaviour)_collider).enabled != flag) { ((Behaviour)_collider).enabled = flag; } } public void Restore() { if ((Object)(object)_collider != (Object)null) { ((Behaviour)_collider).enabled = _gameEnabled; } } } [HarmonyPatch(typeof(PlayerMovementController), "SetCameraRotation")] internal static class SetCameraRotationPatch { private static void Prefix(PlayerMovementController __instance, Vector2 mouseDelta) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) try { OrbitCamera.BeforeRotation(__instance, mouseDelta); } catch (Exception e) { Plugin.LogOnce(e); } } private static void Postfix(PlayerMovementController __instance) { try { OrbitCamera.Apply(__instance); } catch (Exception e) { Plugin.LogOnce(e); } } } [HarmonyPatch(typeof(PlayerMovementController), "Zoom")] internal static class ZoomPatch { private static bool Prefix(PlayerMovementController __instance) { if (FreeCamera.IsActive) { return false; } try { OrbitCamera.OnZoom(__instance); } catch (Exception e) { Plugin.LogOnce(e); } return true; } private static void Postfix(PlayerMovementController __instance) { try { OrbitCamera.Apply(__instance); } catch (Exception e) { Plugin.LogOnce(e); } } } [HarmonyPatch(typeof(InputManager), "Update")] internal static class InputManagerUpdatePatch { private static void Postfix(InputManager __instance) { try { InputBlocker.AfterInputUpdate(__instance); } catch (Exception e) { Plugin.LogOnce(e); } } } internal static class UiEnvironment { internal const string DockName = "LightShaper.ModDock.v1"; internal const string WindowName = "LightShaper.ModWindows.v1"; private static GameObject _windows; private static Font _font; private static float _fontRetry; private static CanvasScaler _gameScaler; private static float _scaleRetry; private static readonly FieldInfo[] Inputs = (from f in typeof(InputManager).GetFields(BindingFlags.Instance | BindingFlags.NonPublic) where f.Name.StartsWith("<") && f.Name.EndsWith(">