using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using TMPro;
using UnityEngine;
[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("ExtraInventorySlot")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.3")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ExtraInventorySlot")]
[assembly: AssemblyTitle("ExtraInventorySlot")]
[assembly: AssemblyVersion("1.0.3.0")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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 ExtraInventorySlot
{
[BepInPlugin("ExtraInventorySlot.nickklmao", "Extra Inventory Slot", "1.0.3")]
[ContentWarningPlugin("ExtraInventorySlot.nickklmao", "1.0.3", false)]
internal class Loader : BaseUnityPlugin
{
[CompilerGenerated]
private static class <>O
{
public static Manipulator <0>__TryAddItemHook;
public static Manipulator <1>__TryGetFreeSlotHook;
public static Manipulator <2>__CheckForIllegalItemsHook;
}
private static Loader instance;
private static int extraSlots;
private static void GameAPIAwakeHook(Action<GameAPI> orig, GameAPI self)
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
orig(self);
Transform val = ((Component)self).transform.Find("HelmetUI");
if (Object.op_Implicit((Object)(object)val))
{
Transform val2 = val.Find("Pivot/Others/Hotbar");
RectTransform component = ((Component)val2).GetComponent<RectTransform>();
Vector2 sizeDelta = component.sizeDelta;
sizeDelta.x = 1000f;
component.sizeDelta = sizeDelta;
((MonoBehaviour)instance).StartCoroutine(instance.SetPositionDelayed(component));
HotbarUI component2 = ((Component)val2).GetComponent<HotbarUI>();
Transform val3 = val2.Find("Items/HotbarSlot");
List<HotbarSlotUI> list = component2.slots.ToList();
for (int i = 0; i < extraSlots; i++)
{
Transform val4 = Object.Instantiate<Transform>(val3, val3.parent);
((TMP_Text)((Component)val4).GetComponentInChildren<TextMeshProUGUI>()).text = (4 + i).ToString();
list.Add(((Component)val4).GetComponent<HotbarSlotUI>());
}
component2.slots = list.ToArray();
}
}
private static void PlayerInventoryAwakeHook(Action<PlayerInventory> orig, PlayerInventory self)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
orig(self);
List<InventorySlot> list = self.slots.ToList();
for (int i = 0; i < extraSlots; i++)
{
list.Add(new InventorySlot(i + 4, self));
}
self.slots = list.ToArray();
}
private static void TryAddItemHook(ILContext context)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(context);
for (int i = 0; i < 2; i++)
{
val.GotoNext(new Func<Instruction, bool>[1]
{
(Instruction instruction) => ILPatternMatchingExt.MatchLdcI4(instruction, 3) && ILPatternMatchingExt.MatchLdfld(instruction.Previous, AccessTools.Field(typeof(PlayerInventory), "slots"))
});
val.Remove();
val.Emit(OpCodes.Ldc_I4, 3 + extraSlots);
}
val.GotoNext(new Func<Instruction, bool>[1]
{
(Instruction instruction) => ILPatternMatchingExt.MatchLdcI4(instruction, 3) && ILPatternMatchingExt.MatchCallvirt(instruction.Previous, (MethodBase)AccessTools.PropertyGetter(typeof(InventorySlot), "SlotID"))
});
val.Remove();
val.Emit(OpCodes.Ldc_I4, 3 + extraSlots);
}
private static void TryGetFreeSlotHook(ILContext context)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(context);
val.GotoNext(new Func<Instruction, bool>[1]
{
(Instruction instruction) => ILPatternMatchingExt.MatchLdcI4(instruction, 3)
});
val.Remove();
val.Emit(OpCodes.Ldc_I4, 3 + extraSlots);
}
private static void CheckForIllegalItemsHook(ILContext context)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(context);
val.GotoNext(new Func<Instruction, bool>[1]
{
(Instruction instruction) => ILPatternMatchingExt.MatchLdcI4(instruction, 3)
});
val.Remove();
val.Emit(OpCodes.Ldc_I4, 3 + extraSlots);
}
private IEnumerator SetPositionDelayed(RectTransform rectTransform)
{
yield return null;
Vector2 anchoredPosition = rectTransform.anchoredPosition;
anchoredPosition.x = 200f;
rectTransform.anchoredPosition = anchoredPosition;
}
private void Awake()
{
instance = this;
extraSlots = ((BaseUnityPlugin)this).Config.Bind<int>("Extra Inventory Slot", "Extra Slots", 1, "How many extra slots should there be? 0-5").Value;
extraSlots = Mathf.Clamp(extraSlots, 0, 5);
if (extraSlots != 0)
{
InitializeHooks();
}
}
private void InitializeHooks()
{
//IL_0029: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: 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_00b2: Expected O, but got Unknown
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Expected O, but got Unknown
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Expected O, but got Unknown
new Hook((MethodBase)AccessTools.Method(typeof(GameAPI), "Awake", (Type[])null, (Type[])null), AccessTools.Method(((object)this).GetType(), "GameAPIAwakeHook", (Type[])null, (Type[])null));
new Hook((MethodBase)AccessTools.Method(typeof(PlayerInventory), "Awake", (Type[])null, (Type[])null), AccessTools.Method(((object)this).GetType(), "PlayerInventoryAwakeHook", (Type[])null, (Type[])null));
MethodInfo methodInfo = AccessTools.Method(typeof(PlayerInventory), "TryAddItem", new Type[2]
{
typeof(ItemDescriptor),
typeof(InventorySlot).MakeByRefType()
}, (Type[])null);
object obj = <>O.<0>__TryAddItemHook;
if (obj == null)
{
Manipulator val = TryAddItemHook;
<>O.<0>__TryAddItemHook = val;
obj = (object)val;
}
new ILHook((MethodBase)methodInfo, (Manipulator)obj);
MethodInfo methodInfo2 = AccessTools.Method(typeof(PlayerInventory), "TryGetFeeSlot", (Type[])null, (Type[])null);
object obj2 = <>O.<1>__TryGetFreeSlotHook;
if (obj2 == null)
{
Manipulator val2 = TryGetFreeSlotHook;
<>O.<1>__TryGetFreeSlotHook = val2;
obj2 = (object)val2;
}
new ILHook((MethodBase)methodInfo2, (Manipulator)obj2);
MethodInfo methodInfo3 = AccessTools.Method(typeof(PhotonGameLobbyHandler), "CheckForIllegalItems", (Type[])null, (Type[])null);
object obj3 = <>O.<2>__CheckForIllegalItemsHook;
if (obj3 == null)
{
Manipulator val3 = CheckForIllegalItemsHook;
<>O.<2>__CheckForIllegalItemsHook = val3;
obj3 = (object)val3;
}
new ILHook((MethodBase)methodInfo3, (Manipulator)obj3);
}
}
}