Decompiled source of More Sudden Death Options v1.0.3

plugins/MoreSuddenDeathOptions.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using MapEmbiggener;
using MapEmbiggener.Controllers;
using MapEmbiggener.Controllers.Default;
using Microsoft.CodeAnalysis;
using MoreSuddenDeathOptions.Options;
using MoreSuddenDeathOptions.Options.BuiltIn;
using MoreSuddenDeathOptions.Options.Menus;
using MoreSuddenDeathOptions.Options.Menus.BuiltIn;
using MoreSuddenDeathOptions.Utils;
using TMPro;
using UnboundLib;
using UnboundLib.Utils.UI;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MoreSuddenDeathOptions
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.aalund13.rounds.more_sudden_death_options", "More Sudden Death Options", "1.0.3")]
	[BepInProcess("Rounds.exe")]
	public class MoreSuddenDeathOptions : BaseUnityPlugin
	{
		[CompilerGenerated]
		private sealed class <SetupGUI>d__6 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public GameObject menu;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_0041: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitUntil((Func<bool>)(() => ready));
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					SuddenDeathMenuManager.Instance.CreateAllMenus(menu);
					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();
			}
		}

		internal const string ModId = "com.aalund13.rounds.more_sudden_death_options";

		internal const string ModName = "More Sudden Death Options";

		internal static ConfigFile ModConfig;

		private static bool ready;

		private void Awake()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("com.aalund13.rounds.more_sudden_death_options").PatchAll();
			ModConfig = ((BaseUnityPlugin)this).Config;
			SuddenDeathOptionsManager suddenDeathOptionsManager = ((Component)this).gameObject.AddComponent<SuddenDeathOptionsManager>();
			suddenDeathOptionsManager.RegisterOption<TriggerSuddeenDeathPlayers>();
			suddenDeathOptionsManager.RegisterOption<TriggerSuddeenDeathTimer>();
			SuddenDeathMenuManager suddenDeathMenuManager = ((Component)this).gameObject.AddComponent<SuddenDeathMenuManager>();
			suddenDeathMenuManager.RegisterMenu<TriggerSuddeenDeathPlayers, TriggerSuddeenDeathPlayersMenu>();
			suddenDeathMenuManager.RegisterMenu<TriggerSuddeenDeathTimer, TriggerSuddeenDeathTimerMenu>();
		}

		private void Start()
		{
			ExtensionMethods.ExecuteAfterFrames((MonoBehaviour)(object)this, 5, (Action)delegate
			{
				SuddenDeathMenuManager.Instance.InitializeMenus();
				ready = true;
			});
			Unbound.RegisterMenu("More Sudden Death Options", (UnityAction)null, (Action<GameObject>)delegate(GameObject menu)
			{
				((MonoBehaviour)this).StartCoroutine(SetupGUI(menu));
			}, (GameObject)null, false);
		}

		[IteratorStateMachine(typeof(<SetupGUI>d__6))]
		private IEnumerator SetupGUI(GameObject menu)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <SetupGUI>d__6(0)
			{
				menu = menu
			};
		}
	}
}
namespace MoreSuddenDeathOptions.Utils
{
	internal static class MenuUtils
	{
		public static void CreateMenu(string name, GameObject parentForButton, int size = 50, GameObject parentForMenu = null)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			MenuHandler.CreateButton(name, parentForButton, (UnityAction)delegate
			{
				parentForMenu.GetComponent<ListMenuPage>().Open();
				parentForButton.GetComponentInParent<GoBack>().goBackEvent.Invoke();
			}, size, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
		}
	}
	public static class SuddenDeathUtils
	{
		public static void ActivateSuddenDeath(DefaultBoundsController boundsController, bool toggle)
		{
			if ((bool)ExtensionMethods.GetFieldValue((object)boundsController, "battleOnGoing"))
			{
				if (toggle)
				{
					float num = 32.004f * ControllerManager.MapSize * ControllerManager.Zoom;
					MapManager instance = MapManager.instance;
					float? obj;
					if (instance == null)
					{
						obj = null;
					}
					else
					{
						MapWrapper currentMap = instance.currentMap;
						obj = ((currentMap == null) ? null : currentMap.Map?.size);
					}
					float? num2 = obj;
					ExtensionMethods.SetPropertyValue((object)boundsController, "MaxXTarget", (object)(num / num2.GetValueOrDefault(1f)));
					float num3 = -32.004f * ControllerManager.MapSize * ControllerManager.Zoom;
					MapManager instance2 = MapManager.instance;
					float? obj2;
					if (instance2 == null)
					{
						obj2 = null;
					}
					else
					{
						MapWrapper currentMap2 = instance2.currentMap;
						obj2 = ((currentMap2 == null) ? null : currentMap2.Map?.size);
					}
					num2 = obj2;
					ExtensionMethods.SetPropertyValue((object)boundsController, "MinXTarget", (object)(num3 / num2.GetValueOrDefault(1f)));
					ExtensionMethods.SetPropertyValue((object)boundsController, "MaxYTarget", (object)0f);
					ExtensionMethods.SetPropertyValue((object)boundsController, "MinYTarget", (object)0f);
					ExtensionMethods.SetPropertyValue((object)boundsController, "ParticleGravityTarget", (object)(-0.1f));
				}
				else
				{
					ExtensionMethods.SetPropertyValue((object)boundsController, "MaxXTarget", (object)(35.56f * ControllerManager.MapSize));
					ExtensionMethods.SetPropertyValue((object)boundsController, "MinXTarget", (object)(-35.56f * ControllerManager.MapSize));
					ExtensionMethods.SetPropertyValue((object)boundsController, "MaxYTarget", (object)(20f * ControllerManager.MapSize));
					ExtensionMethods.SetPropertyValue((object)boundsController, "MinYTarget", (object)(-20f * ControllerManager.MapSize));
					ExtensionMethods.SetPropertyValue((object)boundsController, "ParticleGravityTarget", (object)0f);
				}
				ExtensionMethods.SetPropertyValue((object)boundsController, "XSpeed", (object)DefaultBoundsController.SuddenDeathXSpeed);
				ExtensionMethods.SetPropertyValue((object)boundsController, "YSpeed", (object)1.5f);
			}
			else
			{
				ExtensionMethods.SetPropertyValue((object)boundsController, "MaxXTarget", (object)(35.56f * ControllerManager.MapSize));
				ExtensionMethods.SetPropertyValue((object)boundsController, "MinXTarget", (object)(-35.56f * ControllerManager.MapSize));
				ExtensionMethods.SetPropertyValue((object)boundsController, "MaxYTarget", (object)(20f * ControllerManager.MapSize));
				ExtensionMethods.SetPropertyValue((object)boundsController, "MinYTarget", (object)(-20f * ControllerManager.MapSize));
				ExtensionMethods.SetPropertyValue((object)boundsController, "ParticleGravityTarget", (object)null);
				ExtensionMethods.SetPropertyValue((object)boundsController, "XSpeed", (object)null);
				ExtensionMethods.SetPropertyValue((object)boundsController, "YSpeed", (object)null);
			}
			ExtensionMethods.SetPropertyValue((object)boundsController, "ParticleGravitySpeed", (object)null);
			ExtensionMethods.SetPropertyValue((object)boundsController, "AngleTarget", (object)0f);
			ExtensionMethods.SetPropertyValue((object)boundsController, "AngularSpeed", (object)null);
		}

