Decompiled source of TootTallyGameModifiers v1.2.7

plugins/TootTallyGameModifiers.dll

Decompiled 3 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BaboonAPI.Hooks.Initializer;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using TootTallyCore;
using TootTallyCore.Graphics;
using TootTallyCore.Graphics.Animations;
using TootTallyCore.Utils.Assets;
using TootTallyCore.Utils.TootTallyGlobals;
using TootTallyCore.Utils.TootTallyModules;
using TootTallySettings.TootTallySettingsObjects;
using UnityEngine;
using UnityEngine.PostProcessing;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("TootTally")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Gameplay modifiers for global leaderboards and for fun")]
[assembly: AssemblyFileVersion("1.2.7.0")]
[assembly: AssemblyInformationalVersion("1.2.7")]
[assembly: AssemblyProduct("TootTallyGameModifiers")]
[assembly: AssemblyTitle("TootTallyGameModifiers")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/TootTally/TootTallyGameModifiers")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.7.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 TootTallyGameModifiers
{
	public class CustomPopup
	{
		public CustomButton openPopupButton;

		public GameObject popupBox;

		public bool isPopupEnabled = false;

		private TootTallyAnimation anim;

		public CustomPopup(string title, Transform buttonTransform, Vector2 buttonAnchoredPosition, Vector2 buttonSize, Sprite buttonImage, Transform popupTransform, Vector2 popupSize, int titleFontSize, Vector2 closeButtonSize)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			openPopupButton = GameObjectFactory.CreateCustomButton(buttonTransform, buttonAnchoredPosition, buttonSize, buttonImage, title + " Button", (Action)OnOpenButtonClick);
			popupBox = GameModifierFactory.GetBorderedVerticalBox(popupSize, 4, popupTransform);
			popupBox.transform.localScale = Vector2.op_Implicit(Vector2.zero);
			((Object)popupBox).name = title;
			GameObject gameObject = ((Component)popupBox.transform.GetChild(0)).gameObject;
			((Graphic)gameObject.GetComponent<Image>()).color = (TMPro_ExtensionMethods.CompareRGB(Theme.colors.leaderboard.text, Color.black) ? new Color(1f, 1f, 1f, 1f) : new Color(0f, 0f, 0f, 1f));
			RectTransform component = popupBox.GetComponent<RectTransform>();
			component.anchorMin = (component.anchorMax = (component.pivot = Vector2.one / 2f));
			TMP_Text val3 = GameObjectFactory.CreateSingleText(gameObject.transform, title + " Title", title, (TextFont)0);
			val3.fontSize = titleFontSize;
			val3.fontStyle = (FontStyles)1;
			val3.alignment = (TextAlignmentOptions)1026;
			val3.rectTransform.sizeDelta = new Vector2(450f, 30f);
			((Component)GameObjectFactory.CreateCustomButton(gameObject.transform, Vector2.one * -5f, closeButtonSize, AssetManager.GetSprite("Close64.png"), "Close " + title + " Button", (Action)OnCloseAnimation)).gameObject.AddComponent<LayoutElement>().ignoreLayout = true;
		}

		public void OnCloseAnimation()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			isPopupEnabled = false;
			TootTallyAnimation obj = anim;
			if (obj != null)
			{
				obj.Dispose();
			}
			anim = TootTallyAnimationManager.AddNewScaleAnimation(popupBox, Vector2.zero, 0.5f, new SecondDegreeDynamicsAnimation(3.5f, 1f, 1.1f), (Action<GameObject>)delegate
			{
				popupBox.gameObject.SetActive(false);
				anim = null;
			});
		}

		public void OnOpenAnimation()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			isPopupEnabled = true;
			TootTallyAnimation obj = anim;
			if (obj != null)
			{
				obj.Dispose();
			}
			popupBox.transform.localScale = Vector2.op_Implicit(Vector2.zero);
			popupBox.SetActive(true);
			anim = TootTallyAnimationManager.AddNewScaleAnimation(popupBox, Vector2.one, 0.6f, new SecondDegreeDynamicsAnimation(2.75f, 1f, 1.1f), (Action<GameObject>)null);
		}

		private void OnOpenButtonClick()
		{
			isPopupEnabled = !isPopupEnabled;
			if (isPopupEnabled)
			{
				OnOpenAnimation();
			}
			else
			{
				OnCloseAnimation();
			}
		}
	}
	public abstract class GameModifierBase
	{
		public abstract GameModifiers.Metadata Metadata { get; }

		public virtual void Initialize(GameController __instance)
		{
		}

		public virtual void Update(GameController __instance)
		{
		}

		public virtual void SpecialUpdate(GameController __instance)
		{
		}
	}
	public static class GameModifierFactory
	{
		public static CustomPopup CreateModifiersPopup(Transform buttonTransform, Vector2 buttonAnchoredPosition, Vector2 buttonSize, Transform popupTransform, Vector2 popupSize, int titleFontSize, Vector2 closeButtonSize)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: 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)
			return new CustomPopup("Modifiers", buttonTransform, buttonAnchoredPosition, buttonSize, AssetManager.GetSprite("ModifierButton.png"), popupTransform, popupSize, titleFontSize, closeButtonSize);
		}

		public static GameObject CreatePopupContainer(CustomPopup popup, Vector2 size, float padding, float spacing)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return CreatePopupContainer(popup, size);
		}

		public static GameObject CreatePopupContainer(CustomPopup popup, Vector2 size)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			GameObject gameObject = ((Component)popup.popupBox.transform.GetChild(0)).gameObject;
			GameObject horizontalBox = GetHorizontalBox(size, gameObject.transform);
			HorizontalLayoutGroup val = default(HorizontalLayoutGroup);
			if (horizontalBox.TryGetComponent<HorizontalLayoutGroup>(ref val))
			{
				Object.DestroyImmediate((Object)(object)val);
			}
			GridLayoutGroup val2 = horizontalBox.AddComponent<GridLayoutGroup>();
			val2.cellSize = Vector2.one * 32f;
			((LayoutGroup)val2).childAlignment = (TextAnchor)1;
			return horizontalBox;
		}

		public static GameObject GetVerticalBox(Vector2 size, Transform parent = null)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(AssetBundleManager.GetPrefab("verticalbox"), parent);
			val.GetComponent<RectTransform>().sizeDelta = size;
			return val;
		}

		public static GameObject GetHorizontalBox(Vector2 size, Transform parent = null)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(AssetBundleManager.GetPrefab("horizontalbox"), parent);
			val.GetComponent<RectTransform>().sizeDelta = size;
			return val;
		}

		public static GameObject GetBorderedVerticalBox(Vector2 size, int bordersize, Transform parent = null)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_002d: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(AssetBundleManager.GetPrefab("borderedverticalbox"), parent);
			((LayoutGroup)val.GetComponent<VerticalLayoutGroup>()).padding = new RectOffset(bordersize, bordersize, bordersize, bordersize);
			val.GetComponent<RectTransform>().sizeDelta = size + Vector2.one * 2f * (float)bordersize;
			return val;
		}

		public static GameObject GetBorderedHorizontalBox(Vector2 size, int bordersize, Transform parent = null)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_002d: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(AssetBundleManager.GetPrefab("borderedhorizontalbox"), parent);
			((LayoutGroup)val.GetComponent<HorizontalLayoutGroup>()).padding = new RectOffset(bordersize, bordersize, bordersize, bordersize);
			val.GetComponent<RectTransform>().sizeDelta = size + Vector2.one * 2f * (float)bordersize;
			return val;
		}
	}
	public static class GameModifierManager
	{
		private static bool _isInitialized;

		private static Dictionary<string, GameModifiers.Metadata> _stringModifierDict;

		private static Dictionary<GameModifiers.ModifierType, GameModifierBase> _gameModifierDict;

		private static Dictionary<GameModifiers.ModifierType, ModifierButton> _modifierButtonDict;

		private static string _modifiersBackup;

		private static GameModifierBase _hidden;

		private static GameModifierBase _flashlight;

		private static GameModifierBase _brutalMode;

		private static GameModifierBase _instaFail;

		private static GameModifierBase _easyMode;

		private static GameModifierBase _strictMode;

		private static GameModifierBase _autoTune;

		private static GameModifierBase _noCursor;

		public static bool GetShouldSubmitScore => _gameModifierDict.Values.All((GameModifierBase m) => m.Metadata.ScoreSubmitEnabled);

		[HarmonyPatch(typeof(HomeController), "Start")]
		[HarmonyPostfix]
		private static void OnHomeControllerStartInitialize()
		{
			if (!_isInitialized)
			{
				Initialize();
			}
		}

		private static void AddButton(Transform transform, GameModifiers.Metadata mod)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			bool active = _gameModifierDict.ContainsKey(mod.ModifierType);
			ModifierButton value = new ModifierButton(transform, mod, active, new Vector2(32f, 32f), 3, 8, useWorldPosition: true, delegate
			{
				Toggle(mod.ModifierType);
			});
			_modifierButtonDict.Add(mod.ModifierType, value);
		}

		[HarmonyPatch(typeof(LevelSelectController), "Start")]
		[HarmonyPostfix]
		private static void OnLevelSelectControllerStartPostfix(LevelSelectController __instance)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			if (!_isInitialized)
			{
				Initialize();
			}
			_modifierButtonDict.Clear();
			CustomPopup popup = GameModifierFactory.CreateModifiersPopup(((Component)__instance.fullpanel).transform, new Vector2(-420f, -150f), new Vector2(32f, 32f), ((Component)__instance.fullpanel).transform, new Vector2(175f, 125f), 20, new Vector2(20f, 20f));
			GameObject val = GameModifierFactory.CreatePopupContainer(popup, new Vector2(0f, 65f));
			AddButton(val.transform, GameModifiers.HIDDEN);
			AddButton(val.transform, GameModifiers.FLASHLIGHT);
			AddButton(val.transform, GameModifiers.BRUTAL);
			AddButton(val.transform, GameModifiers.INSTA_FAIL);
			AddButton(val.transform, GameModifiers.EASY_MODE);
			AddButton(val.transform, GameModifiers.STRICT_MODE);
			AddButton(val.transform, GameModifiers.HIDDEN_CURSOR);
			__instance.sortdrop.transform.SetAsLastSibling();
		}

		private static void Initialize()
		{
			_gameModifierDict = new Dictionary<GameModifiers.ModifierType, GameModifierBase>();
			_modifierButtonDict = new Dictionary<GameModifiers.ModifierType, ModifierButton>();
			_stringModifierDict = new Dictionary<string, GameModifiers.Metadata>
			{
				{
					GameModifiers.HIDDEN.Name,
					GameModifiers.HIDDEN
				},
				{
					GameModifiers.FLASHLIGHT.Name,
					GameModifiers.FLASHLIGHT
				},
				{
					GameModifiers.BRUTAL.Name,
					GameModifiers.BRUTAL
				},
				{
					GameModifiers.INSTA_FAIL.Name,
					GameModifiers.INSTA_FAIL
				},
				{
					GameModifiers.EASY_MODE.Name,
					GameModifiers.EASY_MODE
				},
				{
					GameModifiers.STRICT_MODE.Name,
					GameModifiers.STRICT_MODE
				},
				{
					GameModifiers.AUTO_TUNE.Name,
					GameModifiers.AUTO_TUNE
				},
				{
					GameModifiers.HIDDEN_CURSOR.Name,
					GameModifiers.HIDDEN_CURSOR
				}
			};
			_modifiersBackup = "";
			_isInitialized = true;
		}

		[HarmonyPatch(typeof(GameController), "Start")]
		[HarmonyPostfix]
		private static void InitializeModifers(GameController __instance)
		{
			if (!_isInitialized)
			{
				return;
			}
			string modifiersString = GetModifiersString();
			Plugin.LogInfo("Active modifiers: " + modifiersString);
			foreach (GameModifierBase value in _gameModifierDict.Values)
			{
				value.Initialize(__instance);
			}
			_gameModifierDict.TryGetValue(GameModifiers.ModifierType.Hidden, out _hidden);
			_gameModifierDict.TryGetValue(GameModifiers.ModifierType.Flashlight, out _flashlight);
			_gameModifierDict.TryGetValue(GameModifiers.ModifierType.Brutal, out _brutalMode);
			_gameModifierDict.TryGetValue(GameModifiers.ModifierType.InstaFail, out _instaFail);
			_gameModifierDict.TryGetValue(GameModifiers.ModifierType.EasyMode, out _easyMode);
			_gameModifierDict.TryGetValue(GameModifiers.ModifierType.StrictMode, out _strictMode);
			_gameModifierDict.TryGetValue(GameModifiers.ModifierType.AutoTune, out _autoTune);
			_gameModifierDict.TryGetValue(GameModifiers.ModifierType.HiddenCursor, out _noCursor);
			if (_flashlight == null)
			{
				((PostProcessingModel)__instance.gameplayppp.vignette).enabled = false;
			}
		}

		[HarmonyPatch(typeof(GameController), "Start")]
		[HarmonyPostfix]
		public static void OnGameConatrollerStartSetTitleWithModifiers(GameController __instance)
		{
			string modifiersString = GetModifiersString();
			if (!(modifiersString == "") && !__instance.freeplay)
			{
				string text = " [" + modifiersString + "]";
				Text songtitle = __instance.songtitle;
				Text songtitleshadow = __instance.songtitleshadow;
				string text3 = (songtitleshadow.text += text);
				songtitle.text = text3;
			}
		}

		[HarmonyPatch(typeof(GameController), "Update")]
		[HarmonyPostfix]
		private static void UpdateModifiers(GameController __instance)
		{
			if (_isInitialized)
			{
				_hidden?.Update(__instance);
				_flashlight?.Update(__instance);
				_brutalMode?.Update(__instance);
				_strictMode?.Update(__instance);
			}
		}

		[HarmonyPatch(typeof(GameController), "doScoreText")]
		[HarmonyPostfix]
		private static void UpdateEasyAndHardMode(GameController __instance, int whichtext)
		{
			if (_isInitialized)
			{
				_brutalMode?.SpecialUpdate(__instance);
				if (whichtext <= 2)
				{
					_instaFail?.SpecialUpdate(__instance);
				}
			}
		}

		[HarmonyPatch(typeof(GameController), "getScoreAverage")]
		[HarmonyPrefix]
		private static void UpdateBrutalMode(GameController __instance)
		{
			if (_isInitialized)
			{
				_easyMode?.SpecialUpdate(__instance);
				_strictMode?.SpecialUpdate(__instance);
			}
		}

		public static void Toggle(GameModifiers.ModifierType modifierType)
		{
			ModifierButton modifierButton = _modifierButtonDict[modifierType];
			if (!modifierButton.onCooldown)
			{
				modifierButton.onCooldown = true;
				if (!_gameModifierDict.ContainsKey(modifierType))
				{
					modifierButton.ToggleOn();
					Add(modifierType);
				}
				else
				{
					modifierButton.ToggleOff();
					Remove(modifierType);
				}
			}
		}

		public static void ClearAllModifiers()
		{
			_gameModifierDict.Clear();
		}

		public static string GetModifiersString()
		{
			return (_gameModifierDict.Count > 0) ? GeneralExtensions.Join<GameModifierBase>((IEnumerable<GameModifierBase>)_gameModifierDict.Values, (Func<GameModifierBase, string>)((GameModifierBase mod) => mod.Metadata.Name), ",") : "";
		}

		internal static void Add(GameModifiers.ModifierType modifierType)
		{
			if (_gameModifierDict.ContainsKey(modifierType))
			{
				Plugin.LogInfo($"Modifier of type {modifierType} is already in the modifier list.");
			}
			else
			{
				_gameModifierDict.Add(modifierType, CreateGameModifier(modifierType));
			}
		}

		private static GameModifierBase CreateGameModifier(GameModifiers.ModifierType modifierType)
		{
			if (1 == 0)
			{
			}
			GameModifierBase result = modifierType switch
			{
				GameModifiers.ModifierType.Hidden => new GameModifiers.Hidden(), 
				GameModifiers.ModifierType.Flashlight => new GameModifiers.Flashlight(), 
				GameModifiers.ModifierType.Brutal => new GameModifiers.Brutal(), 
				GameModifiers.ModifierType.InstaFail => new GameModifiers.InstaFail(), 
				GameModifiers.ModifierType.EasyMode => new GameModifiers.EasyMode(), 
				GameModifiers.ModifierType.StrictMode => new GameModifiers.StrictMode(), 
				GameModifiers.ModifierType.AutoTune => new GameModifiers.AutoTune(), 
				GameModifiers.ModifierType.HiddenCursor => new GameModifiers.HiddenCursor(), 
				_ => throw new NotImplementedException(), 
			};
			if (1 == 0)
			{
			}
			return result;
		}

		internal static void Remove(GameModifiers.ModifierType modifierType)
		{
			_gameModifierDict.Remove(modifierType);
		}

		public static void LoadModifiersFromString(string replayModifierString)
		{
			_modifiersBackup = GetModifiersString();
			ClearAllModifiers();
			HashSet<GameModifiers.Metadata> modifierSet = GetModifierSet(replayModifierString);
			foreach (GameModifiers.Metadata item in modifierSet)
			{
				Add(item.ModifierType);
			}
		}

		public static HashSet<GameModifiers.Metadata> GetModifierSet(string replayModifierString)
		{
			if (replayModifierString == null)
			{
				return new HashSet<GameModifiers.Metadata>();
			}
			return new HashSet<GameModifiers.Metadata>(from modName in replayModifierString.Split(new char[1] { ',' }).Where(_stringModifierDict.ContainsKey)
				select _stringModifierDict[modName]);
		}

		public static void LoadBackedupModifiers()
		{
			LoadModifiersFromString(_modifiersBackup);
		}
	}
	public static class GameModifiers
	{
		public class Hidden : GameModifierBase
		{
			public class FullNoteComponents
			{
				public Image startPoint;

				public Image endPoint;

				public Image startPointColor;

				public Image endPointColor;

				public LineRenderer outlineLine;

				public LineRenderer line;

				public Color alphaStart;

				public Color alphaEnd;

				public FullNoteComponents()
				{
					//IL_000a: Unknown result type (might be due to invalid IL or missing references)
					//IL_000f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0010: 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_0017: Unknown result type (might be due to invalid IL or missing references)
					alphaStart = (alphaEnd = Color.black);
				}
			}

			public Queue<FullNoteComponents> _activeNotesComponents;

			public Color _headOutColor;

			public Color _headInColor;

			public Color _tailOutColor;

			public Color _tailInColor;

			public Color _bodyOutStartColor;

			public Color _bodyOutEndColor;

			public Color _bodyInStartColor;

			public Color _bodyInEndColor;

			public static float START_FADEOUT_POSX = 3.5f;

			public static float END_FADEOUT_POSX = -1.6f;

			public static int _counter;

			public override Metadata Metadata => HIDDEN;

			public override void Initialize(GameController __instance)
			{
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				//IL_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: 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_0079: Unknown result type (might be due to invalid IL or missing references)
				//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_00b4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
				//IL_0114: Unknown result type (might be due to invalid IL or missing references)
				//IL_0119: Unknown result type (might be due to invalid IL or missing references)
				//IL_0168: Unknown result type (might be due to invalid IL or missing references)
				_counter = 1;
				_activeNotesComponents = new Queue<FullNoteComponents>();
				GameObject val = __instance.allnotes.First();
				_headOutColor = ((Graphic)((Component)val.transform.Find("StartPoint")).GetComponent<Image>()).color;
				_headInColor = ((Graphic)((Component)val.transform.Find("StartPoint/StartPointColor")).GetComponent<Image>()).color;
				_tailOutColor = ((Graphic)((Component)val.transform.Find("EndPoint")).GetComponent<Image>()).color;
				_tailInColor = ((Graphic)((Component)val.transform.Find("EndPoint/EndPointColor")).GetComponent<Image>()).color;
				_bodyOutStartColor = ((Component)val.transform.Find("OutlineLine")).GetComponent<LineRenderer>().startColor;
				_bodyOutEndColor = ((Component)val.transform.Find("OutlineLine")).GetComponent<LineRenderer>().endColor;
				_bodyInStartColor = ((Component)val.transform.Find("Line")).GetComponent<LineRenderer>().startColor;
				_bodyInEndColor = ((Component)val.transform.Find("Line")).GetComponent<LineRenderer>().endColor;
				foreach (GameObject item2 in from n in __instance.allnotes.Skip(1)
					where n.transform.position.x <= START_FADEOUT_POSX + 9.4f
					select n)
				{
					if (item2.transform.position.x <= START_FADEOUT_POSX + 9.4f)
					{
						FullNoteComponents item = new FullNoteComponents
						{
							startPoint = ((Component)item2.transform.Find("StartPoint")).GetComponent<Image>(),
							startPointColor = ((Component)item2.transform.Find("StartPoint/StartPointColor")).GetComponent<Image>(),
							endPoint = ((Component)item2.transform.Find("EndPoint")).GetComponent<Image>(),
							endPointColor = ((Component)item2.transform.Find("EndPoint/EndPointColor")).GetComponent<Image>(),
							outlineLine = ((Component)item2.transform.Find("OutlineLine")).GetComponent<LineRenderer>(),
							line = ((Component)item2.transform.Find("Line")).GetComponent<LineRenderer>()
						};
						_activeNotesComponents.Enqueue(item);
					}
				}
			}

			public static void SetFadeOutValues(float startFadeOut, float endFadeOut)
			{
				START_FADEOUT_POSX = startFadeOut;
				END_FADEOUT_POSX = endFadeOut;
			}

			public override void Update(GameController __instance)
			{
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				//IL_0191: Unknown result type (might be due to invalid IL or missing references)
				//IL_01da: Unknown result type (might be due to invalid IL or missing references)
				//IL_0213: Unknown result type (might be due to invalid IL or missing references)
				//IL_021a: Unknown result type (might be due to invalid IL or missing references)
				//IL_021f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0232: Unknown result type (might be due to invalid IL or missing references)
				//IL_0239: Unknown result type (might be due to invalid IL or missing references)
				//IL_023e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0251: Unknown result type (might be due to invalid IL or missing references)
				//IL_0258: Unknown result type (might be due to invalid IL or missing references)
				//IL_025d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0270: Unknown result type (might be due to invalid IL or missing references)
				//IL_0277: Unknown result type (might be due to invalid IL or missing references)
				//IL_027c: Unknown result type (might be due to invalid IL or missing references)
				//IL_028f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0296: Unknown result type (might be due to invalid IL or missing references)
				//IL_029b: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
				//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
				//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
				//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
				//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
				//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0353: Unknown result type (might be due to invalid IL or missing references)
				for (int i = _counter; i < __instance.allnotes.Count; i++)
				{
					GameObject currentNote = __instance.allnotes[i];
					if (!_activeNotesComponents.Any((FullNoteComponents x) => (Object)(object)((Component)((Component)x.startPoint).transform.parent).gameObject == (Object)(object)currentNote))
					{
						if (currentNote.transform.position.x > START_FADEOUT_POSX + 9.4f)
						{
							break;
						}
						FullNoteComponents item = new FullNoteComponents
						{
							startPoint = ((Component)currentNote.transform.GetChild(0)).GetComponent<Image>(),
							startPointColor = ((Component)currentNote.transform.GetChild(0).GetChild(0)).GetComponent<Image>(),
							endPoint = ((Component)currentNote.transform.GetChild(1)).GetComponent<Image>(),
							endPointColor = ((Component)currentNote.transform.GetChild(1).GetChild(0)).GetComponent<Image>(),
							outlineLine = ((Component)currentNote.transform.GetChild(2)).GetComponent<LineRenderer>(),
							line = ((Component)currentNote.transform.GetChild(3)).GetComponent<LineRenderer>()
						};
						_counter++;
						_activeNotesComponents.Enqueue(item);
					}
				}
				for (int j = 0; j < _activeNotesComponents.Count; j++)
				{
					FullNoteComponents fullNoteComponents = _activeNotesComponents.ElementAt(j);
					fullNoteComponents.alphaStart.a = 1f - Mathf.Clamp((((Component)fullNoteComponents.startPoint).transform.position.x - END_FADEOUT_POSX) / (START_FADEOUT_POSX - END_FADEOUT_POSX), 0f, 1f);
					fullNoteComponents.alphaEnd.a = 1f - Mathf.Clamp((((Component)fullNoteComponents.endPoint).transform.position.x - END_FADEOUT_POSX) / (START_FADEOUT_POSX - END_FADEOUT_POSX), 0f, 1f);
					fullNoteComponents.outlineLine.startColor = _bodyOutStartColor - fullNoteComponents.alphaStart;
					fullNoteComponents.line.startColor = _bodyInStartColor - fullNoteComponents.alphaStart;
					((Graphic)fullNoteComponents.startPoint).color = _headOutColor - fullNoteComponents.alphaStart;
					((Graphic)fullNoteComponents.startPointColor).color = _headInColor - fullNoteComponents.alphaStart;
					fullNoteComponents.outlineLine.endColor = _bodyOutEndColor - fullNoteComponents.alphaEnd;
					fullNoteComponents.line.endColor = _bodyInEndColor - fullNoteComponents.alphaEnd;
					((Graphic)fullNoteComponents.endPoint).color = _tailOutColor - fullNoteComponents.alphaEnd;
					((Graphic)fullNoteComponents.endPointColor).color = _tailInColor - fullNoteComponents.alphaEnd;
				}
				while (_activeNotesComponents.Count > 0 && ((Component)_activeNotesComponents.Peek().endPoint).transform.position.x <= END_FADEOUT_POSX)
				{
					_activeNotesComponents.Dequeue();
				}
			}
		}

		public class Flashlight : GameModifierBase
		{
			private Settings _settings;

			private Vector2 _pointerPos;

			private Color _color;

			public override Metadata Metadata => FLASHLIGHT;

			public override void Initialize(GameController __instance)
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0066: Unknown result type (might be due to invalid IL or missing references)
				//IL_006f: 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_007c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0081: Unknown result type (might be due to invalid IL or missing references)
				//IL_0095: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
				((PostProcessingModel)__instance.gameplayppp.vignette).enabled = true;
				_pointerPos = new Vector2(0.075f, (__instance.pointer.transform.localPosition.y + 215f) / 430f);
				_color = new Color(0.3f, 0.3f, 0.3f, 1f);
				_settings = new Settings
				{
					center = _pointerPos,
					color = _color,
					intensity = 0.8f,
					mode = (Mode)0,
					rounded = true,
					roundness = 1f,
					smoothness = 1f
				};
			}

			public override void Update(GameController __instance)
			{
				//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00da: Unknown result type (might be due to invalid IL or missing references)
				//IL_00df: Unknown result type (might be due to invalid IL or missing references)
				//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f0: 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)
				if (__instance.totalscore != 0)
				{
					float num = (float)__instance.defaultnotelength / (100f / (__instance.tempo * TootTallyGlobalVariables.gameSpeedMultiplier));
					_settings.intensity = 325f / Mathf.Min(num, 325f) + __instance.breathcounter;
					if (__instance.notebuttonpressed && !__instance.outofbreath)
					{
						_color.r = (_color.g = (_color.b = 0f));
						_color.a = 1f;
					}
				}
				_pointerPos.y = (__instance.pointer.transform.localPosition.y + 215f) / 430f;
				_settings.center = _pointerPos;
				_settings.color = _color;
				__instance.gameplayppp.vignette.settings = _settings;
			}
		}

		public class Brutal : GameModifierBase
		{
			private float _defaultSpeed;

			private float _speed;

			private int _lastCombo;

			public override Metadata Metadata => BRUTAL;

			public override void Initialize(GameController __instance)
			{
				_defaultSpeed = 1f;
				_speed = _defaultSpeed;
				_lastCombo = 0;
			}

			public override void Update(GameController __instance)
			{
				if (__instance.paused || __instance.quitting || __instance.retrying || __instance.level_finished)
				{
					_speed = _defaultSpeed;
					Time.timeScale = 1f;
				}
				else if ((Object)(object)__instance.musictrack.outputAudioMixerGroup == (Object)(object)__instance.audmix_bgmus)
				{
					__instance.musictrack.outputAudioMixerGroup = __instance.audmix_bgmus_pitchshifted;
				}
			}

			public override void SpecialUpdate(GameController __instance)
			{
				if (_lastCombo != __instance.highestcombocounter || __instance.highestcombocounter == 0)
				{
					bool flag = _lastCombo < __instance.highestcombocounter && __instance.highestcombocounter != 0;
					_speed = Mathf.Clamp(_speed + (flag ? 0.015f : (-0.07f)), _defaultSpeed, 2f);
					Time.timeScale = _speed / _defaultSpeed;
					__instance.musictrack.pitch = _speed;
					__instance.audmix.SetFloat("pitchShifterMult", 1f / _speed);
				}
				_lastCombo = __instance.highestcombocounter;
			}
		}

		public class InstaFail : GameModifierBase
		{
			public override Metadata Metadata => INSTA_FAIL;

			public override void SpecialUpdate(GameController __instance)
			{
				if (!__instance.paused && !__instance.quitting && !__instance.retrying && !__instance.level_finished && !TootTallyGlobalVariables.isSpectating && !TootTallyGlobalVariables.isReplaying)
				{
					__instance.notebuttonpressed = false;
					__instance.musictrack.Pause();
					__instance.sfxrefs.backfromfreeplay.Play();
					__instance.quitting = true;
					__instance.pauseRetryLevel();
				}
			}
		}

		public class EasyMode : GameModifierBase
		{
			public override Metadata Metadata => EASY_MODE;

			public override void SpecialUpdate(GameController __instance)
			{
				__instance.notescoreaverage = Mathf.Clamp(__instance.notescoreaverage * 1.15f, 0f, 100f);
			}
		}

		public class StrictMode : GameModifierBase
		{
			public override Metadata Metadata => STRICT_MODE;

			public override void Update(GameController __instance)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_0095: Unknown result type (might be due to invalid IL or missing references)
				float num = __instance.noteholderr.anchoredPosition3D.x - __instance.zeroxpos;
				num = ((num > 0f) ? (-1f) : Mathf.Abs(num));
				if (__instance.noteactive && !__instance.freeplay && !__instance.paused)
				{
					float num2 = (__instance.currentnoteend - num) / (__instance.currentnoteend - __instance.currentnotestart);
					num2 = Mathf.Abs(1f - num2);
					float num3 = __instance.easeInOutVal(num2, 0f, __instance.currentnotepshift, 1f);
					float num4 = __instance.pointerrect.anchoredPosition.y - (__instance.currentnotestarty + num3);
					if (__instance.currentnotepshift != 0f)
					{
						float num5 = (Mathf.Clamp(Mathf.Abs(__instance.currentnotepshift), 10f, 150f) - 10f) / 140f;
						float num6 = Mathf.Lerp(0.96f, 0.7f, num5);
						num4 *= num6;
					}
					float num7 = 100f - Mathf.Abs(num4);
					if (num7 < 0f || !__instance.noteplaying)
					{
						__instance.notescoresamples += 4.78f;
						__instance.notescoretotal = 0f;
						__instance.notescoreaverage = __instance.notescoretotal / __instance.notescoresamples;
					}
				}
			}
		}

		public class AutoTune : GameModifierBase
		{
			public override Metadata Metadata => AUTO_TUNE;

			public override void SpecialUpdate(GameController __instance)
			{
			}
		}

		public class HiddenCursor : GameModifierBase
		{
			public override Metadata Metadata => HIDDEN_CURSOR;

			public override void Initialize(GameController __instance)
			{
				__instance.pointer.SetActive(false);
			}
		}

		public readonly struct Metadata
		{
			public string Name { get; }

			public ModifierType ModifierType { get; }

			public string Description { get; }

			public bool ScoreSubmitEnabled { get; }

			public Metadata(string name, ModifierType modifierType, string description, bool scoreSubmitEnabled)
			{
				Name = name;
				ModifierType = modifierType;
				Description = description;
				ScoreSubmitEnabled = scoreSubmitEnabled;
			}
		}

		public enum ModifierType
		{
			Hidden,
			Flashlight,
			Brutal,
			InstaFail,
			EasyMode,
			StrictMode,
			AutoTune,
			HiddenCursor
		}

		public static Metadata HIDDEN = new Metadata("HD", ModifierType.Hidden, "Hidden: Notes will disappear as they\n approach the left", scoreSubmitEnabled: true);

		public static Metadata FLASHLIGHT = new Metadata("FL", ModifierType.Flashlight, "Flashlight: Only a small circle around the\n cursor is visible", scoreSubmitEnabled: true);

		public static Metadata BRUTAL = new Metadata("BT", ModifierType.Brutal, "Brutal: Game will speed up if you do good and\n slow down when you are bad (Unrated)", scoreSubmitEnabled: false);

		public static Metadata INSTA_FAIL = new Metadata("IF", ModifierType.InstaFail, "Insta Fail: Restart the song as soon as you miss", scoreSubmitEnabled: true);

		public static Metadata EASY_MODE = new Metadata("EZ", ModifierType.EasyMode, "Easy Mode: Lower the threshold for combo and champ break", scoreSubmitEnabled: true);

		public static Metadata STRICT_MODE = new Metadata("ST", ModifierType.StrictMode, "Strict Mode: Note timing becomes significantly more strict (Unrated)", scoreSubmitEnabled: false);

		public static Metadata AUTO_TUNE = new Metadata("AT", ModifierType.AutoTune, "Auto Tune: Snaps to standard grid and slides (Unrated)", scoreSubmitEnabled: false);

		public static Metadata HIDDEN_CURSOR = new Metadata("HC", ModifierType.HiddenCursor, "Hidden Cursor: Make the cursor invisible", scoreSubmitEnabled: true);
	}
	public class ModifierButton
	{
		public CustomButton button;

		public bool active;

		public GameModifiers.Metadata modifier;

		public bool onCooldown = false;

		private GameObject glow;

		private SecondDegreeDynamicsAnimation anim = new SecondDegreeDynamicsAnimation(2.5f, 1f, 2.5f);

		public ModifierButton(Transform transform, GameModifiers.Metadata modifier, bool active, Vector2 size, int bubbleBorder, int fontSize, bool useWorldPosition, Action onClick = null)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0067: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Expected O, but got Unknown
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			string text = modifier.ModifierType.ToString();
			Sprite sprite = AssetManager.GetSprite(modifier.Name + ".png");
			this.active = active;
			this.modifier = modifier;
			button = GameObjectFactory.CreateCustomButton(transform, Vector2.zero, size, sprite, text, onClick);
			GameObject gameObject = ((Component)button).gameObject;
			GameObject val = GameObjectFactory.CreateBubble(Vector2.zero, text + "Bubble", modifier.Description, new Vector2(1f, 0f), bubbleBorder, true, fontSize);
			gameObject.AddComponent<BubblePopupHandler>().Initialize(val, useWorldPosition);
			glow = new GameObject("glow", new Type[1] { typeof(Image) });
			Image component = glow.GetComponent<Image>();
			component.useSpriteMesh = true;
			((Graphic)component).color = Theme.colors.replayButton.text;
			((MaskableGraphic)component).maskable = true;
			component.sprite = AssetManager.GetSprite("glow.png");
			glow.GetComponent<RectTransform>().sizeDelta = new Vector2(size.x * 1.5f, size.y * 1.5f);
			glow.transform.SetParent(gameObject.transform);
			glow.transform.localScale = Vector3.one / 1.2f;
			if (active)
			{
				ToggleOn();
			}
			else
			{
				ToggleOff();
			}
			RectTransform component2 = gameObject.GetComponent<RectTransform>();
			component2.pivot = Vector2.one / 2f;
		}

		public void ToggleOn()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			active = true;
			TootTallyAnimationManager.AddNewEulerAngleAnimation(((Component)button).gameObject, new Vector3(0f, 0f, 8f), 0.15f, anim, (Action<GameObject>)delegate
			{
				onCooldown = false;
			});
			glow.SetActive(true);
		}

		public void ToggleOff()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			active = false;
			TootTallyAnimationManager.AddNewEulerAngleAnimation(((Component)button).gameObject, Vector3.zero, 0.15f, anim, (Action<GameObject>)delegate
			{
				onCooldown = false;
			});
			glow.SetActive(false);
		}
	}
	[BepInPlugin("TootTallyGameModifiers", "TootTallyGameModifiers", "1.2.7")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin, ITootTallyModule
	{
		public static Plugin Instance;

		private Harmony _harmony;

		public static TootTallySettingSlider StartFadeoutInput;

		public static TootTallySettingSlider EndFadeoutInput;

		public ConfigEntry<bool> ModuleConfigEnabled { get; set; }

		public bool IsConfigInitialized { get; set; }

		public string Name
		{
			get
			{
				return "TootTallyGameModifiers";
			}
			set
			{
				Name = value;
			}
		}

		public static void LogInfo(string msg)
		{
			((BaseUnityPlugin)Instance).Logger.LogInfo((object)msg);
		}

		public static void LogError(string msg)
		{
			((BaseUnityPlugin)Instance).Logger.LogError((object)msg);
		}

		private void Awake()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			if (!((Object)(object)Instance != (Object)null))
			{
				Instance = this;
				_harmony = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
				GameInitializationEvent.Register(((BaseUnityPlugin)this).Info, (Action)TryInitialize);
			}
		}

		private void TryInitialize()
		{
			ModuleConfigEnabled = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Modules", "GameModifiers", true, "Enable GameModifiers");
			TootTallyModuleManager.AddModule((ITootTallyModule)(object)this);
		}

		public void LoadModule()
		{
			AssetBundleManager.LoadAssets(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)Instance).Info.Location), "layoutassetbundle"));
			AssetManager.LoadAssets(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)Instance).Info.Location), "Assets"));
			_harmony.PatchAll(typeof(GameModifierManager));
			LogInfo("Module loaded!");
		}

		public void UnloadModule()
		{
			_harmony.UnpatchSelf();
			LogInfo("Module unloaded!");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "TootTallyGameModifiers";

		public const string PLUGIN_NAME = "TootTallyGameModifiers";

		public const string PLUGIN_VERSION = "1.2.7";
	}
}