Decompiled source of WiresStableFirelight v1.0.0

WiresStableFirelight.dll

Decompiled 3 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("WiresStableFirelight")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("WiresStableFirelight")]
[assembly: AssemblyTitle("WiresStableFirelight")]
[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 WiresStableFirelight
{
	[BepInPlugin("wire.valheim.stablefirelight", "Wire's Stable Firelight", "1.0.0")]
	public sealed class StableFirelightPlugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(LightFlicker), "Awake")]
		private static class LightFlickerAwakePatch
		{
			private static void Postfix(LightFlicker __instance)
			{
				if (!((Object)(object)__instance == (Object)null) && !((Object)(object)((Component)__instance).GetComponentInParent<Fireplace>() == (Object)null))
				{
					float num = Mathf.Clamp(MovementReductionPercent.Value, 0f, 100f);
					__instance.m_movement *= 1f - num / 100f;
				}
			}
		}

		public const string PluginGuid = "wire.valheim.stablefirelight";

		public const string PluginName = "Wire's Stable Firelight";

		public const string PluginVersion = "1.0.0";

		internal static ConfigEntry<float> MovementReductionPercent;

		private Harmony _harmony;

		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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			MovementReductionPercent = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Light movement reduction", 90f, new ConfigDescription("How much positional light movement to remove. 0 = vanilla movement, 100 = completely stationary light position.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
			_harmony = new Harmony("wire.valheim.stablefirelight");
			_harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Wire's Stable Firelight 1.0.0 loaded. Light movement reduction: " + MovementReductionPercent.Value + "%."));
		}

		private void OnDestroy()
		{
			if (_harmony != null)
			{
				_harmony.UnpatchSelf();
			}
		}
	}
}