Decompiled source of ClientHostInfo v1.1.1

Mods/Rumble Client-Host info+.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using MelonLoader;
using Microsoft.CodeAnalysis;
using RumbleModUI;
using RumbleModdingAPI;
using Rumble_Client_Host_info_;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(TestMod), "ClientHostInfo", "1.1.1", "oreotrollturbo, juicepar and UlvakSkillz", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Rumble Client-Host info+")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Rumble Client-Host info+")]
[assembly: AssemblyTitle("Rumble Client-Host info+")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
		}
	}
}
namespace Rumble_Client_Host_info_
{
	public static class BuildInfo
	{
		public const string ModName = "ClientHostInfo";

		public const string ModVersion = "1.1.1";

		public const string Author = "oreotrollturbo, juicepar and UlvakSkillz";
	}
	public class TestMod : MelonMod
	{
		[CompilerGenerated]
		private sealed class <DisableInfoPanelAfterDelay>d__14 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public float delay;

			public TestMod <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <DisableInfoPanelAfterDelay>d__14(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if (delay < 0f)
					{
						return false;
					}
					<>2__current = (object)new WaitForSeconds(delay);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if ((Object)(object)<>4__this._infoPanel == (Object)null)
					{
						MelonLogger.Warning("Info panel is null");
						return false;
					}
					<>4__this._infoPanel.SetActive(false);
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <WaitAndHandleSceneSwitch>d__13 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public float delay;

			public TestMod <>4__this;

			private string <>s__1;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <WaitAndHandleSceneSwitch>d__13(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>s__1 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(delay);
					<>1__state = 1;
					return true;
				case 1:
				{
					<>1__state = -1;
					string currentSceneName = _currentSceneName;
					<>s__1 = currentSceneName;
					string text = <>s__1;
					if (!(text == "Map0"))
					{
						if (text == "Map1")
						{
							<>4__this.Map1Init();
						}
					}
					else
					{
						<>4__this.Map0Init();
					}
					<>s__1 = null;
					return false;
				}
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private static string? _currentSceneName;

		private GameObject? _infoPanel;

		private Mod RumbleClientHostinfo = new Mod();

		private Color HostColor;

		private Color ClientColor;

		private float HostFont;

		private float ClientFont;

		private float InfoboardDuration;

		public override void OnLateInitializeMelon()
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Expected O, but got Unknown
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Expected O, but got Unknown
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Expected O, but got Unknown
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Expected O, but got Unknown
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Expected O, but got Unknown
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Expected O, but got Unknown
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Expected O, but got Unknown
			Calls.onMapInitialized += SceneLoaded;
			UI.instance.UI_Initialized += UiInit;
			RumbleClientHostinfo.ModSaved += Save;
			RumbleClientHostinfo.ModName = "ClientHostInfo";
			RumbleClientHostinfo.SetFolder("ClientHostInfo");
			RumbleClientHostinfo.AddToList("Host Color R", 255f, "Up to 255, PRESS ENTER AND SAVE", new Tags());
			RumbleClientHostinfo.AddToList("Host Color G", 255f, "Up to 255, PRESS ENTER AND SAVE", new Tags());
			RumbleClientHostinfo.AddToList("Host Color B", 0f, "Up to 255, PRESS ENTER AND SAVE", new Tags());
			RumbleClientHostinfo.AddToList("Client Color R", 255f, "Up to 255, PRESS ENTER AND SAVE", new Tags());
			RumbleClientHostinfo.AddToList("Client Color G", 255f, "Up to 255, PRESS ENTER AND SAVE", new Tags());
			RumbleClientHostinfo.AddToList("Client Color B", 0f, "Up to 255, PRESS ENTER AND SAVE", new Tags());
			RumbleClientHostinfo.AddToList("Host Font", 10f, "Change Font Size.. PRESS ENTER", new Tags());
			RumbleClientHostinfo.AddToList("Client Font", 10f, "PrEsS EnT3R AND SAVE GODANGIT", new Tags());
			RumbleClientHostinfo.AddToList("InfoboardDuration", -1f, "Controls in seconds how long the board will stay active. -1 = Forever 0= Off", new Tags());
			RumbleClientHostinfo.GetFromFile();
		}

		private void UiInit()
		{
			UI.instance.AddMod(RumbleClientHostinfo);
		}

		public override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			_currentSceneName = sceneName;
		}

		private void Save()
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			HostColor = new Color((float)RumbleClientHostinfo.Settings[0].SavedValue / 255f, (float)RumbleClientHostinfo.Settings[1].SavedValue / 255f, (float)RumbleClientHostinfo.Settings[2].SavedValue / 255f);
			ClientColor = new Color((float)RumbleClientHostinfo.Settings[3].SavedValue / 255f, (float)RumbleClientHostinfo.Settings[4].SavedValue / 255f, (float)RumbleClientHostinfo.Settings[5].SavedValue / 255f);
			HostFont = (float)RumbleClientHostinfo.Settings[6].SavedValue;
			ClientFont = (float)RumbleClientHostinfo.Settings[7].SavedValue;
			InfoboardDuration = (float)RumbleClientHostinfo.Settings[8].SavedValue;
		}

		private void SceneLoaded()
		{
			string currentSceneName = _currentSceneName;
			if ((currentSceneName == "Map0" || currentSceneName == "Map1") ? true : false)
			{
				Save();
				MelonCoroutines.Start(DisableInfoPanelAfterDelay(InfoboardDuration));
			}
			MelonCoroutines.Start(WaitAndHandleSceneSwitch(1f));
		}

		[IteratorStateMachine(typeof(<WaitAndHandleSceneSwitch>d__13))]
		private IEnumerator WaitAndHandleSceneSwitch(float delay)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <WaitAndHandleSceneSwitch>d__13(0)
			{
				<>4__this = this,
				delay = delay
			};
		}

		[IteratorStateMachine(typeof(<DisableInfoPanelAfterDelay>d__14))]
		private IEnumerator DisableInfoPanelAfterDelay(float delay)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DisableInfoPanelAfterDelay>d__14(0)
			{
				<>4__this = this,
				delay = delay
			};
		}

		private void Map0Init()
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			if (Players.IsHost())
			{
				_infoPanel = CreateTextBox("Host", HostFont, HostColor, new Vector3(0f, 3.75f, -11f), Quaternion.Euler(0f, 183f, 0f));
			}
			else
			{
				_infoPanel = CreateTextBox("Client", ClientFont, ClientColor, new Vector3(0f, 3.75f, 11f), Quaternion.Euler(0f, 12f, 0f));
			}
		}

		private void Map1Init()
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			if (Players.IsHost())
			{
				_infoPanel = CreateTextBox("Host", HostFont, HostColor, new Vector3(0f, 3.25f, 10.6f), Quaternion.Euler(0f, 0f, 0f));
			}
			else
			{
				_infoPanel = CreateTextBox("Client", ClientFont, ClientColor, new Vector3(0f, 3.25f, 10.6f), Quaternion.Euler(0f, 0f, 0f));
			}
		}

		private static GameObject CreateTextBox(string text, float textSize, Color color, Vector3 vector, Quaternion rotation)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Create.NewText(text, textSize, color, default(Vector3), Quaternion.Euler(0f, 0f, 0f));
			val.transform.position = vector;
			val.transform.rotation = rotation;
			return val;
		}
	}
}