Decompiled source of Better UX v2.0.0

obj/Debug/net472/TABSUXMod.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Landfall.TABS;
using LevelCreator;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
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: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace TABSUXMod;

public static class AutoConfirmLoadModsPatch
{
	private static MethodInfo setPermission;

	private static MethodInfo onCheckedPermission;

	public static void Apply(Harmony harmony)
	{
		//IL_0135: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Expected O, but got Unknown
		Assembly assembly = null;
		Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
		foreach (Assembly assembly2 in assemblies)
		{
			if (assembly2.GetName().Name == "Assembly-CSharp")
			{
				assembly = assembly2;
				break;
			}
		}
		if (assembly == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] Assembly-CSharp not found — load-mods auto-confirm skipped.");
			return;
		}
		Type type = assembly.GetType("Landfall.TABS.Workshop.CustomContentLoaderModIO");
		if (type == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] CustomContentLoaderModIO not found — load-mods auto-confirm skipped.");
			return;
		}
		BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.NonPublic;
		PropertyInfo property = type.GetProperty("DidGivePermissionToLoadMods", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		setPermission = ((property != null) ? property.GetSetMethod(nonPublic: true) : null);
		onCheckedPermission = type.GetMethod("OnCheckedPermissionToLoadMods", bindingAttr);
		MethodInfo method = type.GetMethod("CheckPermissionToLoadMods", BindingFlags.Instance | BindingFlags.Public);
		if (setPermission == null || onCheckedPermission == null || method == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] CustomContentLoaderModIO members not found — load-mods auto-confirm skipped.");
			return;
		}
		MethodInfo method2 = typeof(AutoConfirmLoadModsPatch).GetMethod("CheckPermissionPrefix", BindingFlags.Static | BindingFlags.NonPublic);
		harmony.Patch((MethodBase)method, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		Debug.Log((object)"[TABSUXMod] Load-mods warning auto-confirm active.");
	}

	private static bool CheckPermissionPrefix(object __instance, bool refresh, object doneCallback)
	{
		Debug.Log((object)"[TABSUXMod] Auto-confirming 'load mods?' warning.");
		setPermission.Invoke(__instance, new object[1] { true });
		onCheckedPermission.Invoke(__instance, new object[2] { refresh, doneCallback });
		return false;
	}
}
public static class BulkDeletePatch
{
	private static readonly HashSet<UnitBlueprint> selected = new HashSet<UnitBlueprint>();

	private static readonly List<GameObject> overlays = new List<GameObject>();

	private static bool selectMode = false;

	private static Button deleteButton;

	private static TextMeshProUGUI deleteButtonLabel;

	private static MonoBehaviour sideBarInstance;

	private static MethodInfo deleteBCSCMethod;

	private static Type contentTypeFilterType;

	private static Type customContentFilePathsType;

	[HarmonyPostfix]
	[HarmonyPatch(typeof(CustomContentGridBrowser), "OnEnable")]
	public static void OnBrowserOpen(CustomContentGridBrowser __instance)
	{
		ExitSelectMode();
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(CustomContentGridBrowser), "Populate")]
	public static void OnBrowserPopulate(CustomContentGridBrowser __instance)
	{
		EnsureDeleteButton(__instance);
		RefreshDeleteButton();
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(UnitButtonBase), "Setup")]
	public static void OnUnitButtonSetup(UnitButtonBase __instance, UnitBlueprint unit)
	{
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Expected O, but got Unknown
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: 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_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Expected O, but got Unknown
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: 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_0192: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a9: 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)
		//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fd: Expected O, but got Unknown
		//IL_021d: Unknown result type (might be due to invalid IL or missing references)
		//IL_022a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0237: Unknown result type (might be due to invalid IL or missing references)
		//IL_0244: Unknown result type (might be due to invalid IL or missing references)
		//IL_0281: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bb: Expected O, but got Unknown
		//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)unit == (Object)null)
		{
			return;
		}
		GameObject gameObject = ((Component)__instance).gameObject;
		if ((Object)(object)gameObject.transform.Find("BulkSelectOverlay") != (Object)null)
		{
			return;
		}
		GameObject val = new GameObject("BulkSelectOverlay", new Type[1] { typeof(RectTransform) });
		val.transform.SetParent(gameObject.transform, false);
		val.SetActive(selectMode);
		overlays.Add(val);
		RectTransform component = val.GetComponent<RectTransform>();
		component.anchorMin = Vector2.zero;
		component.anchorMax = Vector2.one;
		component.offsetMin = Vector2.zero;
		component.offsetMax = Vector2.zero;
		Image val2 = val.AddComponent<Image>();
		((Graphic)val2).color = new Color(0f, 0f, 0f, 0f);
		Button val3 = val.AddComponent<Button>();
		((Selectable)val3).targetGraphic = (Graphic)(object)val2;
		((Selectable)val3).transition = (Transition)0;
		GameObject val4 = new GameObject("Checkbox", new Type[1] { typeof(RectTransform) });
		val4.transform.SetParent(val.transform, false);
		RectTransform component2 = val4.GetComponent<RectTransform>();
		component2.anchorMin = new Vector2(0f, 1f);
		component2.anchorMax = new Vector2(0f, 1f);
		component2.pivot = new Vector2(0f, 1f);
		component2.anchoredPosition = new Vector2(4f, -4f);
		component2.sizeDelta = new Vector2(28f, 28f);
		Image val5 = val4.AddComponent<Image>();
		((Graphic)val5).color = new Color(0f, 0f, 0f, 0.55f);
		GameObject val6 = new GameObject("Check", new Type[1] { typeof(RectTransform) });
		val6.transform.SetParent(val4.transform, false);
		RectTransform component3 = val6.GetComponent<RectTransform>();
		component3.anchorMin = Vector2.zero;
		component3.anchorMax = Vector2.one;
		component3.offsetMin = Vector2.zero;
		component3.offsetMax = Vector2.zero;
		TextMeshProUGUI val7 = val6.AddComponent<TextMeshProUGUI>();
		((TMP_Text)val7).text = "";
		((TMP_Text)val7).fontSize = 18f;
		((TMP_Text)val7).alignment = (TextAlignmentOptions)514;
		((Graphic)val7).color = Color.white;
		UnitBlueprint capturedUnit = unit;
		TextMeshProUGUI capturedCheck = val7;
		Image capturedBg = val5;
		((UnityEvent)val3.onClick).AddListener((UnityAction)delegate
		{
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			if (selectMode)
			{
				if (selected.Contains(capturedUnit))
				{
					selected.Remove(capturedUnit);
					((TMP_Text)capturedCheck).text = "";
					((Graphic)capturedBg).color = new Color(0f, 0f, 0f, 0.55f);
				}
				else
				{
					selected.Add(capturedUnit);
					((TMP_Text)capturedCheck).text = "✔";
					((Graphic)capturedBg).color = new Color(0.18f, 0.65f, 0.18f, 0.85f);
				}
				RefreshDeleteButton();
			}
		});
		if (selected.Contains(unit))
		{
			((TMP_Text)val7).text = "✔";
			((Graphic)val5).color = new Color(0.18f, 0.65f, 0.18f, 0.85f);
		}
	}

	private static void EnsureDeleteButton(CustomContentGridBrowser browser)
	{
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Expected O, but got Unknown
		//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b5: Expected O, but got Unknown
		//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d1: Expected O, but got Unknown
		//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_0215: Unknown result type (might be due to invalid IL or missing references)
		//IL_0224: Unknown result type (might be due to invalid IL or missing references)
		//IL_022b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0240: Unknown result type (might be due to invalid IL or missing references)
		//IL_0245: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bb: Expected O, but got Unknown
		//IL_02db: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0302: Unknown result type (might be due to invalid IL or missing references)
		//IL_033e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Expected O, but got Unknown
		if ((Object)(object)deleteButton != (Object)null && (Object)(object)((Component)deleteButton).gameObject != (Object)null)
		{
			return;
		}
		CustomContentUnitBrowser componentInChildren = ((Component)browser).GetComponentInChildren<CustomContentUnitBrowser>(true);
		if ((Object)(object)componentInChildren == (Object)null)
		{
			Debug.LogWarning((object)"[TABSUXMod] CustomContentUnitBrowser not found.");
			return;
		}
		object? obj = typeof(CustomContentUnitBrowser).GetField("layout01", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(componentInChildren);
		Component val = (Component)((obj is Component) ? obj : null);
		if ((Object)(object)val == (Object)null)
		{
			Debug.LogWarning((object)"[TABSUXMod] layout01 field not found.");
			return;
		}
		Transform parent = val.transform.parent;
		Button val2 = null;
		foreach (Transform item in parent)
		{
			Transform val3 = item;
			if (((Object)val3).name == "New Unit")
			{
				val2 = ((Component)val3).GetComponent<Button>();
				break;
			}
		}
		if ((Object)(object)val2 == (Object)null)
		{
			Debug.LogWarning((object)"[TABSUXMod] 'New Unit' not found in UnitGrid. Siblings:");
			{
				foreach (Transform item2 in parent)
				{
					Transform val4 = item2;
					Debug.Log((object)("[TABSUXMod] sibling: '" + ((Object)val4).name + "'"));
				}
				return;
			}
		}
		GameObject val5 = Object.Instantiate<GameObject>(((Component)val2).gameObject, parent, false);
		((Object)val5).name = "BulkDeleteBtn";
		deleteButton = val5.GetComponent<Button>();
		deleteButton.onClick = new ButtonClickedEvent();
		((UnityEvent)deleteButton.onClick).AddListener(new UnityAction(OnDeleteButtonClicked));
		RectTransform component = ((Component)val2).GetComponent<RectTransform>();
		RectTransform component2 = val5.GetComponent<RectTransform>();
		component2.anchorMin = component.anchorMin;
		component2.anchorMax = component.anchorMax;
		component2.pivot = component.pivot;
		component2.sizeDelta = component.sizeDelta;
		component2.anchoredPosition = component.anchoredPosition + new Vector2(component.sizeDelta.x + 8f, 0f);
		val5.transform.SetSiblingIndex(((Component)val2).transform.GetSiblingIndex() + 1);
		TextMeshProUGUI[] componentsInChildren = val5.GetComponentsInChildren<TextMeshProUGUI>();
		foreach (TextMeshProUGUI val6 in componentsInChildren)
		{
			Object.Destroy((Object)(object)((Component)val6).gameObject);
		}
		GameObject val7 = new GameObject("Label", new Type[1] { typeof(RectTransform) });
		val7.transform.SetParent(val5.transform, false);
		RectTransform component3 = val7.GetComponent<RectTransform>();
		component3.anchorMin = Vector2.zero;
		component3.anchorMax = Vector2.one;
		component3.offsetMin = Vector2.zero;
		component3.offsetMax = Vector2.zero;
		deleteButtonLabel = val7.AddComponent<TextMeshProUGUI>();
		((TMP_Text)deleteButtonLabel).alignment = (TextAlignmentOptions)514;
		((TMP_Text)deleteButtonLabel).fontSize = 18f;
		((Graphic)deleteButtonLabel).color = Color.white;
		CacheSideBar();
	}

	private static void OnDeleteButtonClicked()
	{
		if (!selectMode)
		{
			selectMode = true;
			SetOverlaysVisible(visible: true);
			RefreshDeleteButton();
		}
		else if (selected.Count > 0)
		{
			DeleteSelected();
		}
		else
		{
			ExitSelectMode();
		}
	}

	private static void ExitSelectMode()
	{
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		selectMode = false;
		selected.Clear();
		SetOverlaysVisible(visible: false);
		foreach (GameObject overlay in overlays)
		{
			if (!((Object)(object)overlay == (Object)null))
			{
				Transform val = overlay.transform.Find("Checkbox");
				Image val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<Image>() : null);
				if ((Object)(object)val2 != (Object)null)
				{
					((Graphic)val2).color = new Color(0f, 0f, 0f, 0.55f);
				}
				TextMeshProUGUI componentInChildren = overlay.GetComponentInChildren<TextMeshProUGUI>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					((TMP_Text)componentInChildren).text = "";
				}
			}
		}
		RefreshDeleteButton();
	}

	private static void SetOverlaysVisible(bool visible)
	{
		overlays.RemoveAll((GameObject o) => (Object)(object)o == (Object)null);
		foreach (GameObject overlay in overlays)
		{
			overlay.SetActive(visible);
		}
	}

	private static void CacheSideBar()
	{
		if ((Object)(object)sideBarInstance != (Object)null)
		{
			return;
		}
		Assembly assembly = typeof(CustomContentGridBrowser).Assembly;
		Type type = assembly.GetType("Landfall.TABS.CustomContentSideBar");
		if (!(type == null))
		{
			Object obj = Object.FindObjectOfType(type);
			sideBarInstance = (MonoBehaviour)(object)((obj is MonoBehaviour) ? obj : null);
			if (!((Object)(object)sideBarInstance == (Object)null))
			{
				deleteBCSCMethod = type.GetMethod("DeleteBattleCreatorSharedCommandsContent", BindingFlags.Instance | BindingFlags.NonPublic);
				contentTypeFilterType = assembly.GetType("Landfall.TABS.Workshop.ContentTypeFilter");
				customContentFilePathsType = assembly.GetType("Landfall.TABS.Workshop.CustomContentFilePaths");
			}
		}
	}

	private static void RefreshDeleteButton()
	{
		if (!((Object)(object)deleteButtonLabel == (Object)null))
		{
			if (!selectMode)
			{
				((TMP_Text)deleteButtonLabel).text = "SELECT TO DELETE";
				((Selectable)deleteButton).interactable = true;
			}
			else if (selected.Count == 0)
			{
				((TMP_Text)deleteButtonLabel).text = "CANCEL";
				((Selectable)deleteButton).interactable = true;
			}
			else
			{
				((TMP_Text)deleteButtonLabel).text = $"DELETE ({selected.Count})";
				((Selectable)deleteButton).interactable = true;
			}
		}
	}

	private static void DeleteSelected()
	{
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		if (selected.Count == 0)
		{
			return;
		}
		CacheSideBar();
		if ((Object)(object)sideBarInstance == (Object)null || deleteBCSCMethod == null || contentTypeFilterType == null || customContentFilePathsType == null)
		{
			Debug.LogError((object)"[TABSUXMod] Could not resolve deletion methods via reflection.");
			return;
		}
		object obj = Enum.ToObject(contentTypeFilterType, 4);
		PropertyInfo property = customContentFilePathsType.GetProperty("UnitDirectoryPath", BindingFlags.Static | BindingFlags.Public);
		if (property == null)
		{
			Debug.LogError((object)"[TABSUXMod] UnitDirectoryPath property not found.");
			return;
		}
		string text = (string)property.GetValue(null);
		foreach (UnitBlueprint item in selected)
		{
			string text2 = text + ((object)item.Entity.GUID/*cast due to .constrained prefix*/).ToString();
			deleteBCSCMethod.Invoke(sideBarInstance, new object[3] { obj, item, text2 });
		}
		ExitSelectMode();
		CustomContentGridBrowser obj2 = Object.FindObjectOfType<CustomContentGridBrowser>();
		if (obj2 != null)
		{
			obj2.Refresh();
		}
	}
}
public static class DoubleClickPlayMapPatch
{
	private const float DoubleClickWindow = 0.4f;

