using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MoreSuits;
using TMPro;
using TooManySuits.Helper;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
[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("TooManySuits")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TooManySuits")]
[assembly: AssemblyTitle("TooManySuits")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace TooManySuits
{
[BepInPlugin("verity.TooManySuits", "Too Many Suits", "1.0.5")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
public static ManualLogSource LogSource;
public static ConfigEntry<string> NextButton;
public static ConfigEntry<string> BackButton;
public static ConfigEntry<float> TextScale;
private void Awake()
{
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Expected O, but got Unknown
LogSource = ((BaseUnityPlugin)this).Logger;
NextButton = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Next-Page-Keybind", "<Keyboard>/n", "Next page button.");
BackButton = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Back-Page-Keybind", "<Keyboard>/b", "Back page button.");
TextScale = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Text-Scale", 0.003f, "Size of the text above the suit rack.");
GameObject val = new GameObject("TooManySuits");
val.AddComponent<PluginLoader>();
((Object)val).hideFlags = (HideFlags)61;
Object.DontDestroyOnLoad((Object)val);
}
}
public class PluginLoader : MonoBehaviour
{
private class Hooks
{
public static bool SetUI;
public static GameObject SuitPanel;
public static void HookStartGame()
{
allSuits = (from suit in Resources.FindObjectsOfTypeAll<UnlockableSuit>()
orderby suit.syncedSuitID.Value
select suit).ToArray();
Object.Instantiate<GameObject>(suitSelectBundle.LoadAsset<GameObject>("SuitSelect"));
SuitPanel = GameObject.Find("SuitPanel");
SuitPanel.SetActive(false);
SetUI = true;
}
public static void HookDisconnected()
{
currentPage = 0;
}
}
private readonly Harmony Harmony = new Harmony("TooManySuits");
private InputAction moveRightAction;
private InputAction moveLeftAction;
private static int currentPage;
private int suitsPerPage = 13;
private int suitsLength;
private static UnlockableSuit[] allSuits;
private static AssetBundle suitSelectBundle;
private void Awake()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Expected O, but got Unknown
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Expected O, but got Unknown
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Expected O, but got Unknown
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Expected O, but got Unknown
Plugin.LogSource.LogInfo((object)"TooManySuits Mod Loaded.");
moveRightAction = new InputAction((string)null, (InputActionType)0, Plugin.NextButton.Value, (string)null, (string)null, (string)null);
moveRightAction.performed += MoveRightAction;
moveRightAction.Enable();
moveLeftAction = new InputAction((string)null, (InputActionType)0, Plugin.BackButton.Value, (string)null, (string)null, (string)null);
moveLeftAction.performed += MoveLeftAction;
moveLeftAction.Enable();
MethodInfo method = typeof(StartOfRound).GetMethod("Start", BindingFlags.Instance | BindingFlags.NonPublic);
MethodInfo method2 = typeof(Hooks).GetMethod("HookStartGame");
Harmony.Patch((MethodBase)method, (HarmonyMethod)null, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
MethodInfo method3 = typeof(GameNetworkManager).GetMethod("Disconnect");
MethodInfo method4 = typeof(Hooks).GetMethod("HookDisconnected");
Harmony.Patch((MethodBase)method3, (HarmonyMethod)null, new HarmonyMethod(method4), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
MethodInfo method5 = typeof(PlayerControllerB).GetMethod("Start", BindingFlags.Instance | BindingFlags.NonPublic);
MethodInfo method6 = typeof(LocalPlayer).GetMethod("PlayerControllerStart");
Harmony.Patch((MethodBase)method5, (HarmonyMethod)null, new HarmonyMethod(method6), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
suitSelectBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "suitselect"));
if (MoreSuitsMod.MakeSuitsFitOnRack)
{
suitsPerPage = 20;
}
}
private void Update()
{
if (!((Object)(object)StartOfRound.Instance == (Object)null) && allSuits.Length != 0)
{
DisplaySuits();
}
}
private void DisplaySuits()
{
//IL_0239: Unknown result type (might be due to invalid IL or missing references)
//IL_023e: Unknown result type (might be due to invalid IL or missing references)
//IL_0242: Unknown result type (might be due to invalid IL or missing references)
//IL_0256: Unknown result type (might be due to invalid IL or missing references)
//IL_025b: Unknown result type (might be due to invalid IL or missing references)
//IL_027e: Unknown result type (might be due to invalid IL or missing references)
//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: 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_013e: 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_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
if (allSuits.Length == 0)
{
return;
}
int num = currentPage * suitsPerPage;
int num2 = Mathf.Min(num + suitsPerPage, allSuits.Length);
int num3 = 0;
for (int i = 0; i < allSuits.Length; i++)
{
UnlockableSuit val = allSuits[i];
AutoParentToShip component = ((Component)val).gameObject.GetComponent<AutoParentToShip>();
if ((Object)(object)component == (Object)null)
{
continue;
}
bool flag = i >= num && i < num2;
((Component)val).gameObject.SetActive(flag);
if (flag)
{
component.overrideOffset = true;
if (MoreSuitsMod.MakeSuitsFitOnRack && suitsLength > 13)
{
float num4 = 0.18f;
num4 /= (float)Math.Min(suitsLength, 20) / 12f;
component.positionOffset = new Vector3(-2.45f, 2.75f, -8.41f) + StartOfRound.Instance.rightmostSuitPosition.forward * (num4 * (float)num3);
component.rotationOffset = new Vector3(0f, 90f, 0f);
}
else
{
component.positionOffset = new Vector3(-2.45f, 2.75f, -8.41f) + StartOfRound.Instance.rightmostSuitPosition.forward * (0.18f * (float)num3);
component.rotationOffset = new Vector3(0f, 90f, 0f);
}
num3++;
}
}
suitsLength = allSuits.Length;
if (!LocalPlayer.isActive())
{
return;
}
if (LocalPlayer.localPlayer.isInHangarShipRoom)
{
((TMP_Text)Hooks.SuitPanel.GetComponentInChildren<TextMeshProUGUI>()).text = $"Page {currentPage + 1}/{Mathf.CeilToInt((float)suitsLength / (float)suitsPerPage)}";
Hooks.SuitPanel.SetActive(true);
return;
}
Hooks.SuitPanel.SetActive(false);
if (Hooks.SetUI)
{
Hooks.SetUI = false;
Hooks.SuitPanel.GetComponentInParent<Canvas>().renderMode = (RenderMode)2;
Hooks.SuitPanel.GetComponentInParent<Canvas>().worldCamera = LocalPlayer.localPlayer.gameplayCamera;
Transform transform = Hooks.SuitPanel.transform;
Bounds bounds = StartOfRound.Instance.shipBounds.bounds;
transform.position = ((Bounds)(ref bounds)).center - new Vector3(2.8992f, 0.7998f, 2f);
Hooks.SuitPanel.transform.rotation = Quaternion.Euler(0f, 180f, 0f);
Hooks.SuitPanel.transform.localScale = new Vector3(Plugin.TextScale.Value, Plugin.TextScale.Value, Plugin.TextScale.Value);
Hooks.SuitPanel.SetActive(true);
}
}
private void MoveRightAction(CallbackContext obj)
{
currentPage = Mathf.Min(currentPage + 1, Mathf.CeilToInt((float)suitsLength / (float)suitsPerPage) - 1);
}
private void MoveLeftAction(CallbackContext obj)
{
currentPage = Mathf.Max(currentPage - 1, 0);
}
}
}
namespace TooManySuits.Helper
{
public class LocalPlayer
{
public static PlayerControllerB localPlayer;
public static bool isActive()
{
return (Object)(object)localPlayer != (Object)null;
}
public static void PlayerControllerStart(PlayerControllerB __instance)
{
if (NetworkManager.Singleton.LocalClientId == __instance.playerClientId)
{
localPlayer = __instance;
}
}
}
}