Decompiled source of Choose Locker Contents v1.0.0

plugins/ChooseLockerContents/ChooseLockerContents.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Steamworks.Data;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ChooseLockerContents")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Choose Locker Contents")]
[assembly: AssemblyTitle("ChooseLockerContents")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ChooseLockerContents
{
	public class Patches
	{
		private static bool initialized;

		[HarmonyPatch(typeof(CL_Initializer), "Awake")]
		[HarmonyPostfix]
		private static void InitializerAwake()
		{
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: 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_012d: Unknown result type (might be due to invalid IL or missing references)
			if (!initialized)
			{
				GamemodeSetting val = Resources.FindObjectsOfTypeAll<GamemodeSetting>().First((GamemodeSetting x) => x.id == "ironknuckle");
				GamemodeSetting val2 = Resources.FindObjectsOfTypeAll<GamemodeSetting>().First((GamemodeSetting x) => x.id == "competitive");
				GamemodeSetting val3 = ScriptableObject.CreateInstance<GamemodeSetting>();
				val2.gamemodeButtonAsset.selectedHeight = 165;
				Transform[] array = (Transform[])(object)new Transform[2]
				{
					((Component)val2.gamemodeButtonAsset).transform.Find("Locker Settings/Locker 01"),
					((Component)val2.gamemodeButtonAsset).transform.Find("Locker Settings/Locker 02")
				};
				foreach (Transform obj in array)
				{
					((Component)obj.Find("Title")).gameObject.SetActive(false);
					Vector2 sizeDelta = ((Component)obj).GetComponent<RectTransform>().sizeDelta;
					((Component)obj).GetComponent<RectTransform>().sizeDelta = new Vector2(sizeDelta.x, sizeDelta.y - 15f);
				}
				val3.id = "locker";
				val3.title = "Preset Lockers";
				val3.description = "Choose Locker Contents";
				val3.color = val2.color;
				val3.unlock = Resources.FindObjectsOfTypeAll<ProgressionUnlock>().First((ProgressionUnlock x) => x.id == "r_hardmode");
				val3.exclusiveSettings = new List<string>(2) { val.id, val2.id };
				val3.nameAppend = "Preset Lockers";
				val3.leaderboardAppendID = "locker";
				val3.allowDownstream = false;
				val3.downstreamId = "";
				val3.gamemodeButtonAsset = val2.gamemodeButtonAsset;
				val.exclusiveSettings.Add(val3.id);
				val2.exclusiveSettings.Add(val3.id);
				Resources.FindObjectsOfTypeAll<M_Gamemode>().First((M_Gamemode x) => x.gamemodeName == "Campaign").gamemodeSettings.Add(val3);
				initialized = true;
			}
		}

		[HarmonyPatch(typeof(UI_Competitive_Settings), "OnSelect")]
		[HarmonyPostfix]
		private static void CompSettingsOnSelect(UI_Competitive_Settings __instance)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			Scene scene = ((Component)__instance).gameObject.scene;
			GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects();
			for (int i = 0; i < rootGameObjects.Length; i++)
			{
				UI_Competitive_Settings[] componentsInChildren = rootGameObjects[i].GetComponentsInChildren<UI_Competitive_Settings>();
				foreach (UI_Competitive_Settings val in componentsInChildren)
				{
					if (!((Object)(object)val == (Object)(object)__instance))
					{
						for (int k = 0; k < val.lockers.Count; k++)
						{
							val.PopulateItems(val.lockers[k], k);
						}
					}
				}
			}
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> GameManagerLoadIn(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			int num = list.FindIndex((CodeInstruction x) => CodeInstructionExtensions.Calls(x, AccessTools.Method(typeof(M_Gamemode), "IsCompetitive", (Type[])null, (Type[])null)));
			list.InsertRange(num + 1, new <>z__ReadOnlyArray<CodeInstruction>((CodeInstruction[])(object)new CodeInstruction[4]
			{
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(CL_GameManager), "GetBaseGamemode", (Type[])null, (Type[])null)),
				new CodeInstruction(OpCodes.Ldstr, (object)"locker"),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(M_Gamemode), "HasActiveSetting", (Type[])null, (Type[])null)),
				new CodeInstruction(OpCodes.Or, (object)null)
			}));
			return list.AsEnumerable();
		}
	}
	[HarmonyPatch]
	internal class LeaderboardUpdateScorePatch
	{
		public static MethodBase TargetMethod()
		{
			return AccessTools.Method(AccessTools.Method(typeof(Leaderboard_Panel), "UpdateScore", (Type[])null, (Type[])null).GetCustomAttribute<AsyncStateMachineAttribute>().StateMachineType, "MoveNext", (Type[])null, (Type[])null);
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			int index = list.FindIndex((CodeInstruction x) => CodeInstructionExtensions.Calls(x, AccessTools.PropertyGetter(typeof(Leaderboard?), "HasValue")));
			list.RemoveAt(index);
			list.InsertRange(index, new <>z__ReadOnlyArray<CodeInstruction>((CodeInstruction[])(object)new CodeInstruction[2]
			{
				new CodeInstruction(OpCodes.Pop, (object)null),
				new CodeInstruction(OpCodes.Ldc_I4_1, (object)null)
			}));
			return list.AsEnumerable();
		}
	}
	[BepInPlugin("ChooseLockerContents", "Choose Locker Contents", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		public static LightmapData black;

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Harmony.CreateAndPatchAll(typeof(Patches), (string)null);
			Harmony.CreateAndPatchAll(typeof(LeaderboardUpdateScorePatch), (string)null);
			Logger.LogInfo((object)"Patches applied");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "ChooseLockerContents";

		public const string PLUGIN_NAME = "Choose Locker Contents";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
[CompilerGenerated]
internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
	int ICollection.Count => _items.Length;

	bool ICollection.IsSynchronized => false;

	object ICollection.SyncRoot => this;

	object IList.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	bool IList.IsFixedSize => true;

	bool IList.IsReadOnly => true;

	int IReadOnlyCollection<T>.Count => _items.Length;

	T IReadOnlyList<T>.this[int index] => _items[index];

	int ICollection<T>.Count => _items.Length;

	bool ICollection<T>.IsReadOnly => true;

	T IList<T>.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	public <>z__ReadOnlyArray(T[] items)
	{
		_items = items;
	}

	IEnumerator IEnumerable.GetEnumerator()
	{
		return ((IEnumerable)_items).GetEnumerator();
	}

	void ICollection.CopyTo(Array array, int index)
	{
		((ICollection)_items).CopyTo(array, index);
	}

	int IList.Add(object value)
	{
		throw new NotSupportedException();
	}

	void IList.Clear()
	{
		throw new NotSupportedException();
	}

	bool IList.Contains(object value)
	{
		return ((IList)_items).Contains(value);
	}

	int IList.IndexOf(object value)
	{
		return ((IList)_items).IndexOf(value);
	}

	void IList.Insert(int index, object value)
	{
		throw new NotSupportedException();
	}

	void IList.Remove(object value)
	{
		throw new NotSupportedException();
	}

	void IList.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}

	IEnumerator<T> IEnumerable<T>.GetEnumerator()
	{
		return ((IEnumerable<T>)_items).GetEnumerator();
	}

	void ICollection<T>.Add(T item)
	{
		throw new NotSupportedException();
	}

	void ICollection<T>.Clear()
	{
		throw new NotSupportedException();
	}

	bool ICollection<T>.Contains(T item)
	{
		return ((ICollection<T>)_items).Contains(item);
	}

	void ICollection<T>.CopyTo(T[] array, int arrayIndex)
	{
		((ICollection<T>)_items).CopyTo(array, arrayIndex);
	}

	bool ICollection<T>.Remove(T item)
	{
		throw new NotSupportedException();
	}

	int IList<T>.IndexOf(T item)
	{
		return ((IList<T>)_items).IndexOf(item);
	}

	void IList<T>.Insert(int index, T item)
	{
		throw new NotSupportedException();
	}

	void IList<T>.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}
}