	private static CustomMap lastClickedMap;

	private static float lastClickTime = -1f;

	[HarmonyPostfix]
	[HarmonyPatch(typeof(CustomContentLevelButton), "OnPointerClick")]
	public static void OnLevelButtonPointerClick(CustomContentLevelButton __instance, PointerEventData eventData)
	{
		lastClickedMap = __instance.customMap;
		lastClickTime = Time.unscaledTime;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(FactionCreatorFadeBG), "OnPointerClick")]
	public static bool OnFadePointerClick(FactionCreatorFadeBG __instance)
	{
		if ((Object)(object)lastClickedMap == (Object)null)
		{
			return true;
		}
		if (Time.unscaledTime - lastClickTime > 0.4f)
		{
			return true;
		}
		CustomContentSideBar sidebar = __instance.sidebar;
		if ((Object)(object)sidebar == (Object)null || (Object)(object)sidebar.levelParent == (Object)null || !sidebar.levelParent.activeSelf)
		{
			return true;
		}
		lastClickedMap = null;
		lastClickTime = -1f;
		sidebar.Play();
		return false;
	}
}
[BepInPlugin("joshbaier.tabsuxmod", "Better UX", "1.0.0")]
public class Launcher : 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
		Harmony val = new Harmony("joshbaier.tabsuxmod");
		val.PatchAll(typeof(BulkDeletePatch));
		val.PatchAll(typeof(DoubleClickPlayMapPatch));
		SuppressLaunchInvitePatch.Apply(val);
		AutoConfirmLoadModsPatch.Apply(val);
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Better UX loaded.");
	}
}
public static class SuppressLaunchInvitePatch
{
	private static bool declinedFirstInvite;

	public static void Apply(Harmony harmony)
	{
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Expected O, but got Unknown
		Assembly assembly = null;
		Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
		foreach (Assembly assembly2 in assemblies)
		{
			if (assembly2.GetName().Name == "Assembly-CSharp")
			{
				assembly = assembly2;
				break;
			}
		}
		if (assembly == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] Assembly-CSharp not found — launch invite suppression skipped.");
			return;
		}
		Type type = assembly.GetType("TFBGames.SocialProfileService");
		if (type == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] SocialProfileService not found — launch invite suppression skipped.");
			return;
		}
		MethodInfo method = type.GetMethod("SetState", BindingFlags.Instance | BindingFlags.NonPublic);
		if (method == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] SocialProfileService.SetState not found — launch invite suppression skipped.");
			return;
		}
		MethodInfo method2 = typeof(SuppressLaunchInvitePatch).GetMethod("SetStatePrefix", BindingFlags.Static | BindingFlags.NonPublic);
		harmony.Patch((MethodBase)method, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		Debug.Log((object)"[TABSUXMod] Launch invite suppression active (first invite of the session will be auto-declined).");
	}

	private static bool SetStatePrefix(ref object __0)
	{
		if (declinedFirstInvite)
		{
			return true;
		}
		int num = Convert.ToInt32(__0);
		if (num == 1 || num == 2)
		{
			declinedFirstInvite = true;
			Debug.Log((object)("[TABSUXMod] Auto-declined spurious launch invite (redirected SetState(" + num + ") to Idle). Later invites are untouched."));
			__0 = Enum.ToObject(__0.GetType(), 0);
		}
		return true;
	}
}

obj/Release/net472/TABSUXMod.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using DM;
using HarmonyLib;
using Landfall.TABS;
using Landfall.TABS.UnitEditor;
using LevelCreator;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace TABSUXMod;

public static class AllUnitBasesPatch
{
	private static FieldInfo s_nonStreamableAssetsField;

	private static Dictionary<DatabaseID, GameObject> s_rigsByGuid;

	private static int s_rigsBuiltFromCount = -1;

	private static bool s_resolving;

