using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using CameraUnlock.Core.Aim; using CameraUnlock.Core.Data; using CameraUnlock.Core.Input; using CameraUnlock.Core.Math; using CameraUnlock.Core.Processing; using CameraUnlock.Core.Unity.Extensions; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("CameraUnlock Mods")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Unity-specific extensions for CameraUnlock head tracking mods")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1+a3d52bd5a721ee09791549291eb39372d89796c7")] [assembly: AssemblyProduct("CameraUnlock.Core.Unity")] [assembly: AssemblyTitle("CameraUnlock.Core.Unity")] [assembly: AssemblyVersion("1.0.1.0")] namespace CameraUnlock.Core.Unity.Utilities { public static class CrosshairUtility { public static List FindCrosshairCandidates(bool searchInactive = true) { List list = new List(); Image[] array = (searchInactive ? Resources.FindObjectsOfTypeAll() : Object.FindObjectsOfType()); foreach (Image val in array) { if (!((Object)(object)val == (Object)null)) { string text = ((Object)val).name.ToLowerInvariant(); string text2 = ((Object)((Component)val).gameObject).name.ToLowerInvariant(); if (text.Contains("crosshair") || text.Contains("reticle") || text.Contains("reticule") || text.Contains("aim") || text2.Contains("crosshair") || text2.Contains("reticle") || text2.Contains("reticule")) { list.Add(val); } } } return list; } public static List FindRawImageCrosshairCandidates(bool searchInactive = true) { List list = new List(); RawImage[] array = (searchInactive ? Resources.FindObjectsOfTypeAll() : Object.FindObjectsOfType()); foreach (RawImage val in array) { if (!((Object)(object)val == (Object)null)) { string text = ((Object)val).name.ToLowerInvariant(); string text2 = ((Object)((Component)val).gameObject).name.ToLowerInvariant(); if (text.Contains("crosshair") || text.Contains("reticle") || text.Contains("reticule") || text.Contains("aim") || text2.Contains("crosshair") || text2.Contains("reticle") || text2.Contains("reticule")) { list.Add(val); } } } return list; } public static Type FindTypeByName(string typeName) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { try { Type type = assembly.GetType(typeName); if (type != null) { return type; } } catch (ReflectionTypeLoadException) { } catch (FileNotFoundException) { } } return null; } public static void OffsetByScreenPixels(RectTransform rectTransform, Vector2 screenOffset) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_0025: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)rectTransform == (Object)null)) { Vector3 lossyScale = ((Transform)rectTransform).lossyScale; float num = ((lossyScale.x > 0.001f) ? lossyScale.x : 1f); float num2 = ((lossyScale.y > 0.001f) ? lossyScale.y : 1f); rectTransform.anchoredPosition = new Vector2(screenOffset.x / num, screenOffset.y / num2); } } public static bool HideGraphic(Graphic graphic) { if ((Object)(object)graphic == (Object)null || (Object)(object)((Component)graphic).gameObject == (Object)null) { return false; } bool activeSelf = ((Component)graphic).gameObject.activeSelf; ((Component)graphic).gameObject.SetActive(false); return activeSelf; } public static void ShowGraphic(Graphic graphic, bool active = true) { if (!((Object)(object)graphic == (Object)null) && !((Object)(object)((Component)graphic).gameObject == (Object)null)) { ((Component)graphic).gameObject.SetActive(active); } } public static float GetCanvasScaleFactor(Graphic graphic) { if ((Object)(object)graphic == (Object)null) { return 1f; } Canvas componentInParent = ((Component)graphic).GetComponentInParent(); if (!((Object)(object)componentInParent != (Object)null)) { return 1f; } return componentInParent.scaleFactor; } } public static class GameUIFinder { public static readonly string[] CommonReticleNames = new string[15] { "Reticle", "reticle", "CrossHair", "Crosshair", "crosshair", "Cursor", "cursor", "AimIndicator", "CenterDot", "HUD_Reticle", "UIReticle", "InteractionCursor", "LookCursor", "Dot", "dot" }; public static readonly string[] ReticleKeywords = new string[5] { "reticle", "crosshair", "aimpoint", "centerdot", "cursor" }; public static GameObject FindByNames(params string[] names) { if (names == null) { return null; } foreach (string text in names) { if (!string.IsNullOrEmpty(text)) { GameObject val = GameObject.Find(text); if ((Object)(object)val != (Object)null) { return val; } } } return null; } public static GameObject FindByKeywords(params string[] keywords) { if (keywords == null || keywords.Length == 0) { return null; } GameObject[] array = Object.FindObjectsOfType(); foreach (GameObject val in array) { if ((Object)(object)val == (Object)null) { continue; } string text = ((Object)val).name.ToLowerInvariant(); foreach (string text2 in keywords) { if (!string.IsNullOrEmpty(text2) && text.Contains(text2.ToLowerInvariant())) { return val; } } } return null; } public static GameObject FindInCanvas(params string[] keywords) { if (keywords == null || keywords.Length == 0) { return null; } Type type = Type.GetType("UnityEngine.Canvas, UnityEngine") ?? Type.GetType("UnityEngine.Canvas, UnityEngine.UIModule"); if (type == null) { return null; } Object[] array = Object.FindObjectsOfType(type); foreach (Object obj in array) { Component val = (Component)(object)((obj is Component) ? obj : null); if ((Object)(object)val == (Object)null) { continue; } Transform[] componentsInChildren = val.GetComponentsInChildren(true); foreach (Transform val2 in componentsInChildren) { if ((Object)(object)val2 == (Object)null) { continue; } string text = ((Object)val2).name.ToLowerInvariant(); foreach (string text2 in keywords) { if (!string.IsNullOrEmpty(text2) && text.Contains(text2.ToLowerInvariant())) { return ((Component)val2).gameObject; } } } } return null; } public static GameObject FindReticle(string[] customNames = null) { if (customNames != null && customNames.Length != 0) { GameObject val = FindByNames(customNames); if ((Object)(object)val != (Object)null) { return val; } } GameObject val2 = FindByNames(CommonReticleNames); if ((Object)(object)val2 != (Object)null) { return val2; } val2 = FindByKeywords(ReticleKeywords); if ((Object)(object)val2 != (Object)null) { return val2; } return FindInCanvas(ReticleKeywords); } public static RectTransform GetRectTransform(GameObject gameObject) { if ((Object)(object)gameObject == (Object)null) { return null; } return gameObject.GetComponent(); } public static GameObject FindByPath(string rootName, string path) { if (string.IsNullOrEmpty(rootName) && string.IsNullOrEmpty(path)) { return null; } GameObject val = null; if (!string.IsNullOrEmpty(rootName)) { val = GameObject.Find(rootName); if ((Object)(object)val == (Object)null) { return null; } } if (string.IsNullOrEmpty(path)) { return val; } if ((Object)(object)val == (Object)null) { return GameObject.Find(path); } Transform val2 = val.transform; string[] array = path.Split(new char[1] { '/' }); foreach (string text in array) { if (!string.IsNullOrEmpty(text)) { Transform val3 = val2.Find(text); if ((Object)(object)val3 == (Object)null) { return null; } val2 = val3; } } return ((Component)val2).gameObject; } } public sealed class PerFrameCache { private T _cachedValue; private int _cachedFrameCount; private readonly Func _fetcher; private bool _hasValue; public T Value => Get(); public bool HasValue => _hasValue; public PerFrameCache(Func fetcher) { _fetcher = fetcher; _cachedFrameCount = -1; } public PerFrameCache() { _fetcher = null; _cachedFrameCount = -1; } public T Get() { int frameCount = Time.frameCount; if (_cachedFrameCount != frameCount) { _cachedValue = _fetcher(); _cachedFrameCount = frameCount; _hasValue = true; } return _cachedValue; } public T Get(Func fetcher) { int frameCount = Time.frameCount; if (_cachedFrameCount != frameCount) { _cachedValue = fetcher(); _cachedFrameCount = frameCount; _hasValue = true; } return _cachedValue; } public void Invalidate() { _cachedFrameCount = -1; _hasValue = false; } public void Set(T value) { _cachedValue = value; _cachedFrameCount = Time.frameCount; _hasValue = true; } } public static class SingletonChecker { private const BindingFlags StaticFieldFlags = BindingFlags.Static | BindingFlags.Public; private const BindingFlags InstanceFieldFlags = BindingFlags.Instance | BindingFlags.Public; public static bool Exists(string typeName, string fieldName = "main", string assemblyName = "Assembly-CSharp") { if (string.IsNullOrEmpty(typeName)) { throw new ArgumentException("Type name cannot be null or empty", "typeName"); } Type type = ResolveType(typeName, assemblyName); if (type == null) { return false; } FieldInfo field = type.GetField(fieldName, BindingFlags.Static | BindingFlags.Public); if (field == null) { return false; } object value = field.GetValue(null); if (value == null) { return false; } Object val = (Object)((value is Object) ? value : null); if (val != null) { return val != (Object)null; } return true; } public static T GetValue(string typeName, string fieldName = "main", string assemblyName = "Assembly-CSharp") where T : class { if (string.IsNullOrEmpty(typeName)) { throw new ArgumentException("Type name cannot be null or empty", "typeName"); } Type type = ResolveType(typeName, assemblyName); if (type == null) { throw new InvalidOperationException("Type '" + typeName + "' not found in assembly '" + assemblyName + "'"); } FieldInfo field = type.GetField(fieldName, BindingFlags.Static | BindingFlags.Public); if (field == null) { throw new InvalidOperationException("Static field '" + fieldName + "' not found on type '" + typeName + "'"); } return field.GetValue(null) as T; } public static bool TryGetValue(string typeName, string fieldName, out T value, string assemblyName = "Assembly-CSharp") where T : class { value = null; if (string.IsNullOrEmpty(typeName)) { return false; } Type type = ResolveType(typeName, assemblyName); if (type == null) { return false; } FieldInfo field = type.GetField(fieldName, BindingFlags.Static | BindingFlags.Public); if (field == null) { return false; } object value2 = field.GetValue(null); if (value2 == null) { return false; } Object val = (Object)((value2 is Object) ? value2 : null); if (val != null && val == (Object)null) { return false; } value = value2 as T; return value != null; } public static T GetInstanceField(string singletonTypeName, string singletonFieldName, string instanceFieldName, string assemblyName = "Assembly-CSharp") { if (string.IsNullOrEmpty(singletonTypeName)) { throw new ArgumentException("Singleton type name cannot be null or empty", "singletonTypeName"); } if (string.IsNullOrEmpty(instanceFieldName)) { throw new ArgumentException("Instance field name cannot be null or empty", "instanceFieldName"); } Type type = ResolveType(singletonTypeName, assemblyName); if (type == null) { throw new InvalidOperationException("Type '" + singletonTypeName + "' not found"); } FieldInfo field = type.GetField(singletonFieldName, BindingFlags.Static | BindingFlags.Public); if (field == null) { throw new InvalidOperationException("Static field '" + singletonFieldName + "' not found on type '" + singletonTypeName + "'"); } object value = field.GetValue(null); if (value == null) { throw new InvalidOperationException("Singleton '" + singletonTypeName + "." + singletonFieldName + "' is null"); } Object val = (Object)((value is Object) ? value : null); if (val != null && val == (Object)null) { throw new InvalidOperationException("Singleton '" + singletonTypeName + "." + singletonFieldName + "' is destroyed"); } FieldInfo field2 = type.GetField(instanceFieldName, BindingFlags.Instance | BindingFlags.Public); if (field2 == null) { throw new InvalidOperationException("Instance field '" + instanceFieldName + "' not found on type '" + singletonTypeName + "'"); } object value2 = field2.GetValue(value); if (value2 is T) { return (T)value2; } return default(T); } public static bool TryGetInstanceField(string singletonTypeName, string singletonFieldName, string instanceFieldName, out T value, string assemblyName = "Assembly-CSharp") { value = default(T); if (string.IsNullOrEmpty(singletonTypeName) || string.IsNullOrEmpty(instanceFieldName)) { return false; } Type type = ResolveType(singletonTypeName, assemblyName); if (type == null) { return false; } FieldInfo field = type.GetField(singletonFieldName, BindingFlags.Static | BindingFlags.Public); if (field == null) { return false; } object value2 = field.GetValue(null); if (value2 == null) { return false; } Object val = (Object)((value2 is Object) ? value2 : null); if (val != null && val == (Object)null) { return false; } FieldInfo field2 = type.GetField(instanceFieldName, BindingFlags.Instance | BindingFlags.Public); if (field2 == null) { return false; } if (field2.GetValue(value2) is T val2) { value = val2; return true; } return false; } public static bool IsActiveInHierarchy(string typeName, string fieldName = "main", string assemblyName = "Assembly-CSharp") { if (!TryGetValue(typeName, fieldName, out var value, assemblyName)) { return false; } if ((Object)(object)value != (Object)null) { return value.gameObject.activeInHierarchy; } return false; } private static Type ResolveType(string typeName, string assemblyName) { Type type = Type.GetType(typeName + ", " + assemblyName); if (type != null) { return type; } type = Type.GetType(typeName); if (type != null) { return type; } Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { type = assemblies[i].GetType(typeName); if (type != null) { return type; } } return null; } } } namespace CameraUnlock.Core.Unity.UI { public enum NotificationType { Info, Success, Warning, Error } public class NotificationUI { private const float DefaultDisplayDuration = 2f; private const float FadeDuration = 0.5f; private const int FontSize = 24; private const int ShadowOffset = 2; private const float VerticalPosition = 100f; private string _currentMessage; private float _displayTimer; private NotificationType _currentType; private GUIStyle _textStyle; private GUIStyle _shadowStyle; private bool _stylesInitialized; private static readonly Color InfoColor = Color.white; private static readonly Color SuccessColor = new Color(0.4f, 1f, 0.4f); private static readonly Color WarningColor = new Color(1f, 0.9f, 0.3f); private static readonly Color ErrorColor = new Color(1f, 0.4f, 0.4f); public bool IsDisplaying { get { if (_displayTimer > 0f) { return !string.IsNullOrEmpty(_currentMessage); } return false; } } public void ShowNotification(string message) { ShowNotification(message, NotificationType.Info, 2f); } public void ShowNotification(string message, float duration) { ShowNotification(message, NotificationType.Info, duration); } public void ShowNotification(string message, NotificationType type) { ShowNotification(message, type, 2f); } public void ShowNotification(string message, NotificationType type, float duration) { _currentMessage = message; _currentType = type; _displayTimer = duration + 0.5f; } public void ShowTrackingEnabled() { ShowNotification("Head Tracking: ON", NotificationType.Success); } public void ShowTrackingDisabled() { ShowNotification("Head Tracking: OFF", NotificationType.Warning); } public void ShowRecentered() { ShowNotification("Head Tracking: Recentered", NotificationType.Info); } public void ShowConnectionEstablished() { ShowNotification("OpenTrack: Connected", NotificationType.Success); } public void ShowConnectionLost() { ShowNotification("OpenTrack: No Signal", NotificationType.Warning); } public void Update() { if (_displayTimer > 0f) { _displayTimer -= Time.deltaTime; } } public void Draw() { //IL_0047: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0105: 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_0112: Unknown result type (might be due to invalid IL or missing references) if (!(_displayTimer <= 0f) && !string.IsNullOrEmpty(_currentMessage)) { EnsureStyles(); float num = 1f; if (_displayTimer < 0.5f) { num = _displayTimer / 0.5f; } Color colorForType = GetColorForType(_currentType); GUIContent val = new GUIContent(_currentMessage); Vector2 val2 = _textStyle.CalcSize(val); float num2 = ((float)Screen.width - val2.x) / 2f; float num3 = 100f; Rect val3 = new Rect(num2, num3, val2.x, val2.y); Rect val4 = new Rect(num2 + 2f, num3 + 2f, val2.x, val2.y); _shadowStyle.normal.textColor = new Color(0f, 0f, 0f, num * 0.8f); GUI.Label(val4, _currentMessage, _shadowStyle); _textStyle.normal.textColor = new Color(colorForType.r, colorForType.g, colorForType.b, num); GUI.Label(val3, _currentMessage, _textStyle); } } private static Color GetColorForType(NotificationType type) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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) return (Color)(type switch { NotificationType.Success => SuccessColor, NotificationType.Warning => WarningColor, NotificationType.Error => ErrorColor, _ => InfoColor, }); } private void EnsureStyles() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) if (!_stylesInitialized) { _textStyle = new GUIStyle(GUI.skin.label) { fontSize = 24, fontStyle = (FontStyle)1, alignment = (TextAnchor)4 }; _textStyle.normal.textColor = Color.white; _shadowStyle = new GUIStyle(_textStyle); _shadowStyle.normal.textColor = Color.black; _stylesInitialized = true; } } } public class StatusIndicatorUI { private const int FontSize = 14; private const int Padding = 10; private const int ShadowOffset = 1; private const float BackgroundAlpha = 0.4f; private GUIStyle _textStyle; private GUIStyle _shadowStyle; private GUIStyle _backgroundStyle; private Texture2D _backgroundTexture; private bool _stylesInitialized; private bool _enabled = true; private StatusPosition _position = StatusPosition.BottomRight; private bool _trackingEnabled; private bool _isReceiving; private bool _cachedTrackingEnabled; private bool _cachedIsReceiving; private string _statusText; private string _trackingStatus; private string _connectionStatus; private float _width; private float _height; private float _textWidth; private float _textHeight; private float _offset1; private float _offset2; private float _offset3; private float _offset4; private bool _layoutDirty = true; private const string PrefixHT = "[HT:"; private const string PrefixOT = "] [OT:"; private const string Suffix = "]"; private const string StatusOn = "ON"; private const string StatusOff = "OFF"; private const string ConnOk = "OK"; private const string ConnNone = "--"; private static readonly Color EnabledColor = new Color(0.4f, 1f, 0.4f); private static readonly Color DisabledColor = new Color(0.6f, 0.6f, 0.6f); private static readonly Color ConnectedColor = new Color(0.4f, 1f, 0.4f); private static readonly Color DisconnectedColor = new Color(1f, 0.5f, 0.3f); public bool Enabled { get { return _enabled; } set { _enabled = value; } } public StatusPosition Position { get { return _position; } set { if (_position != value) { _position = value; _layoutDirty = true; } } } public void UpdateState(bool trackingEnabled, bool isReceiving) { _trackingEnabled = trackingEnabled; _isReceiving = isReceiving; if (_trackingEnabled != _cachedTrackingEnabled || _isReceiving != _cachedIsReceiving) { _layoutDirty = true; } } public void Draw() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) if (_enabled) { EnsureStyles(); if (_layoutDirty) { RecalculateLayout(); } Rect val = CalculatePosition(_width, _height); Rect rect = default(Rect); ((Rect)(ref rect))..ctor(((Rect)(ref val)).x + 10f, ((Rect)(ref val)).y + 5f, _textWidth, _textHeight); Rect val2 = new Rect(((Rect)(ref rect)).x + 1f, ((Rect)(ref rect)).y + 1f, _textWidth, _textHeight); GUI.Box(val, GUIContent.none, _backgroundStyle); _shadowStyle.normal.textColor = new Color(0f, 0f, 0f, 0.6f); GUI.Label(val2, _statusText, _shadowStyle); DrawColoredStatus(rect); } } public void Dispose() { if ((Object)(object)_backgroundTexture != (Object)null) { Object.Destroy((Object)(object)_backgroundTexture); _backgroundTexture = null; } } private void RecalculateLayout() { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown //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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Expected O, but got Unknown //IL_0150: Unknown result type (might be due to invalid IL or missing references) _trackingStatus = (_trackingEnabled ? "ON" : "OFF"); _connectionStatus = (_isReceiving ? "OK" : "--"); _statusText = string.Format("{0}{1}{2}{3}{4}", "[HT:", _trackingStatus, "] [OT:", _connectionStatus, "]"); GUIContent val = new GUIContent(_statusText); Vector2 val2 = _textStyle.CalcSize(val); _textWidth = val2.x; _textHeight = val2.y; _width = _textWidth + 20f; _height = _textHeight + 10f; _offset1 = _textStyle.CalcSize(new GUIContent("[HT:")).x; _offset2 = _offset1 + _textStyle.CalcSize(new GUIContent(_trackingStatus)).x; _offset3 = _offset2 + _textStyle.CalcSize(new GUIContent("] [OT:")).x; _offset4 = _offset3 + _textStyle.CalcSize(new GUIContent(_connectionStatus)).x; _cachedTrackingEnabled = _trackingEnabled; _cachedIsReceiving = _isReceiving; _layoutDirty = false; } private void DrawColoredStatus(Rect rect) { //IL_000f: 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_0014: 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_001d: 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) //IL_0035: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) Color textColor = (_trackingEnabled ? EnabledColor : DisabledColor); Color textColor2 = (_isReceiving ? ConnectedColor : DisconnectedColor); _textStyle.normal.textColor = Color.white; GUI.Label(rect, "[HT:", _textStyle); Rect val = new Rect(((Rect)(ref rect)).x + _offset1, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width - _offset1, ((Rect)(ref rect)).height); _textStyle.normal.textColor = textColor; GUI.Label(val, _trackingStatus, _textStyle); Rect val2 = new Rect(((Rect)(ref rect)).x + _offset2, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width - _offset2, ((Rect)(ref rect)).height); _textStyle.normal.textColor = Color.white; GUI.Label(val2, "] [OT:", _textStyle); Rect val3 = new Rect(((Rect)(ref rect)).x + _offset3, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width - _offset3, ((Rect)(ref rect)).height); _textStyle.normal.textColor = textColor2; GUI.Label(val3, _connectionStatus, _textStyle); Rect val4 = new Rect(((Rect)(ref rect)).x + _offset4, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width - _offset4, ((Rect)(ref rect)).height); _textStyle.normal.textColor = Color.white; GUI.Label(val4, "]", _textStyle); } private Rect CalculatePosition(float width, float height) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) float num; float num2; switch (_position) { case StatusPosition.TopLeft: num = 10f; num2 = 10f; break; case StatusPosition.TopRight: num = (float)Screen.width - width - 10f; num2 = 10f; break; case StatusPosition.BottomLeft: num = 10f; num2 = (float)Screen.height - height - 10f; break; default: num = (float)Screen.width - width - 10f; num2 = (float)Screen.height - height - 10f; break; } return new Rect(num, num2, width, height); } private void EnsureStyles() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) if (!_stylesInitialized) { _textStyle = new GUIStyle(GUI.skin.label) { fontSize = 14, fontStyle = (FontStyle)1, alignment = (TextAnchor)3 }; _textStyle.normal.textColor = Color.white; _shadowStyle = new GUIStyle(_textStyle); _shadowStyle.normal.textColor = Color.black; _backgroundStyle = new GUIStyle(GUI.skin.box); _backgroundTexture = new Texture2D(1, 1); _backgroundTexture.SetPixel(0, 0, new Color(0f, 0f, 0f, 0.4f)); _backgroundTexture.Apply(); _backgroundStyle.normal.background = _backgroundTexture; _stylesInitialized = true; _layoutDirty = true; } } } public enum StatusPosition { TopLeft, TopRight, BottomLeft, BottomRight } public abstract class UIElementOffsetController : MonoBehaviour { private bool _targetAcquired; private bool _originalStateCaptured; private bool _wasDecoupled; public bool EnableLogging { get; set; } public Action Log { get; set; } public Func IsDecouplingActive { get; set; } public Func GetScreenOffset { get; set; } public Func GetCanvasScaleFactor { get; set; } protected virtual void Start() { _targetAcquired = false; _originalStateCaptured = false; _wasDecoupled = false; LogMessage(((object)this).GetType().Name + " initialized"); } protected virtual void LateUpdate() { if (EnsureTarget()) { bool flag = IsDecouplingActive != null && IsDecouplingActive(); if (flag) { ApplyCurrentOffset(); } else if (_wasDecoupled) { RestoreOriginalState(); } _wasDecoupled = flag; } } protected virtual void OnDestroy() { if (_originalStateCaptured) { RestoreOriginalState(); } } private bool EnsureTarget() { if (!_targetAcquired) { if (!TryAcquireTarget()) { return false; } _targetAcquired = true; LogMessage("Target acquired"); } if (!_originalStateCaptured) { CaptureOriginalState(); _originalStateCaptured = true; LogMessage("Original state captured"); } return true; } private void ApplyCurrentOffset() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (GetScreenOffset == null) { return; } Vector2 val = GetScreenOffset(); if (GetCanvasScaleFactor != null) { float num = GetCanvasScaleFactor(); if (num > 0f) { val /= num; } } ApplyOffset(val); } public void ResetReferences() { if (_originalStateCaptured) { RestoreOriginalState(); } ClearReferences(); _targetAcquired = false; _originalStateCaptured = false; _wasDecoupled = false; LogMessage("References reset"); } protected void LogMessage(string message) { if (EnableLogging && Log != null) { Log("[" + ((object)this).GetType().Name + "] " + message); } } protected abstract bool TryAcquireTarget(); protected abstract void CaptureOriginalState(); protected abstract void ApplyOffset(Vector2 offset); protected abstract void RestoreOriginalState(); protected abstract void ClearReferences(); } } namespace CameraUnlock.Core.Unity.Tracking { public class BaseRotationTracker { private Quaternion _baseRotation = Quaternion.identity; private Quaternion _headTrackingRotation = Quaternion.identity; private Transform _trackedTransform; private bool _hasValidData; public Quaternion BaseRotation => _baseRotation; public Quaternion HeadTrackingRotation => _headTrackingRotation; public Quaternion CombinedRotation => _baseRotation * _headTrackingRotation; public Vector3 BaseForward => _baseRotation * Vector3.forward; public Vector3 CombinedForward => CombinedRotation * Vector3.forward; public bool HasValidData => _hasValidData; public Transform TrackedTransform => _trackedTransform; public void Update(Transform cameraTransform, Quaternion gameWantedRotation, Quaternion headTrackingRotation) { //IL_0008: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) _trackedTransform = cameraTransform; _headTrackingRotation = headTrackingRotation; if ((Object)(object)cameraTransform != (Object)null && (Object)(object)cameraTransform.parent != (Object)null) { _baseRotation = cameraTransform.parent.rotation * gameWantedRotation; } else { _baseRotation = gameWantedRotation; } _hasValidData = true; } public void UpdateBaseOnly(Transform cameraTransform, Quaternion gameWantedRotation) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) Update(cameraTransform, gameWantedRotation, Quaternion.identity); } public Quaternion GetBaseLocalRotation() { //IL_000f: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_trackedTransform == (Object)null) { return _baseRotation; } if ((Object)(object)_trackedTransform.parent != (Object)null) { return Quaternion.Inverse(_trackedTransform.parent.rotation) * _baseRotation; } return _baseRotation; } public Quaternion GetCombinedLocalRotation() { //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_0015: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_0040: Unknown result type (might be due to invalid IL or missing references) Quaternion combinedRotation = CombinedRotation; if ((Object)(object)_trackedTransform == (Object)null) { return combinedRotation; } if ((Object)(object)_trackedTransform.parent != (Object)null) { return Quaternion.Inverse(_trackedTransform.parent.rotation) * combinedRotation; } return combinedRotation; } public Vector3 ProjectBaseForwardToScreen(Camera camera, float distance = 100f) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)camera == (Object)null || !_hasValidData) { return new Vector3((float)Screen.width * 0.5f, (float)Screen.height * 0.5f, 0f); } Vector3 val = ((Component)camera).transform.position + BaseForward * distance; return camera.WorldToScreenPoint(val); } public float GetAimViewAngle() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (!_hasValidData) { return 0f; } return Vector3.Angle(BaseForward, CombinedForward); } public void Reset() { //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_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) _baseRotation = Quaternion.identity; _headTrackingRotation = Quaternion.identity; _trackedTransform = null; _hasValidData = false; } } public sealed class CameraCallbackLifecycle : IDisposable { private static CameraCallback _staticPreCullCallback; private static CameraCallback _staticPreRenderCallback; private static Action _staticWillRenderCanvasesCallback; private bool _ownsPreCull; private bool _ownsPreRender; private bool _ownsWillRenderCanvases; private bool _disposed; public bool HasPreCull { get { if (_ownsPreCull) { return !_disposed; } return false; } } public bool HasPreRender { get { if (_ownsPreRender) { return !_disposed; } return false; } } public bool HasWillRenderCanvases { get { if (_ownsWillRenderCanvases) { return !_disposed; } return false; } } public bool IsDisposed => _disposed; public void RegisterPreCull(CameraCallback callback) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown if (_disposed) { throw new ObjectDisposedException("CameraCallbackLifecycle"); } if (callback == null) { throw new ArgumentNullException("callback"); } if (_staticPreCullCallback != null) { throw new InvalidOperationException("A preCull callback is already registered. Call UnregisterPreCull first or Dispose the previous lifecycle."); } _staticPreCullCallback = callback; Camera.onPreCull = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPreCull, (Delegate?)(object)_staticPreCullCallback); _ownsPreCull = true; } public void UnregisterPreCull() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown if (_ownsPreCull && _staticPreCullCallback != null) { Camera.onPreCull = (CameraCallback)Delegate.Remove((Delegate?)(object)Camera.onPreCull, (Delegate?)(object)_staticPreCullCallback); _staticPreCullCallback = null; _ownsPreCull = false; } } public void RegisterPreRender(CameraCallback callback) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown if (_disposed) { throw new ObjectDisposedException("CameraCallbackLifecycle"); } if (callback == null) { throw new ArgumentNullException("callback"); } if (_staticPreRenderCallback != null) { throw new InvalidOperationException("A preRender callback is already registered. Call UnregisterPreRender first or Dispose the previous lifecycle."); } _staticPreRenderCallback = callback; Camera.onPreRender = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPreRender, (Delegate?)(object)_staticPreRenderCallback); _ownsPreRender = true; } public void UnregisterPreRender() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown if (_ownsPreRender && _staticPreRenderCallback != null) { Camera.onPreRender = (CameraCallback)Delegate.Remove((Delegate?)(object)Camera.onPreRender, (Delegate?)(object)_staticPreRenderCallback); _staticPreRenderCallback = null; _ownsPreRender = false; } } public void RegisterWillRenderCanvases(Action callback) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown if (_disposed) { throw new ObjectDisposedException("CameraCallbackLifecycle"); } if (callback == null) { throw new ArgumentNullException("callback"); } if (_staticWillRenderCanvasesCallback != null) { throw new InvalidOperationException("A willRenderCanvases callback is already registered. Call UnregisterWillRenderCanvases first or Dispose the previous lifecycle."); } _staticWillRenderCanvasesCallback = callback; Canvas.willRenderCanvases += new WillRenderCanvases(OnWillRenderCanvasesWrapper); _ownsWillRenderCanvases = true; } public void UnregisterWillRenderCanvases() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown if (_ownsWillRenderCanvases && _staticWillRenderCanvasesCallback != null) { Canvas.willRenderCanvases -= new WillRenderCanvases(OnWillRenderCanvasesWrapper); _staticWillRenderCanvasesCallback = null; _ownsWillRenderCanvases = false; } } private static void OnWillRenderCanvasesWrapper() { _staticWillRenderCanvasesCallback?.Invoke(); } public void Dispose() { if (!_disposed) { UnregisterPreCull(); UnregisterPreRender(); UnregisterWillRenderCanvases(); _disposed = true; } } public static void ForceCleanupAll() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown if (_staticPreCullCallback != null) { Camera.onPreCull = (CameraCallback)Delegate.Remove((Delegate?)(object)Camera.onPreCull, (Delegate?)(object)_staticPreCullCallback); _staticPreCullCallback = null; } if (_staticPreRenderCallback != null) { Camera.onPreRender = (CameraCallback)Delegate.Remove((Delegate?)(object)Camera.onPreRender, (Delegate?)(object)_staticPreRenderCallback); _staticPreRenderCallback = null; } if (_staticWillRenderCanvasesCallback != null) { Canvas.willRenderCanvases -= new WillRenderCanvases(OnWillRenderCanvasesWrapper); _staticWillRenderCanvasesCallback = null; } } } public abstract class CameraLifecycleManager : MonoBehaviour { private Camera _trackedCamera; private Component _trackingHook; private float _lastLogTime; private float _logInterval = 5f; public Camera TrackedCamera => _trackedCamera; public Component TrackingHook => _trackingHook; public bool IsTracking => (Object)(object)_trackedCamera != (Object)null; public bool IsHookAttached { get { if ((Object)(object)_trackingHook != (Object)null) { return (Object)(object)_trackingHook.gameObject != (Object)null; } return false; } } public float LogInterval { get { return _logInterval; } set { _logInterval = value; } } protected virtual void LateUpdate() { Camera val = FindCamera(); if ((Object)(object)val == (Object)null) { HandleCameraLost(); } else if (NeedsHookAttachment(val)) { AttachHook(val); } } protected virtual bool NeedsHookAttachment(Camera camera) { if ((Object)(object)_trackingHook == (Object)null) { return true; } if ((Object)(object)_trackingHook.gameObject == (Object)null) { return true; } if ((Object)(object)_trackedCamera != (Object)(object)camera) { return true; } if ((Object)(object)_trackingHook.gameObject != (Object)(object)((Component)camera).gameObject) { return true; } return false; } private void AttachHook(Camera camera) { if ((Object)(object)_trackingHook != (Object)null && (Object)(object)_trackingHook.gameObject != (Object)null) { Object.Destroy((Object)(object)_trackingHook); _trackingHook = null; } Component val = FindExistingHook(camera); if ((Object)(object)val != (Object)null) { _trackingHook = val; _trackedCamera = camera; OnCameraFound(camera, val, isReused: true); return; } _trackingHook = CreateTrackingHook(camera); if ((Object)(object)_trackingHook != (Object)null) { _trackedCamera = camera; OnCameraFound(camera, _trackingHook, isReused: false); } } private void HandleCameraLost() { if ((Object)(object)_trackedCamera != (Object)null) { float unscaledTime = Time.unscaledTime; if (_logInterval <= 0f || unscaledTime - _lastLogTime > _logInterval) { OnCameraLost(); _lastLogTime = unscaledTime; } _trackedCamera = null; _trackingHook = null; } } public void ForceRefresh() { _trackedCamera = null; _trackingHook = null; } protected abstract Camera FindCamera(); protected abstract Component CreateTrackingHook(Camera camera); protected virtual void OnCameraFound(Camera camera, Component hook, bool isReused) { } protected virtual void OnCameraLost() { } protected virtual Component FindExistingHook(Camera camera) { return null; } protected virtual void OnDestroy() { if ((Object)(object)_trackingHook != (Object)null && (Object)(object)_trackingHook.gameObject != (Object)null) { Object.Destroy((Object)(object)_trackingHook); } } } public static class CameraRotationComposer { public static Quaternion ComposeAdditive(Quaternion gameRotation, float headYaw, float headPitch, float headRoll) { //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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //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) Quaternion val = Quaternion.AngleAxis(headYaw, Vector3.up); Quaternion val2 = Quaternion.Euler(0f - headPitch, 0f, headRoll); return val * gameRotation * val2; } public static Quaternion ComposeYXZ(Quaternion gameYaw, float gamePitch, float trackYaw, float trackPitch, float trackRoll) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) float num = gamePitch + trackPitch; Quaternion val = gameYaw * Quaternion.AngleAxis(trackYaw, Vector3.up); Quaternion val2 = Quaternion.AngleAxis(num, Vector3.right); Quaternion val3 = Quaternion.AngleAxis(trackRoll, Vector3.forward); return val * val2 * val3; } public static Quaternion ComposeYXZClamped(Quaternion gameYaw, float gamePitch, float trackYaw, float trackPitch, float trackRoll, float minPitch, float maxPitch) { //IL_000c: 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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_003d: 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) float num = Mathf.Clamp(gamePitch + trackPitch, minPitch, maxPitch); Quaternion val = gameYaw * Quaternion.AngleAxis(trackYaw, Vector3.up); Quaternion val2 = Quaternion.AngleAxis(num, Vector3.right); Quaternion val3 = Quaternion.AngleAxis(trackRoll, Vector3.forward); return val * val2 * val3; } public static Quaternion GetTrackingOnlyRotation(float trackYaw, float trackPitch, float trackRoll) { //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_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_0016: 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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) //IL_002a: Unknown result type (might be due to invalid IL or missing references) Quaternion val = Quaternion.AngleAxis(trackYaw, Vector3.up); Quaternion val2 = Quaternion.AngleAxis(trackPitch, Vector3.right); Quaternion val3 = Quaternion.AngleAxis(trackRoll, Vector3.forward); return val * val2 * val3; } public static Quaternion ComposeFirstPerson(Quaternion baseLookRotation, float headYaw, float headPitch, float headRoll) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) return ComposeAdditive(baseLookRotation, headYaw, headPitch, headRoll); } } public class CameraSpeedInfluenceModifier : IInfluenceModifier { private float _currentSpeed; private float _lastDegreesX; private float _lastDegreesY; private bool _initialized; public float SpeedThreshold { get; set; } = 2f; public float SpeedRange { get; set; } = 8f; public float MinInfluence { get; set; } = 0.15f; public float CurrentSpeed => _currentSpeed; public CameraSpeedInfluenceModifier() { } public CameraSpeedInfluenceModifier(float speedThreshold, float speedRange, float minInfluence) { SpeedThreshold = speedThreshold; SpeedRange = speedRange; MinInfluence = minInfluence; } public void UpdateFromDegrees(float degreesX, float degreesY) { if (!_initialized) { _lastDegreesX = degreesX; _lastDegreesY = degreesY; _initialized = true; _currentSpeed = 0f; } else { float num = degreesX - _lastDegreesX; float num2 = degreesY - _lastDegreesY; _currentSpeed = Mathf.Sqrt(num * num + num2 * num2); _lastDegreesX = degreesX; _lastDegreesY = degreesY; } } public void UpdateFromRotation(Quaternion previousRotation, Quaternion currentRotation) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) float currentSpeed = Quaternion.Angle(previousRotation, currentRotation); _currentSpeed = currentSpeed; } public void SetSpeed(float speed) { _currentSpeed = speed; } public float GetInfluence() { if (_currentSpeed <= SpeedThreshold) { return 1f; } if (SpeedRange <= 0f) { return MinInfluence; } float num = Mathf.Clamp01((_currentSpeed - SpeedThreshold) / SpeedRange); return Mathf.Lerp(1f, MinInfluence, num); } public void Reset() { _currentSpeed = 0f; _lastDegreesX = 0f; _lastDegreesY = 0f; _initialized = false; } } public static class DecoupledMovementHelper { public static void ApplyDecoupled(Transform playerBodyTransform, Transform cameraTransform, float pureAimYaw, float trackingYaw, float trackingPitch, float trackingRoll, bool invertPitch = true) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_0048: 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_0055: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)playerBodyTransform == (Object)null)) { float num = NormalizeAngle(pureAimYaw); float num2 = (invertPitch ? (0f - trackingPitch) : trackingPitch); playerBodyTransform.localEulerAngles = new Vector3(num2, num, trackingRoll); if ((Object)(object)cameraTransform != (Object)null && (Object)(object)cameraTransform != (Object)(object)playerBodyTransform) { Vector3 localEulerAngles = cameraTransform.localEulerAngles; cameraTransform.localEulerAngles = new Vector3(localEulerAngles.x, trackingYaw, localEulerAngles.z); } } } public static void ApplyDecoupledFadeOut(Transform playerBodyTransform, Transform cameraTransform, float pureAimYaw, float lastTrackingYaw, float lastTrackingPitch, float lastTrackingRoll, float fadeProgress, bool invertPitch = true) { //IL_004d: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)playerBodyTransform == (Object)null)) { float num = Mathf.Lerp(lastTrackingYaw, 0f, fadeProgress); float num2 = Mathf.Lerp(lastTrackingPitch, 0f, fadeProgress); float num3 = Mathf.Lerp(lastTrackingRoll, 0f, fadeProgress); float num4 = NormalizeAngle(pureAimYaw); float num5 = (invertPitch ? (0f - num2) : num2); playerBodyTransform.localEulerAngles = new Vector3(num5, num4, num3); if ((Object)(object)cameraTransform != (Object)null && (Object)(object)cameraTransform != (Object)(object)playerBodyTransform) { Vector3 localEulerAngles = cameraTransform.localEulerAngles; cameraTransform.localEulerAngles = new Vector3(localEulerAngles.x, num, localEulerAngles.z); } } } public static void ResetCameraYawOffset(Transform cameraTransform, Transform playerBodyTransform) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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) //IL_002b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cameraTransform != (Object)null && (Object)(object)cameraTransform != (Object)(object)playerBodyTransform) { Vector3 localEulerAngles = cameraTransform.localEulerAngles; cameraTransform.localEulerAngles = new Vector3(localEulerAngles.x, 0f, localEulerAngles.z); } } private static float NormalizeAngle(float angle) { while (angle < 0f) { angle += 360f; } while (angle >= 360f) { angle -= 360f; } return angle; } public static float ToSignedAngle(float angle) { if (angle > 180f) { return angle - 360f; } return angle; } } public abstract class LookAimDecoupledHook : MonoBehaviour { private Camera _camera; private Quaternion _preTrackingRotation; private bool _trackingAppliedThisFrame; private bool _isEnabled = true; public bool IsEnabled { get { return _isEnabled; } set { _isEnabled = value; } } protected Camera Camera => _camera; protected bool TrackingAppliedThisFrame => _trackingAppliedThisFrame; protected Quaternion PreTrackingRotation => _preTrackingRotation; protected virtual void Awake() { _camera = ((Component)this).GetComponent(); } protected abstract Quaternion ComputeTrackedRotation(Quaternion gameRotation); protected abstract bool ShouldApplyTracking(); protected virtual void OnPreCullComplete(Quaternion gameRotation, Quaternion trackedRotation) { } protected virtual void OnPostRenderComplete() { } private void OnPreCull() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) _trackingAppliedThisFrame = false; try { if (_isEnabled && !((Object)(object)_camera == (Object)null) && ShouldApplyTracking()) { _preTrackingRotation = ((Component)_camera).transform.rotation; _trackingAppliedThisFrame = true; Quaternion val = ComputeTrackedRotation(_preTrackingRotation); ((Component)_camera).transform.rotation = val; OnPreCullComplete(_preTrackingRotation, val); } } catch (Exception ex) { Debug.LogError((object)("[LookAimDecoupledHook] OnPreCull error: " + ex.Message)); } } private void OnPostRender() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (!_trackingAppliedThisFrame) { return; } try { if ((Object)(object)_camera != (Object)null) { ((Component)_camera).transform.rotation = _preTrackingRotation; } OnPostRenderComplete(); } catch (Exception ex) { Debug.LogError((object)("[LookAimDecoupledHook] OnPostRender error: " + ex.Message)); } } } public static class PositionApplicator { public static Vector3 ToHorizonLockedWorld(Vec3 offset, Quaternion gameRotation) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_0043: 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_004f: 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) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) Vector3 val = gameRotation * Vector3.forward; val.y = 0f; float magnitude = ((Vector3)(ref val)).magnitude; val = ((!(magnitude > 0.001f)) ? Vector3.forward : (val / magnitude)); return new Vector3(val.z, 0f, 0f - val.x) * offset.X + Vector3.up * offset.Y + val * offset.Z; } public static Vector3 ToCameraLocalWorld(Vec3 offset, Quaternion gameRotation) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: 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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) return gameRotation * new Vector3(offset.X, offset.Y, offset.Z); } } public class SmoothedRotationState { private Quaternion _smoothedRotation = Quaternion.identity; private bool _initialized; public Quaternion Current => _smoothedRotation; public bool IsInitialized => _initialized; public Quaternion Update(Quaternion target, float smoothing) { //IL_0010: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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) float effectiveSmoothing = SmoothingUtils.GetEffectiveSmoothing(smoothing); if (!_initialized) { _smoothedRotation = target; _initialized = true; return _smoothedRotation; } if (effectiveSmoothing < 0.001f) { _smoothedRotation = target; return _smoothedRotation; } _smoothedRotation = UnitySmoothingHelper.SmoothRotation(_smoothedRotation, target, effectiveSmoothing); return _smoothedRotation; } public void Reset() { //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) _smoothedRotation = Quaternion.identity; _initialized = false; } public void Reset(Quaternion rotation) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) _smoothedRotation = rotation; _initialized = true; } } public sealed class TemporaryRotationScope : IDisposable { private Quaternion _savedRotation; private Transform _transform; private bool _isActive; private TemporaryRotationScope() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) _savedRotation = Quaternion.identity; _transform = null; _isActive = false; } public static TemporaryRotationScope Apply(Transform transform, Quaternion newRotation) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)transform == (Object)null) { return null; } TemporaryRotationScope result = new TemporaryRotationScope { _savedRotation = transform.localRotation, _transform = transform, _isActive = true }; transform.localRotation = newRotation; return result; } public static TemporaryRotationScope ApplyBaseRotation(Transform cameraTransform, Quaternion baseRotation, Quaternion headTrackingRotation) { //IL_000b: 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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_0032: 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_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) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cameraTransform == (Object)null) { return null; } if (baseRotation == default(Quaternion) || headTrackingRotation == Quaternion.identity) { return null; } Quaternion val = baseRotation * headTrackingRotation; Quaternion newRotation = (((Object)(object)cameraTransform.parent != (Object)null) ? (Quaternion.Inverse(cameraTransform.parent.rotation) * val) : val); return Apply(cameraTransform, newRotation); } public static TemporaryRotationScope RemoveHeadTracking(Transform cameraTransform, Quaternion baseRotation) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cameraTransform == (Object)null || baseRotation == default(Quaternion)) { return null; } Quaternion newRotation = (((Object)(object)cameraTransform.parent != (Object)null) ? (Quaternion.Inverse(cameraTransform.parent.rotation) * baseRotation) : baseRotation); return Apply(cameraTransform, newRotation); } public void Dispose() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (_isActive && !((Object)(object)_transform == (Object)null)) { _transform.localRotation = _savedRotation; _isActive = false; _transform = null; _savedRotation = Quaternion.identity; } } } public sealed class TemporaryWorldRotationScope : IDisposable { private Quaternion _savedRotation; private Transform _transform; private bool _isActive; private TemporaryWorldRotationScope() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) _savedRotation = Quaternion.identity; _transform = null; _isActive = false; } public static TemporaryWorldRotationScope Apply(Transform transform, Quaternion newWorldRotation) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)transform == (Object)null) { return null; } TemporaryWorldRotationScope result = new TemporaryWorldRotationScope { _savedRotation = transform.rotation, _transform = transform, _isActive = true }; transform.rotation = newWorldRotation; return result; } public static TemporaryWorldRotationScope ApplyHeadTracking(Transform transform, Quaternion baseRotation, Quaternion headTrackingRotation) { //IL_000b: 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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)transform == (Object)null) { return null; } if (baseRotation == default(Quaternion) || headTrackingRotation == Quaternion.identity) { return null; } return Apply(transform, baseRotation * headTrackingRotation); } public void Dispose() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (_isActive && !((Object)(object)_transform == (Object)null)) { _transform.rotation = _savedRotation; _isActive = false; _transform = null; _savedRotation = Quaternion.identity; } } } public class TrackingLossHandler { private int _framesWithoutData; private float _secondsWithoutData; private int _stabilizationFramesRemaining; private bool _needsRecenter; private TrackingLossState _currentState; public float FadeDelaySeconds { get; set; } = 0.5f; public float FadeSpeed { get; set; } = 2f; public int StabilizationFrames { get; set; } = 10; public int RecenterThresholdFrames { get; set; } = 60; public TrackingLossState CurrentState => _currentState; public bool NeedsRecenter => _needsRecenter; public int StabilizationFramesRemaining => _stabilizationFramesRemaining; public TrackingLossHandler() { Reset(); } public TrackingLossState Update(bool hasValidData, float deltaTime) { if (!hasValidData) { _framesWithoutData++; _secondsWithoutData += deltaTime; _stabilizationFramesRemaining = StabilizationFrames; if (RecenterThresholdFrames > 0 && _framesWithoutData > RecenterThresholdFrames) { _needsRecenter = true; } if (_secondsWithoutData <= FadeDelaySeconds) { _currentState = TrackingLossState.Holding; } else { _currentState = TrackingLossState.Fading; } } else { _framesWithoutData = 0; _secondsWithoutData = 0f; if (_stabilizationFramesRemaining > 0) { _stabilizationFramesRemaining--; _currentState = TrackingLossState.Stabilizing; } else { _currentState = TrackingLossState.Active; } } return _currentState; } public float GetFadeInterpolation(float deltaTime) { if (_currentState != TrackingLossState.Fading && _currentState != TrackingLossState.Stabilizing) { return 0f; } return 1f - Mathf.Exp((0f - FadeSpeed) * deltaTime); } public Quaternion ApplyFade(Quaternion currentRotation, float deltaTime) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) float fadeInterpolation = GetFadeInterpolation(deltaTime); if (fadeInterpolation <= 0f) { return currentRotation; } return Quaternion.Slerp(currentRotation, Quaternion.identity, fadeInterpolation); } public void ClearRecenterFlag() { _needsRecenter = false; } public void Reset() { _framesWithoutData = 0; _secondsWithoutData = 0f; _stabilizationFramesRemaining = 0; _needsRecenter = false; _currentState = TrackingLossState.Active; } public void TriggerStabilization() { _stabilizationFramesRemaining = StabilizationFrames; _currentState = TrackingLossState.Stabilizing; } } public enum TrackingLossState { Active, Holding, Fading, Stabilizing } public static class ViewMatrixModifier { public static void ApplyHeadRotation(Camera cam, Quaternion headRotation) { //IL_0020: 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) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cam == (Object)null) { throw new ArgumentNullException("cam", "Camera cannot be null"); } cam.ResetWorldToCameraMatrix(); Matrix4x4 worldToCameraMatrix = cam.worldToCameraMatrix; Matrix4x4 val = Matrix4x4.Rotate(headRotation); cam.worldToCameraMatrix = val * worldToCameraMatrix; } public static void ApplyHeadRotation(Camera cam, float yaw, float pitch, float roll) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cam == (Object)null) { throw new ArgumentNullException("cam", "Camera cannot be null"); } Quaternion headRotation = Quaternion.Euler(pitch, yaw, 0f - roll); ApplyHeadRotation(cam, headRotation); } public static void ApplyHeadRotationDecomposed(Camera cam, float yaw, float pitch, float roll) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0043: Unknown result type (might be due to invalid IL or missing references) //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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cam == (Object)null) { throw new ArgumentNullException("cam", "Camera cannot be null"); } Quaternion val = Quaternion.AngleAxis(yaw, Vector3.up); Quaternion val2 = Quaternion.Euler(pitch, 0f, roll); Quaternion rotation = ((Component)cam).transform.rotation; Matrix4x4 val3 = Matrix4x4.Rotate(Quaternion.Inverse(val * rotation * val2)); Matrix4x4 val4 = Matrix4x4.Translate(-((Component)cam).transform.position); Matrix4x4 val5 = val3 * val4; val5.m20 = 0f - val5.m20; val5.m21 = 0f - val5.m21; val5.m22 = 0f - val5.m22; val5.m23 = 0f - val5.m23; cam.worldToCameraMatrix = val5; } public static void SyncMatrixToTransform(Camera cam) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cam == (Object)null) { throw new ArgumentNullException("cam", "Camera cannot be null"); } Matrix4x4 localToWorldMatrix = ((Component)cam).transform.localToWorldMatrix; Matrix4x4 inverse = ((Matrix4x4)(ref localToWorldMatrix)).inverse; inverse.m20 = 0f - inverse.m20; inverse.m21 = 0f - inverse.m21; inverse.m22 = 0f - inverse.m22; inverse.m23 = 0f - inverse.m23; cam.worldToCameraMatrix = inverse; } public static void Reset(Camera cam) { if ((Object)(object)cam == (Object)null) { throw new ArgumentNullException("cam", "Camera cannot be null"); } cam.ResetWorldToCameraMatrix(); } public static Quaternion GetAppliedRotation(Camera cam) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_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_002e: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cam == (Object)null) { throw new ArgumentNullException("cam", "Camera cannot be null"); } Matrix4x4 worldToCameraMatrix = cam.worldToCameraMatrix; cam.ResetWorldToCameraMatrix(); Matrix4x4 worldToCameraMatrix2 = cam.worldToCameraMatrix; cam.worldToCameraMatrix = worldToCameraMatrix; Matrix4x4 val = worldToCameraMatrix * ((Matrix4x4)(ref worldToCameraMatrix2)).inverse; return ((Matrix4x4)(ref val)).rotation; } } } namespace CameraUnlock.Core.Unity.Rendering { public delegate bool ReticlePositionProvider(out float screenX, out float screenY); public enum ReticleStyle { Dot, Circle } public sealed class IMGUIReticle : MonoBehaviour { private ReticlePositionProvider _positionProvider; private Texture2D _reticleTexture; private const int ReferenceHeight = 1080; private int _baseSizeAt1080p = 4; private int _thicknessAt1080p = 2; private int _currentTextureSize; private int _currentThickness; private int _lastScreenHeight; private Color _reticleColor = Color.white; private Color _outlineColor = new Color(0f, 0f, 0f, 0f); private int _outlineWidthAt1080p; private int _currentOutlineWidth; private bool _isVisible = true; private ReticleStyle _style; public int BaseSizeAt1080p { get { return _baseSizeAt1080p; } set { if (value != _baseSizeAt1080p) { _baseSizeAt1080p = Mathf.Max(1, value); RecreateTexture(); } } } public Color ReticleColor { get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return _reticleColor; } set { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (value != _reticleColor) { _reticleColor = value; RecreateTexture(); } } } public bool IsVisible { get { return _isVisible; } set { _isVisible = value; } } public ReticleStyle Style { get { return _style; } set { if (value != _style) { _style = value; RecreateTexture(); } } } public int ThicknessAt1080p { get { return _thicknessAt1080p; } set { if (value != _thicknessAt1080p) { _thicknessAt1080p = Mathf.Max(1, value); RecreateTexture(); } } } public Color OutlineColor { get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return _outlineColor; } set { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (value != _outlineColor) { _outlineColor = value; RecreateTexture(); } } } public int OutlineWidthAt1080p { get { return _outlineWidthAt1080p; } set { if (value != _outlineWidthAt1080p) { _outlineWidthAt1080p = Mathf.Max(0, value); RecreateTexture(); } } } public void Initialize(ReticlePositionProvider positionProvider) { _positionProvider = positionProvider; UpdateTextureForResolution(); } public void InitializeWithOffset(Func getOffset, Func shouldDraw = null) { _positionProvider = delegate(out float x, out float y) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_0053: Unknown result type (might be due to invalid IL or missing references) if (shouldDraw != null && !shouldDraw()) { x = 0f; y = 0f; return false; } Vector2 val = getOffset(); x = (float)Screen.width * 0.5f + val.x; y = (float)Screen.height * 0.5f + val.y; return true; }; UpdateTextureForResolution(); } private int ComputeScaledSize() { float num = (float)Screen.height / 1080f; int num2 = Mathf.RoundToInt((float)(_baseSizeAt1080p + _outlineWidthAt1080p * 2) * num); return Mathf.Max(2, num2); } private int ComputeScaledOutlineWidth() { if (_outlineWidthAt1080p <= 0) { return 0; } float num = (float)Screen.height / 1080f; int num2 = Mathf.RoundToInt((float)_outlineWidthAt1080p * num); return Mathf.Max(1, num2); } private int ComputeScaledThickness() { float num = (float)Screen.height / 1080f; int num2 = Mathf.RoundToInt((float)_thicknessAt1080p * num); return Mathf.Max(1, num2); } private void UpdateTextureForResolution() { int num = ComputeScaledSize(); int num2 = ComputeScaledThickness(); int num3 = ComputeScaledOutlineWidth(); if ((Object)(object)_reticleTexture == (Object)null || num != _currentTextureSize || num2 != _currentThickness || num3 != _currentOutlineWidth || Screen.height != _lastScreenHeight) { _currentTextureSize = num; _currentThickness = num2; _currentOutlineWidth = num3; _lastScreenHeight = Screen.height; RecreateTexture(); } } private void RecreateTexture() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_012f: 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_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0317: 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_0330: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_reticleTexture != (Object)null) { Object.Destroy((Object)(object)_reticleTexture); _reticleTexture = null; } int num = _currentTextureSize; if (num < 2) { num = 2; } _reticleTexture = new Texture2D(num, num, (TextureFormat)4, false); _reticleTexture.filterMode = (FilterMode)1; Color val = default(Color); ((Color)(ref val))..ctor(0f, 0f, 0f, 0f); Color[] array = (Color[])(object)new Color[num * num]; for (int i = 0; i < array.Length; i++) { array[i] = val; } float num2 = (float)(num - 1) * 0.5f; float num3 = (float)num * 0.5f; float num4 = _currentOutlineWidth; float num5 = num3 - num4; if (num5 < 0f) { num5 = 0f; } if (_style == ReticleStyle.Dot) { for (int j = 0; j < num; j++) { for (int k = 0; k < num; k++) { float num6 = (float)k - num2; float num7 = (float)j - num2; float num8 = Mathf.Sqrt(num6 * num6 + num7 * num7); if (!(num8 > num3)) { float num9 = Mathf.Clamp01(num3 - num8 + 0.5f); if (num4 > 0f && num8 > num5) { float num10 = Mathf.Clamp01(num8 - num5 + 0.5f); Color val2 = Color.Lerp(_reticleColor, _outlineColor, num10); val2.a *= num9; array[j * num + k] = val2; } else { Color reticleColor = _reticleColor; reticleColor.a *= num9; array[j * num + k] = reticleColor; } } } } } else { float num11 = _currentThickness; float num12 = num5 - num11; if (num12 < 0f) { num12 = 0f; } for (int l = 0; l < num; l++) { for (int m = 0; m < num; m++) { float num13 = (float)m - num2; float num14 = (float)l - num2; float num15 = Mathf.Sqrt(num13 * num13 + num14 * num14); if (num4 > 0f && num15 > num5 && num15 <= num3) { float num16 = Mathf.Clamp01(num3 - num15 + 0.5f); float num17 = Mathf.Clamp01(num15 - num5 + 0.5f); Color val3 = Color.Lerp(_reticleColor, _outlineColor, num17); val3.a *= num16; array[l * num + m] = val3; } else if (num15 >= num12 && num15 <= num5) { float num18 = Mathf.Clamp01(num5 - num15 + 0.5f); float num19 = Mathf.Clamp01(num15 - num12 + 0.5f); float num20 = num18 * num19; if (num20 > 0f) { Color reticleColor2 = _reticleColor; reticleColor2.a *= num20; array[l * num + m] = reticleColor2; } } else if (num4 > 0f && num15 < num12 && num15 >= num12 - num4) { float num21 = Mathf.Clamp01(num12 - num15 + 0.5f); float num22 = Mathf.Clamp01(num15 - (num12 - num4) + 0.5f); Color val4 = Color.Lerp(_reticleColor, _outlineColor, num21); val4.a *= num22; array[l * num + m] = val4; } } } } _reticleTexture.SetPixels(array); _reticleTexture.Apply(); } private void OnGUI() { //IL_0060: Unknown result type (might be due to invalid IL or missing references) if (_isVisible && _positionProvider != null) { UpdateTextureForResolution(); if (!((Object)(object)_reticleTexture == (Object)null) && _positionProvider(out var screenX, out var screenY)) { float num = (float)Screen.height - screenY; int currentTextureSize = _currentTextureSize; GUI.DrawTexture(new Rect(screenX - (float)currentTextureSize * 0.5f, num - (float)currentTextureSize * 0.5f, (float)currentTextureSize, (float)currentTextureSize), (Texture)(object)_reticleTexture); } } } private void OnDestroy() { if ((Object)(object)_reticleTexture != (Object)null) { Object.Destroy((Object)(object)_reticleTexture); _reticleTexture = null; } } } public static class RenderPipelineHelper { private static bool _isRegistered; private static bool _usingSRP; private static CameraCallback _legacyPreRender; private static CameraCallback _legacyPostRender; private static object _srpPreRenderDelegate; private static object _srpPostRenderDelegate; private static bool _srpCheckDone; private static bool _srpAvailable; private static Action _storedPreRender; private static Action _storedPostRender; public static bool IsSRP { get { if (!_srpCheckDone) { _srpAvailable = CheckSRPAvailable(); _srpCheckDone = true; } if (!_srpAvailable) { return false; } Type type = Type.GetType("UnityEngine.Rendering.GraphicsSettings, UnityEngine.CoreModule"); if (type == null) { type = Type.GetType("UnityEngine.Rendering.GraphicsSettings, UnityEngine"); } if (type != null) { PropertyInfo property = type.GetProperty("currentRenderPipeline", BindingFlags.Static | BindingFlags.Public); if (property != null) { return property.GetValue(null, null) != null; } } return false; } } public static bool IsRegistered => _isRegistered; public static void RegisterCallbacks(Action onPreRender, Action onPostRender) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown if (_isRegistered) { throw new InvalidOperationException("Callbacks already registered. Call UnregisterCallbacks() first."); } if (onPreRender == null) { throw new ArgumentNullException("onPreRender"); } if (onPostRender == null) { throw new ArgumentNullException("onPostRender"); } _usingSRP = IsSRP; if (_usingSRP) { RegisterSRPCallbacks(onPreRender, onPostRender); } else { _legacyPreRender = new CameraCallback(onPreRender.Invoke); _legacyPostRender = new CameraCallback(onPostRender.Invoke); Camera.onPreCull = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPreCull, (Delegate?)(object)_legacyPreRender); Camera.onPostRender = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPostRender, (Delegate?)(object)_legacyPostRender); } _isRegistered = true; } public static void UnregisterCallbacks() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown if (!_isRegistered) { return; } if (_usingSRP) { UnregisterSRPCallbacks(); } else { if (_legacyPreRender != null) { Camera.onPreCull = (CameraCallback)Delegate.Remove((Delegate?)(object)Camera.onPreCull, (Delegate?)(object)_legacyPreRender); _legacyPreRender = null; } if (_legacyPostRender != null) { Camera.onPostRender = (CameraCallback)Delegate.Remove((Delegate?)(object)Camera.onPostRender, (Delegate?)(object)_legacyPostRender); _legacyPostRender = null; } } _isRegistered = false; } private static bool CheckSRPAvailable() { Type type = Type.GetType("UnityEngine.Rendering.RenderPipelineManager, UnityEngine.CoreModule"); if (type == null) { type = Type.GetType("UnityEngine.Rendering.RenderPipelineManager, UnityEngine"); } return type != null; } private static void RegisterSRPCallbacks(Action onPreRender, Action onPostRender) { Type type = Type.GetType("UnityEngine.Rendering.RenderPipelineManager, UnityEngine.CoreModule"); if (type == null) { type = Type.GetType("UnityEngine.Rendering.RenderPipelineManager, UnityEngine"); } if (type == null) { throw new InvalidOperationException("SRP detected but RenderPipelineManager type not found."); } EventInfo @event = type.GetEvent("beginCameraRendering"); EventInfo event2 = type.GetEvent("endCameraRendering"); if (@event == null || event2 == null) { throw new InvalidOperationException("SRP detected but beginCameraRendering/endCameraRendering events not found."); } Type eventHandlerType = @event.EventHandlerType; ParameterInfo[] parameters = eventHandlerType.GetMethod("Invoke").GetParameters(); Type[] array = new Type[parameters.Length]; for (int i = 0; i < parameters.Length; i++) { array[i] = parameters[i].ParameterType; } _storedPreRender = onPreRender; _storedPostRender = onPostRender; _srpPreRenderDelegate = CreateSRPWrapperDelegate("SRPPreRenderWrapper", array, eventHandlerType, "_storedPreRender"); _srpPostRenderDelegate = CreateSRPWrapperDelegate("SRPPostRenderWrapper", array, eventHandlerType, "_storedPostRender"); @event.AddEventHandler(null, (Delegate)_srpPreRenderDelegate); event2.AddEventHandler(null, (Delegate)_srpPostRenderDelegate); } private static Delegate CreateSRPWrapperDelegate(string name, Type[] paramTypes, Type delegateType, string fieldName) { DynamicMethod dynamicMethod = new DynamicMethod(name, typeof(void), paramTypes, typeof(RenderPipelineHelper).Module, skipVisibility: true); FieldInfo field = typeof(RenderPipelineHelper).GetField(fieldName, BindingFlags.Static | BindingFlags.NonPublic); MethodInfo method = typeof(Action).GetMethod("Invoke"); ILGenerator iLGenerator = dynamicMethod.GetILGenerator(); iLGenerator.Emit(OpCodes.Ldsfld, field); iLGenerator.Emit(OpCodes.Ldarg_1); iLGenerator.Emit(OpCodes.Callvirt, method); iLGenerator.Emit(OpCodes.Ret); return dynamicMethod.CreateDelegate(delegateType); } private static void UnregisterSRPCallbacks() { Type type = Type.GetType("UnityEngine.Rendering.RenderPipelineManager, UnityEngine.CoreModule"); if (type == null) { type = Type.GetType("UnityEngine.Rendering.RenderPipelineManager, UnityEngine"); } if (type == null) { throw new InvalidOperationException("SRP was registered but RenderPipelineManager type no longer found."); } EventInfo @event = type.GetEvent("beginCameraRendering"); EventInfo event2 = type.GetEvent("endCameraRendering"); if (@event != null && _srpPreRenderDelegate != null) { @event.RemoveEventHandler(null, (Delegate)_srpPreRenderDelegate); } if (event2 != null && _srpPostRenderDelegate != null) { event2.RemoveEventHandler(null, (Delegate)_srpPostRenderDelegate); } _srpPreRenderDelegate = null; _srpPostRenderDelegate = null; _storedPreRender = null; _storedPostRender = null; } } } namespace CameraUnlock.Core.Unity.Performance { public static class FramerateHelper { private static int _originalTargetFrameRate = -1; private static int _originalVSyncCount = -1; private static bool _settingsSaved; public static bool IsModified => _settingsSaved; public static int CurrentTargetFrameRate => Application.targetFrameRate; public static int CurrentVSyncCount => QualitySettings.vSyncCount; public static void UnlockFramerate() { SaveOriginalSettings(); Application.targetFrameRate = -1; QualitySettings.vSyncCount = 0; } public static void SetTargetFramerate(int targetFps) { SaveOriginalSettings(); Application.targetFrameRate = targetFps; QualitySettings.vSyncCount = 0; } public static void SetTargetFramerate(int targetFps, int vSyncCount) { SaveOriginalSettings(); Application.targetFrameRate = targetFps; QualitySettings.vSyncCount = vSyncCount; } public static void RestoreOriginalSettings() { if (_settingsSaved) { Application.targetFrameRate = _originalTargetFrameRate; QualitySettings.vSyncCount = _originalVSyncCount; _settingsSaved = false; } } private static void SaveOriginalSettings() { if (!_settingsSaved) { _originalTargetFrameRate = Application.targetFrameRate; _originalVSyncCount = QualitySettings.vSyncCount; _settingsSaved = true; } } } } namespace CameraUnlock.Core.Unity.Patching { public static class CameraPatching { public static void RemoveHeadTrackingOffset(Transform cameraTransform, Quaternion appliedInverse, bool wasApplied) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)cameraTransform == (Object)null) && wasApplied) { cameraTransform.localRotation *= appliedInverse; } } public static void ApplyHeadTrackingOffset(Transform cameraTransform, Quaternion trackingRotation, out Quaternion appliedInverse) { //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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) appliedInverse = Quaternion.identity; if (!((Object)(object)cameraTransform == (Object)null)) { cameraTransform.localRotation *= trackingRotation; appliedInverse = Quaternion.Inverse(trackingRotation); } } public static void ApplyAdditiveHeadTracking(Transform cameraTransform, float yawDegrees, float pitchDegrees, float rollDegrees, out Quaternion appliedInverse) { //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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) appliedInverse = Quaternion.identity; if (!((Object)(object)cameraTransform == (Object)null)) { Quaternion val = Quaternion.AngleAxis(yawDegrees, Vector3.up); Quaternion val2 = Quaternion.AngleAxis(pitchDegrees, Vector3.right); Quaternion val3 = Quaternion.AngleAxis(rollDegrees, Vector3.forward); Quaternion val4 = val2 * val3; Quaternion val5 = val; cameraTransform.rotation = val5 * cameraTransform.rotation; cameraTransform.localRotation *= val4; appliedInverse = Quaternion.Inverse(val5 * val4); } } public static Vector3 GetAimDirection(Transform cameraTransform, Quaternion appliedInverse) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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) if ((Object)(object)cameraTransform == (Object)null) { return Vector3.forward; } return cameraTransform.rotation * appliedInverse * Vector3.forward; } public static Vector3 GetAimDirection(Quaternion currentRotation, Quaternion trackingRotation) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) return currentRotation * Quaternion.Inverse(trackingRotation) * Vector3.forward; } } } namespace CameraUnlock.Core.Unity.Lifecycle { public abstract class SelfHealingModBase : MonoBehaviour { private class ModRecreator : MonoBehaviour { private Action _checkRecreateAction; public void SetModType(string name) where T : SelfHealingModBase { _checkRecreateAction = delegate { CheckRecreate(name); }; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); } private void Update() { if ((Object)(object)_instance == (Object)null && _checkRecreateAction != null) { _checkRecreateAction(); } } } private static GameObject _modObject; private static SelfHealingModBase _instance; private static bool _recreateScheduled; private static Type _modType; public static SelfHealingModBase Instance => _instance; protected abstract void Initialize(); protected virtual void OnModDestroyed() { } public static T CreateMod(string name = "HeadTrackingMod") where T : SelfHealingModBase { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown if ((Object)(object)_instance != (Object)null) { return (T)_instance; } _modType = typeof(T); _modObject = new GameObject(name); Object.DontDestroyOnLoad((Object)(object)_modObject); _instance = _modObject.AddComponent(); _modObject.AddComponent().SetModType(name); return (T)_instance; } protected virtual void Awake() { Initialize(); } protected virtual void OnDestroy() { OnModDestroyed(); _instance = null; _modObject = null; _recreateScheduled = true; } public static void ScheduleRecreate() { _recreateScheduled = true; } internal static void CheckRecreate(string name) where T : SelfHealingModBase { if (_recreateScheduled && (Object)(object)_instance == (Object)null) { _recreateScheduled = false; CreateMod(name); } } } } namespace CameraUnlock.Core.Unity.Extensions { public static class CanvasCompensation { public static void RepositionChildren(RectTransform canvasRectTransform, Camera cam, float yaw, float pitch, float roll) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)canvasRectTransform == (Object)null) { throw new ArgumentNullException("canvasRectTransform"); } if ((Object)(object)cam == (Object)null) { throw new ArgumentNullException("cam"); } Rect rect = canvasRectTransform.rect; float width = ((Rect)(ref rect)).width; rect = canvasRectTransform.rect; float height = ((Rect)(ref rect)).height; float num = width * 0.5f; float num2 = height * 0.5f; float fieldOfView = cam.fieldOfView; float num3 = ScreenOffsetCalculator.CalculateHorizontalFov(fieldOfView, cam.aspect); float num4 = default(float); float num5 = default(float); ScreenOffsetCalculator.Calculate(yaw, pitch, 0f, num3, fieldOfView, width, height, 1f, ref num4, ref num5); float num6 = (0f - roll) * ((float)Math.PI / 180f); float num7 = Mathf.Cos(num6); float num8 = Mathf.Sin(num6); int childCount = ((Transform)canvasRectTransform).childCount; for (int i = 0; i < childCount; i++) { Transform child = ((Transform)canvasRectTransform).GetChild(i); if (((Component)child).gameObject.activeInHierarchy) { RectTransform val = (RectTransform)(object)((child is RectTransform) ? child : null); if (!((Object)(object)val == (Object)null)) { Vector2 anchoredPosition = val.anchoredPosition; float num9 = anchoredPosition.x - num; float num10 = anchoredPosition.y - num2; float num11 = num9 * num7 - num10 * num8; float num12 = num9 * num8 + num10 * num7; float num13 = num11 + num4 + num; float num14 = num12 + num5 + num2; val.anchoredPosition = new Vector2(num13, num14); } } } } public static void RepositionElement(RectTransform element, float canvasWidth, float canvasHeight, Camera cam, float yaw, float pitch, float roll) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)element == (Object)null) { throw new ArgumentNullException("element"); } if ((Object)(object)cam == (Object)null) { throw new ArgumentNullException("cam"); } float num = canvasWidth * 0.5f; float num2 = canvasHeight * 0.5f; float fieldOfView = cam.fieldOfView; float num3 = ScreenOffsetCalculator.CalculateHorizontalFov(fieldOfView, cam.aspect); float num4 = default(float); float num5 = default(float); ScreenOffsetCalculator.Calculate(yaw, pitch, 0f, num3, fieldOfView, canvasWidth, canvasHeight, 1f, ref num4, ref num5); Vector2 anchoredPosition = element.anchoredPosition; float num6 = anchoredPosition.x - num; float num7 = anchoredPosition.y - num2; float num8 = default(float); float num9 = default(float); ScreenOffsetCalculator.ApplyRollRotation(num6, num7, roll, ref num8, ref num9); float num10 = num8 + num4 + num; float num11 = num9 + num5 + num2; element.anchoredPosition = new Vector2(num10, num11); } public static Vector2 CalculateCenteredOffset(Camera cam, float yaw, float pitch, float roll) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cam == (Object)null) { throw new ArgumentNullException("cam"); } float fieldOfView = cam.fieldOfView; float num = ScreenOffsetCalculator.CalculateHorizontalFov(fieldOfView, cam.aspect); float num2 = default(float); float num3 = default(float); ScreenOffsetCalculator.Calculate(yaw, pitch, 0f, num, fieldOfView, (float)Screen.width, (float)Screen.height, 1f, ref num2, ref num3); return new Vector2(num2, num3); } public static Vector2 CalculateCenteredOffsetScaled(Camera cam, float canvasScaleFactor, float yaw, float pitch, float roll) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cam == (Object)null) { throw new ArgumentNullException("cam"); } Vector2 result = CalculateCenteredOffset(cam, yaw, pitch, roll); if (canvasScaleFactor > 0f && canvasScaleFactor != 1f) { result.x /= canvasScaleFactor; result.y /= canvasScaleFactor; } return result; } public static Vector2 CalculateAimScreenOffset(Camera cam, Vector3 aimDirection) { //IL_0001: 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) return CalculateAimScreenOffsetCore(cam, aimDirection, 100f); } public static Vector2 CalculateAimScreenOffset(Camera cam, Vector3 aimDirection, float canvasScaleFactor) { //IL_0001: 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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) Vector2 result = CalculateAimScreenOffsetCore(cam, aimDirection, 100f); if (canvasScaleFactor > 0f && canvasScaleFactor != 1f) { result.x /= canvasScaleFactor; result.y /= canvasScaleFactor; } return result; } public static Vector2 CalculateAimScreenOffset(Camera cam, Vector3 aimDirection, float projectionDistance, float canvasScaleFactor) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) Vector2 result = CalculateAimScreenOffsetCore(cam, aimDirection, projectionDistance); if (canvasScaleFactor > 0f && canvasScaleFactor != 1f) { result.x /= canvasScaleFactor; result.y /= canvasScaleFactor; } return result; } public static Vector2 CalculateAimScreenOffset(Camera cam, Quaternion baseRotation) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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) Vector3 aimDirection = baseRotation * Vector3.forward; return CalculateAimScreenOffset(cam, aimDirection); } public static Vector2 CalculateAimScreenOffset(Camera cam, Quaternion baseRotation, float canvasScaleFactor) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) Vector3 aimDirection = baseRotation * Vector3.forward; return CalculateAimScreenOffset(cam, aimDirection, canvasScaleFactor); } public static Vector2 CalculateAimScreenOffsetFromTracking(Camera cam, Quaternion trackingQuaternion) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_0039: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cam == (Object)null) { throw new ArgumentNullException("cam"); } Vector3 val = Quaternion.Inverse(trackingQuaternion) * Vector3.forward; Vector3 aimDirection = ((Component)cam).transform.rotation * val; return CalculateAimScreenOffset(cam, aimDirection); } public static Vector2 CalculateAimScreenOffsetFromTracking(Camera cam, Quaternion trackingQuaternion, float canvasScaleFactor) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) Vector2 result = CalculateAimScreenOffsetFromTracking(cam, trackingQuaternion); if (canvasScaleFactor > 0f && canvasScaleFactor != 1f) { result.x /= canvasScaleFactor; result.y /= canvasScaleFactor; } return result; } public static Vector2 CalculateScreenOffsetFromWorldPoint(Camera cam, Vector3 worldPoint, float canvasScaleFactor) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_00a7: 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) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cam == (Object)null) { throw new ArgumentNullException("cam"); } Vector3 val = cam.WorldToScreenPoint(worldPoint); if (val.z <= 0f) { Vector3 val2 = worldPoint - ((Component)cam).transform.position; Vector3 normalized = ((Vector3)(ref val2)).normalized; float halfWidth = (float)Screen.width * 0.5f; float halfHeight = (float)Screen.height * 0.5f; Vector2 result = ClampToScreenEdge(normalized, cam, halfWidth, halfHeight); if (canvasScaleFactor > 0f && canvasScaleFactor != 1f) { result.x /= canvasScaleFactor; result.y /= canvasScaleFactor; } return result; } Vector2 result2 = default(Vector2); ((Vector2)(ref result2))..ctor(val.x - (float)Screen.width * 0.5f, val.y - (float)Screen.height * 0.5f); if (canvasScaleFactor > 0f && canvasScaleFactor != 1f) { result2.x /= canvasScaleFactor; result2.y /= canvasScaleFactor; } return result2; } private static Vector2 CalculateAimScreenOffsetCore(Camera cam, Vector3 aimDirection, float projectionDistance) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cam == (Object)null) { throw new ArgumentNullException("cam"); } Vector3 val = ((Component)cam).transform.position + aimDirection * projectionDistance; Vector3 val2 = cam.WorldToScreenPoint(val); float num = (float)Screen.width * 0.5f; float num2 = (float)Screen.height * 0.5f; if (val2.z > 0f) { return new Vector2(val2.x - num, val2.y - num2); } return ClampToScreenEdge(aimDirection, cam, num, num2); } private static Vector2 ClampToScreenEdge(Vector3 aimDirection, Camera cam, float halfWidth, float halfHeight) { //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_000c: 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) Vector3 val = ((Component)cam).transform.InverseTransformDirection(aimDirection); float num = 0f - val.x; float num2 = 0f - val.y; float num3 = Mathf.Max(Mathf.Abs(num), Mathf.Abs(num2)); if (num3 > 0.001f) { num /= num3; num2 /= num3; } return new Vector2(num * halfWidth * 0.9f, num2 * halfHeight * 0.9f); } } public static class UnityAimHelper { public static Vector3 ComputeAimDirectionWorld(Quaternion cameraRotation, float yaw, float pitch, float roll) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) float num = default(float); float num2 = default(float); float num3 = default(float); AimDecoupler.ComputeAimDirection(yaw, pitch, roll, ref num, ref num2, ref num3); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(num, num2, num3); return cameraRotation * val; } public static Vector3 ComputeAimDirectionWorldSplit(Quaternion cameraRotation, float yaw, float pitch, float roll) { //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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) Quaternion val = Quaternion.AngleAxis(0f - yaw, Vector3.up); Quaternion val2 = Quaternion.Inverse(Quaternion.Euler(0f - pitch, 0f, roll)); return val * cameraRotation * val2 * Vector3.forward; } public static Vector2 ComputeScreenOffset(Camera camera, Vector3 aimDirection) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)camera).transform.position + aimDirection * 10f; Vector3 val2 = camera.WorldToScreenPoint(val); float num = (float)Screen.width * 0.5f; float num2 = (float)Screen.height * 0.5f; if (val2.z > 0f) { return new Vector2(val2.x - num, val2.y - num2); } return Vector2.zero; } public static Vector2 ComputeScreenOffsetClamped(Camera camera, Vector3 aimDirection, float edgeMargin = 0.9f) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)camera).transform.position + aimDirection * 10f; Vector3 val2 = camera.WorldToScreenPoint(val); float num = (float)Screen.width * 0.5f; float num2 = (float)Screen.height * 0.5f; if (val2.z > 0f) { return new Vector2(val2.x - num, val2.y - num2); } return ClampToScreenEdge(aimDirection, camera, num, num2, edgeMargin); } public static Vector2 ClampToScreenEdge(Vector3 aimDirection, Camera camera, float halfWidth, float halfHeight, float edgeMargin = 0.9f) { //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_000c: 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) Vector3 val = ((Component)camera).transform.InverseTransformDirection(aimDirection); float num = 0f - val.x; float num2 = 0f - val.y; float num3 = Mathf.Max(Mathf.Abs(num), Mathf.Abs(num2)); if (num3 > 0.001f) { num /= num3; num2 /= num3; } return new Vector2(num * halfWidth * edgeMargin, num2 * halfHeight * edgeMargin); } public static Vector2 ComputeScreenOffsetFOV(float yaw, float pitch, float roll, Camera camera, float compensationScale = 1f) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) float fieldOfView = camera.fieldOfView; float aspect = camera.aspect; float num = ScreenOffsetCalculator.CalculateHorizontalFov(fieldOfView, aspect); float num2 = default(float); float num3 = default(float); ScreenOffsetCalculator.Calculate(yaw, pitch, roll, num, fieldOfView, (float)Screen.width, (float)Screen.height, compensationScale, ref num2, ref num3); return new Vector2(num2, num3); } public static Ray CreateAimRay(Camera camera, Vector3 aimDirection) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) return new Ray(((Component)camera).transform.position, aimDirection); } public static bool AimRaycast(Camera camera, Vector3 aimDirection, float maxDistance, out RaycastHit hit, int layerMask = -1) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) return Physics.Raycast(CreateAimRay(camera, aimDirection), ref hit, maxDistance, layerMask); } } public sealed class UnityHotkeyHandler { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static KeyDownCheck <>9__19_0; internal bool <.ctor>b__19_0(int keyCode) { return Input.GetKeyDown((KeyCode)keyCode); } } private readonly HotkeyHandler _handler; public bool IsEnabled { get { return _handler.IsEnabled; } set { _handler.IsEnabled = value; } } public int ToggleCount => _handler.ToggleCount; public int RecenterCount => _handler.RecenterCount; public event ToggleEventHandler OnToggled { add { _handler.OnToggled += value; } remove { _handler.OnToggled -= value; } } [Obsolete("Use OnToggled or IHotkeyListener instead")] public event RecenterEventHandler OnToggle { add { _handler.OnToggle += value; } remove { _handler.OnToggle -= value; } } public event RecenterEventHandler OnRecenter { add { _handler.OnRecenter += value; } remove { _handler.OnRecenter -= value; } } public UnityHotkeyHandler(float cooldownSeconds = 0.3f) : this((KeyCode)279, (KeyCode)278, null, cooldownSeconds) { } public UnityHotkeyHandler(KeyCode toggleKey, KeyCode recenterKey, float cooldownSeconds = 0.3f) : this(toggleKey, recenterKey, null, cooldownSeconds) { }//IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) public UnityHotkeyHandler(KeyCode toggleKey, KeyCode recenterKey, IHotkeyListener listener, float cooldownSeconds = 0.3f) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected I4, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected I4, but got Unknown //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown object obj = <>c.<>9__19_0; if (obj == null) { KeyDownCheck val = (int keyCode) => Input.GetKeyDown((KeyCode)keyCode); <>c.<>9__19_0 = val; obj = (object)val; } _handler = new HotkeyHandler((KeyDownCheck)obj, new TextInputActiveCheck(IsTextInputActive), listener, cooldownSeconds); _handler.SetToggleKey((int)toggleKey); _handler.SetRecenterKey((int)recenterKey); } public void SetToggleKey(KeyCode key) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected I4, but got Unknown _handler.SetToggleKey((int)key); } public void SetRecenterKey(KeyCode key) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected I4, but got Unknown _handler.SetRecenterKey((int)key); } public void Update() { _handler.Update(Time.time); } public bool Toggle() { return _handler.Toggle(); } public void ResetCounts() { _handler.ResetCounts(); } private static bool IsTextInputActive() { return GUIUtility.keyboardControl > 0; } } public static class UnitySmoothingHelper { public static Quaternion SmoothRotation(Quaternion current, Quaternion target, float smoothing) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) float num = SmoothingUtils.CalculateSmoothingFactor(smoothing, Time.deltaTime); return Quaternion.Slerp(current, target, num); } public static Vector3 SmoothVector3(Vector3 current, Vector3 target, float smoothing) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) float num = SmoothingUtils.CalculateSmoothingFactor(smoothing, Time.deltaTime); return Vector3.Lerp(current, target, num); } public static Vector2 SmoothVector2(Vector2 current, Vector2 target, float smoothing) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) float num = SmoothingUtils.CalculateSmoothingFactor(smoothing, Time.deltaTime); return Vector2.Lerp(current, target, num); } public static float SmoothFloat(float current, float target, float smoothing) { return SmoothingUtils.Smooth(current, target, smoothing, Time.deltaTime); } public static float GetSmoothingT(float smoothing) { return SmoothingUtils.CalculateSmoothingFactor(smoothing, Time.deltaTime); } } public static class UnityTypeExtensions { public static Quaternion ToUnity(this Quat4 q) { //IL_0000: 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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) return new Quaternion(q.X, q.Y, q.Z, q.W); } public static Quat4 ToQuat4(this Quaternion q) { //IL_0000: 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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) return new Quat4(q.x, q.y, q.z, q.w); } public static Vector3 ToUnity(this Vec3 v) { //IL_0000: 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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vector3(v.X, v.Y, v.Z); } public static Vec3 ToVec3(this Vector3 v) { //IL_0000: 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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vec3(v.x, v.y, v.z); } public static Vector3 ToEulerVector(this TrackingPose pose) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) return new Vector3(((TrackingPose)(ref pose)).Pitch, ((TrackingPose)(ref pose)).Yaw, ((TrackingPose)(ref pose)).Roll); } public static Vector3 Rotate(this Quat4 q, Vector3 v) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //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) return q.ToUnity() * v; } } } namespace CameraUnlock.Core.Unity.Aim { public class AimDecouplingState { private int _cachedIsActiveFrame = -1; private bool _cachedIsActive; public static AimDecouplingState Instance { get; set; } = new AimDecouplingState(); public bool Enabled { get; set; } = true; public float MinRotationThreshold { get; set; } = 0.5f; public Quaternion LastTrackingQuaternion { get; private set; } = Quaternion.identity; public Vector3 LastTrackingEuler { get; private set; } = Vector3.zero; public Func IsTrackingDataFresh { get; set; } public bool IsActive { get { int frameCount = Time.frameCount; if (_cachedIsActiveFrame == frameCount) { return _cachedIsActive; } _cachedIsActiveFrame = frameCount; _cachedIsActive = ComputeIsActive(); return _cachedIsActive; } } private bool ComputeIsActive() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) if (!Enabled) { return false; } if (IsTrackingDataFresh != null && !IsTrackingDataFresh()) { return false; } return Mathf.Abs(LastTrackingEuler.x) + Mathf.Abs(LastTrackingEuler.y) + Mathf.Abs(LastTrackingEuler.z) > MinRotationThreshold; } public void UpdateTracking(Quaternion trackingQuaternion, Vector3 trackingEuler) { //IL_0001: 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) LastTrackingQuaternion = trackingQuaternion; LastTrackingEuler = trackingEuler; } public void UpdateTracking(float pitch, float yaw, float roll) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) LastTrackingEuler = new Vector3(pitch, yaw, roll); LastTrackingQuaternion = Quaternion.Euler(pitch, yaw, roll); } public void Reset() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) LastTrackingQuaternion = Quaternion.identity; LastTrackingEuler = Vector3.zero; } public Vector3 GetAimDirection(Camera camera) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)camera == (Object)null) { return Vector3.forward; } Vector3 val = Quaternion.Inverse(LastTrackingQuaternion) * Vector3.forward; return ((Component)camera).transform.rotation * val; } public Vector2 GetScreenOffset(Camera camera) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //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_0032: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_0063: 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_0074: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)camera == (Object)null) { return Vector2.zero; } Vector3 aimDirection = GetAimDirection(camera); Vector3 val = ((Component)camera).transform.position + aimDirection * 10f; Vector3 val2 = camera.WorldToScreenPoint(val); float num = (float)Screen.width * 0.5f; float num2 = (float)Screen.height * 0.5f; if (val2.z > 0f) { return new Vector2(val2.x - num, val2.y - num2); } return UnityAimHelper.ClampToScreenEdge(aimDirection, camera, num, num2); } } }