using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
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 PutItBack.Extensions;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyCompany("PutItBack")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Put It Back")]
[assembly: AssemblyTitle("PutItBack")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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;
}
}
}
internal sealed class ConfigurationManagerAttributes
{
public delegate void CustomHotkeyDrawerFunc(ConfigEntryBase setting, ref bool isCurrentlyAcceptingInput);
public bool? ShowRangeAsPercent;
public Action<ConfigEntryBase> CustomDrawer;
public CustomHotkeyDrawerFunc CustomHotkeyDrawer;
public bool? Browsable;
public string Category;
public object DefaultValue;
public bool? HideDefaultButton;
public bool? HideSettingName;
public string Description;
public string DispName;
public int? Order;
public bool? ReadOnly;
public bool? IsAdvanced;
public Func<object, string> ObjToStr;
public Func<string, object> StrToObj;
}
namespace PutItBack
{
public class HeldCardData
{
public int BinderPageIndex { get; set; }
public int BinderCardSlotIndex { get; set; }
public CardData CardData { get; set; }
public Transform Transform { get; set; }
}
[BepInPlugin("PutItBack", "Put It Back", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
private readonly Harmony m_Harmony = new Harmony("PutItBack");
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Settings.Instance.Load(this);
m_Harmony.PatchAll();
Logger.LogInfo((object)"Plugin PutItBack v:1.0.0 by GhostNarwhal is loaded!");
}
private void OnDestroy()
{
m_Harmony.UnpatchSelf();
Logger.LogInfo((object)"Plugin Put It Back is unloaded!");
}
}
public class PutItBack : CSingleton<PutItBack>
{
private bool m_IsReturningCard;
private int m_CurrentBinderPageIndex;
private List<BinderPageGrp> m_BinderPageGrpList = new List<BinderPageGrp>();
private List<HeldCardData> m_HeldCardDataList = new List<HeldCardData>();
private List<Type> m_ItemCompartmentTypeList = new List<Type>();
private ECollectionSortingType m_SortingType;
private void Awake()
{
Settings.Instance.isPutItBackEnabled.SettingChanged += delegate
{
((Behaviour)this).enabled = Settings.Instance.isPutItBackEnabled.Value;
};
}
private void OnDisable()
{
m_HeldCardDataList.Clear();
}
public void OnUpdate(CollectionBinderFlipAnimCtrl collectionBinderFlipAnimCtrl)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: 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_0067: Unknown result type (might be due to invalid IL or missing references)
if (((Behaviour)this).enabled && collectionBinderFlipAnimCtrl.IsBookOpen())
{
m_CurrentBinderPageIndex = collectionBinderFlipAnimCtrl.GetCurrentBinderPageIndex();
m_BinderPageGrpList = collectionBinderFlipAnimCtrl.m_BinderPageGrpList;
m_SortingType = collectionBinderFlipAnimCtrl.GetSortingType();
if (UnityInput.Current.mouseScrollDelta.y > 0f && CSingleton<InteractionPlayerController>.Instance.GetHeldCards().Count > 0)
{
collectionBinderFlipAnimCtrl.OnMouseButtonUp();
}
if (UnityInput.Current.mouseScrollDelta.y < 0f)
{
collectionBinderFlipAnimCtrl.OnRightMouseButtonUp();
}
}
}
public bool OnRightMouseButtonUp(CollectionBinderFlipAnimCtrl collectionBinderFlipAnimCtrl)
{
if (((Behaviour)this).enabled && !m_IsReturningCard)
{
InteractableCard3d currentRaycastedInteractableCard3d = collectionBinderFlipAnimCtrl.m_CurrentRaycastedInteractableCard3d;
bool? flag = ((currentRaycastedInteractableCard3d != null) ? new bool?(currentRaycastedInteractableCard3d.m_Card3dUI.m_CardUI.GetCardData().IsOwned()) : null);
if (!flag.HasValue || !flag.Value)
{
return false;
}
if (InteractionPlayerController.HasEnoughSlotToHoldCard())
{
List<HeldCardData> heldCardDataList = m_HeldCardDataList;
HeldCardData obj = new HeldCardData
{
BinderCardSlotIndex = collectionBinderFlipAnimCtrl.GetRaycastedCardIndex(),
BinderPageIndex = collectionBinderFlipAnimCtrl.GetCurrentBinderPageIndex()
};
InteractableCard3d currentRaycastedInteractableCard3d2 = collectionBinderFlipAnimCtrl.m_CurrentRaycastedInteractableCard3d;
obj.CardData = ((currentRaycastedInteractableCard3d2 != null) ? currentRaycastedInteractableCard3d2.m_Card3dUI.m_CardUI.GetCardData() : null);
InteractableCard3d currentRaycastedInteractableCard3d3 = collectionBinderFlipAnimCtrl.m_CurrentRaycastedInteractableCard3d;
obj.Transform = ((currentRaycastedInteractableCard3d3 != null) ? ((Component)currentRaycastedInteractableCard3d3).transform : null);
heldCardDataList.Add(obj);
}
}
return true;
}
public bool OnLeftMouseButtonUp(CollectionBinderFlipAnimCtrl collectionBinderFlipAnimCtrl)
{
if (((Behaviour)this).enabled && !m_IsReturningCard && m_HeldCardDataList.Count > 0)
{
List<InteractableCard3d> heldCards = CSingleton<InteractionPlayerController>.Instance.GetHeldCards();
if (heldCards.Count > 0)
{
int num = m_HeldCardDataList.Last().BinderCardSlotIndex;
int num2 = m_HeldCardDataList.Last().BinderPageIndex - collectionBinderFlipAnimCtrl.GetCurrentBinderPageIndex();
int index = 0;
if (num2 <= -1)
{
if (num >= 6)
{
num -= 6;
}
index = 2;
}
else if (num2 >= 1)
{
if (num <= 5)
{
num += 6;
}
index = 1;
}
Transform transform = ((Component)collectionBinderFlipAnimCtrl.m_BinderPageGrpList[index].m_CardList[num]).transform;
((InteractableObject)heldCards.Last()).StopLerpToTransform();
((InteractableObject)heldCards.Last()).LerpToTransform(transform, transform.parent);
m_IsReturningCard = true;
return false;
}
}
return true;
}
public void OnCardFinishLerp(ref InteractableCard3d interactableCard3D)
{
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
if (!((Behaviour)this).enabled || !m_IsReturningCard)
{
return;
}
List<InteractableCard3d> heldCards = CSingleton<InteractionPlayerController>.Instance.GetHeldCards();
if (heldCards.Count > 0)
{
CPlayerData.AddCard(m_HeldCardDataList.Last().CardData, 1);
int num = m_HeldCardDataList.Last().BinderPageIndex - m_CurrentBinderPageIndex;
if (num >= -1 && num <= 1)
{
int index = ((num == -1) ? 2 : num);
int cardAmount = CPlayerData.GetCardAmount(m_HeldCardDataList.Last().CardData);
m_BinderPageGrpList[index].SetSingleCard(m_HeldCardDataList.Last().BinderCardSlotIndex, m_HeldCardDataList.Last().CardData, cardAmount, m_SortingType);
((Component)m_BinderPageGrpList[index].m_CardList[m_HeldCardDataList.Last().BinderCardSlotIndex]).gameObject.SetActive(true);
((Component)m_HeldCardDataList.Last().Transform).gameObject.SetActive(true);
}
((InteractableObject)heldCards.Last()).OnDestroyed();
heldCards.RemoveAt(heldCards.Count - 1);
m_HeldCardDataList.RemoveAt(m_HeldCardDataList.Count - 1);
CPlayerData.m_HoldCardDataList.RemoveAt(CPlayerData.m_HoldCardDataList.Count - 1);
SetHoldCardEularRotation(heldCards.Count);
m_IsReturningCard = false;
}
}
private void SetHoldCardEularRotation(int heldCardCount)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
Quaternion value = Quaternion.Euler(0f, 0f, 0f);
if (heldCardCount == 0)
{
CSingleton<InteractionPlayerController>.Instance.SetHoldCardGroupTargetRotation(value);
CSingleton<InteractionPlayerController>.Instance.EnterViewCardAlbumMode();
}
else
{
value = Quaternion.Euler(0f, 0f, Mathf.Lerp(0f, 15f, (float)heldCardCount / 7f));
CSingleton<InteractionPlayerController>.Instance.SetHoldCardGroupTargetRotation(value);
}
}
}
public class Settings
{
public ConfigEntry<bool> isPutItBackEnabled;
private static Settings m_instance;
public static Settings Instance
{
get
{
if (m_instance == null)
{
m_instance = new Settings();
}
return m_instance;
}
}
public void Load(Plugin plugin)
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
isPutItBackEnabled = ((BaseUnityPlugin)plugin).Config.Bind<bool>("Put It Back", "Enable", true, new ConfigDescription("Enables or disables put it back", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 20
}
}));
}
private Settings()
{
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "PutItBack";
public const string PLUGIN_NAME = "Put It Back";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace PutItBack.Patches
{
[HarmonyPatch(typeof(CollectionBinderFlipAnimCtrl))]
public class CollectionBinderFlipAnimCtrlPatches
{
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void OnUpdatePostfix(CollectionBinderFlipAnimCtrl __instance)
{
CSingleton<PutItBack>.Instance.OnUpdate(__instance);
}
[HarmonyPatch("OnMouseButtonUp")]
[HarmonyPrefix]
private static bool OnMouseButtonUpPrefix(CollectionBinderFlipAnimCtrl __instance)
{
return CSingleton<PutItBack>.Instance.OnLeftMouseButtonUp(__instance);
}
[HarmonyPatch("OnRightMouseButtonUp")]
[HarmonyPrefix]
private static bool OnRightMouseButtonUpPrefix(CollectionBinderFlipAnimCtrl __instance)
{
return CSingleton<PutItBack>.Instance.OnRightMouseButtonUp(__instance);
}
}
}
namespace PutItBack.Extensions
{
public static class CardDataExt
{
public static bool IsOwned(this CardData cardData)
{
return CPlayerData.GetCardAmount(cardData) > 0;
}
}
public static class CollectionBinderFlipAnimCtrlExt
{
public static ECollectionSortingType GetSortingType(this CollectionBinderFlipAnimCtrl collectionBinderFlipAnimCtrl)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
return (ECollectionSortingType)AccessTools.Field(typeof(CollectionBinderFlipAnimCtrl), "m_SortingType").GetValue(collectionBinderFlipAnimCtrl);
}
public static int GetCurrentBinderPageIndex(this CollectionBinderFlipAnimCtrl collectionBinderFlipAnimCtrl)
{
return (int)AccessTools.Field(typeof(CollectionBinderFlipAnimCtrl), "m_Index").GetValue(collectionBinderFlipAnimCtrl);
}
public static bool IsBookOpen(this CollectionBinderFlipAnimCtrl collectionBinderFlipAnimCtrl)
{
return (bool)AccessTools.Field(typeof(CollectionBinderFlipAnimCtrl), "m_IsBookOpen").GetValue(collectionBinderFlipAnimCtrl);
}
public static int GetRaycastedCardIndex(this CollectionBinderFlipAnimCtrl collectionBinderFlipAnimCtrl)
{
return (int)AccessTools.Field(typeof(CollectionBinderFlipAnimCtrl), "m_CurrentRaycastedCardIndex").GetValue(collectionBinderFlipAnimCtrl);
}
}
public static class InteractionPlayerControllerExt
{
public static List<InteractableCard3d> GetHeldCards(this InteractionPlayerController playerController)
{
return (List<InteractableCard3d>)AccessTools.Field(typeof(InteractionPlayerController), "m_CurrentHoldingCard3dList").GetValue(playerController);
}
public static void SetHoldCardGroupTargetRotation(this InteractionPlayerController playerController, Quaternion value)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
AccessTools.Field(typeof(InteractionPlayerController), "m_HoldCardGrpTargetRotation").SetValue(playerController, value);
}
}
[HarmonyPatch(typeof(InteractableCard3d))]
internal class InteractableCard3dPatches
{
[HarmonyPatch("OnFinishLerp")]
[HarmonyPostfix]
private static void OnFinishLerpPostfix(ref InteractableCard3d __instance)
{
CSingleton<PutItBack>.Instance.OnCardFinishLerp(ref __instance);
}
}
}