Decompiled source of WiresCameraTweaks v0.1.0

WiresCameraTweaks.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("WiresCameraTweaks")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("WiresCameraTweaks")]
[assembly: AssemblyTitle("WiresCameraTweaks")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[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 WiresShakeItUp
{
	internal static class ZoomEngine
	{
		internal struct Capture
		{
			internal bool Active;

			internal float Target;
		}

		private sealed class State
		{
			internal bool Initialized;

			internal float Visual;
		}

		private static readonly FieldRef<GameCamera, float> Distance = AccessTools.FieldRefAccess<GameCamera, float>("m_distance");

		private static ConditionalWeakTable<GameCamera, State> States = new ConditionalWeakTable<GameCamera, State>();

		internal static Capture Begin(GameCamera camera, float dt)
		{
			Capture result = default(Capture);
			if ((Object)(object)camera == (Object)null || ModConfig.SmoothZoomEnabled == null || !ModConfig.SmoothZoomEnabled.Value || (Object)(object)Player.m_localPlayer == (Object)null || ((Character)Player.m_localPlayer).InIntro())
			{
				return result;
			}
			float num = Distance.Invoke(camera);
			State orCreateValue = States.GetOrCreateValue(camera);
			if (!orCreateValue.Initialized)
			{
				orCreateValue.Initialized = true;
				orCreateValue.Visual = num;
			}
			orCreateValue.Visual = EaseToward(orCreateValue.Visual, num, dt, ModConfig.ZoomResponse.Value);
			result.Active = true;
			result.Target = num;
			Distance.Invoke(camera) = orCreateValue.Visual;
			return result;
		}

		internal static void End(GameCamera camera, Capture capture)
		{
			if (capture.Active && (Object)(object)camera != (Object)null)
			{
				Distance.Invoke(camera) = capture.Target;
			}
		}

		internal static float EaseToward(float current, float target, float dt, float response)
		{
			float num = Mathf.Sin(Mathf.Clamp01(Mathf.Max(0f, dt) * Mathf.Max(0.01f, response)) * (float)Math.PI * 0.5f);
			float num2 = Mathf.Lerp(current, target, num);
			if (Mathf.Abs(num2 - target) < 0.002f)
			{
				num2 = target;
			}
			return num2;
		}

		internal static void Reset()
		{
			States = new ConditionalWeakTable<GameCamera, State>();
		}
	}
	internal static class CollisionAutoZoomEngine
	{
		internal struct Capture
		{
			internal Vector3 OffsetEye;

			internal Vector3 RequestedEnd;
		}

		private sealed class State
		{
			internal bool Active;

			internal float VisualDistance;

			internal int LastFrame = -1000;
		}

		private const float CollisionEpsilon = 0.015f;

		private static ConditionalWeakTable<GameCamera, State> States = new ConditionalWeakTable<GameCamera, State>();

		internal static Capture Begin(Vector3 offsetEye, Vector3 requestedEnd)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return new Capture
			{
				OffsetEye = offsetEye,
				RequestedEnd = requestedEnd
			};
		}

		internal static void End(GameCamera camera, ref Vector3 end, Capture capture)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: 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_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_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: 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)
			if ((Object)(object)camera == (Object)null || ModConfig.CollisionAutoZoomEnabled == null || !ModConfig.CollisionAutoZoomEnabled.Value)
			{
				return;
			}
			Vector3 val = capture.RequestedEnd - capture.OffsetEye;
			float magnitude = ((Vector3)(ref val)).magnitude;
			if (magnitude <= 0.001f)
			{
				return;
			}
			float num = Mathf.Clamp(Vector3.Distance(capture.OffsetEye, end), 0f, magnitude);
			bool flag = num < magnitude - 0.015f;
			State orCreateValue = States.GetOrCreateValue(camera);
			if (Time.frameCount - orCreateValue.LastFrame > 2)
			{
				orCreateValue.Active = false;
				orCreateValue.VisualDistance = num;
			}
			orCreateValue.LastFrame = Time.frameCount;
			if (!orCreateValue.Active)
			{
				if (flag)
				{
					orCreateValue.Active = true;
					orCreateValue.VisualDistance = num;
				}
				return;
			}
			if (num < orCreateValue.VisualDistance)
			{
				orCreateValue.VisualDistance = num;
			}
			else
			{
				orCreateValue.VisualDistance = ZoomEngine.EaseToward(orCreateValue.VisualDistance, num, Time.unscaledDeltaTime, ModConfig.CollisionAutoZoomResponse.Value);
			}
			if (!flag && Mathf.Abs(orCreateValue.VisualDistance - magnitude) < 0.002f)
			{
				orCreateValue.VisualDistance = magnitude;
				orCreateValue.Active = false;
			}
			else
			{
				end = capture.OffsetEye + val / magnitude * Mathf.Min(orCreateValue.VisualDistance, num);
			}
		}

		internal static void Reset()
		{
			States = new ConditionalWeakTable<GameCamera, State>();
		}
	}
	[HarmonyPatch]
	internal static class CameraPositionPatch
	{
		private static MethodBase TargetMethod()
		{
			return AccessTools.DeclaredMethod(typeof(GameCamera), "GetCameraPosition", new Type[3]
			{
				typeof(float),
				typeof(Vector3).MakeByRefType(),
				typeof(Quaternion).MakeByRefType()
			}, (Type[])null);
		}

		[HarmonyPrefix]
		private static void Prefix(GameCamera __instance, float dt, out ZoomEngine.Capture __state)
		{
			__state = ZoomEngine.Begin(__instance, dt);
		}

		[HarmonyPostfix]
		private static void Postfix(GameCamera __instance, ZoomEngine.Capture __state)
		{
			ZoomEngine.End(__instance, __state);
		}
	}
	[HarmonyPatch(typeof(GameCamera), "CollideRay2")]
	internal static class CollisionAutoZoomPatch
	{
		[HarmonyPrefix]
		private static void Prefix(Vector3 offsetedEyePos, Vector3 end, out CollisionAutoZoomEngine.Capture __state)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			__state = CollisionAutoZoomEngine.Begin(offsetedEyePos, end);
		}

		[HarmonyPostfix]
		private static void Postfix(GameCamera __instance, ref Vector3 end, CollisionAutoZoomEngine.Capture __state)
		{
			CollisionAutoZoomEngine.End(__instance, ref end, __state);
		}
	}
	internal static class ModConfig
	{
		internal static ConfigEntry<bool> ShakeEnabled;

		internal static ConfigEntry<float> OverallStrength;

		internal static ConfigEntry<float> RumbleStrength;

		internal static ConfigEntry<float> ImpactStrength;

		internal static ConfigEntry<float> ImpactDuration;

		internal static ConfigEntry<float> LongShakeSoftening;

		internal static ConfigEntry<float> MaxRumbleDegrees;

		internal static ConfigEntry<float> FrequencyMultiplier;

		internal static ConfigEntry<float> SecondaryMotion;

		internal static ConfigEntry<float> PositionShake;

		internal static ConfigEntry<float> RollStrength;

		internal static ConfigEntry<bool> DirectionalImpact;

		internal static ConfigEntry<float> ImpactThreshold;

		internal static ConfigEntry<bool> SmoothZoomEnabled;

		internal static ConfigEntry<float> ZoomResponse;

		internal static ConfigEntry<bool> CollisionAutoZoomEnabled;

		internal static ConfigEntry<float> CollisionAutoZoomResponse;

		internal static void Bind(ConfigFile file)
		{
			ConfigEntry<bool> val = file.Bind<bool>("General", "Enabled", true, "Legacy migration value.");
			ConfigEntry<float> val2 = file.Bind<float>("General", "Overall Strength", 0.5f, "Legacy migration value.");
			ConfigEntry<float> val3 = file.Bind<float>("Rumble", "Rumble Strength", 0.85f, "Legacy migration value.");
			ConfigEntry<float> val4 = file.Bind<float>("Rumble", "Long Shake Softening", 0.8f, "Legacy migration value.");
			ConfigEntry<float> val5 = file.Bind<float>("Rumble", "Max Rumble Degrees", 1.25f, "Legacy migration value.");
			ConfigEntry<float> val6 = file.Bind<float>("Rumble", "Frequency Multiplier", 0.9f, "Legacy migration value.");
			ConfigEntry<float> val7 = file.Bind<float>("Rumble", "Secondary Motion", 0.18f, "Legacy migration value.");
			ConfigEntry<float> val8 = file.Bind<float>("Rumble", "Position Shake", 0.018f, "Legacy migration value.");
			ConfigEntry<float> val9 = file.Bind<float>("Impact", "Impact Strength", 1f, "Legacy migration value.");
			ConfigEntry<float> val10 = file.Bind<float>("Impact", "Impact Duration", 0.18f, "Legacy migration value.");
			ConfigEntry<float> val11 = file.Bind<float>("Impact", "Impact Threshold", 0.12f, "Legacy migration value.");
			ConfigEntry<bool> val12 = file.Bind<bool>("Impact", "Directional Impact", true, "Legacy migration value.");
			ConfigEntry<float> val13 = file.Bind<float>("Impact", "Roll Strength", 0f, "Legacy migration value.");
			bool value = val.Value;
			float value2 = val2.Value;
			float value3 = val3.Value;
			float value4 = val4.Value;
			float value5 = val5.Value;
			float value6 = val6.Value;
			float value7 = val7.Value;
			float value8 = val8.Value;
			float value9 = val9.Value;
			float value10 = val10.Value;
			float value11 = val11.Value;
			bool value12 = val12.Value;
			float value13 = val13.Value;
			file.Remove(((ConfigEntryBase)val).Definition);
			file.Remove(((ConfigEntryBase)val2).Definition);
			file.Remove(((ConfigEntryBase)val3).Definition);
			file.Remove(((ConfigEntryBase)val4).Definition);
			file.Remove(((ConfigEntryBase)val5).Definition);
			file.Remove(((ConfigEntryBase)val6).Definition);
			file.Remove(((ConfigEntryBase)val7).Definition);
			file.Remove(((ConfigEntryBase)val8).Definition);
			file.Remove(((ConfigEntryBase)val9).Definition);
			file.Remove(((ConfigEntryBase)val10).Definition);
			file.Remove(((ConfigEntryBase)val11).Definition);
			file.Remove(((ConfigEntryBase)val12).Definition);
			file.Remove(((ConfigEntryBase)val13).Definition);
			Remove(file, "2 - Collision", "Enabled");
			Remove(file, "2 - Collision", "Recovery Response");
			Remove(file, "2 - Collision", "Release Delay");
			Remove(file, "3 - Occlusion", "Enabled");
			Remove(file, "3 - Occlusion", "Fade Occluders");
			Remove(file, "3 - Occlusion", "Occluder Alpha");
			Remove(file, "3 - Occlusion", "Dither Occluders");
			Remove(file, "3 - Occlusion", "Dither Visibility");
			Remove(file, "3 - Occlusion", "Fade Response");
			Remove(file, "3 - Occlusion", "Ignore Small Obstacles");
			Remove(file, "3 - Occlusion", "Small Obstacle Max Volume");
			Remove(file, "3 - Occlusion", "Thin Obstacle Max Thickness");
			Remove(file, "3 - Player Follow", "Enabled");
			Remove(file, "3 - Player Follow", "Maximum Lag Distance");
			Remove(file, "3 - Player Follow", "Response");
			Remove(file, "3 - Player Follow", "Maximum Horizontal Lag");
			Remove(file, "3 - Player Follow", "Vertical Response");
			Remove(file, "3 - Player Follow", "Maximum Vertical Lag");
			Remove(file, "3 - Player Follow", "Horizontal Catch-up Response");
			Remove(file, "3 - Player Follow", "Horizontal Deadzone");
			Remove(file, "3 - Player Follow", "Maximum Horizontal Lead");
			Remove(file, "3 - Player Follow", "Vertical Catch-up Response");
			Remove(file, "3 - Player Follow", "Vertical Deadzone");
			Remove(file, "3 - Player Follow", "Maximum Vertical Lead");
			Remove(file, "4 - Zoom", "Enabled");
			Remove(file, "4 - Zoom", "Response");
			Remove(file, "5 - Motion", "Enabled");
			Remove(file, "5 - Motion", "Strafe Roll");
			Remove(file, "5 - Motion", "Turn Roll");
			Remove(file, "5 - Motion", "Response");
			Remove(file, "5 - Motion", "Roll Response");
			Remove(file, "5 - Motion", "Camera Lag Distance");
			Remove(file, "5 - Motion", "Camera Lag Response");
			ShakeEnabled = file.Bind<bool>("1 - Shake", "Enabled", value, "Enable the Wire's Shake It Up camera-shake rework.");
			OverallStrength = Float(file, "1 - Shake", "Overall Strength", value2, 0f, 2f, "Master multiplier for camera shake.");
			RumbleStrength = Float(file, "1 - Shake", "Rumble Strength", value3, 0f, 2f, "Strength of sustained shake after the initial impact.");
			LongShakeSoftening = Float(file, "1 - Shake", "Long Shake Softening", value4, 0f, 1f, "Prevents long vanilla shakes from becoming absurdly strong.");
			MaxRumbleDegrees = Float(file, "1 - Shake", "Max Rumble Degrees", value5, 0.1f, 4f, "Approximate cap for sustained rotational shake.");
			FrequencyMultiplier = Float(file, "1 - Shake", "Frequency Multiplier", value6, 0.25f, 2f, "Speed of sustained shake.");
			SecondaryMotion = Float(file, "1 - Shake", "Secondary Motion", value7, 0f, 1f, "Subtle second motion layer for less mechanical shake.");
			PositionShake = Float(file, "1 - Shake", "Position Shake", value8, 0f, 0.08f, "Small positional shake in metres.");
			ImpactStrength = Float(file, "1 - Shake", "Impact Strength", value9, 0f, 2f, "Strength of the short initial impact punch.");
			ImpactDuration = Float(file, "1 - Shake", "Impact Duration", value10, 0.05f, 0.5f, "Length of the initial impact kick.");
			ImpactThreshold = Float(file, "1 - Shake", "Impact Threshold", value11, 0f, 1f, "Tiny shakes below this strength do not receive an extra impact.");
			DirectionalImpact = file.Bind<bool>("1 - Shake", "Directional Impact", value12, "Bias the initial kick away from the shake source.");
			RollStrength = Float(file, "1 - Shake", "Roll Strength", value13, 0f, 1f, "Roll added to impacts. Zero avoids nausea.");
			SmoothZoomEnabled = file.Bind<bool>("2 - Smooth Zoom", "Enabled", true, "Smooth manual mouse-wheel/controller zoom.");
			ZoomResponse = Float(file, "2 - Smooth Zoom", "Manual Zoom Response", 18f, 5f, 40f, "How quickly manual zoom catches the requested target.");
			CollisionAutoZoomEnabled = file.Bind<bool>("2 - Smooth Zoom", "Smooth Collision Auto Zoom", true, "Smooth the automatic zoom-out recovery after Valheim collision forces the camera closer. Collision moving inward remains immediate.");
			CollisionAutoZoomResponse = Float(file, "2 - Smooth Zoom", "Automatic Zoom Response", 14f, 4f, 35f, "How quickly collision-forced camera distance eases back outward.");
			Hook<bool>(ShakeEnabled);
			Hook<float>(OverallStrength);
			Hook<float>(RumbleStrength);
			Hook<float>(ImpactStrength);
			Hook<float>(ImpactDuration);
			Hook<float>(LongShakeSoftening);
			Hook<float>(MaxRumbleDegrees);
			Hook<float>(FrequencyMultiplier);
			Hook<float>(SecondaryMotion);
			Hook<float>(PositionShake);
			Hook<float>(RollStrength);
			Hook<bool>(DirectionalImpact);
			Hook<float>(ImpactThreshold);
			Hook<bool>(SmoothZoomEnabled);
			Hook<bool>(CollisionAutoZoomEnabled);
		}

		private static ConfigEntry<float> Float(ConfigFile file, string section, string key, float value, float min, float max, string description)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			return file.Bind<float>(section, key, value, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<float>(min, max), Array.Empty<object>()));
		}

		private static void Remove(ConfigFile file, string section, string key)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			file.Remove(new ConfigDefinition(section, key));
		}

		private static void Hook<T>(ConfigEntry<T> entry)
		{
			entry.SettingChanged += delegate
			{
				ShakeEngine.ResetTransient();
				ZoomEngine.Reset();
				CollisionAutoZoomEngine.Reset();
			};
		}
	}
	[HarmonyPatch(typeof(GameCamera), "Awake")]
	internal static class GameCameraAwakePatch
	{
		[HarmonyPostfix]
		private static void Postfix()
		{
			ShakeEngine.ResetTransient();
		}
	}
	[HarmonyPatch(typeof(GameCamera), "GetAttenuatedShakeIntensity")]
	internal static class ShakeAmplitudePatch
	{
		[HarmonyPostfix]
		private static void Postfix(GameCamera __instance, ref float __result)
		{
			__result = ShakeEngine.ShapeRumble(__instance, __result);
		}
	}
	[HarmonyPatch(typeof(GameCamera), "AddShake")]
	internal static class AddShakePatch
	{
		[HarmonyPrefix]
		private static void Prefix(GameCamera __instance, out float __state)
		{
			__state = ShakeEngine.CurrentIntensity(__instance);
		}

		[HarmonyPostfix]
		private static void Postfix(GameCamera __instance, Vector3 point, float range, float strength, float __state)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			ShakeEngine.ObserveShake(__instance, point, range, strength, __state);
		}
	}
	[HarmonyPatch(typeof(GameCamera), "UpdateCameraShake")]
	internal static class UpdateCameraShakePatch
	{
		[HarmonyPrefix]
		private static void Prefix(GameCamera __instance, out float __state)
		{
			__state = __instance.m_shakeFreq;
			if (ShakeEngine.Enabled(__instance))
			{
				__instance.m_shakeFreq = __state * ModConfig.FrequencyMultiplier.Value;
			}
		}

		[HarmonyPostfix]
		private static void Postfix(GameCamera __instance, float dt, float __state)
		{
			try
			{
				ShakeEngine.AfterCameraShake(__instance, dt);
			}
			finally
			{
				__instance.m_shakeFreq = __state;
			}
		}
	}
	[BepInPlugin("wire.valheim.shakeitup", "Wire's Camera Tweaks", "0.1.0")]
	[BepInProcess("valheim.exe")]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string Guid = "wire.valheim.shakeitup";

		public const string Name = "Wire's Camera Tweaks";

		public const string Version = "0.1.0";

		internal static Plugin Instance;

		private Harmony _harmony;

		private void Awake()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			Instance = this;
			ModConfig.Bind(((BaseUnityPlugin)this).Config);
			_harmony = new Harmony("wire.valheim.shakeitup");
			_harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Wire's Camera Tweaks 0.1.0 loaded.");
		}

		private void OnDestroy()
		{
			ShakeEngine.Reset();
			ZoomEngine.Reset();
			CollisionAutoZoomEngine.Reset();
			if (_harmony != null)
			{
				_harmony.UnpatchSelf();
			}
			Instance = null;
		}
	}
	internal static class ShakeEngine
	{
		private static readonly FieldRef<GameCamera, float> ShakeIntensity = AccessTools.FieldRefAccess<GameCamera, float>("m_shakeIntensity");

		private static readonly FieldRef<GameCamera, bool> CameraShakeEnabled = AccessTools.FieldRefAccess<GameCamera, bool>("m_cameraShakeEnabled");

		private static float _phase;

		private static float _kickRemaining;

		private static float _kickDuration;

		private static float _kickPitch;

		private static float _kickYaw;

		private static float _kickRoll;

		private static float _lastAcceptedCall = -999f;

		private static float _lastImpactTime = -999f;

		private static Vector3 _lastSource;

		private static bool _hasLastSource;

		internal static float CurrentIntensity(GameCamera camera)
		{
			if (!((Object)(object)camera == (Object)null))
			{
				return ShakeIntensity.Invoke(camera);
			}
			return 0f;
		}

		internal static bool IsCameraShakeEnabled(GameCamera camera)
		{
			if ((Object)(object)camera != (Object)null)
			{
				return CameraShakeEnabled.Invoke(camera);
			}
			return false;
		}

		internal static float ShapeRumble(GameCamera camera, float vanillaAmplitude)
		{
			if (!Enabled(camera))
			{
				return vanillaAmplitude;
			}
			float num = Mathf.Max(0f, CurrentIntensity(camera));
			if (num <= 0f)
			{
				return 0f;
			}
			float num2;
			if (num <= 1f)
			{
				num2 = num * num * num;
			}
			else
			{
				float value = ModConfig.LongShakeSoftening.Value;
				num2 = 1f + (num - 1f) * (1f - value);
				num2 = Mathf.Min(num2, ModConfig.MaxRumbleDegrees.Value);
			}
			return num2 * ModConfig.RumbleStrength.Value * ModConfig.OverallStrength.Value;
		}

		internal static void ObserveShake(GameCamera camera, Vector3 point, float range, float strength, float previousIntensity)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			if (!Enabled(camera) || range <= 0f)
			{
				return;
			}
			float num = Vector3.Distance(point, ((Component)camera).transform.position);
			if (num > range)
			{
				return;
			}
			num = Mathf.Max(1f, num);
			float num2 = strength * (1f - num / range);
			if (!(num2 < ModConfig.ImpactThreshold.Value) && !(num2 + 0.0001f < previousIntensity))
			{
				float unscaledTime = Time.unscaledTime;
				bool flag = unscaledTime - _lastAcceptedCall > 0.16f;
				int num3;
				if (_hasLastSource)
				{
					Vector3 val = point - _lastSource;
					num3 = ((((Vector3)(ref val)).sqrMagnitude > 4f) ? 1 : 0);
				}
				else
				{
					num3 = 1;
				}
				bool flag2 = (byte)num3 != 0;
				bool flag3 = num2 > previousIntensity + Mathf.Max(0.08f, previousIntensity * 0.12f);
				if (unscaledTime - _lastImpactTime > 0.075f && (flag || flag2 || flag3))
				{
					StartImpact(camera, point, num2, unscaledTime);
				}
				_lastAcceptedCall = unscaledTime;
				_lastSource = point;
				_hasLastSource = true;
			}
		}

		private static void StartImpact(GameCamera camera, Vector3 point, float effective, float now)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Clamp(0.15f + 0.55f * Mathf.Sqrt(Mathf.Max(0f, effective)), 0f, 1.2f);
			num *= ModConfig.ImpactStrength.Value * ModConfig.OverallStrength.Value;
			_kickDuration = ModConfig.ImpactDuration.Value;
			_kickRemaining = _kickDuration;
			Vector3 val = point - ((Component)camera).transform.position;
			Vector3 val2 = Vector3.zero;
			if (((Vector3)(ref val)).sqrMagnitude > 0.0001f)
			{
				val2 = ((Component)camera).transform.InverseTransformDirection(((Vector3)(ref val)).normalized);
			}
			float num2 = ((Mathf.Sin(point.x * 12.9898f + point.z * 78.233f + now * 3.173f) >= 0f) ? 1f : (-1f));
			if (ModConfig.DirectionalImpact.Value)
			{
				_kickYaw = num * ((0f - val2.x) * 0.55f + num2 * 0.12f);
				_kickPitch = (0f - num) * (0.68f - val2.y * 0.16f);
			}
			else
			{
				_kickYaw = num2 * num * 0.32f;
				_kickPitch = (0f - num) * 0.68f;
			}
			_kickRoll = num2 * num * 0.18f * ModConfig.RollStrength.Value;
			_lastImpactTime = now;
		}

		internal static void AfterCameraShake(GameCamera camera, float dt)
		{
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			if (!Enabled(camera))
			{
				return;
			}
			if (!IsCameraShakeEnabled(camera))
			{
				_kickRemaining = 0f;
				return;
			}
			float num = Mathf.Max(0f, CurrentIntensity(camera));
			float num2 = ShapeRumble(camera, 0f) * camera.m_shakeMovement;
			float num3 = Mathf.InverseLerp(1f, 3f, num);
			float num4 = Mathf.Lerp(1.08f, 0.72f, num3);
			_phase += dt * camera.m_shakeFreq * num4;
			float num5 = num2 * ModConfig.SecondaryMotion.Value;
			float num6 = Mathf.Sin(_phase * 1.73f + 0.4f) * num5 * 0.42f;
			float num7 = Mathf.Cos(_phase * 1.37f + 1.1f) * num5 * 0.35f;
			float num8 = Mathf.Sin(_phase * 0.91f + 2.2f) * num5 * 0.08f * ModConfig.RollStrength.Value;
			if (_kickRemaining > 0f && _kickDuration > 0f)
			{
				float num9 = Mathf.Clamp01(_kickRemaining / _kickDuration);
				float num10 = num9 * num9 * (3f - 2f * num9);
				num6 += _kickPitch * num10;
				num7 += _kickYaw * num10;
				num8 += _kickRoll * num10;
				_kickRemaining = Mathf.Max(0f, _kickRemaining - dt);
			}
			if (Mathf.Abs(num6) > 0.0001f || Mathf.Abs(num7) > 0.0001f || Mathf.Abs(num8) > 0.0001f)
			{
				((Component)camera).transform.rotation = ((Component)camera).transform.rotation * Quaternion.Euler(num6, num7, num8);
			}
			float num11 = ModConfig.PositionShake.Value * ModConfig.OverallStrength.Value * Mathf.Clamp01(num2);
			if (num11 > 1E-05f)
			{
				Vector3 val = ((Component)camera).transform.right * (Mathf.Sin(_phase * 0.83f + 0.2f) * num11) + ((Component)camera).transform.up * (Mathf.Cos(_phase * 1.11f + 1.7f) * num11 * 0.55f);
				Transform transform = ((Component)camera).transform;
				transform.position += val;
			}
		}

		internal static bool Enabled(GameCamera camera)
		{
			if ((Object)(object)camera != (Object)null && ModConfig.ShakeEnabled != null)
			{
				return ModConfig.ShakeEnabled.Value;
			}
			return false;
		}

		internal static void ResetTransient()
		{
			//IL_0050: 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)
			_phase = 0f;
			_kickRemaining = 0f;
			_kickDuration = 0f;
			_kickPitch = 0f;
			_kickYaw = 0f;
			_kickRoll = 0f;
			_lastAcceptedCall = -999f;
			_lastImpactTime = -999f;
			_lastSource = Vector3.zero;
			_hasLastSource = false;
		}

		internal static void Reset()
		{
			ResetTransient();
		}
	}
}