using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Hamunii")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A lethal company mod which allows the use of the jetpack while holding a two handed item.")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2")]
[assembly: AssemblyProduct("JetpacksCarryBigItems")]
[assembly: AssemblyTitle("JetpacksCarryBigItems")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.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;
}
}
}
namespace JetpacksCarryBigItems
{
[BepInPlugin("JetpacksCarryBigItems", "JetpacksCarryBigItems", "1.0.2")]
public class JetpacksCarryBigItems : BaseUnityPlugin
{
public static Harmony _harmony;
private void Awake()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin JetpacksCarryBigItems is loaded!");
_harmony = new Harmony("JetpacksCarryBigItems");
_harmony.PatchAll(typeof(Patches));
}
}
internal class Patches
{
private static int twoHandedItemIdx;
private static bool playerHasTwoHandedItemInInventoryButIsCurrentlyOnJetpackItem;
[HarmonyPatch(typeof(PlayerControllerB), "ScrollMouse_performed")]
[HarmonyPostfix]
private static void PlayerControllerB_ScrollMouse_performed_Postfix(ref PlayerControllerB __instance)
{
if (__instance.inTerminalMenu || ((!((NetworkBehaviour)__instance).IsOwner || !__instance.isPlayerControlled || (((NetworkBehaviour)__instance).IsServer && !__instance.isHostPlayerObject)) && !__instance.isTestingPlayer) || __instance.isGrabbingObjectAnimation || __instance.quickMenuManager.isMenuOpen || __instance.inSpecialInteractAnimation || __instance.throwingObject || __instance.isTypingChat || __instance.activatingItem || __instance.jetpackControls || __instance.disablingJetpackControls)
{
return;
}
if (playerHasTwoHandedItemInInventoryButIsCurrentlyOnJetpackItem)
{
playerHasTwoHandedItemInInventoryButIsCurrentlyOnJetpackItem = false;
SwitchItemSlots(twoHandedItemIdx, ref __instance);
}
else
{
if (!((Object)(object)__instance.currentlyHeldObjectServer != (Object)null) || !__instance.currentlyHeldObjectServer.itemProperties.twoHanded)
{
return;
}
twoHandedItemIdx = __instance.currentItemSlot;
int num = 0;
GrabbableObject[] itemSlots = __instance.ItemSlots;
for (int i = 0; i < itemSlots.Length; i++)
{
if (itemSlots[i] is JetpackItem)
{
playerHasTwoHandedItemInInventoryButIsCurrentlyOnJetpackItem = true;
SwitchItemSlots(num, ref __instance);
break;
}
num++;
}
}
}
private static void SwitchItemSlots(int destination, ref PlayerControllerB __instance)
{
int i = __instance.currentItemSlot - destination;
bool flag = i > 0;
if (Math.Abs(i) == __instance.ItemSlots.Length - 1)
{
__instance.SwitchItemSlotsServerRpc(flag);
}
else
{
for (; i != 0; i += ((!flag) ? 1 : (-1)))
{
__instance.SwitchItemSlotsServerRpc(!flag);
}
}
ShipBuildModeManager.Instance.CancelBuildMode(true);
__instance.playerBodyAnimator.SetBool("GrabValidated", false);
__instance.SwitchToItemSlot(destination, (GrabbableObject)null);
((Component)__instance.currentlyHeldObjectServer).gameObject.GetComponent<AudioSource>().PlayOneShot(__instance.currentlyHeldObjectServer.itemProperties.grabSFX, 0.6f);
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "JetpacksCarryBigItems";
public const string PLUGIN_NAME = "JetpacksCarryBigItems";
public const string PLUGIN_VERSION = "1.0.2";
}
}