using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using GameNetcodeStuff;
using HarmonyLib;
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: AssemblyTitle("XiaohaiMOD_Slot")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("China")]
[assembly: AssemblyProduct("XiaohaiMOD_Slot")]
[assembly: AssemblyCopyright("Copyright © China 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b5bc4116-e7e5-42fb-9b32-c5ca0fa6a6d1")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace XiaohaiMOD_MoreSlot;
[BepInPlugin("Xiaohai.Plugin.Xiaohai_MoreSlot", "Xiaohai_MoreSlot", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
internal class SlotPatch
{
[HarmonyPatch(typeof(PlayerControllerB), "Awake")]
public static class PlayerControllerBAwakePatch
{
[HarmonyPostfix]
public static void Postfix(ref GrabbableObject[] ___ItemSlots)
{
if (Instance.slots.Value != 4)
{
___ItemSlots = (GrabbableObject[])(object)new GrabbableObject[Instance.slots.Value];
}
}
}
[HarmonyPatch(typeof(HUDManager), "Awake")]
public static class HudManagerAwakePatch
{
[HarmonyPostfix]
public static void Postfix(ref Image[] ___itemSlotIcons, ref Image[] ___itemSlotIconFrames)
{
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_0204: Unknown result type (might be due to invalid IL or missing references)
//IL_020b: Expected O, but got Unknown
GameObject val = Object.Instantiate<GameObject>(((Component)___itemSlotIconFrames[0]).gameObject);
Transform parent = ((Component)___itemSlotIconFrames[0]).transform.parent;
RectTransform component = ((Component)parent).GetComponent<RectTransform>();
((Transform)component).localScale = new Vector3(Mathf.Clamp(1f - (float)(Instance.slots.Value - 4) * 0.05f, 0.5f, 1f), Mathf.Clamp(1f - (float)(Instance.slots.Value - 4), 0.5f, 1f), 1f);
component.anchorMin = new Vector2(0.35f, 0f);
component.anchorMax = new Vector2(0.65f, 0.3f);
component.pivot = new Vector2(0.5f, 0f);
component.anchoredPosition = new Vector2(0f, 0f);
GridLayoutGroup val2 = ((Component)parent).gameObject.AddComponent<GridLayoutGroup>();
val2.spacing = new Vector2(15f, 15f);
val2.cellSize = new Vector2(50f, 50f);
((LayoutGroup)val2).childAlignment = (TextAnchor)7;
foreach (object item in parent)
{
Object.Destroy((Object)(object)((Component)item).gameObject);
}
parent.DetachChildren();
for (int i = 0; i < Instance.slots.Value; i++)
{
((Object)Object.Instantiate<GameObject>(val, parent)).name = $"Slot{i}";
}
Object.Destroy((Object)(object)val);
___itemSlotIcons = (Image[])(object)new Image[Instance.slots.Value];
___itemSlotIconFrames = (Image[])(object)new Image[Instance.slots.Value];
int num = 0;
foreach (object item2 in parent)
{
Transform val3 = (Transform)item2;
___itemSlotIcons[num] = ((Component)val3.GetChild(0)).GetComponent<Image>();
___itemSlotIconFrames[num] = ((Component)val3).GetComponent<Image>();
num++;
}
}
}
}
public ConfigEntry<int> slots;
private readonly Harmony harmony = new Harmony("xiaohai.plugin.XiaohaiMOD_MoreSlot");
public static Plugin Instance;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
((BaseUnityPlugin)this).Logger.LogInfo((object)"欢迎使用小海致命公司额外物品栏模组,当前版本为 Welcome to use Xiaohai's Custom Slot Quantity Mod(more slots),current version is:1.0.0");
slots = ((BaseUnityPlugin)this).Config.Bind<int>("Game", "物品槽数量 Slot Quantity", 4, "设置物品槽数量Input your slot quantity.");
harmony.PatchAll();
}
}