	[HarmonyPrefix]
	[HarmonyPatch(typeof(UnitEditorManager), "Start")]
	public static void BeforeUnitEditorStart(UnitEditorManager __instance)
	{
		Debug.Log((object)"[TABSUXMod] UnitEditorManager.Start prefix fired.");
		try
		{
			Inject(__instance);
		}
		catch (Exception ex)
		{
			Debug.LogError((object)("[TABSUXMod] Failed to add unit bases to the Unit Creator: " + ex));
		}
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(UnitEditorUnitBaseGrid), "SpawnUnitBaseButtons")]
	public static void BeforeSpawnUnitBaseButtons(ref UnitBaseWrapper[] unitBaseWrappers, UnitEditorManager unitEditorManager)
	{
		Debug.Log((object)("[TABSUXMod] SpawnUnitBaseButtons prefix fired with " + ((unitBaseWrappers != null) ? unitBaseWrappers.Length : (-1)) + " wrappers."));
		try
		{
			if (!((Object)(object)unitEditorManager == (Object)null))
			{
				Inject(unitEditorManager);
				unitBaseWrappers = unitEditorManager.UnitBases;
			}
		}
		catch (Exception ex)
		{
			Debug.LogError((object)("[TABSUXMod] Failed to add unit bases to the Unit Creator: " + ex));
		}
	}

	private static void Inject(UnitEditorManager manager)
	{
		//IL_020a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0211: Expected O, but got Unknown
		//IL_0232: Unknown result type (might be due to invalid IL or missing references)
		//IL_0237: Unknown result type (might be due to invalid IL or missing references)
		//IL_023f: 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_0253: Unknown result type (might be due to invalid IL or missing references)
		//IL_025a: Expected O, but got Unknown
		List<UnitBaseWrapper> list = new List<UnitBaseWrapper>(manager.UnitBases);
		if (list.Count == 0)
		{
			Debug.LogWarning((object)"[TABSUXMod] UnitBases is empty; nothing to use as a template, skipping.");
			return;
		}
		UnitBlueprint unitBaseBlueprint = list[0].UnitBaseBlueprint;
		if ((Object)(object)unitBaseBlueprint == (Object)null)
		{
			Debug.LogWarning((object)"[TABSUXMod] UnitBases[0] has no blueprint to use as a template, skipping.");
			return;
		}
		HashSet<GameObject> hashSet = new HashSet<GameObject>();
		foreach (UnitBaseWrapper item in list)
		{
			if (item != null && (Object)(object)item.UnitBaseBlueprint != (Object)null && (Object)(object)item.UnitBaseBlueprint.UnitBase != (Object)null)
			{
				hashSet.Add(item.UnitBaseBlueprint.UnitBase);
			}
		}
		ContentDatabase val = ContentDatabase.Instance();
		List<GameObject> list2 = new List<GameObject>();
		Dictionary<GameObject, UnitBlueprint> dictionary = new Dictionary<GameObject, UnitBlueprint>();
		foreach (GameObject allUnitBasis in val.GetAllUnitBases())
		{
			if ((Object)(object)allUnitBasis != (Object)null)
			{
				list2.Add(allUnitBasis);
			}
		}
		int count = list2.Count;
		foreach (UnitBlueprint allUnitBlueprint in val.GetAllUnitBlueprints())
		{
			if ((Object)(object)allUnitBlueprint == (Object)null)
			{
				continue;
			}
			GameObject unitBase;
			try
			{
				unitBase = allUnitBlueprint.UnitBase;
			}
			catch
			{
				continue;
			}
			if (!((Object)(object)unitBase == (Object)null))
			{
				list2.Add(unitBase);
				if (!dictionary.ContainsKey(unitBase))
				{
					dictionary[unitBase] = allUnitBlueprint;
				}
			}
		}
		int num = 0;
		List<UnitBaseWrapper> list3 = new List<UnitBaseWrapper>();
		foreach (GameObject item2 in list2)
		{
			if (hashSet.Add(item2))
			{
				Unit component = item2.GetComponent<Unit>();
				if ((Object)(object)component == (Object)null || component.Entity == null)
				{
					num++;
					continue;
				}
				if ((Object)(object)item2.GetComponentInChildren<Torso>(true) == (Object)null || (Object)(object)item2.GetComponentInChildren<HealthHandler>(true) == (Object)null || (Object)(object)item2.GetComponentInChildren<RigidbodyHolder>(true) == (Object)null)
				{
					num++;
					continue;
				}
				UnitBlueprint val2 = new UnitBlueprint(unitBaseBlueprint);
				val2.UnitBase = item2;
				val2.Entity.Name = component.Entity.Name;
				UnitBaseWrapper val3 = new UnitBaseWrapper
				{
					UnitBaseBlueprint = val2,
					BaseDisplayName = component.Entity.Name,
					UnitBaseRestriction = (UnitBaseRestrictions)0
				};
				dictionary.TryGetValue(item2, out var value);
				LoadIcon(val3, component.Entity, value);
				list3.Add(val3);
			}
		}
		list3.Sort((UnitBaseWrapper a, UnitBaseWrapper b) => string.Compare(a.BaseDisplayName, b.BaseDisplayName, StringComparison.OrdinalIgnoreCase));
		list.AddRange(list3);
		manager.UnitBases = list.ToArray();
		int num2 = 0;
		foreach (UnitBaseWrapper item3 in list)
		{
			GameObject val4 = ((item3 != null && (Object)(object)item3.UnitBaseBlueprint != (Object)null) ? item3.UnitBaseBlueprint.UnitBase : null);
			if ((Object)(object)val4 != (Object)null && RegisterRig(val, val4))
			{
				num2++;
			}
		}
		Debug.Log((object)("[TABSUXMod] Added " + list3.Count + " unit bases to the Unit Creator (" + list.Count + " total; " + count + " registered rigs, " + (list2.Count - count) + " blueprint rigs, " + num + " skipped as unusable, " + num2 + " rigs newly registered in AssetLoader)."));
	}

	private static bool RegisterRig(ContentDatabase db, GameObject rig)
	{
		//IL_005f: 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)
		Unit component = rig.GetComponent<Unit>();
		if ((Object)(object)component == (Object)null || component.Entity == null)
		{
			return false;
		}
		if (s_nonStreamableAssetsField == null)
		{
			s_nonStreamableAssetsField = typeof(AssetLoader).GetField("m_nonStreamableAssets", BindingFlags.Instance | BindingFlags.NonPublic);
		}
		Dictionary<DatabaseID, Object> dictionary = (Dictionary<DatabaseID, Object>)s_nonStreamableAssetsField.GetValue(db.AssetLoader);
		if (dictionary.ContainsKey(component.Entity.GUID))
		{
			return false;
		}
		dictionary.Add(component.Entity.GUID, (Object)(object)rig);
		return true;
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(ContentDatabase), "GetGameObject")]
	public unsafe static void AfterGetGameObject(DatabaseID databaseId, ref GameObject __result)
	{
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)__result != (Object)null || s_resolving)
		{
			return;
		}
		try
		{
			s_resolving = true;
			ContentDatabase val = ContentDatabase.Instance();
			List<UnitBlueprint> list = new List<UnitBlueprint>(val.GetAllUnitBlueprints());
			if (s_rigsByGuid == null || list.Count != s_rigsBuiltFromCount)
			{
				Dictionary<DatabaseID, GameObject> dictionary = new Dictionary<DatabaseID, GameObject>();
				foreach (UnitBlueprint item in list)
				{
					if ((Object)(object)item == (Object)null)
					{
						continue;
					}
					GameObject unitBase;
					try
					{
						unitBase = item.UnitBase;
					}
					catch
					{
						continue;
					}
					if (!((Object)(object)unitBase == (Object)null))
					{
						Unit component = unitBase.GetComponent<Unit>();
						if ((Object)(object)component != (Object)null && component.Entity != null && !dictionary.ContainsKey(component.Entity.GUID))
						{
							dictionary[component.Entity.GUID] = unitBase;
						}
					}
				}
				s_rigsByGuid = dictionary;
				s_rigsBuiltFromCount = list.Count;
			}
			if (s_rigsByGuid.TryGetValue(databaseId, out var value))
			{
				RegisterRig(val, value);
				__result = value;
				string[] obj2 = new string[5]
				{
					"[TABSUXMod] Resolved unit base '",
					((Object)value).name,
					"' (",
					null,
					null
				};
				DatabaseID val2 = databaseId;
				obj2[3] = ((object)(*(DatabaseID*)(&val2))/*cast due to .constrained prefix*/).ToString();
				obj2[4] = ") via blueprint fallback.";
				Debug.Log((object)string.Concat(obj2));
			}
		}
		catch (Exception ex)
		{
			Debug.LogError((object)("[TABSUXMod] GetGameObject fallback failed: " + ex));
		}
		finally
		{
			s_resolving = false;
		}
	}

	private static void LoadIcon(UnitBaseWrapper wrapper, DatabaseEntity rigEntity, UnitBlueprint fallback)
	{
		rigEntity.GetSpriteIconAsync((Action<Sprite>)delegate(Sprite sprite)
		{
			if ((Object)(object)sprite != (Object)null)
			{
				wrapper.BaseIcon = sprite;
			}
			else if ((Object)(object)fallback != (Object)null && fallback.Entity != null)
			{
				fallback.Entity.GetSpriteIconAsync((Action<Sprite>)delegate(Sprite fallbackSprite)
				{
					wrapper.BaseIcon = fallbackSprite;
				});
			}
		});
	}
}
public static class AutoConfirmLoadModsPatch
{
	private static MethodInfo setPermission;

	private static MethodInfo onCheckedPermission;

	public static void Apply(Harmony harmony)
	{
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Expected O, but got Unknown
		Assembly assembly = null;
		Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
		foreach (Assembly assembly2 in assemblies)
		{
			if (assembly2.GetName().Name == "Assembly-CSharp")
			{
				assembly = assembly2;
				break;
			}
		}
		if (assembly == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] Assembly-CSharp not found — load-mods auto-confirm skipped.");
			return;
		}
		Type type = assembly.GetType("Landfall.TABS.Workshop.CustomContentLoaderModIO");
		if (type == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] CustomContentLoaderModIO not found — load-mods auto-confirm skipped.");
			return;
		}
		BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.NonPublic;
		PropertyInfo property = type.GetProperty("DidGivePermissionToLoadMods", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		setPermission = ((property != null) ? property.GetSetMethod(nonPublic: true) : null);
		onCheckedPermission = type.GetMethod("OnCheckedPermissionToLoadMods", bindingAttr);
		MethodInfo method = type.GetMethod("CheckPermissionToLoadMods", BindingFlags.Instance | BindingFlags.Public);
		if (setPermission == null || onCheckedPermission == null || method == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] CustomContentLoaderModIO members not found — load-mods auto-confirm skipped.");
			return;
		}
		MethodInfo method2 = typeof(AutoConfirmLoadModsPatch).GetMethod("CheckPermissionPrefix", BindingFlags.Static | BindingFlags.NonPublic);
		harmony.Patch((MethodBase)method, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		Debug.Log((object)"[TABSUXMod] Load-mods warning auto-confirm active.");
	}

	private static bool CheckPermissionPrefix(object __instance, bool refresh, object doneCallback)
	{
		Debug.Log((object)"[TABSUXMod] Auto-confirming 'load mods?' warning.");
		setPermission.Invoke(__instance, new object[1] { true });
		onCheckedPermission.Invoke(__instance, new object[2] { refresh, doneCallback });
		return false;
	}
}
public static class BulkDeletePatch
{
	private static readonly HashSet<UnitBlueprint> selected = new HashSet<UnitBlueprint>();

	private static readonly List<GameObject> overlays = new List<GameObject>();

	private static bool selectMode = false;

	private static Button deleteButton;

	private static TextMeshProUGUI deleteButtonLabel;

	private static MonoBehaviour sideBarInstance;

	private static MethodInfo deleteBCSCMethod;

	private static Type contentTypeFilterType;

	private static Type customContentFilePathsType;

