Decompiled source of AutoMessage v1.0.1

AutoMessage.dll

Decompiled a day 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;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("AutoMessage")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+ab97edf17a2a34969542daf84e11868a3f1fdfde")]
[assembly: AssemblyProduct("AutoMessage")]
[assembly: AssemblyTitle("AutoMessage")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace AutoMessage
{
	[BepInPlugin("AutoMessage", "AutoMessage", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static Plugin Instance;

		internal static ManualLogSource Logger;

		public bool randomize;

		public string title;

		public List<string> messages = new List<string>();

		private static Random random = new Random();

		private static int messageIndex = 0;

		public static string lastMoon = "";

		public static bool isFirstRun = true;

		private void Awake()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			Logger = ((BaseUnityPlugin)this).Logger;
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			MakeConfig();
			new Harmony("AutoMessage").PatchAll(Assembly.GetExecutingAssembly());
			Logger.LogInfo((object)"AutoMessage v1.0.0 loaded.");
		}

		public void MakeConfig()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			ConfigEntry<string> val = ((BaseUnityPlugin)this).Config.Bind<string>("1. Randomize", "Randomize", "false", "true / false - Will scramble the order of messages displayed.\nNote that once it starts looping, that same order will persist.\nThus it's not a true on-the-fly randomization.");
			bool.TryParse(val.Value, out randomize);
			ConfigEntry<string> val2 = ((BaseUnityPlugin)this).Config.Bind<string>("2. Title", "Title", "AutoMessage", "The title text that will show above all the messages.\nSome symbols will automatically be preceded by a backslash after the game runs.\nThis won't show in game and it's okay to omit them when typing");
			title = val2.Value;
			ConfigEntry<string> val3 = ((BaseUnityPlugin)this).Config.Bind<string>("3. Messages", "Message1", "Message 1", "Messages will be displayed in sequential order (unless 'randomize' is true) every time the lever is pulled to land, until they loop.\nBlank message entries will be skipped.\nSome symbols will automatically be preceded by a backslash after the game runs.\nThis won't show in game and it's okay to omit them when typing");
			messages.Add(val3.Value);
			for (int i = 2; i <= 100; i++)
			{
				ConfigEntry<string> val4 = ((BaseUnityPlugin)this).Config.Bind<string>("3. Messages", $"Message{i}", "", (ConfigDescription)null);
				if (val4.Value != "")
				{
					messages.Add(val4.Value);
				}
			}
			if (randomize)
			{
				messages = messages.OrderBy((string x) => random.Next()).ToList();
			}
		}

		public void DebugLog(string title, string message)
		{
			if ((Object)(object)HUDManager.Instance != (Object)null)
			{
				HUDManager.Instance.DisplayTip(title, message, false, false, "LC_Tip1");
			}
		}

		public string GetNextMessage()
		{
			string result = messages[messageIndex];
			messageIndex = (messageIndex + 1) % messages.Count;
			return result;
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	public class StartOfRoundPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("SceneManager_OnLoad")]
		public static void OnStartGame()
		{
			string nextMessage = Plugin.Instance.GetNextMessage();
			string title = Plugin.Instance.title;
			Plugin.Instance.DebugLog(title, nextMessage);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "AutoMessage";

		public const string PLUGIN_NAME = "AutoMessage";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}