Decompiled source of MyCampfireDontLeaveMe v0.1.0

plugins/my.pahsiv.MyCampfireDontLeaveMe.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.InputSystem;
using Zorro.Core;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("my.pahsiv.MyCampfireDontLeaveMe")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("my.pahsiv.MyCampfireDontLeaveMe")]
[assembly: AssemblyTitle("MyCampfireDontLeaveMe")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace MyCampfireDontLeaveMe
{
	public static class ColorHelper
	{
		public const string White = "FFFFFF";

		public const string Black = "000000";

		public const string Red = "FF0000";

		public const string Green = "00FF00";

		public const string Blue = "0000FF";

		public const string Yellow = "FFFF00";

		public const string Purple = "8765CA";

		public const string Gray = "808080";

		public const string Orange = "FFA500";

		public const string Cyan = "00FFFF";

		public const string Magenta = "FF00FF";

		public const string Pink = "FFC0CB";

		public const string Brown = "A52A2A";

		public const string Lime = "00FF00";

		public const string Teal = "008080";

		public const string Navy = "000080";

		public const string Maroon = "800000";

		public const string Olive = "808000";

		public const string Aqua = "00FFFF";

		public const string Silver = "C0C0C0";

		public const string Gold = "FFD700";

		public const string LightRed = "FF6B6B";

		public const string LightGreen = "90EE90";

		public const string LightBlue = "ADD8E6";

		public const string LightGray = "D3D3D3";

		public const string LightPink = "FFB6C1";

		public const string DarkRed = "8B0000";

		public const string DarkGreen = "006400";

		public const string DarkBlue = "00008B";

		public const string DarkGray = "A9A9A9";

		public const string DarkOrange = "FF8C00";

		public const string Pahsiv = "3582E7";
	}
	[BepInPlugin("my.pahsiv.MyCampfireDontLeaveMe", "MyCampfireDontLeaveMe", "0.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static ConfigEntry<KeyCode> ForceLoad;

		private static InputAction? ForceLoadAction;

		public const string Id = "my.pahsiv.MyCampfireDontLeaveMe";

		internal static ManualLogSource Log { get; private set; }

		public static Plugin Instance { get; private set; }

		public static string Name => "MyCampfireDontLeaveMe";

		public static string Version => "0.1.0";

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			ForceLoad = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "Force Load hotkey", (KeyCode)292, "Press to force load The Kiln!");
			ForceLoad.SettingChanged += OnForceLoadChanged;
			InitializeForceLoadAction();
			Log.LogMessage((object)("          Plugin " + Name + " " + Version + " is loaded!"));
		}

		private void OnForceLoadChanged(object sender, EventArgs e)
		{
			InitializeForceLoadAction();
		}

		private void InitializeForceLoadAction()
		{
			//IL_0021: 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)
			//IL_0040: Expected O, but got Unknown
			if (ForceLoadAction != null)
			{
				ForceLoadAction.Disable();
				ForceLoadAction.Dispose();
			}
			string text = ConvertKeyCodeToInputPath(ForceLoad.Value);
			ForceLoadAction = new InputAction("ForceLoad", (InputActionType)1, text, (string)null, (string)null, (string)null);
			ForceLoadAction.performed += ForceLoadAction_performed;
			ForceLoadAction.Enable();
		}

		private void ForceLoadAction_performed(CallbackContext obj)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Invalid comparison between Unknown and I4
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			Segment currentSegment = Singleton<MapHandler>.Instance.GetCurrentSegment();
			Utilities.Notification("Current Segment is " + Utilities.AddColor(FixCampfireName(((object)(Segment)(ref currentSegment)).ToString()), "00FFFF") + "!", "FFFF00", sound: true);
			if ((int)Singleton<MapHandler>.Instance.GetCurrentSegment() == 3)
			{
				Segment val = (Segment)4;
				Utilities.Notification("Forcing " + Utilities.AddColor(FixCampfireName(((object)(Segment)(ref val)).ToString()), "FFC0CB") + " to load!", "FFFF00", sound: true);
				Shader.SetGlobalFloat("FakeMountainEnabled", 0f);
				if (Object.op_Implicit((Object)(object)Singleton<MapHandler>.Instance))
				{
					Singleton<MapHandler>.Instance.GoToSegment((Segment)4);
				}
			}
		}

		private string ConvertKeyCodeToInputPath(KeyCode keyCode)
		{
			string text = ((object)(KeyCode)(ref keyCode)).ToString();
			if (text.StartsWith("Keypad"))
			{
				text = text.Replace("Keypad", "numpad");
			}
			return "<Keyboard>/" + text.ToLower();
		}

		public static string FixCampfireName(string campfireName)
		{
			string text = campfireName;
			if (campfireName.Equals("Tropics"))
			{
				text += "/Roots";
			}
			else if (campfireName.Equals("Alpine"))
			{
				text += "/Mesa";
			}
			return text;
		}
	}
	public static class Utilities
	{
		public static void VerifyPatch(Harmony harmony)
		{
			IEnumerable<MethodBase> patchedMethods = harmony.GetPatchedMethods();
			Plugin.Log.LogMessage((object)$"          Total patched methods: {patchedMethods.Count()}");
			foreach (MethodBase item in patchedMethods)
			{
				Plugin.Log.LogMessage((object)("          Patched: " + item.DeclaringType?.Name + "." + item.Name));
			}
		}

		public static void Notification(string message, string color = "FFFFFF", bool sound = false)
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			PlayerConnectionLog val = Object.FindFirstObjectByType<PlayerConnectionLog>();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			string text = "<color=#" + color + ">" + message + "</color>";
			MethodInfo method = typeof(PlayerConnectionLog).GetMethod("AddMessage", BindingFlags.Instance | BindingFlags.NonPublic);
			if (method != null)
			{
				method.Invoke(val, new object[1] { text });
				if ((Object)(object)val.sfxJoin != (Object)null && sound)
				{
					val.sfxJoin.Play(default(Vector3));
				}
			}
			else
			{
				Plugin.Log.LogWarning((object)"AddMessage method not found.");
			}
		}

		public static string AddColor(string text, string color)
		{
			return "<color=#" + color + ">" + text + "</color>";
		}

		public static string ConvertKeyCodeToInputPath(KeyCode keyCode)
		{
			string text = ((object)(KeyCode)(ref keyCode)).ToString();
			if (text.StartsWith("Keypad"))
			{
				text = text.Replace("Keypad", "numpad");
			}
			return "<Keyboard>/" + text.ToLower();
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}