Decompiled source of BigBag v1.0.3

BepInEx/plugins/FateArth/FateArth.BigBagPlugin.dll

Decompiled 2 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("FateArth.BigBagPlugin")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2")]
[assembly: AssemblyProduct("大背包")]
[assembly: AssemblyTitle("FateArth.BigBagPlugin")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 BigBagPlugin
{
	[HarmonyPatch]
	public class BigBagPatch : MonoBehaviour
	{
		[HarmonyPatch(typeof(PlayerInventory), "OnNetworkSpawn")]
		[HarmonyPrefix]
		private static void Prefix1(PlayerInventory __instance)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Expected O, but got Unknown
			__instance.maxSlots = Plugin.configBagCount.Value;
			HorizontalLayoutGroup component = __instance.itemSlots.GetComponent<HorizontalLayoutGroup>();
			Object.DestroyImmediate((Object)(object)component);
			RectTransform component2 = __instance.itemSlots.GetComponent<RectTransform>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				component2.anchorMin = new Vector2(0f, 0f);
				component2.anchorMax = new Vector2(1f, 1f);
				component2.offsetMin = Vector2.zero;
				component2.offsetMax = Vector2.zero;
			}
			GridLayoutGroup val = __instance.itemSlots.AddComponent<GridLayoutGroup>();
			if (Object.op_Implicit((Object)(object)val))
			{
				val.cellSize = new Vector2(64f, 64f);
				val.spacing = new Vector2(8f, 8f);
				val.startCorner = (Corner)0;
				val.constraint = (Constraint)0;
				((LayoutGroup)val).childAlignment = (TextAnchor)8;
				((LayoutGroup)val).padding = new RectOffset(16, 16, 16, 16);
			}
		}

		[HarmonyPatch(typeof(PlayerInventory), "CheckBag")]
		[HarmonyPrefix]
		private static void Prefix2(PlayerInventory __instance)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			ItemSO itemById = GameManager.Instance.GetItemById(__instance.slots[0].itemId);
			BagSO val = (BagSO)(object)((itemById is BagSO) ? itemById : null);
			if (val != null && val.activeSlots == 6)
			{
				val.activeSlots = Plugin.configBagCount.Value;
			}
		}
	}
	[BepInPlugin("FateArth.BigBagPlugin", "大背包", "1.0.2")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		internal static Harmony harmony;

		public static ConfigEntry<int> configBagCount;

		private void Awake()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			configBagCount = ((BaseUnityPlugin)this).Config.Bind<int>("General", "背包大小", 11, "修改背包格子数量,默认初始11(一行铺满为26)");
			Logger = ((BaseUnityPlugin)this).Logger;
			harmony = new Harmony("FateArth.BigBagPlugin");
			harmony.PatchAll();
			Logger.LogInfo((object)"Plugin FateArth.BigBagPlugin is loaded!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "FateArth.BigBagPlugin";

		public const string PLUGIN_NAME = "大背包";

		public const string PLUGIN_VERSION = "1.0.2";
	}
}