	[HarmonyPostfix]
	[HarmonyPatch(typeof(CustomContentGridBrowser), "OnEnable")]
	public static void OnBrowserOpen(CustomContentGridBrowser __instance)
	{
		ExitSelectMode();
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(CustomContentGridBrowser), "Populate")]
	public static void OnBrowserPopulate(CustomContentGridBrowser __instance)
	{
		EnsureDeleteButton(__instance);
		RefreshDeleteButton();
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(UnitButtonBase), "Setup")]
	public static void OnUnitButtonSetup(UnitButtonBase __instance, UnitBlueprint unit)
	{
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Expected O, but got Unknown
		//IL_007d: 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_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Expected O, but got Unknown
		//IL_0129: 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_0153: 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)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01df: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_026c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0276: Expected O, but got Unknown
		//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)unit == (Object)null)
		{
			return;
		}
		GameObject gameObject = ((Component)__instance).gameObject;
		if ((Object)(object)gameObject.transform.Find("BulkSelectOverlay") != (Object)null)
		{
			return;
		}
		GameObject val = new GameObject("BulkSelectOverlay", new Type[1] { typeof(RectTransform) });
		val.transform.SetParent(gameObject.transform, false);
		val.SetActive(selectMode);
		overlays.Add(val);
		RectTransform component = val.GetComponent<RectTransform>();
		component.anchorMin = Vector2.zero;
		component.anchorMax = Vector2.one;
		component.offsetMin = Vector2.zero;
		component.offsetMax = Vector2.zero;
		Image val2 = val.AddComponent<Image>();
		((Graphic)val2).color = new Color(0f, 0f, 0f, 0f);
		Button val3 = val.AddComponent<Button>();
		((Selectable)val3).targetGraphic = (Graphic)(object)val2;
		((Selectable)val3).transition = (Transition)0;
		GameObject val4 = new GameObject("Checkbox", new Type[1] { typeof(RectTransform) });
		val4.transform.SetParent(val.transform, false);
		RectTransform component2 = val4.GetComponent<RectTransform>();
		component2.anchorMin = new Vector2(0f, 1f);
		component2.anchorMax = new Vector2(0f, 1f);
		component2.pivot = new Vector2(0f, 1f);
		component2.anchoredPosition = new Vector2(4f, -4f);
		component2.sizeDelta = new Vector2(28f, 28f);
		Image val5 = val4.AddComponent<Image>();
		((Graphic)val5).color = new Color(0f, 0f, 0f, 0.55f);
		GameObject val6 = new GameObject("Check", new Type[1] { typeof(RectTransform) });
		val6.transform.SetParent(val4.transform, false);
		RectTransform component3 = val6.GetComponent<RectTransform>();
		component3.anchorMin = Vector2.zero;
		component3.anchorMax = Vector2.one;
		component3.offsetMin = Vector2.zero;
		component3.offsetMax = Vector2.zero;
		TextMeshProUGUI val7 = val6.AddComponent<TextMeshProUGUI>();
		((TMP_Text)val7).text = "";
		((TMP_Text)val7).fontSize = 18f;
		((TMP_Text)val7).alignment = (TextAlignmentOptions)514;
		((Graphic)val7).color = Color.white;
		UnitBlueprint capturedUnit = unit;
		TextMeshProUGUI capturedCheck = val7;
		Image capturedBg = val5;
		((UnityEvent)val3.onClick).AddListener((UnityAction)delegate
		{
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			if (selectMode)
			{
				if (selected.Contains(capturedUnit))
				{
					selected.Remove(capturedUnit);
					((TMP_Text)capturedCheck).text = "";
					((Graphic)capturedBg).color = new Color(0f, 0f, 0f, 0.55f);
				}
				else
				{
					selected.Add(capturedUnit);
					((TMP_Text)capturedCheck).text = "✔";
					((Graphic)capturedBg).color = new Color(0.18f, 0.65f, 0.18f, 0.85f);
				}
				RefreshDeleteButton();
			}
		});
		if (selected.Contains(unit))
		{
			((TMP_Text)val7).text = "✔";
			((Graphic)val5).color = new Color(0.18f, 0.65f, 0.18f, 0.85f);
		}
	}

	private static void EnsureDeleteButton(CustomContentGridBrowser browser)
	{
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Expected O, but got Unknown
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Expected O, but got Unknown
		//IL_018a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Expected O, but got Unknown
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0260: Unknown result type (might be due to invalid IL or missing references)
		//IL_0265: Unknown result type (might be due to invalid IL or missing references)
		//IL_0278: Unknown result type (might be due to invalid IL or missing references)
		//IL_027f: Unknown result type (might be due to invalid IL or missing references)
		//IL_028a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0295: Unknown result type (might be due to invalid IL or missing references)
		//IL_029f: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d6: 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_0107: Expected O, but got Unknown
		if ((Object)(object)deleteButton != (Object)null && (Object)(object)((Component)deleteButton).gameObject != (Object)null)
		{
			return;
		}
		CustomContentUnitBrowser componentInChildren = ((Component)browser).GetComponentInChildren<CustomContentUnitBrowser>(true);
		if ((Object)(object)componentInChildren == (Object)null)
		{
			Debug.LogWarning((object)"[TABSUXMod] CustomContentUnitBrowser not found.");
			return;
		}
		object? obj = typeof(CustomContentUnitBrowser).GetField("layout01", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(componentInChildren);
		Component val = (Component)((obj is Component) ? obj : null);
		if ((Object)(object)val == (Object)null)
		{
			Debug.LogWarning((object)"[TABSUXMod] layout01 field not found.");
			return;
		}
		Transform parent = val.transform.parent;
		Button val2 = null;
		foreach (Transform item in parent)
		{
			Transform val3 = item;
			if (((Object)val3).name == "New Unit")
			{
				val2 = ((Component)val3).GetComponent<Button>();
				break;
			}
		}
		if ((Object)(object)val2 == (Object)null)
		{
			Debug.LogWarning((object)"[TABSUXMod] 'New Unit' not found in UnitGrid. Siblings:");
			{
				foreach (Transform item2 in parent)
				{
					Transform val4 = item2;
					Debug.Log((object)("[TABSUXMod] sibling: '" + ((Object)val4).name + "'"));
				}
				return;
			}
		}
		GameObject val5 = Object.Instantiate<GameObject>(((Component)val2).gameObject, parent, false);
		((Object)val5).name = "BulkDeleteBtn";
		deleteButton = val5.GetComponent<Button>();
		deleteButton.onClick = new ButtonClickedEvent();
		((UnityEvent)deleteButton.onClick).AddListener(new UnityAction(OnDeleteButtonClicked));
		RectTransform component = ((Component)val2).GetComponent<RectTransform>();
		RectTransform component2 = val5.GetComponent<RectTransform>();
		component2.anchorMin = component.anchorMin;
		component2.anchorMax = component.anchorMax;
		component2.pivot = component.pivot;
		component2.sizeDelta = component.sizeDelta;
		component2.anchoredPosition = component.anchoredPosition + new Vector2(component.sizeDelta.x + 8f, 0f);
		val5.transform.SetSiblingIndex(((Component)val2).transform.GetSiblingIndex() + 1);
		TextMeshProUGUI[] componentsInChildren = val5.GetComponentsInChildren<TextMeshProUGUI>();
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			Object.Destroy((Object)(object)((Component)componentsInChildren[i]).gameObject);
		}
		GameObject val6 = new GameObject("Label", new Type[1] { typeof(RectTransform) });
		val6.transform.SetParent(val5.transform, false);
		RectTransform component3 = val6.GetComponent<RectTransform>();
		component3.anchorMin = Vector2.zero;
		component3.anchorMax = Vector2.one;
		component3.offsetMin = Vector2.zero;
		component3.offsetMax = Vector2.zero;
		deleteButtonLabel = val6.AddComponent<TextMeshProUGUI>();
		((TMP_Text)deleteButtonLabel).alignment = (TextAlignmentOptions)514;
		((TMP_Text)deleteButtonLabel).fontSize = 18f;
		((Graphic)deleteButtonLabel).color = Color.white;
		CacheSideBar();
	}

	private static void OnDeleteButtonClicked()
	{
		if (!selectMode)
		{
			selectMode = true;
			SetOverlaysVisible(visible: true);
			RefreshDeleteButton();
		}
		else if (selected.Count > 0)
		{
			DeleteSelected();
		}
		else
		{
			ExitSelectMode();
		}
	}

	private static void ExitSelectMode()
	{
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		selectMode = false;
		selected.Clear();
		SetOverlaysVisible(visible: false);
		foreach (GameObject overlay in overlays)
		{
			if (!((Object)(object)overlay == (Object)null))
			{
				Transform val = overlay.transform.Find("Checkbox");
				Image val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<Image>() : null);
				if ((Object)(object)val2 != (Object)null)
				{
					((Graphic)val2).color = new Color(0f, 0f, 0f, 0.55f);
				}
				TextMeshProUGUI componentInChildren = overlay.GetComponentInChildren<TextMeshProUGUI>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					((TMP_Text)componentInChildren).text = "";
				}
			}
		}
		RefreshDeleteButton();
	}

	private static void SetOverlaysVisible(bool visible)
	{
		overlays.RemoveAll((GameObject o) => (Object)(object)o == (Object)null);
		foreach (GameObject overlay in overlays)
		{
			overlay.SetActive(visible);
		}
	}

	private static void CacheSideBar()
	{
		if ((Object)(object)sideBarInstance != (Object)null)
		{
			return;
		}
		Assembly assembly = typeof(CustomContentGridBrowser).Assembly;
		Type type = assembly.GetType("Landfall.TABS.CustomContentSideBar");
		if (!(type == null))
		{
			Object obj = Object.FindObjectOfType(type);
			sideBarInstance = (MonoBehaviour)(object)((obj is MonoBehaviour) ? obj : null);
			if (!((Object)(object)sideBarInstance == (Object)null))
			{
				deleteBCSCMethod = type.GetMethod("DeleteBattleCreatorSharedCommandsContent", BindingFlags.Instance | BindingFlags.NonPublic);
				contentTypeFilterType = assembly.GetType("Landfall.TABS.Workshop.ContentTypeFilter");
				customContentFilePathsType = assembly.GetType("Landfall.TABS.Workshop.CustomContentFilePaths");
			}
		}
	}

	private static void RefreshDeleteButton()
	{
		if (!((Object)(object)deleteButtonLabel == (Object)null))
		{
			if (!selectMode)
			{
				((TMP_Text)deleteButtonLabel).text = "SELECT TO DELETE";
				((Selectable)deleteButton).interactable = true;
			}
			else if (selected.Count == 0)
			{
				((TMP_Text)deleteButtonLabel).text = "CANCEL";
				((Selectable)deleteButton).interactable = true;
			}
			else
			{
				((TMP_Text)deleteButtonLabel).text = $"DELETE ({selected.Count})";
				((Selectable)deleteButton).interactable = true;
			}
		}
	}

	private static void DeleteSelected()
	{
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		if (selected.Count == 0)
		{
			return;
		}
		CacheSideBar();
		if ((Object)(object)sideBarInstance == (Object)null || deleteBCSCMethod == null || contentTypeFilterType == null || customContentFilePathsType == null)
		{
			Debug.LogError((object)"[TABSUXMod] Could not resolve deletion methods via reflection.");
			return;
		}
		object obj = Enum.ToObject(contentTypeFilterType, 4);
		PropertyInfo property = customContentFilePathsType.GetProperty("UnitDirectoryPath", BindingFlags.Static | BindingFlags.Public);
		if (property == null)
		{
			Debug.LogError((object)"[TABSUXMod] UnitDirectoryPath property not found.");
			return;
		}
		string text = (string)property.GetValue(null);
		foreach (UnitBlueprint item in selected)
		{
			string text2 = text + ((object)item.Entity.GUID/*cast due to .constrained prefix*/).ToString();
			deleteBCSCMethod.Invoke(sideBarInstance, new object[3] { obj, item, text2 });
		}
		ExitSelectMode();
		CustomContentGridBrowser obj2 = Object.FindObjectOfType<CustomContentGridBrowser>();
		if (obj2 != null)
		{
			obj2.Refresh();
		}
	}
}
public static class DoubleClickPlayMapPatch
{
	private const float DoubleClickWindow = 0.4f;

	private static CustomMap lastClickedMap;

	private static float lastClickTime = -1f;

	[HarmonyPostfix]
	[HarmonyPatch(typeof(CustomContentLevelButton), "OnPointerClick")]
	public static void OnLevelButtonPointerClick(CustomContentLevelButton __instance, PointerEventData eventData)
	{
		lastClickedMap = __instance.customMap;
		lastClickTime = Time.unscaledTime;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(FactionCreatorFadeBG), "OnPointerClick")]
	public static bool OnFadePointerClick(FactionCreatorFadeBG __instance)
	{
		if ((Object)(object)lastClickedMap == (Object)null)
		{
			return true;
		}
		if (Time.unscaledTime - lastClickTime > 0.4f)
		{
			return true;
		}
		CustomContentSideBar sidebar = __instance.sidebar;
		if ((Object)(object)sidebar == (Object)null || (Object)(object)sidebar.levelParent == (Object)null || !sidebar.levelParent.activeSelf)
		{
			return true;
		}
		lastClickedMap = null;
		lastClickTime = -1f;
		sidebar.Play();
		return false;
	}
}
[BepInPlugin("joshbaier.tabsuxmod", "Better UX", "1.1.2")]
public class Launcher : BaseUnityPlugin
{
	private void Awake()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: 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_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Expected O, but got Unknown
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Expected O, but got Unknown
		Harmony val = new Harmony("joshbaier.tabsuxmod");
		val.PatchAll(typeof(BulkDeletePatch));
		val.PatchAll(typeof(DoubleClickPlayMapPatch));
		val.PatchAll(typeof(AllUnitBasesPatch));
		SuppressLaunchInvitePatch.Apply(val);
		AutoConfirmLoadModsPatch.Apply(val);
		foreach (MethodBase patchedMethod in val.GetPatchedMethods())
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Patched: " + patchedMethod.DeclaringType?.Name + "." + patchedMethod.Name));
		}
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Better UX loaded.");
	}
}
public static class SuppressLaunchInvitePatch
{
	private static bool declinedFirstInvite;

	public static void Apply(Harmony harmony)
	{
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Expected O, but got Unknown
		Assembly assembly = null;
		Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
		foreach (Assembly assembly2 in assemblies)
		{
			if (assembly2.GetName().Name == "Assembly-CSharp")
			{
				assembly = assembly2;
				break;
			}
		}
		if (assembly == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] Assembly-CSharp not found — launch invite suppression skipped.");
			return;
		}
		Type type = assembly.GetType("TFBGames.SocialProfileService");
		if (type == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] SocialProfileService not found — launch invite suppression skipped.");
			return;
		}
		MethodInfo method = type.GetMethod("SetState", BindingFlags.Instance | BindingFlags.NonPublic);
		if (method == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] SocialProfileService.SetState not found — launch invite suppression skipped.");
			return;
		}
		MethodInfo method2 = typeof(SuppressLaunchInvitePatch).GetMethod("SetStatePrefix", BindingFlags.Static | BindingFlags.NonPublic);
		harmony.Patch((MethodBase)method, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		Debug.Log((object)"[TABSUXMod] Launch invite suppression active (first invite of the session will be auto-declined).");
	}

	private static bool SetStatePrefix(ref object __0)
	{
		if (declinedFirstInvite)
		{
			return true;
		}
		int num = Convert.ToInt32(__0);
		if (num == 1 || num == 2)
		{
			declinedFirstInvite = true;
			Debug.Log((object)("[TABSUXMod] Auto-declined spurious launch invite (redirected SetState(" + num + ") to Idle). Later invites are untouched."));
			__0 = Enum.ToObject(__0.GetType(), 0);
		}
		return true;
	}
}

