Decompiled source of SpookySort v1.0.0

SpookySort.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Landfall.TABS;
using Landfall.TABS.Workshop;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SpookySort")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("GeeztJeez")]
[assembly: AssemblyProduct("SpookySort")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7acfaef0-7669-4401-8bff-5a9a02e18c75")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace SpookySort;

[BepInPlugin("GeeztJeez.SpookySort", "SpookySort", "1.0.0")]
internal class Loader : BaseUnityPlugin
{
	public class UnitCostComparer : IComparer
	{
		public int Compare(object x, object y)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			uint unitCost = ((UnitBlueprint)x).GetUnitCost(true);
			uint unitCost2 = ((UnitBlueprint)y).GetUnitCost(true);
			if (unitCost < unitCost2)
			{
				return -1;
			}
			if (unitCost > unitCost2)
			{
				return 1;
			}
			return 0;
		}
	}

	private void Awake()
	{
		((MonoBehaviour)this).StartCoroutine("Call");
	}

	private IEnumerator Call()
	{
		yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)Object.FindObjectOfType<ServiceLocator>() != (Object)null));
		yield return (object)new WaitUntil((Func<bool>)(() => ServiceLocator.GetService<ISaveLoaderService>() != null));
		yield return (object)new WaitForSeconds(0.01f);
		Debug.Log((object)"Loading SpookySort!");
		new Harmony("SpookySort").PatchAll();
		Faction[] array = Resources.FindObjectsOfTypeAll<Faction>();
		for (int i = 0; i < array.Length; i++)
		{
			if (array[i].Entity.Name == "FACTION_HALLOWEEN")
			{
				Array.Sort(array[i].Units, new UnitCostComparer());
			}
			array[i].ValidateFactionUnitPropsAndWeapons();
		}
		ServiceLocator.GetService<CustomContentLoaderModIO>().QuickRefresh((WorkshopContentType)5, (Action)null);
		Debug.Log((object)"Successfully sorted Spooky faction!");
	}
}