		public static void ActivateSuddenDeathCamera(DefaultCameraController cameraController, bool toggle)
		{
			if ((bool)ExtensionMethods.GetFieldValue((object)cameraController, "battleOnGoing") && toggle)
			{
				ExtensionMethods.SetPropertyValue((object)cameraController, "ZoomTarget", (object)0f);
				ExtensionMethods.SetPropertyValue((object)cameraController, "ZoomSpeed", (object)1f);
				ExtensionMethods.SetPropertyValue((object)cameraController, "RotationTarget", (object)null);
				ExtensionMethods.SetPropertyValue((object)cameraController, "RotationSpeed", (object)null);
				ExtensionMethods.SetPropertyValue((object)cameraController, "PositionTarget", (object)null);
				ExtensionMethods.SetPropertyValue((object)cameraController, "MovementSpeed", (object)null);
			}
			else
			{
				ExtensionMethods.SetPropertyValue((object)cameraController, "ZoomTarget", (object)null);
				ExtensionMethods.SetPropertyValue((object)cameraController, "ZoomSpeed", (object)null);
				ExtensionMethods.SetPropertyValue((object)cameraController, "RotationTarget", (object)null);
				ExtensionMethods.SetPropertyValue((object)cameraController, "RotationSpeed", (object)null);
				ExtensionMethods.SetPropertyValue((object)cameraController, "PositionTarget", (object)null);
				ExtensionMethods.SetPropertyValue((object)cameraController, "MovementSpeed", (object)null);
			}
		}
	}
}
namespace MoreSuddenDeathOptions.Patches
{
	[HarmonyPatch(typeof(DefaultBoundsController))]
	internal class DefaultBoundsControllerPatch
	{
		[HarmonyPatch("SetDataToSync")]
		[HarmonyPostfix]
		public static void SetDataToSync()
		{
			SuddenDeathOptionsManager.Instance.SetDataToSync();
		}

