using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Photon.Pun;
using UnityEngine;
using Zorro.Core;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("OpenSlots")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("OpenSlots")]
[assembly: AssemblyTitle("OpenSlots")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace OpenSlots;
internal static class Extensions
{
internal static ItemInstanceData CopyBackpackData(this ItemInstanceData src)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
ItemInstanceData val = new ItemInstanceData(Guid.NewGuid());
ItemInstanceDataHandler.AddInstanceData(val);
BackpackData val2 = default(BackpackData);
if (src == null || !src.TryGetDataEntry<BackpackData>((DataEntryKey)7, ref val2))
{
return val;
}
BackpackData val3 = val.RegisterNewEntry<BackpackData>((DataEntryKey)7);
val3.litRocketData = val2.litRocketData;
BackpackData val5 = default(BackpackData);
for (byte b = 0; b < val2.itemSlots.Length; b++)
{
ItemSlot val4 = val2.itemSlots[b];
if (val4 != null && !val4.IsEmpty() && !((Object)(object)val4.prefab == (Object)null))
{
ItemInstanceData val6;
if (val4.data != null && val4.data.TryGetDataEntry<BackpackData>((DataEntryKey)7, ref val5))
{
val6 = val4.data.CopyBackpackData();
}
else
{
val6 = (ItemInstanceData)((val4.data != null) ? ((object)val4.data.Copy()) : ((object)new ItemInstanceData(Guid.NewGuid())));
ItemInstanceDataHandler.AddInstanceData(val6);
}
val3.AddItem(val4.prefab, val6, b);
}
}
return val;
}
internal static ItemSlot GetSlot(this BackpackData bp, ItemInstanceData data)
{
ItemSlot[] itemSlots = bp.itemSlots;
foreach (ItemSlot val in itemSlots)
{
if (val != null && val.data == data)
{
return val;
}
}
return null;
}
}
[BepInPlugin("coolchair.openslots", "Open Slots", "1.0.0")]
internal class Loader : BaseUnityPlugin
{
internal const string GUID = "coolchair.openslots";
internal const string Name = "Open Slots";
internal const string Version = "1.0.0";
internal static Harmony harmony;
internal static ManualLogSource logger;
private void Awake()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
((BaseUnityPlugin)this).Logger.LogDebug((object)"Started OpenSlots mod");
logger = ((BaseUnityPlugin)this).Logger;
harmony = new Harmony("coolchair.openslots");
harmony.PatchAll();
((BaseUnityPlugin)this).Logger.LogDebug((object)"OpenSlots mod loaded succesfully!");
}
}
[HarmonyPatch(typeof(Item))]
internal static class ItemPatcher
{
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void UpdatePostfix(Item __instance)
{
ItemUIData uIData = __instance.UIData;
if (!uIData.canBackpack)
{
uIData.canBackpack = true;
}
if (!uIData.canDrop)
{
uIData.canDrop = true;
}
if (!uIData.canThrow)
{
uIData.canThrow = true;
}
if (!uIData.canPocket)
{
uIData.canPocket = true;
}
}
}
[HarmonyPatch(typeof(BackpackWheel))]
internal static class BackpackWheelPatch
{
[HarmonyPatch("Choose")]
[HarmonyPrefix]
private static bool Choose(BackpackWheel __instance, Optionable<SliceData> ___chosenSlice)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: 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)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
Loader.logger.LogDebug((object)"Got choose!");
if (!___chosenSlice.IsSome)
{
return true;
}
SliceData value = ___chosenSlice.Value;
if (value.isBackpackWear || value.isStashSlice || value.isJetpackFuelSlice)
{
return true;
}
if (!((BackpackReference)(ref value.backpackReference)).exists)
{
return true;
}
ItemSlot val = ((BackpackReference)(ref value.backpackReference)).GetData().itemSlots[value.slotID];
if (val == null || val.IsEmpty())
{
return true;
}
ItemInstanceData data = val.data;
BackpackData val2 = default(BackpackData);
if (data.TryGetDataEntry<BackpackData>((DataEntryKey)7, ref val2))
{
Loader.logger.LogDebug((object)"Choosed backpack!");
ItemInstanceData val3 = data.CopyBackpackData();
if (Player.localPlayer.HasEmptySlot(val.prefab.itemID))
{
ItemSlot val4 = default(ItemSlot);
Player.localPlayer.AddItem(val.prefab.itemID, val3, ref val4);
}
else
{
Transform transform = ((Component)Camera.main).transform;
GameObject val5 = PhotonNetwork.Instantiate("0_Items/" + val.GetPrefabName(), transform.position + transform.forward * 2f, Quaternion.identity, (byte)0, (object[])null);
((Item)val5.GetComponent<Backpack>()).data = val3;
((MonoBehaviourPun)val5.GetComponent<Backpack>()).photonView.RPC("SetItemInstanceDataRPC", (RpcTarget)0, new object[1] { val3 });
}
((BackpackReference)(ref value.backpackReference)).GetData().GetSlot(data).EmptyOut();
((MonoBehaviourPun)((Component)((BackpackReference)(ref value.backpackReference)).GetVisuals()).gameObject.GetComponent<Backpack>()).photonView.RPC("SetItemInstanceDataRPC", (RpcTarget)0, new object[1] { ((Item)((Component)((BackpackReference)(ref value.backpackReference)).GetVisuals()).gameObject.GetComponent<Backpack>()).data });
return false;
}
return true;
}
}