Decompiled source of Niflheim NoHeatWave v1.1.0

NoHeatWave.dll

Decompiled 29 minutes ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
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: AssemblyVersion("0.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 NoHeatWave
{
	[BepInPlugin("niflheim.noheatwave", "NoHeatWave", "1.1.0")]
	public class NoHeatWavePlugin : BaseUnityPlugin
	{
		public const string Guid = "niflheim.noheatwave";

		public const string Version = "1.1.0";

		internal static ConfigEntry<float> Strength;

		private void Awake()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			Strength = ((BaseUnityPlugin)this).Config.Bind<float>("General", "HeatWaveStrength", 0f, new ConfigDescription("How much Ashlands heat shimmer to keep. 0 removes it, 1 is vanilla, 0.25 leaves a hint of it. Local only: nothing is sent to the server, nothing is synced from it.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			new Harmony("niflheim.noheatwave").PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)("NoHeatWave 1.1.0 loaded, strength " + Strength.Value));
		}
	}
	[HarmonyPatch(typeof(HeatDistortImageEffect), "OnRenderImage")]
	internal static class ScaleHeatDistort
	{
		private static readonly FieldRef<HeatDistortImageEffect, float> Distortion = AccessTools.FieldRefAccess<HeatDistortImageEffect, float>("m_distortionStrength");

		private static readonly FieldRef<HeatDistortImageEffect, float> Vignette = AccessTools.FieldRefAccess<HeatDistortImageEffect, float>("m_vignetteStrength");

		private static bool _scaled;

		private static float _intensity;

		private static float _distortion;

		private static float _vignette;

		private static bool Prefix(HeatDistortImageEffect __instance, RenderTexture source, RenderTexture destination)
		{
			if (NoHeatWavePlugin.Strength == null)
			{
				return true;
			}
			float value = NoHeatWavePlugin.Strength.Value;
			if (value >= 0.999f)
			{
				return true;
			}
			if (value <= 0f)
			{
				Graphics.Blit((Texture)(object)source, destination);
				return false;
			}
			_intensity = __instance.m_intensity;
			_distortion = Distortion.Invoke(__instance);
			_vignette = Vignette.Invoke(__instance);
			_scaled = true;
			__instance.m_intensity *= value;
			Distortion.Invoke(__instance) *= value;
			Vignette.Invoke(__instance) *= value;
			return true;
		}

		private static void Finalizer(HeatDistortImageEffect __instance)
		{
			if (_scaled)
			{
				_scaled = false;
				__instance.m_intensity = _intensity;
				Distortion.Invoke(__instance) = _distortion;
				Vignette.Invoke(__instance) = _vignette;
			}
		}
	}
}