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 Camera Overhaul v1.0.0
BepInEx/plugins/CameraOverhaul/CameraOverhaul.dll
Decompiled 6 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalConfig; using LethalConfig.ConfigItems; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("ClientNetworkTransform")] [assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")] [assembly: IgnoresAccessChecksTo("DissonanceVoip")] [assembly: IgnoresAccessChecksTo("DunGen")] [assembly: IgnoresAccessChecksTo("DunGen.Integration.ASPP")] [assembly: IgnoresAccessChecksTo("DunGen.Integration.UnityNav")] [assembly: IgnoresAccessChecksTo("EasyTextEffects")] [assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Jobs")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")] [assembly: IgnoresAccessChecksTo("Unity.Services.QoS")] [assembly: IgnoresAccessChecksTo("Unity.Services.Relay")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.XR.CoreUtils")] [assembly: IgnoresAccessChecksTo("Unity.XR.Management")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.ConformanceAutomation")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MetaQuestSupport")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MockRuntime")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.OculusQuestSupport")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.RuntimeDebugger")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.SpatialTracking")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("UnityEngine.XR.LegacyInputHelpers")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("CameraOverhaul")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("More satisfying movement through dynamic camera rotations.")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+d61077992626cbceea323d3eae3fcff35298451a")] [assembly: AssemblyProduct("CameraOverhaul")] [assembly: AssemblyTitle("CameraOverhaul")] [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 CameraOverhaul { internal struct CameraContext { public bool isSprinting; public bool isCrouching; public bool inVehicle; public bool isClimbing; public bool isExhausted; public bool isInspectingItem; public bool criticallyInjured; public bool isUsingJetpack; public bool isBeingShocked; public float sprintMeter; public float drunkness; public float insanity; public float poison; public float sinkingValue; public float shipTakeoffPhase; public float shipLandingPhase; public bool inWater; public bool submerged; public Vector3 velocity; public Vector3 forwardRelVelocity; public double pitch; public double yaw; public bool resetSmoothing; } internal sealed class CameraSystem { private const NoiseKind SwayNoise = NoiseKind.Fractal; private const NoiseKind ExhaustionNoise = NoiseKind.Fractal; private const NoiseKind InsanityNoise = NoiseKind.Fractal; private const NoiseKind DrunknessNoise = NoiseKind.OpenSimplex2; private const NoiseKind TinnitusNoise = NoiseKind.Simplex; private const NoiseKind CriticalNoise = NoiseKind.Fractal; private const NoiseKind PoisonNoise = NoiseKind.Simplex; private const NoiseKind JetpackNoise = NoiseKind.Fractal; private const NoiseKind ShockNoise = NoiseKind.FrequencyMod; private const NoiseKind ShipNoise = NoiseKind.Fractal; private const NoiseKind WaterWadeNoise = NoiseKind.Fractal; private const NoiseKind WaterDriftNoise = NoiseKind.OpenSimplex2; private Vector3 _offsetEuler; private Vector3 _impairOffset; private Vector3 _smoothing; private float _master = 1f; private float _masterBase = 1f; private ConfigData.Contextual? _ctxCfg; private double _prevPitch; private double _prevYaw; private double _lastActionTime; private double _prevVerticalPitch; private double _prevForwardPitch; private double _turningRollTarget; private double _prevStrafingRoll; private double _swayFactor; private double _swayFactorTarget; private double _swayTime; private double _exhaustionTime; private double _insanityTime; private double _drunkTime; private double _criticalTime; private double _poisonTime; private double _jetpackTime; private double _shockTime; private double _shipTime; private double _waterTime; private double _exhaustionSeverity; private double _criticalSeverity; private double _jetpackSeverity; private double _shockSeverity; private double _drunkSeverity; private double _drunkRoll; private double _drunkPitch; private double _drunkYaw; private double _waterWadeSeverity; private double _waterSubmergeSeverity; private Vector3 _punch; private Vector3 _punchVel; private bool _msInit; private double _prevYawNorm; private double _prevPitchNorm; private double _contYaw; private double _contPitch; private double _smYaw; private double _smPitch; private const double PunchImpulseScale = 15.0; private const double RecoilImpulseScale = 35.0; private const double ACTION_VELOCITY_EPS_SQ = 0.0004; private const double ACTION_LOOK_EPS = 0.05; private const float PunchStiffness = 220f; private const float PunchDamping = 22f; private const float MaxPunch = 60f; private const double BASE_VERTICAL_PITCH_SMOOTHING = 4E-05; private const double VERTICAL_PITCH_THRESHOLD = 0.4; private const double BASE_FORWARD_PITCH_SMOOTHING = 0.008; private const double BASE_TURNING_ROLL_ACCUMULATION = 0.0048; private const double BASE_TURNING_ROLL_INTENSITY = 1.25; private const double BASE_TURNING_ROLL_SMOOTHING = 0.0825; private const double BASE_STRAFING_ROLL_SMOOTHING = 0.008; private const double BASE_SWAY_SPEED = 0.5; private const double INSANITY_THRESHOLD = 0.7; private const double DRUNK_SEVERITY_SMOOTHING = 0.06; private const double DRUNK_OFFSET_SMOOTHING = 0.025; private const double DRUNK_BASE_ROLL_DEG = 6.5; private const double DRUNK_BASE_PITCH_DEG = 3.0; private const double DRUNK_BASE_YAW_DEG = 2.2; private const double DRUNK_INTENSITY_NORMALIZER = 6.0; private const double DRUNK_NOISE_SPEED_MIN = 0.18; private const double DRUNK_NOISE_SPEED_MAX = 0.42; private const double WATER_WADE_SMOOTHING = 0.06; private const double WATER_SUBMERGE_SMOOTHING = 0.05; private const double WATER_WADE_SPEED = 0.9; private const double WATER_DRIFT_SPEED = 0.4; private const double SHIP_SHAKE_DEG = 0.85; private const double SHIP_RUMBLE_SPEED = 9.0; private const double SHIP_FORWARD_LURCH = 1.2; private const double SHIP_RISE_PITCH = 0.8; private const double BASE_MOUSE_SMOOTHING = 16.0; private const double MOUSE_SMOOTHING_THRESHOLD = 0.001; private static double Now => Time.timeAsDouble; public Vector3 OffsetEuler => _offsetEuler * _master + _impairOffset * _masterBase + _smoothing + ScreenShakes.EulerOffset; public void Reset() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) _offsetEuler = Vector3.zero; _impairOffset = Vector3.zero; _smoothing = Vector3.zero; _ctxCfg = null; _prevPitch = 0.0; _prevYaw = 0.0; _lastActionTime = 0.0; _prevVerticalPitch = 0.0; _prevForwardPitch = 0.0; _turningRollTarget = 0.0; _prevStrafingRoll = 0.0; _swayFactor = 0.0; _swayFactorTarget = 0.0; _swayTime = 0.0; _exhaustionTime = 0.0; _insanityTime = 0.0; _drunkTime = 0.0; _criticalTime = 0.0; _poisonTime = 0.0; _jetpackTime = 0.0; _shockTime = 0.0; _shipTime = 0.0; _waterTime = 0.0; _exhaustionSeverity = 0.0; _criticalSeverity = 0.0; _jetpackSeverity = 0.0; _shockSeverity = 0.0; _drunkSeverity = 0.0; _drunkRoll = 0.0; _drunkPitch = 0.0; _drunkYaw = 0.0; _waterWadeSeverity = 0.0; _waterSubmergeSeverity = 0.0; _punch = Vector3.zero; _punchVel = Vector3.zero; _msInit = false; ScreenShakes.Reset(); } public void AddLandingImpulse(double severity) { _punchVel.x += (float)(ConfigManager.Data.general.landingDipStrength * severity * 15.0); } public void AddWaterSplash(double dipDegrees) { _punchVel.x += (float)(dipDegrees * 15.0); } public void AddRecoil(double kickDeg) { float num = 0f - (float)(kickDeg * 35.0); if (num < _punchVel.x) { _punchVel.x = num; } } public void AddDamageKick(Vector3 degrees) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) _punchVel += degrees * 15f; } public void OnCameraUpdate(in CameraContext context, double dt, PlayerControllerB player) { //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_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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) ConfigData data = ConfigManager.Data; ConfigData.General general = data.general; float num = 1f; if (general.enableHealthCondition && (double)player.health < general.healthConditionTriggerLimit) { num = Mathf.Clamp01((float)player.health / (float)general.healthConditionTriggerLimit); } _masterBase = (float)general.masterStrength; _master = _masterBase * num; UpdateContext(in context, dt, data); _offsetEuler = Vector3.zero; _impairOffset = Vector3.zero; _smoothing = Vector3.zero; ScreenShakes.OnCameraUpdate(dt); UpdateActionTime(in context); CameraSmoothingOffset(in context, dt); if (general.enableSway) { IdleSwayOffset(dt, data); } ApplyStatusEffects(in context, dt, data); ApplyMotionEffects(in context, dt, data); _prevPitch = context.pitch; _prevYaw = context.yaw; } private void UpdateActionTime(in CameraContext context) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) double num = Math.Abs(MathUtils.UnwrapStep(context.yaw - _prevYaw)); double num2 = Math.Abs(context.pitch - _prevPitch); Vector3 velocity = context.velocity; if ((double)((Vector3)(ref velocity)).sqrMagnitude > 0.0004 || num > 0.05 || num2 > 0.05 || context.isInspectingItem) { _lastActionTime = Now; } } private void ApplyStatusEffects(in CameraContext context, double dt, ConfigData cfg) { ConfigData.General general = cfg.general; if (general.enableExhaustionEffect) { ExhaustionOffset(in context, dt, cfg); } if (general.enableInsanityEffect) { InsanityOffset(in context, dt, cfg); } if (general.enableTinnitusEffect) { TinnitusOffset(dt, cfg); } if (general.enableDrunknessEffect) { DrunknessOffset(in context, dt, cfg); } if (general.enableCriticalInjuryEffect) { CriticalInjuryOffset(in context, dt, cfg); } if (general.enablePoisonEffect) { PoisonOffset(in context, dt, cfg); } if (general.enableJetpackTurbulence) { JetpackTurbulenceOffset(in context, dt, cfg); } if (general.enableShockEffect) { ShockOffset(in context, dt, cfg); } if (general.enableSinkingTilt) { SinkingTiltOffset(in context, cfg); } if (general.enableWaterEffect) { WaterOffset(in context, dt, cfg); } } private void ApplyMotionEffects(in CameraContext context, double dt, ConfigData cfg) { ConfigData.General general = cfg.general; ShipMotionOffset(in context, dt, cfg); if (general.enablePitch) { VerticalVelocityPitchOffset(in context, dt, general.maxVelocityPitch); ForwardVelocityPitchOffset(in context, dt, general.maxVelocityPitch); } PunchOffset(dt); if (general.enableRoll) { TurningRollOffset(in context, dt, cfg); StrafingRollOffset(in context, dt, general.maxVelocityRoll); } } private void UpdateContext(in CameraContext context, double dt, ConfigData cfg) { if (_ctxCfg == null) { _ctxCfg = cfg.walking.Clone(); } ConfigData.Contextual b = (context.inVehicle ? cfg.cruiser : (context.isSprinting ? cfg.sprinting : cfg.walking)); double step = ((cfg.general.contextTransitionSmoothing > 0.0) ? MathUtils.DampStep(cfg.general.contextTransitionSmoothing, dt) : 1.0); _ctxCfg.Lerp(_ctxCfg, b, step); } private void PunchOffset(double dt) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) float num = (float)dt; _punchVel += (-220f * _punch - 22f * _punchVel) * num; _punch += _punchVel * num; _punch = Vector3.ClampMagnitude(_punch, 60f); _offsetEuler += _punch; } private void VerticalVelocityPitchOffset(in CameraContext context, double dt, double maxVelocityPitch) { double verticalVelocityPitchFactor = _ctxCfg.verticalVelocityPitchFactor; double smoothing = 4E-05 * _ctxCfg.verticalVelocitySmoothingFactor; double value = (context.isClimbing ? 0.0 : ((double)context.velocity.y * verticalVelocityPitchFactor)); if (Math.Abs(value) < 0.4) { value = 0.0; } value = MathUtils.Clamp(value, 0.0 - maxVelocityPitch, maxVelocityPitch); double num = MathUtils.Damp(_prevVerticalPitch, value, smoothing, dt); _offsetEuler.x += (float)num; _prevVerticalPitch = num; } private void ForwardVelocityPitchOffset(in CameraContext context, double dt, double maxVelocityPitch) { double forwardVelocityPitchFactor = _ctxCfg.forwardVelocityPitchFactor; double smoothing = 0.008 * _ctxCfg.horizontalVelocitySmoothingFactor; double value = (context.isClimbing ? 0.0 : ((double)context.forwardRelVelocity.z * forwardVelocityPitchFactor)); value = MathUtils.Clamp(value, 0.0 - maxVelocityPitch, maxVelocityPitch); double num = MathUtils.Damp(_prevForwardPitch, value, smoothing, dt); _offsetEuler.x += (float)num; _prevForwardPitch = num; } private void TurningRollOffset(in CameraContext context, double dt, ConfigData cfg) { double smoothing = 0.0825 * cfg.general.turningRollSmoothing; double num = 1.25 * cfg.general.turningRollIntensity; double num2 = 0.0048 * cfg.general.turningRollAccumulation; double num3 = MathUtils.UnwrapStep(_prevYaw - context.yaw); if (context.resetSmoothing) { num3 = 0.0; } _turningRollTarget = MathUtils.Damp(_turningRollTarget, 0.0, smoothing, dt); _turningRollTarget = MathUtils.Clamp(_turningRollTarget + num3 * num2, -1.0, 1.0); double num4 = MathUtils.Clamp01(TurningEasing(Math.Abs(_turningRollTarget))) * num * (double)Math.Sign(_turningRollTarget); _offsetEuler.z += (float)num4; } private static double TurningEasing(double x) { if (x < 0.5) { return 4.0 * x * x * x; } double num = -2.0 * x + 2.0; return 1.0 - num * num * num / 2.0; } private void StrafingRollOffset(in CameraContext context, double dt, double maxVelocityRoll) { double strafingRollFactor = _ctxCfg.strafingRollFactor; double smoothing = 0.008 * _ctxCfg.horizontalVelocitySmoothingFactor; double value = (double)(0f - context.forwardRelVelocity.x) * strafingRollFactor; value = MathUtils.Clamp(value, 0.0 - maxVelocityRoll, maxVelocityRoll); double num = MathUtils.Damp(_prevStrafingRoll, value, smoothing, dt); _offsetEuler.z += (float)num; _prevStrafingRoll = num; } private void IdleSwayOffset(double dt, ConfigData cfg) { double now = Now; double cameraSwayIntensity = cfg.general.cameraSwayIntensity; double cameraSwayFrequency = cfg.general.cameraSwayFrequency; if (now - _lastActionTime < cfg.general.cameraSwayFadeInDelay) { _swayFactorTarget = 0.0; } else if (_swayFactor == _swayFactorTarget) { _swayFactorTarget = 1.0; } double num = ((_swayFactorTarget > 0.0) ? cfg.general.cameraSwayFadeInLength : cfg.general.cameraSwayFadeOutLength); double step = ((num > 0.0) ? (dt / num) : 1.0); _swayFactor = MathUtils.StepTowards(_swayFactor, _swayFactorTarget, step); double num2 = _swayFactor * _swayFactor * _swayFactor; if (!(num2 <= 0.0)) { _swayTime += dt * cameraSwayFrequency * 0.5; double num3 = cameraSwayIntensity * num2; _offsetEuler.x += (float)(Noise.Sample(NoiseKind.Fractal, _swayTime, 420.0) * num3); _offsetEuler.y += (float)(Noise.Sample(NoiseKind.Fractal, _swayTime, 1337.0) * num3); } } private void ExhaustionOffset(in CameraContext context, double dt, ConfigData cfg) { double destination = 0.0; if (context.isExhausted) { destination = 1.0; } else if (cfg.general.exhaustionTriggerStamina > 0.0 && (double)context.sprintMeter < cfg.general.exhaustionTriggerStamina) { destination = 1.0 - Math.Max(context.sprintMeter, 0.0) / cfg.general.exhaustionTriggerStamina; } _exhaustionSeverity = MathUtils.Damp(_exhaustionSeverity, destination, 0.02, dt); if (!(_exhaustionSeverity <= 0.01)) { _exhaustionTime += dt * 0.5; double num = cfg.general.exhaustionSwayMultiplier * _exhaustionSeverity * 0.5; _offsetEuler.x += (float)(Noise.Sample(NoiseKind.Fractal, _exhaustionTime, 5500.0) * num); _offsetEuler.y += (float)(Noise.Sample(NoiseKind.Fractal, _exhaustionTime * 1.1, 6600.0) * num * 0.7); } } private void InsanityOffset(in CameraContext context, double dt, ConfigData cfg) { if (!((double)context.insanity < 0.7)) { float num = (float)MathUtils.Clamp01(((double)context.insanity - 0.7) / 0.30000000000000004); if (!(num <= 0f)) { _insanityTime += dt * (1.0 + (double)num * 1.25); double num2 = cfg.general.insanitySwayMultiplier * (double)num * 0.4; _offsetEuler.x += (float)(Noise.Sample(NoiseKind.Fractal, _insanityTime, 7700.0) * num2); _offsetEuler.y += (float)(Noise.Sample(NoiseKind.Fractal, _insanityTime * 1.2, 8800.0) * num2 * 0.6); } } } private void TinnitusOffset(double dt, ConfigData cfg) { if (!((Object)(object)SoundManager.Instance == (Object)null) && !(SoundManager.Instance.earsRingingTimer <= 0f)) { double num = MathUtils.Clamp01((double)SoundManager.Instance.earsRingingTimer / 5.0); double now = Now; double num2 = cfg.general.tinnitusSwayMultiplier * num; _offsetEuler.x += (float)(Noise.Sample(NoiseKind.Simplex, now * 1.25, 800.0) * num2); _offsetEuler.y += (float)(Noise.Sample(NoiseKind.Simplex, now * 1.25 * 0.8, 900.0) * num2); _offsetEuler.z += (float)(Noise.Sample(NoiseKind.Simplex, now * 1.25 * 1.1, 1000.0) * num2 * 0.5); } } private void DrunknessOffset(in CameraContext context, double dt, ConfigData cfg) { double destination = MathUtils.Clamp01(context.drunkness); _drunkSeverity = MathUtils.Damp(_drunkSeverity, destination, 0.06, dt); if (_drunkSeverity <= 0.001) { _drunkPitch = MathUtils.Damp(_drunkPitch, 0.0, 0.025, dt); _drunkYaw = MathUtils.Damp(_drunkYaw, 0.0, 0.025, dt); _drunkRoll = MathUtils.Damp(_drunkRoll, 0.0, 0.025, dt); return; } double num = _drunkSeverity * _drunkSeverity * (3.0 - 2.0 * _drunkSeverity); double num2 = MathUtils.Clamp(cfg.general.drunknessSwayMultiplier / 6.0, 0.25, 2.0); double num3 = MathUtils.Lerp(0.18, 0.42, num); _drunkTime += dt * num3; double num4 = 6.5 * num2; double num5 = 3.0 * num2; double num6 = 2.2 * num2; double destination2 = Noise.Sample(NoiseKind.OpenSimplex2, _drunkTime * 0.84, 3000.0) * num4 * num; double destination3 = Noise.Sample(NoiseKind.OpenSimplex2, _drunkTime * 0.58, 4000.0) * num5 * num; double destination4 = Noise.Sample(NoiseKind.OpenSimplex2, _drunkTime * 0.63, 5000.0) * num6 * num; _drunkRoll = MathUtils.Clamp(MathUtils.Damp(_drunkRoll, destination2, 0.025, dt), 0.0 - num4, num4); _drunkPitch = MathUtils.Clamp(MathUtils.Damp(_drunkPitch, destination3, 0.025, dt), 0.0 - num5, num5); _drunkYaw = MathUtils.Clamp(MathUtils.Damp(_drunkYaw, destination4, 0.025, dt), 0.0 - num6, num6); _impairOffset.z += (float)_drunkRoll; _impairOffset.x += (float)_drunkPitch; _impairOffset.y += (float)_drunkYaw; } private void CriticalInjuryOffset(in CameraContext context, double dt, ConfigData cfg) { double destination = (context.criticallyInjured ? 1.0 : 0.0); _criticalSeverity = MathUtils.Damp(_criticalSeverity, destination, 0.05, dt); if (!(_criticalSeverity <= 0.01)) { _criticalTime += dt * 0.35; double num = 0.75 + 0.25 * Math.Sin(Now * 2.4); double num2 = cfg.general.criticalInjurySwayMultiplier * _criticalSeverity * num; _impairOffset.x += (float)(Noise.Sample(NoiseKind.Fractal, _criticalTime, 9100.0) * num2); _impairOffset.y += (float)(Noise.Sample(NoiseKind.Fractal, _criticalTime * 1.1, 9200.0) * num2 * 0.8); _impairOffset.z += (float)(Noise.Sample(NoiseKind.Fractal, _criticalTime * 0.6, 9300.0) * num2 * 0.4); } } private void PoisonOffset(in CameraContext context, double dt, ConfigData cfg) { if (!(context.poison <= 0f)) { _poisonTime += dt * 1.5; double num = MathUtils.Clamp01(context.poison) * cfg.general.poisonSwayMultiplier; _impairOffset.x += (float)(Noise.Sample(NoiseKind.Simplex, _poisonTime, 10100.0) * num); _impairOffset.y += (float)(Noise.Sample(NoiseKind.Simplex, _poisonTime * 1.3, 10200.0) * num * 0.8); _impairOffset.z += (float)(Noise.Sample(NoiseKind.Simplex, _poisonTime * 0.9, 10300.0) * num * 0.5); } } private void JetpackTurbulenceOffset(in CameraContext context, double dt, ConfigData cfg) { double destination = (context.isUsingJetpack ? 1.0 : 0.0); _jetpackSeverity = MathUtils.Damp(_jetpackSeverity, destination, 0.03, dt); if (!(_jetpackSeverity <= 0.01)) { _jetpackTime += dt * 2.0; double num = cfg.general.jetpackTurbulenceIntensity * _jetpackSeverity; _impairOffset.x += (float)(Noise.Sample(NoiseKind.Fractal, _jetpackTime, 11100.0) * num); _impairOffset.y += (float)(Noise.Sample(NoiseKind.Fractal, _jetpackTime * 1.2, 11200.0) * num); _impairOffset.z += (float)(Noise.Sample(NoiseKind.Fractal, _jetpackTime * 0.8, 11300.0) * num * 0.6); } } private void ShockOffset(in CameraContext context, double dt, ConfigData cfg) { double destination = (context.isBeingShocked ? 1.0 : 0.0); _shockSeverity = MathUtils.Damp(_shockSeverity, destination, 0.02, dt); if (!(_shockSeverity <= 0.01)) { _shockTime += dt * 25.0; double num = cfg.general.shockShakeMultiplier * _shockSeverity; _impairOffset.x += (float)(Noise.Sample(NoiseKind.FrequencyMod, _shockTime, 12100.0) * num); _impairOffset.y += (float)(Noise.Sample(NoiseKind.FrequencyMod, _shockTime * 1.1, 12200.0) * num); _impairOffset.z += (float)(Noise.Sample(NoiseKind.FrequencyMod, _shockTime * 0.9, 12300.0) * num * 0.7); } } private void SinkingTiltOffset(in CameraContext context, ConfigData cfg) { if (!(context.sinkingValue <= 0f)) { double num = MathUtils.Clamp01(context.sinkingValue) * cfg.general.sinkingTiltStrength; _impairOffset.x += (float)num; } } private void WaterOffset(in CameraContext context, double dt, ConfigData cfg) { double destination = ((context.inWater && !context.submerged) ? 1.0 : 0.0); double destination2 = (context.submerged ? 1.0 : 0.0); _waterWadeSeverity = MathUtils.Damp(_waterWadeSeverity, destination, 0.06, dt); _waterSubmergeSeverity = MathUtils.Damp(_waterSubmergeSeverity, destination2, 0.05, dt); if (!(_waterWadeSeverity <= 0.01) || !(_waterSubmergeSeverity <= 0.01)) { _waterTime += dt; if (_waterWadeSeverity > 0.01) { double num = cfg.general.waterWadeStrength * _waterWadeSeverity; double num2 = _waterTime * 0.9; _impairOffset.x += (float)(Noise.Sample(NoiseKind.Fractal, num2, 14100.0) * num * 0.6); _impairOffset.z += (float)(Noise.Sample(NoiseKind.Fractal, num2 * 0.8, 14200.0) * num); } if (_waterSubmergeSeverity > 0.01) { double num3 = cfg.general.waterSubmergedDriftStrength * _waterSubmergeSeverity; double num4 = _waterTime * 0.4; _impairOffset.z += (float)(Noise.Sample(NoiseKind.OpenSimplex2, num4, 14300.0) * num3); _impairOffset.x += (float)(Noise.Sample(NoiseKind.OpenSimplex2, num4 * 0.82, 14400.0) * num3 * 0.8); _impairOffset.y += (float)(Noise.Sample(NoiseKind.OpenSimplex2, num4 * 0.9, 14500.0) * num3 * 0.7); } } } private void ShipMotionOffset(in CameraContext context, double dt, ConfigData cfg) { bool flag = context.shipTakeoffPhase >= 0f && cfg.general.shipTakeoffShakeStrength > 0.0; bool flag2 = context.shipLandingPhase >= 0f && cfg.general.shipLandingShakeStrength > 0.0; if (flag || flag2) { double num2; double num3; double num5; if (flag) { double num = MathUtils.Clamp01(context.shipTakeoffPhase); num2 = cfg.general.shipTakeoffShakeStrength; num3 = num * num; double num4 = Math.Max(0.0, 1.0 - num * 3.0); num5 = (num4 * 1.2 + num3 * 0.8) * num2; } else { double num = MathUtils.Clamp01(context.shipLandingPhase); num2 = cfg.general.shipLandingShakeStrength; num3 = Math.Sin(num * Math.PI); num5 = num3 * 1.2 * num2; } double num6 = num2 * num3 * 0.85; if (!(num6 <= 0.0) || num5 != 0.0) { _shipTime += dt * 9.0; _offsetEuler.x += (float)(Noise.Sample(NoiseKind.Fractal, _shipTime, 13100.0) * num6 + num5); _offsetEuler.y += (float)(Noise.Sample(NoiseKind.Fractal, _shipTime * 1.1, 13200.0) * num6 * 0.7); _offsetEuler.z += (float)(Noise.Sample(NoiseKind.Fractal, _shipTime * 0.9, 13300.0) * num6 * 0.8); } } } private void CameraSmoothingOffset(in CameraContext context, double dt) { double num = Math.Max(0.0, _ctxCfg.cameraSmoothing); double yaw = context.yaw; double pitch = context.pitch; if (!_msInit || context.resetSmoothing) { _prevYawNorm = yaw; _prevPitchNorm = pitch; _contYaw = yaw; _contPitch = pitch; _smYaw = yaw; _smPitch = pitch; _msInit = true; return; } double num2 = MathUtils.UnwrapStep(yaw - _prevYawNorm); double num3 = MathUtils.UnwrapStep(pitch - _prevPitchNorm); _prevYawNorm = yaw; _prevPitchNorm = pitch; _contYaw += num2; _contPitch += num3; if (num <= 0.001) { _smYaw = _contYaw; _smPitch = _contPitch; return; } double num4 = 16.0 / num; double num5 = 1.0 - Math.Exp((0.0 - num4) * Math.Max(0.0, dt)); _smYaw += (_contYaw - _smYaw) * num5; _smPitch += (_contPitch - _smPitch) * num5; _smoothing.y += (float)MathUtils.UnwrapStep(_smYaw - yaw); _smoothing.x += (float)MathUtils.UnwrapStep(_smPitch - pitch); } } internal static class LethalConfigCompat { private const string Guid = "ainavt.lc.lethalconfig"; private static bool? _present; public static bool Present { get { bool valueOrDefault = _present == true; if (!_present.HasValue) { valueOrDefault = Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig"); _present = valueOrDefault; return valueOrDefault; } return valueOrDefault; } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void Register(IReadOnlyList<ConfigEntryBase> entries) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown foreach (ConfigEntryBase entry in entries) { if (!(entry is ConfigEntry<float> val)) { if (!(entry is ConfigEntry<int> val2)) { if (entry is ConfigEntry<bool> val3) { LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(val3, false)); } else { Plugin.Log.LogDebug((object)("Skipping unsupported LethalConfig entry type: " + entry.SettingType.Name)); } } else { LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(val2, false)); } } else { LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(val, false)); } } } } internal static class VisorCompat { public static void StickVisor(Transform? localVisor, Transform? targetPoint, float strength) { //IL_0031: 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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)localVisor == (Object)null) && !((Object)(object)targetPoint == (Object)null)) { localVisor.rotation = ((strength >= 0.999f) ? targetPoint.rotation : Quaternion.Slerp(localVisor.rotation, targetPoint.rotation, strength)); } } } internal static class ConfigManager { private sealed class ContextEntries { public ConfigEntry<float> Strafe; public ConfigEntry<float> ForwardPitch; public ConfigEntry<float> VerticalPitch; public ConfigEntry<float> HSmooth; public ConfigEntry<float> VSmooth; public ConfigEntry<float> MouseSmoothing; } private static readonly ConfigData _data = new ConfigData(); private static readonly List<ConfigEntryBase> _entries = new List<ConfigEntryBase>(); private static ConfigEntry<float> _masterStrength = null; private static ConfigEntry<float> _contextTransitionSmoothing = null; private static ConfigEntry<float> _maxVelocityRoll = null; private static ConfigEntry<float> _maxVelocityPitch = null; private static ConfigEntry<bool> _enableRoll = null; private static ConfigEntry<bool> _enablePitch = null; private static ConfigEntry<bool> _enableSway = null; private static ConfigEntry<bool> _enableScreenShake = null; private static ConfigEntry<bool> _enableLandingDip = null; private static ConfigEntry<bool> _enableWeaponShake = null; private static ConfigEntry<bool> _enableMeleeWeaponShake = null; private static ConfigEntry<bool> _enableTinnitusEffect = null; private static ConfigEntry<bool> _enableExhaustionEffect = null; private static ConfigEntry<bool> _enableInsanityEffect = null; private static ConfigEntry<bool> _enableDrunknessEffect = null; private static ConfigEntry<bool> _enableCriticalInjuryEffect = null; private static ConfigEntry<bool> _enablePoisonEffect = null; private static ConfigEntry<bool> _enableJetpackTurbulence = null; private static ConfigEntry<bool> _enableShockEffect = null; private static ConfigEntry<bool> _enableSinkingTilt = null; private static ConfigEntry<bool> _enableWaterEffect = null; private static ConfigEntry<bool> _enableHealthCondition = null; private static ConfigEntry<float> _turningRollIntensity = null; private static ConfigEntry<float> _turningRollAccumulation = null; private static ConfigEntry<float> _turningRollSmoothing = null; private static ConfigEntry<float> _swayIntensity = null; private static ConfigEntry<float> _swayFrequency = null; private static ConfigEntry<float> _swayFadeInDelay = null; private static ConfigEntry<float> _swayFadeInLength = null; private static ConfigEntry<float> _swayFadeOutLength = null; private static ConfigEntry<float> _tinnitusSwayMultiplier = null; private static ConfigEntry<float> _exhaustionSwayMultiplier = null; private static ConfigEntry<float> _exhaustionTriggerStamina = null; private static ConfigEntry<float> _insanitySwayMultiplier = null; private static ConfigEntry<float> _drunknessSwayMultiplier = null; private static ConfigEntry<float> _criticalInjurySwayMultiplier = null; private static ConfigEntry<float> _poisonSwayMultiplier = null; private static ConfigEntry<float> _jetpackTurbulenceIntensity = null; private static ConfigEntry<float> _shockShakeMultiplier = null; private static ConfigEntry<float> _sinkingTiltStrength = null; private static ConfigEntry<float> _waterWadeStrength = null; private static ConfigEntry<float> _waterSubmergedDriftStrength = null; private static ConfigEntry<float> _waterSplashStrength = null; private static ConfigEntry<float> _shakeMaxIntensity = null; private static ConfigEntry<float> _shakeMaxFrequency = null; private static ConfigEntry<float> _shakeDecay = null; private static ConfigEntry<float> _explosionTrauma = null; private static ConfigEntry<float> _landingTrauma = null; private static ConfigEntry<float> _damageTrauma = null; private static ConfigEntry<float> _damageKick = null; private static ConfigEntry<float> _vehicleImpactTrauma = null; private static ConfigEntry<float> _flashbangTrauma = null; private static ConfigEntry<float> _shipTakeoffShakeStrength = null; private static ConfigEntry<float> _shipLandingShakeStrength = null; private static ConfigEntry<float> _weaponShakeTrauma = null; private static ConfigEntry<float> _weaponRecoilKick = null; private static ConfigEntry<float> _meleeWeaponShakeTrauma = null; private static ConfigEntry<float> _meleeWeaponRecoilKick = null; private static ConfigEntry<float> _meleeWeaponMissMultiplier = null; private static ConfigEntry<float> _landingDipStrength = null; private static ConfigEntry<float> _landingWeightInfluence = null; private static ConfigEntry<float> _healthConditionTriggerLimit = null; private static readonly ContextEntries _walk = new ContextEntries(); private static readonly ContextEntries _sprint = new ContextEntries(); private static readonly ContextEntries _cruiser = new ContextEntries(); public static ConfigData Data => _data; internal static void Initialize(ConfigFile config) { _entries.Clear(); config.SaveOnConfigSet = false; ConfigData configData = new ConfigData(); _masterStrength = BindFloat(config, "1. General", "MasterStrength", (float)configData.general.masterStrength, 0f, 3f, "Scales every effect."); _contextTransitionSmoothing = BindFloat(config, "1. General", "ContextTransitionSmoothing", (float)configData.general.contextTransitionSmoothing, 0f, 1f, "How smoothly tuning blends when your movement context changes."); _maxVelocityRoll = BindFloat(config, "1. General", "MaxVelocityRoll", (float)configData.general.maxVelocityRoll, 0f, 90f, "Safety cap on speed-driven roll so very high speeds can't fling the view."); _maxVelocityPitch = BindFloat(config, "1. General", "MaxVelocityPitch", (float)configData.general.maxVelocityPitch, 0f, 90f, "Safety cap on speed-driven pitch so very high speeds can't fling the view."); _enableRoll = BindBool(config, "2. Effect Toggles", "EnableRoll", configData.general.enableRoll, "Strafing lean and turning roll."); _enablePitch = BindBool(config, "2. Effect Toggles", "EnablePitch", configData.general.enablePitch, "Forward/back and vertical velocity pitch."); _enableSway = BindBool(config, "2. Effect Toggles", "EnableSway", configData.general.enableSway, "Idle camera sway while standing still."); _enableScreenShake = BindBool(config, "2. Effect Toggles", "EnableScreenShake", configData.general.enableScreenShake, "Screen shake from explosions, hard landings and taking damage."); _enableLandingDip = BindBool(config, "2. Effect Toggles", "EnableLandingDip", configData.general.enableLandingDip, "Quick downward pitch punch when you land hard."); _enableWeaponShake = BindBool(config, "2. Effect Toggles", "EnableWeaponShake", configData.general.enableWeaponShake, "Rattle and upward recoil kick when you fire a gun."); _enableMeleeWeaponShake = BindBool(config, "2. Effect Toggles", "EnableMeleeWeaponShake", configData.general.enableMeleeWeaponShake, "Rattle and upward punch when you swing a melee weapon."); _enableTinnitusEffect = BindBool(config, "2. Effect Toggles", "EnableTinnitusEffect", configData.general.enableTinnitusEffect, "Increases camera sway heavily while having tinnitues."); _enableExhaustionEffect = BindBool(config, "2. Effect Toggles", "EnableExhaustionEffect", configData.general.enableExhaustionEffect, "Heavy breathing/sway when you are completely out of stamina."); _enableInsanityEffect = BindBool(config, "2. Effect Toggles", "EnableInsanityEffect", configData.general.enableInsanityEffect, "Faster camera sway when character insanity limit drops."); _enableDrunknessEffect = BindBool(config, "2. Effect Toggles", "EnableDrunknessEffect", configData.general.enableDrunknessEffect, "Smooth floating camera drift when intoxicated."); _enableCriticalInjuryEffect = BindBool(config, "2. Effect Toggles", "EnableCriticalInjuryEffect", configData.general.enableCriticalInjuryEffect, "Pulsing near death sway while critically injured."); _enablePoisonEffect = BindBool(config, "2. Effect Toggles", "EnablePoisonEffect", configData.general.enablePoisonEffect, "Jittery sway while poisoned."); _enableJetpackTurbulence = BindBool(config, "2. Effect Toggles", "EnableJetpackTurbulence", configData.general.enableJetpackTurbulence, "Turbulence sway while flying a jetpack."); _enableShockEffect = BindBool(config, "2. Effect Toggles", "EnableShockEffect", configData.general.enableShockEffect, "Electric jitter while being zapped by a zap gun."); _enableSinkingTilt = BindBool(config, "2. Effect Toggles", "EnableSinkingTilt", configData.general.enableSinkingTilt, "Forward pitch tilt as you sink into quicksand."); _enableWaterEffect = BindBool(config, "2. Effect Toggles", "EnableWaterEffect", configData.general.enableWaterEffect, "Sloshy sway while wading and floaty drift while submerged in water."); _enableHealthCondition = BindBool(config, "2. Effect Toggles", "EnableHealthCondition", configData.general.enableHealthCondition, "When health is low, camera effects gradually fade out."); _turningRollIntensity = BindFloat(config, "3. Turning Roll", "Intensity", (float)configData.general.turningRollIntensity, 0f, 5f, "Maximum roll the camera leans when you whip the view left/right."); _turningRollAccumulation = BindFloat(config, "3. Turning Roll", "Accumulation", (float)configData.general.turningRollAccumulation, 0f, 5f, "How quickly fast turning builds up the lean."); _turningRollSmoothing = BindFloat(config, "3. Turning Roll", "Smoothing", (float)configData.general.turningRollSmoothing, 0f, 5f, "How quickly the turning lean settles back to level once you stop turning."); _swayIntensity = BindFloat(config, "4. Camera Sway", "Intensity", (float)configData.general.cameraSwayIntensity, 0f, 5f, "Strength of the idle sway while standing still."); _swayFrequency = BindFloat(config, "4. Camera Sway", "Frequency", (float)configData.general.cameraSwayFrequency, 0f, 2f, "Speed of the idle sway."); _swayFadeInDelay = BindFloat(config, "4. Camera Sway", "FadeInDelay", (float)configData.general.cameraSwayFadeInDelay, 0f, 5f, "Seconds of stillness before sway starts fading in."); _swayFadeInLength = BindFloat(config, "4. Camera Sway", "FadeInLength", (float)configData.general.cameraSwayFadeInLength, 0f, 20f, "Seconds for sway to reach full strength once it starts fading in."); _swayFadeOutLength = BindFloat(config, "4. Camera Sway", "FadeOutLength", (float)configData.general.cameraSwayFadeOutLength, 0f, 5f, "Seconds for sway to fade back out when you start moving."); _tinnitusSwayMultiplier = BindFloat(config, "4. Camera Sway", "TinnitusSwayMultiplier", (float)configData.general.tinnitusSwayMultiplier, 1f, 10f, "Multiplier on camera sway while you have tinnitus."); _exhaustionSwayMultiplier = BindFloat(config, "4. Camera Sway", "ExhaustionSwayMultiplier", (float)configData.general.exhaustionSwayMultiplier, 1f, 10f, "Multiplier on camera sway while exhausted."); _exhaustionTriggerStamina = BindFloat(config, "4. Camera Sway", "ExhaustionTriggerStamina", (float)configData.general.exhaustionTriggerStamina, 0.05f, 1f, "Stamina level below which exhaustion sway starts creeping in."); _insanitySwayMultiplier = BindFloat(config, "4. Camera Sway", "InsanitySwayMultiplier", (float)configData.general.insanitySwayMultiplier, 1f, 10f, "Multiplier on camera sway frequency while panicked/insane."); _drunknessSwayMultiplier = BindFloat(config, "4. Camera Sway", "DrunknessSwayMultiplier", (float)configData.general.drunknessSwayMultiplier, 1f, 10f, "Multiplier on camera sway drift while intoxicated."); _criticalInjurySwayMultiplier = BindFloat(config, "4. Camera Sway", "CriticalInjurySwayMultiplier", (float)configData.general.criticalInjurySwayMultiplier, 1f, 10f, "Strength of the heavy near-death sway while critically injured."); _poisonSwayMultiplier = BindFloat(config, "4. Camera Sway", "PoisonSwayMultiplier", (float)configData.general.poisonSwayMultiplier, 1f, 10f, "Strength of the jittery sway while poisoned."); _jetpackTurbulenceIntensity = BindFloat(config, "4. Camera Sway", "JetpackTurbulenceIntensity", (float)configData.general.jetpackTurbulenceIntensity, 0f, 10f, "Strength of the turbulence sway while flying a jetpack."); _shockShakeMultiplier = BindFloat(config, "4. Camera Sway", "ShockShakeMultiplier", (float)configData.general.shockShakeMultiplier, 0f, 10f, "Strength of the electric jitter while being shocked."); _sinkingTiltStrength = BindFloat(config, "4. Camera Sway", "SinkingTiltStrength", (float)configData.general.sinkingTiltStrength, 0f, 45f, "Degrees of forward pitch tilt at full sink in quicksand."); _shakeMaxIntensity = BindFloat(config, "5. Screen Shake", "MaxIntensity", (float)configData.general.screenShakesMaxIntensity, 0f, 10f, "Screen shake strength multiplying all shake."); _shakeMaxFrequency = BindFloat(config, "5. Screen Shake", "MaxFrequency", (float)configData.general.screenShakesMaxFrequency, 0f, 20f, "Screen shake speed/harshness."); _shakeDecay = BindFloat(config, "5. Screen Shake", "Decay", (float)configData.general.screenShakeDecay, 0.1f, 5f, "How fast shake fades. Trauma drained per second."); _explosionTrauma = BindFloat(config, "5. Screen Shake", "ExplosionTrauma", (float)configData.general.explosionTrauma, 0f, 3f, "Shake strength of a nearby explosion, scaled by distance."); _landingTrauma = BindFloat(config, "5. Screen Shake", "LandingTrauma", (float)configData.general.landingTrauma, 0f, 3f, "Shake strength of a hard landing, scaled by fall force and carry weight."); _damageTrauma = BindFloat(config, "5. Screen Shake", "DamageTrauma", (float)configData.general.damageTrauma, 0f, 3f, "Shake strength of taking damage, scaled by the hit size."); _damageKick = BindFloat(config, "5. Screen Shake", "DamageKick", (float)configData.general.damageKick, 0f, 20f, "Directional camera punch away from a hit, scaled by hit size."); _vehicleImpactTrauma = BindFloat(config, "5. Screen Shake", "VehicleImpactTrauma", (float)configData.general.vehicleImpactTrauma, 0f, 3f, "Shake strength of a hard cruiser crash, scaled by how fast you stopped."); _flashbangTrauma = BindFloat(config, "5. Screen Shake", "FlashbangTrauma", (float)configData.general.flashbangTrauma, 0f, 5f, "Shake strength of a Stun Grenade detonation, scaled by distance."); _shipTakeoffShakeStrength = BindFloat(config, "5. Screen Shake", "ShipTakeoffShakeStrength", (float)configData.general.shipTakeoffShakeStrength, 0f, 5f, "Camera shake that builds up as the ship blasts off. 0 disables."); _shipLandingShakeStrength = BindFloat(config, "5. Screen Shake", "ShipLandingShakeStrength", (float)configData.general.shipLandingShakeStrength, 0f, 5f, "Camera shake as the ship descends and touches down. 0 disables."); _weaponShakeTrauma = BindFloat(config, "5. Screen Shake", "WeaponShakeTrauma", (float)configData.general.weaponShakeTrauma, 0f, 3f, "Shake strength of a gunshot."); _weaponRecoilKick = BindFloat(config, "5. Screen Shake", "WeaponRecoilKick", (float)configData.general.weaponRecoilKick, 0f, 60f, "Upward recoil punch per shot."); _meleeWeaponShakeTrauma = BindFloat(config, "5. Screen Shake", "MeleeWeaponShakeTrauma", (float)configData.general.meleeWeaponShakeTrauma, 0f, 3f, "Shake strength of a shovel swing."); _meleeWeaponRecoilKick = BindFloat(config, "5. Screen Shake", "MeleeWeaponRecoilKick", (float)configData.general.meleeWeaponRecoilKick, 0f, 60f, "Upward punch per shovel swing."); _meleeWeaponMissMultiplier = BindFloat(config, "5. Screen Shake", "MeleeWeaponMissMultiplier", (float)configData.general.meleeWeaponMissMultiplier, 0f, 1f, "Multiplier on the shovel swing shake/kick if you swing but hit nothing."); _landingDipStrength = BindFloat(config, "5. Screen Shake", "LandingDipStrength", (float)configData.general.landingDipStrength, 0f, 20f, "How far the camera dips down on a hard landing."); _landingWeightInfluence = BindFloat(config, "5. Screen Shake", "LandingWeightInfluence", (float)configData.general.landingWeightInfluence, 0f, 2f, "How much carry weight hardens landings."); _healthConditionTriggerLimit = BindFloat(config, "5. Screen Shake", "HealthConditionTriggerLimit", (float)configData.general.healthConditionTriggerLimit, 0f, 100f, "Below this health, camera effects start to fade out."); BindContext(config, "6. Walking", _walk, configData.walking); BindContext(config, "7. Sprinting", _sprint, configData.sprinting); BindContext(config, "8. Cruiser", _cruiser, configData.cruiser); _waterWadeStrength = BindFloat(config, "9. Water", "WadeStrength", (float)configData.general.waterWadeStrength, 0f, 10f, "Strength of the heavy slosh sway while wading through water."); _waterSubmergedDriftStrength = BindFloat(config, "9. Water", "SubmergedDriftStrength", (float)configData.general.waterSubmergedDriftStrength, 0f, 15f, "Strength of the slow floaty drift while fully submerged."); _waterSplashStrength = BindFloat(config, "9. Water", "SplashStrength", (float)configData.general.waterSplashStrength, 0f, 10f, "Downward camera dip when entering water and when your head goes under."); Sync(); config.SettingChanged += delegate { Sync(); }; ClearOrphanedEntries(config); config.Save(); config.SaveOnConfigSet = true; if (LethalConfigCompat.Present) { LethalConfigCompat.Register(_entries); } } private static void BindContext(ConfigFile c, string section, ContextEntries e, ConfigData.Contextual def) { e.Strafe = BindFloat(c, section, "StrafingRollFactor", (float)def.strafingRollFactor, 0f, 30f, "How hard the camera leans/rolls into sideways movement."); e.ForwardPitch = BindFloat(c, section, "ForwardVelocityPitchFactor", (float)def.forwardVelocityPitchFactor, 0f, 30f, "How much the camera tilts/pitches with forward/back speed."); e.VerticalPitch = BindFloat(c, section, "VerticalVelocityPitchFactor", (float)def.verticalVelocityPitchFactor, 0f, 30f, "How much the camera tilts up/down with vertical speed."); e.HSmooth = BindFloat(c, section, "HorizontalVelocitySmoothingFactor", (float)def.horizontalVelocitySmoothingFactor, 0f, 10f, "Smoothing for the strafe roll and forward-pitch effects."); e.VSmooth = BindFloat(c, section, "VerticalVelocitySmoothingFactor", (float)def.verticalVelocitySmoothingFactor, 0f, 10f, "Smoothing for the vertical velocity pitch."); e.MouseSmoothing = BindFloat(c, section, "CameraSmoothing", (float)def.cameraSmoothing, 0f, 5f, "Mouse moving smoothing."); } private static ConfigEntry<float> BindFloat(ConfigFile c, string section, string key, float def, float min, float max, string desc) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown ConfigEntry<float> val = c.Bind<float>(section, key, def, new ConfigDescription(desc, (AcceptableValueBase)(object)new AcceptableValueRange<float>(min, max), Array.Empty<object>())); _entries.Add((ConfigEntryBase)(object)val); return val; } private static ConfigEntry<bool> BindBool(ConfigFile c, string section, string key, bool def, string desc) { ConfigEntry<bool> val = c.Bind<bool>(section, key, def, desc); _entries.Add((ConfigEntryBase)(object)val); return val; } private static void Sync() { ConfigData.General general = _data.general; general.masterStrength = _masterStrength.Value; general.contextTransitionSmoothing = _contextTransitionSmoothing.Value; general.maxVelocityRoll = _maxVelocityRoll.Value; general.maxVelocityPitch = _maxVelocityPitch.Value; general.enableRoll = _enableRoll.Value; general.enablePitch = _enablePitch.Value; general.enableSway = _enableSway.Value; general.enableScreenShake = _enableScreenShake.Value; general.enableLandingDip = _enableLandingDip.Value; general.enableWeaponShake = _enableWeaponShake.Value; general.enableMeleeWeaponShake = _enableMeleeWeaponShake.Value; general.enableTinnitusEffect = _enableTinnitusEffect.Value; general.enableExhaustionEffect = _enableExhaustionEffect.Value; general.enableInsanityEffect = _enableInsanityEffect.Value; general.enableDrunknessEffect = _enableDrunknessEffect.Value; general.enableCriticalInjuryEffect = _enableCriticalInjuryEffect.Value; general.enablePoisonEffect = _enablePoisonEffect.Value; general.enableJetpackTurbulence = _enableJetpackTurbulence.Value; general.enableShockEffect = _enableShockEffect.Value; general.enableSinkingTilt = _enableSinkingTilt.Value; general.enableWaterEffect = _enableWaterEffect.Value; general.enableHealthCondition = _enableHealthCondition.Value; general.turningRollIntensity = _turningRollIntensity.Value; general.turningRollAccumulation = _turningRollAccumulation.Value; general.turningRollSmoothing = _turningRollSmoothing.Value; general.cameraSwayIntensity = _swayIntensity.Value; general.cameraSwayFrequency = _swayFrequency.Value; general.cameraSwayFadeInDelay = _swayFadeInDelay.Value; general.cameraSwayFadeInLength = _swayFadeInLength.Value; general.cameraSwayFadeOutLength = _swayFadeOutLength.Value; general.tinnitusSwayMultiplier = _tinnitusSwayMultiplier.Value; general.exhaustionSwayMultiplier = _exhaustionSwayMultiplier.Value; general.exhaustionTriggerStamina = _exhaustionTriggerStamina.Value; general.insanitySwayMultiplier = _insanitySwayMultiplier.Value; general.drunknessSwayMultiplier = _drunknessSwayMultiplier.Value; general.criticalInjurySwayMultiplier = _criticalInjurySwayMultiplier.Value; general.poisonSwayMultiplier = _poisonSwayMultiplier.Value; general.jetpackTurbulenceIntensity = _jetpackTurbulenceIntensity.Value; general.shockShakeMultiplier = _shockShakeMultiplier.Value; general.sinkingTiltStrength = _sinkingTiltStrength.Value; general.waterWadeStrength = _waterWadeStrength.Value; general.waterSubmergedDriftStrength = _waterSubmergedDriftStrength.Value; general.waterSplashStrength = _waterSplashStrength.Value; general.screenShakesMaxIntensity = _shakeMaxIntensity.Value; general.screenShakesMaxFrequency = _shakeMaxFrequency.Value; general.screenShakeDecay = _shakeDecay.Value; general.explosionTrauma = _explosionTrauma.Value; general.landingTrauma = _landingTrauma.Value; general.damageTrauma = _damageTrauma.Value; general.damageKick = _damageKick.Value; general.vehicleImpactTrauma = _vehicleImpactTrauma.Value; general.flashbangTrauma = _flashbangTrauma.Value; general.shipTakeoffShakeStrength = _shipTakeoffShakeStrength.Value; general.shipLandingShakeStrength = _shipLandingShakeStrength.Value; general.weaponShakeTrauma = _weaponShakeTrauma.Value; general.weaponRecoilKick = _weaponRecoilKick.Value; general.meleeWeaponShakeTrauma = _meleeWeaponShakeTrauma.Value; general.meleeWeaponRecoilKick = _meleeWeaponRecoilKick.Value; general.meleeWeaponMissMultiplier = _meleeWeaponMissMultiplier.Value; general.landingDipStrength = _landingDipStrength.Value; general.landingWeightInfluence = _landingWeightInfluence.Value; general.healthConditionTriggerLimit = _healthConditionTriggerLimit.Value; SyncContext(_walk, _data.walking); SyncContext(_sprint, _data.sprinting); SyncContext(_cruiser, _data.cruiser); } private static void SyncContext(ContextEntries e, ConfigData.Contextual c) { c.strafingRollFactor = e.Strafe.Value; c.forwardVelocityPitchFactor = e.ForwardPitch.Value; c.verticalVelocityPitchFactor = e.VerticalPitch.Value; c.horizontalVelocitySmoothingFactor = e.HSmooth.Value; c.verticalVelocitySmoothingFactor = e.VSmooth.Value; c.cameraSmoothing = e.MouseSmoothing.Value; } private static void ClearOrphanedEntries(ConfigFile config) { try { PropertyInfo propertyInfo = AccessTools.Property(typeof(ConfigFile), "OrphanedEntries"); if (propertyInfo != null && propertyInfo.GetValue(config) is Dictionary<ConfigDefinition, string> dictionary) { dictionary.Clear(); Plugin.Log.LogDebug((object)"Cleared orphaned config entries"); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not clear orphaned config entries: " + ex.Message)); } } } internal sealed class ConfigData { public sealed class General { public double masterStrength = 1.0; public double contextTransitionSmoothing = 0.1; public bool enableRoll = true; public bool enablePitch = true; public bool enableSway = true; public bool enableScreenShake = true; public bool enableLandingDip = true; public bool enableWeaponShake = true; public bool enableMeleeWeaponShake = true; public bool enableTinnitusEffect = true; public bool enableExhaustionEffect = true; public bool enableInsanityEffect = true; public bool enableDrunknessEffect = true; public bool enableCriticalInjuryEffect = true; public bool enablePoisonEffect = true; public bool enableJetpackTurbulence = true; public bool enableShockEffect = true; public bool enableSinkingTilt = true; public bool enableWaterEffect = true; public bool enableHealthCondition = true; public double turningRollAccumulation = 2.5; public double turningRollIntensity = 3.0; public double turningRollSmoothing = 1.0; public double cameraSwayIntensity = 2.0; public double cameraSwayFrequency = 0.16; public double cameraSwayFadeInDelay = 2.0; public double cameraSwayFadeInLength = 5.0; public double cameraSwayFadeOutLength = 0.75; public double tinnitusSwayMultiplier = 10.0; public double exhaustionSwayMultiplier = 4.0; public double exhaustionTriggerStamina = 0.4; public double insanitySwayMultiplier = 1.5; public double drunknessSwayMultiplier = 6.0; public double criticalInjurySwayMultiplier = 4.0; public double poisonSwayMultiplier = 6.0; public double jetpackTurbulenceIntensity = 1.5; public double shockShakeMultiplier = 3.0; public double sinkingTiltStrength = 12.0; public double waterWadeStrength = 2.0; public double waterSubmergedDriftStrength = 5.0; public double waterSplashStrength = 5.0; public double screenShakesMaxIntensity = 2.5; public double screenShakesMaxFrequency = 6.0; public double screenShakeDecay = 1.5; public double explosionTrauma = 1.7; public double landingTrauma = 1.0; public double damageTrauma = 4.0; public double damageKick = 4.0; public double vehicleImpactTrauma = 2.0; public double flashbangTrauma = 2.5; public double shipTakeoffShakeStrength = 0.5; public double shipLandingShakeStrength = 0.7; public double weaponShakeTrauma = 1.3; public double weaponRecoilKick = 30.0; public double meleeWeaponShakeTrauma = 1.0; public double meleeWeaponRecoilKick = 5.0; public double meleeWeaponMissMultiplier = 0.5; public double landingDipStrength = 6.0; public double landingWeightInfluence = 0.3; public double maxVelocityRoll = 12.0; public double maxVelocityPitch = 10.0; public double healthConditionTriggerLimit = 20.0; } public sealed class Contextual { public double strafingRollFactor = 8.0; public double forwardVelocityPitchFactor = 2.0; public double verticalVelocityPitchFactor = 7.0; public double horizontalVelocitySmoothingFactor = 1.0; public double verticalVelocitySmoothingFactor = 1.0; public double cameraSmoothing; public void CopyFrom(Contextual o) { strafingRollFactor = o.strafingRollFactor; forwardVelocityPitchFactor = o.forwardVelocityPitchFactor; verticalVelocityPitchFactor = o.verticalVelocityPitchFactor; horizontalVelocitySmoothingFactor = o.horizontalVelocitySmoothingFactor; verticalVelocitySmoothingFactor = o.verticalVelocitySmoothingFactor; cameraSmoothing = o.cameraSmoothing; } public Contextual Clone() { Contextual contextual = new Contextual(); contextual.CopyFrom(this); return contextual; } public void Lerp(Contextual a, Contextual b, double step) { strafingRollFactor = MathUtils.Lerp(a.strafingRollFactor, b.strafingRollFactor, step); forwardVelocityPitchFactor = MathUtils.Lerp(a.forwardVelocityPitchFactor, b.forwardVelocityPitchFactor, step); verticalVelocityPitchFactor = MathUtils.Lerp(a.verticalVelocityPitchFactor, b.verticalVelocityPitchFactor, step); horizontalVelocitySmoothingFactor = MathUtils.Lerp(a.horizontalVelocitySmoothingFactor, b.horizontalVelocitySmoothingFactor, step); verticalVelocitySmoothingFactor = MathUtils.Lerp(a.verticalVelocitySmoothingFactor, b.verticalVelocitySmoothingFactor, step); cameraSmoothing = MathUtils.Lerp(a.cameraSmoothing, b.cameraSmoothing, step); } } public General general = new General(); public Contextual walking = new Contextual(); public Contextual sprinting = new Contextual(); public Contextual cruiser = new Contextual(); public ConfigData() { sprinting.strafingRollFactor = 10.0; sprinting.forwardVelocityPitchFactor = 9.5; sprinting.verticalVelocityPitchFactor = 8.0; sprinting.cameraSmoothing = 0.0; cruiser.strafingRollFactor = 5.0; cruiser.forwardVelocityPitchFactor = 3.5; cruiser.verticalVelocityPitchFactor = 5.0; cruiser.cameraSmoothing = 0.0; } } internal static class ModGUIDs { public const string ImmersiveVisor = "ImmersiveVisor"; public const string LethalConfig = "ainavt.lc.lethalconfig"; } [HarmonyPatch(typeof(PlayerControllerB))] internal static class CameraPatches { private static readonly CameraSystem _system = new CameraSystem(); private static bool _wasActive; private static float _lastYawOffset; private static float _lastRollOffset; private static Vector3 _lastBodyPos; private static bool _hasLastBodyPos; private static float _vehicleSpeed; private static bool _hasVehicleSpeed; private static bool _wasClimbing; private static bool _wasInVehicle; private static bool _wasInSpecialInteract; private static bool _wasInTerminal; private static bool _wasInWater; private static bool _wasSubmerged; private const double VelocityScale = 0.05; private const float VehicleImpactDecel = 220f; private const float MaxDeltaTime = 0.05f; private const float MaxEffectPitch = 85f; private const float MaxEffectYaw = 60f; private const float MaxEffectRoll = 70f; internal static CameraSystem System => _system; [HarmonyPostfix] [HarmonyPatch("LateUpdate")] [HarmonyPriority(0)] private static void LateUpdatePostfix(PlayerControllerB __instance, float ___cameraUp) { //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_0388: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_03a4: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance != (Object)(object)StartOfRound.Instance?.localPlayerController) { return; } Camera gameplayCamera = __instance.gameplayCamera; CharacterController thisController = __instance.thisController; Transform thisPlayerBody = __instance.thisPlayerBody; if (ShouldSkipCameraUpdate(__instance, gameplayCamera, thisController, thisPlayerBody)) { DeactivateCameraState(gameplayCamera); return; } bool flag = !_wasActive; bool flag2 = IsInControlledCamera(__instance); bool flag3 = NeedsCameraRestore(flag, __instance); if (flag) { _system.Reset(); } Transform transform = ((Component)gameplayCamera).transform; if (flag3) { Vector3 localEulerAngles = transform.localEulerAngles; transform.localEulerAngles = new Vector3(localEulerAngles.x, localEulerAngles.y - _lastYawOffset, localEulerAngles.z - _lastRollOffset); _lastYawOffset = 0f; _lastRollOffset = 0f; } MarkCameraStateActive(__instance); Vector3 localEulerAngles2 = transform.localEulerAngles; float num = Mathf.Min(Time.deltaTime, 0.05f); Vector3 val = ReadVelocity(__instance, thisPlayerBody, thisController, flag2, num) * 0.05f; float num2 = Mathf.Clamp01(__instance.drunkness); if (!ConfigManager.Data.general.enableDrunknessEffect && num2 > 0f) { val = RemoveVanillaDrunkSpeedScaling(val, num2); num2 = 0f; } Vector3 val2 = thisPlayerBody.forward; val2.y = 0f; val2 = ((((Vector3)(ref val2)).sqrMagnitude > 1E-06f) ? ((Vector3)(ref val2)).normalized : Vector3.forward); Vector3 val3 = thisPlayerBody.right; val3.y = 0f; val3 = ((((Vector3)(ref val3)).sqrMagnitude > 1E-06f) ? ((Vector3)(ref val3)).normalized : Vector3.right); ShipMotionTracker.GetLocalShipShakePhases(__instance, out var takeoff, out var landing); bool isUnderwater = __instance.isUnderwater; int num3; if (isUnderwater && (Object)(object)__instance.underwaterCollider != (Object)null) { Bounds bounds = __instance.underwaterCollider.bounds; num3 = (((Bounds)(ref bounds)).Contains(transform.position) ? 1 : 0); } else { num3 = 0; } bool submerged = (byte)num3 != 0; TriggerWaterSplashes(isUnderwater, submerged); CameraContext context = new CameraContext { isSprinting = __instance.isSprinting, isCrouching = __instance.isCrouching, inVehicle = __instance.inVehicleAnimation, isClimbing = __instance.isClimbingLadder, isExhausted = __instance.isExhausted, isInspectingItem = __instance.IsInspectingItem, criticallyInjured = __instance.criticallyInjured, isUsingJetpack = __instance.jetpackControls, isBeingShocked = ShockTracker.BeingShocked, sprintMeter = __instance.sprintMeter, drunkness = num2, insanity = ((__instance.maxInsanityLevel > 0f) ? (__instance.insanityLevel / __instance.maxInsanityLevel) : 0f), poison = __instance.poison, sinkingValue = __instance.sinkingValue, shipTakeoffPhase = takeoff, shipLandingPhase = landing, inWater = isUnderwater, submerged = submerged, velocity = val, forwardRelVelocity = new Vector3(Vector3.Dot(val, val3), val.y, Vector3.Dot(val, val2)), pitch = ___cameraUp, yaw = thisPlayerBody.eulerAngles.y, resetSmoothing = flag3 }; _system.OnCameraUpdate(in context, num, __instance); Vector3 off = _system.OffsetEuler; if (__instance.inVehicleAnimation) { off.y = 0f; off.z = 0f; } else if (flag2) { off = Vector3.zero; } ClampEffectOffset(ref off, localEulerAngles2.x); transform.localEulerAngles = new Vector3(localEulerAngles2.x + off.x, localEulerAngles2.y - _lastYawOffset + off.y, localEulerAngles2.z - _lastRollOffset + off.z); _lastYawOffset = off.y; _lastRollOffset = off.z; VisorCompat.StickVisor(__instance.localVisor, __instance.localVisorTargetPoint, 1f); } private static bool ShouldSkipCameraUpdate(PlayerControllerB player, Camera? cam, CharacterController? controller, Transform? body) { if (!IsLookLocked(player) && !player.teleportedLastFrame && player.isPlayerControlled && !player.isPlayerDead && !((Object)(object)cam == (Object)null) && !((Object)(object)controller == (Object)null)) { return (Object)(object)body == (Object)null; } return true; } private static void DeactivateCameraState(Camera? cam) { if (_wasActive && (Object)(object)cam != (Object)null) { RestoreCamera(((Component)cam).transform); } _wasActive = false; _hasLastBodyPos = false; _hasVehicleSpeed = false; _wasInWater = false; _wasSubmerged = false; VehicleTracker.Reset(); ShockTracker.BeingShocked = false; } private static void TriggerWaterSplashes(bool inWater, bool submerged) { ConfigData.General general = ConfigManager.Data.general; if (general.enableWaterEffect && general.waterSplashStrength > 0.0) { if (inWater && !_wasInWater) { _system.AddWaterSplash(general.waterSplashStrength * 0.5); } if (submerged && !_wasSubmerged) { _system.AddWaterSplash(general.waterSplashStrength); } } _wasInWater = inWater; _wasSubmerged = submerged; } private static bool IsInControlledCamera(PlayerControllerB player) { if (!player.isClimbingLadder && !player.inVehicleAnimation && !player.inSpecialInteractAnimation) { return player.inTerminalMenu; } return true; } private static bool NeedsCameraRestore(bool justActivated, PlayerControllerB player) { if (!justActivated && _wasClimbing == player.isClimbingLadder && _wasInVehicle == player.inVehicleAnimation && _wasInSpecialInteract == player.inSpecialInteractAnimation) { return _wasInTerminal != player.inTerminalMenu; } return true; } private static void MarkCameraStateActive(PlayerControllerB player) { _wasActive = true; _wasClimbing = player.isClimbingLadder; _wasInVehicle = player.inVehicleAnimation; _wasInSpecialInteract = player.inSpecialInteractAnimation; _wasInTerminal = player.inTerminalMenu; } private static Vector3 ReadVelocity(PlayerControllerB p, Transform body, CharacterController controller, bool inControlledCamera, float dt) { //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0167: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_013f: 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_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(dt, 0.0001f); if (p.inVehicleAnimation) { VehicleController val = VehicleTracker.ResolveActive(p); if ((Object)(object)val == (Object)null) { Vector3 result = (_hasLastBodyPos ? ((body.position - _lastBodyPos) / num) : Vector3.zero); _hasVehicleSpeed = false; _lastBodyPos = body.position; _hasLastBodyPos = true; return result; } Vector3 averageVelocity = val.averageVelocity; float magnitude; if (!((Object)(object)val.mainRigidbody != (Object)null)) { magnitude = ((Vector3)(ref averageVelocity)).magnitude; } else { Vector3 velocity = val.mainRigidbody.velocity; magnitude = ((Vector3)(ref velocity)).magnitude; } float num2 = magnitude; if (_hasVehicleSpeed) { float num3 = (_vehicleSpeed - num2) / num; if (num3 > 220f && _vehicleSpeed > 4f) { ConfigData.General general = ConfigManager.Data.general; float num4 = Mathf.Clamp01((num3 - 220f) / 250f); if (general.enableScreenShake && general.vehicleImpactTrauma > 0.0) { ScreenShakes.BumpTrauma((float)general.vehicleImpactTrauma * num4); } _system.AddDamageKick(new Vector3(3f * num4, 0f, 0f)); } } _vehicleSpeed = num2; _hasVehicleSpeed = true; _lastBodyPos = body.position; _hasLastBodyPos = true; return averageVelocity; } _hasLastBodyPos = false; _hasVehicleSpeed = false; VehicleTracker.ClearCachedActiveIf(p); if (!inControlledCamera) { return controller.velocity; } return Vector3.zero; } private static Vector3 RemoveVanillaDrunkSpeedScaling(Vector3 velocity, float drunkness) { //IL_0017: 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_0040: Unknown result type (might be due to invalid IL or missing references) StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || instance.drunknessSpeedEffect == null) { return velocity; } float num = instance.drunknessSpeedEffect.Evaluate(drunkness) / 5f + 1f; num = Mathf.Max(num, 0.25f); return velocity / num; } [HarmonyPostfix] [HarmonyPatch("PlayerHitGroundEffects")] private static void PlayerHitGroundEffectsPostfix(PlayerControllerB __instance) { if ((Object)(object)__instance != (Object)(object)StartOfRound.Instance?.localPlayerController) { return; } ConfigData.General general = ConfigManager.Data.general; float num = 0f - __instance.fallValue; if (!(num < 9f)) { float num2 = Mathf.Clamp01((num - 9f) / 16f); float num3 = Mathf.Max(1f, __instance.carryWeight); num2 *= 1f + (num3 - 1f) * (float)general.landingWeightInfluence; if (general.enableScreenShake && general.landingTrauma > 0.0) { ScreenShakes.BumpTrauma((float)general.landingTrauma * num2); } if (general.enableLandingDip) { _system.AddLandingImpulse(num2); } } } [HarmonyPostfix] [HarmonyPatch("DamagePlayer")] private static void DamagePlayerPostfix(PlayerControllerB __instance, int damageNumber, Vector3 force) { //IL_005f: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance != (Object)(object)StartOfRound.Instance?.localPlayerController || damageNumber <= 0) { return; } ConfigData.General general = ConfigManager.Data.general; if (general.enableScreenShake) { float num = Mathf.Clamp01((float)damageNumber / 50f); if (general.damageTrauma > 0.0) { ScreenShakes.BumpTrauma((float)general.damageTrauma * num); } Vector3 val = force; if (general.damageKick > 0.0 && ((Vector3)(ref val)).sqrMagnitude > 0.0001f) { Vector3 val2 = ((Component)__instance.gameplayCamera).transform.InverseTransformDirection(((Vector3)(ref val)).normalized); float num2 = (float)general.damageKick * num; _system.AddDamageKick(new Vector3(val2.z * num2, 0f, (0f - val2.x) * num2)); } } } private static void RestoreCamera(Transform camT) { //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_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_001a: 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) Vector3 localEulerAngles = camT.localEulerAngles; camT.localEulerAngles = new Vector3(localEulerAngles.x, localEulerAngles.y - _lastYawOffset, localEulerAngles.z - _lastRollOffset); _lastYawOffset = 0f; _lastRollOffset = 0f; } private static void ClampEffectOffset(ref Vector3 off, float basePitchEuler) { off.y = Mathf.Clamp(off.y, -60f, 60f); off.z = Mathf.Clamp(off.z, -70f, 70f); float num = NormalizeSignedAngle(basePitchEuler); if (num > 85f) { off.x = Mathf.Min(off.x, 0f); return; } if (num < -85f) { off.x = Mathf.Max(off.x, 0f); return; } float num2 = -85f - num; float num3 = 85f - num; off.x = Mathf.Clamp(off.x, num2, num3); } private static float NormalizeSignedAngle(float angle) { return Mathf.Repeat(angle + 180f, 360f) - 180f; } private static bool IsLookLocked(PlayerControllerB p) { if ((!((Object)(object)p.quickMenuManager != (Object)null) || !p.quickMenuManager.isMenuOpen) && !p.inSpecialMenu && !p.disableLookInput) { if ((Object)(object)StartOfRound.Instance != (Object)null) { return StartOfRound.Instance.newGameIsLoading; } return false; } return true; } } [HarmonyPatch(typeof(Landmine))] internal static class ExplosionShakePatch { private const float Radius = 20f; [HarmonyPostfix] [HarmonyPatch("SpawnExplosion")] private static void SpawnExplosionPostfix(Vector3 explosionPosition) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) ConfigData.General general = ConfigManager.Data.general; if (general.enableScreenShake && !(general.explosionTrauma <= 0.0)) { float num = ProximityFactor(explosionPosition, 20f); if (num > 0f) { ScreenShakes.AddTrauma((float)general.explosionTrauma * num); } } } internal static float ProximityFactor(Vector3 source, float radius) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB val = StartOfRound.Instance?.localPlayerController; if ((Object)(object)val == (Object)null) { return 0f; } float num = Vector3.Distance(((Component)val.gameplayCamera).transform.position, source); return 1f - Mathf.Clamp01(num / radius); } } [HarmonyPatch(typeof(StunGrenadeItem))] internal static class FlashbangShakePatch { private const float Radius = 30f; [HarmonyPostfix] [HarmonyPatch("StunExplosion")] private static void StunExplosionPostfix(Vector3 explosionPosition) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) ConfigData.General general = ConfigManager.Data.general; if (general.enableScreenShake && !(general.flashbangTrauma <= 0.0)) { float num = ExplosionShakePatch.ProximityFactor(explosionPosition, 30f); if (num > 0f) { ScreenShakes.AddTrauma((float)general.flashbangTrauma * num); } } } } [HarmonyPatch(typeof(ShotgunItem))] internal static class ShotgunShakePatch { [HarmonyPostfix] [HarmonyPatch("ShootGun")] private static void ShootGunPostfix(ShotgunItem __instance) { if ((Object)(object)((GrabbableObject)__instance).playerHeldBy != (Object)(object)StartOfRound.Instance?.localPlayerController) { return; } ConfigData.General general = ConfigManager.Data.general; if (general.enableWeaponShake) { if (general.weaponShakeTrauma > 0.0) { ScreenShakes.BumpTrauma((float)general.weaponShakeTrauma); } if (general.weaponRecoilKick > 0.0) { CameraPatches.System.AddRecoil(general.weaponRecoilKick); } } } } [HarmonyPatch(typeof(Shovel))] internal static class ShovelShakePatch { [HarmonyPostfix] [HarmonyPatch("HitShovel")] private static void HitShovelPostfix(Shovel __instance) { MeleeShake.Apply(((GrabbableObject)__instance).playerHeldBy, __instance.objectsHitByShovelList); } } [HarmonyPatch(typeof(KnifeItem))] internal static class KnifeShakePatch { [HarmonyPostfix] [HarmonyPatch("HitKnife")] private static void HitKnifePostfix(KnifeItem __instance, List<RaycastHit> ___objectsHitByKnifeList) { MeleeShake.Apply(__instance.previousPlayerHeldBy, ___objectsHitByKnifeList); } } internal static class MeleeShake { private const int RoomLayer = 8; private const int CollidersLayer = 11; public static void Apply(PlayerControllerB? holder, List<RaycastHit>? hits) { if ((Object)(object)holder == (Object)null || (Object)(object)holder != (Object)(object)StartOfRound.Instance?.localPlayerController) { return; } ConfigData.General general = ConfigManager.Data.general; if (general.enableMeleeWeaponShake) { float num = (Connected(hits, holder) ? 1f : ((float)general.meleeWeaponMissMultiplier)); if (general.meleeWeaponShakeTrauma > 0.0) { ScreenShakes.BumpTrauma((float)general.meleeWeaponShakeTrauma * num); } if (general.meleeWeaponRecoilKick > 0.0) { CameraPatches.System.AddRecoil(general.meleeWeaponRecoilKick * (double)num); } } } private static bool Connected(List<RaycastHit>? hits, PlayerControllerB holder) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (hits == null) { return false; } IHittable val = default(IHittable); foreach (RaycastHit hit in hits) { RaycastHit current = hit; if ((Object)(object)((RaycastHit)(ref current)).collider == (Object)null) { continue; } int layer = ((Component)((RaycastHit)(ref current)).transform).gameObject.layer; if (layer == 8 || layer == 11) { if (!((RaycastHit)(ref current)).collider.isTrigger) { return true; } } else if (((Component)((RaycastHit)(ref current)).transform).TryGetComponent<IHittable>(ref val) && (Object)(object)((RaycastHit)(ref current)).transform != (Object)(object)((Component)holder).transform) { return true; } } return false; } } [HarmonyPatch(typeof(StartOfRound))] internal static class ShipMotionTracker { public static float LandingStartRealtime = -1f; private static Collider[] _catwalkColliders = Array.Empty<Collider>(); private static Collider? _shipBoundsCollider; private static Transform? _hangarRoot; private static bool _cacheInitialized; private static float _nextCatwalkRefreshTime; private const float ShipTakeoffDuration = 15f; private const float ShipLandingDuration = 10f; private const float ShipCacheRefreshInterval = 8f; [HarmonyPostfix] [HarmonyPatch("Awake")] private static void AwakePostfix(StartOfRound __instance) { __instance.StartedLandingShip -= OnStartedLanding; __instance.StartedLandingShip += OnStartedLanding; LandingStartRealtime = -1f; _shipBoundsCollider = null; _hangarRoot = null; _catwalkColliders = Array.Empty<Collider>(); _cacheInitialized = false; _nextCatwalkRefreshTime = 0f; WarmShipReferences(__instance); } [HarmonyPostfix] [HarmonyPatch("SceneManager_OnLoadComplete1")] private static void SceneManager_OnLoadComplete1Postfix(StartOfRound __instance) { WarmShipReferences(__instance); } private static void OnStartedLanding() { LandingStartRealtime = Time.realtimeSinceStartup; } internal static void GetLocalShipShakePhases(PlayerControllerB player, out float takeoff, out float landing) { takeoff = -1f; landing = -1f; if (!ConfigManager.Data.general.enableScreenShake) { return; } StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null) { return; } bool shipIsLeaving = instance.shipIsLeaving; bool flag = LandingStartRealtime >= 0f; if ((shipIsLeaving || flag) && IsPlayerOnShipOrCatwalk(player, instance)) { float realtimeSinceStartup = Time.realtimeSinceStartup; if (shipIsLeaving) { takeoff = TakeoffPhase(realtimeSinceStartup, instance); } if (flag) { landing = LandingPhase(realtimeSinceStartup); } } } private static float TakeoffPhase(float now, StartOfRound so) { float num = now - so.timeWhenShipStartedLeaving; if (!(num >= 0f) || !(num <= 15f)) { return -1f; } return num / 15f; } private static float LandingPhase(float now) { float num = now - LandingStartRealtime; if (num >= 0f && num <= 10f) { return num / 10f; } if (num > 10f) { LandingStartRealtime = -1f; } return -1f; } private static bool IsPlayerOnShipOrCatwalk(PlayerControllerB player, StartOfRound so) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_004a: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) if (player.isInHangarShipRoom) { return true; } EnsureShipReferences(so); Vector3 val = ((Component)player).transform.position + Vector3.up * 0.25f; if ((Object)(object)_shipBoundsCollider != (Object)null) { Bounds bounds = _shipBoundsCollider.bounds; if (((Bounds)(ref bounds)).Contains(val)) { return true; } } for (int i = 0; i < _catwalkColliders.Length; i++) { Collider val2 = _catwalkColliders[i]; if (!((Object)(object)val2 == (Object)null)) { Bounds bounds2 = val2.bounds; ((Bounds)(ref bounds2)).Expand(new Vector3(0.2f, 0.7f, 0.2f)); if (((Bounds)(ref bounds2)).Contains(val)) { return true; } } } return false; } private static void WarmShipReferences(StartOfRound so) { _nextCatwalkRefreshTime = Time.realtimeSinceStartup + 8f; RebuildShipReferences(so); } private static void EnsureShipReferences(StartOfRound so) { float realtimeSinceStartup = Time.realtimeSinceStartup; if (!_cacheInitialized || !(realtimeSinceStartup < _nextCatwalkRefreshTime)) { _nextCatwalkRefreshTime = realtimeSinceStartup + 8f; RebuildShipReferences(so); } } private static void RebuildShipReferences(StartOfRound so) { _shipBoundsCollider = so.shipBounds; _hangarRoot = (Transform?)(((Object)(object)_shipBoundsCollider != (Object)null) ? ((object)((Component)_shipBoundsCollider).transform.root) : ((object)FindHangarRoot())); if ((Object)(object)_hangarRoot == (Object)null) { _catwalkColliders = Array.Empty<Collider>(); _cacheInitialized = true; return; } Collider[] componentsInChildren = ((Component)_hangarRoot).GetComponentsInChildren<Collider>(true); Collider[] array = (Collider[])(object)new Collider[componentsInChildren.Length]; int num = 0; foreach (Collider val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !val.isTrigger && HasCatwalkInHierarchy(((Component)val).transform, _hangarRoot)) { array[num++] = val; } } if (num == 0) { _catwalkColliders = Array.Empty<Collider>(); _cacheInitialized = true; } else { _catwalkColliders = (Collider[])(object)new Collider[num]; Array.Copy(array, _catwalkColliders, num); _cacheInitialized = true; } } private static Transform? FindHangarRoot() { GameObject obj = GameObject.Find("HangarShip"); object obj2 = ((obj != null) ? obj.transform : null); if (obj2 == null) { GameObject obj3 = GameObject.Find("Environment/HangarShip"); obj2 = ((obj3 != null) ? obj3.transform : null); if (obj2 == null) { GameObject obj4 = GameObject.Find("/Environment/HangarShip"); if (obj4 == null) { return null; } obj2 = obj4.transform; } } return (Transform?)obj2; } private static bool HasCatwalkInHierarchy(Transform t, Transform hangarRoot) { Transform val = t; while ((Object)(object)val != (Object)null) { if (((Object)val).name.IndexOf("catwalk", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } if ((Object)(object)val == (Object)(object)hangarRoot) { break; } val = val.parent; } return false; } } internal static class ShockTracker { public static bool BeingShocked; internal static MethodBase ResolveInterfaceMethod(string name) { InterfaceMapping interfaceMap = typeof(PlayerControllerB).GetInterfaceMap(typeof(IShockableWithGun)); for (int i = 0; i < interfaceMap.InterfaceMethods.Length; i++) { if (interfaceMap.InterfaceMethods[i].Name == name) { return interfaceMap.TargetMethods[i]; } } throw new MissingMethodException("PlayerControllerB.IShockableWithGun." + name + " not found"); } } [HarmonyPatch] internal static class ShockStartPatch { private static MethodBase TargetMethod() { return ShockTracker.ResolveInterfaceMethod("ShockWithGun"); } [HarmonyPostfix] private static void Postfix(PlayerControllerB __instance) { if ((Object)(object)__instance == (Object)(object)StartOfRound.Instance?.localPlayerController) { ShockTracker.BeingShocked = true; } } } [HarmonyPatch] internal static class ShockStopPatch { private static MethodBase TargetMethod() { return ShockTracker.ResolveInterfaceMethod("StopShockingWithGun"); } [HarmonyPostfix] private static void Postfix(PlayerControllerB __instance) { if ((Object)(object)__instance == (Object)(object)StartOfRound.Instance?.localPlayerController) { ShockTracker.BeingShocked = false; } } } [HarmonyPatch(typeof(VehicleController))] internal static class VehicleTracker { private static VehicleController? _active; [HarmonyPostfix] [HarmonyPatch("Update")] private static void UpdatePostfix(VehicleController __instance) { PlayerControllerB localPlayer = StartOfRound.Instance?.localPlayerController; if (IsPlayerInVehicle(localPlayer, __instance)) { _active = __instance; } else if ((Object)(object)_active == (Object)(object)__instance) { _active = null; } } public static VehicleController? ResolveActive(PlayerControllerB? localPlayer) { if (!IsPlayerInVehicle(localPlayer, _active)) { return null; } return _active; } public static void ClearCachedActiveIf(PlayerControllerB? localPlayer) { if (!IsPlayerInVehicle(localPlayer, _active)) { _active = null; } } public static void Reset() { _active = null; } private static bool IsPlayerInVehicle(PlayerControllerB? localPlayer, VehicleController? vehicle) { if ((Object)(object)localPlayer == (Object)null || (Object)(object)vehicle == (Object)null) { return false; } if (!((Object)(object)vehicle.currentDriver == (Object)(object)localPlayer) && !((Object)(object)vehicle.currentPassenger == (Object)(object)localPlayer) && !vehicle.localPlayerInControl) { return vehicle.localPlayerInPassengerSeat; } return true; } } [BepInPlugin("com.seeya.cameraoverhaul", "Camera Overhaul", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { private readonly Harmony _harmony = new Harmony("com.seeya.cameraoverhaul"); public static Plugin Instance { get; private set; } public static ManualLogSource Log { get; private set; } private void Awake() { Instance = this; Log = ((BaseUnityPlugin)this).Logger; Log.Log