GUM.dll

Decompiled 4 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.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using DM;
using HarmonyLib;
using Landfall.TABS;
using Landfall.TABS.GameMode;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
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: AssemblyTitle("GUM")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GUM")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c18a4f6b-1b3f-4c82-88f4-95db8fb1799e")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace GUM
{
	[BepInPlugin("org.bepinex.plugins.GUM", "GUM", "1.2.2")]
	internal class Loader : BaseUnityPlugin
	{
		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			GameObject val = new GameObject("GUM");
			Object.DontDestroyOnLoad((Object)(object)val);
			val.AddComponent<Main>();
		}
	}
	[BepInPlugin("org.bepinex.plugins.GUM", "GUM", "1.2.2")]
	public class Main : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(SettingsHandler), "OpenSettingsMenu")]
		[HarmonyPatch(new Type[] { typeof(int) })]
		private class SetupSettings
		{
			[HarmonyPostfix]
			public static void Postfix(SettingsHandler __instance, ref int tabID)
			{
				if (!((Object)(object)GameObject.Find("God Units Mod") == (Object)null))
				{
					return;
				}
				Toggle[] source = (Toggle[])typeof(SettingsHandler).GetField("m_topButtons", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
				List<Toggle> list = source.ToList();
				GameObject gameObject = ((Component)((Component)__instance).transform.Find("Tabs")).gameObject;
				GameObject val = Object.Instantiate<GameObject>(((Component)gameObject.transform.Find("Dot")).gameObject);
				val.transform.SetParent(gameObject.transform);
				GameObject val2 = Object.Instantiate<GameObject>(((Component)gameObject.transform.Find("Twitch")).gameObject);
				val2.transform.SetParent(gameObject.transform);
				((Object)val2.gameObject).name = "God Units Mod";
				TextMeshProUGUI[] componentsInChildren = val2.GetComponentsInChildren<TextMeshProUGUI>(true);
				foreach (TextMeshProUGUI val3 in componentsInChildren)
				{
					((TMP_Text)val3).text = "GUM";
				}
				Toggle component = val2.GetComponent<Toggle>();
				((UnityEvent<bool>)(object)component.onValueChanged).AddListener((UnityAction<bool>)delegate(bool isOn)
				{
					if (isOn)
					{
						SelectedTab();
					}
				});
				source = list.ToArray();
			}
		}

		public static ConfigEntry<int> MAGSIZE;

		public static ConfigEntry<float> RECOIL;

		public static ConfigEntry<float> SPREAD;

		public static ConfigEntry<float> atkspeed;

		public static Main instance;

		public ContentDatabase DB => ContentDatabase.Instance();

		public void Awake()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			Debug.Log((object)"Loaded GUM Successfully");
			LoadConfig();
			Harmony val = new Harmony("ARARGDGUM");
			val.PatchAll();
			instance = this;
		}

		public void LoadConfig()
		{
			MAGSIZE = ((BaseUnityPlugin)this).Config.Bind<int>("SETTINGS", "magsize", 10, "Amount of Projectiles to throw");
			RECOIL = ((BaseUnityPlugin)this).Config.Bind<float>("SETTINGS", "Recoil", 1f, "Amount of recoil behind each projectile, recommended low number");
			SPREAD = ((BaseUnityPlugin)this).Config.Bind<float>("SETTINGS", "spread", 10f, "Spread of the projectiles");
			atkspeed = ((BaseUnityPlugin)this).Config.Bind<float>("SETTINGS", "atkspeed", 1f, "Attack Speed of the unit");
		}

		public void Update()
		{
			//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_001f: 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_041c: Unknown result type (might be due to invalid IL or missing references)
			//IL_043d: Unknown result type (might be due to invalid IL or missing references)
			//IL_044f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0454: Unknown result type (might be due to invalid IL or missing references)
			//IL_0470: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0398: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown((KeyCode)282))
			{
				DatabaseID lastSelectedUnit = PlacementUI.m_lastSelectedUnit;
				UnitBlueprint val = Object.Instantiate<UnitBlueprint>(DB.GetUnitBlueprint(lastSelectedUnit));
				val.Entity.GUID = DatabaseID.NewID();
				val.Entity.Name = "GOD UNIT " + ((Object)this).name;
				if (val.UnitRiders != null)
				{
					UnitBlueprint[] unitRiders = val.UnitRiders;
					foreach (UnitBlueprint val2 in unitRiders)
					{
						if ((Object)(object)val2.LeftWeapon != (Object)null && (Object)(object)val2.LeftWeapon.GetComponentInChildren<RangeWeapon>() != (Object)null)
						{
							val2.LeftWeapon = Object.Instantiate<GameObject>(val2.LeftWeapon);
							Object.DontDestroyOnLoad((Object)(object)val2.LeftWeapon);
							val2.LeftWeapon.transform.position = new Vector3(-10000f, -10000f, -10000f);
							RangeWeapon componentInChildren = val2.LeftWeapon.GetComponentInChildren<RangeWeapon>();
							componentInChildren.magSize = MAGSIZE.Value;
							componentInChildren.spread = SPREAD.Value;
							componentInChildren.shootRecoil = RECOIL.Value;
							componentInChildren.numberOfObjects = MAGSIZE.Value;
							val2.attackSpeedMultiplier = atkspeed.Value;
						}
						if ((Object)(object)val2.RightWeapon != (Object)null && (Object)(object)val2.RightWeapon.GetComponentInChildren<RangeWeapon>() != (Object)null)
						{
							val2.RightWeapon = Object.Instantiate<GameObject>(val2.RightWeapon);
							Object.DontDestroyOnLoad((Object)(object)val2.RightWeapon);
							val2.RightWeapon.transform.position = new Vector3(-10000f, -10000f, -10000f);
							RangeWeapon componentInChildren2 = val2.RightWeapon.GetComponentInChildren<RangeWeapon>();
							componentInChildren2.magSize = MAGSIZE.Value;
							componentInChildren2.spread = SPREAD.Value;
							componentInChildren2.shootRecoil = RECOIL.Value;
							componentInChildren2.numberOfObjects = MAGSIZE.Value;
							val2.attackSpeedMultiplier = atkspeed.Value;
						}
					}
				}
				if ((Object)(object)val.LeftWeapon != (Object)null && (Object)(object)val.LeftWeapon.GetComponentInChildren<RangeWeapon>() != (Object)null)
				{
					val.LeftWeapon = Object.Instantiate<GameObject>(val.LeftWeapon);
					Object.DontDestroyOnLoad((Object)(object)val.LeftWeapon);
					val.LeftWeapon.transform.position = new Vector3(-10000f, -10000f, -10000f);
					RangeWeapon componentInChildren3 = val.LeftWeapon.GetComponentInChildren<RangeWeapon>();
					componentInChildren3.magSize = MAGSIZE.Value;
					componentInChildren3.spread = SPREAD.Value;
					componentInChildren3.shootRecoil = RECOIL.Value;
					componentInChildren3.numberOfObjects = MAGSIZE.Value;
					val.attackSpeedMultiplier = atkspeed.Value;
				}
				if ((Object)(object)val.RightWeapon != (Object)null && (Object)(object)val.RightWeapon.GetComponentInChildren<RangeWeapon>() != (Object)null)
				{
					val.RightWeapon = Object.Instantiate<GameObject>(val.RightWeapon);
					Object.DontDestroyOnLoad((Object)(object)val.RightWeapon);
					val.RightWeapon.transform.position = new Vector3(-10000f, -10000f, -10000f);
					RangeWeapon componentInChildren4 = val.RightWeapon.GetComponentInChildren<RangeWeapon>();
					componentInChildren4.magSize = MAGSIZE.Value;
					componentInChildren4.spread = SPREAD.Value;
					componentInChildren4.shootRecoil = RECOIL.Value;
					componentInChildren4.numberOfObjects = MAGSIZE.Value;
					val.attackSpeedMultiplier = atkspeed.Value;
				}
				ContentDatabase.Instance().LandfallContentDatabase.m_unitBlueprints.Add(val.Entity.GUID, val);
				ContentDatabase.Instance().AssetLoader.m_nonStreamableAssets.Add(val.Entity.GUID, (Object)(object)val);
				PlacementUI.m_lastSelectedUnit = val.Entity.GUID;
				BaseGameMode currentGameMode = PlacementUI.Instance.m_currentGameMode;
				currentGameMode.Brush.SetBrushUnit(val.Entity.GUID);
			}
			if (Input.GetKeyDown((KeyCode)283))
			{
				LoadValues();
			}
		}

		public static void SelectedTab()
		{
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Expected O, but got Unknown
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Expected O, but got Unknown
			GameObject gameObject = ((Component)Object.FindObjectOfType<SettingsHandler>()).gameObject;
			GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>();
			GameObject val = null;
			GameObject val2 = null;
			GameObject[] array2 = array;
			foreach (GameObject val3 in array2)
			{
				if (((Object)val3).name == "TwitchConnectPrefab")
				{
					val = val3;
				}
				if (((Object)val3).name == "OpenAuthButton")
				{
					val2 = val3;
				}
			}
			GameObject gameObject2 = ((Component)gameObject.transform.Find("Scroll View").Find("Viewport").Find("Content")).gameObject;
			Transform[] componentsInChildren = gameObject2.GetComponentsInChildren<Transform>();
			foreach (Transform val4 in componentsInChildren)
			{
				if (((Object)((Component)val4).gameObject).name != "Content")
				{
					((Component)val4).gameObject.SetActive(false);
				}
			}
			GameObject val5 = Object.Instantiate<GameObject>(val);
			Object.DontDestroyOnLoad((Object)(object)val5);
			GameObject val6 = Object.Instantiate<GameObject>(val);
			Object.DontDestroyOnLoad((Object)(object)val6);
			GameObject val7 = Object.Instantiate<GameObject>(val);
			Object.DontDestroyOnLoad((Object)(object)val7);
			GameObject val8 = Object.Instantiate<GameObject>(val2);
			Object.DontDestroyOnLoad((Object)(object)val8);
			GameObject val9 = Object.Instantiate<GameObject>(val);
			Object.DontDestroyOnLoad((Object)(object)val9);
			((Object)val5).name = "Ammo setting";
			((Behaviour)((Component)val5.transform.GetChild(0)).GetComponent<LocalizeText>()).enabled = false;
			((TMP_Text)((Component)val5.transform.GetChild(0)).GetComponent<TextMeshProUGUI>()).text = "Ammo";
			val5.transform.SetParent(gameObject.transform.GetChild(6).GetChild(0).GetChild(0));
			((Object)val6).name = "Spread setting";
			((Behaviour)((Component)val6.transform.GetChild(0)).GetComponent<LocalizeText>()).enabled = false;
			((TMP_Text)((Component)val6.transform.GetChild(0)).GetComponent<TextMeshProUGUI>()).text = "Spread";
			val6.transform.SetParent(gameObject.transform.GetChild(6).GetChild(0).GetChild(0));
			((Object)val7).name = "Recoil setting";
			((Behaviour)((Component)val7.transform.GetChild(0)).GetComponent<LocalizeText>()).enabled = false;
			((TMP_Text)((Component)val7.transform.GetChild(0)).GetComponent<TextMeshProUGUI>()).text = "Recoil";
			val7.transform.SetParent(gameObject.transform.GetChild(6).GetChild(0).GetChild(0));
			((Object)val9).name = "atkspeed setting";
			((Behaviour)((Component)val9.transform.GetChild(0)).GetComponent<LocalizeText>()).enabled = false;
			((TMP_Text)((Component)val9.transform.GetChild(0)).GetComponent<TextMeshProUGUI>()).text = "Attack Speed";
			val9.transform.SetParent(gameObject.transform.GetChild(6).GetChild(0).GetChild(0));
			val8.GetComponent<Button>().onClick = new ButtonClickedEvent();
			((UnityEvent)val8.GetComponent<Button>().onClick).AddListener(new UnityAction(instance.LoadValues));
			val8.transform.SetParent(gameObject.transform.GetChild(6).GetChild(0).GetChild(0));
			((Behaviour)val8.GetComponentInChildren<LocalizeText>()).enabled = false;
			((TMP_Text)val8.GetComponentInChildren<TextMeshProUGUI>()).text = "Set Values";
		}

		public void LoadValues()
		{
			string text = GameObject.Find("Ammo setting").GetComponentInChildren<TMP_InputField>().text;
			string text2 = GameObject.Find("Spread setting").GetComponentInChildren<TMP_InputField>().text;
			string text3 = GameObject.Find("Recoil setting").GetComponentInChildren<TMP_InputField>().text;
			string text4 = GameObject.Find("atkspeed setting").GetComponentInChildren<TMP_InputField>().text;
			if (int.TryParse(text, out var result))
			{
				MAGSIZE.Value = result;
			}
			if (float.TryParse(text2, out var result2))
			{
				SPREAD.Value = result2;
			}
			if (float.TryParse(text3, out var result3))
			{
				RECOIL.Value = result3;
			}
			if (float.TryParse(text4, out var result4))
			{
				atkspeed.Value = result4;
			}
			((BaseUnityPlugin)this).Config.Reload();
		}
	}
}
namespace GUM.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "16.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("GUM.Properties.Resources", typeof(Resources).Assembly);
					resourceMan = resourceManager;
				}
				return resourceMan;
			}
		}

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

		internal Resources()
		{
		}
	}
}