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.1
bobabulkerENTERPRISE.BiasedFeatures.dll
Decompiled 18 hours agousing System; using System.Collections.Generic; 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.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using BiasedFeatures.FlashlightTweaks; using CSync.Extensions; using CSync.Lib; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.UI; [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.1.0")] [assembly: AssemblyInformationalVersion("1.0.1+7666b71e14168d4614815999b4f5cd652e5625d2")] [assembly: AssemblyProduct("BiasedFeatures")] [assembly: AssemblyTitle("bobabulkerENTERPRISE.BiasedFeatures")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.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; [SyncedEntryField] public SyncedEntry<bool> ExtraEnergyBars; [SyncedEntryField] public SyncedEntry<string> InfiniteBatteryItems; [SyncedEntryField] public SyncedEntry<bool> LockableDoorsEnabled; [SyncedEntryField] public SyncedEntry<bool> NocturnalEnabled; public BiasedConfig(ConfigFile cfg) : base("bobabulkerENTERPRISE.BiasedFeatures") { BindFlashlightTweaks(cfg); BindNocturnal(cfg); BindFlipModsTweaks(cfg); BindInfiniteBattery(cfg); BindLockableDoors(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>())); } private void BindNocturnal(ConfigFile cfg) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown NocturnalEnabled = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "Nocturnal", "Enabled", true, new ConfigDescription("If true, the ship does not leave by itself when the clock reaches midnight and the round carries on. The ship still leaves when everyone is dead, or when the dead players' vote to leave passes (even at midnight), and dead players can vote at any time of day. Only the host can change this; clients receive the host's value.", (AcceptableValueBase)null, Array.Empty<object>())); } private void BindFlipModsTweaks(ConfigFile cfg) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown ExtraEnergyBars = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "FlipMods Tweaks", "ExtraEnergyBars", true, new ConfigDescription("If true, HotbarPlus's energy bars are also shown for items that don't run on a battery: the spray paint and weed killer (paint left), the TZP-Inhalant (gas left) and the shotgun (empty, half or full for 0, 1 or 2 shells). Bars stay hidden where HotbarPlus's DisableEnergyBars is on, or in the reserved item slots when ReservedItemSlotCore's DisableHotbarPlusEnergyBars is on. Needs HotbarPlus; does nothing without it. Only the host can change this; clients receive the host's value.", (AcceptableValueBase)null, Array.Empty<object>())); } private void BindInfiniteBattery(ConfigFile cfg) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown InfiniteBatteryItems = SyncedBindingExtensions.BindSyncedEntry<string>(cfg, "Infinite Battery", "Items", "Flashlight, Boombox", new ConfigDescription("Comma-separated list of item names that never run out of battery, written exactly as the game registers them, for example: Flashlight, Pro-flashlight. Modded items work too. An item that does not need a battery to be used (including one another mod has already made infinite) is unaffected. Names are case sensitive. Only the host can change this; clients receive the host's list.", (AcceptableValueBase)null, Array.Empty<object>())); } private void BindLockableDoors(ConfigFile cfg) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown LockableDoorsEnabled = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "Lockable Doors", "Enabled", true, new ConfigDescription("If true, anyone holding a key can lock a closed door by using the key on it. Locked doors work like the doors the game locks itself: a key unlocks them (and is used up, as usual), and the lockpick picks them as usual. Only the host can change this; clients receive the host's value.", (AcceptableValueBase)null, Array.Empty<object>())); } } [BepInPlugin("bobabulkerENTERPRISE.BiasedFeatures", "BiasedFeatures", "1.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [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.1 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.1"; } } namespace BiasedFeatures.Nocturnal { [HarmonyPatch(typeof(HUDManager))] internal static class NocturnalClockPatches { private const int MinutesAtMidnight = 1440; private static int ClockMinutes(float timeNormalized, float numberOfHours) { return (int)(timeNormalized * (60f * numberOfHours)) + 360; } private static string AfterMidnight(int minutes, bool createNewLine) { int num = minutes / 60 - 24; if (num == 0) { num = 12; } else if (num > 12) { num %= 12; } return $"{num:00}:{minutes % 60:00}".TrimStart('0') + (createNewLine ? "\n" : " ") + "AM"; } [HarmonyPatch("SetClock")] [HarmonyPrefix] private static void SetClockPrefix(ref float timeNormalized) { if (NocturnalMode.InOvertime && NocturnalMode.Overtime > 0f) { timeNormalized += NocturnalMode.Overtime; } } [HarmonyPatch("SetClock")] [HarmonyPostfix] private static void SetClockPostfix(HUDManager __instance, float timeNormalized, float numberOfHours, bool createNewLine) { if (NocturnalMode.InOvertime && !(NocturnalMode.Overtime <= 0f)) { int num = ClockMinutes(timeNormalized, numberOfHours); if (num >= 1440) { ((TMP_Text)__instance.clockNumber).text = AfterMidnight(num, createNewLine); } } } [HarmonyPatch("GetClockTimeFormatted")] [HarmonyPrefix] private static bool FormatPrefix(float timeNormalized, float numberOfHours, bool createNewLine, ref string __result) { if (!NocturnalMode.Enabled) { return true; } int num = ClockMinutes(timeNormalized, numberOfHours); if (num <= 1440) { return true; } __result = AfterMidnight(num, createNewLine); return false; } } internal static class NocturnalMode { public const float MidnightLeaveTime = 0.998f; public const float EndOfDay = 1f; public static bool VotePassed; public static float OvertimeLeaveAt; public static float Overtime; public static bool DepartureReleased; private static readonly FieldRef<TimeOfDay, bool> ShipLeavingOnMidnight = AccessTools.FieldRefAccess<TimeOfDay, bool>("shipLeavingOnMidnight"); public static bool Enabled => BiasedFeatures.Settings.NocturnalEnabled.Value; public static bool InOvertime { get { if (Enabled) { return OvertimeLeaveAt > 1f; } return false; } } public static float MaxOvertime => Mathf.Max(0f, OvertimeLeaveAt - 1f); public static void AllowAnotherDeparture(TimeOfDay timeOfDay) { ShipLeavingOnMidnight.Invoke(timeOfDay) = false; } public static void ResetRound() { VotePassed = false; OvertimeLeaveAt = 0f; Overtime = 0f; DepartureReleased = false; } } [HarmonyPatch(typeof(TimeOfDay))] internal static class NocturnalTimeOfDayPatches { [HarmonyPatch("SetShipToLeaveOnMidnightClientRpc")] [HarmonyPrefix] private static bool SkipMidnightDeparture(TimeOfDay __instance) { if (!NocturnalMode.Enabled || NocturnalMode.VotePassed || !((NetworkBehaviour)__instance).IsServer) { return true; } BiasedFeatures.Logger.LogDebug((object)"Nocturnal: midnight reached, not sending the ship away."); return false; } [HarmonyPatch("SetShipLeaveEarlyClientRpc")] [HarmonyPrefix] private static void VotePassedPrefix(TimeOfDay __instance, float timeToLeaveEarly) { if (NocturnalMode.Enabled) { NocturnalMode.VotePassed = true; NocturnalMode.DepartureReleased = false; NocturnalMode.OvertimeLeaveAt = ((timeToLeaveEarly > 0.998f) ? Mathf.Max(timeToLeaveEarly, 1f) : 0f); if (((NetworkBehaviour)__instance).IsServer) { NocturnalMode.AllowAnotherDeparture(__instance); } BiasedFeatures.Logger.LogDebug((object)($"Nocturnal: leave vote passed, the ship leaves at {timeToLeaveEarly:F3} of the day" + ((NocturnalMode.OvertimeLeaveAt > 0f) ? " (after midnight)." : "."))); } } [HarmonyPatch("TimeOfDayEvents")] [HarmonyPostfix] private static void OvertimePostfix(TimeOfDay __instance) { if (NocturnalMode.InOvertime && !(__instance.globalTime < __instance.globalTimeAtEndOfDay - 0.001f) && !(__instance.totalTime <= 0f)) { float num = (((Object)(object)__instance.currentLevel != (Object)null) ? __instance.currentLevel.DaySpeedMultiplier : 1f); float num2 = __instance.globalTimeSpeedMultiplier * num / __instance.totalTime; NocturnalMode.Overtime = Mathf.Min(NocturnalMode.Overtime + Time.deltaTime * num2, NocturnalMode.MaxOvertime); if (((NetworkBehaviour)__instance).IsServer && !NocturnalMode.DepartureReleased && NocturnalMode.Overtime >= NocturnalMode.MaxOvertime - 1E-05f) { NocturnalMode.DepartureReleased = true; __instance.shipLeaveAutomaticallyTime = 0.998f; NocturnalMode.AllowAnotherDeparture(__instance); BiasedFeatures.Logger.LogDebug((object)"Nocturnal: the extra time after midnight is up, the ship leaves."); } } } } [HarmonyPatch(typeof(HUDManager), "Update")] internal static class NocturnalSpectatorVotePatch { [HarmonyPrefix] private static void Prefix(out bool __state) { TimeOfDay instance = TimeOfDay.Instance; __state = (Object)(object)instance != (Object)null && instance.shipLeavingAlertCalled; if (__state && NocturnalMode.Enabled && !NocturnalMode.VotePassed) { instance.shipLeavingAlertCalled = false; } } [HarmonyFinalizer] private static void Finalizer(bool __state) { TimeOfDay instance = TimeOfDay.Instance; if (__state && (Object)(object)instance != (Object)null) { instance.shipLeavingAlertCalled = true; } } } [HarmonyPatch(typeof(HUDManager), "ReadDialogue")] internal static class NocturnalLeavingSoonWarningPatch { [HarmonyPrefix] private static bool Prefix(DialogueSegment[] dialogueArray) { TimeOfDay instance = TimeOfDay.Instance; if (NocturnalMode.Enabled && (Object)(object)instance != (Object)null) { return dialogueArray != instance.shipLeavingSoonDialogue; } return true; } } [HarmonyPatch(typeof(StartOfRound), "ShipHasLeft")] internal static class NocturnalRoundEndPatch { [HarmonyPostfix] private static void Postfix() { NocturnalMode.ResetRound(); } } } namespace BiasedFeatures.LockableDoors { internal static class LockableDoorsState { [CompilerGenerated] private static class <>O { public static HandleNamedMessageDelegate <0>__OnLockRequest; public static HandleNamedMessageDelegate <1>__OnLock; } public const string LockRequestMessage = "BiasedFeatures.LockableDoors.LockRequest"; public const string LockMessage = "BiasedFeatures.LockableDoors.Lock"; public static bool Enabled => BiasedFeatures.Settings.LockableDoorsEnabled.Value; public static DoorLock? Resolve(ulong networkObjectId) { NetworkSpawnManager val = (((Object)(object)NetworkManager.Singleton != (Object)null) ? NetworkManager.Singleton.SpawnManager : null); if (val == null || !val.SpawnedObjects.TryGetValue(networkObjectId, out var value) || (Object)(object)value == (Object)null) { return null; } return ((Component)value).GetComponentInChildren<DoorLock>(); } public static bool CanLock(DoorLock? door) { if ((Object)(object)door == (Object)null || door.isLocked || door.isPickingLock || !door.canBeLocked) { return false; } AnimatedObjectTrigger component = ((Component)door).GetComponent<AnimatedObjectTrigger>(); if ((Object)(object)component != (Object)null) { return !component.boolValue; } return false; } public unsafe static bool RequestLock(ulong networkObjectId) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening) { return false; } if (singleton.IsServer) { return HostLock(networkObjectId); } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(8, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives)); singleton.CustomMessagingManager.SendNamedMessage("BiasedFeatures.LockableDoors.LockRequest", 0uL, val, (NetworkDelivery)3); return true; } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } private static void LockWithSound(DoorLock door) { door.LockDoor(30f); if ((Object)(object)door.doorLockSFX != (Object)null && (Object)(object)door.unlockSFX != (Object)null) { door.doorLockSFX.Stop(); door.doorLockSFX.PlayOneShot(door.unlockSFX); } } private unsafe static bool HostLock(ulong networkObjectId) { //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_0065: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; DoorLock val = Resolve(networkObjectId); if ((Object)(object)singleton == (Object)null || !singleton.IsServer || !Enabled || (Object)(object)val == (Object)null || !CanLock(val)) { return false; } LockWithSound(val); FastBufferWriter val2 = default(FastBufferWriter); ((FastBufferWriter)(ref val2))..ctor(8, (Allocator)2, -1); try { ((FastBufferWriter)(ref val2)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives)); singleton.CustomMessagingManager.SendNamedMessageToAll("BiasedFeatures.LockableDoors.Lock", val2, (NetworkDelivery)3); return true; } finally { ((IDisposable)(*(FastBufferWriter*)(&val2))/*cast due to .constrained prefix*/).Dispose(); } } private static void OnLockRequest(ulong senderClientId, FastBufferReader reader) { //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) ulong networkObjectId = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref networkObjectId, default(ForPrimitives)); HostLock(networkObjectId); } private static void OnLock(ulong senderClientId, FastBufferReader reader) { //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) ulong networkObjectId = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref networkObjectId, default(ForPrimitives)); DoorLock val = Resolve(networkObjectId); if ((Object)(object)val != (Object)null && !val.isLocked) { LockWithSound(val); } } public static void Register() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //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_0066: Expected O, but got Unknown CustomMessagingManager val = (((Object)(object)NetworkManager.Singleton != (Object)null) ? NetworkManager.Singleton.CustomMessagingManager : null); if (val != null) { object obj = <>O.<0>__OnLockRequest; if (obj == null) { HandleNamedMessageDelegate val2 = OnLockRequest; <>O.<0>__OnLockRequest = val2; obj = (object)val2; } val.RegisterNamedMessageHandler("BiasedFeatures.LockableDoors.LockRequest", (HandleNamedMessageDelegate)obj); object obj2 = <>O.<1>__OnLock; if (obj2 == null) { HandleNamedMessageDelegate val3 = OnLock; <>O.<1>__OnLock = val3; obj2 = (object)val3; } val.RegisterNamedMessageHandler("BiasedFeatures.LockableDoors.Lock", (HandleNamedMessageDelegate)obj2); } } } [HarmonyPatch] internal static class LockableDoorsPatches { [HarmonyPatch(typeof(StartOfRound), "Start")] [HarmonyPostfix] private static void OnLobbyStart() { LockableDoorsState.Register(); } } [HarmonyPatch(typeof(KeyItem), "ItemActivate")] internal static class KeyLocksDoors { private static DoorLock? FindDoor(KeyItem key) { //IL_001b: 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) PlayerControllerB playerHeldBy = ((GrabbableObject)key).playerHeldBy; RaycastHit val = default(RaycastHit); if ((Object)(object)playerHeldBy == (Object)null || !Physics.Raycast(new Ray(((Component)playerHeldBy.gameplayCamera).transform.position, ((Component)playerHeldBy.gameplayCamera).transform.forward), ref val, 3f, 2816)) { return null; } DoorLock val2 = ((Component)((RaycastHit)(ref val)).transform).GetComponent<DoorLock>(); if ((Object)(object)val2 == (Object)null) { TriggerPointToDoor component = ((Component)((RaycastHit)(ref val)).transform).GetComponent<TriggerPointToDoor>(); if ((Object)(object)component != (Object)null) { val2 = component.pointToDoor; } } return val2; } [HarmonyPrefix] private static void Before(KeyItem __instance, out DoorLock? __state) { __state = null; if (LockableDoorsState.Enabled && ((NetworkBehaviour)__instance).IsOwner) { DoorLock val = FindDoor(__instance); if ((Object)(object)val != (Object)null && !val.isLocked) { __state = val; } } } [HarmonyPostfix] private static void After(KeyItem __instance, bool buttonDown, DoorLock? __state) { if (!((Object)(object)__state == (Object)null) && buttonDown && LockableDoorsState.CanLock(__state)) { PlayerControllerB playerHeldBy = ((GrabbableObject)__instance).playerHeldBy; if ((Object)(object)playerHeldBy != (Object)null && LockableDoorsState.RequestLock(((NetworkBehaviour)__state).NetworkObjectId)) { playerHeldBy.DespawnHeldObject(); } } } } } namespace BiasedFeatures.InfiniteBattery { [HarmonyPatch] internal static class InfiniteBatteryItems { private static readonly char[] Separator = new char[1] { ',' }; private static string? _builtFrom; private static HashSet<string> _names = new HashSet<string>(StringComparer.Ordinal); private static HashSet<string> Names() { string text = BiasedFeatures.Settings.InfiniteBatteryItems.Value ?? ""; if (text == _builtFrom) { return _names; } HashSet<string> hashSet = new HashSet<string>(StringComparer.Ordinal); string[] array = text.Split(Separator, StringSplitOptions.RemoveEmptyEntries); foreach (string text2 in array) { string text3 = text2.Trim(); if (text3.Length > 0) { hashSet.Add(text3); } } _names = hashSet; _builtFrom = text; return hashSet; } [HarmonyPatch(typeof(GrabbableObject), "Update")] [HarmonyPostfix] private static void KeepCharged(GrabbableObject __instance) { Battery insertedBattery = __instance.insertedBattery; if (insertedBattery != null && (!(insertedBattery.charge >= 1f) || insertedBattery.empty)) { Item itemProperties = __instance.itemProperties; if (!((Object)(object)itemProperties == (Object)null) && itemProperties.requiresBattery && itemProperties.itemName != null && Names().Contains(itemProperties.itemName.Trim())) { insertedBattery.charge = 1f; insertedBattery.empty = false; } } } } } namespace BiasedFeatures.FlipModsTweaks { [HarmonyPatch] internal static class ExtraEnergyBars { private const string HotbarPlusGuid = "FlipMods.HotbarPlus"; private const string ReservedItemSlotCoreGuid = "FlipMods.ReservedItemSlotCore"; private static bool _resolved; private static bool _loggedError; private static ConfigEntry<bool>? _hotbarPlusDisabled; private static ConfigEntry<bool>? _reservedBarsDisabled; private static readonly FieldRef<SprayPaintItem, float> SprayTank = AccessTools.FieldRefAccess<SprayPaintItem, float>("sprayCanTank"); private static readonly FieldRef<TetraChemicalItem, float> InhalerFuel = AccessTools.FieldRefAccess<TetraChemicalItem, float>("fuel"); private static bool TryGetFill(GrabbableObject item, out float fill) { fill = 0f; if (item.itemProperties.requiresBattery && item.insertedBattery != null) { return false; } SprayPaintItem val = (SprayPaintItem)(object)((item is SprayPaintItem) ? item : null); if (val == null) { TetraChemicalItem val2 = (TetraChemicalItem)(object)((item is TetraChemicalItem) ? item : null); if (val2 == null) { ShotgunItem val3 = (ShotgunItem)(object)((item is ShotgunItem) ? item : null); if (val3 != null) { fill = (float)Mathf.Clamp(val3.shellsLoaded, 0, 2) / 2f; return true; } return false; } fill = Mathf.Clamp01(InhalerFuel.Invoke(val2)); return true; } fill = Mathf.Clamp01(SprayTank.Invoke(val)); return true; } private static void Resolve() { _resolved = true; ConfigEntry<bool> hotbarPlusDisabled = default(ConfigEntry<bool>); if (Chainloader.PluginInfos.TryGetValue("FlipMods.HotbarPlus", out var value) && (Object)(object)value.Instance != (Object)null && value.Instance.Config.TryGetEntry<bool>("UI", "DisableEnergyBars", ref hotbarPlusDisabled)) { _hotbarPlusDisabled = hotbarPlusDisabled; } ConfigEntry<bool> reservedBarsDisabled = default(ConfigEntry<bool>); if (Chainloader.PluginInfos.TryGetValue("FlipMods.ReservedItemSlotCore", out var value2) && (Object)(object)value2.Instance != (Object)null && value2.Instance.Config.TryGetEntry<bool>("Compatibility", "DisableHotbarPlusEnergyBars", ref reservedBarsDisabled)) { _reservedBarsDisabled = reservedBarsDisabled; } BiasedFeatures.Logger.LogDebug((object)("Extra energy bars: HotbarPlus " + ((_hotbarPlusDisabled != null) ? "found" : "not found") + ", ReservedItemSlotCore setting " + ((_reservedBarsDisabled != null) ? "found" : "not found") + ".")); } [HarmonyPatch(typeof(HUDManager), "Update")] [HarmonyPostfix] [HarmonyPriority(0)] private static void ShowBars(HUDManager __instance) { try { ShowBarsInner(__instance); } catch (Exception arg) { if (!_loggedError) { _loggedError = true; BiasedFeatures.Logger.LogError((object)$"Extra energy bars failed (only logged once): {arg}"); } } } private static void ShowBarsInner(HUDManager hud) { if (!BiasedFeatures.Settings.ExtraEnergyBars.Value) { return; } PlayerControllerB val = (((Object)(object)StartOfRound.Instance != (Object)null) ? StartOfRound.Instance.localPlayerController : null); Image[] itemSlotIconFrames = hud.itemSlotIconFrames; if ((Object)(object)val == (Object)null || val.isPlayerDead || itemSlotIconFrames == null || val.ItemSlots == null) { return; } if (!_resolved) { Resolve(); } ConfigEntry<bool> hotbarPlusDisabled = _hotbarPlusDisabled; if (hotbarPlusDisabled != null && hotbarPlusDisabled.Value) { return; } bool flag = _reservedBarsDisabled?.Value ?? false; for (int i = 0; i < itemSlotIconFrames.Length && i < val.ItemSlots.Length; i++) { Image val2 = itemSlotIconFrames[i]; GrabbableObject val3 = val.ItemSlots[i]; if ((Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null || !TryGetFill(val3, out var fill) || (flag && ((Object)val2).name.ToLower().Contains("reserved"))) { continue; } Transform val4 = ((Component)val2).transform.Find("EnergyBar"); if (!((Object)(object)val4 == (Object)null)) { if (!((Component)val4).gameObject.activeSelf) { ((Component)val4).gameObject.SetActive(true); } Slider componentInChildren = ((Component)val4).GetComponentInChildren<Slider>(true); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.value = fill; } } } } } } 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; } } }