Decompiled source of CustomSplash v1.0.0

CustomSplash.dll

Decompiled a day ago
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("Biomes")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("HP Inc.")]
[assembly: AssemblyProduct("Biomes")]
[assembly: AssemblyCopyright("Copyright © HP Inc. 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f3e54ac2-1def-4f40-8283-6a588efef115")]
[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 CustomSplash;

[BepInPlugin("actuallytim.customsplash", "CustomSplash", "1.0.0")]
public class CustomSplash : BaseUnityPlugin
{
	[HarmonyPatch(typeof(Player), "AddKnownBiome")]
	public static class BiomeKnowledge
	{
		private static bool Prefix(Biome biome)
		{
			if (!Instance.showBiomes)
			{
				return true;
			}
			Instance.Splash(((object)(Biome)(ref biome)).ToString());
			return false;
		}
	}

	private const string pluginGUID = "actuallytim.customsplash";

	private const string pluginName = "CustomSplash";

	private const string pluginVersion = "1.0.0";

	public string customText;

	public bool showBiomes = false;

	public bool playSound = true;

	public static CustomSplash Instance;

	public KeyCode keybind = (KeyCode)61;

	public void Print(string message)
	{
		Logger.CreateLogSource("CustomSplash").LogInfo((object)message);
	}

	public void Awake()
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Expected O, but got Unknown
		Print("Starting Custom Splash Mod");
		Instance = this;
		InitCustomTextCommand();
		InitToggleBiomeCommand();
		InitToggleSoundCommand();
		Harmony val = new Harmony("actuallytim.customsplash");
		val.PatchAll();
	}

	public void Update()
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)Player.m_localPlayer == (Object)null) && Input.GetKeyDown(keybind))
		{
			TriggerMessage();
		}
	}

	private void InitCustomTextCommand()
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Expected O, but got Unknown
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		new ConsoleCommand("setsplashtext", "Set custom splash text to display", (ConsoleEvent)delegate(ConsoleEventArgs args)
		{
			if (args.Args.Length > 1)
			{
				string text = string.Join(" ", args.Args, 1, args.Args.Length - 1);
				Print("Custom Text Set: " + text);
				args.Context.AddString("Custom Text Set: " + text);
				Instance.customText = text;
			}
			else
			{
				Print("Reverting custom text to display current biome");
				args.Context.AddString("Reverting custom text to display current biome");
				Instance.customText = null;
			}
		}, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
	}

	private void InitToggleBiomeCommand()
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Expected O, but got Unknown
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		new ConsoleCommand("togglebiomesplash", "Toggles if the biome text shows upon entering a biome", (ConsoleEvent)delegate(ConsoleEventArgs args)
		{
			Instance.showBiomes = !Instance.showBiomes;
			Print($"Toggling show biome splash on entering biome to {Instance.showBiomes}");
			args.Context.AddString($"Toggling show biome splash on entering biome to {Instance.showBiomes}");
		}, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
	}

	private void InitToggleSoundCommand()
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Expected O, but got Unknown
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		new ConsoleCommand("togglesplashsound", "Toggles if sound plays when custom message is shown", (ConsoleEvent)delegate(ConsoleEventArgs args)
		{
			Instance.playSound = !Instance.playSound;
			Print($"Toggling play sound on custom splash to {Instance.playSound}");
			args.Context.AddString($"Toggling play sound on custom splash to {Instance.playSound}");
		}, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
	}

	private void TriggerMessage()
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		Player localPlayer = Player.m_localPlayer;
		if (!((Object)(object)localPlayer == (Object)null))
		{
			string text = Instance.customText;
			if (text == null)
			{
				Vector3 position = ((Component)localPlayer).transform.position;
				Biome val = Heightmap.FindBiome(position);
				text = ((object)(Biome)(ref val)).ToString();
			}
			Splash(text);
		}
	}

	private void Splash(string text)
	{
		MessageHud.instance.ShowBiomeFoundMsg(text ?? "", playSound);
	}
}