		[HarmonyPatch("ReadSyncedData")]
		[HarmonyPostfix]
		public static void ReadSyncedData()
		{
			SuddenDeathOptionsManager.Instance.ReadSyncedData();
		}

		[HarmonyPatch("OnBattleStart")]
		[HarmonyPostfix]
		public static void OnBattleStart()
		{
			SuddenDeathOptionsManager.Instance.Reset();
		}

		[HarmonyPatch("OnUpdate")]
		[HarmonyPrefix]
		public static bool OnUpdate(DefaultBoundsController __instance)
		{
			if (SuddenDeathOptionsManager.Instance.ActivateSuddenDeath())
			{
				SuddenDeathUtils.ActivateSuddenDeath(__instance, toggle: true);
			}
			else
			{
				SuddenDeathUtils.ActivateSuddenDeath(__instance, toggle: false);
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(DefaultCameraController), "OnUpdate")]
	internal class DefaultCameraControllerPatch
	{
		public static bool Prefix(DefaultCameraController __instance)
		{
			if (SuddenDeathOptionsManager.Instance.ActivateSuddenDeath())
			{
				SuddenDeathUtils.ActivateSuddenDeathCamera(__instance, toggle: true);
			}
			else
			{
				SuddenDeathUtils.ActivateSuddenDeathCamera(__instance, toggle: false);
			}
			return false;
		}
	}
}
namespace MoreSuddenDeathOptions.Options
{
	public abstract class SuddenDeathOption
	{
		public Dictionary<string, int> SyncedIntData => ((ISyncedController)ControllerManager.BoundsControllers["DefaultBounds"]).SyncedIntData;

		public Dictionary<string, float> SyncedFloatData => ((ISyncedController)ControllerManager.BoundsControllers["DefaultBounds"]).SyncedFloatData;

		public Dictionary<string, string> SyncedStringData => ((ISyncedController)ControllerManager.BoundsControllers["DefaultBounds"]).SyncedStringData;

		public abstract string Name { get; }

		public virtual void SetDataToSync()
		{
		}

		public virtual void ReadSyncedData()
		{
		}

		public virtual void OnReset()
		{
		}

		public abstract bool ActivateSuddenDeath();
	}
	public class SuddenDeathOptionsManager : MonoBehaviour
	{
		private readonly Dictionary<Type, SuddenDeathOption> options = new Dictionary<Type, SuddenDeathOption>();

		public IEnumerable<SuddenDeathOption> Options => options.Values;

		public static SuddenDeathOptionsManager Instance { get; private set; }

		public bool ActivateSuddenDeath()
		{
			return options.Values.Any((SuddenDeathOption o) => o.ActivateSuddenDeath());
		}

		public void RegisterOption<T>() where T : SuddenDeathOption, new()
		{
			Type typeFromHandle = typeof(T);
			if (options.ContainsKey(typeFromHandle))
			{
				throw new Exception("SuddenDeathOption '" + typeFromHandle.Name + "' is already registered.");
			}
			T value = new T();
			options.Add(typeFromHandle, value);
		}

		public T GetOptionByType<T>() where T : SuddenDeathOption
		{
			if (options.ContainsKey(typeof(T)))
			{
				return (T)options[typeof(T)];
			}
			return null;
		}

		public SuddenDeathOption GetOptionByType(Type type)
		{
			if (options.ContainsKey(type))
			{
				return options[type];
			}
			return null;
		}

		internal void SetDataToSync()
		{
			foreach (SuddenDeathOption value in options.Values)
			{
				value.SetDataToSync();
			}
		}

		internal void ReadSyncedData()
		{
			foreach (SuddenDeathOption value in options.Values)
			{
				value.ReadSyncedData();
			}
		}

		internal void Reset()
		{
			foreach (SuddenDeathOption value in options.Values)
			{
				value.OnReset();
			}
		}

