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 BiasedFeatures v1.0.0
bobabulkerENTERPRISE.BiasedFeatures.dll
Decompiled 16 hours agousing System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Threading; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using BiasedFeatures.FlashlightTweaks; using CSync.Extensions; using CSync.Lib; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("bobabulkerENTERPRISE.BiasedFeatures")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+defae4b4ac3ff36fd22d2009e69f6a304516ec99")] [assembly: AssemblyProduct("BiasedFeatures")] [assembly: AssemblyTitle("bobabulkerENTERPRISE.BiasedFeatures")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.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 BiasedFeatures { public class BiasedConfig : SyncedConfig2<BiasedConfig> { [SyncedEntryField] public SyncedEntry<float> FlashlightDelayStrength; [SyncedEntryField] public SyncedEntry<float> FlashlightMovementInstability; [SyncedEntryField] public SyncedEntry<float> FlashlightIdleSway; [SyncedEntryField] public SyncedEntry<float> FlashlightBeamPosition; public BiasedConfig(ConfigFile cfg) : base("bobabulkerENTERPRISE.BiasedFeatures") { BindFlashlightTweaks(cfg); ConfigManager.Register<BiasedConfig>((SyncedConfig2<BiasedConfig>)(object)this); } private void BindFlashlightTweaks(ConfigFile cfg) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown FlashlightDelayStrength = SyncedBindingExtensions.BindSyncedEntry<float>(cfg, "Flashlight Tweaks", "DelayStrength", 0.25f, new ConfigDescription("How strongly your held flashlight lags behind camera movement. 0 = no delay (vanilla), 1 = maximum delay. Only the host can change this; clients receive the host's value.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); FlashlightMovementInstability = SyncedBindingExtensions.BindSyncedEntry<float>(cfg, "Flashlight Tweaks", "MovementInstability", 0.5f, new ConfigDescription("How much your flashlight wobbles as you move. The faster you move (walking, running, jumping, landing, crouching, falling), the stronger the wobble. 0 = steady, 1 = most unsteady. Only the host can change this; clients receive the host's value.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); FlashlightIdleSway = SyncedBindingExtensions.BindSyncedEntry<float>(cfg, "Flashlight Tweaks", "IdleSway", 0.5f, new ConfigDescription("How much your flashlight drifts gently at all times, including when you stand still. 0 = none, 1 = most. Only the host can change this; clients receive the host's value.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); FlashlightBeamPosition = SyncedBindingExtensions.BindSyncedEntry<float>(cfg, "Flashlight Tweaks", "BeamPosition", 0.5f, new ConfigDescription("Where the beam of a flashlight you have put away (in your inventory) comes from. 0.5 = from the middle of your view, shining straight ahead. Higher moves the source to the right and angles the beam back toward the middle, in proportion; lower does the same from the left. The default, 0.5, centres it; the game's own beam is about 0.65. A flashlight you are holding is not affected. Only the host can change this; clients receive the host's value.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); } } [BepInPlugin("bobabulkerENTERPRISE.BiasedFeatures", "BiasedFeatures", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class BiasedFeatures : BaseUnityPlugin { private static readonly TimeSpan ReloadDebounce = TimeSpan.FromMilliseconds(300.0); private FileSystemWatcher? _configWatcher; private long _reloadRequestedAtTicks; public static BiasedFeatures Instance { get; private set; } = null; internal static ManualLogSource Logger { get; private set; } = null; internal static Harmony? Harmony { get; set; } internal static BiasedConfig Settings { get; private set; } = null; private void Awake() { ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Logger = ((BaseUnityPlugin)this).Logger; Instance = this; Settings = new BiasedConfig(((BaseUnityPlugin)this).Config); StartConfigWatcher(); HolsteredFlashlightLag.Enable(); Patch(); Logger.LogInfo((object)"bobabulkerENTERPRISE.BiasedFeatures v1.0.0 has loaded!"); } private void Update() { long num = Interlocked.Read(in _reloadRequestedAtTicks); if (num != 0L && DateTime.UtcNow.Ticks - num >= ReloadDebounce.Ticks) { Interlocked.Exchange(ref _reloadRequestedAtTicks, 0L); Logger.LogDebug((object)"Config file changed on disk, reloading..."); ((BaseUnityPlugin)this).Config.Reload(); } } private void OnDestroy() { Logger.LogDebug((object)"Plugin object destroyed."); _configWatcher?.Dispose(); _configWatcher = null; } private void StartConfigWatcher() { string configFilePath = ((BaseUnityPlugin)this).Config.ConfigFilePath; string directoryName = Path.GetDirectoryName(configFilePath); if (!string.IsNullOrEmpty(directoryName)) { _configWatcher = new FileSystemWatcher(directoryName, Path.GetFileName(configFilePath)) { NotifyFilter = (NotifyFilters.Size | NotifyFilters.LastWrite) }; _configWatcher.Changed += delegate { Interlocked.Exchange(ref _reloadRequestedAtTicks, DateTime.UtcNow.Ticks); }; _configWatcher.EnableRaisingEvents = true; } } internal static void Patch() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown if (Harmony == null) { Harmony = new Harmony("bobabulkerENTERPRISE.BiasedFeatures"); } Logger.LogDebug((object)"Patching..."); Harmony.PatchAll(); Logger.LogDebug((object)"Finished patching!"); } internal static void Unpatch() { Logger.LogDebug((object)"Unpatching..."); Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } Logger.LogDebug((object)"Finished unpatching!"); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "bobabulkerENTERPRISE.BiasedFeatures"; public const string PLUGIN_NAME = "BiasedFeatures"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace BiasedFeatures.FlashlightTweaks { internal static class BeamAim { public const float VanillaPosition = 0.65f; private const float SettingSmoothingSeconds = 0.15f; private const float MaxScale = 2f; private static float _position = 0.65f; private static int _advanceFrame = -1; private static bool _logged; private static float Setting => Mathf.Clamp01(BiasedFeatures.Settings.FlashlightBeamPosition.Value); public static bool Enabled { get { if (!(Mathf.Abs(Setting - 0.65f) > 0.0001f)) { return Mathf.Abs(_position - 0.65f) > 0.001f; } return true; } } public static Quaternion Correction(Camera camera, Vector3 vanillaPosition, Quaternion vanillaRotation, out Vector3 slide) { //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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) slide = Vector3.zero; if (_advanceFrame != Time.frameCount) { _advanceFrame = Time.frameCount; _position = Mathf.Lerp(_position, Setting, 1f - Mathf.Exp((0f - Time.deltaTime) / 0.15f)); } Transform transform = ((Component)camera).transform; Quaternion rotation = transform.rotation; Quaternion val = Quaternion.Inverse(rotation); Vector3 val2 = val * (vanillaPosition - transform.position); float x = val2.x; Vector3 val3 = val * (vanillaRotation * Vector3.forward); float num = Mathf.Atan2(val3.x, val3.z) * 57.29578f; if (!_logged) { _logged = true; BiasedFeatures.Logger.LogDebug((object)($"Put-away beam: source {x:F3} m right, {val2.y:F3} m up, {val2.z:F3} m ahead of the camera, aimed {num:F2} deg right " + $"(the game's own beam is at setting {0.65f}; 0.5 = centred and straight ahead).")); } float num2 = ((Mathf.Abs(0.14999998f) < 0.001f) ? 1f : Mathf.Clamp((_position - 0.5f) / 0.14999998f, -2f, 2f)); slide = transform.right * (x * (num2 - 1f)); return Quaternion.AngleAxis(num * (num2 - 1f), transform.up); } } internal static class BeamFrameLimiter { private const float MinVisibleFraction = 0.75f; private const int Slices = 40; private const int Iterations = 10; private const float DefaultSpotAngle = 60f; private const float MinForwardComponent = 0.05f; public static float SpotAngleOf(Light? light) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)light != (Object)null) || (int)light.type != 0) { return 60f; } return light.spotAngle; } public static float FindSafeScale(Camera camera, Quaternion deviation, Vector3 vanillaBeamDirection, float spotAngleDegrees) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) Quaternion inverseCamera = Quaternion.Inverse(((Component)camera).transform.rotation); float halfTanY = Mathf.Tan(camera.fieldOfView * 0.5f * (MathF.PI / 180f)); float halfTanX = halfTanY * camera.aspect; float radius = Mathf.Tan(Mathf.Clamp(spotAngleDegrees * 0.5f, 1f, 80f) * (MathF.PI / 180f)); float num = 0.75f * VisibleAt(0f); if (VisibleAt(1f) >= num) { return 1f; } float num2 = 0f; float num3 = 1f; for (int i = 0; i < 10; i++) { float num4 = (num2 + num3) * 0.5f; if (VisibleAt(num4) >= num) { num2 = num4; } else { num3 = num4; } } return num2; float VisibleAt(float scale) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) Quaternion val = Quaternion.Slerp(Quaternion.identity, deviation, scale); return VisibleFraction(inverseCamera * (val * vanillaBeamDirection), halfTanX, halfTanY, radius); } } private static float VisibleFraction(Vector3 direction, float halfTanX, float halfTanY, float radius) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (direction.z <= 0.05f) { return 0f; } float num = direction.x / direction.z; float num2 = direction.y / direction.z; float num3 = Mathf.Max(num - radius, 0f - halfTanX); float num4 = Mathf.Min(num + radius, halfTanX); if (num4 <= num3) { return 0f; } float num5 = (num4 - num3) / 40f; float num6 = 0f; for (int i = 0; i < 40; i++) { float num7 = num3 + ((float)i + 0.5f) * num5; float num8 = (num7 - num) / radius; float num9 = radius * Mathf.Sqrt(Mathf.Max(0f, 1f - num8 * num8)); float num10 = Mathf.Max(num2 - num9, 0f - halfTanY); float num11 = Mathf.Min(num2 + num9, halfTanY); if (num11 > num10) { num6 += (num11 - num10) * num5; } } return num6 / (MathF.PI * radius * radius); } } internal static class FlashlightInstability { private const float MaxDegrees = 20f; private const float IdleMaxDegrees = 10f; private const float IdleDriftSpeed = 0.35f; private const float IdleBreathRate = 0.22f; private const float IdleFadeInSeconds = 0.5f; private const float DefaultStepInterval = 0.45f; private const float MinStepInterval = 0.15f; private const float MaxStepInterval = 1.2f; private const float MinStepDistance = 0.25f; private const float StepLengthLearnRate = 0.4f; private const float MinStepLengthRatio = 0.4f; private const float MaxStepLengthRatio = 2.5f; private const float PhaseLock = 0.6f; private const float PhaseCorrectionSeconds = 0.15f; private const float MaxPhaseCorrectionRate = 0.35f; private const float JitterSpeed = 1.5f; private const float EaseInSeconds = 0.2f; private const float EaseOutSeconds = 0.4f; private const float SpeedSmoothingSeconds = 0.08f; private const float FullEffectSpeed = 10f; private const float SpeedCurve = 0.8f; private const float HighSpeedStart = 0.5f; private const float HighSpeedReduction = 0.25f; private const float GroundedSmoothingSeconds = 0.08f; private const float AngleSmoothingSeconds = 0.03f; private const float KickGain = 30f; private const float SideKickScale = 0.35f; private const float ForwardKickScale = 0.5f; private const float KickFrequency = 2.2f; private const float KickDamping = 0.35f; private const float MaxVelocityChange = 15f; private const float MaxKickDegrees = 25f; private const float CameraVelocitySmoothingSeconds = 0.03f; private const float TeleportSpeed = 60f; private const float CrouchKick = 2f; private const float CrouchKickPerSpeed = 0.4f; private const float AirFlutterScale = 0.3f; private const float AirFlutterFullSpeed = 12f; private const float InvisibleIntensity = 0.05f; private const float SeedPitch = 0.37f; private const float SeedYaw = 10.71f; private const float SeedRoll = 20.13f; private const float SeedIdlePitch = 30.29f; private const float SeedIdleYaw = 40.83f; private const float SeedIdleRoll = 50.47f; private const float SeedAir = 60.61f; private const float TwoPi = MathF.PI * 2f; private static int _frame = -1; private static float _lastUpdateTime; private static float _intensity; private static float _noiseTime; private static float _idleTime; private static float _idleBlend; private static float _speed; private static float _grounded; private static Quaternion _offset = Quaternion.identity; private static Vector3 _smoothedAngles; private static Vector3 _kick; private static Vector3 _kickSpeed; private static Vector3 _lastCameraPosition; private static Transform? _lastPlatform; private static Vector3 _cameraVelocity; private static bool _hasCameraPosition; private static bool _wasCrouching; private static float _stride; private static float _phaseCorrection; private static float _lastStepTime = -100f; private static bool _loggedFirstStep; private static float _stepLength; private static bool _hasStepLength; private static float _distanceSinceStep; private static float MovementValue => Mathf.Clamp01(BiasedFeatures.Settings.FlashlightMovementInstability.Value); private static float IdleValue => Mathf.Clamp01(BiasedFeatures.Settings.FlashlightIdleSway.Value); public static bool Enabled { get { if (!(MovementValue > 0f)) { return IdleValue > 0f; } return true; } } public static void OnFootstep(PlayerControllerB player) { if (!LagMath.IsLocalPlayer(player) || player.isClimbingLadder || player.inSpecialInteractAnimation) { return; } if (!_loggedFirstStep) { _loggedFirstStep = true; BiasedFeatures.Logger.LogDebug((object)"Flashlight instability: receiving footstep events."); } float time = Time.time; float num = time - _lastStepTime; if (!(num < 0.15f)) { _lastStepTime = time; float distanceSinceStep = _distanceSinceStep; _distanceSinceStep = 0f; float num2 = Mathf.Round(_stride * 2f) / 2f; float num3 = num2 - _stride; if (num < 1.2f) { LearnStepLength(distanceSinceStep); _phaseCorrection = 0.6f * num3; } else if (_intensity < 0.05f) { _stride = Mathf.Repeat(num2, 1f); _phaseCorrection = 0f; } else { _phaseCorrection = 0.6f * num3; } } } private static void LearnStepLength(float distance) { if (!(distance < 0.25f)) { if (!_hasStepLength) { _stepLength = distance; _hasStepLength = true; } else if (!(distance < _stepLength * 0.4f) && !(distance > _stepLength * 2.5f)) { _stepLength = Mathf.Lerp(_stepLength, distance, 0.4f); } } } public static Quaternion GetOffset(PlayerControllerB player) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_0380: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_040e: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_041a: Unknown result type (might be due to invalid IL or missing references) //IL_041c: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Unknown result type (might be due to invalid IL or missing references) //IL_042f: Unknown result type (might be due to invalid IL or missing references) //IL_0445: Unknown result type (might be due to invalid IL or missing references) //IL_044a: Unknown result type (might be due to invalid IL or missing references) //IL_044f: Unknown result type (might be due to invalid IL or missing references) //IL_0451: Unknown result type (might be due to invalid IL or missing references) //IL_0456: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Unknown result type (might be due to invalid IL or missing references) //IL_0470: Unknown result type (might be due to invalid IL or missing references) //IL_0476: Unknown result type (might be due to invalid IL or missing references) //IL_047b: Unknown result type (might be due to invalid IL or missing references) //IL_047d: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Unknown result type (might be due to invalid IL or missing references) //IL_0484: Unknown result type (might be due to invalid IL or missing references) //IL_0489: Unknown result type (might be due to invalid IL or missing references) //IL_048e: Unknown result type (might be due to invalid IL or missing references) //IL_0490: Unknown result type (might be due to invalid IL or missing references) //IL_0495: Unknown result type (might be due to invalid IL or missing references) //IL_049a: Unknown result type (might be due to invalid IL or missing references) //IL_049f: Unknown result type (might be due to invalid IL or missing references) if (_frame == Time.frameCount) { return _offset; } _frame = Time.frameCount; if (Time.unscaledTime - _lastUpdateTime > 0.25f) { _intensity = 0f; _idleBlend = 0f; _smoothedAngles = Vector3.zero; _speed = 0f; _distanceSinceStep = 0f; _kick = Vector3.zero; _kickSpeed = Vector3.zero; _cameraVelocity = Vector3.zero; _hasCameraPosition = false; _wasCrouching = player.isCrouching; } _lastUpdateTime = Time.unscaledTime; float num = Mathf.Min(Time.deltaTime, 0.1f); float movementValue = MovementValue; Transform transform = ((Component)player.gameplayCamera).transform; Vector3 val = (((Object)(object)player.thisController != (Object)null) ? player.thisController.velocity : Vector3.zero); Vector2 val2 = new Vector2(val.x, val.z); float magnitude = ((Vector2)(ref val2)).magnitude; _speed = Mathf.Lerp(_speed, magnitude, 1f - Mathf.Exp((0f - num) / 0.08f)); _distanceSinceStep += magnitude * num; bool flag = (Object)(object)player.thisController == (Object)null || player.thisController.isGrounded; _grounded = Mathf.Lerp(_grounded, flag ? 1f : 0f, 1f - Mathf.Exp((0f - num) / 0.08f)); UpdateKicks(player, transform, num, movementValue); float num2 = Mathf.Clamp01(_speed / 10f); float num3 = Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.5f, 1f, num2)); float num4 = movementValue * Mathf.Pow(num2, 0.8f) * (1f - 0.25f * num3); float num5 = ((num4 > _intensity) ? 0.2f : 0.4f); _intensity = Mathf.Lerp(_intensity, num4, 1f - Mathf.Exp((0f - num) / num5)); float num6 = (_hasStepLength ? _stepLength : (Mathf.Max(_speed, 0.1f) * 0.45f)); float num7 = _speed / (2f * num6); float num8 = _phaseCorrection * (1f - Mathf.Exp((0f - num) / 0.15f)); num8 = Mathf.Clamp(num8, -0.35f * num, 0.35f * num); _phaseCorrection -= num8; _stride = Mathf.Repeat(_stride + num7 * num + num8, 1f); _noiseTime += num * 1.5f; _idleTime += num; _idleBlend = Mathf.Lerp(_idleBlend, 1f, 1f - Mathf.Exp((0f - num) / 0.5f)); float num9 = _intensity * 20f * _grounded; float num10 = _stride * (MathF.PI * 2f); Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(0.5f * Mathf.Cos(num10 * 2f), 0.7f * Mathf.Cos(num10), 0.35f * Mathf.Cos(num10)); Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor(0.3f * Noise(_noiseTime, 0.37f), 0.3f * Noise(_noiseTime, 10.71f), 0.15f * Noise(_noiseTime, 20.13f)); Vector3 val5 = (val3 + val4) * num9; float num11 = movementValue * 20f * 0.3f * (1f - _grounded) * Mathf.Clamp01(Mathf.Abs(_cameraVelocity.y) / 12f); val5 += new Vector3(Noise(_noiseTime * 2f, 60.61f), Noise(_noiseTime * 2f, 68.31f), Noise(_noiseTime * 2f, 76.01f)) * num11; val5 += _kick; val5 += IdleAngles(_idleTime) * (IdleValue * 10f * _idleBlend); _smoothedAngles = Vector3.Lerp(_smoothedAngles, val5, 1f - Mathf.Exp((0f - num) / 0.03f)); Quaternion rotation = transform.rotation; _offset = rotation * Quaternion.Euler(_smoothedAngles) * Quaternion.Inverse(rotation); return _offset; } private static void UpdateKicks(PlayerControllerB player, Transform camera, float dt, float movement) { //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_0024: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_015d: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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) //IL_0081: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: 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_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020c: 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_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0227: 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_0231: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_00bc: 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_00c3: 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_00e8: 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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0118: 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_0126: 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_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) float gain = 30f * movement; float deltaTime = Time.deltaTime; Transform parent = ((Component)player).transform.parent; Vector3 val = (((Object)(object)parent != (Object)null) ? parent.InverseTransformPoint(camera.position) : camera.position); if ((Object)(object)parent != (Object)(object)_lastPlatform) { _lastPlatform = parent; _hasCameraPosition = false; _cameraVelocity = Vector3.zero; } if (_hasCameraPosition && deltaTime > 0.0001f) { Vector3 val2 = (val - _lastCameraPosition) / deltaTime; Vector3 val3 = (((Object)(object)parent != (Object)null) ? parent.TransformVector(val2) : val2); if (((Vector3)(ref val3)).magnitude > 60f) { _cameraVelocity = Vector3.zero; } else { Vector3 cameraVelocity = _cameraVelocity; _cameraVelocity = Vector3.Lerp(_cameraVelocity, val3, 1f - Mathf.Exp((0f - dt) / 0.03f)); Quaternion val4 = Quaternion.Euler(0f, camera.eulerAngles.y, 0f); Vector3 val5 = Quaternion.Inverse(val4) * (_cameraVelocity - cameraVelocity); val5 = Vector3.ClampMagnitude(val5, 15f); Kick(val5.y - val5.z * 0.5f, (0f - val5.x) * 0.35f, (0f - val5.x) * 0.35f, gain); } } _lastCameraPosition = val; _hasCameraPosition = true; if (player.isCrouching != _wasCrouching) { float num = 2f + _speed * 0.4f; Kick(player.isCrouching ? num : (0f - num), 0f, 0f, gain); _wasCrouching = player.isCrouching; } float num2 = 13.823009f; int num3 = Mathf.Max(1, Mathf.CeilToInt(dt / 0.016f)); float num4 = dt / (float)num3; for (int i = 0; i < num3; i++) { Vector3 val6 = (0f - num2) * num2 * _kick - 0.7f * num2 * _kickSpeed; _kickSpeed += val6 * num4; _kick += _kickSpeed * num4; } _kick = new Vector3(Mathf.Clamp(_kick.x, -25f, 25f), Mathf.Clamp(_kick.y, -25f, 25f), Mathf.Clamp(_kick.z, -25f, 25f)); } private static void Kick(float pitch, float yaw, float roll, float gain) { //IL_0000: 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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) _kickSpeed += new Vector3(pitch, yaw, roll) * gain; } private static Vector3 IdleAngles(float time) { //IL_0094: Unknown result type (might be due to invalid IL or missing references) float num = time * 0.35f; float num2 = Mathf.Sin(time * 0.22f * (MathF.PI * 2f)); float num3 = 0.6f * Noise(num, 30.29f) + 0.3f * Noise(num * 2.3f, 35.79f) + 0.25f * num2; float num4 = 0.7f * Noise(num, 40.83f) + 0.3f * Noise(num * 2.3f, 46.33f); float num5 = 0.3f * Noise(num * 0.8f, 50.47f); return new Vector3(num3, num4, num5); } private static float Noise(float time, float seed) { return (Mathf.PerlinNoise(time, seed) - 0.5f) * 2f; } } [HarmonyPatch(typeof(PlayerControllerB), "PlayFootstepLocal")] internal static class FootstepPatch { [HarmonyPostfix] private static void Postfix(PlayerControllerB __instance) { FlashlightInstability.OnFootstep(__instance); } } [HarmonyPatch(typeof(PlayerControllerB))] internal static class HeldFlashlightLagPatch { private const float ReleaseAngle = 0.1f; private static bool _active; private static int _lastStepFrame = -1; private static Quaternion _smoothed; private static Quaternion _pose; private static Transform? _holder; private static Quaternion _holderLocalRotation; [HarmonyPatch("Update")] [HarmonyPostfix] private static void UpdatePostfix(PlayerControllerB __instance) { Step(__instance); } [HarmonyPatch("LateUpdate")] [HarmonyPostfix] private static void LateUpdatePostfix(PlayerControllerB __instance) { Step(__instance); } private static void Step(PlayerControllerB player) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) if (!LagMath.IsLocalPlayer(player)) { return; } Transform playerModelArmsMetarig = player.playerModelArmsMetarig; Transform localArmsRotationTarget = player.localArmsRotationTarget; if ((Object)(object)playerModelArmsMetarig == (Object)null || (Object)(object)localArmsRotationTarget == (Object)null) { return; } float strength = LagMath.Strength; bool flag = (strength > 0f || FlashlightInstability.Enabled) && !player.inSpecialInteractAnimation && IsHoldingFlashlight(player); if (!flag && !_active) { return; } if (player.inSpecialInteractAnimation) { Deactivate(); return; } Quaternion rotation = localArmsRotationTarget.rotation; if (_lastStepFrame != Time.frameCount) { _lastStepFrame = Time.frameCount; if (!_active) { Activate(player, playerModelArmsMetarig); } float timeConstant = ((flag && strength > 0f) ? (strength * 0.5f) : (1f / 15f)); _smoothed = LagMath.Follow(_smoothed, rotation, timeConstant); if (!flag && Quaternion.Angle(_smoothed, rotation) < 0.1f) { Deactivate(); return; } _pose = (flag ? (FlashlightInstability.GetOffset(player) * _smoothed) : _smoothed); if (flag) { KeepBeamInFrame(player, rotation); } } playerModelArmsMetarig.rotation = _pose; if ((Object)(object)_holder != (Object)null) { _holder.localRotation = _holderLocalRotation; _holder.rotation = _pose * Quaternion.Inverse(rotation) * _holder.rotation; } } private static void KeepBeamInFrame(PlayerControllerB player, Quaternion target) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) Camera gameplayCamera = player.gameplayCamera; if ((Object)(object)gameplayCamera == (Object)null) { return; } GrabbableObject currentlyHeldObjectServer = player.currentlyHeldObjectServer; FlashlightItem val = (FlashlightItem)(object)((currentlyHeldObjectServer is FlashlightItem) ? currentlyHeldObjectServer : null); if (val != null) { Quaternion val2 = _pose * Quaternion.Inverse(target); float num = BeamFrameLimiter.FindSafeScale(gameplayCamera, val2, ((Component)gameplayCamera).transform.forward, BeamFrameLimiter.SpotAngleOf(val.flashlightBulb)); if (!(num >= 1f)) { _pose = Quaternion.Slerp(Quaternion.identity, val2, num) * target; _smoothed = Quaternion.Slerp(target, _smoothed, num); } } } private static bool IsHoldingFlashlight(PlayerControllerB player) { GrabbableObject currentlyHeldObjectServer = player.currentlyHeldObjectServer; if (currentlyHeldObjectServer is FlashlightItem && currentlyHeldObjectServer.isHeld) { return !currentlyHeldObjectServer.isPocketed; } return false; } private static void Activate(PlayerControllerB player, Transform arms) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) _active = true; _smoothed = arms.rotation; Transform localItemHolder = player.localItemHolder; bool flag = (Object)(object)localItemHolder != (Object)null && localItemHolder.IsChildOf(arms); if (!flag && (Object)(object)localItemHolder != (Object)null) { _holder = localItemHolder; _holderLocalRotation = localItemHolder.localRotation; } BiasedFeatures.Logger.LogDebug((object)(flag ? "Flashlight hand lag: item holder is under the arms rig, rotating the arms." : "Flashlight hand lag: item holder is NOT under the arms rig, rotating the holder directly.")); } private static void Deactivate() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_holder != (Object)null) { _holder.localRotation = _holderLocalRotation; } _holder = null; _active = false; } } internal static class HolsteredFlashlightLag { private static GameObject? _runner; private static bool _active; private static bool _loggedFirstTick; private static bool? _lastHelmetLightEnabled; private static Transform? _lightTransform; private static Vector3 _localPosition; private static Quaternion _localRotation; private static Quaternion _smoothed; public static void Enable() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown if (!((Object)(object)_runner != (Object)null)) { _runner = new GameObject("BiasedFeatures.HolsteredFlashlightLag") { hideFlags = (HideFlags)61 }; Object.DontDestroyOnLoad((Object)(object)_runner); _runner.AddComponent<HolsteredFlashlightLagRunner>(); BiasedFeatures.Logger.LogDebug((object)"Holstered flashlight lag: runner created."); } } public static void Disable() { if ((Object)(object)_runner != (Object)null) { Object.Destroy((Object)(object)_runner); } _runner = null; Restore(); } internal static void Tick() { //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: 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_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0270: 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_0283: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024c: 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_0253: 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_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) GameNetworkManager instance = GameNetworkManager.Instance; PlayerControllerB val = (((Object)(object)instance == (Object)null) ? null : instance.localPlayerController); if ((Object)(object)val == (Object)null || val.isPlayerDead) { if (_active) { Restore(); } return; } if (!_loggedFirstTick) { _loggedFirstTick = true; BiasedFeatures.Logger.LogDebug((object)"Holstered flashlight lag: running, local player found."); } Light helmetLight = val.helmetLight; float strength = LagMath.Strength; bool flag = (Object)(object)helmetLight != (Object)null && ((Behaviour)helmetLight).enabled; bool flag2 = (strength > 0f || FlashlightInstability.Enabled || BeamAim.Enabled) && flag; if (_lastHelmetLightEnabled != flag) { _lastHelmetLightEnabled = flag; BiasedFeatures.Logger.LogDebug((object)string.Format("Helmet light enabled={0}, delay strength={1}, light={2}", flag, strength, ((Object)(object)helmetLight == (Object)null) ? "none" : ((Object)helmetLight).name)); } if (_active && (!flag2 || (Object)(object)((Component)helmetLight).transform != (Object)(object)_lightTransform)) { Restore(); } if (!flag2) { return; } Transform transform = ((Component)helmetLight).transform; if (!_active) { _active = true; _lightTransform = transform; _localPosition = transform.localPosition; _localRotation = transform.localRotation; _smoothed = transform.rotation; BiasedFeatures.Logger.LogDebug((object)("Holstered flashlight lag started. Helmet light: " + PathOf(transform))); return; } transform.localPosition = _localPosition; transform.localRotation = _localRotation; Quaternion rotation = transform.rotation; _smoothed = LagMath.Follow(_smoothed, rotation, strength * 0.5f); Camera gameplayCamera = val.gameplayCamera; Quaternion val2 = Quaternion.identity; Vector3 slide = Vector3.zero; if ((Object)(object)gameplayCamera != (Object)null && BeamAim.Enabled) { val2 = BeamAim.Correction(gameplayCamera, transform.position, rotation, out slide); } Quaternion val3 = val2 * FlashlightInstability.GetOffset(val) * _smoothed; if ((Object)(object)gameplayCamera != (Object)null) { Quaternion val4 = val3 * Quaternion.Inverse(rotation); float num = BeamFrameLimiter.FindSafeScale(gameplayCamera, val4, rotation * Vector3.forward, BeamFrameLimiter.SpotAngleOf(helmetLight)); if (num < 1f) { val3 = Quaternion.Slerp(Quaternion.identity, val4, num) * rotation; _smoothed = Quaternion.Slerp(rotation, _smoothed, num); } } transform.position += slide; transform.rotation = val3; } private static void Restore() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_lightTransform != (Object)null) { _lightTransform.localPosition = _localPosition; _lightTransform.localRotation = _localRotation; } _lightTransform = null; _active = false; } private static string PathOf(Transform transform) { StringBuilder stringBuilder = new StringBuilder(((Object)transform).name); Transform parent = transform.parent; while ((Object)(object)parent != (Object)null) { stringBuilder.Insert(0, ((Object)parent).name + "/"); parent = parent.parent; } return stringBuilder.ToString(); } } [DefaultExecutionOrder(10000)] internal sealed class HolsteredFlashlightLagRunner : MonoBehaviour { private void LateUpdate() { HolsteredFlashlightLag.Tick(); } } internal static class LagMath { public const float MaxLagSeconds = 0.5f; public const float VanillaArmFollowRate = 15f; public static float Strength => Mathf.Clamp01(BiasedFeatures.Settings.FlashlightDelayStrength.Value); public static Quaternion Follow(Quaternion current, Quaternion target, float timeConstant) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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) if (timeConstant <= 0f) { return target; } float num = 1f - Mathf.Exp((0f - Time.deltaTime) / timeConstant); return Quaternion.Slerp(current, target, num); } public static bool IsLocalPlayer(PlayerControllerB player) { GameNetworkManager instance = GameNetworkManager.Instance; if ((Object)(object)player != (Object)null && (Object)(object)instance != (Object)null && (Object)(object)player == (Object)(object)instance.localPlayerController) { return !player.isPlayerDead; } return false; } } }