using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("AutoMessage")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.2.0+2664facdac8ab07d4d1ce8abe8bb895a04038a1d")]
[assembly: AssemblyProduct("AutoMessage")]
[assembly: AssemblyTitle("AutoMessage")]
[assembly: AssemblyVersion("1.2.0.0")]
[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
{
public static class PluginMetadata
{
public const string PLUGIN_VERSION = "1.2.0";
public const string PLUGIN_NAME = "AutoMessage";
public const string PLUGIN_AUTHOR = "hoffr";
public const string PLUGIN_GUID = "hoffr.AutoMessage";
}
[BepInPlugin("hoffr.AutoMessage", "AutoMessage", "1.2.0")]
[BepInProcess("Lethal Company.exe")]
public class Plugin : BaseUnityPlugin
{
public static Plugin Instance;
public ManualLogSource Log = Logger.CreateLogSource("AutoMessage");
public bool randomize;
public string title;
public List<string> messages = new List<string>();
private int messageIndex = 0;
public GameObject textObject;
public TextMeshProUGUI textComponent;
private void Awake()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
MakeConfig();
new Harmony("hoffr.AutoMessage").PatchAll(Assembly.GetExecutingAssembly());
Log.LogInfo((object)"AutoMessage v1.2.0 loaded.");
}
public void MakeConfig()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
ConfigFile val = new ConfigFile(Path.Combine(Paths.ConfigPath, "AutoMessage.cfg"), true);
Random random = new Random();
ConfigEntry<string> val2 = val.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(val2.Value, out randomize);
ConfigEntry<string> val3 = val.Bind<string>("2. Title", "Title", "AutoMessage", "The title text that will show next to all the messages (eg. AutoMessage: Hello world).\nIf left blank, only the message will show.\nSome symbols typed here 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 = val3.Value;
ConfigEntry<string> val4 = val.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");
if (val4.Value != "")
{
messages.Add(val4.Value);
}
for (int i = 2; i <= 100; i++)
{
ConfigEntry<string> val5 = val.Bind<string>("3. Messages", $"Message{i}", "", (ConfigDescription)null);
if (val5.Value != "")
{
messages.Add(val5.Value);
}
}
if (randomize)
{
messages = messages.OrderBy((string x) => random.Next()).ToList();
}
}
public string GetNextMessage()
{
string result = messages[messageIndex];
messageIndex = (messageIndex + 1) % messages.Count;
return result;
}
public void SetMessage(string message)
{
if (title != "")
{
((TMP_Text)textComponent).text = title + ": " + message;
}
else
{
((TMP_Text)textComponent).text = message ?? "";
}
}
public void DisplayText()
{
if ((Object)(object)textObject == (Object)null)
{
ConstructGameObject();
}
SetMessage(GetNextMessage());
((MonoBehaviour)this).StartCoroutine(MonitorDarkenScreen());
}
public void ConstructGameObject()
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Expected O, but got Unknown
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
GameObject val = GameObject.Find("Systems/UI/Canvas");
if ((Object)(object)val == (Object)null)
{
Log.LogError((object)"Failed to find Canvas GameObject");
return;
}
textObject = new GameObject("AutoMessageText");
textObject.SetActive(false);
RectTransform val2 = textObject.AddComponent<RectTransform>();
((Transform)val2).SetParent(val.transform);
((Transform)val2).SetAsLastSibling();
textObject.layer = LayerMask.NameToLayer("UI");
val2.anchoredPosition3D = new Vector3(0f, -200f, 0f);
((Transform)val2).localScale = new Vector3(1f, 1f, 1f);
val2.anchorMin = new Vector2(0.5f, 0.5f);
val2.anchorMax = new Vector2(0.5f, 0.5f);
val2.sizeDelta = new Vector2(500f, 100f);
textComponent = textObject.AddComponent<TextMeshProUGUI>();
TMP_FontAsset val3 = ((IEnumerable<TMP_FontAsset>)Resources.FindObjectsOfTypeAll<TMP_FontAsset>()).FirstOrDefault((Func<TMP_FontAsset, bool>)((TMP_FontAsset f) => ((Object)f).name == "b"));
if ((Object)(object)val3 == (Object)null)
{
Log.LogError((object)"Font 'b' not found");
return;
}
((TMP_Text)textComponent).font = val3;
Material material = ((TMP_Asset)val3).material;
if ((Object)(object)material == (Object)null)
{
Log.LogError((object)"FontMaterial not found");
return;
}
((TMP_Text)textComponent).fontMaterial = material;
((Graphic)textComponent).color = new Color(0.6462264f, 0.95584375f, 1f, 47f / 85f);
((TMP_Text)textComponent).fontSize = 18f;
((TMP_Text)textComponent).horizontalAlignment = (HorizontalAlignmentOptions)2;
((TMP_Text)textComponent).enableWordWrapping = true;
}
private IEnumerator MonitorDarkenScreen()
{
while (!((Behaviour)HUDManager.Instance.loadingDarkenScreen).enabled)
{
yield return (object)new WaitForSeconds(0.2f);
}
textObject.SetActive(true);
while (((Behaviour)HUDManager.Instance.loadingDarkenScreen).enabled)
{
yield return (object)new WaitForSeconds(0.2f);
}
textObject.SetActive(false);
}
}
[HarmonyPatch(typeof(StartOfRound))]
public class StartOfRoundPatch
{
[HarmonyPrefix]
[HarmonyPatch("SceneManager_OnLoad")]
public static void OnLoad()
{
Plugin.Instance.DisplayText();
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "AutoMessage";
public const string PLUGIN_NAME = "AutoMessage";
public const string PLUGIN_VERSION = "1.2.0";
}
}