		private void Awake()
		{
			if ((Object)(object)Instance != (Object)null)
			{
				Object.Destroy((Object)(object)this);
			}
			else
			{
				Instance = this;
			}
		}

		private void Start()
		{
			AccessTools.PropertySetter(typeof(MapEmbiggener), "suddenDeathMode").Invoke(null, new object[1] { false });
			AccessTools.PropertySetter(typeof(MapEmbiggener), "chaosMode").Invoke(null, new object[1] { false });
			AccessTools.PropertySetter(typeof(MapEmbiggener), "chaosModeClassic").Invoke(null, new object[1] { false });
		}
	}
}
namespace MoreSuddenDeathOptions.Options.Menus
{
	public abstract class SuddenDeathMenu
	{
		public SuddenDeathOption SuddenDeathOption { get; private set; }

		public SuddenDeathMenu(SuddenDeathOption suddenDeathOption)
		{
			SuddenDeathOption = suddenDeathOption;
		}

		public abstract void CreateConfigMenu(GameObject menu);
	}
	public abstract class SuddenDeathMenu<T> : SuddenDeathMenu where T : SuddenDeathOption
	{
		public T SuddenDeathOptionType { get; private set; }

		public SuddenDeathMenu(T suddenDeathOption)
			: base(suddenDeathOption)
		{
			SuddenDeathOptionType = suddenDeathOption;
		}
	}
	public class SuddenDeathMenuManager : MonoBehaviour
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__7_0;

			internal void <CreateAllMenus>b__7_0()
			{
			}
		}

		private readonly Dictionary<Type, Type> menuTypes = new Dictionary<Type, Type>();

		private readonly List<SuddenDeathMenu> suddenDeathMenus = new List<SuddenDeathMenu>();

		public static SuddenDeathMenuManager Instance { get; private set; }

		public void RegisterMenu<O, M>() where O : SuddenDeathOption where M : SuddenDeathMenu
		{
			menuTypes[typeof(O)] = typeof(M);
		}