bin/Debug/net472/TABSUXMod.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Landfall.TABS;
using LevelCreator;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
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: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace TABSUXMod;

public static class AutoConfirmLoadModsPatch
{
	private static MethodInfo setPermission;

	private static MethodInfo onCheckedPermission;

	public static void Apply(Harmony harmony)
	{
		//IL_0135: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Expected O, but got Unknown
		Assembly assembly = null;
		Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
		foreach (Assembly assembly2 in assemblies)
		{
			if (assembly2.GetName().Name == "Assembly-CSharp")
			{
				assembly = assembly2;
				break;
			}
		}
		if (assembly == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] Assembly-CSharp not found — load-mods auto-confirm skipped.");
			return;
		}
		Type type = assembly.GetType("Landfall.TABS.Workshop.CustomContentLoaderModIO");
		if (type == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] CustomContentLoaderModIO not found — load-mods auto-confirm skipped.");
			return;
		}
		BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.NonPublic;
		PropertyInfo property = type.GetProperty("DidGivePermissionToLoadMods", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		setPermission = ((property != null) ? property.GetSetMethod(nonPublic: true) : null);
		onCheckedPermission = type.GetMethod("OnCheckedPermissionToLoadMods", bindingAttr);
		MethodInfo method = type.GetMethod("CheckPermissionToLoadMods", BindingFlags.Instance | BindingFlags.Public);
		if (setPermission == null || onCheckedPermission == null || method == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] CustomContentLoaderModIO members not found — load-mods auto-confirm skipped.");
			return;
		}
		MethodInfo method2 = typeof(AutoConfirmLoadModsPatch).GetMethod("CheckPermissionPrefix", BindingFlags.Static | BindingFlags.NonPublic);
		harmony.Patch((MethodBase)method, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		Debug.Log((object)"[TABSUXMod] Load-mods warning auto-confirm active.");
	}

	private static bool CheckPermissionPrefix(object __instance, bool refresh, object doneCallback)
	{
		Debug.Log((object)"[TABSUXMod] Auto-confirming 'load mods?' warning.");
		setPermission.Invoke(__instance, new object[1] { true });
		onCheckedPermission.Invoke(__instance, new object[2] { refresh, doneCallback });
		return false;
	}
}
public static class BulkDeletePatch
{
	private static readonly HashSet<UnitBlueprint> selected = new HashSet<UnitBlueprint>();

	private static readonly List<GameObject> overlays = new List<GameObject>();

	private static bool selectMode = false;

	private static Button deleteButton;

	private static TextMeshProUGUI deleteButtonLabel;

	private static MonoBehaviour sideBarInstance;

	private static MethodInfo deleteBCSCMethod;

	private static Type contentTypeFilterType;

	private static Type customContentFilePathsType;

	[HarmonyPostfix]
	[HarmonyPatch(typeof(CustomContentGridBrowser), "OnEnable")]
	public static void OnBrowserOpen(CustomContentGridBrowser __instance)
	{
		ExitSelectMode();
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(CustomContentGridBrowser), "Populate")]
	public static void OnBrowserPopulate(CustomContentGridBrowser __instance)
	{
		EnsureDeleteButton(__instance);
		RefreshDeleteButton();
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(UnitButtonBase), "Setup")]
	public static void OnUnitButtonSetup(UnitButtonBase __instance, UnitBlueprint unit)
	{
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Expected O, but got Unknown
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: 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_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Expected O, but got Unknown
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: 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_0192: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a9: 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)
		//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fd: Expected O, but got Unknown
		//IL_021d: Unknown result type (might be due to invalid IL or missing references)
		//IL_022a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0237: Unknown result type (might be due to invalid IL or missing references)
		//IL_0244: Unknown result type (might be due to invalid IL or missing references)
		//IL_0281: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bb: Expected O, but got Unknown
		//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)unit == (Object)null)
		{
			return;
		}
		GameObject gameObject = ((Component)__instance).gameObject;
		if ((Object)(object)gameObject.transform.Find("BulkSelectOverlay") != (Object)null)
		{
			return;
		}
		GameObject val = new GameObject("BulkSelectOverlay", new Type[1] { typeof(RectTransform) });
		val.transform.SetParent(gameObject.transform, false);
		val.SetActive(selectMode);
		overlays.Add(val);
		RectTransform component = val.GetComponent<RectTransform>();
		component.anchorMin = Vector2.zero;
		component.anchorMax = Vector2.one;
		component.offsetMin = Vector2.zero;
		component.offsetMax = Vector2.zero;
		Image val2 = val.AddComponent<Image>();
		((Graphic)val2).color = new Color(0f, 0f, 0f, 0f);
		Button val3 = val.AddComponent<Button>();
		((Selectable)val3).targetGraphic = (Graphic)(object)val2;
		((Selectable)val3).transition = (Transition)0;
		GameObject val4 = new GameObject("Checkbox", new Type[1] { typeof(RectTransform) });
		val4.transform.SetParent(val.transform, false);
		RectTransform component2 = val4.GetComponent<RectTransform>();
		component2.anchorMin = new Vector2(0f, 1f);
		component2.anchorMax = new Vector2(0f, 1f);
		component2.pivot = new Vector2(0f, 1f);
		component2.anchoredPosition = new Vector2(4f, -4f);
		component2.sizeDelta = new Vector2(28f, 28f);
		Image val5 = val4.AddComponent<Image>();
		((Graphic)val5).color = new Color(0f, 0f, 0f, 0.55f);
		GameObject val6 = new GameObject("Check", new Type[1] { typeof(RectTransform) });
		val6.transform.SetParent(val4.transform, false);
		RectTransform component3 = val6.GetComponent<RectTransform>();
		component3.anchorMin = Vector2.zero;
		component3.anchorMax = Vector2.one;
		component3.offsetMin = Vector2.zero;
		component3.offsetMax = Vector2.zero;
		TextMeshProUGUI val7 = val6.AddComponent<TextMeshProUGUI>();
		((TMP_Text)val7).text = "";
		((TMP_Text)val7).fontSize = 18f;
		((TMP_Text)val7).alignment = (TextAlignmentOptions)514;
		((Graphic)val7).color = Color.white;
		UnitBlueprint capturedUnit = unit;
		TextMeshProUGUI capturedCheck = val7;
		Image capturedBg = val5;
		((UnityEvent)val3.onClick).AddListener((UnityAction)delegate
		{
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			if (selectMode)
			{
				if (selected.Contains(capturedUnit))
				{
					selected.Remove(capturedUnit);
					((TMP_Text)capturedCheck).text = "";
					((Graphic)capturedBg).color = new Color(0f, 0f, 0f, 0.55f);
				}
				else
				{
					selected.Add(capturedUnit);
					((TMP_Text)capturedCheck).text = "✔";
					((Graphic)capturedBg).color = new Color(0.18f, 0.65f, 0.18f, 0.85f);
				}
				RefreshDeleteButton();
			}
		});
		if (selected.Contains(unit))
		{
			((TMP_Text)val7).text = "✔";
			((Graphic)val5).color = new Color(0.18f, 0.65f, 0.18f, 0.85f);
		}
	}

	private static void EnsureDeleteButton(CustomContentGridBrowser browser)
	{
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Expected O, but got Unknown
		//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b5: Expected O, but got Unknown
		//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d1: Expected O, but got Unknown
		//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_0215: Unknown result type (might be due to invalid IL or missing references)
		//IL_0224: Unknown result type (might be due to invalid IL or missing references)
		//IL_022b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0240: Unknown result type (might be due to invalid IL or missing references)
		//IL_0245: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bb: Expected O, but got Unknown
		//IL_02db: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0302: Unknown result type (might be due to invalid IL or missing references)
		//IL_033e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Expected O, but got Unknown
		if ((Object)(object)deleteButton != (Object)null && (Object)(object)((Component)deleteButton).gameObject != (Object)null)
		{
			return;
		}
		CustomContentUnitBrowser componentInChildren = ((Component)browser).GetComponentInChildren<CustomContentUnitBrowser>(true);
		if ((Object)(object)componentInChildren == (Object)null)
		{
			Debug.LogWarning((object)"[TABSUXMod] CustomContentUnitBrowser not found.");
			return;
		}
		object? obj = typeof(CustomContentUnitBrowser).GetField("layout01", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(componentInChildren);
		Component val = (Component)((obj is Component) ? obj : null);
		if ((Object)(object)val == (Object)null)
		{
			Debug.LogWarning((object)"[TABSUXMod] layout01 field not found.");
			return;
		}
		Transform parent = val.transform.parent;
		Button val2 = null;
		foreach (Transform item in parent)
		{
			Transform val3 = item;
			if (((Object)val3).name == "New Unit")
			{
				val2 = ((Component)val3).GetComponent<Button>();
				break;
			}
		}
		if ((Object)(object)val2 == (Object)null)
		{
			Debug.LogWarning((object)"[TABSUXMod] 'New Unit' not found in UnitGrid. Siblings:");
			{
				foreach (Transform item2 in parent)
				{
					Transform val4 = item2;
					Debug.Log((object)("[TABSUXMod] sibling: '" + ((Object)val4).name + "'"));
				}
				return;
			}
		}
		GameObject val5 = Object.Instantiate<GameObject>(((Component)val2).gameObject, parent, false);
		((Object)val5).name = "BulkDeleteBtn";
		deleteButton = val5.GetComponent<Button>();
		deleteButton.onClick = new ButtonClickedEvent();
		((UnityEvent)deleteButton.onClick).AddListener(new UnityAction(OnDeleteButtonClicked));
		RectTransform component = ((Component)val2).GetComponent<RectTransform>();
		RectTransform component2 = val5.GetComponent<RectTransform>();
		component2.anchorMin = component.anchorMin;
		component2.anchorMax = component.anchorMax;
		component2.pivot = component.pivot;
		component2.sizeDelta = component.sizeDelta;
		component2.anchoredPosition = component.anchoredPosition + new Vector2(component.sizeDelta.x + 8f, 0f);
		val5.transform.SetSiblingIndex(((Component)val2).transform.GetSiblingIndex() + 1);
		TextMeshProUGUI[] componentsInChildren = val5.GetComponentsInChildren<TextMeshProUGUI>();
		foreach (TextMeshProUGUI val6 in componentsInChildren)
		{
			Object.Destroy((Object)(object)((Component)val6).gameObject);
		}
		GameObject val7 = new GameObject("Label", new Type[1] { typeof(RectTransform) });
		val7.transform.SetParent(val5.transform, false);
		RectTransform component3 = val7.GetComponent<RectTransform>();
		component3.anchorMin = Vector2.zero;
		component3.anchorMax = Vector2.one;
		component3.offsetMin = Vector2.zero;
		component3.offsetMax = Vector2.zero;
		deleteButtonLabel = val7.AddComponent<TextMeshProUGUI>();
		((TMP_Text)deleteButtonLabel).alignment = (TextAlignmentOptions)514;
		((TMP_Text)deleteButtonLabel).fontSize = 18f;
		((Graphic)deleteButtonLabel).color = Color.white;
		CacheSideBar();
	}

	private static void OnDeleteButtonClicked()
	{
		if (!selectMode)
		{
			selectMode = true;
			SetOverlaysVisible(visible: true);
			RefreshDeleteButton();
		}
		else if (selected.Count > 0)
		{
			DeleteSelected();
		}
		else
		{
			ExitSelectMode();
		}
	}

	private static void ExitSelectMode()
	{
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		selectMode = false;
		selected.Clear();
		SetOverlaysVisible(visible: false);
		foreach (GameObject overlay in overlays)
		{
			if (!((Object)(object)overlay == (Object)null))
			{
				Transform val = overlay.transform.Find("Checkbox");
				Image val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<Image>() : null);
				if ((Object)(object)val2 != (Object)null)
				{
					((Graphic)val2).color = new Color(0f, 0f, 0f, 0.55f);
				}
				TextMeshProUGUI componentInChildren = overlay.GetComponentInChildren<TextMeshProUGUI>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					((TMP_Text)componentInChildren).text = "";
				}
			}
		}
		RefreshDeleteButton();
	}

	private static void SetOverlaysVisible(bool visible)
	{
		overlays.RemoveAll((GameObject o) => (Object)(object)o == (Object)null);
		foreach (GameObject overlay in overlays)
		{
			overlay.SetActive(visible);
		}
	}

	private static void CacheSideBar()
	{
		if ((Object)(object)sideBarInstance != (Object)null)
		{
			return;
		}
		Assembly assembly = typeof(CustomContentGridBrowser).Assembly;
		Type type = assembly.GetType("Landfall.TABS.CustomContentSideBar");
		if (!(type == null))
		{
			Object obj = Object.FindObjectOfType(type);
			sideBarInstance = (MonoBehaviour)(object)((obj is MonoBehaviour) ? obj : null);
			if (!((Object)(object)sideBarInstance == (Object)null))
			{
				deleteBCSCMethod = type.GetMethod("DeleteBattleCreatorSharedCommandsContent", BindingFlags.Instance | BindingFlags.NonPublic);
				contentTypeFilterType = assembly.GetType("Landfall.TABS.Workshop.ContentTypeFilter");
				customContentFilePathsType = assembly.GetType("Landfall.TABS.Workshop.CustomContentFilePaths");
			}
		}
	}

	private static void RefreshDeleteButton()
	{
		if (!((Object)(object)deleteButtonLabel == (Object)null))
		{
			if (!selectMode)
			{
				((TMP_Text)deleteButtonLabel).text = "SELECT TO DELETE";
				((Selectable)deleteButton).interactable = true;
			}
			else if (selected.Count == 0)
			{
				((TMP_Text)deleteButtonLabel).text = "CANCEL";
				((Selectable)deleteButton).interactable = true;
			}
			else
			{
				((TMP_Text)deleteButtonLabel).text = $"DELETE ({selected.Count})";
				((Selectable)deleteButton).interactable = true;
			}
		}
	}

	private static void DeleteSelected()
	{
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		if (selected.Count == 0)
		{
			return;
		}
		CacheSideBar();
		if ((Object)(object)sideBarInstance == (Object)null || deleteBCSCMethod == null || contentTypeFilterType == null || customContentFilePathsType == null)
		{
			Debug.LogError((object)"[TABSUXMod] Could not resolve deletion methods via reflection.");
			return;
		}
		object obj = Enum.ToObject(contentTypeFilterType, 4);
		PropertyInfo property = customContentFilePathsType.GetProperty("UnitDirectoryPath", BindingFlags.Static | BindingFlags.Public);
		if (property == null)
		{
			Debug.LogError((object)"[TABSUXMod] UnitDirectoryPath property not found.");
			return;
		}
		string text = (string)property.GetValue(null);
		foreach (UnitBlueprint item in selected)
		{
			string text2 = text + ((object)item.Entity.GUID/*cast due to .constrained prefix*/).ToString();
			deleteBCSCMethod.Invoke(sideBarInstance, new object[3] { obj, item, text2 });
		}
		ExitSelectMode();
		CustomContentGridBrowser obj2 = Object.FindObjectOfType<CustomContentGridBrowser>();
		if (obj2 != null)
		{
			obj2.Refresh();
		}
	}
}
public static class DoubleClickPlayMapPatch
{
	private const float DoubleClickWindow = 0.4f;

