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 CG.Client;
using CG.Client.Player.Interactions;
using CG.Client.Ship.Interactions;
using CG.Game.Player;
using CG.Objects;
using CG.Space;
using Gameplay.Carryables;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Opsive.Shared.StateSystem;
using Opsive.UltimateCharacterController.Character;
using Opsive.UltimateCharacterController.Character.Abilities;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
using VoidManager;
using VoidManager.CustomGUI;
using VoidManager.MPModChecks;
using VoidManager.Utilities;
[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.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("Backpack")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Backpack")]
[assembly: AssemblyTitle("Allows the player to carry multiple items at the same time")]
[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;
}
}
}
namespace Backpack
{
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
internal class CarryableAttractorLinkPatch
{
private static void Postfix(CarryableObject carryable)
{
if (Common.backpackItems.Contains(carryable))
{
Common.RemoveItem(carryable);
}
}
}
internal class Common
{
internal static readonly Vector3[] backpackLocations = (Vector3[])(object)new Vector3[3]
{
new Vector3(0f, 1.3f, -0.35f),
new Vector3(0.5f, 1.3f, 0f),
new Vector3(-0.5f, 1.3f, 0f)
};
internal static readonly int backpackSize = backpackLocations.Length;
internal static List<CarryableObject> backpackItems = new List<CarryableObject>();
internal static void ButtonPressed(object o, EventArgs e)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Invalid comparison between Unknown and I4
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)LocalPlayer.Instance == (Object)null) && (int)Configs.ToggleBackpackItem.Value != 0 && UnityInput.Current.GetKeyDown(Configs.ToggleBackpackItem.Value))
{
if ((Object)(object)((Player)LocalPlayer.Instance).Payload != (Object)null)
{
StoreItem();
}
else
{
RetrieveItem();
}
}
}
private static void StoreItem()
{
if (VoidManagerPlugin.Enabled && backpackItems.Count < backpackSize)
{
if (backpackItems.Count == 0)
{
Events.Instance.LateUpdate += MoveItems;
}
CarryableObject payload = ((Player)LocalPlayer.Instance).Payload;
backpackItems.Add(payload);
((Player)LocalPlayer.Instance).TryReleaseCarryable();
((MonoBehaviourPun)payload).photonView.RequestOwnership();
payload.OwnerChange = (Action<Player>)Delegate.Combine(payload.OwnerChange, new Action<Player>(HandleTheft));
}
}
private static void RetrieveItem()
{
if (backpackItems.Count != 0)
{
CarryableObject val = ((!Configs.Stack.Value) ? backpackItems.First() : backpackItems.Last());
RemoveItem(val);
CharacterLocomotion character = ((Player)LocalPlayer.Instance).Character;
Ability obj = ((UltimateCharacterLocomotion)((character is CustomCharacterLocomotion) ? character : null)).Abilities.First((Ability ability) => ability is CarryableInteract);
CarryableInteract val2 = (CarryableInteract)(object)((obj is CarryableInteract) ? obj : null);
((MonoBehaviour)LocalPlayer.Instance).StartCoroutine(val2.DelayedPickupGrabable((AbstractInteractable)(object)((Component)val).GetComponent<GrabableObject>()));
}
}
internal static void RemoveItem(CarryableObject item)
{
if (backpackItems.Contains(item))
{
backpackItems.Remove(item);
item.OwnerChange = (Action<Player>)Delegate.Remove(item.OwnerChange, new Action<Player>(HandleTheft));
if (backpackItems.Count == 0)
{
Events.Instance.LateUpdate -= MoveItems;
}
}
}
internal static void MoveItems(object o, EventArgs e)
{
//IL_0018: 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)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: 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)
for (int i = 0; i < backpackItems.Count; i++)
{
CarryableObject val = backpackItems[i];
val.Position = ((Player)LocalPlayer.Instance).Position + ((Player)LocalPlayer.Instance).Rotation * backpackLocations[i];
val.Rotation = Quaternion.identity;
val.Velocity = ((Player)LocalPlayer.Instance).Velocity;
val.UseGravity = false;
}
}
private static void HandleTheft(Player player)
{
for (int num = backpackItems.Count - 1; num >= 0; num--)
{
CarryableObject val = backpackItems.ElementAt(num);
if (!((OrbitObject)val).AmOwner)
{
RemoveItem(val);
}
}
}
}
internal class Configs
{
internal static ConfigEntry<KeyCode> ToggleBackpackItem;
internal static ConfigEntry<bool> Stack;
internal static void Load(BepinPlugin plugin)
{
ToggleBackpackItem = ((BaseUnityPlugin)plugin).Config.Bind<KeyCode>("backpack", "toggleItem", (KeyCode)103, (ConfigDescription)null);
Stack = ((BaseUnityPlugin)plugin).Config.Bind<bool>("backpack", "isStack", true, (ConfigDescription)null);
}
}
internal class GUI : ModSettingsMenu
{
public override string Name()
{
return "Backpack";
}
public override void Draw()
{
GUITools.DrawChangeKeybindButton("Change backpack interact", ref Configs.ToggleBackpackItem);
if (GUILayout.Button(Configs.Stack.Value ? "Stack (first in - last out)" : "Queue (first in - first out)", Array.Empty<GUILayoutOption>()))
{
Configs.Stack.Value = !Configs.Stack.Value;
}
}
}
public class MyPluginInfo
{
public const string PLUGIN_GUID = "id107.backpack";
public const string PLUGIN_NAME = "Backpack";
public const string USERS_PLUGIN_NAME = "Backpack";
public const string PLUGIN_VERSION = "1.0.0";
public const string PLUGIN_DESCRIPTION = "Allows the player to carry multiple items at the same time";
public const string PLUGIN_ORIGINAL_AUTHOR = "18107";
public const string PLUGIN_AUTHORS = "18107";
public const string PLUGIN_THUNDERSTORE_ID = "";
}
[BepInPlugin("id107.backpack", "Backpack", "1.0.0")]
[BepInProcess("Void Crew.exe")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class BepinPlugin : BaseUnityPlugin
{
internal static ManualLogSource Log;
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
Configs.Load(this);
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin id107.backpack is loaded!");
}
}
public class VoidManagerPlugin : VoidPlugin
{
public static bool Enabled { get; private set; }
public override MultiplayerType MPType => (MultiplayerType)8;
public override string Author => "18107";
public override string Description => "Allows the player to carry multiple items at the same time";
public override string ThunderstoreID => "";
public VoidManagerPlugin()
{
Events.Instance.LeftRoom += delegate
{
if (Common.backpackItems.Count > 0)
{
Events.Instance.LateUpdate -= Common.MoveItems;
Common.backpackItems.Clear();
}
};
Events.Instance.LateUpdate += Common.ButtonPressed;
}
public override SessionChangedReturn OnSessionChange(SessionChangedInput input)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: 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)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
Enabled = input.IsMod_Session;
SessionChangedReturn result = default(SessionChangedReturn);
result.SetMod_Session = true;
return result;
}
}
[HarmonyPatch(typeof(TakeoverChair), "TrySitInChair")]
internal class TakeoverChairPatch
{
private static bool Prefix(TakeoverChair __instance)
{
if (!__instance.IsAvailable)
{
return true;
}
if (StateManager.GetState(((Component)LocalPlayer.Instance).gameObject, "OxygenMaskOn") && !__instance.WorksWithJetpack)
{
return true;
}
if ((Object)(object)__instance._playerCarryableCarrier == (Object)null && (Object)(object)((Component)LocalPlayer.Instance).gameObject.GetComponent<Carrier>().Payload != (Object)null)
{
return true;
}
if (Common.backpackItems.Count > 0)
{
ViewEventBus.Instance.OnShowQuickWarning.Publish(LocalizationExtensions.TryGetLocalizedString(DataTable<LocalizedStringsDataTable>.Instance.WarningHelperEntry.CannotUseCarryingSomething));
return false;
}
return true;
}
}
}