Decompiled source of UnitsSummoner v1.0.5

UnitsSummoner.dll

Decompiled 5 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Landfall.TABS;
using Landfall.TABS.Workshop;
using TFBGames;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ArmsSummoner")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("by fhpslm")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7acfaef0-7669-4401-8bff-5a9a02e18c75")]
[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 ArmsSummoner;

[BepInPlugin("ArmsSummonermain", "ArmsSummonermain", "1.0.0")]
public class Main : BaseUnityPlugin
{
	public class U : MonoBehaviour
	{
		public void Start()
		{
			S2.US(((Component)this).gameObject.GetComponent<Unit>());
		}
	}

	public LandfallUnitDatabase db;

	private int num;

	private Team team;

	private int size = 1;

	private bool start;

	private Dictionary<string, string> keyValuePairs;

	private UnitBlueprint spawnunit;

	private bool Isnum;

	private bool use;

	public void Awake()
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
		new Harmony("ArmsSummoner").PatchAll();
	}

	private void Update()
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Invalid comparison between Unknown and I4
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Invalid comparison between Unknown and I4
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Invalid comparison between Unknown and I4
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Invalid comparison between Unknown and I4
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Invalid comparison between Unknown and I4
		//IL_0195: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Invalid comparison between Unknown and I4
		//IL_020b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0211: Invalid comparison between Unknown and I4
		//IL_0234: Unknown result type (might be due to invalid IL or missing references)
		//IL_023a: Invalid comparison between Unknown and I4
		//IL_021d: Unknown result type (might be due to invalid IL or missing references)
		//IL_022f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0226: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0308: Unknown result type (might be due to invalid IL or missing references)
		//IL_032b: Unknown result type (might be due to invalid IL or missing references)
		//IL_033b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0359: Unknown result type (might be due to invalid IL or missing references)
		//IL_035f: Unknown result type (might be due to invalid IL or missing references)
		if ((int)CampaignPlayerDataHolder.CurrentGameModeState == 2 && !start)
		{
			UnitBlueprint[] array = Resources.FindObjectsOfTypeAll<UnitBlueprint>();
			foreach (UnitBlueprint item in array)
			{
				if (!SLMATool.super<UnitBlueprint>("Units").Contains(item))
				{
					SLMATool.super<UnitBlueprint>("Units").Add(item);
				}
			}
			start = true;
			num = 0;
			spawnunit = SLMATool.super<UnitBlueprint>("Units")[num];
		}
		if (Input.GetKeyDown((KeyCode)108))
		{
			use = !use;
		}
		if (!use)
		{
			return;
		}
		if ((int)CampaignPlayerDataHolder.CurrentGameModeState == 2 && Input.GetKeyDown((KeyCode)98))
		{
			team = (Team)0;
			start = true;
			num = 0;
			spawnunit = SLMATool.super<UnitBlueprint>("Units")[num];
		}
		if ((int)CampaignPlayerDataHolder.CurrentGameModeState == 2 && Input.GetKeyDown((KeyCode)99))
		{
			size++;
		}
		if ((int)CampaignPlayerDataHolder.CurrentGameModeState == 2 && Input.GetKeyDown((KeyCode)118) && size != 1)
		{
			size--;
		}
		if ((int)CampaignPlayerDataHolder.CurrentGameModeState == 2 && Input.GetKeyDown((KeyCode)106))
		{
			if (num == SLMATool.super<UnitBlueprint>("Units").Count - 1)
			{
				num = 0;
				spawnunit = SLMATool.super<UnitBlueprint>("Units")[num];
			}
			else
			{
				num++;
				spawnunit = SLMATool.super<UnitBlueprint>("Units")[num];
			}
		}
		if ((int)CampaignPlayerDataHolder.CurrentGameModeState == 2 && Input.GetKeyDown((KeyCode)107))
		{
			if (num == 0)
			{
				num = SLMATool.super<UnitBlueprint>("Units").Count - 1;
				spawnunit = SLMATool.super<UnitBlueprint>("Units")[num];
			}
			else
			{
				num--;
				spawnunit = SLMATool.super<UnitBlueprint>("Units")[num];
			}
		}
		if ((int)CampaignPlayerDataHolder.CurrentGameModeState == 2 && Input.GetKeyDown((KeyCode)120))
		{
			if ((int)team == 0)
			{
				team = (Team)1;
			}
			else
			{
				team = (Team)0;
			}
		}
		if ((int)CampaignPlayerDataHolder.CurrentGameModeState == 2 && Input.GetKeyDown((KeyCode)122))
		{
			UnitBlueprint val = CreateUnit(spawnunit);
			if (Object.op_Implicit((Object)(object)val.RightWeapon))
			{
				size obj = val.RightWeapon.AddComponent<size>();
				obj.ssize = size;
				obj.unit = val;
			}
			if (Object.op_Implicit((Object)(object)val.LeftWeapon))
			{
				size obj2 = val.LeftWeapon.AddComponent<size>();
				obj2.ssize = size;
				obj2.unit = val;
			}
			val.UnitBase.AddComponent<U>();
			val.sizeMultiplier *= (float)size;
			val.Spawn(new Vector3(((Component)((Component)((Component)Object.FindObjectOfType<CameraMovement>()).transform.root).GetComponentInChildren<Camera>()).transform.position.x, ((Component)((Component)((Component)Object.FindObjectOfType<CameraMovement>()).transform.root).GetComponentInChildren<Camera>()).transform.position.y, ((Component)((Component)((Component)Object.FindObjectOfType<CameraMovement>()).transform.root).GetComponentInChildren<Camera>()).transform.position.z + 1f), ((Component)((Component)((Component)Object.FindObjectOfType<CameraMovement>()).transform.root).GetComponentInChildren<Camera>()).transform.rotation, team, 1f, (UnitPoolInfo?)null);
		}
	}

	private void OnGUI()
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Expected O, but got Unknown
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Invalid comparison between Unknown and I4
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: 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_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: 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_00fb: Expected O, but got Unknown
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Expected O, but got Unknown
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Expected O, but got Unknown
		//IL_0158: Unknown result type (might be due to invalid IL or missing references)
		//IL_0178: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: Expected O, but got Unknown
		GUIStyle val = new GUIStyle();
		if ((int)CampaignPlayerDataHolder.CurrentGameModeState == 2 && use)
		{
			Language val2 = (Language)typeof(Localizer).GetField("m_locale", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);
			keyValuePairs = Localizer.GetLanguage(val2);
			val.normal.textColor = Color.red;
			val.fontSize = Screen.width / 80;
			if (keyValuePairs.ContainsKey(spawnunit.Name))
			{
				GUI.Label(new Rect(0f, (float)Screen.width / 18f, (float)Screen.width, 80f), new GUIContent(keyValuePairs[spawnunit.Name]), val);
			}
			else
			{
				GUI.Label(new Rect(0f, (float)Screen.width / 18f, (float)Screen.width, 80f), new GUIContent(spawnunit.Name), val);
			}
			GUI.Label(new Rect(0f, (float)Screen.width / 24f, (float)Screen.width, 80f), new GUIContent("Size:" + size), val);
			GUI.Label(new Rect(0f, (float)Screen.width / 36f, (float)Screen.width, 80f), new GUIContent("Team:" + ((object)(Team)(ref team)).ToString()), val);
		}
	}

	public static UnitBlueprint CreateUnit(UnitBlueprint unit)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Expected O, but got Unknown
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		LandfallUnitDatabase database = LandfallUnitDatabase.GetDatabase();
		UnitBlueprint val = Object.Instantiate<UnitBlueprint>(unit);
		((DatabaseEntity)val.SetField<UnitBlueprint>("m_entity", (object)new DatabaseEntity((WorkshopContentType)0)).GetField<UnitBlueprint>("m_entity")).GenerateNewID();
		database.AddUnitWithID(val);
		val.Entity.Name = unit.Entity.Name + "S";
		return val;
	}
}
public static class S
{
	public static object GetField<T>(this T self, string name) where T : class
	{
		FieldInfo field = typeof(T).GetField(name, (BindingFlags)(-1));
		if (field != null)
		{
			return field.GetValue(self);
		}
		return null;
	}
}
public class SLMATool
{
	public static List<T> super<T>(string key)
	{
		return LandfallUnitDatabase.GetDatabase().GetField<LandfallUnitDatabase>(key) as List<T>;
	}
}
[BepInPlugin("SLMA.ArmsSummoner", "ArmsSummoner", "1.0.0")]
public static class S2
{
	public static T SetField<T>(this T self, string name, object value) where T : class
	{
		FieldInfo field = typeof(T).GetField(name, (BindingFlags)(-1));
		if (field != null)
		{
			field.SetValue(self, value);
		}
		return self;
	}

	public static void US(Unit unit)
	{
		Debug.Log((object)"hi");
	}
}
public class size : MonoBehaviour
{
	public int ssize;

	public UnitBlueprint unit;

	public void Start()
	{
		//IL_002e: 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)
		if ((Object)(object)((Component)((Component)this).transform.root).GetComponent<Unit>().unitBlueprint == (Object)(object)unit)
		{
			Transform transform = ((Component)this).gameObject.transform;
			transform.localScale *= (float)ssize;
		}
	}
}