	private static CustomMap lastClickedMap;

	private static float lastClickTime = -1f;

	[HarmonyPostfix]
	[HarmonyPatch(typeof(CustomContentLevelButton), "OnPointerClick")]
	public static void OnLevelButtonPointerClick(CustomContentLevelButton __instance, PointerEventData eventData)
	{
		lastClickedMap = __instance.customMap;
		lastClickTime = Time.unscaledTime;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(FactionCreatorFadeBG), "OnPointerClick")]
	public static bool OnFadePointerClick(FactionCreatorFadeBG __instance)
	{
		if ((Object)(object)lastClickedMap == (Object)null)
		{
			return true;
		}
		if (Time.unscaledTime - lastClickTime > 0.4f)
		{
			return true;
		}
		CustomContentSideBar sidebar = __instance.sidebar;
		if ((Object)(object)sidebar == (Object)null || (Object)(object)sidebar.levelParent == (Object)null || !sidebar.levelParent.activeSelf)
		{
			return true;
		}
		lastClickedMap = null;
		lastClickTime = -1f;
		sidebar.Play();
		return false;
	}
}
[BepInPlugin("joshbaier.tabsuxmod", "Better UX", "1.0.0")]
public class Launcher : 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
		Harmony val = new Harmony("joshbaier.tabsuxmod");
		val.PatchAll(typeof(BulkDeletePatch));
		val.PatchAll(typeof(DoubleClickPlayMapPatch));
		SuppressLaunchInvitePatch.Apply(val);
		AutoConfirmLoadModsPatch.Apply(val);
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Better UX loaded.");
	}
}
public static class SuppressLaunchInvitePatch
{
	private static bool declinedFirstInvite;

	public static void Apply(Harmony harmony)
	{
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Expected O, but got Unknown
		Assembly assembly = null;
		Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
		foreach (Assembly assembly2 in assemblies)
		{
			if (assembly2.GetName().Name == "Assembly-CSharp")
			{
				assembly = assembly2;
				break;
			}
		}
		if (assembly == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] Assembly-CSharp not found — launch invite suppression skipped.");
			return;
		}
		Type type = assembly.GetType("TFBGames.SocialProfileService");
		if (type == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] SocialProfileService not found — launch invite suppression skipped.");
			return;
		}
		MethodInfo method = type.GetMethod("SetState", BindingFlags.Instance | BindingFlags.NonPublic);
		if (method == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] SocialProfileService.SetState not found — launch invite suppression skipped.");
			return;
		}
		MethodInfo method2 = typeof(SuppressLaunchInvitePatch).GetMethod("SetStatePrefix", BindingFlags.Static | BindingFlags.NonPublic);
		harmony.Patch((MethodBase)method, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		Debug.Log((object)"[TABSUXMod] Launch invite suppression active (first invite of the session will be auto-declined).");
	}

	private static bool SetStatePrefix(ref object __0)
	{
		if (declinedFirstInvite)
		{
			return true;
		}
		int num = Convert.ToInt32(__0);
		if (num == 1 || num == 2)
		{
			declinedFirstInvite = true;
			Debug.Log((object)("[TABSUXMod] Auto-declined spurious launch invite (redirected SetState(" + num + ") to Idle). Later invites are untouched."));
			__0 = Enum.ToObject(__0.GetType(), 0);
		}
		return true;
	}
}

bin/Release/net472/TABSUXMod.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using DM;
using HarmonyLib;
using Landfall.TABS;
using Landfall.TABS.UnitEditor;
using LevelCreator;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace TABSUXMod;

public static class AllUnitBasesPatch
{
	private static FieldInfo s_nonStreamableAssetsField;

	private static Dictionary<DatabaseID, GameObject> s_rigsByGuid;

	private static int s_rigsBuiltFromCount = -1;

	private static bool s_resolving;

