Decompiled source of ExplorerIronPit v1.0.0

plugins/IronFirePitForExplorers.dll

Decompiled 3 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("IronFirePitForExplorers")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("IronFirePitForExplorers")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("dcfbad94-3490-4284-985d-a36bc82c8090")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MyBepInExPlugin;

[BepInPlugin("Durinson.IronFirePitForExplorers", "Iron fire pit for explorers", "1.0.0")]
public class Main : BaseUnityPlugin
{
	[HarmonyPatch(typeof(SE_Rested), "CalculateComfortLevel", new Type[]
	{
		typeof(bool),
		typeof(Vector3)
	})]
	public static class ComfortPatch
	{
		private static void Postfix(bool inShelter, Vector3 position, ref int __result)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			if (__result > 4)
			{
				return;
			}
			Collider[] array = Physics.OverlapSphere(position, 10f);
			Collider[] array2 = array;
			foreach (Collider val in array2)
			{
				Piece componentInParent = ((Component)val).GetComponentInParent<Piece>();
				if ((Object)(object)componentInParent != (Object)null && ((Object)componentInParent).name.ToLower().Contains("fire_pit_iron"))
				{
					logger.LogInfo((object)"Iron Fire Pit low comfort bonus applied.");
					__result += 7;
					break;
				}
			}
		}
	}

	[HarmonyPatch(typeof(ObjectDB), "Awake")]
	public static class ObjectDB_Awake_Patch
	{
		private static void Postfix()
		{
			GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("Ironpit");
			if ((Object)(object)itemPrefab == (Object)null)
			{
				logger.LogInfo((object)"Iron pit prefab not found");
				return;
			}
			ItemDrop component = itemPrefab.GetComponent<ItemDrop>();
			if ((Object)(object)component == (Object)null)
			{
				logger.LogInfo((object)"ItemDrop not found");
				return;
			}
			component.m_itemData.m_shared.m_teleportable = true;
			logger.LogInfo((object)"Iron pit is now teleportable");
			component.m_itemData.m_shared.m_description = "A trusty fire pit for nomads and explorers.";
			logger.LogInfo((object)"Iron pit description modified.");
		}
	}

	private const string pluginGUID = "Durinson.IronFirePitForExplorers";

	private const string pluginName = "Iron fire pit for explorers";

	private const string pluginVersion = "1.0.0";

	private readonly Harmony HarmonyInstance = new Harmony("Durinson.IronFirePitForExplorers");

	public static ManualLogSource logger = Logger.CreateLogSource("Iron fire pit for explorers");

	public void Awake()
	{
		logger.LogInfo((object)"Thank you for using my mod!");
		Assembly executingAssembly = Assembly.GetExecutingAssembly();
		HarmonyInstance.PatchAll(executingAssembly);
	}
}