Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of First Person POV v0.1.12
BepInEx/plugins/FirstPersonPOV.dll
Decompiled 4 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] namespace JPValheim.FirstPersonPOV; internal static class ConfigMigration { internal const string LegacyGuid = "jpvalheim.naturalfirstperson"; internal static float? Import(ConfigFile config, string legacyPath) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (File.Exists(config.ConfigFilePath) || !File.Exists(legacyPath)) { return null; } ConfigFile val = new ConfigFile(legacyPath, false) { SaveOnConfigSet = false }; float value = val.Bind<float>("Body Awareness", "HardYawDegrees", 75f, (ConfigDescription)null).Value; float value2 = val.Bind<float>("Body Awareness", "SoftYawDegrees", 40f, (ConfigDescription)null).Value; float num = Math.Min(90f, Math.Max(value, value2) + 10f); if (float.IsNaN(num) || float.IsInfinity(num)) { num = 85f; } File.Copy(legacyPath, config.ConfigFilePath); config.Reload(); config.Remove(((ConfigEntryBase)config.Bind<float>("Body Awareness", "HardYawDegrees", 75f, (ConfigDescription)null)).Definition); config.Remove(((ConfigEntryBase)config.Bind<int>("Internal", "LookDefaultsRevision", 0, (ConfigDescription)null)).Definition); return num; } } [BepInPlugin("jpvalheim.firstpersonpov", "First Person POV", "0.1.12")] [BepInIncompatibility("jpvalheim.naturalfirstperson")] public sealed class FirstPersonPOVPlugin : BaseUnityPlugin { private struct CameraOverrideState { public bool Active; public float Distance; public Vector3 FpsOffset; public bool BaseOffsetOverridden; public Vector3 BaseOffset; } [HarmonyPatch(typeof(Character), "SetVisible")] private static class CharacterSetVisiblePatch { private static bool Prefix(Character __instance) { Player val = (Player)(object)((__instance is Player) ? __instance : null); if ((Object)(object)val == (Object)null || (Object)(object)val != (Object)(object)Player.m_localPlayer) { return true; } if (IsFirstPersonRequested(val)) { ApplyFirstPersonVisibility(val); return false; } if (_lodSettingsOverridden) { RestoreFirstPersonVisibility(); } return true; } } [HarmonyPatch(typeof(Player), "SetMouseLook")] private static class SetMouseLookPatch { private static void Prefix(Player __instance, ref Vector2 mouseLook) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && IsFirstPersonRequested(__instance) && !(LookYawField == null)) { float y = ((Component)__instance).transform.eulerAngles.y; Quaternion val = (Quaternion)LookYawField.GetValue(__instance); float relativeYaw = Mathf.DeltaAngle(y, ((Quaternion)(ref val)).eulerAngles.y); mouseLook.x = YawResistance.Apply(relativeYaw, mouseLook.x, YawResistanceStart.Value, YawResistanceWidth.Value, MaxYawDegrees.Value); } } private static void Postfix(Player __instance) { if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer && IsFirstPersonRequested(__instance)) { ApplyFirstPersonLookConstraints(__instance); } } } [HarmonyPatch(typeof(Character), "UpdateRotation")] private static class BodyAwareRotationPatch { private struct RotationState { public bool Active; public Quaternion CameraYaw; } private static void Prefix(Character __instance, ref float turnSpeed, out RotationState __state) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_009b: Unknown result type (might be due to invalid IL or missing references) __state = default(RotationState); Player val = (Player)(object)((__instance is Player) ? __instance : null); if (!((Object)(object)val == (Object)null) && !((Object)(object)val != (Object)(object)Player.m_localPlayer) && ShouldApplyBodyYawController(val) && !(LookYawField == null)) { ApplyFirstPersonLookConstraints(val); Quaternion cameraYaw = (Quaternion)LookYawField.GetValue(val); float y = ((Component)val).transform.eulerAngles.y; float num = Mathf.DeltaAngle(y, ((Quaternion)(ref cameraYaw)).eulerAngles.y); float num2 = Mathf.Min(SoftYawDegrees.Value, YawResistanceStart.Value); float num3 = y; if (Mathf.Abs(num) > num2) { num3 = ((Quaternion)(ref cameraYaw)).eulerAngles.y - Mathf.Sign(num) * num2; } __state.Active = true; __state.CameraYaw = cameraYaw; _forceBodyRotationCameraTarget = true; LookYawField.SetValue(val, Quaternion.Euler(0f, num3, 0f)); turnSpeed = BodyTurnSpeed.Value; } } private static void Postfix(Character __instance, RotationState __state) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) if (__state.Active) { _forceBodyRotationCameraTarget = false; Player val = (Player)(object)((__instance is Player) ? __instance : null); if (!((Object)(object)val == (Object)null) && !((Object)(object)val != (Object)(object)Player.m_localPlayer) && !(LookYawField == null)) { LookYawField.SetValue(val, __state.CameraYaw); ApplyFirstPersonLookConstraints(val); } } } } [HarmonyPatch(typeof(Player), "AlwaysRotateCamera")] private static class AlwaysRotateCameraPatch { private static void Postfix(Player __instance, ref bool __result) { if (_forceBodyRotationCameraTarget && (Object)(object)__instance == (Object)(object)Player.m_localPlayer) { __result = true; } } } [HarmonyPatch(typeof(GameCamera), "UpdateCamera")] private static class UpdateCameraPatch { private static void Prefix(GameCamera __instance) { RestoreBowVisual(); RestoreHead(); _forceBodyRotationCameraTarget = false; _firstPersonFrame = false; if (GameCamera.InFreeFly()) { RestoreFirstPersonVisibility(); ResetPoseResidual(); _wasFirstPerson = false; if (_fovOverridden) { RestoreVanillaFov(__instance); _fovOverridden = false; } } } private static void Postfix(GameCamera __instance) { Player localPlayer = Player.m_localPlayer; if (!_firstPersonFrame || !((Object)(object)localPlayer != (Object)null) || GameCamera.InFreeFly()) { ResetBowVisual(); RestoreLocalShadow(); if (_wasFirstPerson) { RestoreFirstPersonVisibility(); ResetPoseResidual(); _wasFirstPerson = false; } if (!GameCamera.InFreeFly()) { _fovOverridden = false; } } else { ApplyFirstPersonVisibility(localPlayer); UpdateBowVisual(localPlayer); ApplyLocalShadow(localPlayer); _wasFirstPerson = true; ApplyFirstPersonFov(__instance); ApplyFirstPersonNearClip(__instance); ApplyHeadHide(localPlayer); } } } [HarmonyPatch(typeof(GameCamera), "GetCameraPosition")] private static class GetCameraPositionPatch { private static void Prefix(GameCamera __instance, float dt, ref float ___m_distance, ref Vector3 ___m_fpsOffset, out CameraOverrideState __state) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00de: 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_00d5: Unknown result type (might be due to invalid IL or missing references) __state = default(CameraOverrideState); Player localPlayer = Player.m_localPlayer; if (_firstPersonLocked && CanUseFirstPerson(localPlayer)) { ___m_distance = __instance.m_minDistance; } if (!ShouldUseFirstPerson(localPlayer, ___m_distance, __instance.m_minDistance)) { return; } __state.Active = true; __state.Distance = ___m_distance; __state.FpsOffset = ___m_fpsOffset; ApplyFirstPersonLookConstraints(localPlayer); if (CameraBaseOffsetField != null) { Vector3 baseOffset = (Vector3)CameraBaseOffsetField.GetValue(__instance); __state.BaseOffset = baseOffset; __state.BaseOffsetOverridden = true; Vector3 val = EvaluateStableEye(localPlayer, dt); Vector3 val2 = ((Component)localPlayer).transform.position; if (!((Character)localPlayer).IsAttached() && !((Object)(object)((Character)localPlayer).GetStandingOnShip() != (Object)null) && CameraPlayerPosField != null) { val2 = (Vector3)CameraPlayerPosField.GetValue(__instance); } CameraBaseOffsetField.SetValue(__instance, val - val2); } ___m_distance = 0f; ___m_fpsOffset = Vector3.zero; _firstPersonFrame = true; } private static void Postfix(GameCamera __instance, ref float ___m_distance, ref Vector3 ___m_fpsOffset, CameraOverrideState __state) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (__state.Active) { ___m_distance = __state.Distance; ___m_fpsOffset = __state.FpsOffset; if (__state.BaseOffsetOverridden && CameraBaseOffsetField != null) { CameraBaseOffsetField.SetValue(__instance, __state.BaseOffset); } } } } [HarmonyPatch(typeof(GameCamera), "ToggleFreeFly")] private static class ToggleFreeFlyPatch { private static void Prefix(GameCamera __instance) { ResetBowVisual(); RestoreLocalShadow(); RestoreHead(); ResetPoseResidual(); RestoreFirstPersonVisibility(); RestoreFreeFlyNearClip(__instance); _wasFirstPerson = false; if (_fovOverridden) { RestoreVanillaFov(__instance); _fovOverridden = false; } _firstPersonFrame = false; } } [HarmonyPatch(typeof(Hud), "Update")] private static class HudUpdatePatch { private static void Prefix(Hud __instance) { //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) if ((Object)(object)Player.m_localPlayer != (Object)null) { KeyboardShortcut value = ToggleHudKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { __instance.m_userHidden = !__instance.m_userHidden; } } } } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEvent <>9__67_0; public static ConsoleEvent <>9__67_1; public static Comparison<ConfigEntryBase> <>9__70_0; internal void <Awake>b__67_0(ConsoleEventArgs args) { _firstPersonLocked = false; args.Context.AddString("First Person POV: first-person lock disabled."); } internal void <Awake>b__67_1(ConsoleEventArgs args) { _firstPersonLocked = true; GameCamera instance = GameCamera.instance; if ((Object)(object)instance != (Object)null && CameraDistanceField != null) { CameraDistanceField.SetValue(instance, instance.m_minDistance); } args.Context.AddString("First Person POV: first-person lock enabled."); } internal int <PrintSettingHelp>b__70_0(ConfigEntryBase a, ConfigEntryBase b) { return string.Compare(a.Definition.Section + a.Definition.Key, b.Definition.Section + b.Definition.Key, StringComparison.Ordinal); } } public const string PluginGuid = "jpvalheim.firstpersonpov"; public const string PluginName = "First Person POV"; public const string PluginVersion = "0.1.12"; private const float HiddenHeadScale = 0.0001f; private const float DistanceEpsilon = 0.001f; internal static ConfigEntry<float> FirstPersonFov; internal static ConfigEntry<bool> ForceFirstPerson; internal static ConfigEntry<float> ForwardOffset; internal static ConfigEntry<float> VerticalOffset; internal static ConfigEntry<float> SoftYawDegrees; internal static ConfigEntry<float> YawResistanceStart; internal static ConfigEntry<float> YawResistanceWidth; internal static ConfigEntry<float> MaxYawDegrees; internal static ConfigEntry<float> BodyTurnSpeed; internal static ConfigEntry<float> PoseResidualSmoothing; internal static ConfigEntry<float> MaxLookDown; internal static ConfigEntry<float> FirstPersonNearClip; internal static ConfigEntry<KeyboardShortcut> ToggleHudKey; internal static ConfigEntry<float> DrawnBowRoll; internal static ConfigEntry<bool> HideHeadlessShadow; private static readonly FieldInfo HeadField = AccessTools.Field(typeof(Character), "m_head"); private static readonly FieldInfo LodVisibleField = AccessTools.Field(typeof(Character), "m_lodVisible"); private static readonly FieldInfo LodGroupField = AccessTools.Field(typeof(Character), "m_lodGroup"); private static readonly FieldInfo OriginalLocalRefField = AccessTools.Field(typeof(Character), "m_originalLocalRef"); private static readonly FieldInfo CameraDistanceField = AccessTools.Field(typeof(GameCamera), "m_distance"); private static readonly FieldInfo CameraBaseOffsetField = AccessTools.Field(typeof(GameCamera), "m_currentBaseOffset"); private static readonly FieldInfo CameraPlayerPosField = AccessTools.Field(typeof(GameCamera), "m_playerPos"); private static readonly FieldInfo LookYawField = AccessTools.Field(typeof(Character), "m_lookYaw"); private static readonly FieldInfo LookDirField = AccessTools.Field(typeof(Character), "m_lookDir"); private static readonly FieldInfo LookPitchField = AccessTools.Field(typeof(Player), "m_lookPitch"); private static readonly FieldInfo VisualField = AccessTools.Field(typeof(Character), "m_visual"); private static readonly FieldInfo HelmetItemInstanceField = AccessTools.Field(typeof(VisEquipment), "m_helmetItemInstance"); private static readonly FieldInfo HairItemInstanceField = AccessTools.Field(typeof(VisEquipment), "m_hairItemInstance"); private static readonly FieldInfo BeardItemInstanceField = AccessTools.Field(typeof(VisEquipment), "m_beardItemInstance"); private static readonly FieldInfo LeftItemInstanceField = AccessTools.Field(typeof(VisEquipment), "m_leftItemInstance"); private static readonly FieldInfo RightItemInstanceField = AccessTools.Field(typeof(VisEquipment), "m_rightItemInstance"); private static readonly FieldInfo LeftEquippedItemField = AccessTools.Field(typeof(Humanoid), "m_leftItem"); private static readonly FieldInfo RightEquippedItemField = AccessTools.Field(typeof(Humanoid), "m_rightItem"); private static bool _firstPersonFrame; private static bool _firstPersonLocked; private static bool _wasFirstPerson; private static bool _fovOverridden; private static bool _forceBodyRotationCameraTarget; private static LODGroup _firstPersonLodGroup; private static bool _lodSettingsOverridden; private static bool _originalAnimateCrossFading; private static LODFadeMode _originalFadeMode; private static Transform _scaledHead; private static Vector3 _originalHeadScale; private static bool _headScaled; private static readonly Dictionary<Renderer, bool> HiddenHeadRendererStates = new Dictionary<Renderer, bool>(); private static readonly List<Renderer> HeadRenderers = new List<Renderer>(); private static readonly Dictionary<Renderer, ShadowCastingMode> LocalShadowStates = new Dictionary<Renderer, ShadowCastingMode>(); private static readonly List<Renderer> ShadowRenderers = new List<Renderer>(); private static Transform _bowVisual; private static Quaternion _bowOriginalRotation; private static bool _bowRenderRotationApplied; private static float _bowRollAngle; private static Player _anchorPlayer; private static Transform _anchorVisualRoot; private static Transform _anchorEye; private static Vector3 _baselineVisualRootLocal; private static Vector3 _neutralEyeRelativeToVisualRoot; private static Vector3 _filteredPoseResidual; private static bool _anchorInitialized; private static bool _anchorNeedsNeutralRecalibration; private Harmony _harmony; private void Awake() { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Expected O, but got Unknown //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Expected O, but got Unknown //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: 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_0211: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Expected O, but got Unknown //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Expected O, but got Unknown //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Expected O, but got Unknown //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Expected O, but got Unknown //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Expected O, but got Unknown //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Expected O, but got Unknown //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Expected O, but got Unknown //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Expected O, but got Unknown //IL_042d: Unknown result type (might be due to invalid IL or missing references) //IL_0466: Unknown result type (might be due to invalid IL or missing references) //IL_0451: Unknown result type (might be due to invalid IL or missing references) //IL_0456: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Expected O, but got Unknown //IL_049f: Unknown result type (might be due to invalid IL or missing references) //IL_04ab: Unknown result type (might be due to invalid IL or missing references) //IL_04b5: Expected O, but got Unknown //IL_04cc: Unknown result type (might be due to invalid IL or missing references) //IL_04d6: Expected O, but got Unknown //IL_04d6: Unknown result type (might be due to invalid IL or missing references) //IL_04e0: Expected O, but got Unknown //IL_04ec: Unknown result type (might be due to invalid IL or missing references) //IL_04f6: Expected O, but got Unknown //IL_04f6: Unknown result type (might be due to invalid IL or missing references) //IL_0500: Expected O, but got Unknown //IL_048a: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_0495: Expected O, but got Unknown ((BaseUnityPlugin)this).Config.SaveOnConfigSet = false; float? num = null; try { num = ConfigMigration.Import(((BaseUnityPlugin)this).Config, Path.Combine(Paths.ConfigPath, "jpvalheim.naturalfirstperson.cfg")); } catch (IOException ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not import previous settings: " + ex.Message)); } catch (UnauthorizedAccessException ex2) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not import previous settings: " + ex2.Message)); } FirstPersonFov = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "FirstPersonFOV", 70f, new ConfigDescription("Field of view used only while first person is active.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(30f, 120f), Array.Empty<object>())); ForceFirstPerson = ((BaseUnityPlugin)this).Config.Bind<bool>("Mode", "ForceFirstPerson", false, "Forces first-person mode on when the plugin loads. While locked, normal zoom cannot leave first person. Use the console commands unlockfirstperson and lockfirstperson to change the lock for the current game session."); _firstPersonLocked = ForceFirstPerson.Value; ForceFirstPerson.SettingChanged += OnForceFirstPersonChanged; ForwardOffset = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "EyeForwardOffset", 0.1f, new ConfigDescription("Fine forward trim in meters from the calibrated neutral eye position. The stable anchor already follows the body; this is only for personal fit.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-0.05f, 0.2f), Array.Empty<object>())); VerticalOffset = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "EyeVerticalOffset", 0.05f, new ConfigDescription("Fine vertical trim in meters from the calibrated neutral eye position. Positive values raise the viewpoint.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-0.1f, 0.2f), Array.Empty<object>())); SoftYawDegrees = ((BaseUnityPlugin)this).Config.Bind<float>("Body Awareness", "SoftYawDegrees", 40f, new ConfigDescription("Relative view angle where the torso begins catching up to the camera.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 60f), Array.Empty<object>())); YawResistanceStart = ((BaseUnityPlugin)this).Config.Bind<float>("Body Awareness", "YawResistanceStart", 85f, new ConfigDescription("Sideways angle where outward look begins slowing. Limited below MaxYawDegrees.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(30f, 120f), Array.Empty<object>())); YawResistanceWidth = ((BaseUnityPlugin)this).Config.Bind<float>("Body Awareness", "YawResistanceWidth", 15f, new ConfigDescription("Degrees past the resistance start that reduce outward speed to one quarter. Smaller values feel tighter. Inward look stays immediate.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 60f), Array.Empty<object>())); MaxYawDegrees = ((BaseUnityPlugin)this).Config.Bind<float>("Body Awareness", "MaxYawDegrees", 160f, new ConfigDescription("Distant safety limit for sideways look. Resistance makes this difficult to reach.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(90f, 175f), Array.Empty<object>())); if (num.HasValue) { YawResistanceStart.Value = num.Value; } BodyTurnSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Body Awareness", "BodyTurnSpeed", 480f, new ConfigDescription("Maximum torso catch-up speed in degrees per second.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(120f, 900f), Array.Empty<object>())); PoseResidualSmoothing = ((BaseUnityPlugin)this).Config.Bind<float>("Body Awareness", "PoseResidualSmoothing", 0.04f, new ConfigDescription("Seconds used to filter animation-only eye motion. Root translation is never delayed by this value.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 0.15f), Array.Empty<object>())); MaxLookDown = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "MaxLookDown", 40f, new ConfigDescription("Maximum downward first-person look angle in degrees. Valheim's upward limit remains unchanged.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(20f, 89f), Array.Empty<object>())); FirstPersonNearClip = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "NearClip", 0.03f, new ConfigDescription("First-person near clipping plane in meters. Lower values reveal more nearby hands/body geometry; higher values trim geometry extremely close to the eyes.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.005f, 0.2f), Array.Empty<object>())); ToggleHudKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("HUD", "ToggleHudKey", new KeyboardShortcut((KeyCode)282, Array.Empty<KeyCode>()), "Alternative key for toggling Valheim's own user-hidden HUD state. Bare F1 by default; Ctrl+F1 remains Valheim's mouse-capture shortcut."); DrawnBowRoll = ((BaseUnityPlugin)this).Config.Bind<float>("Bow", "DrawnBowRollDegrees", 75f, new ConfigDescription("Clockwise screen-space roll of the visible bow while drawing in first person. The arrow's attack origin and direction are unchanged.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-180f, 180f), Array.Empty<object>())); HideHeadlessShadow = ((BaseUnityPlugin)this).Config.Bind<bool>("Body Awareness", "HideHeadlessShadow", true, "Hides the local player's entire shadow while first person is active, so the collapsed head does not cast a headless silhouette. Disable this to retain the original body shadow."); ((BaseUnityPlugin)this).Config.SaveOnConfigSet = true; ((BaseUnityPlugin)this).Config.Save(); new ConsoleCommand("ffpov", "List or change First Person POV settings.", new ConsoleEvent(HandleSettingCommand), false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj = <>c.<>9__67_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { _firstPersonLocked = false; args.Context.AddString("First Person POV: first-person lock disabled."); }; <>c.<>9__67_0 = val; obj = (object)val; } new ConsoleCommand("unlockfirstperson", "Unlock forced first-person mode for the current game session.", (ConsoleEvent)obj, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj2 = <>c.<>9__67_1; if (obj2 == null) { ConsoleEvent val2 = delegate(ConsoleEventArgs args) { _firstPersonLocked = true; GameCamera instance = GameCamera.instance; if ((Object)(object)instance != (Object)null && CameraDistanceField != null) { CameraDistanceField.SetValue(instance, instance.m_minDistance); } args.Context.AddString("First Person POV: first-person lock enabled."); }; <>c.<>9__67_1 = val2; obj2 = (object)val2; } new ConsoleCommand("lockfirstperson", "Force first-person mode for the current game session.", (ConsoleEvent)obj2, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); _harmony = new Harmony("jpvalheim.firstpersonpov"); _harmony.PatchAll(); Camera.onPreCull = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPreCull, (Delegate?)new CameraCallback(OnCameraPreCull)); Camera.onPostRender = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPostRender, (Delegate?)new CameraCallback(OnCameraPostRender)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"First Person POV 0.1.12 loaded."); } private IEnumerable<ConfigEntryBase> PlayerSettings() { foreach (KeyValuePair<ConfigDefinition, ConfigEntryBase> item in ((BaseUnityPlugin)this).Config) { yield return item.Value; } } private ConfigEntryBase FindSetting(string name) { foreach (ConfigEntryBase item in PlayerSettings()) { if (item.Definition.Key.Equals(name, StringComparison.OrdinalIgnoreCase)) { return item; } } return null; } private void PrintSettingHelp(Terminal terminal) { terminal.AddString("ffpov <setting> [value] (omit value to see current; changes save automatically)"); List<ConfigEntryBase> list = new List<ConfigEntryBase>(PlayerSettings()); list.Sort((ConfigEntryBase a, ConfigEntryBase b) => string.Compare(a.Definition.Section + a.Definition.Key, b.Definition.Section + b.Definition.Key, StringComparison.Ordinal)); foreach (ConfigEntryBase item in list) { string text = ((item.Description.AcceptableValues != null) ? (" (" + item.Description.AcceptableValues.ToDescriptionString() + ")") : ""); terminal.AddString(item.Definition.Key + " = " + item.GetSerializedValue() + text); } } private void HandleSettingCommand(ConsoleEventArgs args) { if (args.Length < 2 || args[1].Equals("help", StringComparison.OrdinalIgnoreCase) || args[1].Equals("list", StringComparison.OrdinalIgnoreCase)) { PrintSettingHelp(args.Context); return; } ConfigEntryBase val = FindSetting(args[1]); if (val == null) { args.Context.AddString("Unknown setting. Use 'ffpov' to list settings."); return; } if (args.Length == 2) { args.Context.AddString(val.Definition.Key + " = " + val.GetSerializedValue()); return; } string input = string.Join(" ", args.Args, 2, args.Args.Length - 2).Trim(); if (!TrySetSetting(val, input, out var error)) { args.Context.AddString(error); } else { args.Context.AddString(val.Definition.Key + " = " + val.GetSerializedValue() + " (saved)"); } } private bool TrySetSetting(ConfigEntryBase setting, string input, out string error) { //IL_00a6: 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_00af: 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) error = "Invalid value for " + setting.Definition.Key + "."; object obj; if (setting.SettingType == typeof(float)) { if (!float.TryParse(input, NumberStyles.Float, CultureInfo.InvariantCulture, out var result) || float.IsNaN(result) || float.IsInfinity(result)) { return false; } obj = result; } else if (setting.SettingType == typeof(bool)) { if (!bool.TryParse(input, out var result2)) { return false; } obj = result2; } else { if (!(setting.SettingType == typeof(KeyboardShortcut))) { return false; } KeyboardShortcut val = KeyboardShortcut.Deserialize(input); if ((int)((KeyboardShortcut)(ref val)).MainKey == 0 && !input.Equals("None", StringComparison.OrdinalIgnoreCase)) { return false; } obj = val; } AcceptableValueBase acceptableValues = setting.Description.AcceptableValues; if (acceptableValues != null && !acceptableValues.IsValid(obj)) { error = setting.Definition.Key + " must be " + acceptableValues.ToDescriptionString() + "."; return false; } setting.BoxedValue = obj; if ((object)setting == ForceFirstPerson) { OnForceFirstPersonChanged(null, EventArgs.Empty); } if (!((BaseUnityPlugin)this).Config.SaveOnConfigSet) { ((BaseUnityPlugin)this).Config.Save(); } return true; } private static void OnForceFirstPersonChanged(object sender, EventArgs args) { _firstPersonLocked = ForceFirstPerson.Value; } private void OnDestroy() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown if (ForceFirstPerson != null) { ForceFirstPerson.SettingChanged -= OnForceFirstPersonChanged; } Camera.onPreCull = (CameraCallback)Delegate.Remove((Delegate?)(object)Camera.onPreCull, (Delegate?)new CameraCallback(OnCameraPreCull)); Camera.onPostRender = (CameraCallback)Delegate.Remove((Delegate?)(object)Camera.onPostRender, (Delegate?)new CameraCallback(OnCameraPostRender)); ResetBowVisual(); RestoreLocalShadow(); RestoreHead(); ResetStableAnchor(); RestoreFirstPersonVisibility(); GameCamera instance = GameCamera.instance; if (_fovOverridden && (Object)(object)instance != (Object)null) { RestoreVanillaFov(instance); RestoreFreeFlyNearClip(instance); } _fovOverridden = false; _firstPersonFrame = false; _wasFirstPerson = false; if (_harmony != null) { _harmony.UnpatchSelf(); } } private static bool CanUseFirstPerson(Player player) { if ((Object)(object)player == (Object)null || GameCamera.InFreeFly()) { return false; } if (!((Character)player).IsDead() && !((Character)player).InIntro() && !((Character)player).InCutscene()) { return !((Character)player).IsTeleporting(); } return false; } private static bool ShouldUseFirstPerson(Player player, float distance, float minDistance) { if (CanUseFirstPerson(player)) { if (!_firstPersonLocked) { return distance <= minDistance + 0.001f; } return true; } return false; } private static bool ShouldApplyBodyYawController(Player player) { if ((Object)(object)player != (Object)null && IsFirstPersonRequested(player) && !((Character)player).IsAttached()) { return !((Character)player).InDodge(); } return false; } private static void ApplyFirstPersonLookConstraints(Player player) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: 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_011b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)player == (Object)null) && !(LookYawField == null) && !(LookDirField == null) && !(LookPitchField == null)) { Quaternion val = (Quaternion)LookYawField.GetValue(player); float num = ((Quaternion)(ref val)).eulerAngles.y; float y = ((Component)player).transform.eulerAngles.y; float num2 = Mathf.DeltaAngle(y, num); float value = MaxYawDegrees.Value; float num3 = Mathf.Clamp(num2, 0f - value, value); if (Mathf.Abs(Mathf.DeltaAngle(num2, num3)) > 0.001f) { num = y + num3; } float num4 = Mathf.Min((float)LookPitchField.GetValue(player), MaxLookDown.Value); Quaternion val2 = Quaternion.Euler(0f, num, 0f); LookYawField.SetValue(player, val2); LookPitchField.SetValue(player, num4); ((Character)player).m_eye.rotation = val2 * Quaternion.Euler(num4, 0f, 0f); LookDirField.SetValue(player, ((Character)player).m_eye.forward); } } private static void ResetStableAnchor() { //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) _anchorPlayer = null; _anchorVisualRoot = null; _anchorEye = null; _filteredPoseResidual = Vector3.zero; _anchorInitialized = false; _anchorNeedsNeutralRecalibration = false; } private static void ResetPoseResidual() { //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) _filteredPoseResidual = Vector3.zero; } private static bool EnsureStableAnchor(Player player) { //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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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) if ((Object)(object)player == (Object)null || (Object)(object)((Character)player).m_eye == (Object)null) { ResetStableAnchor(); return false; } Transform transform = ((Component)player).transform; if (VisualField != null) { object? value = VisualField.GetValue(player); GameObject val = (GameObject)((value is GameObject) ? value : null); if ((Object)(object)val != (Object)null) { transform = val.transform; } } if (_anchorInitialized && (Object)(object)_anchorPlayer == (Object)(object)player && (Object)(object)_anchorVisualRoot == (Object)(object)transform && (Object)(object)_anchorEye == (Object)(object)((Character)player).m_eye) { return true; } _anchorPlayer = player; _anchorVisualRoot = transform; _anchorEye = ((Character)player).m_eye; Transform transform2 = ((Component)player).transform; _baselineVisualRootLocal = transform2.InverseTransformPoint(transform.position); _neutralEyeRelativeToVisualRoot = transform2.InverseTransformPoint(((Character)player).m_eye.position) - _baselineVisualRootLocal; _filteredPoseResidual = Vector3.zero; _anchorInitialized = true; Vector3 velocity = ((Character)player).GetVelocity(); _anchorNeedsNeutralRecalibration = ((Vector3)(ref velocity)).magnitude > 0.25f || ((Character)player).IsCrouching(); return true; } private static Vector3 EvaluateStableEye(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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_00a2: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: 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_007f: 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_0086: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) if (!EnsureStableAnchor(player)) { if (!((Object)(object)player != (Object)null) || !((Object)(object)((Character)player).m_eye != (Object)null)) { return Vector3.zero; } return ((Character)player).m_eye.position; } Transform transform = ((Component)player).transform; Vector3 val = transform.InverseTransformPoint(_anchorVisualRoot.position); Vector3 val2 = transform.InverseTransformPoint(((Character)player).m_eye.position); if (_anchorNeedsNeutralRecalibration) { Vector3 velocity = ((Character)player).GetVelocity(); if (((Vector3)(ref velocity)).magnitude < 0.1f && !((Character)player).IsCrouching()) { _baselineVisualRootLocal = val; _neutralEyeRelativeToVisualRoot = val2 - val; _filteredPoseResidual = Vector3.zero; _anchorNeedsNeutralRecalibration = false; } } Vector3 val3 = val2 - val - _neutralEyeRelativeToVisualRoot; val3.x = Mathf.Clamp(val3.x, -0.015f, 0.015f); val3.z = Mathf.Clamp(val3.z, -0.02f, 0.02f); val3.y = Mathf.Clamp(val3.y, -0.3f, 0.1f); float value = PoseResidualSmoothing.Value; float num = ((value <= 0f) ? 1f : (1f - Mathf.Exp((0f - Mathf.Max(0f, dt)) / value))); _filteredPoseResidual = Vector3.Lerp(_filteredPoseResidual, val3, num); Vector3 val4 = _baselineVisualRootLocal + _neutralEyeRelativeToVisualRoot + _filteredPoseResidual + new Vector3(0f, VerticalOffset.Value, ForwardOffset.Value); return transform.TransformPoint(val4); } private static void HideInstanceRenderers(VisEquipment vis, FieldInfo instanceField) { if ((Object)(object)vis == (Object)null || instanceField == null) { return; } object? value = instanceField.GetValue(vis); GameObject val = (GameObject)((value is GameObject) ? value : null); if ((Object)(object)val == (Object)null) { return; } HeadRenderers.Clear(); val.GetComponentsInChildren<Renderer>(true, HeadRenderers); foreach (Renderer headRenderer in HeadRenderers) { if (!((Object)(object)headRenderer == (Object)null)) { if (!HiddenHeadRendererStates.ContainsKey(headRenderer)) { HiddenHeadRendererStates.Add(headRenderer, headRenderer.enabled); } headRenderer.enabled = false; } } } private static void ApplyHeadHide(Player player) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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) //IL_0067: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || HeadField == null) { return; } object? value = HeadField.GetValue(player); Transform val = (Transform)((value is Transform) ? value : null); if (!((Object)(object)val == (Object)null)) { if (_headScaled && (Object)(object)_scaledHead != (Object)(object)val) { RestoreHead(); } _scaledHead = val; _originalHeadScale = val.localScale; val.localScale = _originalHeadScale * 0.0001f; _headScaled = true; VisEquipment componentInChildren = ((Component)player).GetComponentInChildren<VisEquipment>(true); HideInstanceRenderers(componentInChildren, HelmetItemInstanceField); HideInstanceRenderers(componentInChildren, HairItemInstanceField); HideInstanceRenderers(componentInChildren, BeardItemInstanceField); } } private static void RestoreHead() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (_headScaled && (Object)(object)_scaledHead != (Object)null) { _scaledHead.localScale = _originalHeadScale; } foreach (KeyValuePair<Renderer, bool> hiddenHeadRendererState in HiddenHeadRendererStates) { if ((Object)(object)hiddenHeadRendererState.Key != (Object)null) { hiddenHeadRendererState.Key.enabled = hiddenHeadRendererState.Value; } } HiddenHeadRendererStates.Clear(); _headScaled = false; _scaledHead = null; } private static void ApplyLocalShadow(Player player) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) if (!HideHeadlessShadow.Value) { RestoreLocalShadow(); return; } GameObject val = (GameObject)((VisualField != null) ? /*isinst with value type is only supported in some contexts*/: null); if ((Object)(object)val == (Object)null) { return; } ShadowRenderers.Clear(); val.GetComponentsInChildren<Renderer>(true, ShadowRenderers); foreach (Renderer shadowRenderer in ShadowRenderers) { if (!((Object)(object)shadowRenderer == (Object)null)) { if (!LocalShadowStates.ContainsKey(shadowRenderer)) { LocalShadowStates.Add(shadowRenderer, shadowRenderer.shadowCastingMode); } shadowRenderer.shadowCastingMode = (ShadowCastingMode)0; } } } private static void RestoreLocalShadow() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair<Renderer, ShadowCastingMode> localShadowState in LocalShadowStates) { if ((Object)(object)localShadowState.Key != (Object)null) { localShadowState.Key.shadowCastingMode = localShadowState.Value; } } LocalShadowStates.Clear(); ShadowRenderers.Clear(); } private static void RestoreBowVisual() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (_bowRenderRotationApplied && (Object)(object)_bowVisual != (Object)null) { _bowVisual.rotation = _bowOriginalRotation; } _bowRenderRotationApplied = false; } private static void ResetBowVisual() { RestoreBowVisual(); _bowVisual = null; _bowRollAngle = 0f; } private static Transform GetEquippedBowVisual(Player player) { ItemData val = (((Object)(object)player != (Object)null) ? ((Humanoid)player).GetCurrentWeapon() : null); if (val == null || val.m_shared == null || val.m_shared.m_attack == null || !val.m_shared.m_attack.m_bowDraw) { return null; } VisEquipment componentInChildren = ((Component)player).GetComponentInChildren<VisEquipment>(true); if ((Object)(object)componentInChildren == (Object)null) { return null; } FieldInfo fieldInfo = null; if (RightEquippedItemField != null && RightEquippedItemField.GetValue(player) == val) { fieldInfo = RightItemInstanceField; } else if (LeftEquippedItemField != null && LeftEquippedItemField.GetValue(player) == val) { fieldInfo = LeftItemInstanceField; } GameObject val2 = (GameObject)((fieldInfo != null) ? /*isinst with value type is only supported in some contexts*/: null); if (!((Object)(object)val2 != (Object)null)) { return null; } return val2.transform; } private static void UpdateBowVisual(Player player) { Transform equippedBowVisual = GetEquippedBowVisual(player); if ((Object)(object)equippedBowVisual != (Object)(object)_bowVisual) { ResetBowVisual(); _bowVisual = equippedBowVisual; } if (!((Object)(object)_bowVisual == (Object)null)) { float num = (((Character)player).IsDrawingBow() ? DrawnBowRoll.Value : 0f); float num2 = ((Mathf.Abs(num) > 0.01f) ? 0.08f : 0.18f); float num3 = 1f - Mathf.Exp((0f - Time.unscaledDeltaTime) / num2); _bowRollAngle = Mathf.Lerp(_bowRollAngle, num, num3); if (Mathf.Abs(_bowRollAngle) < 0.05f && num == 0f) { _bowRollAngle = 0f; } } } private static bool IsGameplayCamera(Camera camera) { GameCamera instance = GameCamera.instance; if ((Object)(object)instance != (Object)null) { return (Object)(object)camera == (Object)(object)((Component)instance).GetComponent<Camera>(); } return false; } private static void OnCameraPreCull(Camera camera) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) if (IsGameplayCamera(camera) && _firstPersonFrame && !GameCamera.InFreeFly() && !((Object)(object)_bowVisual == (Object)null) && !(Mathf.Abs(_bowRollAngle) < 0.05f)) { RestoreBowVisual(); _bowOriginalRotation = _bowVisual.rotation; _bowVisual.rotation = Quaternion.AngleAxis(0f - _bowRollAngle, ((Component)camera).transform.forward) * _bowOriginalRotation; _bowRenderRotationApplied = true; } } private static void OnCameraPostRender(Camera camera) { if (IsGameplayCamera(camera)) { RestoreBowVisual(); } } private static LODGroup GetLodGroup(Player player) { if (!((Object)(object)player != (Object)null) || !(LodGroupField != null)) { return null; } object? value = LodGroupField.GetValue(player); return (LODGroup)((value is LODGroup) ? value : null); } private static bool IsFirstPersonRequested(Player player) { GameCamera instance = GameCamera.instance; if ((Object)(object)instance == (Object)null || CameraDistanceField == null) { return false; } float distance = (float)CameraDistanceField.GetValue(instance); return ShouldUseFirstPerson(player, distance, instance.m_minDistance); } private static void ApplyFirstPersonVisibility(Player player) { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || LodVisibleField == null || OriginalLocalRefField == null) { return; } LODGroup lodGroup = GetLodGroup(player); if (!((Object)(object)lodGroup == (Object)null)) { if (_lodSettingsOverridden && (Object)(object)_firstPersonLodGroup != (Object)(object)lodGroup) { RestoreFirstPersonVisibility(); } if (!_lodSettingsOverridden) { _firstPersonLodGroup = lodGroup; _originalAnimateCrossFading = lodGroup.animateCrossFading; _originalFadeMode = lodGroup.fadeMode; _lodSettingsOverridden = true; } lodGroup.animateCrossFading = false; lodGroup.fadeMode = (LODFadeMode)0; LodVisibleField.SetValue(player, true); lodGroup.localReferencePoint = (Vector3)OriginalLocalRefField.GetValue(player); } } private static void RestoreFirstPersonVisibility() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (_lodSettingsOverridden && (Object)(object)_firstPersonLodGroup != (Object)null) { _firstPersonLodGroup.fadeMode = _originalFadeMode; _firstPersonLodGroup.animateCrossFading = _originalAnimateCrossFading; } _lodSettingsOverridden = false; _firstPersonLodGroup = null; } private static void ApplyFirstPersonFov(GameCamera gameCamera) { Camera component = ((Component)gameCamera).GetComponent<Camera>(); if ((Object)(object)component != (Object)null) { component.fieldOfView = FirstPersonFov.Value; } if ((Object)(object)gameCamera.m_skyCamera != (Object)null) { gameCamera.m_skyCamera.fieldOfView = FirstPersonFov.Value; } _fovOverridden = true; } private static void RestoreVanillaFov(GameCamera gameCamera) { Camera component = ((Component)gameCamera).GetComponent<Camera>(); if ((Object)(object)component != (Object)null) { component.fieldOfView = gameCamera.m_fov; } if ((Object)(object)gameCamera.m_skyCamera != (Object)null) { gameCamera.m_skyCamera.fieldOfView = gameCamera.m_fov; } } private static void ApplyFirstPersonNearClip(GameCamera gameCamera) { if (!((Object)(object)gameCamera == (Object)null)) { Camera component = ((Component)gameCamera).GetComponent<Camera>(); if ((Object)(object)component != (Object)null) { component.nearClipPlane = FirstPersonNearClip.Value; } } } private static void RestoreFreeFlyNearClip(GameCamera gameCamera) { if (!((Object)(object)gameCamera == (Object)null)) { Camera component = ((Component)gameCamera).GetComponent<Camera>(); if ((Object)(object)component != (Object)null) { component.nearClipPlane = gameCamera.m_nearClipPlaneMax; } } } } internal static class YawResistance { internal static float Apply(float relativeYaw, float input, float start, float width, float limit) { if (input == 0f) { return 0f; } start = Math.Min(start, limit - 1f); double num = Math.Sign(input); double num2 = num * (double)relativeYaw; double num3 = Math.Abs(input); double num4 = Math.Max(0.0, (double)start - num2); if (num3 <= num4) { return input; } double num5 = Math.Max(0.0, num2 - (double)start); double num6 = 1.0 + num5 / (double)width; double num7 = (double)width * (Math.Pow(num6 * num6 * num6 + 3.0 * (num3 - num4) / (double)width, 1.0 / 3.0) - 1.0); double num8 = Math.Min(limit, (double)start + num7); return (float)(num * Math.Max(0.0, num8 - num2)); } }