Decompiled source of NukesFusionServerUtilities v1.0.4

Mods/NukesFusionServerUtilities.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BoneLib;
using BoneLib.BoneMenu;
using BoneLib.Notifications;
using HarmonyLib;
using Il2CppSLZ.Marrow;
using LabFusion.Network;
using LabFusion.Player;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using NukesFusionServerUtilities;
using NukesFusionServerUtilities.Features;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Entrypoint), "NukesFusionServerUtilities", "1.0.4", "The_UltimateNuke", null)]
[assembly: MelonOptionalDependencies(new string[] { "SceneJanitor" })]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("The_UltimateNuke")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.4.0")]
[assembly: AssemblyInformationalVersion("1.0.4+35b9e245aba06734f2b8988969274ac8e13ef07d")]
[assembly: AssemblyProduct("NukesFusionServerUtilities")]
[assembly: AssemblyTitle("NukesFusionServerUtilities")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/TheUltimateNuke/NukesFusionServerUtilities")]
[assembly: AssemblyVersion("1.0.4.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.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 NukesFusionServerUtilities
{
	public class Entrypoint : MelonMod
	{
		internal static Harmony StaticHarmonyInstance => ((MelonBase)Melon<Entrypoint>.Instance).HarmonyInstance;

		internal static Instance Logger => Melon<Entrypoint>.Logger;

		public override void OnInitializeMelon()
		{
			new PanicButton().Initialize();
			Logger.Msg(ConsoleColor.Green, "NukesFusionServerUtilities v1.0.4 initialized!");
		}
	}
	internal static class MyModInfo
	{
		public const string Author = "The_UltimateNuke";

		public const string Name = "NukesFusionServerUtilities";

		public const string Version = "1.0.4";
	}
}
namespace NukesFusionServerUtilities.Features
{
	public abstract class Feature
	{
		protected virtual void SetupConfiguration(ref Page? page)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			page = Page.Root.CreatePage("Nuke's Fusion Server Utilities", Color.yellow, 0, true);
		}

		public virtual void Initialize()
		{
			Page page = null;
			SetupConfiguration(ref page);
		}

		public abstract void Deinitialize();
	}
	public class PanicButton : Feature
	{
		private const int DefaultTriggerCount = 10;

		public static MelonPreferences_Category Category = MelonPreferences.CreateCategory("NukesFusionServerUtilities");

		public static ModPref<int> PanicButtonTriggerCountPref = new ModPref<int>(Category, "PanicButtonTriggerCountPref", 10, "Panic Button Trigger Count", (string)null, false, false, (ValueValidator)null);

		public static ModPref<bool> PanicButtonResetAvatarPref = new ModPref<bool>(Category, "PanicButtonResetAvatarPref", false, "Fallback Avatar on Panic Button", (string)null, false, false, (ValueValidator)null);

		private static BindingFlags _allFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;

		private static float _secondsBetweenInputs = 0.8f;

		private static int _count;

		private static float _lastIncTime;

		public override void Initialize()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			base.Initialize();
			((MelonEventBase<LemonAction>)(object)MelonEvents.OnUpdate).Subscribe(new LemonAction(OnUpdate), 0, false);
		}

		protected override void SetupConfiguration(ref Page? page)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			base.SetupConfiguration(ref page);
			Page? obj = page;
			if (obj != null)
			{
				obj.CreateBool("Fallback Avatar on Panic Button", Color.gray, PanicButtonResetAvatarPref.entry.Value, (Action<bool>)delegate(bool i)
				{
					PanicButtonResetAvatarPref.entry.Value = i;
				});
			}
			Page? obj2 = page;
			if (obj2 != null)
			{
				obj2.CreateInt("Panic Button Trigger Count", Color.gray, PanicButtonTriggerCountPref.entry.Value, 1, 2, 16, (Action<int>)delegate(int i)
				{
					PanicButtonTriggerCountPref.entry.Value = i;
				});
			}
		}

		public override void Deinitialize()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			((MelonEventBase<LemonAction>)(object)MelonEvents.OnUpdate).Unsubscribe(new LemonAction(OnUpdate));
		}

		public static void OnTriggerPanicButton()
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			if (PanicButtonResetAvatarPref.entry.Value)
			{
				LocalAvatar.SwapAvatarCrate("c3534c5a-94b2-40a4-912a-24a8506f6c79");
			}
			LocalPlayer.ClearConstraints();
			LocalPlayer.TeleportToCheckpoint();
			if (NetworkInfo.IsHost)
			{
				MelonBase val = MelonBase.FindMelon("Scene Janitor", "minecart");
				((object)val)?.GetType().GetMethod("RestoreCleanup", _allFlags)?.Invoke(val, null);
			}
			Notifier.Send(new Notification
			{
				Type = (NotificationType)3,
				PopupLength = 5f,
				Message = NotificationText.op_Implicit("Panic button triggered! You have been reset!")
			});
		}

		private void OnUpdate()
		{
			if (_secondsBetweenInputs <= Time.realtimeSinceStartup - _lastIncTime)
			{
				_count = 0;
			}
			BaseController leftController = Player.LeftController;
			if (leftController != null && leftController.GetBButtonDown())
			{
				goto IL_006c;
			}
			Keyboard current = Keyboard.current;
			if (current != null)
			{
				KeyControl bKey = current.bKey;
				if (((bKey != null) ? new bool?(((ButtonControl)bKey).wasPressedThisFrame) : null).GetValueOrDefault())
				{
					goto IL_006c;
				}
			}
			goto IL_0084;
			IL_0084:
			if (_count >= PanicButtonTriggerCountPref.entry.Value)
			{
				_count = 0;
				OnTriggerPanicButton();
			}
			return;
			IL_006c:
			_count++;
			_lastIncTime = Time.realtimeSinceStartup;
			goto IL_0084;
		}
	}
}