Decompiled source of CGModifiers v1.1.1

CGModifiers.dll

Decompiled 2 months ago
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using CGModifiers.Properties;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("CGModifiers")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1")]
[assembly: AssemblyProduct("CGModifiers")]
[assembly: AssemblyTitle("CGModifiers")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.1.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 CGModifiers
{
	[ConfigureSingleton(/*Could not decode attribute arguments.*/)]
	public class ModifierManager : MonoSingleton<ModifierManager>
	{
		private WaveMenu wm;

		public FloatSelector waveSelect;

		[Header("Wave Modifiers")]
		public FloatSelector startingPointsSelector;

		public FloatSelector pointMultiplierSelector;

		[Header("Enemy Modifiers")]
		public BoolSelector forceRadianceSelector;

		public FloatSelector initialUncommonsSelector;

		public FloatSelector uncommonsIncreaseSelector;

		public FloatSelector initialSpecialsSelector;

		public FloatSelector specialsIncreaseSelector;

		[Header("Arena Modifiers")]
		public BoolSelector scoreboardToggler;

		public FloatSelector zapZoneHeightSelector;

		public BoolSelector visibleOOBSelector;

		public Material OOBMaterial;

		[Header("Player Modifiers")]
		public FloatSelector maxStaminaSelector;

		public FloatSelector staminaRegenSelector;

		private void Start()
		{
			CollectionExtensions.Do<FloatSelector>((IEnumerable<FloatSelector>)((Component)this).GetComponentsInChildren<FloatSelector>(true), (Action<FloatSelector>)delegate(FloatSelector s)
			{
				s.Init();
			});
			CollectionExtensions.Do<BoolSelector>((IEnumerable<BoolSelector>)((Component)this).GetComponentsInChildren<BoolSelector>(true), (Action<BoolSelector>)delegate(BoolSelector s)
			{
				s.Init();
			});
			CollectionExtensions.Do<StringSelector>((IEnumerable<StringSelector>)((Component)this).GetComponentsInChildren<StringSelector>(true), (Action<StringSelector>)delegate(StringSelector s)
			{
				s.Init();
			});
			waveSelect.Init();
			wm = ((Component)waveSelect).GetComponentInParent<WaveMenu>();
			waveSelect.maxValue = Mathf.Min(Traverse.Create((object)wm).Field("highestWave").GetValue<int>() / 2, 25);
			startingPointsSelector.minValue = Traverse.Create((object)MonoSingleton<EndlessGrid>.Instance).Field("maxPoints").GetValue<int>();
			FloatSelector floatSelector = waveSelect;
			floatSelector.onValueChanged = (Action<float>)Delegate.Combine(floatSelector.onValueChanged, (Action<float>)delegate(float value)
			{
				wm.SetCurrentWave((int)value);
			});
		}
	}
	[HarmonyPatch]
	internal static class Patches
	{
		[HarmonyPatch(typeof(WaveSetter), "OnPointerClick")]
		[HarmonyPostfix]
		private static void WaveSetter_OnPointerClick_Postfix(WaveSetter __instance)
		{
			MonoSingleton<ModifierManager>.Instance.waveSelect.Value = __instance.wave;
		}

		[HarmonyPatch(typeof(WaveMenu), "SetCurrentWave")]
		[HarmonyPrefix]
		private static bool WaveMenu_SetCurrentWave_Prefix(int wave, WaveMenu __instance, ref int ___currentWave)
		{
			MonoSingleton<EndlessGrid>.Instance.startWave = (___currentWave = wave);
			MonoSingleton<PrefsManager>.Instance.SetInt("cyberGrind.startingWave", wave);
			foreach (WaveSetter setter in __instance.setters)
			{
				if (setter.wave == ___currentWave)
				{
					setter.Selected();
				}
				else
				{
					setter.Unselected();
				}
			}
			return false;
		}

		[HarmonyPatch(typeof(EndlessGrid), "OnTriggerEnter")]
		[HarmonyPrefix]
		private static void EndlessGrid_OnTriggerEnter_Prefix(Collider other, EndlessGrid __instance, ref int ___maxPoints)
		{
			if (((Component)other).CompareTag("Player"))
			{
				___maxPoints = Mathf.RoundToInt(MonoSingleton<ModifierManager>.Instance.startingPointsSelector.Value * (float)((!MonoSingleton<ModifierManager>.Instance.forceRadianceSelector.Value) ? 1 : 3));
				for (int i = 1; i <= __instance.startWave - 1; i++)
				{
					___maxPoints += Mathf.RoundToInt((float)(3 + i / 3) * (MonoSingleton<ModifierManager>.Instance.pointMultiplierSelector.Value * (float)((!MonoSingleton<ModifierManager>.Instance.forceRadianceSelector.Value) ? 1 : 3) - 1f));
				}
			}
		}

		[HarmonyPatch(typeof(EndlessGrid), "OnTriggerEnter")]
		[HarmonyPostfix]
		private static void EndlessGrid_OnTriggerEnter_Postfix(Collider other)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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)
			if (((Component)other).CompareTag("Player"))
			{
				Transform transform = GameObject.Find("/Everything").transform;
				Transform child = transform.GetChild(4);
				child.localPosition = new Vector3(child.localPosition.x, MonoSingleton<ModifierManager>.Instance.zapZoneHeightSelector.Value * 2.5f + 10.5f, child.localPosition.z);
				((Component)child.Find("Canvas")).gameObject.SetActive(MonoSingleton<ModifierManager>.Instance.scoreboardToggler.Value);
				Renderer component = GameObject.Find("/OutOfBounds").GetComponent<Renderer>();
				component.enabled = MonoSingleton<ModifierManager>.Instance.visibleOOBSelector.Value;
				component.material = MonoSingleton<ModifierManager>.Instance.OOBMaterial;
			}
		}

		[HarmonyPatch(typeof(EndlessGrid), "NextWave")]
		[HarmonyPrefix]
		private static void EndlessGrid_NextWave_Prefix(EndlessGrid __instance, ref int ___maxPoints)
		{
			___maxPoints += Mathf.RoundToInt((float)(3 + (__instance.currentWave + 1) / 3) * (MonoSingleton<ModifierManager>.Instance.pointMultiplierSelector.Value * (float)((!MonoSingleton<ModifierManager>.Instance.forceRadianceSelector.Value) ? 1 : 3) - 1f));
		}

		[HarmonyPatch(typeof(EndlessGrid), "SpawnRadiant")]
		[HarmonyPrefix]
		private static bool EndlessGrid_SpawnRadiant_Prefix(ref bool __result)
		{
			if (MonoSingleton<ModifierManager>.Instance.forceRadianceSelector.Value)
			{
				__result = true;
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(EndlessGrid), "CapUncommonsAmount")]
		[HarmonyPostfix]
		private static void EndlessGrid_CapUncommonsAmount_Postfix(ref int __result)
		{
			__result += (int)MonoSingleton<ModifierManager>.Instance.initialUncommonsSelector.Value;
		}
	}
	[BepInPlugin("CGModifiers", "CGModifiers", "1.1.1")]
	public class Plugin : BaseUnityPlugin
	{
		private const string CGSceneName = "9240e656c89994d44b21940f65ab57da";

		private const string FirstRoomPath = "/FirstRoom/Room";

		private const string WavePanelPath = "/FirstRoom/Room/CyberGrindSettings/Canvas/Waves/Panel";

		public static AssetBundle assets;

		private void Awake()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			assets = AssetBundle.LoadFromMemory(Resources.assets);
			SceneManager.sceneLoaded += OnSceneLoaded;
			new Harmony("CGModifiers.harmony").PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin CGModifiers is loaded!");
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode loadSceneMode)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			if (!(((Scene)(ref scene)).name != "9240e656c89994d44b21940f65ab57da"))
			{
				Transform transform = GameObject.Find("/FirstRoom/Room/CyberGrindSettings/Canvas/Waves/Panel").transform;
				GameObject val = Object.Instantiate<GameObject>(assets.LoadAsset<GameObject>("Wave Selector"), transform, false);
				Transform val2 = transform.Find("Text");
				val2.localPosition += new Vector3(0f, 10f, 0f);
				((TMP_Text)((Component)val2).GetComponent<TextMeshProUGUI>()).paragraphSpacing = -30f;
				((Component)transform.Find("0")).GetComponent<WaveSetter>().wave = 1;
				Object.Instantiate<GameObject>(assets.LoadAsset<GameObject>("Modifiers Terminal"), GameObject.Find("/FirstRoom/Room").transform, false).GetComponent<ModifierManager>().waveSelect = val.GetComponent<FloatSelector>();
			}
		}
	}
	public class BoolSelector : MonoBehaviour
	{
		public string identifier;

		private GameObject checkmark;

		private ShopButton button;

		public bool requireCheatsToToggle;

		public bool defaultValue;

		public Action<bool> onValueChanged;

		private bool value;

		private bool CheatsEnabled => MonoSingleton<AssistController>.Instance.cheatsEnabled;

		public bool Value
		{
			get
			{
				return value;
			}
			set
			{
				if (!requireCheatsToToggle || CheatsEnabled)
				{
					this.value = value;
					MonoSingleton<PrefsManager>.Instance.SetBoolLocal(identifier, Value);
					onValueChanged?.Invoke(Value);
					checkmark.SetActive(Value);
				}
			}
		}

		public void Init()
		{
			button = ((Component)this).GetComponentInChildren<ShopButton>(true);
			checkmark = ((Component)((Component)this).transform.Find("Toggle/Checkmark")).gameObject;
			Value = MonoSingleton<PrefsManager>.Instance.GetBoolLocal(identifier, defaultValue);
		}

		private void Update()
		{
			button.failure = requireCheatsToToggle && !CheatsEnabled;
		}

		public void Toggle()
		{
			Value = !Value;
		}
	}
	public class FloatSelector : MonoBehaviour
	{
		public string identifier;

		private TextMeshProUGUI valueText;

		private ShopButton[] increaseButtons;

		private ShopButton[] decreaseButtons;

		private ShopButton resetButton;

		public string suffix;

		public float minValue;

		public float minValueWithCheats;

		public float maxValue;

		public float maxValueWithCheats;

		public float defaultValue;

		public Action<float> onValueChanged;

		private float value;

		private bool CheatsEnabled => MonoSingleton<AssistController>.Instance.cheatsEnabled;

		public float Value
		{
			get
			{
				return value;
			}
			set
			{
				this.value = Mathf.Clamp(value, CheatsEnabled ? minValueWithCheats : minValue, CheatsEnabled ? maxValueWithCheats : maxValue);
				MonoSingleton<PrefsManager>.Instance.SetFloatLocal(identifier, Value);
				onValueChanged?.Invoke(Value);
				((MonoBehaviour)this).Invoke("UpdateButtons", 0f);
				SetText(Value);
			}
		}

		public void Init()
		{
			valueText = ((Component)((Component)this).transform.Find("Value/Text")).GetComponent<TextMeshProUGUI>();
			increaseButtons = (ShopButton[])(object)new ShopButton[2]
			{
				((Component)((Component)this).transform.Find(">")).GetComponent<ShopButton>(),
				((Component)((Component)this).transform.Find(">>")).GetComponent<ShopButton>()
			};
			decreaseButtons = (ShopButton[])(object)new ShopButton[2]
			{
				((Component)((Component)this).transform.Find("<")).GetComponent<ShopButton>(),
				((Component)((Component)this).transform.Find("<<")).GetComponent<ShopButton>()
			};
			resetButton = ((Component)((Component)this).transform.Find("Value")).GetComponent<ShopButton>();
			Value = MonoSingleton<PrefsManager>.Instance.GetFloatLocal(identifier, defaultValue);
		}

		public void AddAmount(float amount)
		{
			Value += (MonoSingleton<InputManager>.Instance.InputSource.Dodge.IsPressed ? (amount * 10f) : amount);
		}

		public void ResetValue()
		{
			Value = defaultValue;
		}

		private void SetText(float value)
		{
			((TMP_Text)valueText).text = value + suffix;
		}

		private void UpdateButtons()
		{
			CollectionExtensions.Do<ShopButton>((IEnumerable<ShopButton>)increaseButtons, (Action<ShopButton>)delegate(ShopButton btn)
			{
				btn.failure = Value >= (CheatsEnabled ? maxValueWithCheats : maxValue);
			});
			CollectionExtensions.Do<ShopButton>((IEnumerable<ShopButton>)decreaseButtons, (Action<ShopButton>)delegate(ShopButton btn)
			{
				btn.failure = Value <= (CheatsEnabled ? minValueWithCheats : minValue);
			});
			if (Object.op_Implicit((Object)(object)resetButton))
			{
				resetButton.deactivated = Value == defaultValue;
			}
		}
	}
	public class StringSelector : MonoBehaviour
	{
		public string identifier;

		private TMP_Dropdown dropdown;

		public string[] options;

		public bool[] cheatsRequiredFor;

		public string defaultValue;

		public Action<string> onValueChanged;

		private string value;

		private bool CheatsEnabled => MonoSingleton<AssistController>.Instance.cheatsEnabled;

		public string Value
		{
			get
			{
				return value;
			}
			set
			{
				if (!cheatsRequiredFor[options.ToList().FindIndex((string opt) => opt == value)] || CheatsEnabled)
				{
					this.value = value;
					MonoSingleton<PrefsManager>.Instance.SetStringLocal(identifier, Value);
					onValueChanged?.Invoke(Value);
				}
			}
		}

		public void Init()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			dropdown = ((Component)this).GetComponentInChildren<TMP_Dropdown>(true);
			string[] array = options;
			foreach (string text in array)
			{
				dropdown.options.Add(new OptionData(text));
			}
			dropdown.value = dropdown.options.FindIndex((OptionData opt) => opt.text == MonoSingleton<PrefsManager>.Instance.GetStringLocal(identifier, defaultValue));
		}

		public void SetValue(int data)
		{
			Value = dropdown.options[data].text;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "CGModifiers";

		public const string PLUGIN_NAME = "CGModifiers";

		public const string PLUGIN_VERSION = "1.1.1";
	}
}
namespace CGModifiers.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resources
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static ResourceManager ResourceManager
		{
			get
			{
				if (resourceMan == null)
				{
					ResourceManager resourceManager = new ResourceManager("CGModifiers.Properties.Resources", typeof(Resources).Assembly);
					resourceMan = resourceManager;
				}
				return resourceMan;
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static CultureInfo Culture
		{
			get
			{
				return resourceCulture;
			}
			set
			{
				resourceCulture = value;
			}
		}

		internal static byte[] assets
		{
			get
			{
				object @object = ResourceManager.GetObject("assets", resourceCulture);
				return (byte[])@object;
			}
		}

		internal Resources()
		{
		}
	}
}