Decompiled source of BigBack v1.0.2

BepInEx/plugins/smolMods.BigBack.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using SmolMods.Core;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("smolMods.BigBack")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2+e4383d9039f31eeab0b2bd5a60119d741bff9f4a")]
[assembly: AssemblyProduct("smolMods.BigBack")]
[assembly: AssemblyTitle("smolMods.BigBack")]
[assembly: AssemblyVersion("1.0.2.0")]
[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 SmolMods.BigBack
{
	[BepInPlugin("com.smolmods.bigback", "smolMods.BigBack", "1.0.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BasePlugin
	{
		public const string PluginGuid = "com.smolmods.bigback";

		public const string PluginName = "smolMods.BigBack";

		public const string PluginVersion = "1.0.2";

		public const int RowOrder = 500;

		internal static ManualLogSource Logger;

		public override void Load()
		{
			//IL_0015: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Expected O, but got Unknown
			Logger = ((BasePlugin)this).Log;
			PocketsFeature.Register();
			Harmony val = new Harmony("com.smolmods.bigback");
			val.PatchAll(typeof(Plugin).Assembly);
			int num = 0;
			foreach (MethodBase patchedMethod in val.GetPatchedMethods())
			{
				_ = patchedMethod;
				num++;
			}
			ManualLogSource log = ((BasePlugin)this).Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(27, 3, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("smolMods.BigBack");
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("1.0.2");
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" loaded, ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" methods patched.");
			}
			log.LogInfo(val2);
		}
	}
	[HarmonyPatch]
	internal static class PocketsFeature
	{
		internal static ModRowDef Row;

		private static bool _enabled = true;

		private static readonly PropGroup[] Groups = (PropGroup[])(object)new PropGroup[2]
		{
			(PropGroup)25,
			(PropGroup)31
		};

		private static readonly Dictionary<PropGroup, HashSet<int>> Tagged = new Dictionary<PropGroup, HashSet<int>>
		{
			{
				(PropGroup)25,
				new HashSet<int>()
			},
			{
				(PropGroup)31,
				new HashSet<int>()
			}
		};

		internal static bool Enabled => _enabled;

		public static void Register()
		{
			Row = ModSettingsApi.AddArrayRow(500, "Big Backpack", "settings_mod_bigback_backpack", 1, new int[2] { 0, 1 }, (Func<int, string>)((int v) => (v != 1) ? "Off" : "On"), (Action<int>)delegate(int v)
			{
				bool flag = v == 1;
				if (flag != _enabled)
				{
					_enabled = flag;
					if (flag)
					{
						TagAll();
					}
					else
					{
						UntagAll();
					}
				}
			}, (Func<int, Color?>)null, false, false);
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Prop), "Start")]
		private static void Start_Postfix(Prop __instance)
		{
			if (_enabled)
			{
				Tag(__instance);
			}
		}

		private static void Tag(Prop prop)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				List<PropGroup> propGroups = prop.propGroups;
				if (propGroups == null)
				{
					return;
				}
				int instanceID = ((Object)prop).GetInstanceID();
				PropGroup[] groups = Groups;
				foreach (PropGroup val in groups)
				{
					if (!Contains(propGroups, val))
					{
						propGroups.Add(val);
						Tagged[val].Add(instanceID);
					}
				}
			}
			catch
			{
			}
		}

		private static void TagAll()
		{
			try
			{
				List<Prop> allProps = Prop.allProps;
				if (allProps == null)
				{
					return;
				}
				int count = allProps.Count;
				for (int i = 0; i < count; i++)
				{
					Prop val = allProps[i];
					if ((Object)(object)val != (Object)null)
					{
						Tag(val);
					}
				}
			}
			catch
			{
			}
		}

		private static void UntagAll()
		{
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			PropGroup[] groups;
			try
			{
				List<Prop> allProps = Prop.allProps;
				if (allProps != null)
				{
					int count = allProps.Count;
					for (int i = 0; i < count; i++)
					{
						Prop val = allProps[i];
						if ((Object)(object)val == (Object)null)
						{
							continue;
						}
						int instanceID = ((Object)val).GetInstanceID();
						List<PropGroup> propGroups = val.propGroups;
						if (propGroups == null)
						{
							continue;
						}
						groups = Groups;
						foreach (PropGroup val2 in groups)
						{
							if (!Tagged[val2].Contains(instanceID))
							{
								continue;
							}
							for (int num = propGroups.Count - 1; num >= 0; num--)
							{
								if (propGroups[num] == val2)
								{
									propGroups.RemoveAt(num);
								}
							}
						}
					}
				}
			}
			catch
			{
			}
			groups = Groups;
			foreach (PropGroup key in groups)
			{
				Tagged[key].Clear();
			}
		}

		private static bool Contains(List<PropGroup> groups, PropGroup g)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			int count = groups.Count;
			for (int i = 0; i < count; i++)
			{
				if (groups[i] == g)
				{
					return true;
				}
			}
			return false;
		}
	}
}