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 EnhancedScrollWheel.Extensions;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;
[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("EnhancedScrollWheel")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Enhanced Scroll Wheel")]
[assembly: AssemblyTitle("EnhancedScrollWheel")]
[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 EnhancedScrollWheel
{
[BepInPlugin("EnhancedScrollWheel", "Enhanced Scroll Wheel", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private readonly Harmony m_Harmony = new Harmony("EnhancedScrollWheel");
private GameObject m_ChildGameObject;
internal static ManualLogSource Logger { get; private set; }
internal static SceneRaycaster Raycaster { get; private set; }
private void Awake()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
Settings.Instance.Load(this);
if (m_ChildGameObject == null)
{
m_ChildGameObject = new GameObject("EnhancedScrollWheel+Internal Mods");
}
m_ChildGameObject.transform.parent = ((Component)this).gameObject.transform;
Raycaster = m_ChildGameObject.AddComponent<SceneRaycaster>();
SceneManager.sceneLoaded += delegate(Scene scene, LoadSceneMode _)
{
if (((Scene)(ref scene)).name == "Start")
{
((Behaviour)CSingleton<ScrollWheeler>.Instance).enabled = Settings.Instance.isEnhancedScrollWheelEnabled.Value;
}
else
{
((Behaviour)Raycaster).enabled = false;
}
};
m_Harmony.PatchAll();
Logger.LogInfo((object)"Plugin EnhancedScrollWheel v:1.0.0 by GhostNarwhal is loaded!");
}
private void OnDestroy()
{
if (m_ChildGameObject != null)
{
Object.Destroy((Object)(object)m_ChildGameObject);
}
m_Harmony.UnpatchSelf();
Logger.LogInfo((object)"Plugin Enhanced Scroll Wheel is unloaded!");
}
}
public class SceneRaycaster : MonoBehaviour
{
private List<Type> m_ItemCompartmentTypeList = new List<Type>();
public Component RaycastedComponent { get; private set; }
private void Awake()
{
((Behaviour)this).enabled = false;
}
private void OnEnable()
{
m_ItemCompartmentTypeList.Add(typeof(InteractableCard3d));
m_ItemCompartmentTypeList.Add(typeof(CardShelf));
m_ItemCompartmentTypeList.Add(typeof(InteractableCardCompartment));
m_ItemCompartmentTypeList.Add(typeof(InteractablePackagingBox_Item));
m_ItemCompartmentTypeList.Add(typeof(ShelfCompartment));
m_ItemCompartmentTypeList.Add(typeof(InteractableTrashBin));
m_ItemCompartmentTypeList.Add(typeof(InteractableWorkbench));
}
private void OnDisable()
{
m_ItemCompartmentTypeList.Clear();
RaycastedComponent = null;
}
private void FixedUpdate()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: 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)
Camera val = CSingleton<InteractionPlayerController>.Instance?.m_Cam;
Ray val2 = default(Ray);
((Ray)(ref val2))..ctor(((Component)val).transform.position, ((Component)val).transform.forward);
int mask = LayerMask.GetMask(new string[4] { "UI", "Physics", "ItemCompartment", "ShopModel" });
RaycastHit val3 = default(RaycastHit);
RaycastedComponent = (Physics.Raycast(val2, ref val3, CSingleton<InteractionPlayerController>.Instance.m_RayDistance, mask) ? (from component in ((Component)((RaycastHit)(ref val3)).transform).gameObject.GetComponents<Component>()
where m_ItemCompartmentTypeList.Contains(((object)component).GetType())
select component).FirstOrDefault() : null);
}
public void OnBinderOpen()
{
RaycastedComponent = null;
((Behaviour)this).enabled = false;
}
public void OnBinderClose()
{
((Behaviour)this).enabled = true;
}
}
public class ScrollWheeler : CSingleton<ScrollWheeler>
{
private void Awake()
{
Settings.Instance.isEnhancedScrollWheelEnabled.SettingChanged += delegate
{
((Behaviour)this).enabled = Settings.Instance.isEnhancedScrollWheelEnabled.Value;
};
((Behaviour)this).enabled = false;
}
private void Update()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
if (UnityInput.Current.mouseScrollDelta.y > 0f)
{
OnScrollWheel(placingItem: true);
}
if (UnityInput.Current.mouseScrollDelta.y < 0f)
{
OnScrollWheel(placingItem: false);
}
}
private void OnEnable()
{
((Behaviour)Plugin.Raycaster).enabled = true;
}
private void OnDisable()
{
((Behaviour)Plugin.Raycaster).enabled = false;
}
public void EnterNonRaystateMode()
{
if (((Behaviour)this).enabled)
{
((Behaviour)Plugin.Raycaster).enabled = false;
}
}
public void ExitNonRaystateMode()
{
if (((Behaviour)this).enabled)
{
((Behaviour)Plugin.Raycaster).enabled = true;
}
}
private void OnScrollWheel(bool placingItem)
{
InteractablePackagingBox_Item packagingBox = CSingleton<InteractionPlayerController>.Instance.GetCurrentHeldBox();
int heldCardCount = CSingleton<InteractionPlayerController>.Instance.GetHeldCards().Count;
int heldItemCount = CSingleton<InteractionPlayerController>.Instance.GetHeldItemList().Count;
Component raycastedComponent = Plugin.Raycaster.RaycastedComponent;
if (raycastedComponent == null)
{
goto IL_0214;
}
ShelfCompartment val = default(ShelfCompartment);
ref ShelfCompartment reference = ref val;
Component obj = raycastedComponent;
reference = (ShelfCompartment)(object)((obj is ShelfCompartment) ? obj : null);
Action action;
if (val != null && packagingBox != null)
{
action = delegate
{
if (placingItem)
{
packagingBox.DispenseItem(true, val);
}
else
{
packagingBox.RemoveItemFromShelf(true, val);
}
};
}
else
{
ShelfCompartment val2 = default(ShelfCompartment);
ref ShelfCompartment reference2 = ref val2;
Component obj2 = raycastedComponent;
reference2 = (ShelfCompartment)(object)((obj2 is ShelfCompartment) ? obj2 : null);
if (val2 != null && val2.m_CanPutBox && !placingItem)
{
action = delegate
{
((InteractableObject)((Component)val2).gameObject.GetComponent<InteractableStorageCompartment>()).OnMouseButtonUp();
};
}
else
{
InteractablePackagingBox_Item val3 = default(InteractablePackagingBox_Item);
ref InteractablePackagingBox_Item reference3 = ref val3;
Component obj3 = raycastedComponent;
reference3 = (InteractablePackagingBox_Item)(object)((obj3 is InteractablePackagingBox_Item) ? obj3 : null);
if (val3 != null && packagingBox != null)
{
action = delegate
{
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: 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_010d: Unknown result type (might be due to invalid IL or missing references)
if (!((InteractablePackagingBox)val3).IsBoxOpened())
{
((InteractablePackagingBox)val3).OnPressOpenBox();
}
else if (!((InteractablePackagingBox)packagingBox).IsBoxOpened())
{
((InteractablePackagingBox)packagingBox).OnPressOpenBox();
}
else
{
InteractablePackagingBox_Item val7 = (placingItem ? val3 : packagingBox);
InteractablePackagingBox_Item val8 = (placingItem ? packagingBox : val3);
Item lastItem = val8.m_ItemCompartment.GetLastItem();
if (lastItem != null && (val7.m_ItemCompartment.GetItemType() == val8.m_ItemCompartment.GetItemType() || val7.m_ItemCompartment.GetItemCount() == 0))
{
lastItem.LerpToTransform(val7.m_ItemCompartment.GetLastEmptySlotTransform(), val7.m_ItemCompartment.GetLastEmptySlotTransform().parent, false);
val7.m_ItemCompartment.SetCompartmentItemType(val8.m_ItemCompartment.GetItemType());
val7.m_ItemCompartment.AddItem(lastItem, false);
val8.m_ItemCompartment.RemoveItem(lastItem);
val7.m_ItemCompartment.SetPriceTagItemImage(val8.GetItemType());
val7.m_ItemCompartment.SetPriceTagVisibility(false);
val7.m_ItemCompartment.RefreshPriceTagItemPriceText();
}
}
};
}
else if (raycastedComponent is InteractableTrashBin && packagingBox != null && placingItem)
{
action = delegate
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
if (packagingBox.m_ItemCompartment.GetItemCount() > 0)
{
((UIScreenBase)CSingleton<InteractionPlayerController>.Instance.m_ConfirmTrashScreen).OpenScreen();
}
else
{
((InteractableTrashBin)Plugin.Raycaster.RaycastedComponent).DiscardBox((InteractablePackagingBox)(object)packagingBox, true);
}
};
}
else
{
InteractableWorkbench val4 = default(InteractableWorkbench);
ref InteractableWorkbench reference4 = ref val4;
Component obj4 = raycastedComponent;
reference4 = (InteractableWorkbench)(object)((obj4 is InteractableWorkbench) ? obj4 : null);
if (val4 != null && packagingBox != null)
{
action = delegate
{
if (placingItem)
{
val4.DispenseItemFromBox(packagingBox, true);
}
else
{
val4.RemoveItemFromShelf(true, packagingBox);
}
};
}
else
{
InteractableCardCompartment val5 = default(InteractableCardCompartment);
ref InteractableCardCompartment reference5 = ref val5;
Component obj5 = raycastedComponent;
reference5 = (InteractableCardCompartment)(object)((obj5 is InteractableCardCompartment) ? obj5 : null);
if (val5 != null)
{
action = delegate
{
if (placingItem && heldCardCount > 0)
{
val5.OnMouseButtonUp();
}
else if (!placingItem)
{
val5.OnRightMouseButtonUp();
}
};
}
else
{
CardShelf val6 = default(CardShelf);
ref CardShelf reference6 = ref val6;
Component obj6 = raycastedComponent;
reference6 = (CardShelf)(object)((obj6 is CardShelf) ? obj6 : null);
if (val6 == null)
{
goto IL_0214;
}
action = delegate
{
foreach (InteractableCardCompartment cardCompartment in val6.GetCardCompartmentList())
{
if (placingItem && heldCardCount > 0 && cardCompartment.m_StoredCardList.Count == 0)
{
cardCompartment.OnMouseButtonUp();
break;
}
if (!placingItem && cardCompartment.m_StoredCardList.Count > 0)
{
cardCompartment.OnRightMouseButtonUp();
break;
}
}
};
}
}
}
}
}
goto IL_0226;
IL_0226:
action();
return;
IL_0214:
action = delegate
{
if (raycastedComponent != null && placingItem && heldItemCount > 0)
{
CSingleton<InteractionPlayerController>.Instance.PutItemOnShelf();
}
else if (raycastedComponent != null && !placingItem && packagingBox == null)
{
CSingleton<InteractionPlayerController>.Instance.TakeItemFromShelf();
}
};
goto IL_0226;
}
}
public class Settings
{
public ConfigEntry<bool> isEnhancedScrollWheelEnabled;
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
isEnhancedScrollWheelEnabled = ((BaseUnityPlugin)plugin).Config.Bind<bool>("Enhanced ScrollWheel", "Enabled", true, new ConfigDescription("Enables or disables Scroll Wheeler", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 20
}
}));
}
private Settings()
{
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "EnhancedScrollWheel";
public const string PLUGIN_NAME = "Enhanced Scroll Wheel";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace EnhancedScrollWheel.Patches
{
[HarmonyPatch(typeof(CollectionBinderFlipAnimCtrl))]
public class CollectionBinderFlipAnimCtrlPatch
{
[HarmonyPatch("StartShowCardAlbum")]
[HarmonyPostfix]
private static void StartShowCardAlbumPostfix()
{
CSingleton<ScrollWheeler>.Instance.EnterNonRaystateMode();
}
[HarmonyPatch("HideCardAlbum")]
[HarmonyPostfix]
private static void HideCardAlbumPostfix()
{
CSingleton<ScrollWheeler>.Instance.ExitNonRaystateMode();
}
}
[HarmonyPatch(typeof(InteractionPlayerController))]
public class InteractionPlayerControllerPatch
{
[HarmonyPatch("EnterUIMode")]
[HarmonyPostfix]
private static void EnterUIModePostfix()
{
CSingleton<ScrollWheeler>.Instance.EnterNonRaystateMode();
}
[HarmonyPatch("ExitUIMode")]
[HarmonyPostfix]
private static void ExitUIModePostfix()
{
CSingleton<ScrollWheeler>.Instance.ExitNonRaystateMode();
}
[HarmonyPatch("OnEnterCashCounterMode")]
[HarmonyPostfix]
private static void OnEnterCashCounterModePostfix(InteractableCashierCounter cashierCounter)
{
CSingleton<ScrollWheeler>.Instance.EnterNonRaystateMode();
}
[HarmonyPatch("OnExitCashCounterMode")]
[HarmonyPostfix]
private static void OnExitCashCounterModePostfix()
{
CSingleton<ScrollWheeler>.Instance.ExitNonRaystateMode();
}
[HarmonyPatch("OnEnterMoveObjectMode")]
[HarmonyPostfix]
private static void OnEnterMoveObjectModePostfix()
{
CSingleton<ScrollWheeler>.Instance.EnterNonRaystateMode();
}
[HarmonyPatch("OnExitMoveObjectMode")]
[HarmonyPostfix]
private static void OnExitMoveObjectModePostfix()
{
CSingleton<ScrollWheeler>.Instance.ExitNonRaystateMode();
}
[HarmonyPatch("OnEnterOpenPackState")]
[HarmonyPostfix]
private static void OnEnterOpenPackStatePostfix()
{
CSingleton<ScrollWheeler>.Instance.EnterNonRaystateMode();
}
[HarmonyPatch("OnExitOpenPackState")]
[HarmonyPostfix]
private static void OnExitOpenPackStatePostfix()
{
CSingleton<ScrollWheeler>.Instance.ExitNonRaystateMode();
}
[HarmonyPatch("OnEnterPhoneScreenMode")]
[HarmonyPostfix]
private static void OnEnterPhoneScreenModePostfix()
{
CSingleton<ScrollWheeler>.Instance.EnterNonRaystateMode();
}
[HarmonyPatch("OnExitPhoneScreenMode")]
[HarmonyPostfix]
private static void OnExitPhoneScreenModePostfix()
{
CSingleton<ScrollWheeler>.Instance.EnterNonRaystateMode();
}
[HarmonyPatch("OnEnterWorkbenchMode")]
[HarmonyPostfix]
private static void OnEnterWorkbenchModePostfix()
{
CSingleton<ScrollWheeler>.Instance.EnterNonRaystateMode();
}
[HarmonyPatch("OnExitWorkbenchMode")]
[HarmonyPostfix]
private static void OnExitWorkbenchModePostfix()
{
CSingleton<ScrollWheeler>.Instance.ExitNonRaystateMode();
}
}
}
namespace EnhancedScrollWheel.Extensions
{
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 InteractablePackagingBox_Item GetCurrentHeldBox(this InteractionPlayerController playerController)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
return (InteractablePackagingBox_Item)AccessTools.Field(typeof(InteractionPlayerController), "m_CurrentHoldingItemBox").GetValue(playerController);
}
public static List<Item> GetHeldItemList(this InteractionPlayerController playerController)
{
return (List<Item>)AccessTools.Field(typeof(InteractionPlayerController), "m_HoldItemList").GetValue(playerController);
}
public static void PutItemOnShelf(this InteractionPlayerController playerController)
{
AccessTools.Method(typeof(InteractionPlayerController), "EvaluatePutItemOnShelf", (Type[])null, (Type[])null).Invoke(playerController, null);
}
public static void TakeItemFromShelf(this InteractionPlayerController playerController)
{
AccessTools.Method(typeof(InteractionPlayerController), "EvaluateTakeItemFromShelf", (Type[])null, (Type[])null).Invoke(playerController, null);
}
}
}