Decompiled source of Scene Janitor v1.1.0

Mods/SceneJanitor.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BoneLib.BoneMenu;
using BoneLib.Notifications;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.AI;
using Il2CppSLZ.Marrow.Interaction;
using Il2CppSLZ.Marrow.Pool;
using Il2CppSLZ.Marrow.Warehouse;
using Il2CppSLZ.VFX;
using Il2CppSystem;
using LabFusion.Network;
using LabFusion.Utilities;
using MelonLoader;
using UnityEngine;
using scene_janitor;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("it clean the scene")]
[assembly: AssemblyDescription("it clean the scene")]
[assembly: AssemblyCompany("minecart")]
[assembly: AssemblyProduct("Scene Janitor")]
[assembly: AssemblyCopyright("Developed by minecart")]
[assembly: AssemblyTrademark("minecart")]
[assembly: AssemblyFileVersion("1.1.0")]
[assembly: MelonInfo(typeof(Main), "Scene Janitor", "1.1.0", "minecart", "https://github.com/minecartman/SceneJanitor")]
[assembly: MelonColor(255, 255, 255, 255)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.1.0.0")]
namespace scene_janitor;

internal class Main : MelonMod
{
	internal const string Name = "Scene Janitor";

	internal const string Description = "it clean the scene";

	internal const string Author = "minecart";

	internal const string Company = "minecart";

	internal const string Version = "1.1.0";

	internal const string DownloadLink = "https://github.com/minecartman/SceneJanitor";

	public override void OnInitializeMelon()
	{
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_015b: Unknown result type (might be due to invalid IL or missing references)
		//IL_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_01db: Unknown result type (might be due to invalid IL or missing references)
		//IL_0209: Unknown result type (might be due to invalid IL or missing references)
		//IL_0237: Unknown result type (might be due to invalid IL or missing references)
		//IL_0265: Unknown result type (might be due to invalid IL or missing references)
		//IL_0293: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_031c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0340: Unknown result type (might be due to invalid IL or missing references)
		//IL_036e: Unknown result type (might be due to invalid IL or missing references)
		((MelonBase)this).OnInitializeMelon();
		MelonLogger.Msg("Scene Janitor Loaded");
		Page val = Page.Root.CreatePage("Scene Janitor", new Color(0.486f, 0.871f, 1f), 0, true);
		BoolElement val2 = val.CreateBool("Use Fusion Methods", new Color(1f, 1f, 1f), VarSaves.FusionSyncBool, (Action<bool>)delegate(bool value)
		{
			VarSaves.FusionSyncBool = value;
		});
		Page val3 = val.CreatePage("Crate Management", new Color(0.8f, 0.6f, 1f), 0, true);
		val3.CreateFunction("NOTE: Non Fusion Methods are currently extremely buggy.", new Color(1f, 1f, 0.5f), (Action)null);
		FunctionElement val4 = val3.CreateFunction("Despawn All Props", new Color(1f, 0.5f, 0.5f), (Action)DespawnProps);
		FunctionElement val5 = val3.CreateFunction("Clear & Restore Old Props", new Color(0.5f, 1f, 0.5f), (Action)RestoreCleanup);
		FunctionElement val6 = val3.CreateFunction("Spawn All Props", new Color(1f, 1f, 0.5f), (Action)PropSpawn);
		Page val7 = val.CreatePage("NPC Cleanup", new Color(0.6f, 1f, 0.6f), 0, true);
		FunctionElement val8 = val7.CreateFunction("Clear all NPCs", new Color(1f, 1f, 1f), (Action)AllNPCClear);
		FunctionElement val9 = val7.CreateFunction("Clear all Dead NPCs", new Color(1f, 0.8f, 0.8f), (Action)DeadNPCALLCLEAR);
		FunctionElement val10 = val7.CreateFunction("Clear Fords", new Color(0.6f, 1f, 0.6f), (Action)FordClearVoid);
		FunctionElement val11 = val7.CreateFunction("Clear Nullbodies", new Color(1f, 0.8f, 0.6f), (Action)NullClearVoid);
		FunctionElement val12 = val7.CreateFunction("Clear Crablets", new Color(1f, 0.6f, 0.6f), (Action)CrabClearVoid);
		FunctionElement val13 = val7.CreateFunction("Clear Omnis", new Color(1f, 1f, 0.8f), (Action)OmniClearVoid);
		FunctionElement val14 = val7.CreateFunction("Clear Skeletons", new Color(0.9f, 0.9f, 0.9f), (Action)SkeleClearVoid);
		FunctionElement val15 = val7.CreateFunction("Clear Peasants", new Color(0.8f, 0.7f, 1f), (Action)PeasantCLearVoid);
		FunctionElement val16 = val7.CreateFunction("Clear Early Exits", new Color(0.5f, 0.5f, 1f), (Action)ZombieVoid);
		Page val17 = val.CreatePage("Misc. Cleanup", new Color(1f, 0.7f, 0.8f), 0, true);
		FunctionElement val18 = val17.CreateFunction("Clear all Dev Tools", new Color(1f, 0.9f, 0.7f), (Action)DevToolCleanupVoid);
		FunctionElement val19 = val17.CreateFunction("Clear all Debris (Client Side Only)", new Color(1f, 0.5f, 0f), (Action)debriscleanupbutwiththethingthatmakesthenotificationtrue);
	}

	public void NotificationVoid(string Message, NotificationType NotifType, float Length, bool ShowTitle)
	{
		//IL_0001: 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_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: 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_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Expected O, but got Unknown
		Notification val = new Notification
		{
			Title = NotificationText.op_Implicit("Scene Janitor"),
			Message = NotificationText.op_Implicit(Message),
			Type = NotifType,
			PopupLength = Length,
			ShowTitleOnPopup = ShowTitle
		};
		Notifier.Send(val);
	}

	public void PropCleanup(bool Despawning, bool Restoring, string NotifText)
	{
		bool flag = false;
		if (VarSaves.FusionSyncBool)
		{
			if (!NetworkInfo.IsHost)
			{
				NotificationVoid("You are not the server host!", (NotificationType)2, 4f, ShowTitle: true);
				return;
			}
			if (Despawning)
			{
				flag = true;
				PooleeUtilities.DespawnAll();
				DebrisCleanupVoid(shownotif: false);
			}
		}
		GameObject[] array = Il2CppArrayBase<GameObject>.op_Implicit(Object.FindObjectsOfType<GameObject>());
		if (!VarSaves.FusionSyncBool && Despawning)
		{
			GameObject[] array2 = Il2CppArrayBase<GameObject>.op_Implicit(Object.FindObjectsOfType<GameObject>());
			GameObject[] array3 = array2;
			foreach (GameObject val in array3)
			{
				if ((Object)(object)val.GetComponent<Poolee>() != (Object)null && (Object)(object)val.GetComponent<MarrowEntity>() != (Object)null && val.layer != LayerMask.NameToLayer("Player") && val.tag == "Untagged" && (Object)(object)val.GetComponentInChildren<Tracker>() != (Object)null && (((Object)(object)val.GetComponent<MarrowBody>() != (Object)null) | ((Object)(object)val.GetComponentInChildren<MarrowBody>() != (Object)null)) && (((Object)(object)val.GetComponentInChildren<InteractableHost>() != (Object)null) | ((Object)(object)val.GetComponent<InteractableHost>() != (Object)null)))
				{
					flag = true;
					val.GetComponent<Poolee>().Despawn();
				}
			}
			DebrisCleanupVoid(shownotif: false);
		}
		GameObject[] array4 = array;
		foreach (GameObject val2 in array4)
		{
			if (Restoring && (Object)(object)val2.GetComponent<CrateSpawner>() != (Object)null && val2.layer == LayerMask.NameToLayer("Ignore Raycast") && val2.active && !val2.GetComponent<CrateSpawner>().manualMode)
			{
				string text = ((Object)((ScannableReference)val2.GetComponent<CrateSpawner>().spawnableCrateReference).Barcode).ToString();
				if ((text == "Lakatrazz.FusionContent.Spawnable.BitMart") | (text == "Lakatrazz.FusionContent.Spawnable.InfoBoard") | (text == "Lakatrazz.FusionContent.Spawnable.AchievementBoard"))
				{
					return;
				}
				flag = true;
				val2.GetComponent<CrateSpawner>().SpawnSpawnable();
			}
		}
		if (flag)
		{
			MelonLogger.Msg(NotifText);
			NotificationVoid(NotifText, (NotificationType)3, 1f, ShowTitle: true);
		}
	}

	private void RestoreCleanup()
	{
		PropCleanup(Despawning: true, Restoring: true, "Cleared & Restored Props");
	}

	private void PropSpawn()
	{
		PropCleanup(Despawning: false, Restoring: true, "Spawned Props");
	}

	private void DespawnProps()
	{
		PropCleanup(Despawning: true, Restoring: false, "Despawned Props");
	}

	public void NPCCleanup(string nameLook, string NotifText, bool SpecificNPC, bool DeadOnly)
	{
		bool flag = false;
		if (VarSaves.FusionSyncBool && !NetworkInfo.IsHost)
		{
			NotificationVoid("You are not the server host!", (NotificationType)2, 4f, ShowTitle: true);
			return;
		}
		GameObject[] array = Il2CppArrayBase<GameObject>.op_Implicit(Object.FindObjectsOfType<GameObject>());
		GameObject[] array2 = array;
		foreach (GameObject val in array2)
		{
			if (!((Object)(object)val.GetComponent<Poolee>() != (Object)null) || !((Object)(object)val.GetComponent<MarrowEntity>() != (Object)null) || val.layer == LayerMask.NameToLayer("Player") || !(val.tag == "Untagged") || !((Object)(object)val.GetComponentInChildren<Tracker>() != (Object)null) || !(((Object)(object)val.GetComponent<MarrowBody>() != (Object)null) | ((Object)(object)val.GetComponentInChildren<MarrowBody>() != (Object)null)) || !(((Object)(object)val.GetComponentInChildren<InteractableHost>() != (Object)null) | ((Object)(object)val.GetComponent<InteractableHost>() != (Object)null)) || !Object.op_Implicit((Object)(object)val.GetComponent<AIBrain>()))
			{
				continue;
			}
			if (SpecificNPC)
			{
				if (DeadOnly)
				{
					if (val.GetComponent<AIBrain>().isDead && ((Object)val).name.Contains(nameLook))
					{
						flag = true;
						val.GetComponent<Poolee>().Despawn();
					}
				}
				else if (((Object)val).name.Contains(nameLook))
				{
					flag = true;
					val.GetComponent<Poolee>().Despawn();
				}
			}
			else if (DeadOnly)
			{
				if (val.GetComponent<AIBrain>().isDead)
				{
					flag = true;
					val.GetComponent<Poolee>().Despawn();
				}
			}
			else
			{
				flag = true;
				val.GetComponent<Poolee>().Despawn();
			}
		}
		if (flag && NotifText != null)
		{
			MelonLogger.Msg(NotifText);
			NotificationVoid(NotifText, (NotificationType)3, 1f, ShowTitle: true);
		}
	}

	private void AllNPCClear()
	{
		NPCCleanup(null, "Cleared all NPCs", SpecificNPC: false, DeadOnly: false);
	}

	private void DeadNPCALLCLEAR()
	{
		NPCCleanup(null, "Cleared all Dead NPCs", SpecificNPC: false, DeadOnly: true);
	}

	private void FordClearVoid()
	{
		NPCCleanup("NPC_Ford_BWOrig", "Cleared all Fords", SpecificNPC: true, DeadOnly: false);
	}

	private void NullClearVoid()
	{
		NPCCleanup("Null", "Cleared all Nullbodies", SpecificNPC: true, DeadOnly: false);
	}

	private void CrabClearVoid()
	{
		NPCCleanup("Crablet", "I HATE THOSE STUPID CRABS GAHHHHHHH", SpecificNPC: true, DeadOnly: false);
	}

	private void OmniClearVoid()
	{
		NPCCleanup("omniProjector_hazmat", "Cleared all Omni Projectors", SpecificNPC: true, DeadOnly: false);
	}

	private void SkeleClearVoid()
	{
		NPCCleanup("Skeleton", "Cleared all Skeletons", SpecificNPC: true, DeadOnly: false);
	}

	private void PeasantCLearVoid()
	{
		NPCCleanup("NPC_Peasant", "Cleared all Peasants", SpecificNPC: true, DeadOnly: false);
	}

	private void ZombieVoid()
	{
		NPCCleanup("Ford_EarlyExit", "Cleared all Early Exits", SpecificNPC: true, DeadOnly: false);
	}

	public void DevToolCleanupVoid()
	{
		bool flag = false;
		if (VarSaves.FusionSyncBool && !NetworkInfo.IsHost)
		{
			NotificationVoid("You are not the server host!", (NotificationType)2, 4f, ShowTitle: true);
			return;
		}
		GameObject[] array = Il2CppArrayBase<GameObject>.op_Implicit(Object.FindObjectsOfType<GameObject>());
		GameObject[] array2 = array;
		foreach (GameObject val in array2)
		{
			if ((Object)(object)val.GetComponent<Poolee>() != (Object)null && (Object)(object)val.GetComponent<MarrowEntity>() != (Object)null && val.layer != LayerMask.NameToLayer("Player") && val.tag == "Untagged" && (Object.op_Implicit((Object)(object)val.GetComponentByName("SpawnGun")) | Object.op_Implicit((Object)(object)val.GetComponent<FlyingGun>()) | Object.op_Implicit((Object)(object)val.GetComponent<Constrainer>())))
			{
				flag = true;
				val.GetComponent<Poolee>().Despawn();
			}
		}
		if (flag)
		{
			MelonLogger.Msg("Cleared all Dev Tools");
			NotificationVoid("Cleared all Dev Tools", (NotificationType)3, 1f, ShowTitle: true);
		}
	}

	public void DebrisCleanupVoid(bool shownotif)
	{
		bool flag = false;
		GameObject[] array = Il2CppArrayBase<GameObject>.op_Implicit(Object.FindObjectsOfType<GameObject>());
		GameObject[] array2 = array;
		foreach (GameObject val in array2)
		{
			if ((Object)(object)val.GetComponent<Poolee>() != (Object)null && val.tag == "Untagged" && (Object.op_Implicit((Object)(object)val.GetComponent<DecalProjector>()) | Object.op_Implicit((Object)(object)val.GetComponent<SpawnFragment>()) | Object.op_Implicit((Object)(object)val.GetComponent<FirearmCartridge>())))
			{
				flag = true;
				val.GetComponent<Poolee>().Despawn();
			}
		}
		if (flag && shownotif)
		{
			MelonLogger.Msg("Cleared all Debris");
			NotificationVoid("Cleared all Debris", (NotificationType)3, 1f, ShowTitle: true);
		}
	}

	private void debriscleanupbutwiththethingthatmakesthenotificationtrue()
	{
		DebrisCleanupVoid(shownotif: true);
	}
}
public static class VarSaves
{
	public static bool FusionSyncBool = true;
}