Decompiled source of FixHideLockedChoices v1.0.0

FixHideLockedChoices.dll

Decompiled 4 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using IL.RoR2.UI;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using RoR2;
using RoR2.UI;

[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("MajOfMyth")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+592fd5400362ed9931d9da4d073d45a46c06a77f")]
[assembly: AssemblyProduct("FixHideLockedChoices")]
[assembly: AssemblyTitle("FixHideLockedChoices")]
[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 FixHideLockedChoices
{
	[BepInPlugin("MajOfMyth.FixHideLockedChoices", "FixHideLockedChoices", "1.0.0")]
	public class FixHideLockedChoices : BaseUnityPlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Manipulator <0>__OnSetupGridVoteDisplayPopout;
		}

		private const string PluginGUID = "MajOfMyth.FixHideLockedChoices";

		private const string PluginAuthor = "MajOfMyth";

		private const string PluginName = "FixHideLockedChoices";

		private const string PluginVersion = "1.0.0";

		public void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__OnSetupGridVoteDisplayPopout;
			if (obj == null)
			{
				Manipulator val = OnSetupGridVoteDisplayPopout;
				<>O.<0>__OnSetupGridVoteDisplayPopout = val;
				obj = (object)val;
			}
			RuleCategoryController.SetupGridVoteDisplayPopout += (Manipulator)obj;
		}

		private static void OnSetupGridVoteDisplayPopout(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ILLabel val2 = il.DefineLabel();
			ILLabel val3 = il.DefineLabel();
			FieldReference val4 = default(FieldReference);
			if (val.TryGotoNext(new Func<Instruction, bool>[3]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 7),
				(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchStfld(x, ref val4)
			}))
			{
				val.Index += 4;
				val.Emit(OpCodes.Nop);
				val2.Target = val.Prev;
				val.Emit(OpCodes.Ldloc, 5);
				val.Emit(OpCodes.Ldloc_0);
				val.Emit(OpCodes.Ldfld, GetNestedFields(typeof(RuleCategoryController), "availability")[1]);
				val.Emit(OpCodes.Ldloc, 7);
				val.Emit(OpCodes.Ldfld, GetNestedFields(typeof(RuleCategoryController), "localChoiceIndex")[0]);
				val.EmitDelegate<Func<RuleDef, RuleChoiceMask, int, bool>>((Func<RuleDef, RuleChoiceMask, int, bool>)((RuleDef ruleDef, RuleChoiceMask availability, int localChoiceIndex) => ruleDef.hideLockedChoicesInLobby && !((SerializableBitArray)availability)[ruleDef.choices[localChoiceIndex].globalIndex]));
				val.Emit(OpCodes.Brtrue_S, (object)val3);
				val.GotoNext(new Func<Instruction, bool>[5]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 7),
					(Instruction x) => ILPatternMatchingExt.MatchLdfld(x, ref val4),
					(Instruction x) => ILPatternMatchingExt.MatchStloc(x, 9),
					(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 7),
					(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 9)
				});
				val.MarkLabel(val3);
				val.GotoNext(new Func<Instruction, bool>[3]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 7),
					(Instruction x) => ILPatternMatchingExt.MatchLdfld(x, ref val4),
					(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 6)
				});
				val.Index += 3;
				val.Next.Operand = val2;
			}
		}

		private static List<FieldInfo> GetNestedFields(Type type, string fieldName)
		{
			List<FieldInfo> list = new List<FieldInfo>();
			Type[] nestedTypes = type.GetNestedTypes((BindingFlags)(-1));
			foreach (Type type2 in nestedTypes)
			{
				list.AddRange(from field in type2.GetFields((BindingFlags)(-1))
					where field.Name.Contains(fieldName)
					select field);
			}
			return list;
		}
	}
}