Decompiled source of DeadBodyDeleter v1.1.1

Mods/DeadBodyDeleter.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Timers;
using BoneLib;
using BoneLib.BoneMenu;
using DeadBodyDeleter;
using DeadBodyDeleter.Fusion;
using Il2CppSLZ.Marrow.AI;
using Il2CppSLZ.Marrow.Pool;
using LabFusion.Network;
using LabFusion.SDK.Modules;
using MelonLoader;
using MelonLoader.Preferences;
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: MelonInfo(typeof(Core), "DeadBodyDeleter", "1.0.0", "MajedCT", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: MelonOptionalDependencies(new string[] { "LabFusion" })]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("DeadBodyDeleter")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+01ae908b379e9f144399931eff1c76f1bb17947f")]
[assembly: AssemblyProduct("DeadBodyDeleter")]
[assembly: AssemblyTitle("DeadBodyDeleter")]
[assembly: NeutralResourcesLanguage("en-US")]
[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.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 DeadBodyDeleter
{
	public class Core : MelonMod
	{
		public static List<AIBrain> KillList = new List<AIBrain>();

		public static ElapsedEventHandler OnTimerElapsed { get; private set; }

		public override void OnInitializeMelon()
		{
			Hooking.OnNPCBrainDie += Hooking_OnNPCBrainDie;
			((MelonBase)this).LoggerInstance.Msg("Initialized.");
			Preferences.MelonPreferencesCreator();
			Preferences.BoneMenuCreator();
			TryLoadFusion();
		}

		public void TryLoadFusion()
		{
			if (MelonBase.FindMelon("LabFusion", "Lakatrazz") != null)
			{
				LoadModule();
			}
		}

		private static void LoadModule()
		{
			ModuleManager.RegisterModule<MyModule>();
		}

		public static void Hooking_OnNPCBrainDie(AIBrain brain)
		{
			if (Preferences.ModIsEnabled.Value)
			{
				if (Preferences.InstaDelete.Value)
				{
					((SpawnEvents)brain).Despawn();
				}
				double interval = Preferences.DeleteTime.Value * 1000f;
				Timer deleteTimer = new Timer(interval);
				deleteTimer.AutoReset = false;
				deleteTimer.Elapsed += delegate
				{
					ElapsedDeathTimerEvent(deleteTimer, brain);
				};
				deleteTimer.Start();
			}
		}

		private static void ElapsedDeathTimerEvent(Timer timer, AIBrain brain)
		{
			KillList.Add(brain);
			((SpawnEvents)brain).Despawn();
			timer.Dispose();
		}
	}
	internal class Preferences
	{
		public static MelonPreferences_Category MelonPrefCategory { get; set; }

		public static MelonPreferences_Entry<bool> ModIsEnabled { get; set; }

		public static MelonPreferences_Entry<float> DeleteTime { get; set; }

		public static MelonPreferences_Entry<bool> InstaDelete { get; set; }

		public static void MelonPreferencesCreator()
		{
			MelonPrefCategory = MelonPreferences.CreateCategory("Dead Body Deleter");
			ModIsEnabled = MelonPrefCategory.CreateEntry<bool>("ModIsEnabled", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			DeleteTime = MelonPrefCategory.CreateEntry<float>("DeleteTime (Seconds)", 30f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			InstaDelete = MelonPrefCategory.CreateEntry<bool>("InstaDelete", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		}

		public static void BoneMenuCreator()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			Page val = Page.Root.CreatePage("Dead Body Deleter", Color.green, 0, true);
			val.CreateBool("Toggle (ONLY DO IN SANDBOX)", Color.yellow, ModIsEnabled.Value, (Action<bool>)OnSetEnabled);
			val.CreateFloat("Delete Time (Seconds)", Color.green, DeleteTime.Value, 5f, 5f, 120f, (Action<float>)OnFloatChanged);
			val.CreateBool("Insta Delete", Color.red, InstaDelete.Value, (Action<bool>)OnInstaDeleteEnabled);
		}

		private static void OnSetEnabled(bool value)
		{
			ModIsEnabled.Value = value;
			MelonPrefCategory.SaveToFile(true);
		}

		private static void OnFloatChanged(float value)
		{
			DeleteTime.Value = value;
			MelonPrefCategory.SaveToFile(true);
		}

		private static void OnInstaDeleteEnabled(bool value)
		{
			InstaDelete.Value = value;
			MelonPrefCategory.SaveToFile(true);
		}
	}
}
namespace DeadBodyDeleter.Fusion
{
	public class MyModule : Module
	{
		public override string Name => "Dead Body Deleter";

		public override string Author => "MajedCT";

		public override Version Version => new Version(1, 0, 0);

		public NetworkLayer CurrentLayer => NetworkLayerManager.Layer;

		public override ConsoleColor Color => ConsoleColor.Red;

		protected override void OnModuleRegistered()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			((MelonEventBase<LemonAction>)(object)MelonEvents.OnUpdate).Subscribe(new LemonAction(Update), 0, false);
		}

		private void Update()
		{
			if (CurrentLayer == null || !CurrentLayer.IsHost)
			{
				return;
			}
			foreach (AIBrain item in Core.KillList.ToList())
			{
				((SpawnEvents)item).Despawn();
				if ((Object)(object)item != (Object)null)
				{
					Core.KillList.Remove(item);
				}
			}
		}

		protected override void OnModuleUnregistered()
		{
			//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(Update));
		}
	}
}