using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using TrueCamera.Features; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace TrueCamera { internal sealed class ConfigurationManagerAttributes { public bool? ReadOnly; public bool? ShowRangeAsPercent; public int? Order; public bool? IsAdvanced; public string Category; public string Subcategory; public Action CustomDrawer; public bool? Browsable; public bool? HideSettingName; } [BepInPlugin("truecamera", "True Camera", "0.9.0")] public sealed class TrueCameraPlugin : BaseUnityPlugin { [CompilerGenerated] private sealed class d__9 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public TrueCameraPlugin <>4__this; private int 5__2; private bool 5__3; private MethodInfo 5__4; private Camera 5__5; private float 5__6; private Vector3 5__7; private bool 5__8; private int 5__9; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__9(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__4 = null; 5__5 = null; <>1__state = -2; } private bool MoveNext() { //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Expected O, but got Unknown //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_042d: Unknown result type (might be due to invalid IL or missing references) //IL_0436: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; TrueCameraPlugin trueCameraPlugin = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; 5__2 = 0; goto IL_0061; case 1: <>1__state = -1; goto IL_0061; case 2: <>1__state = -1; 5__9++; goto IL_0170; case 3: <>1__state = -1; 5__9++; goto IL_02c1; case 4: { <>1__state = -1; 5__9++; break; } IL_0061: if (5__2 < 600 && ((Object)(object)Player.m_localPlayer == (Object)null || ((Character)Player.m_localPlayer).IsDead())) { 5__2++; <>2__current = null; <>1__state = 1; return true; } 5__3 = false; 5__4 = ReflectionCache.GetMethod(typeof(Player), "TakeInput", Type.EmptyTypes); 5__9 = 0; goto IL_0170; IL_0180: 5__5 = Camera.main; 5__6 = (Object.op_Implicit((Object)(object)5__5) ? ((Component)5__5).transform.eulerAngles.y : 0f); 5__7 = (Object.op_Implicit((Object)(object)Player.m_localPlayer) ? ((Component)Player.m_localPlayer).transform.position : Vector3.zero); 5__8 = false; 5__9 = 0; goto IL_02c1; IL_02c1: if (5__9 < 300) { 5__5 = (Object.op_Implicit((Object)(object)5__5) ? 5__5 : Camera.main); float num2 = (Object.op_Implicit((Object)(object)5__5) ? ((Component)5__5).transform.eulerAngles.y : 5__6); Vector3 val = (Object.op_Implicit((Object)(object)Player.m_localPlayer) ? ((Component)Player.m_localPlayer).transform.position : 5__7); if (!(Mathf.Abs(Mathf.DeltaAngle(5__6, num2)) > 1f) && !(Vector3.Distance(5__7, val) > 0.1f)) { <>2__current = null; <>1__state = 3; return true; } 5__8 = true; } try { Suspended = true; if (trueCameraPlugin._harmony == null) { trueCameraPlugin._harmony = new Harmony("truecamera"); } trueCameraPlugin._harmony.UnpatchSelf(); trueCameraPlugin._harmony.PatchAll(Assembly.GetExecutingAssembly()); ManualLogSource log = Log; if (log != null) { log.LogInfo((object)"TrueCamera: patches applied, warming up..."); } } catch (Exception ex) { ManualLogSource log2 = Log; if (log2 != null) { log2.LogDebug((object)("ReEnableAfterRespawnCoroutine repatch failed: " + ex.Message)); } } 5__9 = 0; break; IL_0170: if (5__9 < 600) { if ((!Object.op_Implicit((Object)(object)Chat.instance) || !Chat.instance.HasFocus()) && !Console.IsVisible() && !InventoryGui.IsVisible() && !StoreGui.IsVisible() && !Menu.IsVisible() && !Minimap.IsOpen() && !Hud.IsPieceSelectionVisible() && (Object)(object)Player.m_localPlayer != (Object)null && 5__4 != null) { try { 5__3 = (bool)5__4.Invoke(Player.m_localPlayer, null); } catch { 5__3 = false; } if (5__3) { goto IL_0180; } } <>2__current = null; <>1__state = 2; return true; } goto IL_0180; } if (5__9 < 10) { <>2__current = null; <>1__state = 4; return true; } try { Camera main = Camera.main; float num3 = default(float); if (Object.op_Implicit((Object)(object)main) && Object.op_Implicit((Object)(object)ZoneSystem.instance) && ZoneSystem.instance.GetGroundHeight(((Component)main).transform.position, ref num3)) { Vector3 position = ((Component)main).transform.position; if (position.y < num3 - 0.5f) { Vector3 position2 = (Vector3)(Object.op_Implicit((Object)(object)Player.m_localPlayer) ? (((Component)Player.m_localPlayer).transform.position + Vector3.up * 1.6f) : new Vector3(position.x, num3 + 0.2f, position.z)); ((Component)main).transform.position = position2; } } CameraSettings_Patches.ApplyCameraConfig(); Suspended = false; ManualLogSource log3 = Log; if (log3 != null) { log3.LogInfo((object)("TrueCamera: re-enabled after respawn (input ready=" + 5__3 + ", moved=" + 5__8 + ")")); } } catch (Exception ex2) { ManualLogSource log4 = Log; if (log4 != null) { log4.LogDebug((object)("Warmup/apply config failed: " + ex2.Message)); } } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__10 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public TrueCameraPlugin <>4__this; private int 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__10(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown int num = <>1__state; TrueCameraPlugin trueCameraPlugin = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; 5__2 = 0; break; case 1: <>1__state = -1; 5__2++; break; } if (5__2 < 10) { <>2__current = null; <>1__state = 1; return true; } try { if (trueCameraPlugin._harmony == null) { trueCameraPlugin._harmony = new Harmony("truecamera"); } trueCameraPlugin._harmony.PatchAll(Assembly.GetExecutingAssembly()); Suspended = false; CameraSettings_Patches.ApplyCameraConfig(); } catch (Exception ex) { ManualLogSource log = Log; if (log != null) { log.LogDebug((object)("SuspendAndRestoreCoroutine repatch failed: " + ex.Message)); } } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public const string PluginGuid = "truecamera"; public const string PluginName = "True Camera"; public const string PluginVersion = "0.9.0"; internal static ManualLogSource Log; internal static ConfigEntry FoV_FP; internal static ConfigEntry FoV_TP; internal static ConfigEntry FoV_TP_Combat; internal static ConfigEntry FoV_TP_Vehicle; internal static ConfigEntry MaxDistance; internal static ConfigEntry MaxDistanceBoat; internal static ConfigEntry AlwaysFaceCamera; internal static ConfigEntry HideHUD; internal static ConfigEntry Camera_SideAngle; internal static ConfigEntry HideHUD_Hotkey; internal static ConfigEntry Hotkey_AngleLeft; internal static ConfigEntry Hotkey_AngleRight; internal static ConfigEntry ToggleBuildCameraHotkey; internal static ConfigEntry Hotkey_FovIncrease; internal static ConfigEntry Hotkey_FovDecrease; internal static ConfigEntry FP_Enabled; internal static ConfigEntry FP_Mode_NoBody; internal static ConfigEntry FP_Mode_NoHair; internal static ConfigEntry FP_Mode_NoHelmet; internal static ConfigEntry FP_HeadOffsetX; internal static ConfigEntry FP_HeadOffsetY; internal static ConfigEntry FP_HeadOffsetZ; internal static ConfigEntry FP_HeadOffsetMultiplier; internal static ConfigEntry FP_Rotate_LockNearShoulders; internal static ConfigEntry FP_Rotate_SnapRotate; internal static ConfigEntry FP_Rotate_ForceRotate; internal static ConfigEntry FP_MaxShoulderAngle; internal static ConfigEntry FP_ForceRotateSpeed; internal static ConfigEntry FP_FreeLookKey; internal static ConfigEntry FP_FreeLookHeightOffset; internal static ConfigEntry FP_StabilizerEnabled; internal static ConfigEntry FP_StabilizerTime; internal static ConfigEntry FP_StabilizerZeroRoll; internal static ConfigEntry FP_AimYawDriven; internal static ConfigEntry FP_ToggleHotkey; internal static ConfigEntry BuildCamera_MoveWorldSpace; internal static ConfigEntry BuildCamera_MoveSpeedMultiplier; internal static ConfigEntry BuildCamera_RangeMultiplier; internal static ConfigEntry BuildCamera_SphericalRadius; internal static ConfigEntry BuildCamera_RequireStation; internal static ConfigEntry BuildCamera_SmoothFly; internal static ConfigEntry BuildCamera_SmoothTime; internal static ConfigEntry BuildCamera_SmoothSpeedMultiplier; internal static ConfigEntry TP_Enabled; internal static ConfigEntry TP_ToggleHotkey; internal static ConfigEntry TP_HeightOffset; internal static ConfigEntry TP_SideOffset; internal static ConfigEntry TP_Vehicle_HeightOffset; internal static ConfigEntry TP_Vehicle_SideOffset; internal static ConfigEntry TP_HeadBobFromHead; internal static ConfigEntry TP_HeadBobStrength; internal static ConfigEntry TP_HeadBobVerticalOnly; internal static ConfigEntry TP_HeadBobSmoothing; internal static ConfigEntry TP_Combat_Enabled; internal static ConfigEntry TP_Combat_WhileWeaponDrawn; internal static ConfigEntry TP_Combat_HeightOffset; internal static ConfigEntry TP_Combat_SideOffset; internal static ConfigEntry TP_Combat_SearchRadius; internal static ConfigEntry TP_Combat_HoldTime; private Harmony _harmony; internal static bool Suspended; private Coroutine _suspendRoutine; internal static ConfigEntry DOF_Enabled; internal static ConfigEntry DOF_Autofocus; internal static ConfigEntry DOF_FocusDistance; internal static ConfigEntry DOF_BlurStrength; internal static ConfigEntry DOF_MaxBlurSize; internal static ConfigEntry DOF_InvertNear; internal static ConfigEntry DOF_FocusIncreaseHotkey; internal static ConfigEntry DOF_FocusDecreaseHotkey; internal static ConfigEntry DOF_ToggleAutofocusHotkey; internal static ConfigEntry DOF_ToggleEnabledHotkey; internal static ConfigEntry Camera_ModeTransition_Enable; internal static ConfigEntry Camera_ModeTransition_Time; internal static ConfigEntry Camera_CombatTransition_Time; internal static TrueCameraPlugin Instance { get; private set; } private static int PlatformPrefs_GetInt(string key, int def) { try { Type type = AccessTools.TypeByName("PlatformPrefs"); if (type != null) { MethodInfo methodInfo = AccessTools.Method(type, "GetInt", new Type[2] { typeof(string), typeof(int) }, (Type[])null); if (methodInfo != null) { object obj = methodInfo.Invoke(null, new object[2] { key, def }); int result = 0; bool flag; if (obj is int) { result = (int)obj; flag = true; } else { flag = false; } if (flag) { return result; } } } } catch { } return def; } private void Awake() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown //IL_0106: 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_0139: Expected O, but got Unknown //IL_0155: 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_0188: Expected O, but got Unknown //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Expected O, but got Unknown //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Expected O, but got Unknown //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Expected O, but got Unknown //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Expected O, but got Unknown //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Expected O, but got Unknown //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Expected O, but got Unknown //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Expected O, but got Unknown //IL_041c: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Expected O, but got Unknown //IL_0472: Unknown result type (might be due to invalid IL or missing references) //IL_047c: Expected O, but got Unknown //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_04c1: Unknown result type (might be due to invalid IL or missing references) //IL_04cb: Expected O, but got Unknown //IL_0512: Unknown result type (might be due to invalid IL or missing references) //IL_051c: Expected O, but got Unknown //IL_0556: Unknown result type (might be due to invalid IL or missing references) //IL_0560: Expected O, but got Unknown //IL_05ac: Unknown result type (might be due to invalid IL or missing references) //IL_05b6: Expected O, but got Unknown //IL_0602: Unknown result type (might be due to invalid IL or missing references) //IL_060c: Expected O, but got Unknown //IL_0658: Unknown result type (might be due to invalid IL or missing references) //IL_0662: Expected O, but got Unknown //IL_069c: Unknown result type (might be due to invalid IL or missing references) //IL_06a6: Expected O, but got Unknown //IL_06c2: Unknown result type (might be due to invalid IL or missing references) //IL_06eb: Unknown result type (might be due to invalid IL or missing references) //IL_06f5: Expected O, but got Unknown //IL_0711: Unknown result type (might be due to invalid IL or missing references) //IL_073a: Unknown result type (might be due to invalid IL or missing references) //IL_0744: Expected O, but got Unknown //IL_0760: Unknown result type (might be due to invalid IL or missing references) //IL_0789: Unknown result type (might be due to invalid IL or missing references) //IL_0793: Expected O, but got Unknown //IL_07af: Unknown result type (might be due to invalid IL or missing references) //IL_07d8: Unknown result type (might be due to invalid IL or missing references) //IL_07e2: Expected O, but got Unknown //IL_07fe: Unknown result type (might be due to invalid IL or missing references) //IL_0827: Unknown result type (might be due to invalid IL or missing references) //IL_0831: Expected O, but got Unknown //IL_084d: Unknown result type (might be due to invalid IL or missing references) //IL_0876: Unknown result type (might be due to invalid IL or missing references) //IL_0880: Expected O, but got Unknown //IL_089c: Unknown result type (might be due to invalid IL or missing references) //IL_08c5: Unknown result type (might be due to invalid IL or missing references) //IL_08cf: Expected O, but got Unknown //IL_0909: Unknown result type (might be due to invalid IL or missing references) //IL_0913: Expected O, but got Unknown //IL_095f: Unknown result type (might be due to invalid IL or missing references) //IL_0969: Expected O, but got Unknown //IL_09b5: Unknown result type (might be due to invalid IL or missing references) //IL_09bf: Expected O, but got Unknown //IL_0a0b: Unknown result type (might be due to invalid IL or missing references) //IL_0a15: Expected O, but got Unknown //IL_0a4f: Unknown result type (might be due to invalid IL or missing references) //IL_0a59: Expected O, but got Unknown //IL_0a93: Unknown result type (might be due to invalid IL or missing references) //IL_0a9d: Expected O, but got Unknown //IL_0ae9: Unknown result type (might be due to invalid IL or missing references) //IL_0af3: Expected O, but got Unknown //IL_0b3f: Unknown result type (might be due to invalid IL or missing references) //IL_0b49: Expected O, but got Unknown //IL_0b83: Unknown result type (might be due to invalid IL or missing references) //IL_0b8d: Expected O, but got Unknown //IL_0bc7: Unknown result type (might be due to invalid IL or missing references) //IL_0bd1: Expected O, but got Unknown //IL_0c0b: Unknown result type (might be due to invalid IL or missing references) //IL_0c15: Expected O, but got Unknown //IL_0c4f: Unknown result type (might be due to invalid IL or missing references) //IL_0c59: Expected O, but got Unknown //IL_0ca5: Unknown result type (might be due to invalid IL or missing references) //IL_0caf: Expected O, but got Unknown //IL_0cfb: Unknown result type (might be due to invalid IL or missing references) //IL_0d05: Expected O, but got Unknown //IL_0d24: Unknown result type (might be due to invalid IL or missing references) //IL_0d4d: Unknown result type (might be due to invalid IL or missing references) //IL_0d57: Expected O, but got Unknown //IL_0da3: Unknown result type (might be due to invalid IL or missing references) //IL_0dad: Expected O, but got Unknown //IL_0de7: Unknown result type (might be due to invalid IL or missing references) //IL_0df1: Expected O, but got Unknown //IL_0e0c: Unknown result type (might be due to invalid IL or missing references) //IL_0e35: Unknown result type (might be due to invalid IL or missing references) //IL_0e3f: Expected O, but got Unknown //IL_0e79: Unknown result type (might be due to invalid IL or missing references) //IL_0e83: Expected O, but got Unknown //IL_0ebd: Unknown result type (might be due to invalid IL or missing references) //IL_0ec7: Expected O, but got Unknown //IL_0f01: Unknown result type (might be due to invalid IL or missing references) //IL_0f0b: Expected O, but got Unknown //IL_0f57: Unknown result type (might be due to invalid IL or missing references) //IL_0f61: Expected O, but got Unknown //IL_0fad: Unknown result type (might be due to invalid IL or missing references) //IL_0fb7: Expected O, but got Unknown //IL_1003: Unknown result type (might be due to invalid IL or missing references) //IL_100d: Expected O, but got Unknown //IL_1059: Unknown result type (might be due to invalid IL or missing references) //IL_1063: Expected O, but got Unknown //IL_109d: Unknown result type (might be due to invalid IL or missing references) //IL_10a7: Expected O, but got Unknown //IL_10f3: Unknown result type (might be due to invalid IL or missing references) //IL_10fd: Expected O, but got Unknown //IL_1137: Unknown result type (might be due to invalid IL or missing references) //IL_1141: Expected O, but got Unknown //IL_117b: Unknown result type (might be due to invalid IL or missing references) //IL_1185: Expected O, but got Unknown //IL_11a4: Unknown result type (might be due to invalid IL or missing references) //IL_11cd: Unknown result type (might be due to invalid IL or missing references) //IL_11d7: Expected O, but got Unknown //IL_1223: Unknown result type (might be due to invalid IL or missing references) //IL_122d: Expected O, but got Unknown //IL_1279: Unknown result type (might be due to invalid IL or missing references) //IL_1283: Expected O, but got Unknown //IL_12cf: Unknown result type (might be due to invalid IL or missing references) //IL_12d9: Expected O, but got Unknown //IL_1325: Unknown result type (might be due to invalid IL or missing references) //IL_132f: Expected O, but got Unknown //IL_1369: Unknown result type (might be due to invalid IL or missing references) //IL_1373: Expected O, but got Unknown //IL_13bf: Unknown result type (might be due to invalid IL or missing references) //IL_13c9: Expected O, but got Unknown //IL_1403: Unknown result type (might be due to invalid IL or missing references) //IL_140d: Expected O, but got Unknown //IL_1459: Unknown result type (might be due to invalid IL or missing references) //IL_1463: Expected O, but got Unknown //IL_149d: Unknown result type (might be due to invalid IL or missing references) //IL_14a7: Expected O, but got Unknown //IL_14e1: Unknown result type (might be due to invalid IL or missing references) //IL_14eb: Expected O, but got Unknown //IL_1537: Unknown result type (might be due to invalid IL or missing references) //IL_1541: Expected O, but got Unknown //IL_158d: Unknown result type (might be due to invalid IL or missing references) //IL_1597: Expected O, but got Unknown //IL_15e3: Unknown result type (might be due to invalid IL or missing references) //IL_15ed: Expected O, but got Unknown //IL_1639: Unknown result type (might be due to invalid IL or missing references) //IL_1643: Expected O, but got Unknown //IL_16c9: Unknown result type (might be due to invalid IL or missing references) //IL_16d3: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; AlwaysFaceCamera = ((BaseUnityPlugin)this).Config.Bind("Camera", "AlwaysFaceCamera", false, new ConfigDescription("Player character always faces crosshair direction when a weapon is readied.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 1000 } })); HideHUD = ((BaseUnityPlugin)this).Config.Bind("Camera", "HideHUD", false, new ConfigDescription("Hide full HUD (crosshair, hotbar, minimap, etc)", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 999 } })); Camera_SideAngle = ((BaseUnityPlugin)this).Config.Bind("Camera", "SideAngle", 0f, new ConfigDescription("Horizontal camera yaw offset (degrees)", (AcceptableValueBase)(object)new AcceptableValueRange(-180f, 180f), new object[1] { new ConfigurationManagerAttributes { Order = 998 } })); Hotkey_AngleLeft = ((BaseUnityPlugin)this).Config.Bind("Hotkeys", "AngleLeft", new KeyboardShortcut((KeyCode)59, Array.Empty()), new ConfigDescription("Rotate camera left (S-curve speed)", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 980 } })); Hotkey_AngleRight = ((BaseUnityPlugin)this).Config.Bind("Hotkeys", "AngleRight", new KeyboardShortcut((KeyCode)39, Array.Empty()), new ConfigDescription("Rotate camera right (S-curve speed)", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 979 } })); FoV_FP = ((BaseUnityPlugin)this).Config.Bind("Camera.FOV", "FP", 65f, new ConfigDescription("First Person FOV.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 120f), new object[1] { new ConfigurationManagerAttributes { Order = 904 } })); FoV_TP = ((BaseUnityPlugin)this).Config.Bind("Camera.FOV", "TP", 65f, new ConfigDescription("Third Person (on foot) FOV.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 120f), new object[1] { new ConfigurationManagerAttributes { Order = 903 } })); FoV_TP_Combat = ((BaseUnityPlugin)this).Config.Bind("Camera.FOV", "TP_Combat", 65f, new ConfigDescription("Third Person Combat FOV.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 120f), new object[1] { new ConfigurationManagerAttributes { Order = 902 } })); FoV_TP_Vehicle = ((BaseUnityPlugin)this).Config.Bind("Camera.FOV", "TP_Vehicle", 65f, new ConfigDescription("Third Person Vehicle FOV.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 120f), new object[1] { new ConfigurationManagerAttributes { Order = 901 } })); MaxDistance = ((BaseUnityPlugin)this).Config.Bind("Camera", "MaxDistance", 6f, new ConfigDescription("Max camera zoom distance on foot.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 120f), new object[1] { new ConfigurationManagerAttributes { Order = 895 } })); MaxDistanceBoat = ((BaseUnityPlugin)this).Config.Bind("Camera", "MaxDistanceBoat", 12f, new ConfigDescription("Max camera zoom distance on boat.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 120f), new object[1] { new ConfigurationManagerAttributes { Order = 890 } })); Camera_ModeTransition_Enable = ((BaseUnityPlugin)this).Config.Bind("Camera", "ModeTransitionEnable", true, new ConfigDescription("Enable S-curve position transition when switching FP/TP/TP Combat/TP Vehicle.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 870 } })); Camera_ModeTransition_Time = ((BaseUnityPlugin)this).Config.Bind("Camera", "ModeTransitionTime", 0.35f, new ConfigDescription("Duration (seconds) of S-curve transition between camera modes.", (AcceptableValueBase)(object)new AcceptableValueRange(0.05f, 1.5f), new object[1] { new ConfigurationManagerAttributes { Order = 869 } })); Camera_CombatTransition_Time = ((BaseUnityPlugin)this).Config.Bind("Camera", "CombatTransitionTime", 0.45f, new ConfigDescription("Duration (seconds) for S-curve when entering/leaving Combat.", (AcceptableValueBase)(object)new AcceptableValueRange(0.05f, 2f), new object[1] { new ConfigurationManagerAttributes { Order = 868 } })); HideHUD_Hotkey = ((BaseUnityPlugin)this).Config.Bind("Camera", "HideHUD_Hotkey", new KeyboardShortcut((KeyCode)104, Array.Empty()), new ConfigDescription("Toggle HideHUD on/off", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 997 } })); DOF_Enabled = ((BaseUnityPlugin)this).Config.Bind("DOF", "Enabled", PlatformPrefs_GetInt("DOF", 1) == 1, new ConfigDescription("Enable Depth of Field post-effect (game setting DOF)", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 1000 } })); DOF_Autofocus = ((BaseUnityPlugin)this).Config.Bind("DOF", "Autofocus", true, new ConfigDescription("Auto-focus by raycast to target", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 995 } })); DOF_FocusDistance = ((BaseUnityPlugin)this).Config.Bind("DOF", "FocusDistance", 50f, new ConfigDescription("Manual focus distance when Autofocus is disabled (meters)", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 300f), new object[1] { new ConfigurationManagerAttributes { Order = 990 } })); DOF_BlurStrength = ((BaseUnityPlugin)this).Config.Bind("DOF", "BlurStrength", 1f, new ConfigDescription("Blur strength multiplier (applies to aperture/blur size parameters)", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 2f), new object[1] { new ConfigurationManagerAttributes { Order = 975 } })); DOF_MaxBlurSize = ((BaseUnityPlugin)this).Config.Bind("DOF", "MaxBlurSize", 2f, new ConfigDescription("Max blur size for DepthOfField effect", (AcceptableValueBase)(object)new AcceptableValueRange(0.5f, 4f), new object[1] { new ConfigurationManagerAttributes { Order = 970 } })); DOF_InvertNear = ((BaseUnityPlugin)this).Config.Bind("DOF", "InvertNear", false, new ConfigDescription("Invert focus: blur near and keep far in focus", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 969 } })); DOF_FocusIncreaseHotkey = ((BaseUnityPlugin)this).Config.Bind("DOF.Hotkeys", "FocusIncrease", new KeyboardShortcut((KeyCode)93, Array.Empty()), new ConfigDescription("Increase manual focus distance", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 960 } })); DOF_FocusDecreaseHotkey = ((BaseUnityPlugin)this).Config.Bind("DOF.Hotkeys", "FocusDecrease", new KeyboardShortcut((KeyCode)91, Array.Empty()), new ConfigDescription("Decrease manual focus distance", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 959 } })); DOF_ToggleAutofocusHotkey = ((BaseUnityPlugin)this).Config.Bind("DOF.Hotkeys", "ToggleAutofocus", new KeyboardShortcut((KeyCode)92, Array.Empty()), new ConfigDescription("Toggle DOF Autofocus on/off", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 958 } })); DOF_ToggleEnabledHotkey = ((BaseUnityPlugin)this).Config.Bind("DOF.Hotkeys", "ToggleEnabled", new KeyboardShortcut((KeyCode)39, Array.Empty()), new ConfigDescription("Toggle DOF effect on/off", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 957 } })); Hotkey_FovDecrease = ((BaseUnityPlugin)this).Config.Bind("Hotkeys", "FovDecrease", new KeyboardShortcut((KeyCode)45, Array.Empty()), new ConfigDescription("Decrease FOV", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 1000 } })); Hotkey_FovIncrease = ((BaseUnityPlugin)this).Config.Bind("Hotkeys", "FovIncrease", new KeyboardShortcut((KeyCode)61, Array.Empty()), new ConfigDescription("Increase FOV", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 995 } })); ToggleBuildCameraHotkey = ((BaseUnityPlugin)this).Config.Bind("BuildCamera", "ToggleHotkey", new KeyboardShortcut((KeyCode)98, Array.Empty()), new ConfigDescription("Toggle Build Camera mode", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 1000 } })); BuildCamera_MoveWorldSpace = ((BaseUnityPlugin)this).Config.Bind("BuildCamera", "MoveWorldSpace", false, new ConfigDescription("Move independent from camera orientation (world space). If false, move relative to camera.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 995 } })); BuildCamera_MoveSpeedMultiplier = ((BaseUnityPlugin)this).Config.Bind("BuildCamera", "MoveSpeedMultiplier", 3f, new ConfigDescription("Camera pan speed multiplier.", (AcceptableValueBase)(object)new AcceptableValueRange(0.5f, 10f), new object[1] { new ConfigurationManagerAttributes { Order = 900 } })); BuildCamera_RangeMultiplier = ((BaseUnityPlugin)this).Config.Bind("BuildCamera", "RangeMultiplier", 1f, new ConfigDescription("Max distance from build station.", (AcceptableValueBase)(object)new AcceptableValueRange(0.5f, 5f), new object[1] { new ConfigurationManagerAttributes { Order = 895 } })); BuildCamera_SphericalRadius = ((BaseUnityPlugin)this).Config.Bind("BuildCamera", "SphericalRadius", 30f, new ConfigDescription("Spherical radius around player within which camera can move in Build Mode (meters).", (AcceptableValueBase)(object)new AcceptableValueRange(5f, 120f), new object[1] { new ConfigurationManagerAttributes { Order = 890 } })); BuildCamera_RequireStation = ((BaseUnityPlugin)this).Config.Bind("BuildCamera", "RequireStation", false, new ConfigDescription("If true, clamp camera to nearest crafting station range; if false, build camera works anywhere.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 985 } })); BuildCamera_SmoothFly = ((BaseUnityPlugin)this).Config.Bind("BuildCamera", "SmoothFly", true, new ConfigDescription("Enable smooth flight (interpolated position/rotation)", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 980 } })); BuildCamera_SmoothTime = ((BaseUnityPlugin)this).Config.Bind("BuildCamera", "SmoothTime", 0.12f, new ConfigDescription("Smoothing time (seconds) for build camera flight", (AcceptableValueBase)(object)new AcceptableValueRange(0.01f, 1f), new object[1] { new ConfigurationManagerAttributes { Order = 975 } })); BuildCamera_SmoothSpeedMultiplier = ((BaseUnityPlugin)this).Config.Bind("BuildCamera", "SmoothSpeedMultiplier", 3f, new ConfigDescription("Speed multiplier used when SmoothFly is enabled (compensate smoothing slow-down)", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 10f), new object[1] { new ConfigurationManagerAttributes { Order = 974 } })); FP_Enabled = ((BaseUnityPlugin)this).Config.Bind("FirstPerson", "Enabled", true, new ConfigDescription("Enable first person camera.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 1000 } })); FP_Rotate_LockNearShoulders = ((BaseUnityPlugin)this).Config.Bind("FirstPerson.Rotation", "LockNearShoulders", true, new ConfigDescription("Clamp body/camera yaw within shoulder angle", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 990 } })); FP_Rotate_SnapRotate = ((BaseUnityPlugin)this).Config.Bind("FirstPerson.Rotation", "SnapRotate", false, new ConfigDescription("Snap body to camera yaw when exceeding shoulder angle", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 985 } })); FP_Rotate_ForceRotate = ((BaseUnityPlugin)this).Config.Bind("FirstPerson.Rotation", "ForceRotate", false, new ConfigDescription("Continuously rotate body towards camera yaw", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 980 } })); FP_MaxShoulderAngle = ((BaseUnityPlugin)this).Config.Bind("FirstPerson.Rotation", "MaxShoulderAngle", 80f, new ConfigDescription("Max shoulder yaw angle in degrees", (AcceptableValueBase)(object)new AcceptableValueRange(10f, 120f), new object[1] { new ConfigurationManagerAttributes { Order = 900 } })); FP_ForceRotateSpeed = ((BaseUnityPlugin)this).Config.Bind("FirstPerson.Rotation", "ForceRotateSpeed", 180f, new ConfigDescription("Degrees/second for forced rotation", (AcceptableValueBase)(object)new AcceptableValueRange(30f, 720f), new object[1] { new ConfigurationManagerAttributes { Order = 895 } })); FP_FreeLookKey = ((BaseUnityPlugin)this).Config.Bind("FirstPerson.FreeLook", "Key", new KeyboardShortcut((KeyCode)308, Array.Empty()), new ConfigDescription("Hold to free look without rotating body (ARMA-style)", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 970 } })); FP_FreeLookHeightOffset = ((BaseUnityPlugin)this).Config.Bind("FirstPerson.FreeLook", "HeightOffset", 0.1f, new ConfigDescription("Vertical offset above anchor while free looking (meters)", (AcceptableValueBase)(object)new AcceptableValueRange(-0.5f, 0.5f), new object[1] { new ConfigurationManagerAttributes { Order = 880 } })); FP_AimYawDriven = ((BaseUnityPlugin)this).Config.Bind("FirstPerson", "YawDriven", true, new ConfigDescription("Use 360° yaw/pitch driven by mouse for FP (cam rotation independent of head animations)", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 995 } })); FP_ToggleHotkey = ((BaseUnityPlugin)this).Config.Bind("FirstPerson", "ToggleHotkey", new KeyboardShortcut((KeyCode)0, Array.Empty()), new ConfigDescription("Toggle First Person mode", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 990 } })); FP_Mode_NoHair = ((BaseUnityPlugin)this).Config.Bind("FirstPerson", "NoHair", false, new ConfigDescription("Hide hair/beard (local only)", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 985 } })); FP_Mode_NoHelmet = ((BaseUnityPlugin)this).Config.Bind("FirstPerson", "NoHelmet", false, new ConfigDescription("Hide helmet (local only)", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 980 } })); FP_Mode_NoBody = ((BaseUnityPlugin)this).Config.Bind("FirstPerson", "NoBody", false, new ConfigDescription("Hide body and hand items (local only)", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 975 } })); FP_HeadOffsetMultiplier = ((BaseUnityPlugin)this).Config.Bind("FirstPerson", "HeadLocalOffsetMultiplier", 0.4f, new ConfigDescription("Sensitivity multiplier for head offsets (use smaller to move slower)", (AcceptableValueBase)(object)new AcceptableValueRange(0.001f, 2f), new object[1] { new ConfigurationManagerAttributes { Order = 900 } })); FP_HeadOffsetX = ((BaseUnityPlugin)this).Config.Bind("FirstPerson", "HeadLocalOffsetX", 0f, new ConfigDescription("Head local offset X (right + / left -)", (AcceptableValueBase)(object)new AcceptableValueRange(-5f, 5f), new object[1] { new ConfigurationManagerAttributes { Order = 895 } })); FP_HeadOffsetY = ((BaseUnityPlugin)this).Config.Bind("FirstPerson", "HeadLocalOffsetY", 0.4f, new ConfigDescription("Head local offset Y (up + / down -)", (AcceptableValueBase)(object)new AcceptableValueRange(-5f, 5f), new object[1] { new ConfigurationManagerAttributes { Order = 890 } })); FP_HeadOffsetZ = ((BaseUnityPlugin)this).Config.Bind("FirstPerson", "HeadLocalOffsetZ", 0.3f, new ConfigDescription("Head local offset Z (forward + / backward -)", (AcceptableValueBase)(object)new AcceptableValueRange(-5f, 5f), new object[1] { new ConfigurationManagerAttributes { Order = 885 } })); FP_StabilizerEnabled = ((BaseUnityPlugin)this).Config.Bind("FirstPerson.NonJawDriven", "StabilizerEnabled", false, new ConfigDescription("Non Jaw Driven Options: enable camera rotation smoothing when YawDriven is off", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 860 } })); FP_StabilizerTime = ((BaseUnityPlugin)this).Config.Bind("FirstPerson.NonJawDriven", "StabilizerLerpTime", 0.06f, new ConfigDescription("Time constant (seconds) for rotation smoothing (0 = off)", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 0.5f), new object[1] { new ConfigurationManagerAttributes { Order = 855 } })); FP_StabilizerZeroRoll = ((BaseUnityPlugin)this).Config.Bind("FirstPerson.NonJawDriven", "ZeroRoll", true, new ConfigDescription("Zero out camera roll from head when YawDriven is off", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 850 } })); TP_Enabled = ((BaseUnityPlugin)this).Config.Bind("ThirdPerson", "Enabled", true, new ConfigDescription("Enable third person custom offsets.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 1000 } })); TP_ToggleHotkey = ((BaseUnityPlugin)this).Config.Bind("ThirdPerson", "ToggleHotkey", new KeyboardShortcut((KeyCode)271, Array.Empty()), new ConfigDescription("Toggle Third Person mode (custom offsets)", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 995 } })); TP_HeightOffset = ((BaseUnityPlugin)this).Config.Bind("ThirdPerson", "HeightOffset", 0f, new ConfigDescription("Vertical offset (meters).", (AcceptableValueBase)(object)new AcceptableValueRange(-5f, 5f), new object[1] { new ConfigurationManagerAttributes { Order = 900 } })); TP_SideOffset = ((BaseUnityPlugin)this).Config.Bind("ThirdPerson", "SideOffset", 0f, new ConfigDescription("Horizontal offset (meters). Positive moves camera to the right.", (AcceptableValueBase)(object)new AcceptableValueRange(-5f, 5f), new object[1] { new ConfigurationManagerAttributes { Order = 895 } })); TP_Vehicle_HeightOffset = ((BaseUnityPlugin)this).Config.Bind("ThirdPersonVehicle", "HeightOffset", 0.2f, new ConfigDescription("Vertical offset in vehicles (meters).", (AcceptableValueBase)(object)new AcceptableValueRange(-5f, 5f), new object[1] { new ConfigurationManagerAttributes { Order = 890 } })); TP_Vehicle_SideOffset = ((BaseUnityPlugin)this).Config.Bind("ThirdPersonVehicle", "SideOffset", 0f, new ConfigDescription("Horizontal offset in vehicles (meters).", (AcceptableValueBase)(object)new AcceptableValueRange(-5f, 5f), new object[1] { new ConfigurationManagerAttributes { Order = 885 } })); TP_HeadBobFromHead = ((BaseUnityPlugin)this).Config.Bind("ThirdPerson", "HeadBobFromHead", false, new ConfigDescription("Add subtle head animation bobbing to third-person camera (position-only add-on)", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 880 } })); TP_HeadBobStrength = ((BaseUnityPlugin)this).Config.Bind("ThirdPerson", "HeadBobStrength", 1f, new ConfigDescription("Head bob strength (0..1.5)", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1.5f), new object[1] { new ConfigurationManagerAttributes { Order = 875 } })); TP_HeadBobVerticalOnly = ((BaseUnityPlugin)this).Config.Bind("ThirdPerson", "HeadBobVerticalOnly", true, new ConfigDescription("Use only vertical component for head bob", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 874 } })); TP_HeadBobSmoothing = ((BaseUnityPlugin)this).Config.Bind("ThirdPerson", "HeadBobSmoothing", 0.08f, new ConfigDescription("Smoothing time (seconds) for bobbing delta", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 0.5f), new object[1] { new ConfigurationManagerAttributes { Order = 873 } })); TP_Combat_Enabled = ((BaseUnityPlugin)this).Config.Bind("ThirdPerson.Combat", "Enabled", true, new ConfigDescription("Enable Combat stance offsets when enemies are alerted or weapon is drawn.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 1000 } })); TP_Combat_WhileWeaponDrawn = ((BaseUnityPlugin)this).Config.Bind("ThirdPerson.Combat", "WhileWeaponDrawn", true, new ConfigDescription("Also activate Combat stance if a weapon is actively equipped.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 995 } })); TP_Combat_HeightOffset = ((BaseUnityPlugin)this).Config.Bind("ThirdPerson.Combat", "HeightOffset", 0f, new ConfigDescription("Combat stance vertical offset (meters)", (AcceptableValueBase)(object)new AcceptableValueRange(-5f, 5f), new object[1] { new ConfigurationManagerAttributes { Order = 900 } })); TP_Combat_SideOffset = ((BaseUnityPlugin)this).Config.Bind("ThirdPerson.Combat", "SideOffset", 0f, new ConfigDescription("Combat stance horizontal offset (meters). Positive moves camera to the right.", (AcceptableValueBase)(object)new AcceptableValueRange(-5f, 5f), new object[1] { new ConfigurationManagerAttributes { Order = 895 } })); TP_Combat_SearchRadius = ((BaseUnityPlugin)this).Config.Bind("ThirdPerson.Combat", "SearchRadius", 25f, new ConfigDescription("Radius to look for alerted enemies targeting the player (meters). 0 to disable scanning and rely only on alerts.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 100f), new object[1] { new ConfigurationManagerAttributes { Order = 880 } })); TP_Combat_HoldTime = ((BaseUnityPlugin)this).Config.Bind("ThirdPerson.Combat", "HoldTime", 4f, new ConfigDescription("Time in seconds to keep Combat stance after the last alert/sighting.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 15f), new object[1] { new ConfigurationManagerAttributes { Order = 875 } })); MaxDistance.SettingChanged += delegate { CameraSettings_Patches.ApplyCameraConfig(); }; MaxDistanceBoat.SettingChanged += delegate { CameraSettings_Patches.ApplyCameraConfig(); }; AlwaysFaceCamera.SettingChanged += delegate { CameraSettings_Patches.ApplyCameraConfig(); }; _harmony = new Harmony("truecamera"); _harmony.PatchAll(Assembly.GetExecutingAssembly()); } private void OnDestroy() { try { if (_harmony != null) { _harmony.UnpatchSelf(); } } catch { } ((BaseUnityPlugin)this).Config.Save(); } internal static void Restore() { if ((Object)(object)Instance == (Object)null || Suspended) { return; } Suspended = true; ManualLogSource log = Log; if (log != null) { log.LogInfo((object)"TrueCamera: Restore invoked — suspending and unpatching"); } Instance.SafeCleanupVisuals(); try { Harmony harmony = Instance._harmony; if (harmony != null) { harmony.UnpatchSelf(); } } catch { } if (Instance._suspendRoutine != null) { ((MonoBehaviour)Instance).StopCoroutine(Instance._suspendRoutine); } Instance._suspendRoutine = ((MonoBehaviour)Instance).StartCoroutine(Instance.SuspendAndRestoreCoroutine()); } internal static void ScheduleReenableAfterRespawn() { try { if (!((Object)(object)Instance == (Object)null)) { ((MonoBehaviour)Instance).StartCoroutine(Instance.ReEnableAfterRespawnCoroutine()); ManualLogSource log = Log; if (log != null) { log.LogInfo((object)"TrueCamera: OnRespawn detected, scheduling re-enable"); } } } catch { } } [IteratorStateMachine(typeof(d__9))] private IEnumerator ReEnableAfterRespawnCoroutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__9(0) { <>4__this = this }; } [IteratorStateMachine(typeof(d__10))] private IEnumerator SuspendAndRestoreCoroutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__10(0) { <>4__this = this }; } private void SafeCleanupVisuals() { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_00a5: 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_00ba: 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_00ec: Unknown result type (might be due to invalid IL or missing references) try { Camera main = Camera.main; if (Object.op_Implicit((Object)(object)main)) { if (main.nearClipPlane < 0.01f) { main.nearClipPlane = 0.3f; } CameraLocalCuller component = ((Component)main).GetComponent(); if (Object.op_Implicit((Object)(object)component)) { component.ForceRestore(); } NativeCullingController component2 = ((Component)main).GetComponent(); if (Object.op_Implicit((Object)(object)component2)) { component2.RestoreAll(); } try { float num = default(float); if (Object.op_Implicit((Object)(object)ZoneSystem.instance) && ZoneSystem.instance.GetGroundHeight(((Component)main).transform.position, ref num)) { Vector3 position = ((Component)main).transform.position; if (position.y < num - 0.1f) { Vector3 position2 = (Vector3)(Object.op_Implicit((Object)(object)Player.m_localPlayer) ? (((Component)Player.m_localPlayer).transform.position + Vector3.up * 1.8f) : new Vector3(position.x, num + 0.2f, position.z)); ((Component)main).transform.position = position2; } } } catch { } } if (Object.op_Implicit((Object)(object)Hud.instance)) { Hud.instance.m_userHidden = false; } ModeManager.OnModeDisabled("Build"); try { CameraViewModes.ResetState(); } catch { } } catch { } } } } namespace TrueCamera.Features { [HarmonyPatch] internal static class BuildCamera_EnableDisable { private static bool _enabled; private static float _yaw; private static float _pitch; private static Vector3 _posVel; private static Vector3 _targetPos; private static Quaternion _targetRot; private static bool _boneLockActive; private static Transform _boneLock; private static Vector3 _boneLockLocalOffset; private static Quaternion _boneLockLocalRotation = Quaternion.identity; private static bool _bonePreviewActive; private static Action _setVisible; private static Character _setVisibleOwner; public static bool Enabled => _enabled; internal static bool BoneDrivenActive => _boneLockActive; [HarmonyPostfix] [HarmonyPatch(typeof(Player), "SetLocalPlayer")] private static void Initialize() { //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) _enabled = false; _boneLockActive = false; _boneLock = null; _boneLockLocalRotation = Quaternion.identity; _bonePreviewActive = false; } internal static void Toggle(Player player) { //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: 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) //IL_00d9: 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) if (!Object.op_Implicit((Object)(object)player)) { return; } _enabled = !_enabled; if (_enabled) { ModeManager.DisableAllExcept("Build"); CameraViewModes.ResetState(); Transform val = (Object.op_Implicit((Object)(object)GameCamera.instance) ? ((Component)GameCamera.instance).transform : ((Object.op_Implicit((Object)(object)player) && Object.op_Implicit((Object)(object)((Character)player).m_eye)) ? ((Component)((Character)player).m_eye).transform : null)); if (!Object.op_Implicit((Object)(object)val)) { val = ((Component)player).transform; } Quaternion rotation = val.rotation; Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles; float num = eulerAngles.x; if (num > 180f) { num -= 360f; } _pitch = Mathf.Clamp(num, -89f, 89f); _yaw = eulerAngles.y; _posVel = Vector3.zero; _targetPos = val.position; _targetRot = val.rotation; ((Character)player).Message((MessageType)2, "Build Camera enabled.", 0, (Sprite)null); } else { _boneLockActive = false; _boneLock = null; _boneLockLocalRotation = Quaternion.identity; _bonePreviewActive = false; ModeManager.OnModeDisabled("Build"); ((Character)player).Message((MessageType)2, "Build Camera disabled.", 0, (Sprite)null); } } internal static bool ExitBoneDrivenMode(Player player) { //IL_001c: 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) if (!_enabled || !_boneLockActive) { return false; } _boneLockActive = false; _boneLock = null; _boneLockLocalRotation = Quaternion.identity; _bonePreviewActive = false; if (Object.op_Implicit((Object)(object)player)) { ((Character)player).Message((MessageType)2, "BoneDriven mode disabled (Build Camera).", 0, (Sprite)null); } return true; } internal static Quaternion UpdateView(float dt) { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) _yaw += PlayerController.m_mouseSens * Input.GetAxis("Mouse X") + InputCompat.GetJoyRightStickX(abs: true) * 110f * dt; float num = (PlayerController.m_invertMouse ? (-1f) : 1f); _pitch = Mathf.Clamp(_pitch - num * (PlayerController.m_mouseSens * Input.GetAxis("Mouse Y") - InputCompat.GetJoyRightStickY(abs: true) * 110f * dt), -89f, 89f); return Quaternion.Euler(0f, _yaw, 0f) * Quaternion.Euler(_pitch, 0f, 0f); } private static void UpdateBoneDrivenPlayerTurn(Player player, float dt) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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) if (Object.op_Implicit((Object)(object)player)) { float num = PlayerController.m_mouseSens * Input.GetAxis("Mouse X") + InputCompat.GetJoyRightStickX(abs: true) * 110f * dt; if (!(Mathf.Abs(num) <= 0.0001f)) { Quaternion rotation = ((Component)player).transform.rotation; float num2 = ((Quaternion)(ref rotation)).eulerAngles.y + num; ((Component)player).transform.rotation = Quaternion.Euler(0f, num2, 0f); } } } internal static Vector3 UntransformedMove(float dt) { //IL_0000: 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_0017: 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_002a: 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_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_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_004d: 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_005b: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: 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) //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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.zero; Player localPlayer = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)localPlayer)) { return val; } if (InputCompat.GetButton("Left")) { val -= Vector3.right; } if (InputCompat.GetButton("Right")) { val += Vector3.right; } if (InputCompat.GetButton("Forward")) { val += Vector3.forward; } if (InputCompat.GetButton("Backward")) { val -= Vector3.forward; } if (InputCompat.GetButton("Jump") || InputCompat.GetButtonDown("JoyJump")) { val += Vector3.up; } if (InputCompat.GetButton("Crouch") || InputCompat.GetButtonDown("JoyCrouch")) { val -= Vector3.up; } ((Vector3)(ref val)).Normalize(); val += Vector3.right * InputCompat.GetJoyLeftStickX(abs: false); val += -Vector3.forward * InputCompat.GetJoyLeftStickY(abs: true); float num = (InputCompat.GetButton("Run") ? ((Character)localPlayer).m_runSpeed : ((Character)localPlayer).m_walkSpeed); return val * (dt * num * TrueCameraPlugin.BuildCamera_MoveSpeedMultiplier.Value); } internal static void ClampToPlayerSphere(GameCamera cam) { //IL_0025: 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_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_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_004f: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (Object.op_Implicit((Object)(object)localPlayer)) { float value = TrueCameraPlugin.BuildCamera_SphericalRadius.Value; Vector3 position = ((Component)localPlayer).transform.position; Vector3 val = ((Component)cam).transform.position - position; if (((Vector3)(ref val)).magnitude > value) { ((Component)cam).transform.position = position + ((Vector3)(ref val)).normalized * value; } } } internal static void ClampToBuildRange(GameCamera cam) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011e: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: 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_008f: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)cam).transform.position; FieldInfo fieldInfo = AccessTools.Field(typeof(CraftingStation), "m_allStations"); IEnumerable enumerable = null; try { enumerable = ((fieldInfo != null) ? fieldInfo.GetValue(null) : null) as IEnumerable; } catch (Exception ex) { ManualLogSource log = TrueCameraPlugin.Log; if (log != null) { log.LogDebug((object)("ClampToBuildRange reflection: " + ex.Message)); } } float num = float.MaxValue; CraftingStation val = null; if (enumerable != null) { foreach (CraftingStation item in enumerable) { CraftingStation val2 = item; float num2 = Vector3.Distance(((Component)val2).transform.position, position); if (num2 < num) { val = val2; num = num2; } } } if (Object.op_Implicit((Object)(object)val)) { float num3 = val.m_rangeBuild * TrueCameraPlugin.BuildCamera_RangeMultiplier.Value; if (num > num3) { float num4 = num - num3; Vector3 val3 = ((Component)val).transform.position - position; Vector3 normalized = ((Vector3)(ref val3)).normalized; ((Component)cam).transform.position = position + normalized * num4; } } else { _enabled = false; } } internal static void StayAboveGround(GameCamera cam) { //IL_001d: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) float num = default(float); if (Object.op_Implicit((Object)(object)ZoneSystem.instance) && ZoneSystem.instance.GetGroundHeight(((Component)cam).transform.position, ref num) && ((Component)cam).transform.position.y < num - 2f) { Vector3 position = ((Component)cam).transform.position; position.y = num - 2f; ((Component)cam).transform.position = position; } } internal static void UpdateBuildCamera(float dt, GameCamera cam) { //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011a: 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_012a: 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_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_03ea: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Unknown result type (might be due to invalid IL or missing references) //IL_03fa: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; Camera val = (Object.op_Implicit((Object)(object)cam) ? ((Component)cam).GetComponent() : null); if (Object.op_Implicit((Object)(object)val) && val.nearClipPlane > 0.003f) { val.nearClipPlane = 0.003f; } bool flag = (Object.op_Implicit((Object)(object)Chat.instance) && Chat.instance.HasFocus()) || Console.IsVisible() || InventoryGui.IsVisible() || StoreGui.IsVisible() || Menu.IsVisible() || Minimap.IsOpen(); if (!flag && Object.op_Implicit((Object)(object)localPlayer) && Input.GetKeyDown((KeyCode)112)) { _bonePreviewActive = !_bonePreviewActive; if (_bonePreviewActive) { ((Character)localPlayer).Message((MessageType)2, "Bones overlay ON. Click LMB on a bone to enter BoneDriven mode.", 0, (Sprite)null); } else { ((Character)localPlayer).Message((MessageType)2, "Bones overlay OFF.", 0, (Sprite)null); } } if (_bonePreviewActive && !flag && Object.op_Implicit((Object)(object)localPlayer)) { DrawBoneOverlay(cam, localPlayer); if (Input.GetMouseButtonDown(0)) { Transform val2 = PickBoneInCrosshair(cam, localPlayer); if (Object.op_Implicit((Object)(object)val2)) { _boneLock = val2; _boneLockLocalOffset = val2.InverseTransformPoint(((Component)cam).transform.position); _boneLockLocalRotation = Quaternion.Inverse(val2.rotation) * ((Component)cam).transform.rotation; _boneLockActive = true; _bonePreviewActive = false; _posVel = Vector3.zero; ((Character)localPlayer).Message((MessageType)2, "BoneDriven mode: " + ((Object)val2).name, 0, (Sprite)null); } else { ((Character)localPlayer).Message((MessageType)2, "No bone selected. Aim at a bone and click LMB.", 0, (Sprite)null); } } } EnsureLocalPlayerVisible(localPlayer); bool flag2 = (!Object.op_Implicit((Object)(object)Chat.instance) || !Chat.instance.HasFocus()) && !Console.IsVisible() && !InventoryGui.IsVisible() && !StoreGui.IsVisible() && !Menu.IsVisible() && !Minimap.IsOpen(); bool flag3 = false; try { flag3 = Traverse.Create((object)localPlayer).Method("TakeInput", Array.Empty()).GetValue(); } catch { flag3 = false; } if (_boneLockActive && flag2 && flag3) { UpdateBoneDrivenPlayerTurn(localPlayer, dt); } bool num = flag2 && !Hud.IsPieceSelectionVisible() && flag3; Vector3 val3 = ((Component)cam).transform.position; Quaternion val4 = ((Component)cam).transform.rotation; if (flag2 && !_boneLockActive) { val4 = UpdateView(dt); } if (num && !_boneLockActive) { Vector3 val5 = UntransformedMove(dt); Vector3 val6 = (TrueCameraPlugin.BuildCamera_MoveWorldSpace.Value ? val5 : ((Component)cam).transform.TransformVector(val5)); float num2 = (TrueCameraPlugin.BuildCamera_SmoothFly.Value ? Mathf.Max(0.1f, TrueCameraPlugin.BuildCamera_SmoothSpeedMultiplier.Value) : 1f); val3 += val6 * num2; Vector3 position = ((Component)cam).transform.position; Quaternion rotation = ((Component)cam).transform.rotation; ((Component)cam).transform.position = val3; ClampToPlayerSphere(cam); if (TrueCameraPlugin.BuildCamera_RequireStation.Value) { ClampToBuildRange(cam); } StayAboveGround(cam); val3 = ((Component)cam).transform.position; ((Component)cam).transform.position = position; ((Component)cam).transform.rotation = rotation; } if (_boneLockActive) { if ((Object)(object)_boneLock == (Object)null) { _boneLockActive = false; } else { val3 = _boneLock.TransformPoint(_boneLockLocalOffset); val4 = _boneLock.rotation * _boneLockLocalRotation; } } if (TrueCameraPlugin.Camera_SideAngle != null) { val4 = Quaternion.AngleAxis(TrueCameraPlugin.Camera_SideAngle.Value, Vector3.up) * val4; } if (TrueCameraPlugin.BuildCamera_SmoothFly.Value && !_boneLockActive) { float num3 = Mathf.Clamp(TrueCameraPlugin.BuildCamera_SmoothTime.Value, 0.01f, 1f); ((Component)cam).transform.position = Vector3.SmoothDamp(((Component)cam).transform.position, val3, ref _posVel, num3, float.PositiveInfinity, dt); ((Component)cam).transform.rotation = Quaternion.Slerp(((Component)cam).transform.rotation, val4, Mathf.Clamp01(dt / num3)); } else { ((Component)cam).transform.position = val3; ((Component)cam).transform.rotation = val4; } } private static Transform PickBoneInCrosshair(GameCamera cam, Player player) { //IL_0058: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_00ac: 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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) try { if (!Object.op_Implicit((Object)(object)cam) || !Object.op_Implicit((Object)(object)player)) { return null; } Transform val = FirstPerson_Modes.GetHead(player) ?? ((Character)player).m_eye; Transform val2 = (Object.op_Implicit((Object)(object)val) ? val.root : ((Component)player).transform); if (!Object.op_Implicit((Object)(object)val2)) { return null; } Ray val3 = default(Ray); ((Ray)(ref val3))..ctor(((Component)cam).transform.position, ((Component)cam).transform.forward); Transform result = null; float num = float.MaxValue; Transform[] boneCandidates = GetBoneCandidates(player, val2); foreach (Transform val4 in boneCandidates) { if (!Object.op_Implicit((Object)(object)val4)) { continue; } Vector3 position = val4.position; float num2 = Vector3.Dot(position - ((Ray)(ref val3)).origin, ((Ray)(ref val3)).direction); if (!(num2 >= 0f) || !(num2 <= 12f)) { continue; } Vector3 val5 = ((Ray)(ref val3)).origin + ((Ray)(ref val3)).direction * num2; float num3 = Vector3.Distance(position, val5); if (num3 <= 0.35f) { float num4 = num3 + num2 * 0.01f; if (num4 < num) { num = num4; result = val4; } } } return result; } catch { } return null; } private static Transform[] GetBoneCandidates(Player player, Transform root) { //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_0042: 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) List list = new List(128); Vector3 position = ((Component)player).transform.position; Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { if (Object.op_Implicit((Object)(object)val) && (Object)(object)val != (Object)(object)((Component)player).transform && Vector3.Distance(val.position, position) <= 4f) { list.Add(val); } } return list.ToArray(); } private static void DrawBoneOverlay(GameCamera cam, Player player) { //IL_0045: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) try { Transform val = FirstPerson_Modes.GetHead(player) ?? ((Character)player).m_eye; Transform val2 = (Object.op_Implicit((Object)(object)val) ? val.root : ((Component)player).transform); if (!Object.op_Implicit((Object)(object)val2)) { return; } Transform[] boneCandidates = GetBoneCandidates(player, val2); Ray val3 = default(Ray); ((Ray)(ref val3))..ctor(((Component)cam).transform.position, ((Component)cam).transform.forward); float num = float.MaxValue; Transform val4 = null; foreach (Transform val5 in boneCandidates) { if (!Object.op_Implicit((Object)(object)val5)) { continue; } Vector3 position = val5.position; float num2 = Vector3.Dot(position - ((Ray)(ref val3)).origin, ((Ray)(ref val3)).direction); if (!(num2 >= 0f) || !(num2 <= 12f)) { continue; } Vector3 val6 = ((Ray)(ref val3)).origin + ((Ray)(ref val3)).direction * num2; float num3 = Vector3.Distance(position, val6); if (num3 <= 0.35f) { float num4 = num3 + num2 * 0.01f; if (num4 < num) { num = num4; val4 = val5; } } } foreach (Transform val7 in boneCandidates) { if (Object.op_Implicit((Object)(object)val7)) { Vector3 position2 = val7.position; Color val8 = (Color)(((Object)(object)val7 == (Object)(object)val4) ? Color.yellow : new Color(0f, 1f, 1f, 1f)); float num5 = (((Object)(object)val7 == (Object)(object)val4) ? 0.07f : 0.045f); Debug.DrawLine(position2 - Vector3.right * num5, position2 + Vector3.right * num5, val8, 0f, false); Debug.DrawLine(position2 - Vector3.up * num5, position2 + Vector3.up * num5, val8, 0f, false); Debug.DrawLine(position2 - Vector3.forward * num5, position2 + Vector3.forward * num5, val8, 0f, false); Transform parent = val7.parent; if (Object.op_Implicit((Object)(object)parent) && (Object)(object)parent != (Object)(object)((Component)player).transform && Vector3.Distance(parent.position, ((Component)player).transform.position) <= 4f) { Debug.DrawLine(position2, parent.position, new Color(0.2f, 0.9f, 1f, 1f), 0f, false); } } } } catch { } } private static void EnsureLocalPlayerVisible(Player player) { if (!Object.op_Implicit((Object)(object)player)) { return; } try { if ((Object)(object)_setVisibleOwner != (Object)(object)player || _setVisible == null) { MethodInfo methodInfo = AccessTools.Method(typeof(Character), "SetVisible", new Type[1] { typeof(bool) }, (Type[])null); if (methodInfo != null) { ParameterExpression parameterExpression = Expression.Parameter(typeof(bool), "visible"); _setVisible = Expression.Lambda>(Expression.Call(Expression.Constant(player, typeof(Character)), methodInfo, parameterExpression), new ParameterExpression[1] { parameterExpression }).Compile(); _setVisibleOwner = (Character)(object)player; } } if (_setVisible != null) { _setVisible(obj: true); } } catch { _setVisible = null; _setVisibleOwner = null; } } } [HarmonyPatch] internal static class BuildCamera_Input { [HarmonyPostfix] [HarmonyPatch(typeof(Player), "Update")] private static void PlayerUpdatePostfix(Player __instance) { if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer || !BuildCamera_EnableDisable.Enabled) { return; } bool flag = false; try { MethodInfo method = ReflectionCache.GetMethod(typeof(Player), "TakeInput"); if (method != null) { flag = (bool)method.Invoke(__instance, null); } } catch (Exception ex) { ManualLogSource log = TrueCameraPlugin.Log; if (log != null) { log.LogDebug((object)("BuildCamera_Input.TakeInput: " + ex.Message)); } } bool flag2 = Hud.IsPieceSelectionVisible(); if (flag) { for (int i = 0; i < 8; i++) { if (Input.GetKeyDown((KeyCode)(49 + i))) { __instance.UseHotbarItem(i + 1); } } if (InputCompat.GetButtonDown("Hide") || InputCompat.GetButtonDown("JoyHide")) { ItemData val = null; ItemData val2 = null; try { MethodInfo method2 = ReflectionCache.GetMethod(typeof(Humanoid), "GetRightItem"); object? obj = ((method2 != null) ? method2.Invoke(__instance, null) : null); val = (ItemData)((obj is ItemData) ? obj : null); } catch (Exception ex2) { ManualLogSource log2 = TrueCameraPlugin.Log; if (log2 != null) { log2.LogDebug((object)("GetRightItem: " + ex2.Message)); } } try { MethodInfo method3 = ReflectionCache.GetMethod(typeof(Humanoid), "GetLeftItem"); object? obj2 = ((method3 != null) ? method3.Invoke(__instance, null) : null); val2 = (ItemData)((obj2 is ItemData) ? obj2 : null); } catch (Exception ex3) { ManualLogSource log3 = TrueCameraPlugin.Log; if (log3 != null) { log3.LogDebug((object)("GetLeftItem: " + ex3.Message)); } } if ((val != null || val2 != null) && !((Character)__instance).InAttack()) { ((Humanoid)__instance).HideHandItems(false, true); } } } if (!(((!Object.op_Implicit((Object)(object)Chat.instance) || !Chat.instance.HasFocus()) && !Console.IsVisible() && !InventoryGui.IsVisible() && !StoreGui.IsVisible() && !Menu.IsVisible() && !Minimap.IsOpen()) || flag2)) { return; } try { MethodInfo method4 = ReflectionCache.GetMethod(typeof(Player), "UpdatePlacement", typeof(bool), typeof(float)); if (method4 != null) { method4.Invoke(__instance, new object[2] { true, Time.deltaTime }); } } catch (Exception ex4) { ManualLogSource log4 = TrueCameraPlugin.Log; if (log4 != null) { log4.LogDebug((object)("UpdatePlacement: " + ex4.Message)); } } } } [HarmonyPatch] internal static class BuildCamera_Patches { [HarmonyPrefix] [HarmonyPriority(int.MaxValue)] [HarmonyPatch(typeof(PlayerController), "TakeInput")] private static bool SuppressPlayerController(ref bool __result) { if (BuildCamera_EnableDisable.Enabled) { if (BuildCamera_EnableDisable.BoneDrivenActive) { return true; } __result = false; return false; } return true; } [HarmonyPrefix] [HarmonyPriority(int.MaxValue)] [HarmonyPatch(typeof(GameCamera), "UpdateCamera")] private static bool UpdateCameraPrefix(float dt, GameCamera __instance) { if (!BuildCamera_EnableDisable.Enabled) { return true; } BuildCamera_EnableDisable.UpdateBuildCamera(dt, __instance); return false; } } internal sealed class CameraLocalCuller : MonoBehaviour { private struct StateEnable { public Renderer R; public bool Prev; } private struct StateShadow { public Renderer R; public ShadowCastingMode Prev; } private struct ColorEntry { public int Index; public Color Color; } private struct StateColor { public Renderer R; public List PrevColors; } private readonly List _head = new List(); private readonly List _helmet = new List(); private readonly List _hairBeard = new List(); private readonly List _jawMouth = new List(); private readonly List _bodyAndArmor = new List(); private readonly List _hands = new List(); private Transform _neckBone; private Vector3 _neckOrigScale; private bool _neckScaled; private Transform _headBone; private Vector3 _headOrigScale = Vector3.one; private bool _headScaled; private Transform _jawBone; private Vector3 _jawOrigScale; private bool _jawScaled; private readonly List _eyeBones = new List(); private readonly List _eyeOrigScales = new List(); private bool _eyesScaled; private readonly List _headDescBones = new List(); private readonly List _headDescOrigScales = new List(); private bool _headDescScaled; private bool _noHair; private bool _noBody; private bool _noHelmet; private bool _initialized; private float _headAlpha = 1f; private float _hairAlpha = 1f; private float _helmetAlpha = 1f; private static FieldInfo _fiBeardInst = AccessTools.Field(typeof(VisEquipment), "m_beardItemInstance"); private static FieldInfo _fiHairInst = AccessTools.Field(typeof(VisEquipment), "m_hairItemInstance"); private static FieldInfo _fiRightItemInst = AccessTools.Field(typeof(VisEquipment), "m_rightItemInstance"); private static FieldInfo _fiLeftItemInst = AccessTools.Field(typeof(VisEquipment), "m_leftItemInstance"); private static FieldInfo _fiHelmetItemInst = AccessTools.Field(typeof(VisEquipment), "m_helmetItemInstance"); private readonly List _disabled = new List(); private readonly List _shadowed = new List(); private readonly List _debugVisible = new List(); private readonly List _colored = new List(); internal void ForceRestore() { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: 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) EnableAll(_head); EnableAll(_helmet); EnableAll(_hairBeard); EnableAll(_jawMouth); EnableAll(_bodyAndArmor); EnableAll(_hands); _disabled.Clear(); _shadowed.Clear(); _colored.Clear(); if (_headScaled && Object.op_Implicit((Object)(object)_headBone)) { _headBone.localScale = _headOrigScale; _headScaled = false; } if (_headDescScaled && _headDescBones.Count > 0) { for (int i = 0; i < _headDescBones.Count; i++) { if (Object.op_Implicit((Object)(object)_headDescBones[i])) { _headDescBones[i].localScale = _headDescOrigScales[i]; } } _headDescScaled = false; } if (_jawScaled && Object.op_Implicit((Object)(object)_jawBone)) { _jawBone.localScale = _jawOrigScale; _jawScaled = false; } if (_eyesScaled && _eyeBones.Count > 0) { for (int j = 0; j < _eyeBones.Count; j++) { if (Object.op_Implicit((Object)(object)_eyeBones[j])) { _eyeBones[j].localScale = _eyeOrigScales[j]; } } _eyesScaled = false; } if (_neckScaled && Object.op_Implicit((Object)(object)_neckBone)) { _neckBone.localScale = _neckOrigScale; _neckScaled = false; } } internal static CameraLocalCuller Ensure(Camera cam) { CameraLocalCuller cameraLocalCuller = ((Component)cam).GetComponent(); if (!Object.op_Implicit((Object)(object)cameraLocalCuller)) { cameraLocalCuller = ((Component)cam).gameObject.AddComponent(); } return cameraLocalCuller; } internal void InitializeFor(Player p) { //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Expected O, but got Unknown //IL_0247: Unknown result type (might be due to invalid IL or missing references) if (_initialized || !Object.op_Implicit((Object)(object)p)) { return; } _head.Clear(); _helmet.Clear(); _hairBeard.Clear(); _bodyAndArmor.Clear(); _hands.Clear(); Transform val = null; try { FieldInfo fieldInfo = AccessTools.Field(typeof(Character), "m_head"); if (fieldInfo != null) { object? value = fieldInfo.GetValue(p); val = (Transform)((value is Transform) ? value : null); } } catch { } if (!Object.op_Implicit((Object)(object)val)) { val = FirstPerson_Modes.GetHead(p); } if (Object.op_Implicit((Object)(object)val)) { _headBone = val; Transform parent = val.parent; while (Object.op_Implicit((Object)(object)parent) && !((Object)parent).name.ToLower().Contains("neck")) { parent = parent.parent; } _neckBone = parent; _head.AddRange(((Component)val).GetComponentsInChildren(true)); Transform val2 = val.Find("Jaw"); if (Object.op_Implicit((Object)(object)val2)) { _jawMouth.AddRange(((Component)val2).GetComponentsInChildren(true)); _jawBone = val2; } } VisEquipment componentInChildren = ((Component)p).GetComponentInChildren(); GameObject val3 = null; GameObject val4 = null; if (Object.op_Implicit((Object)(object)componentInChildren)) { FieldInfo fiBeardInst = _fiBeardInst; object? obj2 = ((fiBeardInst != null) ? fiBeardInst.GetValue(componentInChildren) : null); val3 = (GameObject)((obj2 is GameObject) ? obj2 : null); FieldInfo fiHairInst = _fiHairInst; object? obj3 = ((fiHairInst != null) ? fiHairInst.GetValue(componentInChildren) : null); val4 = (GameObject)((obj3 is GameObject) ? obj3 : null); } if (Object.op_Implicit((Object)(object)_headBone)) { Transform val5 = _headBone.Find("Helmet_attach"); Transform[] componentsInChildren = ((Component)_headBone).GetComponentsInChildren(true); foreach (Transform val6 in componentsInChildren) { if ((!Object.op_Implicit((Object)(object)val5) || (!((Object)(object)val6 == (Object)(object)val5) && !val6.IsChildOf(val5))) && !((Object)(object)val6 == (Object)(object)_headBone)) { _headDescBones.Add(val6); _headDescOrigScales.Add(val6.localScale); if (((Object)val6).name.ToLower().Contains("eye")) { _eyeBones.Add(val6); _eyeOrigScales.Add(val6.localScale); } } } if (Object.op_Implicit((Object)(object)val5)) { foreach (Transform item in val5) { Transform val7 = item; if ((!Object.op_Implicit((Object)(object)val3) || !val7.IsChildOf(val3.transform)) && (!Object.op_Implicit((Object)(object)val4) || !val7.IsChildOf(val4.transform))) { _helmet.AddRange(((Component)val7).GetComponentsInChildren(true)); } } } } if (Object.op_Implicit((Object)(object)componentInChildren)) { if (Object.op_Implicit((Object)(object)componentInChildren.m_helmet)) { _helmet.AddRange(((Component)componentInChildren.m_helmet).GetComponentsInChildren(true)); } FieldInfo fiHelmetItemInst = _fiHelmetItemInst; object? obj4 = ((fiHelmetItemInst != null) ? fiHelmetItemInst.GetValue(componentInChildren) : null); GameObject val8 = (GameObject)((obj4 is GameObject) ? obj4 : null); if (Object.op_Implicit((Object)(object)val8)) { _helmet.AddRange(val8.GetComponentsInChildren(true)); } if (Object.op_Implicit((Object)(object)val3)) { _hairBeard.AddRange(val3.GetComponentsInChildren(true)); } if (Object.op_Implicit((Object)(object)val4)) { _hairBeard.AddRange(val4.GetComponentsInChildren(true)); } FieldInfo fiRightItemInst = _fiRightItemInst; object? obj5 = ((fiRightItemInst != null) ? fiRightItemInst.GetValue(componentInChildren) : null); GameObject val9 = (GameObject)((obj5 is GameObject) ? obj5 : null); FieldInfo fiLeftItemInst = _fiLeftItemInst; object? obj6 = ((fiLeftItemInst != null) ? fiLeftItemInst.GetValue(componentInChildren) : null); GameObject val10 = (GameObject)((obj6 is GameObject) ? obj6 : null); if (Object.op_Implicit((Object)(object)val9)) { _hands.AddRange(val9.GetComponentsInChildren(true)); } if (Object.op_Implicit((Object)(object)val10)) { _hands.AddRange(val10.GetComponentsInChildren(true)); } } GameObject visual = ((Character)p).GetVisual(); if (Object.op_Implicit((Object)(object)visual)) { Renderer[] componentsInChildren2 = visual.GetComponentsInChildren(true); foreach (Renderer val11 in componentsInChildren2) { if (Object.op_Implicit((Object)(object)val11) && !IsInList(val11, _head) && !IsInList(val11, _hairBeard) && !IsInList(val11, _helmet)) { string text = ((Object)((Component)val11).gameObject).name.ToLower(); ((Object)((Component)val11).transform).name.ToLower(); if ((text.Contains("helmet") || text.Contains("helm") || text.Contains("hood") || text.Contains("mask") || text.Contains("cap")) && (!Object.op_Implicit((Object)(object)val3) || !((Component)val11).transform.IsChildOf(val3.transform)) && (!Object.op_Implicit((Object)(object)val4) || !((Component)val11).transform.IsChildOf(val4.transform))) { _helmet.Add(val11); } } } SkinnedMeshRenderer[] componentsInChildren3 = visual.GetComponentsInChildren(true); foreach (SkinnedMeshRenderer val12 in componentsInChildren3) { if (!IsInList((Renderer)(object)val12, _head) && !IsInList((Renderer)(object)val12, _helmet) && !IsInList((Renderer)(object)val12, _hairBeard)) { _bodyAndArmor.Add((Renderer)(object)val12); } } } _initialized = true; } private static bool IsInList(Renderer r, List list) { if ((Object)(object)r == (Object)null || list == null) { return false; } for (int i = 0; i < list.Count; i++) { if ((Object)(object)list[i] == (Object)(object)r) { return true; } } return false; } internal void SetFlags(bool noHair, bool noBody, bool noHelmet) { _noHair = noHair; _noBody = noBody; _noHelmet = noHelmet; } internal void ApplyOpacities(float head, float hair, float helmet) { _headAlpha = Mathf.Clamp01(head); _hairAlpha = Mathf.Clamp01(hair); _helmetAlpha = Mathf.Clamp01(helmet); } private void OnPreCull() { //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) if (!CameraViewModes.FPActive) { return; } _disabled.Clear(); _shadowed.Clear(); _debugVisible.Clear(); for (int i = 0; i < _bodyAndArmor.Count; i++) { if (Object.op_Implicit((Object)(object)_bodyAndArmor[i]) && _bodyAndArmor[i].enabled) { _debugVisible.Add(((Object)((Component)_bodyAndArmor[i]).gameObject).name); } } for (int j = 0; j < _hands.Count; j++) { if (Object.op_Implicit((Object)(object)_hands[j]) && _hands[j].enabled) { _debugVisible.Add(((Object)((Component)_hands[j]).gameObject).name); } } if (_noHair) { DisableList(_hairBeard); } if (_noHelmet) { DisableList(_helmet); } ApplyTransparency(_head, _headAlpha); ApplyTransparency(_hairBeard, _hairAlpha); ApplyTransparency(_helmet, _helmetAlpha); if (_noBody) { DisableList(_bodyAndArmor); DisableList(_hands); DisableList(_head); DisableList(_hairBeard); DisableList(_jawMouth); DisableList(_helmet); if (Object.op_Implicit((Object)(object)_neckBone) && !_neckScaled) { _neckOrigScale = _neckBone.localScale; _neckBone.localScale = new Vector3(0.0001f, 0.0001f, 0.0001f); _neckScaled = true; } } } private void OnPostRender() { //IL_0082: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) foreach (StateEnable item in _disabled) { if (Object.op_Implicit((Object)(object)item.R)) { item.R.enabled = item.Prev; } } _disabled.Clear(); foreach (StateShadow item2 in _shadowed) { if (Object.op_Implicit((Object)(object)item2.R)) { item2.R.shadowCastingMode = item2.Prev; } } _shadowed.Clear(); foreach (StateColor item3 in _colored) { if (!Object.op_Implicit((Object)(object)item3.R)) { continue; } Material[] sharedMaterials = item3.R.sharedMaterials; for (int i = 0; i < item3.PrevColors.Count; i++) { ColorEntry colorEntry = item3.PrevColors[i]; int index = colorEntry.Index; Color color = colorEntry.Color; if (index >= 0 && index < sharedMaterials.Length && Object.op_Implicit((Object)(object)sharedMaterials[index])) { Material val = sharedMaterials[index]; if (val.HasProperty("_Color")) { val.color = color; } } } } _colored.Clear(); if (_headScaled && Object.op_Implicit((Object)(object)_headBone)) { _headBone.localScale = _headOrigScale; _headScaled = false; } if (_headDescScaled && _headDescBones.Count > 0) { for (int j = 0; j < _headDescBones.Count; j++) { _headDescBones[j].localScale = _headDescOrigScales[j]; } _headDescScaled = false; } if (_jawScaled && Object.op_Implicit((Object)(object)_jawBone)) { _jawBone.localScale = _jawOrigScale; _jawScaled = false; } if (_eyesScaled && _eyeBones.Count > 0) { for (int k = 0; k < _eyeBones.Count; k++) { _eyeBones[k].localScale = _eyeOrigScales[k]; } _eyesScaled = false; } if (_neckScaled && Object.op_Implicit((Object)(object)_neckBone)) { _neckBone.localScale = _neckOrigScale; _neckScaled = false; } } private void DisableList(List list) { for (int i = 0; i < list.Count; i++) { Renderer val = list[i]; if (Object.op_Implicit((Object)(object)val)) { _disabled.Add(new StateEnable { R = val, Prev = val.enabled }); val.enabled = false; } } } private void ApplyTransparency(List list, float alpha) { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) if (alpha >= 0.999f) { return; } for (int i = 0; i < list.Count; i++) { Renderer val = list[i]; if (!Object.op_Implicit((Object)(object)val)) { continue; } Material[] sharedMaterials = val.sharedMaterials; if (sharedMaterials == null) { continue; } StateColor stateColor = default(StateColor); stateColor.R = val; stateColor.PrevColors = new List(); StateColor item = stateColor; bool flag = false; for (int j = 0; j < sharedMaterials.Length; j++) { Material val2 = sharedMaterials[j]; if (Object.op_Implicit((Object)(object)val2) && val2.HasProperty("_Color")) { Color color = val2.color; item.PrevColors.Add(new ColorEntry { Index = j, Color = color }); color.a = alpha; val2.color = color; flag = true; } } if (flag) { _colored.Add(item); } } } private void ShadowsOnlyList(List list) { //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) for (int i = 0; i < list.Count; i++) { Renderer val = list[i]; if (Object.op_Implicit((Object)(object)val)) { _shadowed.Add(new StateShadow { R = val, Prev = val.shadowCastingMode }); val.shadowCastingMode = (ShadowCastingMode)3; } } } internal List GetDebugVisibleBody() { return _debugVisible; } internal static void EnableAll(List list) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < list.Count; i++) { Renderer val = list[i]; if (!Object.op_Implicit((Object)(object)val)) { continue; } val.enabled = true; try { val.shadowCastingMode = (ShadowCastingMode)1; } catch { } Material[] sharedMaterials = val.sharedMaterials; if (sharedMaterials == null) { continue; } Material[] array = sharedMaterials; foreach (Material val2 in array) { if (Object.op_Implicit((Object)(object)val2) && val2.HasProperty("_Color")) { Color color = val2.color; color.a = 1f; val2.color = color; } } } } } [HarmonyPatch] internal static class CameraSettings_Awake { [HarmonyPostfix] [HarmonyPatch(typeof(GameCamera), "Awake")] private static void PostAwake(GameCamera __instance) { if ((Object)(object)__instance == (Object)null) { return; } try { __instance.m_maxDistance = TrueCameraPlugin.MaxDistance.Value; __instance.m_maxDistanceBoat = TrueCameraPlugin.MaxDistanceBoat.Value; } catch (Exception ex) { ManualLogSource log = TrueCameraPlugin.Log; if (log != null) { log.LogDebug((object)("CameraSettings_Awake.PostAwake error: " + ex.Message)); } } } } [HarmonyPatch] internal static class CameraSettings_Patches { [HarmonyPrefix] [HarmonyPriority(0)] [HarmonyPatch(typeof(GameCamera), "UpdateCamera")] private static void MaxDistBoatPrefix(GameCamera __instance, ref float __state) { __state = -1f; Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null && ((Character)localPlayer).IsAttachedToShip()) { __state = __instance.m_maxDistance; __instance.m_maxDistance = __instance.m_maxDistanceBoat; } } [HarmonyPostfix] [HarmonyPriority(0)] [HarmonyPatch(typeof(GameCamera), "UpdateCamera")] private static void MaxDistBoatPostfix(GameCamera __instance, float __state) { if (__state != -1f) { __instance.m_maxDistance = __state; } } [HarmonyPrefix] [HarmonyPatch(typeof(Character), "AlwaysRotateCamera")] private static bool AlwaysRotateCameraPrefix(Character __instance, ref bool __result) { Humanoid localPlayer = (Humanoid)(object)Player.m_localPlayer; bool flag = (Object)(object)localPlayer != (Object)null && localPlayer.GetCurrentWeapon() != null; if (TrueCameraPlugin.AlwaysFaceCamera.Value && flag && !__instance.InEmote() && !((Character)localPlayer).IsAttached() && !((Character)localPlayer).IsAttachedToShip() && !((Character)localPlayer).IsRiding()) { __result = true; return false; } return true; } internal static void ApplyCameraConfig() { if (!((Object)(object)GameCamera.instance != (Object)null)) { return; } GameCamera.instance.m_maxDistance = TrueCameraPlugin.MaxDistance.Value; GameCamera.instance.m_maxDistanceBoat = TrueCameraPlugin.MaxDistanceBoat.Value; MethodInfo methodInfo = AccessTools.Method(typeof(GameCamera), "UpdateCamera", (Type[])null, (Type[])null); try { if (methodInfo != null) { methodInfo.Invoke(GameCamera.instance, new object[1] { Time.unscaledDeltaTime }); } } catch (Exception ex) { ManualLogSource log = TrueCameraPlugin.Log; if (log != null) { log.LogDebug((object)("ApplyCameraConfig.Invoke UpdateCamera: " + ex.Message)); } } } } [HarmonyPatch] [HarmonyPriority(int.MinValue)] internal static class CameraViewModes { private static bool _fpLatched = false; private static bool _fpForced = false; private static Action _setVisible; private static Character _setVisibleOwner; private static bool _hadPlayableControl; private static bool _uiOpenLast; private static Quaternion _fpRot; private static bool _fpRotInit = false; private static float _fpYawAcc = 0f; private static float _fpPitchAcc = 0f; private static bool _wasFP = false; private static float? _prevNear = null; private static bool _tpBobInit = false; private static Vector3 _tpBobPrevAnchor; private static Vector3 _tpBobVel; private static Vector3 _tpBobFiltered; private static Vector3 _tpBobBaseLocalHead; private static float _combatActiveUntil = 0f; private static float _combatCheckTimer = 0f; private static Vector3 _posFrom; private static Vector3 _posTo; private static float _posT = 1f; private static Quaternion _rotFrom; private static Quaternion _rotTo; private static float _rotT = 1f; private static float _fovFrom = 65f; private static float _fovTo = 65f; private static float _fovT = 1f; private static string _modePrev = ""; private static string _modeNow = ""; private static bool _prevCombat = false; private static bool _prevAttached = false; private static float _lastDistance = float.PositiveInfinity; private static bool _prevWeaponDrawn = false; private static bool _combatHeld = false; private static Func s_GetKeyFunc; private static bool _haveLastApplied; private static Vector3 _lastAppliedPos; private static Quaternion _lastAppliedRot = Quaternion.identity; private static float _lastAppliedFov = 65f; internal static bool FPActive { get; private set; } internal static string CurrentModeId => _modeNow; internal static bool CurrentCombat => _prevCombat; internal static bool CurrentAttached => _prevAttached; [HarmonyPostfix] [HarmonyPatch(typeof(GameCamera), "UpdateCamera")] private static void AfterUpdate(GameCamera __instance, float dt) { //IL_0cd5: Unknown result type (might be due to invalid IL or missing references) //IL_0cda: Unknown result type (might be due to invalid IL or missing references) //IL_0ce2: Unknown result type (might be due to invalid IL or missing references) //IL_0ce4: Unknown result type (might be due to invalid IL or missing references) //IL_0ce9: Unknown result type (might be due to invalid IL or missing references) //IL_0d13: Unknown result type (might be due to invalid IL or missing references) //IL_0d15: Unknown result type (might be due to invalid IL or missing references) //IL_0d1a: Unknown result type (might be due to invalid IL or missing references) //IL_0d1f: Unknown result type (might be due to invalid IL or missing references) //IL_0cf5: Unknown result type (might be due to invalid IL or missing references) //IL_0cf7: Unknown result type (might be due to invalid IL or missing references) //IL_0d02: Unknown result type (might be due to invalid IL or missing references) //IL_0d07: Unknown result type (might be due to invalid IL or missing references) //IL_0d0c: Unknown result type (might be due to invalid IL or missing references) //IL_0d0e: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_0d60: Unknown result type (might be due to invalid IL or missing references) //IL_0d65: Unknown result type (might be due to invalid IL or missing references) //IL_0d74: Unknown result type (might be due to invalid IL or missing references) //IL_0d79: Unknown result type (might be due to invalid IL or missing references) //IL_0d85: Unknown result type (might be due to invalid IL or missing references) //IL_0d94: Unknown result type (might be due to invalid IL or missing references) //IL_0d34: Unknown result type (might be due to invalid IL or missing references) //IL_0e2d: Unknown result type (might be due to invalid IL or missing references) //IL_0e26: Unknown result type (might be due to invalid IL or missing references) //IL_0dc2: Unknown result type (might be due to invalid IL or missing references) //IL_0dac: Unknown result type (might be due to invalid IL or missing references) //IL_0dbb: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_05a7: Unknown result type (might be due to invalid IL or missing references) //IL_05ae: Unknown result type (might be due to invalid IL or missing references) //IL_05b3: Unknown result type (might be due to invalid IL or missing references) //IL_0549: Unknown result type (might be due to invalid IL or missing references) //IL_0559: Unknown result type (might be due to invalid IL or missing references) //IL_0e32: Unknown result type (might be due to invalid IL or missing references) //IL_0dc7: Unknown result type (might be due to invalid IL or missing references) //IL_0dcc: Unknown result type (might be due to invalid IL or missing references) //IL_0dce: Unknown result type (might be due to invalid IL or missing references) //IL_0dd0: Unknown result type (might be due to invalid IL or missing references) //IL_0de1: Unknown result type (might be due to invalid IL or missing references) //IL_0de6: Unknown result type (might be due to invalid IL or missing references) //IL_0deb: Unknown result type (might be due to invalid IL or missing references) //IL_0e49: Unknown result type (might be due to invalid IL or missing references) //IL_0e42: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0909: Unknown result type (might be due to invalid IL or missing references) //IL_090b: Unknown result type (might be due to invalid IL or missing references) //IL_0910: Unknown result type (might be due to invalid IL or missing references) //IL_0914: Unknown result type (might be due to invalid IL or missing references) //IL_0919: Unknown result type (might be due to invalid IL or missing references) //IL_067b: Unknown result type (might be due to invalid IL or missing references) //IL_0680: Unknown result type (might be due to invalid IL or missing references) //IL_0682: Unknown result type (might be due to invalid IL or missing references) //IL_0691: Unknown result type (might be due to invalid IL or missing references) //IL_0696: Unknown result type (might be due to invalid IL or missing references) //IL_069e: Unknown result type (might be due to invalid IL or missing references) //IL_06aa: Unknown result type (might be due to invalid IL or missing references) //IL_06ba: Unknown result type (might be due to invalid IL or missing references) //IL_06c4: Unknown result type (might be due to invalid IL or missing references) //IL_06c9: Unknown result type (might be due to invalid IL or missing references) //IL_06cb: Unknown result type (might be due to invalid IL or missing references) //IL_06d0: Unknown result type (might be due to invalid IL or missing references) //IL_06d2: Unknown result type (might be due to invalid IL or missing references) //IL_06d4: Unknown result type (might be due to invalid IL or missing references) //IL_06d9: Unknown result type (might be due to invalid IL or missing references) //IL_06de: Unknown result type (might be due to invalid IL or missing references) //IL_06e7: Unknown result type (might be due to invalid IL or missing references) //IL_05cd: Unknown result type (might be due to invalid IL or missing references) //IL_05d2: Unknown result type (might be due to invalid IL or missing references) //IL_0e4e: Unknown result type (might be due to invalid IL or missing references) //IL_0929: Unknown result type (might be due to invalid IL or missing references) //IL_092e: Unknown result type (might be due to invalid IL or missing references) //IL_093c: Unknown result type (might be due to invalid IL or missing references) //IL_093e: Unknown result type (might be due to invalid IL or missing references) //IL_0943: Unknown result type (might be due to invalid IL or missing references) //IL_0716: Unknown result type (might be due to invalid IL or missing references) //IL_071b: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_075a: Unknown result type (might be due to invalid IL or missing references) //IL_075f: Unknown result type (might be due to invalid IL or missing references) //IL_0763: Unknown result type (might be due to invalid IL or missing references) //IL_09a6: Unknown result type (might be due to invalid IL or missing references) //IL_09ab: Unknown result type (might be due to invalid IL or missing references) //IL_09af: Unknown result type (might be due to invalid IL or missing references) //IL_09b4: Unknown result type (might be due to invalid IL or missing references) //IL_096f: Unknown result type (might be due to invalid IL or missing references) //IL_0971: Unknown result type (might be due to invalid IL or missing references) //IL_080f: Unknown result type (might be due to invalid IL or missing references) //IL_0814: Unknown result type (might be due to invalid IL or missing references) //IL_1186: Unknown result type (might be due to invalid IL or missing references) //IL_09b9: Unknown result type (might be due to invalid IL or missing references) //IL_09be: Unknown result type (might be due to invalid IL or missing references) //IL_084a: Unknown result type (might be due to invalid IL or missing references) //IL_084f: Unknown result type (might be due to invalid IL or missing references) //IL_0851: Unknown result type (might be due to invalid IL or missing references) //IL_0853: Unknown result type (might be due to invalid IL or missing references) //IL_0858: Unknown result type (might be due to invalid IL or missing references) //IL_085d: Unknown result type (might be due to invalid IL or missing references) //IL_0820: Unknown result type (might be due to invalid IL or missing references) //IL_0825: Unknown result type (might be due to invalid IL or missing references) //IL_082c: Unknown result type (might be due to invalid IL or missing references) //IL_0831: Unknown result type (might be due to invalid IL or missing references) //IL_0836: Unknown result type (might be due to invalid IL or missing references) //IL_0838: Unknown result type (might be due to invalid IL or missing references) //IL_083a: Unknown result type (might be due to invalid IL or missing references) //IL_083f: Unknown result type (might be due to invalid IL or missing references) //IL_0844: Unknown result type (might be due to invalid IL or missing references) //IL_11be: Unknown result type (might be due to invalid IL or missing references) //IL_085f: Unknown result type (might be due to invalid IL or missing references) //IL_0861: Unknown result type (might be due to invalid IL or missing references) //IL_0f01: Unknown result type (might be due to invalid IL or missing references) //IL_0f03: Unknown result type (might be due to invalid IL or missing references) //IL_11eb: Unknown result type (might be due to invalid IL or missing references) //IL_11f0: Unknown result type (might be due to invalid IL or missing references) //IL_11fc: Unknown result type (might be due to invalid IL or missing references) //IL_1201: Unknown result type (might be due to invalid IL or missing references) //IL_0f0c: Unknown result type (might be due to invalid IL or missing references) //IL_0f15: Unknown result type (might be due to invalid IL or missing references) //IL_0f1a: Unknown result type (might be due to invalid IL or missing references) //IL_0f1f: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_0fb4: Unknown result type (might be due to invalid IL or missing references) //IL_0fb6: Unknown result type (might be due to invalid IL or missing references) //IL_0fd1: Unknown result type (might be due to invalid IL or missing references) //IL_0fd3: Unknown result type (might be due to invalid IL or missing references) //IL_0f4d: Unknown result type (might be due to invalid IL or missing references) //IL_0f4f: Unknown result type (might be due to invalid IL or missing references) //IL_0f54: Unknown result type (might be due to invalid IL or missing references) //IL_0f56: Unknown result type (might be due to invalid IL or missing references) //IL_0f8c: Unknown result type (might be due to invalid IL or missing references) //IL_0f8e: Unknown result type (might be due to invalid IL or missing references) //IL_0f93: Unknown result type (might be due to invalid IL or missing references) //IL_0f95: Unknown result type (might be due to invalid IL or missing references) //IL_0f2f: Unknown result type (might be due to invalid IL or missing references) //IL_0f31: Unknown result type (might be due to invalid IL or missing references) //IL_0f33: Unknown result type (might be due to invalid IL or missing references) //IL_0f38: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Unknown result type (might be due to invalid IL or missing references) //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_08bc: Unknown result type (might be due to invalid IL or missing references) //IL_08f8: Unknown result type (might be due to invalid IL or missing references) //IL_0df6: Unknown result type (might be due to invalid IL or missing references) //IL_0dfb: Unknown result type (might be due to invalid IL or missing references) //IL_0ff3: Unknown result type (might be due to invalid IL or missing references) //IL_0ff5: Unknown result type (might be due to invalid IL or missing references) //IL_0ffa: Unknown result type (might be due to invalid IL or missing references) //IL_0ffc: Unknown result type (might be due to invalid IL or missing references) //IL_1032: Unknown result type (might be due to invalid IL or missing references) //IL_1034: Unknown result type (might be due to invalid IL or missing references) //IL_1039: Unknown result type (might be due to invalid IL or missing references) //IL_103b: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_0435: Unknown result type (might be due to invalid IL or missing references) //IL_0439: Unknown result type (might be due to invalid IL or missing references) //IL_1258: Unknown result type (might be due to invalid IL or missing references) //IL_10ce: Unknown result type (might be due to invalid IL or missing references) //IL_10dc: Unknown result type (might be due to invalid IL or missing references) //IL_1092: Unknown result type (might be due to invalid IL or missing references) //IL_1097: Unknown result type (might be due to invalid IL or missing references) //IL_109e: Unknown result type (might be due to invalid IL or missing references) //IL_10af: Unknown result type (might be due to invalid IL or missing references) //IL_10b4: Unknown result type (might be due to invalid IL or missing references) //IL_10bb: Unknown result type (might be due to invalid IL or missing references) //IL_12d0: Unknown result type (might be due to invalid IL or missing references) //IL_12db: Unknown result type (might be due to invalid IL or missing references) //IL_0bbf: Unknown result type (might be due to invalid IL or missing references) //IL_0bc1: Unknown result type (might be due to invalid IL or missing references) //IL_0bc5: Unknown result type (might be due to invalid IL or missing references) //IL_0bca: Unknown result type (might be due to invalid IL or missing references) //IL_0bcf: Unknown result type (might be due to invalid IL or missing references) //IL_0bd3: Unknown result type (might be due to invalid IL or missing references) //IL_0bd8: Unknown result type (might be due to invalid IL or missing references) //IL_0bdd: Unknown result type (might be due to invalid IL or missing references) //IL_0bed: Unknown result type (might be due to invalid IL or missing references) //IL_0bf2: Unknown result type (might be due to invalid IL or missing references) //IL_0bf4: Unknown result type (might be due to invalid IL or missing references) //IL_0bfb: Unknown result type (might be due to invalid IL or missing references) //IL_0c0a: Unknown result type (might be due to invalid IL or missing references) //IL_0c0c: Unknown result type (might be due to invalid IL or missing references) //IL_13ec: Unknown result type (might be due to invalid IL or missing references) //IL_13f1: Unknown result type (might be due to invalid IL or missing references) //IL_13fd: Unknown result type (might be due to invalid IL or missing references) //IL_1402: Unknown result type (might be due to invalid IL or missing references) //IL_0c3c: Unknown result type (might be due to invalid IL or missing references) //IL_0c3e: Unknown result type (might be due to invalid IL or missing references) //IL_0c42: Unknown result type (might be due to invalid IL or missing references) //IL_0c47: Unknown result type (might be due to invalid IL or missing references) //IL_0c4c: Unknown result type (might be due to invalid IL or missing references) //IL_0c50: Unknown result type (might be due to invalid IL or missing references) //IL_0c55: Unknown result type (might be due to invalid IL or missing references) //IL_0c5a: Unknown result type (might be due to invalid IL or missing references) try { if (TrueCameraPlugin.Suspended) { return; } Player localPlayer = Player.m_localPlayer; bool flag = (Object.op_Implicit((Object)(object)Chat.instance) && Chat.instance.HasFocus()) || Console.IsVisible() || InventoryGui.IsVisible() || StoreGui.IsVisible() || Menu.IsVisible() || Minimap.IsOpen() || Hud.IsPieceSelectionVisible(); bool flag2 = false; if (Object.op_Implicit((Object)(object)localPlayer)) { try { MethodInfo method = ReflectionCache.GetMethod(typeof(Player), "TakeInput", Type.EmptyTypes); flag2 = method != null && (bool)method.Invoke(localPlayer, null); } catch { flag2 = false; } } Quaternion rotation; if ((!_hadPlayableControl && flag2) || (_uiOpenLast && !flag)) { float fpYawAcc; if (!Object.op_Implicit((Object)(object)localPlayer)) { fpYawAcc = 0f; } else { rotation = ((Component)localPlayer).transform.rotation; fpYawAcc = ((Quaternion)(ref rotation)).eulerAngles.y; } _fpYawAcc = fpYawAcc; _fpPitchAcc = 0f; _fpRotInit = false; } _hadPlayableControl = flag2; _uiOpenLast = flag; if ((Object)(object)localPlayer == (Object)null) { return; } Camera val = (((Object)(object)__instance != (Object)null) ? ((Component)__instance).gameObject.GetComponent() : null); if ((Object)(object)val == (Object)null) { val = Camera.main; } if ((Object)(object)val == (Object)null) { return; } Vector3 position = ((Component)val).transform.position; Vector3 right = ((Component)val).transform.right; Vector3 up = Vector3.up; float minDistance = __instance.m_minDistance; float num = minDistance + 999f; try { FieldInfo fieldInfo = AccessTools.Field(typeof(GameCamera), "m_distance"); num = ((!(fieldInfo != null)) ? Vector3.Distance(((Component)val).transform.position, ((Component)localPlayer).transform.position) : ((float)fieldInfo.GetValue(__instance))); } catch { } bool flag3 = ((Character)localPlayer).IsAttached() || ((Character)localPlayer).IsAttachedToShip() || ((Character)localPlayer).IsRiding(); bool flag4 = false; if (TrueCameraPlugin.TP_Combat_Enabled != null && TrueCameraPlugin.TP_Combat_Enabled.Value) { flag4 = UpdateCombatState(localPlayer, dt); } TrueCameraPlugin.Log.LogDebug((object)$"CV: Update dt={dt:F3}"); if (BuildCamera_EnableDisable.Enabled) { return; } KeyboardShortcut value = TrueCameraPlugin.FP_ToggleHotkey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { _fpForced = !_fpForced; } bool flag5 = TrueCameraPlugin.FP_Enabled.Value && num <= minDistance + 0.05f; TrueCameraPlugin.Log.LogDebug((object)$"CV: dist={num:F2} min={minDistance:F2} wantFP={flag5} forced={_fpForced} latched={_fpLatched}"); if (_fpLatched) { if (num >= minDistance + 0.4f && num > _lastDistance + 0.005f) { _fpLatched = false; } } else if (flag5 && num < _lastDistance - 0.005f) { _fpLatched = true; } bool flag7 = (FPActive = _fpForced || _fpLatched); if (!_wasFP && flag7) { Vector3 eulerAngles = ((Component)val).transform.eulerAngles; _fpYawAcc = eulerAngles.y; _fpPitchAcc = Mathf.Clamp(NormalizePitch(eulerAngles.x), -89f, 89f); _fpRotInit = true; if (!_prevNear.HasValue) { _prevNear = val.nearClipPlane; } TrueCameraPlugin.Log.LogInfo((object)$"CV: FP enter yaw={_fpYawAcc:F1} pitch={_fpPitchAcc:F1}"); } Vector3 position2 = ((Component)val).transform.position; string text = "TP"; float num2 = ((TrueCameraPlugin.FoV_TP != null) ? TrueCameraPlugin.FoV_TP.Value : 65f); Quaternion val2 = ((Component)val).transform.rotation; bool flag8 = false; if (flag7) { text = "FP"; num2 = ((TrueCameraPlugin.FoV_FP != null) ? TrueCameraPlugin.FoV_FP.Value : 65f); KeyboardShortcut value2 = TrueCameraPlugin.FP_FreeLookKey.Value; bool flag9; if (Input.GetKey(((KeyboardShortcut)(ref value2)).MainKey)) { if (((KeyboardShortcut)(ref value2)).Modifiers != null) { IEnumerable modifiers = ((KeyboardShortcut)(ref value2)).Modifiers; Func predicate; if ((predicate = s_GetKeyFunc) == null) { predicate = (s_GetKeyFunc = Input.GetKey); } flag9 = modifiers.All(predicate); } else { flag9 = true; } } else { flag9 = false; } bool flag10 = flag9; Transform val3 = null; try { FieldInfo fieldInfo2 = AccessTools.Field(typeof(Character), "m_head"); if (fieldInfo2 != null) { object? value3 = fieldInfo2.GetValue(localPlayer); val3 = (Transform)((value3 is Transform) ? value3 : null); } } catch { } if (!Object.op_Implicit((Object)(object)val3)) { val3 = FirstPerson_Modes.GetHead(localPlayer) ?? ((Character)localPlayer).m_eye; } VisEquipment componentInChildren = ((Component)localPlayer).GetComponentInChildren(); Transform val4 = ((Object.op_Implicit((Object)(object)componentInChildren) && Object.op_Implicit((Object)(object)componentInChildren.m_helmet)) ? componentInChildren.m_helmet : val3); bool flag11 = ((Character)localPlayer).IsAttached() || ((Character)localPlayer).IsAttachedToShip() || ((Character)localPlayer).IsRiding(); float num3 = 1.55f; if (Object.op_Implicit((Object)(object)((Character)localPlayer).m_eye)) { num3 = Mathf.Clamp(((Character)localPlayer).m_eye.position.y - ((Component)localPlayer).transform.position.y, 1f, 2.2f); } float value4 = TrueCameraPlugin.FP_HeadOffsetX.Value; float value5 = TrueCameraPlugin.FP_HeadOffsetY.Value; float value6 = TrueCameraPlugin.FP_HeadOffsetZ.Value; float value7 = TrueCameraPlugin.FP_HeadOffsetMultiplier.Value; Vector3 val5 = new Vector3(value4, value5, value6) * value7; if (flag10) { if (!_fpRotInit) { Vector3 eulerAngles2 = ((Component)val).transform.eulerAngles; _fpYawAcc = eulerAngles2.y; _fpPitchAcc = Mathf.Clamp(NormalizePitch(eulerAngles2.x), -89f, 89f); _fpRotInit = true; } float num4 = PlayerController.m_mouseSens * Input.GetAxis("Mouse X") + InputCompat.GetJoyRightStickX(abs: true) * 110f * dt; float num5 = PlayerController.m_mouseSens * Input.GetAxis("Mouse Y") - InputCompat.GetJoyRightStickY(abs: true) * 110f * dt; _fpYawAcc += num4; _fpPitchAcc = Mathf.Clamp(_fpPitchAcc - num5, -89f, 89f); Quaternion val6 = Quaternion.Euler(_fpPitchAcc, _fpYawAcc, 0f); Vector3 val7 = Vector3.up * TrueCameraPlugin.FP_FreeLookHeightOffset.Value; position2 = new Vector3(((Component)localPlayer).transform.position.x, val4.position.y, ((Component)localPlayer).transform.position.z) + val7 + val6 * val5; ((Component)val).transform.rotation = val6; } else if (TrueCameraPlugin.FP_AimYawDriven.Value || flag11) { if (!_fpRotInit) { Vector3 eulerAngles3 = ((Component)val).transform.eulerAngles; _fpYawAcc = eulerAngles3.y; _fpPitchAcc = Mathf.Clamp(NormalizePitch(eulerAngles3.x), -89f, 89f); _fpRotInit = true; } if (!_fpRotInit) { rotation = ((Component)localPlayer).transform.rotation; _fpYawAcc = ((Quaternion)(ref rotation)).eulerAngles.y; _fpPitchAcc = 0f; _fpRotInit = true; } float num6 = PlayerController.m_mouseSens * Input.GetAxis("Mouse X") + InputCompat.GetJoyRightStickX(abs: true) * 110f * dt; float num7 = PlayerController.m_mouseSens * Input.GetAxis("Mouse Y") - InputCompat.GetJoyRightStickY(abs: true) * 110f * dt; _fpYawAcc += num6; _fpPitchAcc = Mathf.Clamp(_fpPitchAcc - num7, -89f, 89f); Quaternion val8 = Quaternion.Euler(_fpPitchAcc, _fpYawAcc, TrueCameraPlugin.FP_StabilizerZeroRoll.Value ? 0f : 0f); position2 = ((!flag11) ? (val4.position + val8 * val5) : (((Component)localPlayer).transform.position + Vector3.up * num3 + val8 * val5)); val2 = val8; if ((!Object.op_Implicit((Object)(object)Chat.instance) || !Chat.instance.HasFocus()) && !Console.IsVisible() && !InventoryGui.IsVisible() && !StoreGui.IsVisible() && !Menu.IsVisible() && !Minimap.IsOpen() && !Hud.IsPieceSelectionVisible() && !flag10 && !flag11) { float y = ((Component)localPlayer).transform.eulerAngles.y; float fpYawAcc2 = _fpYawAcc; float value8 = TrueCameraPlugin.FP_ForceRotateSpeed.Value; float num8 = Mathf.MoveTowardsAngle(y, fpYawAcc2, value8 * dt); ((Component)localPlayer).transform.rotation = Quaternion.Euler(0f, num8, 0f); } } else { position2 = val4.TransformPoint(val5); Quaternion val9 = val4.rotation; if (TrueCameraPlugin.FP_StabilizerZeroRoll.Value) { Vector3 eulerAngles4 = ((Quaternion)(ref val9)).eulerAngles; eulerAngles4.z = 0f; val9 = Quaternion.Euler(eulerAngles4); } if (!TrueCameraPlugin.FP_StabilizerEnabled.Value || TrueCameraPlugin.FP_StabilizerTime.Value <= 0f || !_fpRotInit) { _fpRot = val9; _fpRotInit = true; } else { float num9 = Mathf.Max(0.0001f, TrueCameraPlugin.FP_StabilizerTime.Value); float num10 = 1f - Mathf.Exp((0f - dt) / num9); _fpRot = Quaternion.Slerp(_fpRot, val9, num10); } val2 = _fpRot; } if (_setVisible == null) { MethodInfo methodInfo = AccessTools.Method(typeof(Character), "SetVisible", new Type[1] { typeof(bool) }, (Type[])null); if (methodInfo != null) { _setVisible = (Action)Delegate.CreateDelegate(typeof(Action), localPlayer, methodInfo); } } if ((Object)(object)_setVisibleOwner != (Object)(object)localPlayer) { try { MethodInfo methodInfo2 = AccessTools.Method(typeof(Character), "SetVisible", new Type[1] { typeof(bool) }, (Type[])null); if (methodInfo2 != null) { _setVisible = (Action)Delegate.CreateDelegate(typeof(Action), localPlayer, methodInfo2); _setVisibleOwner = (Character)(object)localPlayer; } } catch { _setVisible = null; _setVisibleOwner = null; } } _setVisible?.Invoke(obj: true); CameraLocalCuller cameraLocalCuller = CameraLocalCuller.Ensure(val); cameraLocalCuller.InitializeFor(localPlayer); bool noHair = TrueCameraPlugin.FP_Mode_NoHair != null && TrueCameraPlugin.FP_Mode_NoHair.Value; bool noBody = TrueCameraPlugin.FP_Mode_NoBody != null && TrueCameraPlugin.FP_Mode_NoBody.Value; bool noHelmet = TrueCameraPlugin.FP_Mode_NoHelmet != null && TrueCameraPlugin.FP_Mode_NoHelmet.Value; cameraLocalCuller.SetFlags(noHair, noBody, noHelmet); } else if (TrueCameraPlugin.TP_Enabled.Value) { float num11; float num12; if (flag4) { num2 = ((TrueCameraPlugin.FoV_TP_Combat != null) ? TrueCameraPlugin.FoV_TP_Combat.Value : num2); num11 = TrueCameraPlugin.TP_Combat_SideOffset.Value; num12 = TrueCameraPlugin.TP_Combat_HeightOffset.Value; text = (flag3 ? "TPV" : "TP"); } else { if (flag3) { num2 = ((TrueCameraPlugin.FoV_TP_Vehicle != null) ? TrueCameraPlugin.FoV_TP_Vehicle.Value : num2); } num11 = (flag3 ? TrueCameraPlugin.TP_Vehicle_SideOffset.Value : TrueCameraPlugin.TP_SideOffset.Value); num12 = (flag3 ? TrueCameraPlugin.TP_Vehicle_HeightOffset.Value : TrueCameraPlugin.TP_HeightOffset.Value); text = (flag3 ? "TPV" : "TP"); } position2 = position + right * num11 + up * num12; if (Object.op_Implicit((Object)(object)localPlayer)) { Vector3 position3 = ((Component)localPlayer).transform.position; float num13 = Mathf.Abs(position.y - position3.y); float num14 = Vector3.Distance(position, position3); if (float.IsNaN(num14) || float.IsInfinity(num14) || num13 > 80f || num14 > 150f) { position2 = position + right * num11 + up * num12; ResetState(); flag8 = true; } } if (TrueCameraPlugin.TP_HeadBobFromHead.Value) { Transform val10 = null; try { FieldInfo fieldInfo3 = AccessTools.Field(typeof(Character), "m_head"); if (fieldInfo3 != null) { object? value9 = fieldInfo3.GetValue(localPlayer); val10 = (Transform)((value9 is Transform) ? value9 : null); } } catch { } if ((Object)(object)val10 == (Object)null) { val10 = FirstPerson_Modes.GetHead(localPlayer) ?? ((Character)localPlayer).m_eye; } if ((Object)(object)val10 != (Object)null) { Vector3 position4 = val10.position; Vector3 val11 = ((Component)localPlayer).transform.InverseTransformPoint(position4); if (!_tpBobInit) { _tpBobPrevAnchor = position4; _tpBobInit = true; _tpBobVel = Vector3.zero; _tpBobBaseLocalHead = val11; } Vector3 val12 = val11 - _tpBobBaseLocalHead; if (TrueCameraPlugin.TP_HeadBobVerticalOnly.Value) { ((Vector3)(ref val12))..ctor(0f, val12.y, 0f); } float num15 = Mathf.Clamp(TrueCameraPlugin.TP_HeadBobSmoothing.Value, 0f, 0.5f); _tpBobFiltered = Vector3.SmoothDamp(_tpBobFiltered, val12, ref _tpBobVel, num15, float.PositiveInfinity, dt); Vector3 val13 = ((Component)val).transform.up * _tpBobFiltered.y + (TrueCameraPlugin.TP_HeadBobVerticalOnly.Value ? Vector3.zero : (((Component)val).transform.right * _tpBobFiltered.x)); position2 += val13 * Mathf.Clamp01(TrueCameraPlugin.TP_HeadBobStrength.Value); } } } else { position2 = ((Component)val).transform.position; } bool num16 = TrueCameraPlugin.Camera_ModeTransition_Enable != null && TrueCameraPlugin.Camera_ModeTransition_Enable.Value && !flag8; Vector3 val14 = (_haveLastApplied ? _lastAppliedPos : ((Component)val).transform.position); Quaternion rotFrom = (_haveLastApplied ? _lastAppliedRot : ((Component)val).transform.rotation); float fovFrom = (_haveLastApplied ? _lastAppliedFov : val.fieldOfView); if (num16) { float num17 = Mathf.Max(0.01f, TrueCameraPlugin.Camera_ModeTransition_Time.Value); if (_prevCombat != flag4) { num17 = Mathf.Max(0.01f, TrueCameraPlugin.Camera_CombatTransition_Time.Value); } if (_modeNow == "FP" || text == "FP") { num17 = Mathf.Max(num17, 0.55f); } bool num18 = _modeNow != text; bool flag12 = _prevCombat != flag4; bool flag13 = _prevAttached != flag3; bool num19 = num18 || flag12 || flag13; Vector3 val15 = position2; if (_haveLastApplied) { Vector3 val16 = val14 - ((Component)val).transform.position; if (((Vector3)(ref val16)).sqrMagnitude <= 36f) { val15 += val16; } } if (num19) { _modePrev = _modeNow; _modeNow = text; _posFrom = val14; _posTo = val15; _posT = 0f; _fovFrom = fovFrom; _fovTo = Mathf.Clamp(num2, 0f, 120f); _fovT = 0f; _rotFrom = rotFrom; _rotTo = val2; _rotT = 0f; _prevCombat = flag4; _prevAttached = flag3; } else { _posTo = position2; _fovTo = Mathf.Clamp(num2, 0f, 120f); _rotTo = val2; } if (_wasFP && _modeNow != "FP") { _posFrom = val14; _posTo = val15; _posT = 0f; _fovFrom = fovFrom; _fovTo = Mathf.Clamp(num2, 0f, 120f); _fovT = 0f; _rotFrom = rotFrom; _rotTo = val2; _rotT = 0f; } if (_posT < 1f) { _posT = Mathf.Clamp01(_posT + dt / num17); float num20 = _posT * _posT * (3f - 2f * _posT); ((Component)val).transform.position = Vector3.LerpUnclamped(_posFrom, _posTo, num20); ((Component)val).transform.rotation = Quaternion.Slerp(_rotFrom, _rotTo, num20); } else { ((Component)val).transform.position = position2; ((Component)val).transform.rotation = _rotTo; } if (_fovT < 1f) { _fovT = Mathf.Clamp01(_fovT + dt / num17); float num21 = _fovT * _fovT * (3f - 2f * _fovT); val.fieldOfView = Mathf.LerpUnclamped(_fovFrom, _fovTo, num21); } else { val.fieldOfView = _fovTo; } } else { if (_modeNow != text) { _modePrev = _modeNow; _modeNow = text; } _prevCombat = flag4; _prevAttached = flag3; ((Component)val).transform.position = position2; if (!float.IsNaN(num2) && Object.op_Implicit((Object)(object)val)) { val.fieldOfView = Mathf.Clamp(num2, 0f, 120f); } ((Component)val).transform.rotation = val2; } if (TrueCameraPlugin.Camera_SideAngle != null) { float value10 = TrueCameraPlugin.Camera_SideAngle.Value; ((Component)val).transform.rotation = Quaternion.AngleAxis(value10, ((Component)val).transform.forward) * ((Component)val).transform.rotation; } if (TrueCameraPlugin.Camera_ModeTransition_Enable == null || !TrueCameraPlugin.Camera_ModeTransition_Enable.Value) { if (!float.IsNaN(num2) && Object.op_Implicit((Object)(object)val)) { val.fieldOfView = Mathf.Clamp(num2, 0f, 120f); } ((Component)val).transform.rotation = val2; } bool num22 = TrueCameraPlugin.HideHUD != null && TrueCameraPlugin.HideHUD.Value; if (Object.op_Implicit((Object)(object)localPlayer) && ((Character)localPlayer).IsDead()) { ClampDeadCameraAboveGround(val); } if (num22) { if (Object.op_Implicit((Object)(object)Hud.instance)) { Hud.instance.m_userHidden = true; } } else if (Object.op_Implicit((Object)(object)Hud.instance)) { Hud.instance.m_userHidden = false; } bool fPActive = FPActive; bool flag14 = Object.op_Implicit((Object)(object)localPlayer) && Vector3.Distance(((Component)val).transform.position, ((Component)localPlayer).transform.position) < 1.25f; if (fPActive || flag14) { if (!_prevNear.HasValue) { _prevNear = val.nearClipPlane; } if (val.nearClipPlane > 0.003f) { val.nearClipPlane = 0.003f; } } else { bool wasFP = _wasFP; if (wasFP || _prevNear.HasValue) { if (_prevNear.HasValue) { val.nearClipPlane = _prevNear.Value; } _prevNear = null; if (wasFP) { CameraLocalCuller cameraLocalCuller2 = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent() : null); if (Object.op_Implicit((Object)(object)cameraLocalCuller2)) { cameraLocalCuller2.ForceRestore(); } NativeCullingController nativeCullingController = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent() : null); if (Object.op_Implicit((Object)(object)nativeCullingController)) { nativeCullingController.RestoreAll(); } TrueCameraPlugin.Log.LogInfo((object)"CV: FP exit — restored hair/helmet/body state"); } } } _wasFP = flag7; _lastDistance = num; _lastAppliedPos = ((Component)val).transform.position; _lastAppliedRot = ((Component)val).transform.rotation; _lastAppliedFov = val.fieldOfView; _haveLastApplied = true; } catch (Exception arg) { TrueCameraPlugin.Log.LogError((object)$"CV: Exception in AfterUpdate: {arg}"); } } private static float NormalizePitch(float x) { if (x > 180f) { x -= 360f; } return x; } private static void ClampDeadCameraAboveGround(Camera camera) { //IL_0020: 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_0051: 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_0065: 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_006c: 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_0072: Unknown result type (might be due to invalid IL or missing references) float num = default(float); if (Object.op_Implicit((Object)(object)camera) && Object.op_Implicit((Object)(object)ZoneSystem.instance) && ZoneSystem.instance.GetGroundHeight(((Component)camera).transform.position, ref num)) { float num2 = num + 0.2f; if (!(((Component)camera).transform.position.y >= num2)) { Vector3 position = ((Component)camera).transform.position; position.y = num2; ((Component)camera).transform.position = position; _posFrom = position; _posTo = position; _posT = 1f; } } } private static bool UpdateCombatState(Player player, float dt) { //IL_024b: 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_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) float time = Time.time; if (_combatActiveUntil > 0f && time < _combatActiveUntil) { _combatHeld = true; return true; } bool flag = false; try { if (TrueCameraPlugin.TP_Combat_WhileWeaponDrawn != null && TrueCameraPlugin.TP_Combat_WhileWeaponDrawn.Value) { ItemData val = (((Object)(object)player != (Object)null) ? ((Humanoid)player).GetCurrentWeapon() : null); ItemData val2 = (((Object)(object)player != (Object)null && (Object)(object)((Humanoid)player).m_unarmedWeapon != (Object)null) ? ((Humanoid)player).m_unarmedWeapon.m_itemData : null); if (val != null && val != val2 && val.m_shared != null && val.IsWeapon()) { DamageTypes damages = val.m_shared.m_damages; flag = damages.m_damage > 0f || damages.m_blunt > 0f || damages.m_slash > 0f || damages.m_pierce > 0f || damages.m_fire > 0f || damages.m_frost > 0f || damages.m_lightning > 0f || damages.m_poison > 0f || damages.m_spirit > 0f; } } } catch { } if (flag) { _prevWeaponDrawn = true; _combatHeld = true; return true; } if (_prevWeaponDrawn) { float num = Mathf.Max(0.15f, (TrueCameraPlugin.Camera_ModeTransition_Time != null) ? TrueCameraPlugin.Camera_ModeTransition_Time.Value : 0.35f); _combatActiveUntil = Mathf.Max(_combatActiveUntil, time + num); _prevWeaponDrawn = false; _combatHeld = true; return true; } _combatCheckTimer -= dt; if (_combatCheckTimer > 0f) { return _combatHeld; } _combatCheckTimer = 0.25f; _combatHeld = false; float num2 = Mathf.Max(0f, TrueCameraPlugin.TP_Combat_SearchRadius.Value); if (num2 <= 0.01f) { return false; } List allCharacters = Character.GetAllCharacters(); if (allCharacters != null) { foreach (Character item in allCharacters) { if (!Object.op_Implicit((Object)(object)item) || (Object)(object)item == (Object)(object)player) { continue; } Vector3 val3 = ((Component)item).transform.position - ((Component)player).transform.position; if (((Vector3)(ref val3)).sqrMagnitude > num2 * num2) { continue; } try { BaseAI baseAI = item.GetBaseAI(); if ((Object)(object)baseAI != (Object)null && (baseAI.IsAlerted() || item.InAttack()) && BaseAI.IsEnemy(item, (Character)(object)player)) { Character val4 = null; try { val4 = baseAI.GetTargetCreature(); } catch { } if ((Object)(object)val4 == (Object)null || (Object)(object)val4 == (Object)(object)player) { _combatActiveUntil = time + Mathf.Max(0.1f, TrueCameraPlugin.TP_Combat_HoldTime.Value); _prevWeaponDrawn = false; return true; } } } catch { } } } return false; } internal static void ResetState() { //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_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) try { _tpBobInit = false; _tpBobFiltered = Vector3.zero; _tpBobVel = Vector3.zero; _modeNow = string.Empty; _modePrev = string.Empty; _posT = 1f; _fovT = 1f; _wasFP = false; FPActive = false; _fpLatched = false; _fpForced = false; _prevNear = null; _lastDistance = float.PositiveInfinity; _fpRotInit = false; _combatActiveUntil = 0f; _combatCheckTimer = 0f; _haveLastApplied = false; } catch { } } } [HarmonyPatch] internal static class DepthOfField_Control { private static float _focusHeld; private static int _focusDirLast; private static Component GetDOF() { Camera main = Camera.main; CameraEffects instance = CameraEffects.instance; Component val = null; if (Object.op_Implicit((Object)(object)instance)) { try { FieldInfo fieldInfo = AccessTools.Field(typeof(CameraEffects), "m_dof"); if (fieldInfo != null) { object? value = fieldInfo.GetValue(instance); val = (Component)((value is Component) ? value : null); } } catch { } } if (!Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)instance)) { val = ((Component)instance).GetComponent("UnityStandardAssets.ImageEffects.DepthOfField"); if (!Object.op_Implicit((Object)(object)val)) { val = ((Component)instance).GetComponent("DepthOfField"); } } if (!Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)main)) { val = ((Component)main).GetComponent("UnityStandardAssets.ImageEffects.DepthOfField"); if (!Object.op_Implicit((Object)(object)val)) { val = ((Component)main).GetComponent("DepthOfField"); } } if (!Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)main)) { Type type = AccessTools.TypeByName("UnityStandardAssets.ImageEffects.DepthOfField") ?? AccessTools.TypeByName("DepthOfField"); if (type != null && typeof(Behaviour).IsAssignableFrom(type)) { try { val = ((Component)main).gameObject.AddComponent(type); } catch { } } } return val; } [HarmonyPostfix] [HarmonyPatch(typeof(CameraEffects), "Awake")] private static void OnCameraEffectsAwake() { ApplyDOFSettings(force: true); } [HarmonyPostfix] [HarmonyPatch(typeof(CameraEffects), "ApplySettings")] private static void AfterApplySettings() { ApplyDOFSettings(force: true); } [HarmonyPostfix] [HarmonyPatch(typeof(GameCamera), "UpdateCamera")] private static void OnUpdateCamera() { HandleHotkeysAndLiveUpdate(); } private static void HandleHotkeysAndLiveUpdate() { //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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut value = TrueCameraPlugin.DOF_ToggleEnabledHotkey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { TrueCameraPlugin.DOF_Enabled.Value = !TrueCameraPlugin.DOF_Enabled.Value; ApplyDOFSettings(force: true); } value = TrueCameraPlugin.DOF_ToggleAutofocusHotkey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { TrueCameraPlugin.DOF_Autofocus.Value = !TrueCameraPlugin.DOF_Autofocus.Value; } value = TrueCameraPlugin.DOF_FocusIncreaseHotkey.Value; bool flag = ((KeyboardShortcut)(ref value)).IsPressed(); value = TrueCameraPlugin.DOF_FocusDecreaseHotkey.Value; bool flag2 = ((KeyboardShortcut)(ref value)).IsPressed(); if (!TrueCameraPlugin.DOF_Autofocus.Value && (flag || flag2)) { float deltaTime = Time.deltaTime; float num = (flag ? 1f : (-1f)); float value2 = TrueCameraPlugin.DOF_FocusDistance.Value; if (value2 > 2f) { float num2 = num * 100f * deltaTime; float value3 = Mathf.Clamp(value2 + num2, 0f, 300f); TrueCameraPlugin.DOF_FocusDistance.Value = value3; } else { if ((flag && _focusDirLast < 0) || (flag2 && _focusDirLast > 0)) { _focusHeld = 0f; } _focusDirLast = (flag ? 1 : (-1)); _focusHeld = Mathf.Clamp01(_focusHeld + deltaTime); float num3 = _focusHeld * _focusHeld * (3f - 2f * _focusHeld); float num4 = 8f; float num5 = Mathf.Lerp(num4 * 0.25f, num4, num3); float num6 = num * num5 * deltaTime; float value4 = Mathf.Clamp(value2 + num6, 0f, 300f); TrueCameraPlugin.DOF_FocusDistance.Value = value4; } } else { _focusHeld = 0f; _focusDirLast = 0; } ApplyDOFSettings(force: false); } private static float GetFloatMember(Component c, string name, float fallback) { if (!Object.op_Implicit((Object)(object)c)) { return fallback; } Type type = ((object)c).GetType(); try { PropertyInfo property = type.GetProperty(name); if (property != null && property.PropertyType == typeof(float)) { return (float)property.GetValue(c, null); } } catch { } try { FieldInfo field = type.GetField(name); if (field != null && field.FieldType == typeof(float)) { return (float)field.GetValue(c); } } catch { } return fallback; } private static void SetFloatMember(Component c, string name, float value) { if (!Object.op_Implicit((Object)(object)c)) { return; } Type type = ((object)c).GetType(); try { PropertyInfo property = type.GetProperty(name); if (property != null && property.PropertyType == typeof(float)) { property.SetValue(c, value, null); return; } } catch { } try { FieldInfo field = type.GetField(name); if (field != null && field.FieldType == typeof(float)) { field.SetValue(c, value); } } catch { } } private static void ApplyDOFSettings(bool force) { Component dOF = GetDOF(); CameraEffects instance = CameraEffects.instance; if (!Object.op_Implicit((Object)(object)dOF)) { return; } bool flag = TrueCameraPlugin.DOF_Enabled.Value || ((Object)(object)instance != (Object)null && instance.m_forceDof); Behaviour val = (Behaviour)(object)((dOF is Behaviour) ? dOF : null); if (Object.op_Implicit((Object)(object)val) && val.enabled != flag) { val.enabled = flag; } if (Object.op_Implicit((Object)(object)instance)) { instance.m_dofAutoFocus = TrueCameraPlugin.DOF_Autofocus.Value; } if (!TrueCameraPlugin.DOF_Autofocus.Value) { float num = Mathf.Clamp(TrueCameraPlugin.DOF_FocusDistance.Value, 0f, 300f); float floatMember = GetFloatMember(dOF, "focalLength", num); float value = (force ? num : Mathf.Lerp(floatMember, num, 0.2f)); SetFloatMember(dOF, "focalLength", value); } float value2 = Mathf.Clamp(TrueCameraPlugin.DOF_MaxBlurSize.Value * Mathf.Max(0.01f, TrueCameraPlugin.DOF_BlurStrength.Value), 0.01f, 10f); SetFloatMember(dOF, "maxBlurSize", value2); bool value3 = TrueCameraPlugin.DOF_InvertNear.Value; Type type = ((object)dOF).GetType(); PropertyInfo property = type.GetProperty("nearBlur"); if (property != null && property.PropertyType == typeof(bool)) { try { property.SetValue(dOF, value3, null); } catch { } } FieldInfo field = type.GetField("nearBlur"); if (field != null && field.FieldType == typeof(bool)) { try { field.SetValue(dOF, value3); } catch { } } PropertyInfo property2 = type.GetProperty("foregroundBlur"); if (property2 != null && property2.PropertyType == typeof(bool)) { try { property2.SetValue(dOF, value3, null); } catch { } } FieldInfo field2 = type.GetField("foregroundBlur"); if (field2 != null && field2.FieldType == typeof(bool)) { try { field2.SetValue(dOF, value3); } catch { } } PropertyInfo property3 = type.GetProperty("foreground"); if (property3 != null && property3.PropertyType == typeof(bool)) { try { property3.SetValue(dOF, value3, null); } catch { } } FieldInfo field3 = type.GetField("foreground"); if (field3 != null && field3.FieldType == typeof(bool)) { try { field3.SetValue(dOF, value3); } catch { } } PropertyInfo property4 = type.GetProperty("invert"); if (property4 != null && property4.PropertyType == typeof(bool)) { try { property4.SetValue(dOF, value3, null); } catch { } } FieldInfo field4 = type.GetField("invert"); if (field4 != null && field4.FieldType == typeof(bool)) { try { field4.SetValue(dOF, value3); } catch { } } } } [HarmonyPatch] internal static class FirstPerson_Modes { [CompilerGenerated] private sealed class d__3 : IEnumerable, IEnumerable, IEnumerator, IDisposable, IEnumerator { private int <>1__state; private T <>2__current; private int <>l__initialThreadId; T IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__3(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { if (<>1__state != 0) { return false; } <>1__state = -1; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; return this; } return new d__3(0); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } private static bool _init; internal static Transform _head; private static Transform _helmetAttach; private static Transform _jaw; private static Transform _eyeL; private static Transform _eyeR; private static Vector3 _origHelmetScale = Vector3.one; private static Vector3 _origJawScale; private static FieldInfo _fiBeardInst = AccessTools.Field(typeof(VisEquipment), "m_beardItemInstance"); private static FieldInfo _fiHairInst = AccessTools.Field(typeof(VisEquipment), "m_hairItemInstance"); private static FieldInfo _fiRightItemInst = AccessTools.Field(typeof(VisEquipment), "m_rightItemInstance"); private static FieldInfo _fiLeftItemInst = AccessTools.Field(typeof(VisEquipment), "m_leftItemInstance"); [HarmonyPostfix] [HarmonyPatch(typeof(Player), "SetLocalPlayer")] private static void OnLocal() { _init = false; } internal static void EnsureSetup(Player p) { //IL_0097: 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_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) if (_init) { return; } _head = FindTF(((Component)p).transform, "Visual", "Armature", "Hips", "Spine", "Spine1", "Spine2", "Neck", "Head"); if (Object.op_Implicit((Object)(object)_head)) { _helmetAttach = _head.Find("Helmet_attach"); if (Object.op_Implicit((Object)(object)_helmetAttach)) { _origHelmetScale = _helmetAttach.localScale; } _jaw = _head.Find("Jaw"); Transform[] componentsInChildren = ((Component)_head).GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { string text = ((Object)val).name.ToLower(); if ((Object)(object)_eyeL == (Object)null && (text.Contains("eye_l") || text.Contains("lefteye"))) { _eyeL = val; } if ((Object)(object)_eyeR == (Object)null && (text.Contains("eye_r") || text.Contains("righteye"))) { _eyeR = val; } } _origJawScale = (Object.op_Implicit((Object)(object)_jaw) ? _jaw.localScale : Vector3.one); } _init = true; } private static Transform FindTF(Transform t, params string[] path) { Transform val = t; foreach (string text in path) { val = val.Find(text); if (!Object.op_Implicit((Object)(object)val)) { break; } } return val; } [IteratorStateMachine(typeof(d__3<>))] private static IEnumerable GetGrandChildren(GameObject root) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__3(-2); } internal static bool IsThirdPerson() { return false; } internal static bool IsFP() { return CameraViewModes.FPActive; } internal static void ApplyVisibility(Player p) { } internal static Transform GetHead(Player p) { EnsureSetup(p); return _head; } } [HarmonyPatch] internal static class FirstPerson_Placeholder { } [HarmonyPatch] internal static class FirstPerson_RotationLimiters { private static Func s_GetKeyFunc; [HarmonyPostfix] [HarmonyPatch(typeof(GameCamera), "UpdateCamera")] private static void ApplyLimiters(GameCamera __instance) { //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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) if (BuildCamera_EnableDisable.Enabled) { return; } Player localPlayer = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)localPlayer) || !CameraViewModes.FPActive || ((Character)localPlayer).IsAttached() || ((Character)localPlayer).IsAttachedToShip() || ((Character)localPlayer).IsRiding()) { return; } KeyboardShortcut value = TrueCameraPlugin.FP_FreeLookKey.Value; bool flag; if (Input.GetKey(((KeyboardShortcut)(ref value)).MainKey)) { if (((KeyboardShortcut)(ref value)).Modifiers != null) { IEnumerable modifiers = ((KeyboardShortcut)(ref value)).Modifiers; Func predicate; if ((predicate = s_GetKeyFunc) == null) { predicate = (s_GetKeyFunc = Input.GetKey); } flag = modifiers.All(predicate); } else { flag = true; } } else { flag = false; } if (flag) { return; } Camera main = Camera.main; if (Object.op_Implicit((Object)(object)main)) { float y = ((Component)main).transform.eulerAngles.y; float num = ((Component)localPlayer).transform.eulerAngles.y; float num2 = Mathf.Clamp(TrueCameraPlugin.FP_MaxShoulderAngle.Value, 10f, 120f); bool value2 = TrueCameraPlugin.FP_Rotate_LockNearShoulders.Value; bool value3 = TrueCameraPlugin.FP_Rotate_SnapRotate.Value; bool value4 = TrueCameraPlugin.FP_Rotate_ForceRotate.Value; float num3 = Mathf.DeltaAngle(num, y); if (value2 && Mathf.Abs(num3) > num2) { float num4 = y - Mathf.Sign(num3) * num2; ((Component)localPlayer).transform.rotation = Quaternion.Euler(0f, num4, 0f); num = num4; num3 = Mathf.DeltaAngle(num, y); } if (value3 && Mathf.Abs(num3) > num2) { ((Component)localPlayer).transform.rotation = Quaternion.Euler(0f, y, 0f); num = y; num3 = 0f; } if (value4 && Mathf.Abs(num3) > 1f) { float value5 = TrueCameraPlugin.FP_ForceRotateSpeed.Value; float num5 = Mathf.MoveTowardsAngle(num, y, value5 * Time.deltaTime); ((Component)localPlayer).transform.rotation = Quaternion.Euler(0f, num5, 0f); } } } } [HarmonyPatch] internal static class HideHud_Patches { [HarmonyPrefix] [HarmonyPatch(typeof(Hud), "SetVisible")] private static void Hud_SetVisible_Prefix(ref bool visible) { if (TrueCameraPlugin.HideHUD != null && TrueCameraPlugin.HideHUD.Value) { visible = false; } } [HarmonyPostfix] [HarmonyPatch(typeof(Hud), "Update")] private static void Hud_Update_Postfix(Hud __instance) { if (TrueCameraPlugin.HideHUD == null || !TrueCameraPlugin.HideHUD.Value || !((Object)(object)__instance != (Object)null)) { return; } __instance.m_userHidden = true; try { MethodInfo methodInfo = AccessTools.Method(typeof(Hud), "SetVisible", (Type[])null, (Type[])null); if (methodInfo != null) { methodInfo.Invoke(__instance, new object[1] { false }); } } catch (Exception ex) { ManualLogSource log = TrueCameraPlugin.Log; if (log != null) { log.LogDebug((object)("Hud.SetVisible invoke: " + ex.Message)); } } } [HarmonyPostfix] [HarmonyPatch(typeof(Hud), "UpdateCrosshair")] private static void Hud_UpdateCrosshair_Postfix(Hud __instance) { if (TrueCameraPlugin.HideHUD != null && TrueCameraPlugin.HideHUD.Value) { if (Object.op_Implicit((Object)(object)__instance) && Object.op_Implicit((Object)(object)__instance.m_crosshair)) { ((Component)__instance.m_crosshair).gameObject.SetActive(false); } if (Object.op_Implicit((Object)(object)__instance) && Object.op_Implicit((Object)(object)__instance.m_crosshairBow)) { ((Component)__instance.m_crosshairBow).gameObject.SetActive(false); } } } [HarmonyPostfix] [HarmonyPatch(typeof(Minimap), "Update")] private static void Minimap_Update_Postfix(Minimap __instance) { if (TrueCameraPlugin.HideHUD != null && TrueCameraPlugin.HideHUD.Value && Object.op_Implicit((Object)(object)__instance)) { if (Object.op_Implicit((Object)(object)__instance.m_smallRoot) && __instance.m_smallRoot.activeSelf) { __instance.m_smallRoot.SetActive(false); } if (Object.op_Implicit((Object)(object)__instance.m_largeRoot) && __instance.m_largeRoot.activeSelf) { __instance.m_largeRoot.SetActive(false); } } } } [HarmonyPatch] internal static class Hotkeys { private static float _fovHeld; private static bool _fovLastDirInc; private static bool _init; private static float _fovTarget; private static float _fovVelocity; private static float _angleHeld; private static bool _angleLastDirInc; private static float _angleTarget; private static float _angleVelocity; private static bool Pressed(KeyboardShortcut ks) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) try { if (((KeyboardShortcut)(ref ks)).IsPressed()) { return true; } } catch { } try { return Input.GetKey(((KeyboardShortcut)(ref ks)).MainKey); } catch { return false; } } [HarmonyPostfix] [HarmonyPatch(typeof(Player), "Update")] private static void OnUpdate(Player __instance) { //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return; } float deltaTime = Time.deltaTime; if (!_init) { string currentModeId = CameraViewModes.CurrentModeId; bool currentAttached = CameraViewModes.CurrentAttached; bool currentCombat = CameraViewModes.CurrentCombat; float fovTarget = ((TrueCameraPlugin.FoV_TP != null) ? TrueCameraPlugin.FoV_TP.Value : 65f); if (currentModeId == "FP" && TrueCameraPlugin.FoV_FP != null) { fovTarget = TrueCameraPlugin.FoV_FP.Value; } else if (currentAttached && TrueCameraPlugin.FoV_TP_Vehicle != null) { fovTarget = TrueCameraPlugin.FoV_TP_Vehicle.Value; } else if (currentCombat && TrueCameraPlugin.FoV_TP_Combat != null) { fovTarget = TrueCameraPlugin.FoV_TP_Combat.Value; } _fovTarget = fovTarget; _angleTarget = TrueCameraPlugin.Camera_SideAngle.Value; _init = true; } KeyboardShortcut value = TrueCameraPlugin.HideHUD_Hotkey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { TrueCameraPlugin.HideHUD.Value = !TrueCameraPlugin.HideHUD.Value; } value = TrueCameraPlugin.ToggleBuildCameraHotkey.Value; if (((KeyboardShortcut)(ref value)).IsDown() && Traverse.Create((object)__instance).Method("TakeInput", Array.Empty()).GetValue()) { if (BuildCamera_EnableDisable.Enabled && BuildCamera_EnableDisable.BoneDrivenActive) { BuildCamera_EnableDisable.ExitBoneDrivenMode(__instance); } else { BuildCamera_EnableDisable.Toggle(__instance); } } value = TrueCameraPlugin.TP_ToggleHotkey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { ThirdPerson_Toggle.Toggle(__instance); } bool num = Pressed(TrueCameraPlugin.Hotkey_FovDecrease.Value); bool flag = Pressed(TrueCameraPlugin.Hotkey_FovIncrease.Value); if (num || flag) { if (flag != _fovLastDirInc) { _fovHeld = 0f; } _fovLastDirInc = flag; _fovHeld += deltaTime; float num2 = Mathf.Clamp01(_fovHeld / 1.5f); float num3 = num2 * num2 * (3f - 2f * num2); float num4 = Mathf.Lerp(5f, 60f, num3); _fovTarget += (flag ? 1f : (-1f)) * num4 * deltaTime; } else { _fovHeld = 0f; string currentModeId2 = CameraViewModes.CurrentModeId; bool currentAttached2 = CameraViewModes.CurrentAttached; bool currentCombat2 = CameraViewModes.CurrentCombat; float fovTarget2 = ((currentModeId2 == "FP") ? TrueCameraPlugin.FoV_FP.Value : (currentAttached2 ? TrueCameraPlugin.FoV_TP_Vehicle.Value : ((!currentCombat2) ? TrueCameraPlugin.FoV_TP.Value : TrueCameraPlugin.FoV_TP_Combat.Value))); _fovTarget = fovTarget2; } _fovTarget = Mathf.Clamp(_fovTarget, 0f, 120f); string currentModeId3 = CameraViewModes.CurrentModeId; bool currentAttached3 = CameraViewModes.CurrentAttached; bool currentCombat3 = CameraViewModes.CurrentCombat; float num5 = ((currentModeId3 == "FP") ? TrueCameraPlugin.FoV_FP.Value : (currentAttached3 ? TrueCameraPlugin.FoV_TP_Vehicle.Value : ((!currentCombat3) ? TrueCameraPlugin.FoV_TP.Value : TrueCameraPlugin.FoV_TP_Combat.Value))); float num6 = Mathf.SmoothDamp(num5, _fovTarget, ref _fovVelocity, 0.15f, float.PositiveInfinity, deltaTime); if (Mathf.Abs(num6 - num5) > 1E-05f) { if (currentModeId3 == "FP") { TrueCameraPlugin.FoV_FP.Value = num6; } else if (currentAttached3) { TrueCameraPlugin.FoV_TP_Vehicle.Value = num6; } else if (currentCombat3) { TrueCameraPlugin.FoV_TP_Combat.Value = num6; } else { TrueCameraPlugin.FoV_TP.Value = num6; } Camera main = Camera.main; if (Object.op_Implicit((Object)(object)main)) { main.fieldOfView = num6; } } bool num7 = Pressed(TrueCameraPlugin.Hotkey_AngleLeft.Value); bool flag2 = Pressed(TrueCameraPlugin.Hotkey_AngleRight.Value); if (num7 || flag2) { if (flag2 != _angleLastDirInc) { _angleHeld = 0f; } _angleLastDirInc = flag2; _angleHeld += deltaTime; float num8 = Mathf.Clamp01(_angleHeld / 1.5f); float num9 = num8 * num8 * (3f - 2f * num8); float num10 = Mathf.Lerp(10f, 180f, num9); _angleTarget += (flag2 ? (-1f) : 1f) * num10 * deltaTime; } else { _angleHeld = 0f; _angleTarget = TrueCameraPlugin.Camera_SideAngle.Value; } _angleTarget = Mathf.Repeat(_angleTarget + 180f, 360f) - 180f; float value2 = TrueCameraPlugin.Camera_SideAngle.Value; float num11 = Mathf.SmoothDampAngle(value2, _angleTarget, ref _angleVelocity, 0.15f, float.PositiveInfinity, deltaTime); if (Mathf.Abs(Mathf.DeltaAngle(num11, value2)) > 1E-05f) { TrueCameraPlugin.Camera_SideAngle.Value = num11; } } } internal static class InputCompat { private static Type _tZInput; private static MethodInfo _miIsGamepadActive; private static MethodInfo _miGetMouseDelta; private static MethodInfo _miGetJoyRX; private static MethodInfo _miGetJoyRY; private static MethodInfo _miGetJoyLX; private static MethodInfo _miGetJoyLY; private static MethodInfo _miGetButton; private static MethodInfo _miGetButtonDown; private static PropertyInfo _piToggleRun; internal static bool ToggleRun { get { try { Ensure(); if (_piToggleRun != null) { return (bool)_piToggleRun.GetValue(null); } } catch { } return false; } } private static void Ensure() { if (!(_tZInput != null)) { _tZInput = AccessTools.TypeByName("ZInput"); if (!(_tZInput == null)) { _miIsGamepadActive = AccessTools.Method(_tZInput, "IsGamepadActive", (Type[])null, (Type[])null); _miGetMouseDelta = AccessTools.Method(_tZInput, "GetMouseDelta", (Type[])null, (Type[])null); _miGetJoyRX = AccessTools.Method(_tZInput, "GetJoyRightStickX", new Type[1] { typeof(bool) }, (Type[])null); _miGetJoyRY = AccessTools.Method(_tZInput, "GetJoyRightStickY", new Type[1] { typeof(bool) }, (Type[])null); _miGetJoyLX = AccessTools.Method(_tZInput, "GetJoyLeftStickX", new Type[1] { typeof(bool) }, (Type[])null); _miGetJoyLY = AccessTools.Method(_tZInput, "GetJoyLeftStickY", new Type[1] { typeof(bool) }, (Type[])null); _miGetButton = AccessTools.Method(_tZInput, "GetButton", new Type[1] { typeof(string) }, (Type[])null); _miGetButtonDown = AccessTools.Method(_tZInput, "GetButtonDown", new Type[1] { typeof(string) }, (Type[])null); _piToggleRun = AccessTools.Property(_tZInput, "ToggleRun"); } } } internal static bool IsGamepadActive() { try { Ensure(); if (_miIsGamepadActive != null) { return (bool)_miIsGamepadActive.Invoke(null, null); } } catch { } return false; } internal static Vector2 GetMouseDelta() { //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_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_0051: 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_0040: 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) try { Ensure(); if (_miGetMouseDelta != null) { return (Vector2)_miGetMouseDelta.Invoke(null, null); } } catch { } try { return new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y")); } catch { return Vector2.zero; } } internal static float GetJoyRightStickX(bool abs) { try { Ensure(); if (_miGetJoyRX != null) { return (float)_miGetJoyRX.Invoke(null, new object[1] { abs }); } } catch { } return 0f; } internal static float GetJoyRightStickY(bool abs) { try { Ensure(); if (_miGetJoyRY != null) { return (float)_miGetJoyRY.Invoke(null, new object[1] { abs }); } } catch { } return 0f; } internal static float GetJoyLeftStickX(bool abs) { try { Ensure(); if (_miGetJoyLX != null) { return (float)_miGetJoyLX.Invoke(null, new object[1] { abs }); } } catch { } return 0f; } internal static float GetJoyLeftStickY(bool abs) { try { Ensure(); if (_miGetJoyLY != null) { return (float)_miGetJoyLY.Invoke(null, new object[1] { abs }); } } catch { } return 0f; } private static bool ZBtn(string key) { try { Ensure(); if (_miGetButton != null) { return (bool)_miGetButton.Invoke(null, new object[1] { key }); } } catch { } return false; } private static bool ZBtnDown(string key) { try { Ensure(); if (_miGetButtonDown != null) { return (bool)_miGetButtonDown.Invoke(null, new object[1] { key }); } } catch { } return false; } internal static bool GetButton(string name) { switch (name) { case "Backward": if (!Input.GetKey((KeyCode)115)) { if (IsGamepadActive()) { return ZBtn("Backward"); } return false; } return true; case "Right": if (!Input.GetKey((KeyCode)100)) { if (IsGamepadActive()) { return ZBtn("Right"); } return false; } return true; case "Jump": if (!Input.GetKey((KeyCode)32)) { if (IsGamepadActive()) { if (!ZBtn("Jump")) { return ZBtn("JoyJump"); } return true; } return false; } return true; case "Left": if (!Input.GetKey((KeyCode)97)) { if (IsGamepadActive()) { return ZBtn("Left"); } return false; } return true; case "Run": if (!Input.GetKey((KeyCode)304)) { if (IsGamepadActive()) { if (!ZBtn("Run")) { return ZBtn("JoyRun"); } return true; } return false; } return true; case "Forward": if (!Input.GetKey((KeyCode)119)) { if (IsGamepadActive()) { return ZBtn("Forward"); } return false; } return true; case "Crouch": if (!Input.GetKey((KeyCode)306) && !Input.GetKey((KeyCode)99)) { if (IsGamepadActive()) { if (!ZBtn("Crouch")) { return ZBtn("JoyCrouch"); } return true; } return false; } return true; default: return false; } } internal static bool GetButtonDown(string name) { int result; switch (name) { case "JoyCrouch": if (!IsGamepadActive()) { goto default; } result = (ZBtnDown("JoyCrouch") ? 1 : 0); goto IL_0051; default: result = 0; goto IL_0051; case "JoyJump": return IsGamepadActive() && ZBtnDown("JoyJump"); case "JoyHide": return IsGamepadActive() && ZBtnDown("JoyButtonY"); case "Hide": { return Input.GetKeyDown((KeyCode)104); } IL_0051: return (byte)result != 0; } } } internal static class LocalVisibility { private struct Saved { public Renderer R; public ShadowCastingMode PrevMode; } private static readonly List _saved = new List(); private static bool _applied; internal static void Clear() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (!_applied) { return; } foreach (Saved item in _saved) { if (Object.op_Implicit((Object)(object)item.R)) { item.R.shadowCastingMode = item.PrevMode; } } _saved.Clear(); _applied = false; } private static void SetShadowsOnly(Renderer r) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)r)) { _saved.Add(new Saved { R = r, PrevMode = r.shadowCastingMode }); r.shadowCastingMode = (ShadowCastingMode)3; } } internal static void ApplyNoHead(Player p, Transform head, Transform helmetAttach, FieldInfo fiBeard, FieldInfo fiHair) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)p) || _applied) { return; } if (Object.op_Implicit((Object)(object)head)) { Renderer[] componentsInChildren = ((Component)head).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { SetShadowsOnly(componentsInChildren[i]); } } if (Object.op_Implicit((Object)(object)helmetAttach)) { foreach (Transform item in helmetAttach) { Renderer[] componentsInChildren = ((Component)item).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { SetShadowsOnly(componentsInChildren[i]); } } } VisEquipment componentInChildren = ((Component)p).GetComponentInChildren(); if (Object.op_Implicit((Object)(object)componentInChildren)) { object? obj = ((fiBeard != null) ? fiBeard.GetValue(componentInChildren) : null); GameObject val = (GameObject)((obj is GameObject) ? obj : null); object? obj2 = ((fiHair != null) ? fiHair.GetValue(componentInChildren) : null); GameObject val2 = (GameObject)((obj2 is GameObject) ? obj2 : null); if (Object.op_Implicit((Object)(object)val)) { Renderer[] componentsInChildren = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { SetShadowsOnly(componentsInChildren[i]); } } if (Object.op_Implicit((Object)(object)val2)) { Renderer[] componentsInChildren = val2.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { SetShadowsOnly(componentsInChildren[i]); } } } _applied = true; } internal static void ApplyBodyHidden(Player p, bool hideWeapons, FieldInfo fiRight, FieldInfo fiLeft) { if (!Object.op_Implicit((Object)(object)p) || _applied) { return; } GameObject visual = ((Character)p).GetVisual(); if (Object.op_Implicit((Object)(object)visual)) { Transform val = visual.transform.Find("body"); Renderer val2 = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent() : null); if (Object.op_Implicit((Object)(object)val2)) { SetShadowsOnly(val2); } } if (hideWeapons) { VisEquipment componentInChildren = ((Component)p).GetComponentInChildren(); if (Object.op_Implicit((Object)(object)componentInChildren)) { object? obj = ((fiRight != null) ? fiRight.GetValue(componentInChildren) : null); GameObject val3 = (GameObject)((obj is GameObject) ? obj : null); object? obj2 = ((fiLeft != null) ? fiLeft.GetValue(componentInChildren) : null); GameObject val4 = (GameObject)((obj2 is GameObject) ? obj2 : null); if (Object.op_Implicit((Object)(object)val3)) { Renderer[] componentsInChildren = val3.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { SetShadowsOnly(componentsInChildren[i]); } } if (Object.op_Implicit((Object)(object)val4)) { Renderer[] componentsInChildren = val4.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { SetShadowsOnly(componentsInChildren[i]); } } } } _applied = true; } } internal static class ModeManager { private static bool _prevFPEnabled; private static bool _hasPrevFP; private static bool _prevTPEnabled; private static bool _hasPrevTP; private static float? _defaultNear; internal static void EnsureDefaults(Camera cam) { if (!_defaultNear.HasValue && Object.op_Implicit((Object)(object)cam)) { _defaultNear = cam.nearClipPlane; } } internal static void DisableAllExcept(string mode) { if (!(mode != "Build")) { _prevFPEnabled = TrueCameraPlugin.FP_Enabled.Value; _hasPrevFP = true; if (_prevFPEnabled) { TrueCameraPlugin.FP_Enabled.Value = false; } _prevTPEnabled = TrueCameraPlugin.TP_Enabled.Value; _hasPrevTP = true; if (_prevTPEnabled) { TrueCameraPlugin.TP_Enabled.Value = false; } } } internal static void OnModeDisabled(string mode) { if (mode == "Build") { if (_hasPrevFP) { TrueCameraPlugin.FP_Enabled.Value = _prevFPEnabled; _hasPrevFP = false; } if (_hasPrevTP) { TrueCameraPlugin.TP_Enabled.Value = _prevTPEnabled; _hasPrevTP = false; } } Camera main = Camera.main; try { if (Object.op_Implicit((Object)(object)main) && _defaultNear.HasValue) { main.nearClipPlane = _defaultNear.Value; } } catch (Exception ex) { ManualLogSource log = TrueCameraPlugin.Log; if (log != null) { log.LogDebug((object)("ModeManager.OnModeDisabled restore near: " + ex.Message)); } } } } internal sealed class NativeCullingController : MonoBehaviour { private readonly List _head = new List(); private readonly List _helmet = new List(); private readonly List _hairBeard = new List(); private readonly List _body = new List(); private readonly List _hands = new List(); private bool _initialized; private bool _noHead; private bool _noBody; private static readonly int CamCullProp = Shader.PropertyToID("_CamCull"); private static FieldInfo _fiBeardInst = AccessTools.Field(typeof(VisEquipment), "m_beardItemInstance"); private static FieldInfo _fiHairInst = AccessTools.Field(typeof(VisEquipment), "m_hairItemInstance"); private static FieldInfo _fiRightItemInst = AccessTools.Field(typeof(VisEquipment), "m_rightItemInstance"); private static FieldInfo _fiLeftItemInst = AccessTools.Field(typeof(VisEquipment), "m_leftItemInstance"); private MaterialPropertyBlock _mpbHide; private MaterialPropertyBlock _mpbShow; internal static NativeCullingController Ensure(Camera cam) { NativeCullingController nativeCullingController = ((Component)cam).GetComponent(); if (!Object.op_Implicit((Object)(object)nativeCullingController)) { nativeCullingController = ((Component)cam).gameObject.AddComponent(); } return nativeCullingController; } internal void InitializeFor(Player p) { //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Expected O, but got Unknown //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Expected O, but got Unknown //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Expected O, but got Unknown if (_initialized || !Object.op_Implicit((Object)(object)p)) { return; } _head.Clear(); _helmet.Clear(); _hairBeard.Clear(); _body.Clear(); _hands.Clear(); Transform val = null; try { val = FirstPerson_Modes.GetHead(p); } catch (Exception ex) { ManualLogSource log = TrueCameraPlugin.Log; if (log != null) { log.LogDebug((object)("GetHead: " + ex.Message)); } } if (Object.op_Implicit((Object)(object)val)) { _head.AddRange(((Component)val).GetComponentsInChildren(true)); Transform val2 = val.Find("Helmet_attach"); if (Object.op_Implicit((Object)(object)val2)) { foreach (Transform item in val2) { Transform val3 = item; _helmet.AddRange(((Component)val3).GetComponentsInChildren(true)); } } } VisEquipment componentInChildren = ((Component)p).GetComponentInChildren(); if (Object.op_Implicit((Object)(object)componentInChildren)) { GameObject val4 = null; GameObject val5 = null; try { FieldInfo fiBeardInst = _fiBeardInst; object? obj = ((fiBeardInst != null) ? fiBeardInst.GetValue(componentInChildren) : null); val4 = (GameObject)((obj is GameObject) ? obj : null); } catch (Exception ex2) { ManualLogSource log2 = TrueCameraPlugin.Log; if (log2 != null) { log2.LogDebug((object)("fiBeard: " + ex2.Message)); } } try { FieldInfo fiHairInst = _fiHairInst; object? obj2 = ((fiHairInst != null) ? fiHairInst.GetValue(componentInChildren) : null); val5 = (GameObject)((obj2 is GameObject) ? obj2 : null); } catch (Exception ex3) { ManualLogSource log3 = TrueCameraPlugin.Log; if (log3 != null) { log3.LogDebug((object)("fiHair: " + ex3.Message)); } } if (Object.op_Implicit((Object)(object)val4)) { _hairBeard.AddRange(val4.GetComponentsInChildren(true)); } if (Object.op_Implicit((Object)(object)val5)) { _hairBeard.AddRange(val5.GetComponentsInChildren(true)); } GameObject val6 = null; GameObject val7 = null; try { FieldInfo fiRightItemInst = _fiRightItemInst; object? obj3 = ((fiRightItemInst != null) ? fiRightItemInst.GetValue(componentInChildren) : null); val6 = (GameObject)((obj3 is GameObject) ? obj3 : null); } catch (Exception ex4) { ManualLogSource log4 = TrueCameraPlugin.Log; if (log4 != null) { log4.LogDebug((object)("fiRight: " + ex4.Message)); } } try { FieldInfo fiLeftItemInst = _fiLeftItemInst; object? obj4 = ((fiLeftItemInst != null) ? fiLeftItemInst.GetValue(componentInChildren) : null); val7 = (GameObject)((obj4 is GameObject) ? obj4 : null); } catch (Exception ex5) { ManualLogSource log5 = TrueCameraPlugin.Log; if (log5 != null) { log5.LogDebug((object)("fiLeft: " + ex5.Message)); } } if (Object.op_Implicit((Object)(object)val6)) { _hands.AddRange(val6.GetComponentsInChildren(true)); } if (Object.op_Implicit((Object)(object)val7)) { _hands.AddRange(val7.GetComponentsInChildren(true)); } } GameObject visual = ((Character)p).GetVisual(); if (Object.op_Implicit((Object)(object)visual)) { Transform val8 = visual.transform.Find("body"); if (Object.op_Implicit((Object)(object)val8)) { _body.AddRange(((Component)val8).GetComponentsInChildren(true)); } } _mpbHide = new MaterialPropertyBlock(); _mpbHide.SetFloat(CamCullProp, 1f); _mpbShow = new MaterialPropertyBlock(); _mpbShow.SetFloat(CamCullProp, 0f); _initialized = true; } internal void SetFlags(bool noHead, bool noBody) { _noHead = noHead; _noBody = noBody; } private void ApplyBlock(List list, MaterialPropertyBlock block) { for (int i = 0; i < list.Count; i++) { Renderer val = list[i]; if (Object.op_Implicit((Object)(object)val)) { val.SetPropertyBlock(block); } } } internal void RestoreAll() { ApplyBlock(_head, _mpbShow); ApplyBlock(_helmet, _mpbShow); ApplyBlock(_hairBeard, _mpbShow); ApplyBlock(_body, _mpbShow); ApplyBlock(_hands, _mpbShow); } private void OnPreCull() { if (!CameraViewModes.FPActive) { RestoreAll(); return; } ApplyBlock(_head, _noHead ? _mpbHide : _mpbShow); ApplyBlock(_helmet, _noHead ? _mpbHide : _mpbShow); ApplyBlock(_hairBeard, _noHead ? _mpbHide : _mpbShow); ApplyBlock(_body, _noBody ? _mpbHide : _mpbShow); ApplyBlock(_hands, _noBody ? _mpbHide : _mpbShow); } private void OnPostRender() { if (!CameraViewModes.FPActive) { RestoreAll(); } } } internal static class ReflectionCache { private static readonly ConcurrentDictionary, MethodInfo> _methods = new ConcurrentDictionary, MethodInfo>(); private static readonly ConcurrentDictionary, FieldInfo> _fields = new ConcurrentDictionary, FieldInfo>(); internal static MethodInfo GetMethod(Type t, string name, params Type[] signature) { try { string text = string.Empty; if (signature != null && signature.Length != 0) { string[] array = new string[signature.Length]; for (int i = 0; i < signature.Length; i++) { int num = i; Type type = signature[i]; array[num] = ((type != null) ? type.FullName : null) ?? "null"; } text = "#" + string.Join("_", array); } Tuple key = new Tuple(t, name + text); if (_methods.TryGetValue(key, out var value)) { return value; } value = ((signature != null && signature.Length != 0) ? AccessTools.Method(t, name, signature, (Type[])null) : AccessTools.Method(t, name, (Type[])null, (Type[])null)); if (value != null) { _methods[key] = value; } return value; } catch { return null; } } internal static FieldInfo GetField(Type t, string name) { try { Tuple key = new Tuple(t, name); if (_fields.TryGetValue(key, out var value)) { return value; } value = AccessTools.Field(t, name); if (value != null) { _fields[key] = value; } return value; } catch { return null; } } } [HarmonyPatch] internal static class Respawn_Reset { [HarmonyPostfix] [HarmonyPatch(typeof(Player), "OnDeath")] private static void OnPlayerDeath(Player __instance) { try { if ((Object)(object)__instance != (Object)null && (Object)(object)__instance == (Object)(object)Player.m_localPlayer) { TrueCameraPlugin.Restore(); } } catch { } } [HarmonyPostfix] [HarmonyPatch(typeof(Player), "OnRespawn")] private static void OnPlayerRespawn(Player __instance) { try { if ((Object)(object)__instance != (Object)null && (Object)(object)__instance == (Object)(object)Player.m_localPlayer) { TrueCameraPlugin.ScheduleReenableAfterRespawn(); } } catch { } } } internal static class ThirdPerson_Toggle { internal static void Toggle(Player player) { if (Object.op_Implicit((Object)(object)player)) { TrueCameraPlugin.TP_Enabled.Value = !TrueCameraPlugin.TP_Enabled.Value; ((Character)player).Message((MessageType)2, "Third Person " + (TrueCameraPlugin.TP_Enabled.Value ? "enabled" : "disabled") + ".", 0, (Sprite)null); } } } }