Decompiled source of SimpleExtendedComfortRange v1.0.0

SimpleExtendedComfortRange.dll

Decompiled 3 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("SimpleExtendedComfortRange")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SimpleExtendedComfortRange")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("df744729-17eb-4aa7-b039-708057cb8350")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace SimpleExtendedComfortRange;

[BepInPlugin("com.robit.simpleextendedcomfortrange", "Simple Extended Comfort Range", "1.0.0")]
public class SimpleExtendedComfortRangePlugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(SE_Rested), "GetNearbyComfortPieces")]
	private static class ComfortRangePatch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			foreach (CodeInstruction instruction in instructions)
			{
				if (instruction.opcode == OpCodes.Ldc_R4 && instruction.operand is float num && Math.Abs(num - 10f) < 0.001f)
				{
					instruction.opcode = OpCodes.Call;
					instruction.operand = AccessTools.Method(typeof(SimpleExtendedComfortRangePlugin), "GetComfortRadius", (Type[])null, (Type[])null);
				}
				yield return instruction;
			}
		}
	}

	private static ConfigEntry<float> ComfortRadius;

	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
		ComfortRadius = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ComfortRadius", 30f, new ConfigDescription("Maximum distance in meters that comfort items can contribute to your comfort level.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 100f), Array.Empty<object>()));
		_harmony = new Harmony("com.robit.simpleextendedcomfortrange");
		_harmony.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)$"Extended Comfort Range loaded. Comfort radius: {ComfortRadius.Value}m");
	}

	private static float GetComfortRadius()
	{
		return ComfortRadius.Value;
	}
}