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 View v1.5.2
BepInEx/plugins/FirstPersonView/FirstPersonView.dll
Decompiled a week ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using FirstPersonView.Compat; using GameNetcodeStuff; using HarmonyLib; using LethalConfig; using LethalConfig.ConfigItems; using Microsoft.CodeAnalysis; using MoreCompany.Cosmetics; using TooManyEmotes; using TooManyEmotes.Patches; using Unity.Netcode; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("ClientNetworkTransform")] [assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")] [assembly: IgnoresAccessChecksTo("DissonanceVoip")] [assembly: IgnoresAccessChecksTo("DunGen")] [assembly: IgnoresAccessChecksTo("DunGen.Integration.ASPP")] [assembly: IgnoresAccessChecksTo("DunGen.Integration.UnityNav")] [assembly: IgnoresAccessChecksTo("EasyTextEffects")] [assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Jobs")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")] [assembly: IgnoresAccessChecksTo("Unity.Services.QoS")] [assembly: IgnoresAccessChecksTo("Unity.Services.Relay")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.XR.CoreUtils")] [assembly: IgnoresAccessChecksTo("Unity.XR.Management")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.ConformanceAutomation")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MetaQuestSupport")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MockRuntime")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.OculusQuestSupport")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.RuntimeDebugger")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.SpatialTracking")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("UnityEngine.XR.LegacyInputHelpers")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("FirstPersonView")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Lets players see their own body.")] [assembly: AssemblyFileVersion("1.5.2.0")] [assembly: AssemblyInformationalVersion("1.5.2+cf53ae7ec59bd81fbe3cc8afd0d03b075429c0a5")] [assembly: AssemblyProduct("FirstPersonView")] [assembly: AssemblyTitle("FirstPersonView")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.5.2.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace FirstPersonView { internal static class CameraRig { public static void ApplyOffset(LocalBodyState state, PlayerControllerB player) { //IL_003f: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_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_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) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_0094: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_0198: 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_019e: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0229: 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_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024b: 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_024f: 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_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: 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_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02df: 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_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) Camera gameplayCamera = state.GameplayCamera; if (!((Object)(object)gameplayCamera == (Object)null) && state.CameraBaseCaptured) { state.VehiclePushApplied = false; Transform transform = ((Component)gameplayCamera).transform; Transform parent = transform.parent; Vector3 val = (((Object)(object)parent != (Object)null) ? parent.up : Vector3.up); Vector3 val2 = Vector3.ProjectOnPlane(transform.forward, val); if (((Vector3)(ref val2)).sqrMagnitude < 1E-05f) { val2 = Vector3.ProjectOnPlane(((Component)player).transform.forward, val); } val2 = ((!(((Vector3)(ref val2)).sqrMagnitude < 1E-05f)) ? ((Vector3)(ref val2)).normalized : (((Object)(object)parent != (Object)null) ? parent.forward : Vector3.forward)); Vector3 val3 = Vector3.Cross(val, val2); Quaternion yawRotation = Quaternion.LookRotation(val2, val); CameraBlends blends = state.Blends; blends.Crouch = Mathf.MoveTowards(blends.Crouch, player.isCrouching ? 1f : 0f, Time.deltaTime / 0.15f); blends.Run = Mathf.MoveTowards(blends.Run, player.isSprinting ? 1f : 0f, Time.deltaTime / 0.18f); blends.Walk = Mathf.MoveTowards(blends.Walk, (player.isWalking && !player.isSprinting) ? 1f : 0f, Time.deltaTime / 0.18f); blends.Jump = Mathf.MoveTowards(blends.Jump, (player.isJumping || player.isFallingFromJump) ? 1f : 0f, Time.deltaTime / 0.18f); float num = Vector3.Dot(transform.forward, -val); float num2 = Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.45f, 0.95f, num)); float num3 = (player.inVehicleAnimation ? 0.13f : 0.13f); float num4 = Mathf.Max(blends.Run * 0.12f, Mathf.Max(blends.Walk * 0.02f, blends.Jump * 0.12f)); float num5 = num2 * (num3 + num4); Vector3 val4 = (((Object)(object)parent != (Object)null) ? parent.TransformPoint(state.CameraBaseLocalPosition) : state.CameraBaseLocalPosition); Vector3 val5 = FollowBodyAnchor(state, player, val4, yawRotation, num); Vector3 val6 = val5 - val4; float num6 = Vector3.Dot(val6, val2); float num7 = num6 + num5; float num8 = Vector3.Dot(val6, val3); float totalUp = Vector3.Dot(val6, val); float num9 = Mathf.Max(num5, 0f); if (!player.inSpecialInteractAnimation) { num7 = Mathf.Max(num7, num9); } num7 = ClampTravelToWall(val4, val2, num7, 0.05f); Vector3 horizontalPoint = val4 + val2 * num7 + val3 * num8; Vector3 val7 = (transform.position = ResolveVerticalClearance(horizontalPoint, val, totalUp)); state.LastCameraTargetLocal = (((Object)(object)parent != (Object)null) ? parent.InverseTransformPoint(val7) : val7); state.HasCameraTarget = true; state.CameraOffsetApplied = true; } } public static void PrepareVehicleDetach(LocalBodyState state) { state.CameraOffsetApplied = false; state.HasCameraTarget = false; } public static void ApplyVehiclePush(LocalBodyState state) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_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_00be: 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_00ba: 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_00cd: 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_00d6: 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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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_00eb: Unknown result type (might be due to invalid IL or missing references) Camera gameplayCamera = state.GameplayCamera; if ((Object)(object)gameplayCamera == (Object)null) { return; } Transform transform = ((Component)gameplayCamera).transform; Transform parent = transform.parent; Vector3 val = (((Object)(object)parent != (Object)null) ? parent.up : Vector3.up); float num = Vector3.Dot(transform.forward, -val); float num2 = Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.45f, 0.95f, num)); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(0f, 0f, num2 * 0.26f); Vector3 localPosition = transform.localPosition; Vector3 val4; if (state.VehiclePushApplied) { Vector3 val3 = localPosition - state.VehiclePushResult; if (((Vector3)(ref val3)).sqrMagnitude < 1E-08f) { val4 = localPosition - state.VehiclePush; goto IL_00cb; } } val4 = localPosition; goto IL_00cb; IL_00cb: Vector3 val5 = val4; Vector3 vehiclePushResult = (transform.localPosition = val5 + val2); state.VehiclePush = val2; state.VehiclePushResult = vehiclePushResult; state.VehiclePushApplied = true; } public static void RelaxSeatedLookClamp(PlayerControllerB player) { if (player.isPlayerControlled && !player.isPlayerDead) { if (player.clampLooking && !player.inSpecialInteractAnimation) { player.clampLooking = false; player.inVehicleAnimation = false; } else if (player.clampLooking && player.minVerticalClamp < 75f) { player.minVerticalClamp = 75f; } } } public static void AlignForInteractionRay(LocalBodyState state) { //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_0035: Unknown result type (might be due to invalid IL or missing references) if (state.HasCameraTarget && !((Object)(object)state.GameplayCamera == (Object)null)) { Transform transform = ((Component)state.GameplayCamera).transform; Transform parent = transform.parent; transform.position = (((Object)(object)parent != (Object)null) ? parent.TransformPoint(state.LastCameraTargetLocal) : state.LastCameraTargetLocal); } } public static void ApplyArmAnchor(PlayerControllerB player, bool useVanillaArms) { //IL_0046: 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_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_005c: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) if (!useVanillaArms || player.inSpecialInteractAnimation) { return; } Transform localArmsTransform = player.localArmsTransform; Camera gameplayCamera = player.gameplayCamera; Transform cameraContainerTransform = player.cameraContainerTransform; if (!((Object)(object)localArmsTransform == (Object)null) && !((Object)(object)gameplayCamera == (Object)null) && !((Object)(object)cameraContainerTransform == (Object)null)) { Transform transform = ((Component)gameplayCamera).transform; localArmsTransform.position += transform.position - cameraContainerTransform.position; float value = ConfigManager.HandOffsetZ.Value; if (value != 0f) { localArmsTransform.position += transform.forward * value; } } } private static Vector3 FollowBodyAnchor(LocalBodyState state, PlayerControllerB player, Vector3 baseWorld, Quaternion yawRotation, float lookDown) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_00cc: 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_00d8: 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_00e2: 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_00e5: 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_00ec: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: 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_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_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: 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_0124: 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_012d: 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_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0202: 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) //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_0152: 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_015e: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: 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_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) Transform headBone = state.HeadBone; if ((Object)(object)headBone == (Object)null) { return baseWorld; } EyeAnchorState eyeAnchor = state.EyeAnchor; if (!eyeAnchor.Captured && !player.isCrouching) { eyeAnchor.Local = Quaternion.Inverse(yawRotation) * (baseWorld - headBone.position); eyeAnchor.BoneLocal = headBone.InverseTransformPoint(baseWorld); eyeAnchor.Drift = Vector3.zero; eyeAnchor.Captured = true; } if (!eyeAnchor.Captured) { return baseWorld; } if (TooManyEmotesCompat.IsFirstPersonEmoteActive()) { return headBone.TransformPoint(eyeAnchor.BoneLocal); } CameraBlends blends = state.Blends; bool flag = ConfigManager.StickCameraToHeadInAnimations.Value && IsInteractTriggerAnimation(player); blends.StickToHead = Mathf.MoveTowards(blends.StickToHead, flag ? 1f : 0f, Time.deltaTime / 0.12f); Vector3 val = headBone.position + yawRotation * eyeAnchor.Local; Vector3 val2 = Quaternion.Inverse(yawRotation) * (val - baseWorld); if (IsEyeAnchorSettled(state, player, lookDown)) { float num = 1f - Mathf.Exp((0f - Time.deltaTime) / 2f); eyeAnchor.Drift = Vector3.Lerp(eyeAnchor.Drift, val2, num); float num2 = 0.06f; if (((Vector3)(ref eyeAnchor.Drift)).sqrMagnitude > num2 * num2) { eyeAnchor.Drift = ((Vector3)(ref eyeAnchor.Drift)).normalized * num2; } } WarnOnPersistentDrift(eyeAnchor); Vector3 val3 = val2 - eyeAnchor.Drift; val3.x *= 1f; val3.z *= 1f; val3.y *= 1f; val3.y = DampHeadBob(state, player, val3.y); val3 = StabilizeSprintBob(state, player, val3); val3 = StabilizeLadder(state, player, val3); if (((Vector3)(ref val3)).sqrMagnitude > 0.25f) { val3 = ((Vector3)(ref val3)).normalized * 0.5f; } Vector3 val4 = baseWorld + yawRotation * val3; if (blends.StickToHead > 0f) { val4 = Vector3.Lerp(val4, headBone.TransformPoint(eyeAnchor.BoneLocal), blends.StickToHead); } return val4; } private static bool IsInteractTriggerAnimation(PlayerControllerB player) { InteractTrigger currentTriggerInAnimationWith = player.currentTriggerInAnimationWith; if (player.inSpecialInteractAnimation && (Object)(object)currentTriggerInAnimationWith != (Object)null && !currentTriggerInAnimationWith.isLadder && !player.isClimbingLadder && !player.inVehicleAnimation) { return !player.inShockingMinigame; } return false; } private static void WarnOnPersistentDrift(EyeAnchorState anchor) { if (!anchor.DriftWarned) { float num = 0.06f; if (((Vector3)(ref anchor.Drift)).sqrMagnitude < num * num) { anchor.DriftHighSince = 0f; } else if (anchor.DriftHighSince <= 0f) { anchor.DriftHighSince = Time.unscaledTime; } else if (!(Time.unscaledTime - anchor.DriftHighSince < 5f)) { anchor.DriftWarned = true; Plugin.Log.LogWarning((object)($"Eye anchor drift held at {((Vector3)(ref anchor.Drift)).magnitude:F3}m for over {5f:F0}s. " + "The head bone rest pose does not match the captured anchor, the forward eye offset may be reduced.")); } } } private static bool IsEyeAnchorSettled(LocalBodyState state, PlayerControllerB player, float lookDown) { if (Mathf.Abs(lookDown) <= 0.05f && !player.isWalking && !player.isSprinting && !player.inSpecialInteractAnimation && !player.isCrouching && state.Blends.Crouch <= 0f && !player.isClimbingLadder && !player.isJumping) { return !player.isFallingFromJump; } return false; } private static float DampHeadBob(LocalBodyState state, PlayerControllerB player, float rawY) { BobSmoothing bobSmooth = state.BobSmooth; CameraBlends blends = state.Blends; bool flag = !player.isCrouching && blends.Crouch <= 0f && ConfigManager.DisableHeadBob.Value; if (!bobSmooth.YInitialized) { bobSmooth.SmoothedY = rawY; bobSmooth.YInitialized = true; } bool flag2 = Mathf.Abs(rawY - bobSmooth.SmoothedY) <= 0.06f; bool flag3 = flag && (blends.DisableBob > 0f || flag2); if (flag3 && blends.DisableBob <= 0f) { bobSmooth.SmoothedY = rawY; } float num = (flag3 ? 1f : 0.15f); float num2 = 1f - Mathf.Exp((0f - Time.deltaTime) / num); bobSmooth.SmoothedY = Mathf.Lerp(bobSmooth.SmoothedY, rawY, num2); blends.DisableBob = Mathf.MoveTowards(blends.DisableBob, flag3 ? 1f : 0f, Time.deltaTime / 0.15f); return Mathf.Lerp(rawY, bobSmooth.SmoothedY, blends.DisableBob); } private static Vector3 StabilizeSprintBob(LocalBodyState state, PlayerControllerB player, Vector3 deviationLocal) { //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_005c: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) BobSmoothing bobSmooth = state.BobSmooth; CameraBlends blends = state.Blends; bool flag = player.isSprinting || player.isJumping || player.isFallingFromJump; blends.BobDamp = Mathf.MoveTowards(blends.BobDamp, flag ? 1f : 0f, Time.deltaTime / 0.12f); if (!bobSmooth.DeviationInitialized) { bobSmooth.SmoothedDeviationLocal = deviationLocal; bobSmooth.DeviationInitialized = true; } else { float num = 1f - Mathf.Exp((0f - Time.deltaTime) / 0.2f); bobSmooth.SmoothedDeviationLocal = Vector3.Lerp(bobSmooth.SmoothedDeviationLocal, deviationLocal, num); } float num2 = blends.BobDamp * 0.6f; return Vector3.Lerp(deviationLocal, bobSmooth.SmoothedDeviationLocal, num2); } private static bool IsLadderSequence(PlayerControllerB player) { if (player.isClimbingLadder) { return true; } InteractTrigger currentTriggerInAnimationWith = player.currentTriggerInAnimationWith; if (player.inSpecialInteractAnimation && (Object)(object)currentTriggerInAnimationWith != (Object)null) { return currentTriggerInAnimationWith.isLadder; } return false; } private static Vector3 StabilizeLadder(LocalBodyState state, PlayerControllerB player, Vector3 deviationLocal) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_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_0055: 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_0091: 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_009e: Unknown result type (might be due to invalid IL or missing references) BobSmoothing bobSmooth = state.BobSmooth; CameraBlends blends = state.Blends; bool flag = IsLadderSequence(player); float num = (flag ? 0.08f : 0.6f); blends.Ladder = Mathf.MoveTowards(blends.Ladder, flag ? 1f : 0f, Time.deltaTime / num); if (!bobSmooth.LadderInitialized) { bobSmooth.SmoothedLadderLocal = deviationLocal; bobSmooth.LadderInitialized = true; } else { float num2 = 1f - Mathf.Exp((0f - Time.deltaTime) / 0.45f); bobSmooth.SmoothedLadderLocal = Vector3.Lerp(bobSmooth.SmoothedLadderLocal, deviationLocal, num2); } return Vector3.Lerp(deviationLocal, bobSmooth.SmoothedLadderLocal, blends.Ladder); } private static float ClampTravelToWall(Vector3 origin, Vector3 dir, float distance, float radius) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || distance <= 0f) { return distance; } RaycastHit val = default(RaycastHit); if (Physics.SphereCast(origin, Mathf.Max(0.01f, radius), dir, ref val, distance, instance.collidersAndRoomMask, (QueryTriggerInteraction)1)) { return Mathf.Max(0f, ((RaycastHit)(ref val)).distance); } return distance; } private static Vector3 ResolveVerticalClearance(Vector3 horizontalPoint, Vector3 up, float totalUp) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((totalUp >= 0f) ? up : (-up)); float num = ClampTravelToWall(horizontalPoint, val, Mathf.Abs(totalUp), 0.1f); return horizontalPoint + val * num; } public static void RestoreOffset(LocalBodyState state) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) state.Blends.Reset(); state.BobSmooth.Reset(); state.HasCameraTarget = false; state.VehiclePushApplied = false; if (state.CameraOffsetApplied) { Camera gameplayCamera = state.GameplayCamera; if ((Object)(object)gameplayCamera != (Object)null && state.CameraBaseCaptured) { ((Component)gameplayCamera).transform.localPosition = state.CameraBaseLocalPosition; } state.CameraOffsetApplied = false; } } } internal static class VisorRig { private static bool? immersiveVisorPresent; public static bool IsImmersiveVisorPresent() { bool valueOrDefault = immersiveVisorPresent == true; if (!immersiveVisorPresent.HasValue) { valueOrDefault = Chainloader.PluginInfos.ContainsKey("ImmersiveVisor"); immersiveVisorPresent = valueOrDefault; } return immersiveVisorPresent.Value; } public static void StickToCamera(LocalBodyState state) { if (!state.VisorReparented) { Transform localVisor = state.LocalVisor; Camera gameplayCamera = state.GameplayCamera; if (!((Object)(object)localVisor == (Object)null) && !((Object)(object)gameplayCamera == (Object)null)) { localVisor.SetParent(((Component)gameplayCamera).transform, true); state.VisorReparented = true; } } } public static void Restore(LocalBodyState state) { if (state.VisorReparented) { if ((Object)(object)state.LocalVisor != (Object)null && state.VisorOriginalParentCaptured) { state.LocalVisor.SetParent(state.VisorOriginalParent, true); } state.VisorReparented = false; } } public static void SuppressVanillaCrack(LocalBodyState state, bool hide) { if (hide == state.CrackHidden) { return; } if (state.CrackRenderers == null) { GameObject val = (((Object)(object)HUDManager.Instance != (Object)null) ? HUDManager.Instance.visorCracksObject : null); if ((Object)(object)val == (Object)null) { return; } state.CrackRenderers = val.GetComponentsInChildren<Renderer>(true); } Renderer[] crackRenderers = state.CrackRenderers; foreach (Renderer val2 in crackRenderers) { if ((Object)(object)val2 != (Object)null) { val2.enabled = !hide; } } state.CrackHidden = hide; } } public static class ConfigManager { public static ConfigEntry<HeldItemFadeMode> HeldItemFadeStyle; public static ConfigEntry<HandsMode> Hands; public static ConfigEntry<bool> VanillaArmsWhileSprinting; public static ConfigEntry<bool> VanillaArmsWhileCrouching; public static ConfigEntry<bool> VanillaArmsWhileJumping; public static ConfigEntry<bool> VanillaArmsWhileWalking; public static ConfigEntry<bool> VanillaArmsWhileEmoting; public static ConfigEntry<bool> VanillaArmsNearWall; public static ConfigEntry<ItemDitherMode> ItemDither; public static ConfigEntry<float> HandOffsetZ; public static ConfigEntry<bool> DisableHeadBob; public static ConfigEntry<bool> StickCameraToHeadInAnimations; public static ConfigEntry<bool> HideBodyInCruiser; public static ConfigEntry<bool> SmoothSwingReturn; public static ConfigEntry<bool> EnableMoreCompanyCompatibility; public static ConfigEntry<bool> EnableTooManyEmotesCompatibility; public static ConfigEntry<bool> EnableLethalPhonesCompatibility; public static ConfigEntry<bool> EnableCruiserImprovedCompatibility; public static ConfigEntry<bool> ShowMoreCompanyHat; public static ConfigEntry<bool> ShowMoreCompanyChest; public static ConfigEntry<bool> ShowMoreCompanyHip; public static ConfigEntry<bool> ShowMoreCompanyRightLowerArm; public static ConfigEntry<bool> ShowMoreCompanyLeftShin; public static ConfigEntry<bool> ShowMoreCompanyRightShin; public static ConfigEntry<bool> ShowCosmetics; public static ConfigEntry<string> HideCosmetics; public static ConfigEntry<string> InstalledCosmeticIds; internal static void Initialize(ConfigFile config, bool registerWithLethalConfig) { //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Expected O, but got Unknown EnableMoreCompanyCompatibility = config.Bind<bool>("1. Compatibility", "Enable MoreCompany Compatibility", true, "Show your MoreCompany cosmetics in first person when MoreCompany is installed."); EnableTooManyEmotesCompatibility = config.Bind<bool>("1. Compatibility", "Enable TooManyEmotes Compatibility", true, "Keep the camera on your head during a TooManyEmotes first-person emote."); EnableLethalPhonesCompatibility = config.Bind<bool>("1. Compatibility", "Enable LethalPhones Compatibility", true, "Show your hands holding a LethalPhones phone."); EnableCruiserImprovedCompatibility = config.Bind<bool>("1. Compatibility", "Enable CruiserImproved Compatibility", false, "Allows CruiserImproveds lean and seat boost to work. Not recommended as you will slightly start to see your bodies neck on leaning and camera is pushed more forward"); ShowMoreCompanyHat = config.Bind<bool>("1. Compatibility", "ShowHat", false, "Show hat cosmetics. False by default to prevent hats from clipping into the camera."); ShowMoreCompanyChest = config.Bind<bool>("1. Compatibility", "ShowChest", true, "Show chest cosmetics."); ShowMoreCompanyHip = config.Bind<bool>("1. Compatibility", "ShowHip", true, "Show hip cosmetics."); ShowMoreCompanyRightLowerArm = config.Bind<bool>("1. Compatibility", "ShowRightLowerArm", true, "Show right lower arm cosmetics."); ShowMoreCompanyLeftShin = config.Bind<bool>("1. Compatibility", "ShowLeftShin", true, "Show left shin cosmetics."); ShowMoreCompanyRightShin = config.Bind<bool>("1. Compatibility", "ShowRightShin", true, "Show right shin cosmetics."); ShowCosmetics = config.Bind<bool>("1. Compatibility", "ShowCosmetics", true, "Show your cosmetics in first-person. Make this false if another mod replaces your player model and your cosmetics sit wrong on model."); HideCosmetics = config.Bind<string>("1. Compatibility", "HideCosmetics", "", "Comma separated cosmetic ids to hide in first-person for cosmetics that are in the view. Copy ids you want from InstalledCosmeticIds."); InstalledCosmeticIds = config.Bind<string>("1. Compatibility", "InstalledCosmeticIds", "", "Every cosmetic id you have installed. This list generates automatically, editing it does nothing."); HeldItemFadeStyle = config.Bind<HeldItemFadeMode>("2. Held Item", "FadeMode", HeldItemFadeMode.Dither, "Held item will start to dither when it is close to or filling the players camera. Dither: a fade that lets you see through the item. Off: nothing dithers."); ItemDither = config.Bind<ItemDitherMode>("2. Held Item", "ItemDither", ItemDitherMode.ThirdPerson, "Which hands mode the held item dithers in."); HandOffsetZ = config.Bind<float>("2. Held Item", "HandOffsetZ", 0f, new ConfigDescription("First-person hand offset.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 1f), Array.Empty<object>())); Hands = config.Bind<HandsMode>("3. Hands", "HandsMode", HandsMode.Vanilla, "Which arms hold an item in first person. Vanilla: real first-person arms that aim the item with the camera [ recommended ]. ThirdPerson: the body own arms hold the item, more consistent body, but with known issues."); VanillaArmsWhileSprinting = config.Bind<bool>("3. Hands", "Vanilla Arms While Sprinting", true, "Show vanilla first-person arms while sprinting."); VanillaArmsWhileCrouching = config.Bind<bool>("3. Hands", "Vanilla Arms While Crouching", true, "Show vanilla first-person arms while crouching."); VanillaArmsWhileJumping = config.Bind<bool>("3. Hands", "Vanilla Arms While Jumping", true, "Show vanilla first-person arms while jumping or falling."); VanillaArmsWhileWalking = config.Bind<bool>("3. Hands", "Vanilla Arms While Walking", true, "Show vanilla first-person arms while walking."); VanillaArmsWhileEmoting = config.Bind<bool>("3. Hands", "Vanilla Arms While Emoting", true, "Show vanilla first-person arms while performing an emote (dance, point)."); VanillaArmsNearWall = config.Bind<bool>("3. Hands", "Vanilla Arms Near Wall", true, "Show vanilla first-person arms when a wall is close and the body extends its hands."); DisableHeadBob = config.Bind<bool>("4. Camera", "DisableHeadBob", true, "Disable head bobbing from walking and running animations and up and down from the idle breathing animation."); StickCameraToHeadInAnimations = config.Bind<bool>("4. Camera", "StickCameraToHeadInAnimations", true, "Put the camera on your head during interact animations like the ship lever, item charging and chairs, the way vanilla does."); SmoothSwingReturn = config.Bind<bool>("4. Camera", "SmoothSwingReturn", true, "Smooth body and arms while doing a shovel swing."); HideBodyInCruiser = config.Bind<bool>("4. Camera", "HideBodyInCruiser", false, "Hide first-person body while seated in vehicle and use vanilla first person arms."); if (registerWithLethalConfig && LethalConfigCompat.Present) { LethalConfigCompat.Register(CollectEntries(config)); } } private static List<ConfigEntryBase> CollectEntries(ConfigFile config) { List<ConfigEntryBase> list = new List<ConfigEntryBase>(); foreach (KeyValuePair<ConfigDefinition, ConfigEntryBase> item in config) { list.Add(item.Value); } return list; } } internal static class Constants { public const string ScavengerModelName = "ScavengerModel"; public const string MetarigName = "metarig"; public const string HeadBoneName = "spine.004"; public const string LeftArmBoneName = "arm.L_upper"; public const string RightArmBoneName = "arm.R_upper"; public const int EnemiesNotRenderedLayer = 23; public static readonly string[] HeadBoneNameHints = new string[4] { "head", "helmet", "visor", "spine.004" }; public const float HeadStrongInfluenceThreshold = 0.35f; public const float HeadAverageInfluenceThreshold = 0.3f; public const float PipeCullBehindThreshold = 0f; public const float CosmeticBodyScanInterval = 0.5f; public const float LethalPhonesScanInterval = 0.5f; public const float BodyDisabledWarnDelay = 5f; public const float NeckColumnCullStart = 0.6f; public const float NeckColumnCullRadius = 0.62f; public const float CrouchBlendTime = 0.15f; public const float BobDampBlendTime = 0.12f; public const float BobStabilizeTau = 0.2f; public const float LadderBlendTime = 0.08f; public const float LadderReleaseTime = 0.6f; public const float LadderStabilizeTau = 0.45f; public const float DisableHeadBobTau = 1f; public const float DisableHeadBobBlendTime = 0.15f; public const float DisableHeadBobEngageBand = 0.06f; public const float ArmSwapEngageDelay = 0.05f; public const float ArmSwapReleaseDelay = 0.25f; public const float EyeAnchorDriftTau = 2f; public const float EyeAnchorSettledLookBand = 0.05f; public const float EyeAnchorDriftLimit = 0.06f; public const float EyeAnchorDriftWarnThreshold = 0.06f; public const float EyeAnchorDriftWarnDelay = 5f; public const float StickToHeadBlendTime = 0.12f; public const float VehiclePushMatchEpsilonSqr = 1E-08f; public const float FollowStrengthVertical = 1f; public const float FollowStrengthHorizontal = 1f; public const float SprintBobReduction = 0.6f; public const float MaxFollowOffset = 0.5f; public const float EyeForwardFloor = 0f; public const float SwingReturnBlendTime = 0.3f; public const float SwingReturnHit = 0.7f; public const float SwingReturnCollide = 0.3f; public const float SwingTorsoTau = 0.07f; public const float SwingTorsoReturnTau = 0.16f; public const float SwingTorsoBlendTime = 0.25f; public const float SwingTorsoTail = 0.45f; public const float RunningBlendTime = 0.18f; public const float WalkingBlendTime = 0.18f; public const float JumpingBlendTime = 0.18f; public const float WallCollisionRadius = 0.1f; public const float WallCollisionForwardProbeRadius = 0.05f; public const float LookDownEyeOffsetForward = 0.13f; public const float LookDownCruiserImprovedEyeOffsetForward = 0.26f; public const float LookDownForwardStart = 0.45f; public const float LookDownForwardFull = 0.95f; public const float LookDownRunningEyeOffsetForward = 0.12f; public const float LookDownWalkingEyeOffsetForward = 0.02f; public const float LookDownJumpingEyeOffsetForward = 0.12f; public const float LookDownCruiserEyeOffsetForward = 0.13f; public const float HeldItemFadeStartDistance = 0.35f; public const float HeldItemFadeEndDistance = 0.1f; public const float HeldItemCoverageFadeStart = 0.45f; public const float HeldItemCoverageFadeFull = 0.6f; public const float HeldItemMinFade = 0.11f; public const float HeldItemFadeSmoothTime = 0.08f; public const float SeatedLookDownClamp = 75f; public static readonly Vector3 CruiserKeyPositionOffset = new Vector3(0f, 0f, -0.05f); public static readonly Vector3 CruiserKeyRotationOffset = Vector3.zero; } public enum HandsMode { Vanilla, ThirdPerson } public enum HeldItemFadeMode { Dither, Off } [Flags] public enum ItemDitherMode { Vanilla = 1, ThirdPerson = 2 } internal sealed class CameraBlends { public float Crouch; public float BobDamp; public float Run; public float Walk; public float Jump; public float DisableBob; public float StickToHead; public float Ladder; public void Reset() { Crouch = 0f; BobDamp = 0f; Run = 0f; Walk = 0f; Jump = 0f; DisableBob = 0f; StickToHead = 0f; Ladder = 0f; } } internal sealed class BobSmoothing { public Vector3 SmoothedDeviationLocal; public bool DeviationInitialized; public Vector3 SmoothedLadderLocal; public bool LadderInitialized; public float SmoothedY; public bool YInitialized; public void Reset() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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) SmoothedDeviationLocal = Vector3.zero; DeviationInitialized = false; SmoothedLadderLocal = Vector3.zero; LadderInitialized = false; SmoothedY = 0f; YInitialized = false; } } internal sealed class EyeAnchorState { public Vector3 Local; public Vector3 BoneLocal; public Vector3 Drift; public bool Captured; public float DriftHighSince; public bool DriftWarned; } internal sealed class LocalBodyState { public PlayerControllerB Player; public Transform ModelRoot; public Transform? HeadBone; public SkinnedMeshRenderer? BodyRenderer; public Mesh? OriginalBodyMesh; public bool OriginalBodyMeshCaptured; public bool HeadHidden; public SkinnedMeshRenderer? ShadowProxy; public LODGroup? PlayerLodGroup; public int BodyLodIndex = -1; public float BodyLodNextScan; public float CosmeticBodyNextScan; public Transform? LeftArmBone; public Transform? RightArmBone; public Transform? LocalVisor; public Transform? VisorOriginalParent; public bool VisorOriginalParentCaptured; public bool VisorReparented; public Renderer[]? CrackRenderers; public bool CrackHidden; public Camera? GameplayCamera; public Vector3 CameraBaseLocalPosition; public bool CameraBaseCaptured; public bool CameraOffsetApplied; public Vector3 LastCameraTargetLocal; public bool HasCameraTarget; public Vector3 VehiclePush; public Vector3 VehiclePushResult; public bool VehiclePushApplied; public readonly CameraBlends Blends = new CameraBlends(); public readonly BobSmoothing BobSmooth = new BobSmoothing(); public readonly EyeAnchorState EyeAnchor = new EyeAnchorState(); public bool MovementArmsActive; public float MovementArmsTimer; public bool SwingReturnStarted; public Component? LethalPhonesPlayerPhone; public float LethalPhonesNextScan; public Component? MoreCompanyCosmeticApplication; } internal static class LocalBodyViewController { private static readonly Dictionary<int, LocalBodyState> States = new Dictionary<int, LocalBodyState>(); private static bool renderCallbacksHooked; internal static bool LocalBodyShown; private static readonly HashSet<string> _loggedStageErrors = new HashSet<string>(); private static readonly List<SkinnedMeshRenderer> _riggedBodyScratch = new List<SkinnedMeshRenderer>(); private static readonly List<CosmeticBodyView.RiggedBodyCandidate> _candidateScratch = new List<CosmeticBodyView.RiggedBodyCandidate>(); private static readonly (Action<Camera> Apply, Action<Camera> Restore)[] CameraPasses = new(Action<Camera>, Action<Camera>)[4] { (FirstPersonBody.ApplyForCamera, FirstPersonBody.RestoreAfterCamera), (HeldItemView.ApplyForCamera, HeldItemView.RestoreAfterCamera), (MoreCompanyCompat.ApplyForCamera, MoreCompanyCompat.RestoreAfterCamera), (CosmeticBodyView.ApplyForCamera, CosmeticBodyView.RestoreAfterCamera) }; public static void ResetAllStates() { foreach (LocalBodyState value in States.Values) { FirstPersonBody.RestoreHead(value); VisorRig.Restore(value); CameraRig.RestoreOffset(value); if ((Object)(object)value.ShadowProxy != (Object)null) { Object.Destroy((Object)(object)((Component)value.ShadowProxy).gameObject); } } States.Clear(); LocalBodyShown = false; FirstPersonBody.Reset(); HeldItemView.Reset(); MoreCompanyCompat.Reset(); CosmeticBodyView.Reset(); SwingTorsoSmoothing.Reset(); MeshSurgery.ClearCaches(); if (renderCallbacksHooked) { RenderPipelineManager.beginCameraRendering -= OnBeginCameraRendering; RenderPipelineManager.endCameraRendering -= OnEndCameraRendering; renderCallbacksHooked = false; } } public static void Tick(PlayerControllerB player) { if (!Players.IsLocal(player)) { return; } EnsureRenderCallbacksHooked(); LocalBodyState orCreateState = GetOrCreateState(player); if (NeedsRefresh(orCreateState, player)) { try { RefreshState(orCreateState, player); } catch (Exception ex) { LogStageError("State refresh", ex); return; } } bool flag = player.isPlayerControlled && !player.isPlayerDead; bool flag2 = flag && HideBodyForVehicle(player); bool flag3 = (LocalBodyShown = flag && !flag2); bool flag4 = false; try { bool flag5 = LethalPhonesCompat.IsLocalPhoneActive(orCreateState, player); flag4 = !player.inSpecialInteractAnimation && (flag5 || (Players.IsActivelyHolding(player) && ConfigManager.Hands.Value == HandsMode.Vanilla)); } catch (Exception ex2) { LogStageError("Holding arms", ex2); } bool flag6 = false; try { if (flag3 && !Players.IsActivelyHolding(player) && !player.inSpecialInteractAnimation) { flag6 = MovementArmsGate.Update(orCreateState, player, Time.deltaTime); } else { MovementArmsGate.Reset(orCreateState); } } catch (Exception ex3) { LogStageError("Movement arms", ex3); } bool flag7 = flag3 && (flag4 || flag6); try { FirstPersonBody.ApplyBodyRendering(orCreateState, flag3, flag7); } catch (Exception ex4) { LogStageError("Body rendering", ex4); } try { HeldItemView.ApplyHolder(orCreateState, player, flag3, flag7); } catch (Exception ex5) { LogStageError("Held item", ex5); } try { if (flag3) { FirstPersonBody.HideHead(orCreateState, flag7); } else { FirstPersonBody.RestoreHead(orCreateState); } } catch (Exception ex6) { LogStageError("Head hiding", ex6); } try { if (flag3 && !VisorRig.IsImmersiveVisorPresent()) { VisorRig.StickToCamera(orCreateState); } else { VisorRig.Restore(orCreateState); } VisorRig.SuppressVanillaCrack(orCreateState, VisorRig.IsImmersiveVisorPresent()); } catch (Exception ex7) { LogStageError("Visor", ex7); } try { SwingReturn.Apply(orCreateState, player); } catch (Exception ex8) { LogStageError("Swing return", ex8); } try { SwingTorsoSmoothing.Apply(orCreateState, player); } catch (Exception ex9) { LogStageError("Swing torso", ex9); } try { if (IsInCruiserImprovedSeat(player)) { CameraRig.PrepareVehicleDetach(orCreateState); } else if (flag3 && !player.inTerminalMenu) { CameraRig.ApplyOffset(orCreateState, player); } else { CameraRig.RestoreOffset(orCreateState); } } catch (Exception ex10) { LogStageError("Camera offset", ex10); } try { CameraRig.ApplyArmAnchor(player, flag7); CameraRig.RelaxSeatedLookClamp(player); } catch (Exception ex11) { LogStageError("Arm anchor", ex11); } try { MoreCompanyCompat.ApplyLocalCosmeticVisibility(orCreateState, player, flag3, flag7, flag2); } catch (Exception ex12) { LogStageError("MoreCompany cosmetics", ex12); } try { RefreshCosmeticBodies(orCreateState, flag3, flag7); } catch (Exception ex13) { LogStageError("Cosmetic body", ex13); } } private static void LogStageError(string stage, Exception ex) { if (_loggedStageErrors.Add($"{stage}|{ex.GetType()}: {ex.Message}")) { Plugin.Log.LogError((object)$"{stage} failed.\n{ex}"); } } public static void AlignCameraForInteractionRay(PlayerControllerB player) { if (Players.IsLocal(player) && States.TryGetValue(((Object)player).GetInstanceID(), out LocalBodyState value)) { if (IsInCruiserImprovedSeat(player)) { CameraRig.ApplyVehiclePush(value); } else { CameraRig.AlignForInteractionRay(value); } } } private static void RefreshCosmeticBodies(LocalBodyState state, bool showBody, bool useVanillaArms) { if (!showBody || !state.HeadHidden || (Object)(object)state.HeadBone == (Object)null) { if (CosmeticBodyView.Active) { CosmeticBodyView.RestoreAll(); } state.CosmeticBodyNextScan = 0f; return; } CosmeticBodyView.SetFrameState(state.GameplayCamera, useVanillaArms); if (Time.unscaledTime < state.CosmeticBodyNextScan) { return; } state.CosmeticBodyNextScan = Time.unscaledTime + 0.5f; _candidateScratch.Clear(); MoreCompanyCompat.CollectRiggedBodies(state.HeadBone, _riggedBodyScratch); foreach (SkinnedMeshRenderer item in _riggedBodyScratch) { _candidateScratch.Add(new CosmeticBodyView.RiggedBodyCandidate { Renderer = item, HeadBone = state.HeadBone, LeftArmBone = state.LeftArmBone, RightArmBone = state.RightArmBone }); } CosmeticBodyView.Rebuild(_candidateScratch); } private static bool HideBodyForVehicle(PlayerControllerB player) { if (ConfigManager.HideBodyInCruiser.Value) { return player.inVehicleAnimation; } return false; } private static bool IsInCruiserImprovedSeat(PlayerControllerB player) { if (!ConfigManager.EnableCruiserImprovedCompatibility.Value || !player.inVehicleAnimation) { return false; } if (HideBodyForVehicle(player)) { return false; } InteractTrigger currentTriggerInAnimationWith = player.currentTriggerInAnimationWith; if ((Object)(object)currentTriggerInAnimationWith == (Object)null || (Object)(object)currentTriggerInAnimationWith.overridePlayerParent == (Object)null) { return false; } VehicleController val = default(VehicleController); if (((Component)currentTriggerInAnimationWith.overridePlayerParent).TryGetComponent<VehicleController>(ref val)) { return val.vehicleID == 0; } return false; } private static LocalBodyState GetOrCreateState(PlayerControllerB player) { int instanceID = ((Object)player).GetInstanceID(); if (!States.TryGetValue(instanceID, out LocalBodyState value)) { value = new LocalBodyState(); States[instanceID] = value; } return value; } private static bool NeedsRefresh(LocalBodyState state, PlayerControllerB player) { if (!((Object)(object)state.Player != (Object)(object)player) && !((Object)(object)state.ModelRoot == (Object)null) && !((Object)(object)state.HeadBone == (Object)null)) { return (Object)(object)state.BodyRenderer == (Object)null; } return true; } private static void RefreshState(LocalBodyState state, PlayerControllerB player) { state.Player = player; Transform val = ((Component)player).transform.Find("ScavengerModel"); state.ModelRoot = (((Object)(object)val != (Object)null) ? val : ((Component)player).transform); state.HeadBone = FindHeadBone(state.ModelRoot, player); state.LeftArmBone = FindBodyBone(player, "arm.L_upper"); state.RightArmBone = FindBodyBone(player, "arm.R_upper"); state.BodyRenderer = player.thisPlayerModel; state.PlayerLodGroup = ((Component)player).GetComponentInChildren<LODGroup>(); state.BodyLodIndex = -1; CaptureOriginalBodyMesh(state); state.LocalVisor = player.localVisor; CaptureVisorOriginalParent(state); state.GameplayCamera = player.gameplayCamera; CaptureCameraBase(state); } private static void CaptureOriginalBodyMesh(LocalBodyState state) { if (!((Object)(object)state.BodyRenderer == (Object)null) && !state.OriginalBodyMeshCaptured && !state.HeadHidden) { Mesh sharedMesh = state.BodyRenderer.sharedMesh; if (!((Object)(object)sharedMesh == (Object)null) && !MeshSurgery.IsGenerated(((Object)sharedMesh).GetInstanceID())) { state.OriginalBodyMesh = sharedMesh; state.OriginalBodyMeshCaptured = true; } } } private static void CaptureVisorOriginalParent(LocalBodyState state) { if (!((Object)(object)state.LocalVisor == (Object)null) && !state.VisorOriginalParentCaptured && !state.VisorReparented) { state.VisorOriginalParent = state.LocalVisor.parent; state.VisorOriginalParentCaptured = true; } } private static void CaptureCameraBase(LocalBodyState state) { //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) if (!((Object)(object)state.GameplayCamera == (Object)null) && !state.CameraBaseCaptured && !state.CameraOffsetApplied) { state.CameraBaseLocalPosition = ((Component)state.GameplayCamera).transform.localPosition; state.CameraBaseCaptured = true; } } private static Transform? FindHeadBone(Transform modelRoot, PlayerControllerB player) { SkinnedMeshRenderer thisPlayerModel = player.thisPlayerModel; if ((Object)(object)thisPlayerModel != (Object)null) { Transform[] bones = thisPlayerModel.bones; foreach (Transform val in bones) { if ((Object)(object)val != (Object)null && NameContains(((Object)val).name, "spine.004")) { return val; } } } return FindFirstByNameContains(modelRoot, "spine.004") ?? FindFirstByNameContains(modelRoot, "head"); } private static Transform? FindBodyBone(PlayerControllerB player, string boneName) { SkinnedMeshRenderer thisPlayerModel = player.thisPlayerModel; if ((Object)(object)thisPlayerModel == (Object)null) { return null; } Transform[] bones = thisPlayerModel.bones; foreach (Transform val in bones) { if ((Object)(object)val != (Object)null && string.Equals(((Object)val).name, boneName, StringComparison.OrdinalIgnoreCase)) { return val; } } return null; } private static Transform? FindFirstByNameContains(Transform root, string token) { Queue<Transform> queue = new Queue<Transform>(); queue.Enqueue(root); while (queue.Count > 0) { Transform val = queue.Dequeue(); if (NameContains(((Object)val).name, token)) { return val; } for (int i = 0; i < val.childCount; i++) { queue.Enqueue(val.GetChild(i)); } } return null; } private static bool NameContains(string name, string token) { return name.IndexOf(token, StringComparison.OrdinalIgnoreCase) >= 0; } private static void EnsureRenderCallbacksHooked() { if (!renderCallbacksHooked) { renderCallbacksHooked = true; RenderPipelineManager.beginCameraRendering += OnBeginCameraRendering; RenderPipelineManager.endCameraRendering += OnEndCameraRendering; } } private static void OnBeginCameraRendering(ScriptableRenderContext context, Camera camera) { (Action<Camera>, Action<Camera>)[] cameraPasses = CameraPasses; for (int i = 0; i < cameraPasses.Length; i++) { (Action<Camera>, Action<Camera>) tuple = cameraPasses[i]; tuple.Item1(camera); } } private static void OnEndCameraRendering(ScriptableRenderContext context, Camera camera) { (Action<Camera>, Action<Camera>)[] cameraPasses = CameraPasses; for (int i = 0; i < cameraPasses.Length; i++) { (Action<Camera>, Action<Camera>) tuple = cameraPasses[i]; tuple.Item2(camera); } } } internal static class ModGUIDs { public const string MoreCompany = "me.swipez.melonloader.morecompany"; public const string TooManyEmotes = "FlipMods.TooManyEmotes"; public const string ImmersiveVisor = "ImmersiveVisor"; public const string LethalPhones = "LethalPhones"; public const string LethalConfig = "ainavt.lc.lethalconfig"; } internal static class MovementArmsGate { private const float WallWeightThreshold = 0.01f; public static bool Update(LocalBodyState state, PlayerControllerB player, float deltaTime) { bool flag = (ConfigManager.VanillaArmsWhileSprinting.Value && player.isSprinting) || (ConfigManager.VanillaArmsWhileCrouching.Value && player.isCrouching) || (ConfigManager.VanillaArmsWhileJumping.Value && (player.isJumping || player.isFallingFromJump)) || (ConfigManager.VanillaArmsWhileWalking.Value && player.isWalking && !player.isSprinting) || (ConfigManager.VanillaArmsWhileEmoting.Value && player.performingEmote) || (ConfigManager.VanillaArmsNearWall.Value && player.handsOnWallWeight > 0.01f); if (flag == state.MovementArmsActive) { state.MovementArmsTimer = 0f; } else { state.MovementArmsTimer += deltaTime; float num = (flag ? 0.05f : 0.25f); if (state.MovementArmsTimer >= num) { state.MovementArmsActive = flag; state.MovementArmsTimer = 0f; } } return state.MovementArmsActive; } public static void Reset(LocalBodyState state) { state.MovementArmsActive = false; state.MovementArmsTimer = 0f; } } internal static class Players { private static readonly int ReelingUpHash = Animator.StringToHash("reelingUp"); public static bool IsLocal(PlayerControllerB player) { StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance != (Object)null) { return (Object)(object)instance.localPlayerController == (Object)(object)player; } return false; } public static bool IsActivelyHolding(PlayerControllerB player) { GrabbableObject currentlyHeldObjectServer = player.currentlyHeldObjectServer; if ((Object)(object)currentlyHeldObjectServer != (Object)null && currentlyHeldObjectServer.isHeld && !currentlyHeldObjectServer.isPocketed) { return (Object)(object)currentlyHeldObjectServer.playerHeldBy == (Object)(object)player; } return false; } public static bool IsSwingingShovelLike(PlayerControllerB player) { Animator playerBodyAnimator = player.playerBodyAnimator; if ((Object)(object)playerBodyAnimator != (Object)null && playerBodyAnimator.GetBool(ReelingUpHash)) { return true; } if (player.activatingItem) { return player.currentlyHeldObjectServer is Shovel; } return false; } } [BepInPlugin("com.seeya.firstpersonview", "First-Person View", "1.5.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { private const string GlobalConfigFolder = "FirstPersonView"; private readonly Harmony _harmony = new Harmony("com.seeya.firstpersonview"); public static Plugin Instance { get; private set; } public static ManualLogSource Log { get; private set; } internal static Harmony Harmony { get; private set; } private void Awake() { Instance = this; Log = ((BaseUnityPlugin)this).Logger; Harmony = _harmony; Log.LogInfo((object)"Initializing First-Person View"); ConfigFile val = ResolveConfigFile(); ConfigManager.Initialize(val, val != ((BaseUnityPlugin)this).Config); MoreCompanyCompat.Initialize(); TooManyEmotesCompat.Initialize(); LethalPhonesCompat.Initialize(); _harmony.PatchAll(); Log.LogInfo((object)"First-Person View is loaded!"); } private ConfigFile ResolveConfigFile() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown BepInPlugin metadata = MetadataHelper.GetMetadata((object)this); ConfigFile val = new ConfigFile(Path.Combine(Paths.ConfigPath, "com.seeya.firstpersonview.bootstrap.cfg"), true, metadata); if (!val.Bind<bool>("Main", "Use Global Config", false, "Share settings across all profiles via one global file instead of this profiles BepInEx/config. Requires a restart.").Value) { return ((BaseUnityPlugin)this).Config; } string localPath = Path.Combine(Paths.ConfigPath, "com.seeya.firstpersonview.cfg"); string text = Path.Combine(Application.persistentDataPath, "FirstPersonView"); string text2 = Path.Combine(text, "global.cfg"); MigrateLocalConfig(localPath, text, text2); return new ConfigFile(text2, false, metadata); } private static void MigrateLocalConfig(string localPath, string globalDirectory, string globalPath) { if (!File.Exists(globalPath) && File.Exists(localPath)) { Directory.CreateDirectory(globalDirectory); File.Copy(localPath, globalPath); Log.LogInfo((object)"Migrated existing profile config into the global config file."); } } } internal static class CosmeticBodyView { private sealed class RiggedBody { public SkinnedMeshRenderer Renderer; public Mesh Original; public Mesh Headless; public Mesh? HeadlessArmless; public bool OriginalUpdateWhenOffscreen; public LODGroup? GoverningLodGroup; public SkinnedMeshRenderer? ShadowProxy; } internal struct RiggedBodyCandidate { public SkinnedMeshRenderer Renderer; public Transform HeadBone; public Transform? LeftArmBone; public Transform? RightArmBone; } private static readonly List<RiggedBody> Bodies = new List<RiggedBody>(); private static readonly HashSet<int> RejectedMeshes = new HashSet<int>(); private static Camera? firstPersonCamera; private static bool hideArms; private static bool active; public static bool Active => active; public static void SetFrameState(Camera? camera, bool useVanillaArms) { firstPersonCamera = camera; hideArms = useVanillaArms; } public static void Rebuild(List<RiggedBodyCandidate> candidates) { for (int num = Bodies.Count - 1; num >= 0; num--) { RiggedBody riggedBody = Bodies[num]; if ((Object)(object)riggedBody.Renderer == (Object)null || (Object)(object)riggedBody.Original == (Object)null || (Object)(object)riggedBody.Headless == (Object)null || !ContainsRenderer(candidates, riggedBody.Renderer)) { ReleaseBody(riggedBody); Bodies.RemoveAt(num); } } foreach (RiggedBodyCandidate candidate in candidates) { try { TryTrackCandidate(candidate); } catch (Exception ex) { RejectCandidate(candidate, ex); } } active = Bodies.Count > 0; foreach (RiggedBody body in Bodies) { UpdateShadowProxy(body); } } private static void TryTrackCandidate(RiggedBodyCandidate candidate) { //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_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) SkinnedMeshRenderer renderer = candidate.Renderer; if ((Object)(object)renderer == (Object)null || (Object)(object)candidate.HeadBone == (Object)null || FindBody(renderer) != null) { return; } Mesh sharedMesh = renderer.sharedMesh; if ((Object)(object)sharedMesh == (Object)null || MeshSurgery.IsGenerated(((Object)sharedMesh).GetInstanceID()) || RejectedMeshes.Contains(((Object)sharedMesh).GetInstanceID())) { return; } Mesh orCreateHeadlessMesh = MeshSurgery.GetOrCreateHeadlessMesh(sharedMesh, renderer, candidate.HeadBone); if ((Object)(object)orCreateHeadlessMesh == (Object)null || !RemovesGeometry(sharedMesh, orCreateHeadlessMesh)) { if (RejectedMeshes.Add(((Object)sharedMesh).GetInstanceID())) { Plugin.Log.LogWarning((object)("Mesh '" + ((Object)sharedMesh).name + "' is rigged to head bone but no geometry could be removed from it so its head will not be hidden in first person.")); } return; } Mesh orCreateHeadlessArmlessMesh = MeshSurgery.GetOrCreateHeadlessArmlessMesh(sharedMesh, renderer, candidate.HeadBone, candidate.LeftArmBone, candidate.RightArmBone); RiggedBody riggedBody = new RiggedBody { Renderer = renderer, Original = sharedMesh, Headless = orCreateHeadlessMesh, HeadlessArmless = orCreateHeadlessArmlessMesh, OriginalUpdateWhenOffscreen = renderer.updateWhenOffscreen }; if (!renderer.updateWhenOffscreen) { Bounds bounds = ((Renderer)renderer).bounds; Vector3 size = ((Bounds)(ref bounds)).size; if (((Vector3)(ref size)).sqrMagnitude < 1E-06f) { renderer.updateWhenOffscreen = true; Plugin.Log.LogInfo((object)("Cosmetic '" + ((Object)renderer).name + "' had no usable bounds so it was culled from most cameras. Its bounds are now recalculated every frame.")); } } riggedBody.GoverningLodGroup = FindGoverningLodGroup(renderer); if ((Object)(object)riggedBody.GoverningLodGroup != (Object)null) { riggedBody.GoverningLodGroup.ForceLOD(0); Plugin.Log.LogInfo((object)("Cosmetic '" + ((Object)renderer).name + "' is managed by its own level of detail group which culled it on cameras that were far enough away.")); } Bodies.Add(riggedBody); } private static LODGroup? FindGoverningLodGroup(SkinnedMeshRenderer renderer) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) Transform root = ((Component)renderer).transform.root; LODGroup[] componentsInChildren = ((Component)root).GetComponentsInChildren<LODGroup>(true); foreach (LODGroup val in componentsInChildren) { LOD[] lODs = val.GetLODs(); foreach (LOD val2 in lODs) { Renderer[] renderers = val2.renderers; foreach (Renderer val3 in renderers) { if ((object)val3 == renderer) { return val; } } } } return null; } private static void RejectCandidate(RiggedBodyCandidate candidate, Exception ex) { SkinnedMeshRenderer renderer = candidate.Renderer; Mesh val = (((Object)(object)renderer != (Object)null) ? renderer.sharedMesh : null); if (!((Object)(object)val == (Object)null) && RejectedMeshes.Add(((Object)val).GetInstanceID())) { Plugin.Log.LogWarning((object)("Mesh '" + ((Object)val).name + "' could not be get ready for first person so its head will stay visible. " + ex.Message)); } } private static bool ContainsRenderer(List<RiggedBodyCandidate> candidates, SkinnedMeshRenderer renderer) { foreach (RiggedBodyCandidate candidate in candidates) { if (candidate.Renderer == renderer) { return true; } } return false; } private static bool RemovesGeometry(Mesh source, Mesh headless) { if (headless.subMeshCount != source.subMeshCount) { return true; } for (int i = 0; i < source.subMeshCount; i++) { if (headless.GetIndexCount(i) != source.GetIndexCount(i)) { return true; } } return false; } public static bool OwnsRenderer(Renderer renderer) { foreach (RiggedBody body in Bodies) { if ((object)body.Renderer == renderer) { return true; } } return false; } private static RiggedBody? FindBody(SkinnedMeshRenderer renderer) { foreach (RiggedBody body in Bodies) { if (body.Renderer == renderer) { return body; } } return null; } public static void ApplyForCamera(Camera camera) { if (!active) { return; } bool flag = (Object)(object)camera == (Object)(object)firstPersonCamera && FirstPersonBody.HideActive; foreach (RiggedBody body in Bodies) { SkinnedMeshRenderer renderer = body.Renderer; if ((Object)(object)renderer == (Object)null) { continue; } if (flag) { Mesh val = (Mesh)((hideArms && (Object)(object)body.HeadlessArmless != (Object)null) ? ((object)body.HeadlessArmless) : ((object)body.Headless)); if ((Object)(object)val != (Object)null && (Object)(object)renderer.sharedMesh != (Object)(object)val) { renderer.sharedMesh = val; } } else if ((Object)(object)body.Original != (Object)null && (Object)(object)renderer.sharedMesh != (Object)(object)body.Original) { renderer.sharedMesh = body.Original; } } } public static void RestoreAfterCamera(Camera camera) { if (!active || (Object)(object)camera != (Object)(object)firstPersonCamera) { return; } foreach (RiggedBody body in Bodies) { RestoreBody(body); } } private static void RestoreBody(RiggedBody body) { SkinnedMeshRenderer renderer = body.Renderer; if (!((Object)(object)renderer == (Object)null) && !((Object)(object)body.Original == (Object)null) && !((Object)(object)renderer.sharedMesh == (Object)(object)body.Original)) { renderer.sharedMesh = body.Original; } } private static void ReleaseBody(RiggedBody body) { RestoreBody(body); if ((Object)(object)body.Renderer != (Object)null) { body.Renderer.updateWhenOffscreen = body.OriginalUpdateWhenOffscreen; } if ((Object)(object)body.GoverningLodGroup != (Object)null) { body.GoverningLodGroup.ForceLOD(-1); body.GoverningLodGroup = null; } if ((Object)(object)body.ShadowProxy != (Object)null) { Object.Destroy((Object)(object)((Component)body.ShadowProxy).gameObject); } body.ShadowProxy = null; } public static void RestoreAll() { foreach (RiggedBody body in Bodies) { ReleaseBody(body); } Bodies.Clear(); active = false; } public static void Reset() { RestoreAll(); RejectedMeshes.Clear(); firstPersonCamera = null; hideArms = false; } private static void UpdateShadowProxy(RiggedBody body) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0050: 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_007c: Unknown result type (might be due to invalid IL or missing references) SkinnedMeshRenderer renderer = body.Renderer; if ((Object)(object)renderer == (Object)null) { return; } if ((Object)(object)body.ShadowProxy == (Object)null) { try { GameObject val = new GameObject("FPVCosmeticShadowProxy"); val.transform.SetParent(((Component)renderer).transform.parent, false); val.transform.localPosition = ((Component)renderer).transform.localPosition; val.transform.localRotation = ((Component)renderer).transform.localRotation; val.transform.localScale = ((Component)renderer).transform.localScale; SkinnedMeshRenderer val2 = val.AddComponent<SkinnedMeshRenderer>(); val2.sharedMesh = body.Original; val2.bones = renderer.bones; val2.rootBone = renderer.rootBone; ((Renderer)val2).sharedMaterials = ((Renderer)renderer).sharedMaterials; ((Renderer)val2).shadowCastingMode = (ShadowCastingMode)3; val2.updateWhenOffscreen = true; body.ShadowProxy = val2; } catch (Exception ex) { Plugin.Log.LogWarning((object)("Failed to create cosmetic shadow proxy. " + ex.Message)); return; } } ((Component)body.ShadowProxy).gameObject.layer = ((Component)renderer).gameObject.layer; if (((Renderer)body.ShadowProxy).enabled != ((Renderer)renderer).enabled) { ((Renderer)body.ShadowProxy).enabled = ((Renderer)renderer).enabled; } } } internal static class FirstPersonBody { private static SkinnedMeshRenderer? hideRenderer; private static Mesh? originalMesh; private static Mesh? headlessMesh; private static Mesh? headlessArmlessMesh; private static bool hideArmsInFirstPerson; private static Camera? hideCamera; private static bool hideActive; private static SkinnedMeshRenderer? fpArms; private static bool fpArmsIntended; private static bool bodyDisabledWarned; private static float bodyDisabledSince; private static bool bodyLayerMoveLogged; public static bool HideActive => hideActive; public static void ApplyBodyRendering(LocalBodyState state, bool showBody, bool useVanillaArms) { //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Invalid comparison between Unknown and I4 //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Invalid comparison between Unknown and I4 //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Invalid comparison between Unknown and I4 PlayerControllerB player = state.Player; if ((Object)(object)player == (Object)null || !player.isPlayerControlled || player.isPlayerDead) { return; } if (showBody) { if ((Object)(object)player.thisPlayerModel != (Object)null) { WarnIfBodyRendererDisabled(player.thisPlayerModel); RestoreBodyLayer(state, player.thisPlayerModel); if ((int)((Renderer)player.thisPlayerModel).shadowCastingMode != 1) { ((Renderer)player.thisPlayerModel).shadowCastingMode = (ShadowCastingMode)1; } if ((int)((Renderer)player.thisPlayerModel).motionVectorGenerationMode != 2) { ((Renderer)player.thisPlayerModel).motionVectorGenerationMode = (MotionVectorGenerationMode)2; } } bool flag = IsPlayerModelReplaced(player); if ((Object)(object)state.PlayerLodGroup != (Object)null) { if (!state.PlayerLodGroup.enabled) { state.PlayerLodGroup.enabled = true; } if ((Object)(object)player.thisPlayerModel != (Object)null && (state.BodyLodIndex < 0 || Time.unscaledTime >= state.BodyLodNextScan)) { state.BodyLodIndex = FindLodIndex(state.PlayerLodGroup, (Renderer)(object)player.thisPlayerModel); state.BodyLodNextScan = Time.unscaledTime + 0.5f; } state.PlayerLodGroup.ForceLOD(flag ? (-1) : ((state.BodyLodIndex >= 0) ? state.BodyLodIndex : 0)); } if (!flag) { if ((Object)(object)player.thisPlayerModelLOD1 != (Object)null && ((Renderer)player.thisPlayerModelLOD1).enabled) { ((Renderer)player.thisPlayerModelLOD1).enabled = false; } if ((Object)(object)player.thisPlayerModelLOD2 != (Object)null && ((Renderer)player.thisPlayerModelLOD2).enabled) { ((Renderer)player.thisPlayerModelLOD2).enabled = false; } } SetFpArmsEnabled(player, useVanillaArms); } else { if ((Object)(object)player.thisPlayerModel != (Object)null && (int)((Renderer)player.thisPlayerModel).shadowCastingMode != 3) { ((Renderer)player.thisPlayerModel).shadowCastingMode = (ShadowCastingMode)3; } SetFpArmsEnabled(player, enabled: true); } } private static void RestoreBodyLayer(LocalBodyState state, SkinnedMeshRenderer body) { if (((Component)body).gameObject.layer == 23) { Transform modelRoot = state.ModelRoot; int num = (((Object)(object)modelRoot != (Object)null && ((Component)modelRoot).gameObject.layer != 23) ? ((Component)modelRoot).gameObject.layer : 0); ((Component)body).gameObject.layer = num; if (!bodyLayerMoveLogged) { bodyLayerMoveLogged = true; Plugin.Log.LogInfo((object)$"Your body renderer was on layer {23} which most cameras do not draw. Moved it to layer {num} so it shows on cameras."); } } } private static void WarnIfBodyRendererDisabled(SkinnedMeshRenderer body) { if (!bodyDisabledWarned) { if (((Renderer)body).enabled || CosmeticBodyView.Active) { bodyDisabledSince = 0f; } else if (bodyDisabledSince <= 0f) { bodyDisabledSince = Time.unscaledTime; } else if (!(Time.unscaledTime - bodyDisabledSince < 5f)) { bodyDisabledWarned = true; Plugin.Log.LogError((object)"Your body renderer was disabled by another mod and nothing rigged to your skeleton replaced it so First-Person View cannot show your body. Mods such as ModelReplacementAPI are not supported and won't be supported."); } } } private static void SetFpArmsEnabled(PlayerControllerB player, bool enabled) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Invalid comparison between Unknown and I4 fpArms = player.thisPlayerModelArms; fpArmsIntended = enabled; if (!((Object)(object)fpArms == (Object)null)) { if ((int)((Renderer)fpArms).motionVectorGenerationMode != 2) { ((Renderer)fpArms).motionVectorGenerationMode = (MotionVectorGenerationMode)2; } if (((Renderer)fpArms).enabled != enabled) { ((Renderer)fpArms).enabled = enabled; } } } private static int FindLodIndex(LODGroup group, Renderer target) { LOD[] lODs = group.GetLODs(); for (int i = 0; i < lODs.Length; i++) { Renderer[] renderers = lODs[i].renderers; for (int j = 0; j < renderers.Length; j++) { if ((Object)(object)renderers[j] == (Object)(object)target) { return i; } } } return 0; } private static bool IsPlayerModelReplaced(PlayerControllerB player) { if ((Object)(object)player.thisPlayerModel != (Object)null) { return !((Renderer)player.thisPlayerModel).enabled; } return false; } public static void HideHead(LocalBodyState state, bool hideArms) { hideArmsInFirstPerson = hideArms; hideCamera = state.GameplayCamera; state.HeadHidden = true; SkinnedMeshRenderer bodyRenderer = state.BodyRenderer; Mesh originalBodyMesh = state.OriginalBodyMesh; if ((Object)(object)bodyRenderer == (Object)null || (Object)(object)originalBodyMesh == (Object)null || (Object)(object)state.HeadBone == (Object)null) { hideActive = false; UpdateShadowProxy(state, active: false); return; } Mesh orCreateHeadlessMesh = MeshSurgery.GetOrCreateHeadlessMesh(originalBodyMesh, bodyRenderer, state.HeadBone); if ((Object)(object)orCreateHeadlessMesh == (Object)null) { hideActive = false; UpdateShadowProxy(state, active: false); return; } if ((Object)(object)bodyRenderer.sharedMesh != (Object)(object)originalBodyMesh) { bodyRenderer.sharedMesh = originalBodyMesh; } headlessArmlessMesh = (hideArms ? MeshSurgery.GetOrCreateHeadlessArmlessMesh(originalBodyMesh, bodyRenderer, state.HeadBone, state.LeftArmBone, state.RightArmBone) : null); hideRenderer = bodyRenderer; originalMesh = originalBodyMesh; headlessMesh = orCreateHeadlessMesh; hideCamera = state.GameplayCamera; hideActive = true; UpdateShadowProxy(state, active: true); } public static void RestoreHead(LocalBodyState state) { hideActive = false; hideCamera = state.GameplayCamera; SkinnedMeshRenderer bodyRenderer = state.BodyRenderer; if ((Object)(object)bodyRenderer != (Object)null && (Object)(object)state.OriginalBodyMesh != (Object)null && (Object)(object)bodyRenderer.sharedMesh != (Object)(object)state.OriginalBodyMesh) { bodyRenderer.sharedMesh = state.OriginalBodyMesh; } UpdateShadowProxy(state, active: false); state.HeadHidden = false; } private static void UpdateShadowProxy(LocalBodyState state, bool active) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_00a1: 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_00cd: Unknown result type (might be due to invalid IL or missing references) if (!active) { if ((Object)(object)state.ShadowProxy != (Object)null) { ((Renderer)state.ShadowProxy).enabled = false; } return; } SkinnedMeshRenderer bodyRenderer = state.BodyRenderer; Mesh originalBodyMesh = state.OriginalBodyMesh; if ((Object)(object)bodyRenderer == (Object)null || (Object)(object)originalBodyMesh == (Object)null) { return; } if (!((Renderer)bodyRenderer).enabled) { if ((Object)(object)state.ShadowProxy != (Object)null) { ((Renderer)state.ShadowProxy).enabled = false; } return; } if ((Object)(object)state.ShadowProxy == (Object)null) { try { GameObject val = new GameObject("FPVHeadShadowProxy"); val.transform.SetParent(((Component)bodyRenderer).transform.parent, false); val.transform.localPosition = ((Component)bodyRenderer).transform.localPosition; val.transform.localRotation = ((Component)bodyRenderer).transform.localRotation; val.transform.localScale = ((Component)bodyRenderer).transform.localScale; SkinnedMeshRenderer val2 = val.AddComponent<SkinnedMeshRenderer>(); val2.sharedMesh = originalBodyMesh; val2.bones = bodyRenderer.bones; val2.rootBone = bodyRenderer.rootBone; ((Renderer)val2).sharedMaterials = ((Renderer)bodyRenderer).sharedMaterials; ((Renderer)val2).shadowCastingMode = (ShadowCastingMode)3; val2.updateWhenOffscreen = true; state.ShadowProxy = val2; } catch (Exception ex) { Plugin.Log.LogWarning((object)("Failed to create head shadow proxy. " + ex.Message)); return; } } ((Component)state.ShadowProxy).gameObject.layer = ((Component)bodyRenderer).gameObject.layer; if (!((Renderer)state.ShadowProxy).enabled) { ((Renderer)state.ShadowProxy).enabled = true; } } public static void ApplyForCamera(Camera camera) { SetArmsVisibleForCamera(fpArmsIntended && (Object)(object)camera == (Object)(object)hideCamera); SkinnedMeshRenderer val = hideRenderer; if (!hideActive || (Object)(object)val == (Object)null) { return; } if ((Object)(object)camera == (Object)(object)hideCamera) { Mesh val2 = ((hideArmsInFirstPerson && (Object)(object)headlessArmlessMesh != (Object)null) ? headlessArmlessMesh : headlessMesh); if ((Object)(object)val2 != (Object)null && (Object)(object)val.sharedMesh != (Object)(object)val2) { val.sharedMesh = val2; } } else if ((Object)(object)originalMesh != (Object)null && (Object)(object)val.sharedMesh != (Object)(object)originalMesh) { val.sharedMesh = originalMesh; } } private static void SetArmsVisibleForCamera(bool visible) { if (!((Object)(object)fpArms == (Object)null) && ((Renderer)fpArms).enabled != visible) { ((Renderer)fpArms).enabled = visible; } } public static void RestoreAfterCamera(Camera camera) { if ((Object)(object)camera == (Object)(object)hideCamera) { SetArmsVisibleForCamera(fpArmsIntended); } SkinnedMeshRenderer val = hideRenderer; if (!((Object)(object)val == (Object)null) && !((Object)(object)originalMesh == (Object)null) && (Object)(object)camera == (Object)(object)hideCamera && (Object)(object)val.sharedMesh != (Object)(object)originalMesh) { val.sharedMesh = originalMesh; } } public static void Reset() { hideActive = false; hideRenderer = null; originalMesh = null; headlessMesh = null; headlessArmlessMesh = null; hideArmsInFirstPerson = false; hideCamera = null; fpArms = null; fpArmsIntended = false; bodyDisabledWarned = false; bodyDisabledSince = 0f; bodyLayerMoveLogged = false; } } internal static class HeldItemView { private const int CoverageGridSize = 16; private static readonly int[] coverageRowMin = new int[16]; private static readonly int[] coverageRowMax = new int[16]; private static GrabbableObject? trackedItem; private static Renderer[] renderers = Array.Empty<Renderer>(); private static MotionVectorGenerationMode[] originalMotionModes = Array.Empty<MotionVectorGenerationMode>(); private static Material[] materials = Array.Empty<Material>(); private static bool materialsResolved; private static Renderer? boundsSource; private static Vector3[] localVertices = Array.Empty<Vector3>(); private static Camera? camera; private static bool hideActive; private static float fadeCurrent = 1f; public static void ApplyHolder(LocalBodyState state, PlayerControllerB player, bool showBody, bool useVanillaArms) { GrabbableObject currentlyHeldObjectServer = player.currentlyHeldObjectServer; bool flag = Players.IsActivelyHolding(player); bool isInspectingItem = player.IsInspectingItem; if (flag && (Object)(object)currentlyHeldObjectServer != (Object)null) { Transform val = ((useVanillaArms || isInspectingItem || !showBody) ? player.localItemHolder : player.serverItemHolder); if ((Object)(object)val != (Object)null && (Object)(object)currentlyHeldObjectServer.parentObject != (Object)(object)val) { currentlyHeldObjectServer.parentObject = val; } } bool flag2 = DitherEnabled(); GrabbableObject val2 = (flag ? currentlyHeldObjectServer : null); if ((Object)(object)val2 != (Object)(object)trackedItem) { ResetEffect(); RestoreMotionVectors(); trackedItem = val2; renderers = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponentsInChildren<Renderer>() : Array.Empty<Renderer>()); SuppressMotionVectors(); materials = (Material[])(flag2 ? ((Array)MaterialDither.CollectInstancedMaterials(renderers)) : ((Array)Array.Empty<Material>())); materialsResolved = flag2; boundsSource = ResolveBoundsSource(val2, renderers); localVertices = ResolveLocalVertices(boundsSource); } else if (flag2 && !materialsResolved && renderers.Length != 0) { materials = MaterialDither.CollectInstancedMaterials(renderers); materialsResolved = true; } camera = state.GameplayCamera; hideActive = showBody && (Object)(object)val2 != (Object)null && !isInspectingItem; } public static void ApplyForCamera(Camera renderingCamera) { if (hideActive && renderers.Length != 0 && DitherEnabled()) { float fade = (((Object)(object)renderingCamera == (Object)(object)camera) ? ComputeFade(renderingCamera) : 1f); ApplyFade(fade); } } private static bool DitherEnabled() { if (ConfigManager.HeldItemFadeStyle.Value == HeldItemFadeMode.Off) { return false; } ItemDitherMode value = ConfigManager.ItemDither.Value; if (ConfigManager.Hands.Value != HandsMode.Vanilla) { return (value & ItemDitherMode.ThirdPerson) != 0; } return (value & ItemDitherMode.Vanilla) != 0; } public static void RestoreAfterCamera(Camera renderingCamera) { if (renderers.Length != 0 && (Object)(object)renderingCamera == (Object)(object)camera) { ApplyFade(1f); } } private static float ComputeFade(Camera renderingCamera) { //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_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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) Renderer val = boundsSource; if ((Object)(object)val == (Object)null) { return 1f; } Vector3[] array = localVertices; Vector3 position = ((Component)renderingCamera).transform.position; float num; if (array.Length == 0) { num = MaterialDither.ProximityFade(NearestBoxDistance(val, position)); } else { Matrix4x4 localToWorldMatrix = val.localToWorldMatrix; float num2 = float.MaxValue; for (int i = 0; i < 16; i++) { coverageRowMin[i] = 16; coverageRowMax[i] = -1; } Vector3[] array2 = array; foreach (Vector3 val2 in array2) { Vector3 val3 = ((Matrix4x4)(ref localToWorldMatrix)).MultiplyPoint3x4(val2); Vector3 val4 = val3 - position; float sqrMagnitude = ((Vector3)(ref val4)).sqrMagnitude; if (sqrMagnitude < num2) { num2 = sqrMagnitude; } Vector3 val5 = renderingCamera.WorldToViewportPoint(val3); if (!(val5.z <= 0f)) { int num3 = Mathf.Clamp((int)(Mathf.Clamp01(val5.x) * 16f), 0, 15); int num4 = Mathf.Clamp((int)(Mathf.Clamp01(val5.y) * 16f), 0, 15); if (num3 < coverageRowMin[num4]) { coverageRowMin[num4] = num3; } if (num3 > coverageRowMax[num4]) { coverageRowMax[num4] = num3; } } } int num5 = 0; for (int k = 0; k < 16; k++) { if (coverageRowMax[k] >= coverageRowMin[k]) { num5 += coverageRowMax[k] - coverageRowMin[k] + 1; } } float coverage = (float)num5 / 256f; num = Mathf.Min(MaterialDither.ProximityFade(Mathf.Sqrt(num2)), CoverageFade(coverage)); } num = Mathf.Max(0.11f, num); fadeCurrent = MaterialDither.Smooth(fadeCurrent, num, 0.08f); return fadeCurrent; } private static float CoverageFade(float coverage) { return 1f - Mathf.Clamp01(Mathf.InverseLerp(0.45f, 0.6f, coverage)); } private static float NearestBoxDistance(Renderer renderer, Vector3 worldPoint) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references)