Decompiled source of FusionReborn v1.3.0

Mods/FusionReborn.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BoneLib.BoneMenu;
using BoneLib.Notifications;
using FusionReborn;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.Pool;
using LabFusion.Data;
using LabFusion.Downloading.ModIO;
using LabFusion.Entities;
using LabFusion.Marrow.Pool;
using LabFusion.Marrow.Serialization;
using LabFusion.Network;
using LabFusion.Network.Serialization;
using LabFusion.Permissions;
using LabFusion.Player;
using LabFusion.RPC;
using LabFusion.Representation;
using LabFusion.SDK.Lobbies;
using LabFusion.SDK.Modules;
using LabFusion.Senders;
using LabFusion.Utilities;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Reborn), "Fusion: Reborn", "1.0.0", "Gerf.", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Gerf.")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Fusion: Reborn")]
[assembly: AssemblyTitle("FusionReborn")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 FusionReborn
{
	public class Reborn : MelonMod
	{
		public static Reborn Instance { get; private set; }

		public override void OnInitializeMelon()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0026: Expected O, but got Unknown
			Instance = this;
			RebornConfig.Load();
			Harmony val = new Harmony("com.gerf.fusionreborn");
			val.PatchAll();
			NetworkSpawnPermissionGuard.TryPatch(val);
			NetworkSpawnBarcodeGuard.TryPatch(val);
			ModuleManager.RegisterModule<RebornNetModule>();
			ModuleMessageManager.RegisterHandler<PresenceMessageHandler>();
			ModuleMessageManager.RegisterHandler<VitalityAlertMessageHandler>();
			ModuleMessageManager.RegisterHandler<FlyhackAlertMessageHandler>();
			HostSync.Initialize();
			ObjectSpawnGuard.Initialize();
			FlyhackGuard.Initialize();
			VitalityGuard.Initialize();
			ModioGuard.Initialize();
			ServerHider.Initialize();
			PanicKick.Initialize();
			DespawnAllLoop.Initialize();
			AutoVolumeLimiter.Initialize();
			EmissionBloomGuard.Initialize();
			SceneObjectCapGuard.Initialize();
			RebornMenu.Setup();
		}

		public override void OnUpdate()
		{
			PlayerGuardTick.Tick();
			PanicKick.Tick();
			DespawnAllLoop.Tick();
			AutoVolumeLimiter.Tick();
		}

		public override void OnDeinitializeMelon()
		{
			RebornConfig.Save();
		}
	}
	public static class RebornConfig
	{
		public static readonly List<string> DefaultBlockedSpawnables = new List<string> { "stayx.weaponpack.Spawnable.NuclearBomb", "Cancer.Test.Spawnable.Test", "stayx.weaponpack.Spawnable.BigExplosion", "BaBaCorp.MiscExplosiveDevices.Spawnable.Missile", "BaBaCorp.MiscExplosiveDevices.Spawnable.ExplosionMissile", "BaBaCorp.MiscExplosiveDevices.Spawnable.MiniMissile", "BaBaCorp.MiscExplosiveDevices.Spawnable.IncinMissile", "BaBaCorp.MiscExplosiveDevices.Spawnable.ExplosionFlameMissile", "BaBaCorp.MiscExplosiveDevices.Spawnable.ExplosionDivineLight", "BaBaCorp.MiscExplosiveDevices.Spawnable.KCB4VoidTunnelingDevice" };

		public static readonly List<string> DefaultAmmoBarcodeKeywords = new List<string> { "ammo", "bullet", "cartridge", "casing", "shellcasing", "shell", "round" };

		public static readonly List<string> DefaultBlockedModioProfiles = new List<string> { "6ixleafclover", "Kozmo_123", "fracturedterps", "E7huzzALT", "E7huzz", "Fraud33", "SoopSaw", "Milonthevr" };

		public static float FuzzyNameSimilarityThreshold = 0.82f;

		public static readonly List<string> DefaultServerHideCodewords = new List<string>
		{
			"Hood", "hood", "rus", "Rus", "russian", "Russian", "Pol", "pol", "poland", "Poland",
			"ukr", "Ukr", "Ukraine", "ukraine"
		};

		public const float VitalityHardCapThreshold = 1000f;

		public static HashSet<string> BlockedSpawnables = new HashSet<string>();

		public static HashSet<string> BlockedModioProfiles = new HashSet<string>();

		public static HashSet<string> ServerHideCodewords = new HashSet<string>();

		public static HashSet<string> AmmoBarcodeKeywords = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

		public static MelonPreferences_Category Category;

		public static MelonPreferences_Entry<bool> ObjectSpawnGuardEnabled;

		public static MelonPreferences_Entry<bool> FlyhackGuardEnabled;

		public static MelonPreferences_Entry<bool> VitalityGuardEnabled;

		public static MelonPreferences_Entry<bool> KickOnInfiniteVitality;

		public static MelonPreferences_Entry<bool> RestrictNetworkedSpawningToOperators;

		public static MelonPreferences_Entry<bool> ModBlacklistEnabled;

		public static MelonPreferences_Entry<bool> ServerHidingEnabled;

		public static MelonPreferences_Entry<bool> PanicKickEnabled;

		public static MelonPreferences_Entry<KeyCode> PanicKickKey;

		public static MelonPreferences_Entry<bool> DespawnAllKeyEnabled;

		public static MelonPreferences_Entry<KeyCode> DespawnAllKey;

		public static MelonPreferences_Entry<int> MaxSceneObjects;

		public static MelonPreferences_Entry<bool> AutoVolumeLimiterEnabled;

		public static MelonPreferences_Entry<float> AutoVolumeLoudnessThreshold;

		public static MelonPreferences_Entry<float> AutoVolumeMaxReduction;

		public static MelonPreferences_Entry<bool> EmissionBloomGuardEnabled;

		public static MelonPreferences_Entry<float> EmissionIntensityThreshold;

		public static MelonPreferences_Entry<float> MaxAllowedSpeed;

		public static void Load()
		{
			Category = MelonPreferences.CreateCategory("FusionReborn");
			ObjectSpawnGuardEnabled = Category.CreateEntry<bool>("ObjectSpawnGuardEnabled", true, "Block Greifing Items", (string)null, false, false, (ValueValidator)null, (string)null);
			FlyhackGuardEnabled = Category.CreateEntry<bool>("FlyhackGuardEnabled", true, "Flyhack Detection", (string)null, false, false, (ValueValidator)null, (string)null);
			VitalityGuardEnabled = Category.CreateEntry<bool>("VitalityGuardEnabled", true, "Infinite Health Detection", (string)null, false, false, (ValueValidator)null, (string)null);
			KickOnInfiniteVitality = Category.CreateEntry<bool>("KickOnInfiniteVitality", true, "Kick on Infinite Health", (string)null, false, false, (ValueValidator)null, (string)null);
			RestrictNetworkedSpawningToOperators = Category.CreateEntry<bool>("RestrictNetworkedSpawningToOperators", false, "Block Spawn Requests", (string)null, false, false, (ValueValidator)null, (string)null);
			MaxAllowedSpeed = Category.CreateEntry<float>("MaxAllowedSpeed", 40f, "Max Allowed Player Speed (u/s)", (string)null, false, false, (ValueValidator)null, (string)null);
			ModBlacklistEnabled = Category.CreateEntry<bool>("ModBlacklistEnabled", false, "Hide Hood Avatars", (string)null, false, false, (ValueValidator)null, (string)null);
			ServerHidingEnabled = Category.CreateEntry<bool>("ServerHidingEnabled", false, "Hide Hood & Racist Servers", (string)null, false, false, (ValueValidator)null, (string)null);
			PanicKickEnabled = Category.CreateEntry<bool>("PanicKickEnabled", true, "Enable Panic Kick Key", (string)null, false, false, (ValueValidator)null, (string)null);
			PanicKickKey = Category.CreateEntry<KeyCode>("PanicKickKey", (KeyCode)290, "Panic Kick All Key", (string)null, false, false, (ValueValidator)null, (string)null);
			DespawnAllKeyEnabled = Category.CreateEntry<bool>("DespawnAllKeyEnabled", true, "Despawn All Key Enabled", (string)null, false, false, (ValueValidator)null, (string)null);
			DespawnAllKey = Category.CreateEntry<KeyCode>("DespawnAllKey", (KeyCode)289, "Despawn All Key", (string)null, false, false, (ValueValidator)null, (string)null);
			MaxSceneObjects = Category.CreateEntry<int>("MaxSceneObjects", 300, "Max Scene Objects", (string)null, false, false, (ValueValidator)null, (string)null);
			AutoVolumeLimiterEnabled = Category.CreateEntry<bool>("AutoVolumeLimiterEnabled", true, "Auto Volume Limiter", (string)null, false, false, (ValueValidator)null, (string)null);
			AutoVolumeLoudnessThreshold = Category.CreateEntry<float>("AutoVolumeLoudnessThreshold", -10f, "Loudness Threshold (dB)", (string)null, false, false, (ValueValidator)null, (string)null);
			AutoVolumeMaxReduction = Category.CreateEntry<float>("AutoVolumeMaxReduction", 0.6f, "Max Volume Reduction", (string)null, false, false, (ValueValidator)null, (string)null);
			EmissionBloomGuardEnabled = Category.CreateEntry<bool>("EmissionBloomGuardEnabled", true, "Disable Overbright Emission", (string)null, false, false, (ValueValidator)null, (string)null);
			EmissionIntensityThreshold = Category.CreateEntry<float>("EmissionIntensityThreshold", 5f, "Emission Intensity Threshold", (string)null, false, false, (ValueValidator)null, (string)null);
			BlockedSpawnables = new HashSet<string>(DefaultBlockedSpawnables);
			BlockedModioProfiles = new HashSet<string>(DefaultBlockedModioProfiles);
			ServerHideCodewords = new HashSet<string>(DefaultServerHideCodewords, StringComparer.OrdinalIgnoreCase);
			AmmoBarcodeKeywords = new HashSet<string>(DefaultAmmoBarcodeKeywords, StringComparer.OrdinalIgnoreCase);
		}

		public static void Save()
		{
			MelonPreferences_Category category = Category;
			if (category != null)
			{
				category.SaveToFile(false);
			}
		}
	}
	public class RebornNetModule : Module
	{
		public override string Name => "Fusion: Reborn";

		public override string Author => "Gerf.";

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

		public override ConsoleColor Color => ConsoleColor.Red;

		protected override void OnModuleRegistered()
		{
		}
	}
	public class PresenceMessageHandler : ModuleMessageHandler
	{
		protected override void OnHandleMessage(ReceivedMessage received)
		{
			NetReader val = NetReader.Create(((ReceivedMessage)(ref received)).Bytes);
			try
			{
				if (val.ReadByte() == 1 && ((ReceivedMessage)(ref received)).Sender == 0)
				{
					HostSync.OnPresenceReceivedFromHost();
				}
			}
			finally
			{
				((IDisposable)val)?.Dispose();
			}
		}
	}
	public class VitalityAlertMessageHandler : ModuleMessageHandler
	{
		protected override void OnHandleMessage(ReceivedMessage received)
		{
			if (!NetworkInfo.IsHost)
			{
				return;
			}
			NetReader val = NetReader.Create(((ReceivedMessage)(ref received)).Bytes);
			try
			{
				string title = val.ReadString();
				string message = val.ReadString();
				VitalityGuard.OnVitalityAlertReceived(title, message);
			}
			finally
			{
				((IDisposable)val)?.Dispose();
			}
		}
	}
	public class FlyhackAlertMessageHandler : ModuleMessageHandler
	{
		protected override void OnHandleMessage(ReceivedMessage received)
		{
			if (!NetworkInfo.IsHost)
			{
				return;
			}
			NetReader val = NetReader.Create(((ReceivedMessage)(ref received)).Bytes);
			try
			{
				string title = val.ReadString();
				string message = val.ReadString();
				FlyhackGuard.OnFlyhackAlertReceived(title, message);
			}
			finally
			{
				((IDisposable)val)?.Dispose();
			}
		}
	}
	public static class HostSync
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static ServerEvent <0>__OnJoinedServer;

			public static PlayerUpdate <1>__OnPlayerJoined;

			public static ServerEvent <2>__OnDisconnected;
		}

		public static bool HostHasReborn { get; private set; }

		public static bool HostEnforcementActive
		{
			get
			{
				if (NetworkInfo.HasServer)
				{
					return HostHasReborn;
				}
				return false;
			}
		}

		public static void Initialize()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0030: 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_003b: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			object obj = <>O.<0>__OnJoinedServer;
			if (obj == null)
			{
				ServerEvent val = OnJoinedServer;
				<>O.<0>__OnJoinedServer = val;
				obj = (object)val;
			}
			MultiplayerHooking.OnJoinedServer += (ServerEvent)obj;
			object obj2 = <>O.<1>__OnPlayerJoined;
			if (obj2 == null)
			{
				PlayerUpdate val2 = OnPlayerJoined;
				<>O.<1>__OnPlayerJoined = val2;
				obj2 = (object)val2;
			}
			MultiplayerHooking.OnPlayerJoined += (PlayerUpdate)obj2;
			object obj3 = <>O.<2>__OnDisconnected;
			if (obj3 == null)
			{
				ServerEvent val3 = OnDisconnected;
				<>O.<2>__OnDisconnected = val3;
				obj3 = (object)val3;
			}
			MultiplayerHooking.OnDisconnected += (ServerEvent)obj3;
		}

		private static void OnJoinedServer()
		{
			HostHasReborn = false;
			BroadcastPresence();
		}

		private static void OnPlayerJoined(PlayerID player)
		{
			BroadcastPresence();
		}

		private static void OnDisconnected()
		{
			HostHasReborn = false;
		}

		private static void BroadcastPresence()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				NetWriter val = NetWriter.Create();
				try
				{
					val.Write((byte)1);
					NetMessage val2 = NetMessage.ModuleCreate(typeof(PresenceMessageHandler), val, CommonMessageRoutes.ReliableToServer, (byte?)PlayerIDManager.LocalSmallID);
					try
					{
						MessageSender.SendToServer((NetworkChannel)0, val2);
						if (NetworkInfo.IsHost)
						{
							HostHasReborn = true;
						}
					}
					finally
					{
						((IDisposable)val2)?.Dispose();
					}
				}
				finally
				{
					((IDisposable)val)?.Dispose();
				}
			}
			catch (Exception)
			{
			}
		}

		public static void OnPresenceReceivedFromHost()
		{
			HostHasReborn = true;
		}
	}
	public static class HostAlerts
	{
		public static void Send<THandler>(string title, string message) where THandler : ModuleMessageHandler
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (NetworkInfo.IsHost)
				{
					ShowLocal(title, message);
					return;
				}
				NetWriter val = NetWriter.Create();
				try
				{
					val.Write(title);
					val.Write(message);
					NetMessage val2 = NetMessage.ModuleCreate(typeof(THandler), val, CommonMessageRoutes.ReliableToServer, (byte?)PlayerIDManager.LocalSmallID);
					try
					{
						MessageSender.SendToServer((NetworkChannel)0, val2);
					}
					finally
					{
						((IDisposable)val2)?.Dispose();
					}
				}
				finally
				{
					((IDisposable)val)?.Dispose();
				}
			}
			catch (Exception)
			{
			}
		}

		public static void ShowLocal(string title, string message)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: 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_0013: 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_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			Notifier.Send(new Notification
			{
				Title = NotificationText.op_Implicit(title),
				Message = NotificationText.op_Implicit(message),
				ShowTitleOnPopup = true,
				Type = (NotificationType)1,
				PopupLength = 6f
			});
		}
	}
	public static class ObjectSpawnGuard
	{
		public static void Initialize()
		{
		}

		public static bool IsBlocked(string barcode)
		{
			if (RebornConfig.ObjectSpawnGuardEnabled.Value && !string.IsNullOrEmpty(barcode))
			{
				return RebornConfig.BlockedSpawnables.Contains(barcode);
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(LocalAssetSpawner), "CreateSpawnable", new Type[] { typeof(string) })]
	public static class SpawnBlockPatch
	{
		[HarmonyPrefix]
		public static bool Prefix(string barcode)
		{
			if (!HostSync.HostEnforcementActive)
			{
				return true;
			}
			if (!ObjectSpawnGuard.IsBlocked(barcode))
			{
				return true;
			}
			return false;
		}
	}
	public static class NetworkSpawnPermissionGuard
	{
		public static void TryPatch(Harmony harmony)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			try
			{
				MethodInfo methodInfo = AccessTools.Method(typeof(SpawnRequestMessage), "OnHandleMessage", (Type[])null, (Type[])null);
				if (!(methodInfo == null))
				{
					harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(NetworkSpawnPermissionGuard), "Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
			}
			catch (Exception)
			{
			}
		}

		public static bool Prefix(ReceivedMessage received)
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkInfo.IsHost)
			{
				return true;
			}
			if (!RebornConfig.RestrictNetworkedSpawningToOperators.Value)
			{
				return true;
			}
			if (((ReceivedMessage)(ref received)).Sender == 0)
			{
				return true;
			}
			try
			{
				if (!FusionDevTools.DevToolsDisabled)
				{
					return true;
				}
			}
			catch (Exception)
			{
			}
			if (((ReceivedMessage)(ref received)).Sender.HasValue && IsSenderAuthorized(((ReceivedMessage)(ref received)).Sender.Value))
			{
				return true;
			}
			if (IsAmmoOrBulletRequest(received))
			{
				return true;
			}
			return false;
		}

		private static bool IsAmmoOrBulletRequest(ReceivedMessage received)
		{
			try
			{
				string barcode = ((ReceivedMessage)(ref received)).ReadData<SerializedSpawnData>().Barcode;
				if (string.IsNullOrEmpty(barcode))
				{
					return false;
				}
				string[] array = barcode.Split(new char[6] { '.', '_', '-', ' ', '/', '\\' }, StringSplitOptions.RemoveEmptyEntries);
				foreach (string a in array)
				{
					foreach (string ammoBarcodeKeyword in RebornConfig.AmmoBarcodeKeywords)
					{
						if (string.Equals(a, ammoBarcodeKeyword, StringComparison.OrdinalIgnoreCase))
						{
							return true;
						}
						if (ModioGuard.NameSimilarity(a, ammoBarcodeKeyword) >= RebornConfig.FuzzyNameSimilarityThreshold)
						{
							return true;
						}
					}
				}
			}
			catch (Exception)
			{
			}
			return false;
		}

		private static bool IsSenderAuthorized(byte senderSmallId)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			if (!PlayerIDManager.HasPlayerID(senderSmallId))
			{
				return false;
			}
			PlayerID playerID = PlayerIDManager.GetPlayerID(senderSmallId);
			try
			{
				PermissionLevel val = default(PermissionLevel);
				Color val2 = default(Color);
				FusionPermissions.FetchPermissionLevel(playerID.PlatformID, ref val, ref val2);
				if (FusionPermissions.HasSufficientPermissions(val, (PermissionLevel)1))
				{
					return true;
				}
			}
			catch (Exception)
			{
			}
			try
			{
				if (MasterPermissionsManager.IsMaster(playerID.PlatformID))
				{
					return true;
				}
			}
			catch (Exception)
			{
			}
			return false;
		}
	}
	public static class NetworkSpawnBarcodeGuard
	{
		public static void TryPatch(Harmony harmony)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			try
			{
				MethodInfo methodInfo = AccessTools.Method(typeof(SpawnRequestMessage), "OnHandleMessage", (Type[])null, (Type[])null);
				if (!(methodInfo == null))
				{
					harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(NetworkSpawnBarcodeGuard), "Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
			}
			catch (Exception)
			{
			}
		}

		public static bool Prefix(ReceivedMessage received)
		{
			if (!NetworkInfo.IsHost)
			{
				return true;
			}
			string barcode;
			try
			{
				barcode = ((ReceivedMessage)(ref received)).ReadData<SerializedSpawnData>().Barcode;
			}
			catch (Exception)
			{
				return true;
			}
			if (!ObjectSpawnGuard.IsBlocked(barcode))
			{
				return true;
			}
			return false;
		}
	}
	public static class PlayerGuardTick
	{
		private const float IntervalSeconds = 0.15f;

		private static float _accumulator;

		public static void Tick()
		{
			_accumulator += Time.unscaledDeltaTime;
			if (_accumulator < 0.15f)
			{
				return;
			}
			_accumulator = 0f;
			if (!HostSync.HostEnforcementActive)
			{
				return;
			}
			bool value = RebornConfig.FlyhackGuardEnabled.Value;
			bool value2 = RebornConfig.VitalityGuardEnabled.Value;
			if (!value && !value2)
			{
				return;
			}
			RigRefs val = default(RigRefs);
			foreach (PlayerID playerID in PlayerIDManager.PlayerIDs)
			{
				if (!playerID.IsMe && PlayerRepUtilities.TryGetReferences(playerID.SmallID, ref val) && val.IsValid)
				{
					if (value)
					{
						FlyhackGuard.Check(playerID, val);
					}
					if (value2)
					{
						VitalityGuard.Check(playerID, val);
					}
				}
			}
		}
	}
	public static class FlyhackGuard
	{
		private class TrackedPlayer
		{
			public Vector3 LastPosition;

			public float LastCheckTime;

			public int ViolationStrikes;
		}

		private static readonly Dictionary<byte, TrackedPlayer> _tracked = new Dictionary<byte, TrackedPlayer>();

		private const float TeleportIgnoreThreshold = 15f;

		private const int StrikesBeforeAction = 6;

		public static void Initialize()
		{
		}

		public static void Check(PlayerID playerId, RigRefs refs)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			RigManager rigManager = refs.RigManager;
			if ((Object)(object)rigManager == (Object)null)
			{
				return;
			}
			Vector3 position = ((Rig)rigManager.physicsRig).m_pelvis.position;
			float time = Time.time;
			if (!_tracked.TryGetValue(playerId.SmallID, out var value))
			{
				_tracked[playerId.SmallID] = new TrackedPlayer
				{
					LastPosition = position,
					LastCheckTime = time
				};
				return;
			}
			float num = time - value.LastCheckTime;
			if (num <= 0f)
			{
				return;
			}
			float num2 = Vector3.Distance(position, value.LastPosition);
			float num3 = num2 / num;
			if (num2 < 15f && num3 > RebornConfig.MaxAllowedSpeed.Value)
			{
				value.ViolationStrikes++;
				if (value.ViolationStrikes >= 6)
				{
					HandleFlyhackDetected(playerId, num3);
					value.ViolationStrikes = 0;
				}
			}
			else
			{
				value.ViolationStrikes = 0;
			}
			value.LastPosition = position;
			value.LastCheckTime = time;
		}

		private static void HandleFlyhackDetected(PlayerID playerId, float speed)
		{
			string value = $"exceeded max speed ({speed:F1} u/s)";
			HostAlerts.Send<FlyhackAlertMessageHandler>("Fusion: Reborn", $"Possible flyhack: Player {playerId.SmallID} ({value})");
		}

		public static void OnFlyhackAlertReceived(string title, string message)
		{
			HostAlerts.ShowLocal(title, message);
		}
	}
	public static class VitalityGuard
	{
		private class HealthTrack
		{
			public float LastKnownHealth;

			public int UnchangedAfterDamageCount;

			public bool AlreadyFlaggedHardCap;

			public bool AlreadyKicked;
		}

		private static readonly Dictionary<byte, HealthTrack> _tracked = new Dictionary<byte, HealthTrack>();

		private const int StrikesBeforeAction = 3;

		public static void Initialize()
		{
		}

		public static void Check(PlayerID playerId, RigRefs refs)
		{
			float vitalityValue = GetVitalityValue(refs);
			CheckHardCap(playerId, vitalityValue);
		}

		private static float GetVitalityValue(RigRefs refs)
		{
			_ = refs.Health;
			return 0f;
		}

		private static void CheckHardCap(PlayerID playerId, float health)
		{
			if (!_tracked.TryGetValue(playerId.SmallID, out var value))
			{
				value = new HealthTrack
				{
					LastKnownHealth = health
				};
				_tracked[playerId.SmallID] = value;
			}
			int num;
			int num2;
			if (!float.IsInfinity(health))
			{
				num = (float.IsNaN(health) ? 1 : 0);
				if (num == 0)
				{
					num2 = ((health >= 1000f) ? 1 : 0);
					goto IL_0054;
				}
			}
			else
			{
				num = 1;
			}
			num2 = 0;
			goto IL_0054;
			IL_0054:
			bool flag = (byte)num2 != 0;
			if (num != 0)
			{
				if (!value.AlreadyFlaggedHardCap)
				{
					value.AlreadyFlaggedHardCap = true;
					HandleInfiniteOrNaNDetected(playerId);
				}
			}
			else if (flag)
			{
				if (!value.AlreadyFlaggedHardCap)
				{
					value.AlreadyFlaggedHardCap = true;
					HandleOverCapDetected(playerId, health);
				}
			}
			else
			{
				value.AlreadyFlaggedHardCap = false;
				value.AlreadyKicked = false;
			}
			value.LastKnownHealth = health;
		}

		public static void DamageEventReceived(PlayerID playerId, float damageAmount, float healthBefore, float healthAfter)
		{
			if (!RebornConfig.VitalityGuardEnabled.Value || !HostSync.HostEnforcementActive)
			{
				return;
			}
			if (!_tracked.TryGetValue(playerId.SmallID, out var value))
			{
				value = new HealthTrack
				{
					LastKnownHealth = healthBefore
				};
				_tracked[playerId.SmallID] = value;
			}
			bool num = damageAmount > 0.5f;
			bool flag = healthAfter < healthBefore - 0.01f;
			if (num && !flag)
			{
				value.UnchangedAfterDamageCount++;
				if (value.UnchangedAfterDamageCount >= 3)
				{
					HandleOverCapDetected(playerId, healthAfter, "no-sold repeated damage without health decreasing");
					value.UnchangedAfterDamageCount = 0;
				}
			}
			else
			{
				value.UnchangedAfterDamageCount = 0;
			}
			value.LastKnownHealth = healthAfter;
		}

		private static void HandleInfiniteOrNaNDetected(PlayerID playerId)
		{
			string playerName = GetPlayerName(playerId);
			string text = "vitality value is Infinity/NaN";
			HostAlerts.Send<VitalityAlertMessageHandler>("Fusion: Reborn", $"Infinite vitality detected: {playerName} ({text})" + (RebornConfig.KickOnInfiniteVitality.Value ? " - kicking." : ""));
			if (RebornConfig.KickOnInfiniteVitality.Value)
			{
				TryKick(playerId, text);
			}
		}

		private static void HandleOverCapDetected(PlayerID playerId, float health, string reasonOverride = null)
		{
			string playerName = GetPlayerName(playerId);
			string value = reasonOverride ?? $"vitality value {health:F0} is at/above the {1000f:F0} hard cap";
			HostAlerts.Send<VitalityAlertMessageHandler>("Fusion: Reborn", $"Possible infinite vitality: {playerName} ({value})");
		}

		private static void TryKick(PlayerID playerId, string reason)
		{
			if (!NetworkInfo.IsHost)
			{
				return;
			}
			try
			{
				NetworkHelper.KickUser(playerId);
			}
			catch (Exception)
			{
			}
		}

		private static string GetPlayerName(PlayerID playerId)
		{
			return $"Player {playerId.SmallID}";
		}

		public static void OnVitalityAlertReceived(string title, string message)
		{
			HostAlerts.ShowLocal(title, message);
		}
	}
	public static class PanicKick
	{
		public static void Initialize()
		{
		}

		public static void Tick()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkInfo.IsHost && NetworkInfo.HasServer && RebornConfig.PanicKickEnabled.Value && Input.GetKeyDown(RebornConfig.PanicKickKey.Value))
			{
				KickAllPlayers();
			}
		}

		public static void KickAllPlayers()
		{
			List<PlayerID> list = new List<PlayerID>(PlayerIDManager.PlayerIDs);
			int num = 0;
			foreach (PlayerID item in list)
			{
				if (!item.IsMe)
				{
					try
					{
						NetworkHelper.KickUser(item);
						num++;
					}
					catch (Exception)
					{
					}
				}
			}
			HostAlerts.ShowLocal("Fusion: Reborn", $"Panic kick triggered - kicked {num} player(s).");
		}
	}
	public static class DespawnAllLoop
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static ServerEvent <0>__Stop;
		}

		private const float IntervalSeconds = 0.2f;

		private static float _accumulator;

		private static bool _active;

		public static void Initialize()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__Stop;
			if (obj == null)
			{
				ServerEvent val = Stop;
				<>O.<0>__Stop = val;
				obj = (object)val;
			}
			MultiplayerHooking.OnDisconnected += (ServerEvent)obj;
		}

		public static void Tick()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkInfo.IsHost || !NetworkInfo.HasServer)
			{
				_active = false;
			}
			else
			{
				if (!RebornConfig.DespawnAllKeyEnabled.Value)
				{
					return;
				}
				if (Input.GetKeyDown(RebornConfig.DespawnAllKey.Value))
				{
					_active = !_active;
				}
				if (_active)
				{
					_accumulator += Time.unscaledDeltaTime;
					if (!(_accumulator < 0.2f))
					{
						_accumulator = 0f;
						PooleeUtilities.DespawnAll();
					}
				}
			}
		}

		public static void DespawnAllNow()
		{
			PooleeUtilities.DespawnAll();
		}

		private static void Stop()
		{
			_active = false;
		}
	}
	public static class AutoVolumeLimiter
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static ServerEvent <0>__ResetOnDisconnect;
		}

		private static readonly float[] _samples = new float[256];

		private static bool _baselineCaptured;

		private static float _baselineVolume = 1f;

		private static float _currentReduction;

		private static bool _tooLoud;

		private const float StepDownPerSecond = 1.5f;

		private const float StepUpPerSecond = 0.5f;

		private const float SilenceFloorDb = -80f;

		private const float SampleIntervalSeconds = 0.1f;

		private static float _sampleAccumulator;

		public static void Initialize()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__ResetOnDisconnect;
			if (obj == null)
			{
				ServerEvent val = ResetOnDisconnect;
				<>O.<0>__ResetOnDisconnect = val;
				obj = (object)val;
			}
			MultiplayerHooking.OnDisconnected += (ServerEvent)obj;
		}

		public static void Tick()
		{
			if (!NetworkInfo.HasServer)
			{
				if (_baselineCaptured)
				{
					ResetOnDisconnect();
				}
				return;
			}
			if (!RebornConfig.AutoVolumeLimiterEnabled.Value)
			{
				if (_baselineCaptured)
				{
					ResetOnDisconnect();
				}
				return;
			}
			if (!_baselineCaptured)
			{
				_baselineVolume = AudioListener.volume;
				_baselineCaptured = true;
			}
			float unscaledDeltaTime = Time.unscaledDeltaTime;
			_sampleAccumulator += unscaledDeltaTime;
			if (_sampleAccumulator >= 0.1f)
			{
				_sampleAccumulator = 0f;
				_tooLoud = MeasureLoudnessDb() > RebornConfig.AutoVolumeLoudnessThreshold.Value;
			}
			float num = Mathf.Clamp01(RebornConfig.AutoVolumeMaxReduction.Value);
			if (_tooLoud)
			{
				_currentReduction = Mathf.Min(_currentReduction + 1.5f * unscaledDeltaTime, num);
			}
			else
			{
				_currentReduction = Mathf.Max(_currentReduction - 0.5f * unscaledDeltaTime, 0f);
			}
			AudioListener.volume = Mathf.Clamp01(_baselineVolume - _currentReduction);
		}

		private static float MeasureLoudnessDb()
		{
			AudioListener.GetOutputData(Il2CppStructArray<float>.op_Implicit(_samples), 0);
			float num = 0f;
			float[] samples = _samples;
			foreach (float num2 in samples)
			{
				num += num2 * num2;
			}
			float num3 = Mathf.Sqrt(num / (float)_samples.Length);
			if (!(num3 > 0.0001f))
			{
				return -80f;
			}
			return 20f * Mathf.Log10(num3);
		}

		private static void ResetOnDisconnect()
		{
			if (_baselineCaptured)
			{
				AudioListener.volume = _baselineVolume;
			}
			_baselineCaptured = false;
			_currentReduction = 0f;
			_sampleAccumulator = 0f;
			_tooLoud = false;
		}
	}
	public static class EmissionBloomGuard
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UpdateEvent <>9__2_0;

			internal void <Initialize>b__2_0()
			{
				_processedInstanceIds.Clear();
			}
		}

		private static readonly HashSet<int> _processedInstanceIds = new HashSet<int>();

		private static readonly int _emissionColorId = Shader.PropertyToID("_EmissionColor");

		public static void Initialize()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			object obj = <>c.<>9__2_0;
			if (obj == null)
			{
				UpdateEvent val = delegate
				{
					_processedInstanceIds.Clear();
				};
				<>c.<>9__2_0 = val;
				obj = (object)val;
			}
			MultiplayerHooking.OnTargetLevelLoaded += (UpdateEvent)obj;
		}

		public static void OnPooleeSpawned(Poolee poolee)
		{
			if (!RebornConfig.EmissionBloomGuardEnabled.Value || (Object)(object)poolee == (Object)null)
			{
				return;
			}
			GameObject gameObject = ((Component)poolee).gameObject;
			if ((Object)(object)gameObject == (Object)null)
			{
				return;
			}
			int instanceID = ((Object)gameObject).GetInstanceID();
			if (!_processedInstanceIds.Add(instanceID))
			{
				return;
			}
			try
			{
				StripOverbrightEmission(gameObject);
			}
			catch (Exception)
			{
			}
		}

		private static void StripOverbrightEmission(GameObject root)
		{
			//IL_0094: 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)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Expected O, but got Unknown
			Il2CppArrayBase<Renderer> componentsInChildren = root.GetComponentsInChildren<Renderer>(true);
			if (componentsInChildren == null || componentsInChildren.Length == 0)
			{
				return;
			}
			float value = RebornConfig.EmissionIntensityThreshold.Value;
			MaterialPropertyBlock val = null;
			foreach (Renderer item in componentsInChildren)
			{
				if ((Object)(object)item == (Object)null)
				{
					continue;
				}
				Il2CppReferenceArray<Material> sharedMaterials = item.sharedMaterials;
				if (sharedMaterials == null || ((Il2CppArrayBase<Material>)(object)sharedMaterials).Length == 0)
				{
					continue;
				}
				bool flag = false;
				foreach (Material item2 in (Il2CppArrayBase<Material>)(object)sharedMaterials)
				{
					if (!((Object)(object)item2 == (Object)null) && item2.HasProperty(_emissionColorId))
					{
						Color color = item2.GetColor(_emissionColorId);
						if (Mathf.Max(new float[3] { color.r, color.g, color.b }) >= value)
						{
							flag = true;
							break;
						}
					}
				}
				if (flag)
				{
					if (val == null)
					{
						val = new MaterialPropertyBlock();
					}
					item.GetPropertyBlock(val);
					val.SetColor(_emissionColorId, Color.black);
					item.SetPropertyBlock(val);
					val.Clear();
				}
			}
		}
	}
	[HarmonyPatch(typeof(LocalAssetSpawner), "Spawn")]
	public static class SceneObjectCapGuard
	{
		public static void Initialize()
		{
		}

		public static void OnPooleeSpawned(Poolee poolee)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkInfo.IsHost || !NetworkInfo.HasServer || (Object)(object)poolee == (Object)null)
			{
				return;
			}
			int value = RebornConfig.MaxSceneObjects.Value;
			if (CountSpawnedProps() <= value)
			{
				return;
			}
			NetworkEntity val = FindEntityForPoolee(poolee);
			if (val == null)
			{
				return;
			}
			try
			{
				NetworkAssetSpawner.Despawn(new DespawnRequestInfo
				{
					EntityID = val.ID,
					DespawnEffect = false
				});
			}
			catch (Exception)
			{
			}
		}

		private static int CountSpawnedProps()
		{
			int num = 0;
			foreach (NetworkEntity value in NetworkEntityManager.IDManager.RegisteredEntities.IDEntityLookup.Values)
			{
				if (value.GetExtender<NetworkProp>() != null)
				{
					num++;
				}
			}
			return num;
		}

		private static NetworkEntity FindEntityForPoolee(Poolee poolee)
		{
			foreach (NetworkEntity value in NetworkEntityManager.IDManager.RegisteredEntities.IDEntityLookup.Values)
			{
				NetworkProp extender = value.GetExtender<NetworkProp>();
				if ((Object)(object)((extender != null) ? extender.MarrowEntity : null) != (Object)null && (Object)(object)((Component)extender.MarrowEntity).gameObject == (Object)(object)((Component)poolee).gameObject)
				{
					return value;
				}
			}
			return null;
		}
	}
	public static class EmissionSpawnHookPatch
	{
		[HarmonyPrefix]
		public static void Prefix(ref Action<Poolee> spawnCallback)
		{
			Action<Poolee> original = spawnCallback;
			spawnCallback = delegate(Poolee poolee)
			{
				original?.Invoke(poolee);
				EmissionBloomGuard.OnPooleeSpawned(poolee);
				SceneObjectCapGuard.OnPooleeSpawned(poolee);
			};
		}
	}
	public static class ModioGuard
	{
		public static void Initialize()
		{
		}

		public static bool IsBlocked(string modIdOrNameId, out string matchedReason)
		{
			matchedReason = null;
			if (!RebornConfig.ModBlacklistEnabled.Value)
			{
				return false;
			}
			if (string.IsNullOrWhiteSpace(modIdOrNameId))
			{
				return false;
			}
			foreach (string blockedModioProfile in RebornConfig.BlockedModioProfiles)
			{
				if (string.Equals(blockedModioProfile, modIdOrNameId, StringComparison.OrdinalIgnoreCase))
				{
					matchedReason = "exact match to blacklisted entry '" + blockedModioProfile + "'";
					return true;
				}
			}
			foreach (string blockedModioProfile2 in RebornConfig.BlockedModioProfiles)
			{
				if (!IsNumeric(blockedModioProfile2))
				{
					float num = NameSimilarity(blockedModioProfile2, modIdOrNameId);
					if (num >= RebornConfig.FuzzyNameSimilarityThreshold)
					{
						matchedReason = $"name similar ({num:P0}) to blacklisted entry '{blockedModioProfile2}'";
						return true;
					}
				}
			}
			return false;
		}

		private static bool IsNumeric(string s)
		{
			for (int i = 0; i < s.Length; i++)
			{
				if (!char.IsDigit(s[i]))
				{
					return false;
				}
			}
			return s.Length > 0;
		}

		public static float NameSimilarity(string a, string b)
		{
			a = Normalize(a);
			b = Normalize(b);
			if (a.Length == 0 && b.Length == 0)
			{
				return 1f;
			}
			int num = LevenshteinDistance(a, b);
			int num2 = Math.Max(a.Length, b.Length);
			if (num2 != 0)
			{
				return 1f - (float)num / (float)num2;
			}
			return 1f;
		}

		private static string Normalize(string s)
		{
			return s.ToLowerInvariant().Replace("_", "").Replace("-", "")
				.Replace(".", "")
				.Replace(" ", "");
		}

		private static int LevenshteinDistance(string a, string b)
		{
			int[,] array = new int[a.Length + 1, b.Length + 1];
			for (int i = 0; i <= a.Length; i++)
			{
				array[i, 0] = i;
			}
			for (int j = 0; j <= b.Length; j++)
			{
				array[0, j] = j;
			}
			for (int k = 1; k <= a.Length; k++)
			{
				for (int l = 1; l <= b.Length; l++)
				{
					int num = ((a[k - 1] != b[l - 1]) ? 1 : 0);
					array[k, l] = Math.Min(Math.Min(array[k - 1, l] + 1, array[k, l - 1] + 1), array[k - 1, l - 1] + num);
				}
			}
			return array[a.Length, b.Length];
		}
	}
	[HarmonyPatch(typeof(ModIODownloader), "EnqueueDownload")]
	public static class ModioDownloadBlockPatch
	{
		[HarmonyPrefix]
		public static bool Prefix(ModTransaction transaction)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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)
			ModIOFile? val = ((transaction != null) ? new ModIOFile?(transaction.ModFile) : ((ModIOFile?)null));
			if (ModioGuard.IsBlocked(val.HasValue ? ((object)val.GetValueOrDefault()/*cast due to .constrained prefix*/).ToString() : null, out var _))
			{
				return false;
			}
			return true;
		}
	}
	public static class ServerHider
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static GenericLobbyDelegate <>9__1_0;

			internal bool <Initialize>b__1_0(INetworkLobby lobby, LobbyMetadataInfo info)
			{
				if (!RebornConfig.ServerHidingEnabled.Value)
				{
					return true;
				}
				LobbyInfo lobbyInfo = ((LobbyMetadataInfo)(ref info)).LobbyInfo;
				return !ShouldHide((lobbyInfo != null) ? lobbyInfo.LobbyName : null);
			}
		}

		private static GenericLobbyFilter _filter;

		public static void Initialize()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_0019: 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_0024: Expected O, but got Unknown
			object obj = <>c.<>9__1_0;
			if (obj == null)
			{
				GenericLobbyDelegate val = delegate(INetworkLobby lobby, LobbyMetadataInfo info)
				{
					if (!RebornConfig.ServerHidingEnabled.Value)
					{
						return true;
					}
					LobbyInfo lobbyInfo = ((LobbyMetadataInfo)(ref info)).LobbyInfo;
					return !ShouldHide((lobbyInfo != null) ? lobbyInfo.LobbyName : null);
				};
				<>c.<>9__1_0 = val;
				obj = (object)val;
			}
			_filter = new GenericLobbyFilter("Fusion: Reborn Codeword Filter", (GenericLobbyDelegate)obj);
			LobbyFilterManager.AddLobbyFilter((ILobbyFilter)(object)_filter);
		}

		public static bool ShouldHide(string serverName)
		{
			if (string.IsNullOrEmpty(serverName))
			{
				return false;
			}
			foreach (string serverHideCodeword in RebornConfig.ServerHideCodewords)
			{
				if (serverName.IndexOf(serverHideCodeword, StringComparison.OrdinalIgnoreCase) >= 0)
				{
					return true;
				}
			}
			return false;
		}
	}
	public static class RebornMenu
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static ServerEvent <0>__ShowHostPage;

			public static ServerEvent <1>__EnforceHostPageVisibility;

			public static ServerEvent <2>__HideHostPage;

			public static Action <3>__KickAllPlayers;

			public static Action <4>__DespawnAllNow;

			public static Action <5>__TeleportAllToHost;
		}

		private const int MaxElementsPerPage = 20;

		private const bool DebugPreviewHostPage = false;

		private static Page _mainPage;

		private static Page _hostPage;

		private static readonly FieldInfo _pageElementsField = typeof(Page).GetField("_elements", BindingFlags.Instance | BindingFlags.NonPublic);

		public static void Setup()
		{
			//IL_000a: 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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			_mainPage = Page.Root.CreatePage("Fusion: Reborn", Color.red, 20, true);
			object obj = <>O.<0>__ShowHostPage;
			if (obj == null)
			{
				ServerEvent val = ShowHostPage;
				<>O.<0>__ShowHostPage = val;
				obj = (object)val;
			}
			MultiplayerHooking.OnStartedServer += (ServerEvent)obj;
			object obj2 = <>O.<1>__EnforceHostPageVisibility;
			if (obj2 == null)
			{
				ServerEvent val2 = EnforceHostPageVisibility;
				<>O.<1>__EnforceHostPageVisibility = val2;
				obj2 = (object)val2;
			}
			MultiplayerHooking.OnJoinedServer += (ServerEvent)obj2;
			object obj3 = <>O.<2>__HideHostPage;
			if (obj3 == null)
			{
				ServerEvent val3 = HideHostPage;
				<>O.<2>__HideHostPage = val3;
				obj3 = (object)val3;
			}
			MultiplayerHooking.OnDisconnected += (ServerEvent)obj3;
			if (NetworkInfo.HasServer && NetworkInfo.IsHost)
			{
				ShowHostPage();
			}
			_mainPage.CreateBool("Hide Hood Avatars", Color.white, RebornConfig.ModBlacklistEnabled.Value, (Action<bool>)delegate(bool v)
			{
				RebornConfig.ModBlacklistEnabled.Value = v;
				RebornConfig.Save();
			});
			_mainPage.CreateBool("Hide Offensive Hood & Racist Servers", Color.white, RebornConfig.ServerHidingEnabled.Value, (Action<bool>)delegate(bool v)
			{
				RebornConfig.ServerHidingEnabled.Value = v;
				RebornConfig.Save();
			});
			_mainPage.CreateBool("Ear Protection", Color.white, RebornConfig.AutoVolumeLimiterEnabled.Value, (Action<bool>)delegate(bool v)
			{
				RebornConfig.AutoVolumeLimiterEnabled.Value = v;
				RebornConfig.Save();
			});
			_mainPage.CreateFloat("Max Volume Reduction", Color.white, RebornConfig.AutoVolumeMaxReduction.Value, 0.05f, 0f, 1f, (Action<float>)delegate(float v)
			{
				RebornConfig.AutoVolumeMaxReduction.Value = v;
				RebornConfig.Save();
			});
			_mainPage.CreateBool("Disable Overbright Emission", Color.white, RebornConfig.EmissionBloomGuardEnabled.Value, (Action<bool>)delegate(bool v)
			{
				RebornConfig.EmissionBloomGuardEnabled.Value = v;
				RebornConfig.Save();
			});
		}

		private static void ShowHostPage()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			if (_hostPage == null)
			{
				_hostPage = _mainPage.CreatePage("Host Controls (Owner Only)", Color.yellow, 20, true);
				_hostPage.CreateBool("Block Greifing Items", Color.white, RebornConfig.ObjectSpawnGuardEnabled.Value, (Action<bool>)delegate(bool v)
				{
					RebornConfig.ObjectSpawnGuardEnabled.Value = v;
					RebornConfig.Save();
				});
				_hostPage.CreateBool("Flyhack Detection", Color.white, RebornConfig.FlyhackGuardEnabled.Value, (Action<bool>)delegate(bool v)
				{
					RebornConfig.FlyhackGuardEnabled.Value = v;
					RebornConfig.Save();
				});
				_hostPage.CreateBool("Infinite Health Detection", Color.white, RebornConfig.VitalityGuardEnabled.Value, (Action<bool>)delegate(bool v)
				{
					RebornConfig.VitalityGuardEnabled.Value = v;
					RebornConfig.Save();
				});
				_hostPage.CreateBool("Kick on Infinite Health", Color.white, RebornConfig.KickOnInfiniteVitality.Value, (Action<bool>)delegate(bool v)
				{
					RebornConfig.KickOnInfiniteVitality.Value = v;
					RebornConfig.Save();
				});
				_hostPage.CreateBool("Block Spawn Requests", Color.white, RebornConfig.RestrictNetworkedSpawningToOperators.Value, (Action<bool>)delegate(bool v)
				{
					RebornConfig.RestrictNetworkedSpawningToOperators.Value = v;
					RebornConfig.Save();
				});
				_hostPage.CreateInt("Max Scene Objects", Color.white, RebornConfig.MaxSceneObjects.Value, 100, 100, 3000, (Action<int>)delegate(int v)
				{
					RebornConfig.MaxSceneObjects.Value = v;
					RebornConfig.Save();
				});
				_hostPage.CreateBool("Kick All Key Enabled", Color.white, RebornConfig.PanicKickEnabled.Value, (Action<bool>)delegate(bool v)
				{
					RebornConfig.PanicKickEnabled.Value = v;
					RebornConfig.Save();
				});
				_hostPage.CreateEnum("Kick All Key", Color.white, (Enum)(object)RebornConfig.PanicKickKey.Value, (Action<Enum>)delegate(Enum v)
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					RebornConfig.PanicKickKey.Value = (KeyCode)(object)v;
					RebornConfig.Save();
				});
				_hostPage.CreateFunction("Kick All Players Now", Color.red, (Action)PanicKick.KickAllPlayers);
				_hostPage.CreateBool("Despawn All Key Enabled", Color.white, RebornConfig.DespawnAllKeyEnabled.Value, (Action<bool>)delegate(bool v)
				{
					RebornConfig.DespawnAllKeyEnabled.Value = v;
					RebornConfig.Save();
				});
				_hostPage.CreateEnum("Despawn All Key", Color.white, (Enum)(object)RebornConfig.DespawnAllKey.Value, (Action<Enum>)delegate(Enum v)
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					RebornConfig.DespawnAllKey.Value = (KeyCode)(object)v;
					RebornConfig.Save();
				});
				_hostPage.CreateFunction("Despawn All Now", Color.red, (Action)DespawnAllLoop.DespawnAllNow);
				_hostPage.CreateFunction("Teleport All", Color.red, (Action)TeleportAllToHost);
				TryReorderHostLinkUnderBugReport();
			}
		}

		private static void TeleportAllToHost()
		{
			foreach (PlayerID playerID in PlayerIDManager.PlayerIDs)
			{
				if (!playerID.IsMe)
				{
					PermissionSender.SendPermissionRequest((PermissionCommandType)4, (byte?)playerID.SmallID);
				}
			}
		}

		private static void TryReorderHostLinkUnderBugReport()
		{
			try
			{
				if (_hostPage == null)
				{
					return;
				}
				PageLinkElement val = null;
				foreach (Element element in _mainPage.Elements)
				{
					PageLinkElement val2 = (PageLinkElement)(object)((element is PageLinkElement) ? element : null);
					if (val2 != null && val2.LinkedPage == _hostPage)
					{
						val = val2;
						break;
					}
				}
				if (val != null && _pageElementsField?.GetValue(_mainPage) is List<Element> list)
				{
					list.Remove((Element)(object)val);
					list.Insert(1, (Element)(object)val);
				}
			}
			catch (Exception)
			{
			}
		}

		private static void HideHostPage()
		{
			if (_hostPage != null)
			{
				_mainPage.RemovePage(_hostPage);
				_hostPage = null;
			}
		}

		private static void EnforceHostPageVisibility()
		{
			if (!NetworkInfo.IsHost)
			{
				HideHostPage();
			}
		}
	}
}