	[HarmonyPrefix]
	[HarmonyPatch(typeof(UnitEditorManager), "Start")]
	public static void BeforeUnitEditorStart(UnitEditorManager __instance)
	{
		Debug.Log((object)"[TABSUXMod] UnitEditorManager.Start prefix fired.");
		try
		{
			Inject(__instance);
		}
		catch (Exception ex)
		{
			Debug.LogError((object)("[TABSUXMod] Failed to add unit bases to the Unit Creator: " + ex));
		}
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(UnitEditorUnitBaseGrid), "SpawnUnitBaseButtons")]
	public static void BeforeSpawnUnitBaseButtons(ref UnitBaseWrapper[] unitBaseWrappers, UnitEditorManager unitEditorManager)
	{
		Debug.Log((object)("[TABSUXMod] SpawnUnitBaseButtons prefix fired with " + ((unitBaseWrappers != null) ? unitBaseWrappers.Length : (-1)) + " wrappers."));
		try
		{
			if (!((Object)(object)unitEditorManager == (Object)null))
			{
				Inject(unitEditorManager);
				unitBaseWrappers = unitEditorManager.UnitBases;
			}
		}
		catch (Exception ex)
		{
			Debug.LogError((object)("[TABSUXMod] Failed to add unit bases to the Unit Creator: " + ex));
		}
	}

	private static void Inject(UnitEditorManager manager)
	{
		//IL_020a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0211: Expected O, but got Unknown
		//IL_0232: Unknown result type (might be due to invalid IL or missing references)
		//IL_0237: Unknown result type (might be due to invalid IL or missing references)
		//IL_023f: 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_0253: Unknown result type (might be due to invalid IL or missing references)
		//IL_025a: Expected O, but got Unknown
		List<UnitBaseWrapper> list = new List<UnitBaseWrapper>(manager.UnitBases);
		if (list.Count == 0)
		{
			Debug.LogWarning((object)"[TABSUXMod] UnitBases is empty; nothing to use as a template, skipping.");
			return;
		}
		UnitBlueprint unitBaseBlueprint = list[0].UnitBaseBlueprint;
		if ((Object)(object)unitBaseBlueprint == (Object)null)
		{
			Debug.LogWarning((object)"[TABSUXMod] UnitBases[0] has no blueprint to use as a template, skipping.");
			return;
		}
		HashSet<GameObject> hashSet = new HashSet<GameObject>();
		foreach (UnitBaseWrapper item in list)
		{
			if (item != null && (Object)(object)item.UnitBaseBlueprint != (Object)null && (Object)(object)item.UnitBaseBlueprint.UnitBase != (Object)null)
			{
				hashSet.Add(item.UnitBaseBlueprint.UnitBase);
			}
		}
		ContentDatabase val = ContentDatabase.Instance();
		List<GameObject> list2 = new List<GameObject>();
		Dictionary<GameObject, UnitBlueprint> dictionary = new Dictionary<GameObject, UnitBlueprint>();
		foreach (GameObject allUnitBasis in val.GetAllUnitBases())
		{
			if ((Object)(object)allUnitBasis != (Object)null)
			{
				list2.Add(allUnitBasis);
			}
		}
		int count = list2.Count;
		foreach (UnitBlueprint allUnitBlueprint in val.GetAllUnitBlueprints())
		{
			if ((Object)(object)allUnitBlueprint == (Object)null)
			{
				continue;
			}
			GameObject unitBase;
			try
			{
				unitBase = allUnitBlueprint.UnitBase;
			}
			catch
			{
				continue;
			}
			if (!((Object)(object)unitBase == (Object)null))
			{
				list2.Add(unitBase);
				if (!dictionary.ContainsKey(unitBase))
				{
					dictionary[unitBase] = allUnitBlueprint;
				}
			}
		}
		int num = 0;
		List<UnitBaseWrapper> list3 = new List<UnitBaseWrapper>();
		foreach (GameObject item2 in list2)
		{
			if (hashSet.Add(item2))
			{
				Unit component = item2.GetComponent<Unit>();
				if ((Object)(object)component == (Object)null || component.Entity == null)
				{
					num++;
					continue;
				}
				if ((Object)(object)item2.GetComponentInChildren<Torso>(true) == (Object)null || (Object)(object)item2.GetComponentInChildren<HealthHandler>(true) == (Object)null || (Object)(object)item2.GetComponentInChildren<RigidbodyHolder>(true) == (Object)null)
				{
					num++;
					continue;
				}
				UnitBlueprint val2 = new UnitBlueprint(unitBaseBlueprint);
				val2.UnitBase = item2;
				val2.Entity.Name = component.Entity.Name;
				UnitBaseWrapper val3 = new UnitBaseWrapper
				{
					UnitBaseBlueprint = val2,
					BaseDisplayName = component.Entity.Name,
					UnitBaseRestriction = (UnitBaseRestrictions)0
				};
				dictionary.TryGetValue(item2, out var value);
				LoadIcon(val3, component.Entity, value);
				list3.Add(val3);
			}
		}
		list3.Sort((UnitBaseWrapper a, UnitBaseWrapper b) => string.Compare(a.BaseDisplayName, b.BaseDisplayName, StringComparison.OrdinalIgnoreCase));
		list.AddRange(list3);
		manager.UnitBases = list.ToArray();
		int num2 = 0;
		foreach (UnitBaseWrapper item3 in list)
		{
			GameObject val4 = ((item3 != null && (Object)(object)item3.UnitBaseBlueprint != (Object)null) ? item3.UnitBaseBlueprint.UnitBase : null);
			if ((Object)(object)val4 != (Object)null && RegisterRig(val, val4))
			{
				num2++;
			}
		}
		Debug.Log((object)("[TABSUXMod] Added " + list3.Count + " unit bases to the Unit Creator (" + list.Count + " total; " + count + " registered rigs, " + (list2.Count - count) + " blueprint rigs, " + num + " skipped as unusable, " + num2 + " rigs newly registered in AssetLoader)."));
	}

	private static bool RegisterRig(ContentDatabase db, GameObject rig)
	{
		//IL_005f: 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)
		Unit component = rig.GetComponent<Unit>();
		if ((Object)(object)component == (Object)null || component.Entity == null)
		{
			return false;
		}
		if (s_nonStreamableAssetsField == null)
		{
			s_nonStreamableAssetsField = typeof(AssetLoader).GetField("m_nonStreamableAssets", BindingFlags.Instance | BindingFlags.NonPublic);
		}
		Dictionary<DatabaseID, Object> dictionary = (Dictionary<DatabaseID, Object>)s_nonStreamableAssetsField.GetValue(db.AssetLoader);
		if (dictionary.ContainsKey(component.Entity.GUID))
		{
			return false;
		}
		dictionary.Add(component.Entity.GUID, (Object)(object)rig);
		return true;
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(ContentDatabase), "GetGameObject")]
	public unsafe static void AfterGetGameObject(DatabaseID databaseId, ref GameObject __result)
	{
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)__result != (Object)null || s_resolving)
		{
			return;
		}
		try
		{
			s_resolving = true;
			ContentDatabase val = ContentDatabase.Instance();
			List<UnitBlueprint> list = new List<UnitBlueprint>(val.GetAllUnitBlueprints());
			if (s_rigsByGuid == null || list.Count != s_rigsBuiltFromCount)
			{
				Dictionary<DatabaseID, GameObject> dictionary = new Dictionary<DatabaseID, GameObject>();
				foreach (UnitBlueprint item in list)
				{
					if ((Object)(object)item == (Object)null)
					{
						continue;
					}
					GameObject unitBase;
					try
					{
						unitBase = item.UnitBase;
					}
					catch
					{
						continue;
					}
					if (!((Object)(object)unitBase == (Object)null))
					{
						Unit component = unitBase.GetComponent<Unit>();
						if ((Object)(object)component != (Object)null && component.Entity != null && !dictionary.ContainsKey(component.Entity.GUID))
						{
							dictionary[component.Entity.GUID] = unitBase;
						}
					}
				}
				s_rigsByGuid = dictionary;
				s_rigsBuiltFromCount = list.Count;
			}
			if (s_rigsByGuid.TryGetValue(databaseId, out var value))
			{
				RegisterRig(val, value);
				__result = value;
				string[] obj2 = new string[5]
				{
					"[TABSUXMod] Resolved unit base '",
					((Object)value).name,
					"' (",
					null,
					null
				};
				DatabaseID val2 = databaseId;
				obj2[3] = ((object)(*(DatabaseID*)(&val2))/*cast due to .constrained prefix*/).ToString();
				obj2[4] = ") via blueprint fallback.";
				Debug.Log((object)string.Concat(obj2));
			}
		}
		catch (Exception ex)
		{
			Debug.LogError((object)("[TABSUXMod] GetGameObject fallback failed: " + ex));
		}
		finally
		{
			s_resolving = false;
		}
	}

	private static void LoadIcon(UnitBaseWrapper wrapper, DatabaseEntity rigEntity, UnitBlueprint fallback)
	{
		rigEntity.GetSpriteIconAsync((Action<Sprite>)delegate(Sprite sprite)
		{
			if ((Object)(object)sprite != (Object)null)
			{
				wrapper.BaseIcon = sprite;
			}
			else if ((Object)(object)fallback != (Object)null && fallback.Entity != null)
			{
				fallback.Entity.GetSpriteIconAsync((Action<Sprite>)delegate(Sprite fallbackSprite)
				{
					wrapper.BaseIcon = fallbackSprite;
				});
			}
		});
	}
}
public static class AutoConfirmLoadModsPatch
{
	private static MethodInfo setPermission;

	private static MethodInfo onCheckedPermission;

	public static void Apply(Harmony harmony)
	{
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Expected O, but got Unknown
		Assembly assembly = null;
		Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
		foreach (Assembly assembly2 in assemblies)
		{
			if (assembly2.GetName().Name == "Assembly-CSharp")
			{
				assembly = assembly2;
				break;
			}
		}
		if (assembly == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] Assembly-CSharp not found — load-mods auto-confirm skipped.");
			return;
		}
		Type type = assembly.GetType("Landfall.TABS.Workshop.CustomContentLoaderModIO");
		if (type == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] CustomContentLoaderModIO not found — load-mods auto-confirm skipped.");
			return;
		}
		BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.NonPublic;
		PropertyInfo property = type.GetProperty("DidGivePermissionToLoadMods", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		setPermission = ((property != null) ? property.GetSetMethod(nonPublic: true) : null);
		onCheckedPermission = type.GetMethod("OnCheckedPermissionToLoadMods", bindingAttr);
		MethodInfo method = type.GetMethod("CheckPermissionToLoadMods", BindingFlags.Instance | BindingFlags.Public);
		if (setPermission == null || onCheckedPermission == null || method == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] CustomContentLoaderModIO members not found — load-mods auto-confirm skipped.");
			return;
		}
		MethodInfo method2 = typeof(AutoConfirmLoadModsPatch).GetMethod("CheckPermissionPrefix", BindingFlags.Static | BindingFlags.NonPublic);
		harmony.Patch((MethodBase)method, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		Debug.Log((object)"[TABSUXMod] Load-mods warning auto-confirm active.");
	}

	private static bool CheckPermissionPrefix(object __instance, bool refresh, object doneCallback)
	{
		Debug.Log((object)"[TABSUXMod] Auto-confirming 'load mods?' warning.");
		setPermission.Invoke(__instance, new object[1] { true });
		onCheckedPermission.Invoke(__instance, new object[2] { refresh, doneCallback });
		return false;
	}
}
public static class BulkDeletePatch
{
	private static readonly HashSet<UnitBlueprint> selected = new HashSet<UnitBlueprint>();

	private static readonly List<GameObject> overlays = new List<GameObject>();

	private static bool selectMode = false;

	private static Button deleteButton;

	private static TextMeshProUGUI deleteButtonLabel;

	private static MonoBehaviour sideBarInstance;

	private static MethodInfo deleteBCSCMethod;

	private static Type contentTypeFilterType;

	private static Type customContentFilePathsType;