		internal void CreateAllMenus(GameObject parent)
		{
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Expected O, but got Unknown
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI val = default(TextMeshProUGUI);
			MenuHandler.CreateText("<b>More Sudden Death Options</b>", parent, ref val, 70, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			MenuHandler.CreateText(" ", parent, ref val, 50, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			foreach (SuddenDeathMenu suddenDeathMenu in suddenDeathMenus)
			{
				string name = suddenDeathMenu.SuddenDeathOption.Name;
				object obj = <>c.<>9__7_0;
				if (obj == null)
				{
					UnityAction val2 = delegate
					{
					};
					<>c.<>9__7_0 = val2;
					obj = (object)val2;
				}
				GameObject val3 = MenuHandler.CreateMenu(name, (UnityAction)obj, parent, 40, true, true, ((Component)parent.transform.parent).gameObject, true, -1);
				MenuHandler.CreateText("<b>" + suddenDeathMenu.SuddenDeathOption.Name + " Options</b>", val3, ref val, 70, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
				suddenDeathMenu.CreateConfigMenu(val3);
			}
			MapEmbiggener val4 = (MapEmbiggener)AccessTools.Field(typeof(MapEmbiggener), "instance").GetValue(null);
			((Component)(Toggle)ExtensionMethods.GetFieldValue((object)val4, "suddenDeathModeToggle")).gameObject.SetActive(false);
			((Component)(Toggle)ExtensionMethods.GetFieldValue((object)val4, "chaosModeToggle")).gameObject.SetActive(false);
			((Component)(Toggle)ExtensionMethods.GetFieldValue((object)val4, "chaosModeClassicToggle")).gameObject.SetActive(false);
			MenuUtils.CreateMenu("Sudden Death Options", ((Component)((Component)(Toggle)ExtensionMethods.GetFieldValue((object)val4, "chaosModeClassicToggle")).transform.parent).gameObject, 30, parent);
		}

		internal void InitializeMenus()
		{
			foreach (KeyValuePair<Type, Type> menuType in menuTypes)
			{
				Type key = menuType.Key;
				Type value = menuType.Value;
				SuddenDeathOption optionByType = SuddenDeathOptionsManager.Instance.GetOptionByType(key);
				SuddenDeathMenu item = (SuddenDeathMenu)Activator.CreateInstance(value, optionByType);
				suddenDeathMenus.Add(item);
			}
		}

		private void Awake()
		{
			if ((Object)(object)Instance != (Object)null)
			{
				Object.Destroy((Object)(object)this);
			}
			else
			{
				Instance = this;
			}
		}
	}
}
namespace MoreSuddenDeathOptions.Options.Menus.BuiltIn
{
	public class TriggerSuddeenDeathPlayersMenu : SuddenDeathMenu<TriggerSuddeenDeathPlayers>
	{
		public TriggerSuddeenDeathPlayersMenu(TriggerSuddeenDeathPlayers suddenDeathOption)
			: base(suddenDeathOption)
		{
		}

		public override void CreateConfigMenu(GameObject menu)
		{
			MenuHandler.CreateToggle(base.SuddenDeathOptionType.EnableConfig.Value, "Enable Sudden Death Option", menu, (UnityAction<bool>)delegate(bool value)
			{
				base.SuddenDeathOptionType.Enable = value;
				base.SuddenDeathOptionType.EnableConfig.Value = value;
			}, 60, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			TextMeshProUGUI val = default(TextMeshProUGUI);
			MenuHandler.CreateText(" ", menu, ref val, 30, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			Slider val2 = default(Slider);
			MenuHandler.CreateSlider("Enable When Above <b>N</b> Amount of Players", menu, 30, 0f, 5f, (float)base.SuddenDeathOptionType.EnableWhenAboveNPlayersConfig.Value, (UnityAction<float>)delegate(float value)
			{
				base.SuddenDeathOptionType.EnableWhenAboveNPlayersConfig.Value = (int)value;
				base.SuddenDeathOptionType.EnableWhenAboveNPlayers = (int)value;
			}, ref val2, true, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			MenuHandler.CreateSlider("Trigger When Below or Equal <b>N</b> Amount of Players", menu, 30, 0f, 5f, (float)base.SuddenDeathOptionType.TriggerWhenBelowOrEqualNPlayersConfig.Value, (UnityAction<float>)delegate(float value)
			{
				base.SuddenDeathOptionType.TriggerWhenBelowOrEqualNPlayersConfig.Value = (int)value;
				base.SuddenDeathOptionType.TriggerWhenBelowOrEqualNPlayers = (int)value;
			}, ref val2, true, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
		}
	}
	public class TriggerSuddeenDeathTimerMenu : SuddenDeathMenu<TriggerSuddeenDeathTimer>
	{
		public TriggerSuddeenDeathTimerMenu(TriggerSuddeenDeathTimer suddenDeathOption)
			: base(suddenDeathOption)
		{
		}

		public override void CreateConfigMenu(GameObject menu)
		{
			MenuHandler.CreateToggle(base.SuddenDeathOptionType.EnableConfig.Value, "Enable Sudden Death Option", menu, (UnityAction<bool>)delegate(bool value)
			{
				base.SuddenDeathOptionType.Enable = value;
				base.SuddenDeathOptionType.EnableConfig.Value = value;
			}, 60, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			TextMeshProUGUI val = default(TextMeshProUGUI);
			MenuHandler.CreateText(" ", menu, ref val, 30, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			Slider val2 = default(Slider);
			MenuHandler.CreateSlider("Trigger When <b>N</b> Amount of Time Pass", menu, 30, 0f, 120f, base.SuddenDeathOptionType.TriggerWhenNTimePassConfig.Value, (UnityAction<float>)delegate(float value)
			{
				base.SuddenDeathOptionType.TriggerWhenNTimePassConfig.Value = value;
				base.SuddenDeathOptionType.TriggerWhenNTimePass = value;
			}, ref val2, true, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
		}
	}
}
namespace MoreSuddenDeathOptions.Options.BuiltIn
{
	public class TriggerSuddeenDeathPlayers : SuddenDeathOption
	{
		public int EnableWhenAboveNPlayers = 2;

		public int TriggerWhenBelowOrEqualNPlayers = 2;

		public bool Enable;

		internal ConfigEntry<int> EnableWhenAboveNPlayersConfig;

		internal ConfigEntry<int> TriggerWhenBelowOrEqualNPlayersConfig;

		public ConfigEntry<bool> EnableConfig;

		public override string Name => "Trigger With Amount Of Player";

		public TriggerSuddeenDeathPlayers()
		{
			bool value = MapEmbiggener.SuddenDeathConfig.Value;
			EnableConfig = MoreSuddenDeathOptions.ModConfig.Bind<bool>(ExtensionMethods.Sanitize("More Sudden Death Options", (string[])null), ExtensionMethods.Sanitize(Name, (string[])null) + "_Enable", value, "Enable or disable \"" + Name + "\" sudden death option");
			Enable = EnableConfig.Value;
			EnableWhenAboveNPlayersConfig = MoreSuddenDeathOptions.ModConfig.Bind<int>(ExtensionMethods.Sanitize("More Sudden Death Options", (string[])null), "EnableWhenAboveNPlayers", EnableWhenAboveNPlayers, "The amount of players needed for this sudden death option to be enable");
			EnableWhenAboveNPlayers = EnableWhenAboveNPlayersConfig.Value;
			TriggerWhenBelowOrEqualNPlayersConfig = MoreSuddenDeathOptions.ModConfig.Bind<int>(ExtensionMethods.Sanitize("More Sudden Death Options", (string[])null), "TriggerWhenBelowOrEqualNPlayers", TriggerWhenBelowOrEqualNPlayers, "Trigger the sudden death once the the alive players is below or equal to this amount");
			TriggerWhenBelowOrEqualNPlayers = TriggerWhenBelowOrEqualNPlayersConfig.Value;
		}

		public override bool ActivateSuddenDeath()
		{
			if (Enable && PlayerManager.instance.players.Count > EnableWhenAboveNPlayers)
			{
				return PlayerManager.instance.players.Where((Player p) => !p.data.dead).Count() <= TriggerWhenBelowOrEqualNPlayers;
			}
			return false;
		}

		public override void SetDataToSync()
		{
			base.SyncedIntData["EnableWhenAboveNPlayers"] = EnableWhenAboveNPlayersConfig.Value;
			base.SyncedIntData["TriggerWhenBelowOrEqualNPlayers"] = TriggerWhenBelowOrEqualNPlayersConfig.Value;
			base.SyncedIntData[ExtensionMethods.Sanitize(Name, (string[])null) + "_Enable"] = (Enable ? 1 : 0);
		}

		public override void ReadSyncedData()
		{
			EnableWhenAboveNPlayers = base.SyncedIntData["EnableWhenAboveNPlayers"];
			TriggerWhenBelowOrEqualNPlayers = base.SyncedIntData["TriggerWhenBelowOrEqualNPlayers"];
			Enable = base.SyncedIntData[ExtensionMethods.Sanitize(Name, (string[])null) + "_Enable"] == 1;
		}
	}
	public class TriggerSuddeenDeathTimer : SuddenDeathOption
	{
		public float TriggerWhenNTimePass = 30f;

		public bool Enable;

		internal ConfigEntry<float> TriggerWhenNTimePassConfig;

		internal ConfigEntry<bool> EnableConfig;

		private float LastSetTime;

		public override string Name => "Trigger With Timer";

		public TriggerSuddeenDeathTimer()
		{
			EnableConfig = MoreSuddenDeathOptions.ModConfig.Bind<bool>(ExtensionMethods.Sanitize("More Sudden Death Options", (string[])null), ExtensionMethods.Sanitize(Name, (string[])null) + "_Enable", false, "Enable or disable \"" + Name + "\" sudden death option");
			Enable = EnableConfig.Value;
			TriggerWhenNTimePassConfig = MoreSuddenDeathOptions.ModConfig.Bind<float>(ExtensionMethods.Sanitize("More Sudden Death Options", (string[])null), "TriggerWhenNTimePass", TriggerWhenNTimePass, "The amount of time require for sudden death to trigger");
			TriggerWhenNTimePass = TriggerWhenNTimePassConfig.Value;
		}

		public override bool ActivateSuddenDeath()
		{
			if (Enable)
			{
				return Time.unscaledTime > LastSetTime + TriggerWhenNTimePass;
			}
			return false;
		}

		public override void OnReset()
		{
			LastSetTime = Time.unscaledTime;
		}

		public override void SetDataToSync()
		{
			base.SyncedFloatData["TriggerWhenNTimePass"] = TriggerWhenNTimePassConfig.Value;
			base.SyncedIntData[ExtensionMethods.Sanitize(Name, (string[])null) + "_Enable"] = (Enable ? 1 : 0);
		}

		public override void ReadSyncedData()
		{
			TriggerWhenNTimePass = base.SyncedIntData["TriggerWhenNTimePass"];
			Enable = base.SyncedIntData[ExtensionMethods.Sanitize(Name, (string[])null) + "_Enable"] == 1;
		}
	}
}