Decompiled source of LocationBasedBeds v0.1.0

LocationBasedBeds.dll

Decompiled 10 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("LocationBasedBeds")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LocationBasedBeds")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("cda2b61e-c407-4a42-93c3-d51ead4ceb3c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LocationBasedBeds;

[BepInPlugin("randyknapp.mods.locationbasedbeds", "Location Based Beds", "0.1.0")]
public class LocationBasedBeds : BaseUnityPlugin
{
	public const string GUID = "randyknapp.mods.locationbasedbeds";

	public const string NAME = "Location Based Beds";

	public const string VERSION = "0.1.0";

	public void Awake()
	{
		((BaseUnityPlugin)this).Logger.LogWarning((object)"Location Based Beds Loaded");
		Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "randyknapp.mods.locationbasedbeds");
	}
}
[HarmonyPatch]
public static class UIDeathPatch
{
	private static Location FindClosestLocation(Vector3 worldPos)
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		Location result = null;
		float num = float.MaxValue;
		foreach (Location locations in WorldScene.code.locationsList)
		{
			Vector3 val = worldPos - locations.mapLocator.position;
			float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
			if (sqrMagnitude < num)
			{
				num = sqrMagnitude;
				result = locations;
			}
		}
		return result;
	}

	[HarmonyPatch(typeof(UIDeath), "Open")]
	[HarmonyPostfix]
	public static void Open_Postfix(UIDeath __instance)
	{
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		List<Button> value = Traverse.Create((object)__instance).Field<List<Button>>("InteractBtns").Value;
		for (int i = 0; i < WorldScene.code.Beds.Count; i++)
		{
			Bed val = WorldScene.code.Beds[i];
			if (Mainframe.code.WorldManager.IsSpawnPointShared || !(val.BuilderID != Mainframe.code.SaveManager.CurrentCharacterGuid))
			{
				Button val2 = value[i];
				Location val3 = FindClosestLocation(((Component)val).transform.position);
				((Component)val2).GetComponentInChildren<Text>().text = val3.locationName;
			}
		}
	}
}