	[HarmonyPostfix]
	[HarmonyPatch(typeof(CustomContentGridBrowser), "OnEnable")]
	public static void OnBrowserOpen(CustomContentGridBrowser __instance)
	{
		ExitSelectMode();
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(CustomContentGridBrowser), "Populate")]
	public static void OnBrowserPopulate(CustomContentGridBrowser __instance)
	{
		EnsureDeleteButton(__instance);
		RefreshDeleteButton();
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(UnitButtonBase), "Setup")]
	public static void OnUnitButtonSetup(UnitButtonBase __instance, UnitBlueprint unit)
	{
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Expected O, but got Unknown
		//IL_007d: 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_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Expected O, but got Unknown
		//IL_0129: 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_0153: 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)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01df: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_026c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0276: Expected O, but got Unknown
		//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)unit == (Object)null)
		{
			return;
		}
		GameObject gameObject = ((Component)__instance).gameObject;
		if ((Object)(object)gameObject.transform.Find("BulkSelectOverlay") != (Object)null)
		{
			return;
		}
		GameObject val = new GameObject("BulkSelectOverlay", new Type[1] { typeof(RectTransform) });
		val.transform.SetParent(gameObject.transform, false);
		val.SetActive(selectMode);
		overlays.Add(val);
		RectTransform component = val.GetComponent<RectTransform>();
		component.anchorMin = Vector2.zero;
		component.anchorMax = Vector2.one;
		component.offsetMin = Vector2.zero;
		component.offsetMax = Vector2.zero;
		Image val2 = val.AddComponent<Image>();
		((Graphic)val2).color = new Color(0f, 0f, 0f, 0f);
		Button val3 = val.AddComponent<Button>();
		((Selectable)val3).targetGraphic = (Graphic)(object)val2;
		((Selectable)val3).transition = (Transition)0;
		GameObject val4 = new GameObject("Checkbox", new Type[1] { typeof(RectTransform) });
		val4.transform.SetParent(val.transform, false);
		RectTransform component2 = val4.GetComponent<RectTransform>();
		component2.anchorMin = new Vector2(0f, 1f);
		component2.anchorMax = new Vector2(0f, 1f);
		component2.pivot = new Vector2(0f, 1f);
		component2.anchoredPosition = new Vector2(4f, -4f);
		component2.sizeDelta = new Vector2(28f, 28f);
		Image val5 = val4.AddComponent<Image>();
		((Graphic)val5).color = new Color(0f, 0f, 0f, 0.55f);
		GameObject val6 = new GameObject("Check", new Type[1] { typeof(RectTransform) });
		val6.transform.SetParent(val4.transform, false);
		RectTransform component3 = val6.GetComponent<RectTransform>();
		component3.anchorMin = Vector2.zero;
		component3.anchorMax = Vector2.one;
		component3.offsetMin = Vector2.zero;
		component3.offsetMax = Vector2.zero;
		TextMeshProUGUI val7 = val6.AddComponent<TextMeshProUGUI>();
		((TMP_Text)val7).text = "";
		((TMP_Text)val7).fontSize = 18f;
		((TMP_Text)val7).alignment = (TextAlignmentOptions)514;
		((Graphic)val7).color = Color.white;
		UnitBlueprint capturedUnit = unit;
		TextMeshProUGUI capturedCheck = val7;
		Image capturedBg = val5;
		((UnityEvent)val3.onClick).AddListener((UnityAction)delegate
		{
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			if (selectMode)
			{
				if (selected.Contains(capturedUnit))
				{
					selected.Remove(capturedUnit);
					((TMP_Text)capturedCheck).text = "";
					((Graphic)capturedBg).color = new Color(0f, 0f, 0f, 0.55f);
				}
				else
				{
					selected.Add(capturedUnit);
					((TMP_Text)capturedCheck).text = "✔";
					((Graphic)capturedBg).color = new Color(0.18f, 0.65f, 0.18f, 0.85f);
				}
				RefreshDeleteButton();
			}
		});
		if (selected.Contains(unit))
		{
			((TMP_Text)val7).text = "✔";
			((Graphic)val5).color = new Color(0.18f, 0.65f, 0.18f, 0.85f);
		}
	}

	private static void EnsureDeleteButton(CustomContentGridBrowser browser)
	{
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Expected O, but got Unknown
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Expected O, but got Unknown
		//IL_018a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Expected O, but got Unknown
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0260: Unknown result type (might be due to invalid IL or missing references)
		//IL_0265: Unknown result type (might be due to invalid IL or missing references)
		//IL_0278: Unknown result type (might be due to invalid IL or missing references)
		//IL_027f: Unknown result type (might be due to invalid IL or missing references)
		//IL_028a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0295: Unknown result type (might be due to invalid IL or missing references)
		//IL_029f: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d6: 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_0107: Expected O, but got Unknown
		if ((Object)(object)deleteButton != (Object)null && (Object)(object)((Component)deleteButton).gameObject != (Object)null)
		{
			return;
		}
		CustomContentUnitBrowser componentInChildren = ((Component)browser).GetComponentInChildren<CustomContentUnitBrowser>(true);
		if ((Object)(object)componentInChildren == (Object)null)
		{
			Debug.LogWarning((object)"[TABSUXMod] CustomContentUnitBrowser not found.");
			return;
		}
		object? obj = typeof(CustomContentUnitBrowser).GetField("layout01", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(componentInChildren);
		Component val = (Component)((obj is Component) ? obj : null);
		if ((Object)(object)val == (Object)null)
		{
			Debug.LogWarning((object)"[TABSUXMod] layout01 field not found.");
			return;
		}
		Transform parent = val.transform.parent;
		Button val2 = null;
		foreach (Transform item in parent)
		{
			Transform val3 = item;
			if (((Object)val3).name == "New Unit")
			{
				val2 = ((Component)val3).GetComponent<Button>();
				break;
			}
		}
		if ((Object)(object)val2 == (Object)null)
		{
			Debug.LogWarning((object)"[TABSUXMod] 'New Unit' not found in UnitGrid. Siblings:");
			{
				foreach (Transform item2 in parent)
				{
					Transform val4 = item2;
					Debug.Log((object)("[TABSUXMod] sibling: '" + ((Object)val4).name + "'"));
				}
				return;
			}
		}
		GameObject val5 = Object.Instantiate<GameObject>(((Component)val2).gameObject, parent, false);
		((Object)val5).name = "BulkDeleteBtn";
		deleteButton = val5.GetComponent<Button>();
		deleteButton.onClick = new ButtonClickedEvent();
		((UnityEvent)deleteButton.onClick).AddListener(new UnityAction(OnDeleteButtonClicked));
		RectTransform component = ((Component)val2).GetComponent<RectTransform>();
		RectTransform component2 = val5.GetComponent<RectTransform>();
		component2.anchorMin = component.anchorMin;
		component2.anchorMax = component.anchorMax;
		component2.pivot = component.pivot;
		component2.sizeDelta = component.sizeDelta;
		component2.anchoredPosition = component.anchoredPosition + new Vector2(component.sizeDelta.x + 8f, 0f);
		val5.transform.SetSiblingIndex(((Component)val2).transform.GetSiblingIndex() + 1);
		TextMeshProUGUI[] componentsInChildren = val5.GetComponentsInChildren<TextMeshProUGUI>();
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			Object.Destroy((Object)(object)((Component)componentsInChildren[i]).gameObject);
		}
		GameObject val6 = new GameObject("Label", new Type[1] { typeof(RectTransform) });
		val6.transform.SetParent(val5.transform, false);
		RectTransform component3 = val6.GetComponent<RectTransform>();
		component3.anchorMin = Vector2.zero;
		component3.anchorMax = Vector2.one;
		component3.offsetMin = Vector2.zero;
		component3.offsetMax = Vector2.zero;
		deleteButtonLabel = val6.AddComponent<TextMeshProUGUI>();
		((TMP_Text)deleteButtonLabel).alignment = (TextAlignmentOptions)514;
		((TMP_Text)deleteButtonLabel).fontSize = 18f;
		((Graphic)deleteButtonLabel).color = Color.white;
		CacheSideBar();
	}

	private static void OnDeleteButtonClicked()
	{
		if (!selectMode)
		{
			selectMode = true;
			SetOverlaysVisible(visible: true);
			RefreshDeleteButton();
		}
		else if (selected.Count > 0)
		{
			DeleteSelected();
		}
		else
		{
			ExitSelectMode();
		}
	}

	private static void ExitSelectMode()
	{
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		selectMode = false;
		selected.Clear();
		SetOverlaysVisible(visible: false);
		foreach (GameObject overlay in overlays)
		{
			if (!((Object)(object)overlay == (Object)null))
			{
				Transform val = overlay.transform.Find("Checkbox");
				Image val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<Image>() : null);
				if ((Object)(object)val2 != (Object)null)
				{
					((Graphic)val2).color = new Color(0f, 0f, 0f, 0.55f);
				}
				TextMeshProUGUI componentInChildren = overlay.GetComponentInChildren<TextMeshProUGUI>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					((TMP_Text)componentInChildren).text = "";
				}
			}
		}
		RefreshDeleteButton();
	}

	private static void SetOverlaysVisible(bool visible)
	{
		overlays.RemoveAll((GameObject o) => (Object)(object)o == (Object)null);
		foreach (GameObject overlay in overlays)
		{
			overlay.SetActive(visible);
		}
	}

	private static void CacheSideBar()
	{
		if ((Object)(object)sideBarInstance != (Object)null)
		{
			return;
		}
		Assembly assembly = typeof(CustomContentGridBrowser).Assembly;
		Type type = assembly.GetType("Landfall.TABS.CustomContentSideBar");
		if (!(type == null))
		{
			Object obj = Object.FindObjectOfType(type);
			sideBarInstance = (MonoBehaviour)(object)((obj is MonoBehaviour) ? obj : null);
			if (!((Object)(object)sideBarInstance == (Object)null))
			{
				deleteBCSCMethod = type.GetMethod("DeleteBattleCreatorSharedCommandsContent", BindingFlags.Instance | BindingFlags.NonPublic);
				contentTypeFilterType = assembly.GetType("Landfall.TABS.Workshop.ContentTypeFilter");
				customContentFilePathsType = assembly.GetType("Landfall.TABS.Workshop.CustomContentFilePaths");
			}
		}
	}

	private static void RefreshDeleteButton()
	{
		if (!((Object)(object)deleteButtonLabel == (Object)null))
		{
			if (!selectMode)
			{
				((TMP_Text)deleteButtonLabel).text = "SELECT TO DELETE";
				((Selectable)deleteButton).interactable = true;
			}
			else if (selected.Count == 0)
			{
				((TMP_Text)deleteButtonLabel).text = "CANCEL";
				((Selectable)deleteButton).interactable = true;
			}
			else
			{
				((TMP_Text)deleteButtonLabel).text = $"DELETE ({selected.Count})";
				((Selectable)deleteButton).interactable = true;
			}
		}
	}

	private static void DeleteSelected()
	{
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		if (selected.Count == 0)
		{
			return;
		}
		CacheSideBar();
		if ((Object)(object)sideBarInstance == (Object)null || deleteBCSCMethod == null || contentTypeFilterType == null || customContentFilePathsType == null)
		{
			Debug.LogError((object)"[TABSUXMod] Could not resolve deletion methods via reflection.");
			return;
		}
		object obj = Enum.ToObject(contentTypeFilterType, 4);
		PropertyInfo property = customContentFilePathsType.GetProperty("UnitDirectoryPath", BindingFlags.Static | BindingFlags.Public);
		if (property == null)
		{
			Debug.LogError((object)"[TABSUXMod] UnitDirectoryPath property not found.");
			return;
		}
		string text = (string)property.GetValue(null);
		foreach (UnitBlueprint item in selected)
		{
			string text2 = text + ((object)item.Entity.GUID/*cast due to .constrained prefix*/).ToString();
			deleteBCSCMethod.Invoke(sideBarInstance, new object[3] { obj, item, text2 });
		}
		ExitSelectMode();
		CustomContentGridBrowser obj2 = Object.FindObjectOfType<CustomContentGridBrowser>();
		if (obj2 != null)
		{
			obj2.Refresh();
		}
	}
}
public static class DoubleClickPlayMapPatch
{
	private const float DoubleClickWindow = 0.4f;

	private static CustomMap lastClickedMap;

	private static float lastClickTime = -1f;

	[HarmonyPostfix]
	[HarmonyPatch(typeof(CustomContentLevelButton), "OnPointerClick")]
	public static void OnLevelButtonPointerClick(CustomContentLevelButton __instance, PointerEventData eventData)
	{
		lastClickedMap = __instance.customMap;
		lastClickTime = Time.unscaledTime;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(FactionCreatorFadeBG), "OnPointerClick")]
	public static bool OnFadePointerClick(FactionCreatorFadeBG __instance)
	{
		if ((Object)(object)lastClickedMap == (Object)null)
		{
			return true;
		}
		if (Time.unscaledTime - lastClickTime > 0.4f)
		{
			return true;
		}
		CustomContentSideBar sidebar = __instance.sidebar;
		if ((Object)(object)sidebar == (Object)null || (Object)(object)sidebar.levelParent == (Object)null || !sidebar.levelParent.activeSelf)
		{
			return true;
		}
		lastClickedMap = null;
		lastClickTime = -1f;
		sidebar.Play();
		return false;
	}
}
[BepInPlugin("joshbaier.tabsuxmod", "Better UX", "1.1.2")]
public class Launcher : BaseUnityPlugin
{
	private void Awake()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: 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_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Expected O, but got Unknown
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Expected O, but got Unknown
		Harmony val = new Harmony("joshbaier.tabsuxmod");
		val.PatchAll(typeof(BulkDeletePatch));
		val.PatchAll(typeof(DoubleClickPlayMapPatch));
		val.PatchAll(typeof(AllUnitBasesPatch));
		SuppressLaunchInvitePatch.Apply(val);
		AutoConfirmLoadModsPatch.Apply(val);
		foreach (MethodBase patchedMethod in val.GetPatchedMethods())
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Patched: " + patchedMethod.DeclaringType?.Name + "." + patchedMethod.Name));
		}
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Better UX loaded.");
	}
}
public static class SuppressLaunchInvitePatch
{
	private static bool declinedFirstInvite;

	public static void Apply(Harmony harmony)
	{
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Expected O, but got Unknown
		Assembly assembly = null;
		Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
		foreach (Assembly assembly2 in assemblies)
		{
			if (assembly2.GetName().Name == "Assembly-CSharp")
			{
				assembly = assembly2;
				break;
			}
		}
		if (assembly == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] Assembly-CSharp not found — launch invite suppression skipped.");
			return;
		}
		Type type = assembly.GetType("TFBGames.SocialProfileService");
		if (type == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] SocialProfileService not found — launch invite suppression skipped.");
			return;
		}
		MethodInfo method = type.GetMethod("SetState", BindingFlags.Instance | BindingFlags.NonPublic);
		if (method == null)
		{
			Debug.LogWarning((object)"[TABSUXMod] SocialProfileService.SetState not found — launch invite suppression skipped.");
			return;
		}
		MethodInfo method2 = typeof(SuppressLaunchInvitePatch).GetMethod("SetStatePrefix", BindingFlags.Static | BindingFlags.NonPublic);
		harmony.Patch((MethodBase)method, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		Debug.Log((object)"[TABSUXMod] Launch invite suppression active (first invite of the session will be auto-declined).");
	}

	private static bool SetStatePrefix(ref object __0)
	{
		if (declinedFirstInvite)
		{
			return true;
		}
		int num = Convert.ToInt32(__0);
		if (num == 1 || num == 2)
		{
			declinedFirstInvite = true;
			Debug.Log((object)("[TABSUXMod] Auto-declined spurious launch invite (redirected SetState(" + num + ") to Idle). Later invites are untouched."));
			__0 = Enum.ToObject(__0.GetType(), 0);
		}
		return true;
	}
}