Decompiled source of InstantRested v1.0.0

BepInEx/plugins/InstantRested.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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Dedryx")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright © Dedryx 2026")]
[assembly: AssemblyDescription("Reduces the delay before receiving the normal Rested buff while preserving vanilla resting requirements.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("InstantRested")]
[assembly: AssemblyTitle("InstantRested")]
[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 InstantRested
{
	[BepInPlugin("dedryx.instantrested", "InstantRested", "1.0.0")]
	[BepInProcess("valheim.exe")]
	public sealed class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(SE_Cozy), "UpdateStatusEffect")]
		private static class RestingDelayPatch
		{
			private static void Prefix(SE_Cozy __instance)
			{
				Player localPlayer = Player.m_localPlayer;
				if (!((Object)(object)localPlayer == (Object)null) && !((Object)(object)((StatusEffect)__instance).m_character != (Object)(object)localPlayer) && ((StatusEffect)__instance).NameHash() == SEMan.s_statusEffectResting && !(__instance.m_statusEffect != "Rested") && (object)((Character)localPlayer).GetSEMan().GetStatusEffect(SEMan.s_statusEffectResting) == __instance)
				{
					float value = restDelaySeconds.Value;
					__instance.m_delay = (float.IsNaN(value) ? 1f : Mathf.Clamp(value, 0.1f, 20f));
				}
			}
		}

		private static ConfigEntry<float> restDelaySeconds;

		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)
			restDelaySeconds = ((BaseUnityPlugin)this).Config.Bind<float>("General", "RestDelaySeconds", 1f, new ConfigDescription("Seconds in vanilla Resting before vanilla Rested is granted. Changes apply immediately.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 20f), Array.Empty<object>()));
			new Harmony("dedryx.instantrested").PatchAll(typeof(Plugin).Assembly);
		}
	}
}