using System;
using System.Collections;
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 System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using OpenLib;
using OpenLib.Common;
using OpenLib.Compat;
using OpenLib.ConfigManager;
using OpenLib.CoreMethods;
using OpenLib.Events;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering;
using UnityEngine.UI;
using UnityEngine.Video;
using suitsTerminal.EventSub;
using suitsTerminal.Suit_Stuff;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.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.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;
}
}
[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 suitsTerminal
{
internal class ChatHandler
{
internal static string lastCommandRun = "";
internal static void HandleChatMessage(string command)
{
if (lastCommandRun == command)
{
return;
}
if (command.StartsWith("!suits"))
{
string[] array = command.Split(' ');
if (array.Length == 1)
{
AdvancedMenu.GetCurrentSuitID();
string text = StringStuff.ChatListing(AllSuits.suitListing, 6, 1);
HUDManager.Instance.AddTextToChatOnServer("[suitsTerminal]:\t " + text, -1);
lastCommandRun = command;
}
else if (array.Length > 1)
{
string text2 = array[1];
if (int.TryParse(text2, out var result))
{
string text3 = StringStuff.ChatListing(AllSuits.suitListing, 6, result);
HUDManager.Instance.AddTextToChatOnServer("[suitsTerminal]:\t " + text3, -1);
lastCommandRun = command;
}
else
{
HUDManager.Instance.AddTextToChatOnServer("[suitsTerminal]:\t Invalid page number format: " + text2, -1);
Plugin.WARNING("Invalid page number format: " + text2);
lastCommandRun = command;
}
}
}
else if (command.StartsWith("!wear"))
{
string[] array2 = command.Split(' ');
if (array2.Length == 1)
{
HUDManager.Instance.AddTextToChatOnServer("[suitsTerminal]:\t No suit specified...", -1);
lastCommandRun = command;
}
else
{
if (array2.Length <= 1)
{
return;
}
string text4 = array2[1];
if (int.TryParse(text4, out var result2))
{
if (result2 >= 0 && result2 < AllSuits.suitListing.SuitsList.Count)
{
SuitAttributes suit = AllSuits.suitListing.SuitsList[result2];
Plugin.X("wear command");
CommandHandler.BetterSuitPick(suit);
AdvancedMenu.GetCurrentSuitID();
lastCommandRun = command;
}
else
{
HUDManager.Instance.AddTextToChatOnServer("[suitsTerminal]:\t Invalid suit number: " + text4, -1);
Plugin.WARNING("Invalid suit number: " + text4);
lastCommandRun = command;
}
}
else
{
HUDManager.Instance.AddTextToChatOnServer("[suitsTerminal]:\t Invalid suit number format: " + text4, -1);
Plugin.WARNING("Invalid suit number format: " + text4);
lastCommandRun = command;
}
}
}
else if (command.StartsWith("!clear"))
{
((TMP_Text)HUDManager.Instance.chatText).text.Remove(0, ((TMP_Text)HUDManager.Instance.chatText).text.Length);
HUDManager.Instance.ChatMessageHistory.Clear();
lastCommandRun = command;
}
}
}
[HarmonyPatch(typeof(HUDManager), "SubmitChat_performed")]
public class Chat_Patch : MonoBehaviour
{
internal static string lastMessage = "";
private static void Postfix(HUDManager __instance)
{
if (SConfig.ChatCommands.Value && !(lastMessage == __instance.lastChatMessage))
{
Plugin.X("Testing message [" + __instance.lastChatMessage + "] for command.");
string lastChatMessage = __instance.lastChatMessage;
ChatHandler.HandleChatMessage(lastChatMessage);
}
}
}
[HarmonyPatch(typeof(StartOfRound), "PositionSuitsOnRack")]
public class SuitBoughtByOthersPatch
{
private static void Postfix(StartOfRound __instance)
{
if (!((Object)(object)__instance == (Object)null) && Misc.hasLaunched)
{
Plugin.X("suits rack func called, calling InitSuitsTerm func");
InitThisPlugin.InitSuitsTerm();
}
}
}
public class Page
{
public StringBuilder Content { get; set; }
public int PageNumber { get; set; }
}
public class PageSplitter
{
public static List<Page> SplitTextIntoPages(string inputText, int maxLinesPerPage)
{
string[] array = inputText.Split(new string[1] { Environment.NewLine }, StringSplitOptions.None);
List<Page> list = new List<Page>();
int num = 0;
int num2 = 1;
while (num < array.Length)
{
Page page = new Page
{
Content = new StringBuilder(),
PageNumber = num2
};
page.Content.AppendLine($"=== Choose your Suit! Page {num2} ===\r\n\r\n");
for (int i = 0; i < maxLinesPerPage; i++)
{
if (num >= array.Length)
{
break;
}
page.Content.AppendLine(array[num]);
num++;
}
if (num < array.Length)
{
page.Content.AppendLine($"> Use command 'suits {num2 + 1}' to see the next page of suits!\r\n");
}
list.Add(page);
num2++;
}
return list;
}
}
internal class Bools
{
internal static bool ShouldShowSuit(SuitAttributes suit)
{
SuitAttributes suit2 = suit;
List<string> keywordsPerConfigItem = CommonStringStuff.GetKeywordsPerConfigItem(SConfig.SuitsOnRackOnly.Value, ',');
List<string> listToLower = CommonStringStuff.GetListToLower(CommonStringStuff.GetKeywordsPerConfigItem(SConfig.DontAddToRack.Value, ','));
if (SConfig.HideRack.Value)
{
return false;
}
if (listToLower.Contains(suit2.Name.ToLower()))
{
return false;
}
if (keywordsPerConfigItem.Count == 0 && Misc.suitsOnRack >= SConfig.SuitsOnRack.Value && !Misc.rackSituated)
{
return false;
}
if (Misc.suitsOnRack == SConfig.SuitsOnRack.Value && !Misc.rackSituated)
{
return false;
}
if (Misc.rackSituated && !suit2.IsOnRack)
{
return false;
}
if (keywordsPerConfigItem.Count > 0 && !keywordsPerConfigItem.Any((string s) => s.ToLower() == suit2.Name.ToLower()))
{
return false;
}
if (Misc.rackSituated && suit2.IsOnRack)
{
return true;
}
if (Misc.suitsOnRack < SConfig.SuitsOnRack.Value && !Misc.rackSituated)
{
return true;
}
return false;
}
}
public static class SConfig
{
public static ConfigEntry<bool> ExtensiveLogging { get; internal set; }
public static ConfigEntry<int> SuitsOnRack { get; internal set; }
public static ConfigEntry<bool> HideRack { get; internal set; }
public static ConfigEntry<bool> HideBoots { get; internal set; }
public static ConfigEntry<bool> RandomSuitCommand { get; internal set; }
public static ConfigEntry<bool> ChatCommands { get; internal set; }
public static ConfigEntry<bool> DontRemove { get; internal set; }
public static ConfigEntry<bool> EnforcePaidSuits { get; internal set; }
public static ConfigEntry<bool> TerminalCommands { get; internal set; }
public static ConfigEntry<bool> AdvancedTerminalMenu { get; internal set; }
public static ConfigEntry<bool> EnablePiPCamera { get; internal set; }
public static ConfigEntry<bool> ChatHints { get; internal set; }
public static ConfigEntry<bool> BannerHints { get; internal set; }
public static ConfigEntry<bool> UseOpenBodyCams { get; internal set; }
public static ConfigEntry<string> ObcResolution { get; internal set; }
public static ConfigEntry<string> DefaultSuit { get; internal set; }
public static ConfigEntry<string> MenuUp { get; internal set; }
public static ConfigEntry<string> MenuDown { get; internal set; }
public static ConfigEntry<string> MenuLeft { get; internal set; }
public static ConfigEntry<string> MenuRight { get; internal set; }
public static ConfigEntry<string> LeaveMenu { get; internal set; }
public static ConfigEntry<string> SelectMenu { get; internal set; }
public static ConfigEntry<string> HelpMenu { get; internal set; }
public static ConfigEntry<string> FavItemKey { get; internal set; }
public static ConfigEntry<string> FavMenuKey { get; internal set; }
public static ConfigEntry<string> TogglePiP { get; internal set; }
public static ConfigEntry<string> TogglePiPZoom { get; internal set; }
public static ConfigEntry<string> TogglePiPRotation { get; internal set; }
public static ConfigEntry<string> TogglePiPHeight { get; internal set; }
public static ConfigEntry<string> SuitsOnRackOnly { get; internal set; }
public static ConfigEntry<string> DontAddToRack { get; internal set; }
public static ConfigEntry<string> DontAddToTerminal { get; internal set; }
public static ConfigEntry<string> FavoritesMenuList { get; internal set; }
public static ConfigEntry<string> SuitsSortingStyle { get; internal set; }
public static ConfigEntry<float> MenuKeyPressDelay { get; internal set; }
public static ConfigEntry<float> MenuPostSelectDelay { get; internal set; }
public static void Settings()
{
Plugin.Log.LogInfo((object)"Reading configuration settings");
AdvancedTerminalMenu = MakeBool("General", "AdvancedTerminalMenu", defaultValue: true, "Enable this to utilize the advanced menu system and keybinds below");
ExtensiveLogging = MakeBool("General", "ExtensiveLogging", defaultValue: false, "Enable or Disable extensive logging for this mod.");
EnforcePaidSuits = MakeBool("General", "EnforcePaidSuits", defaultValue: true, "Enable or Disable enforcing paid suits being locked until they are paid for & unlocked.");
RandomSuitCommand = MakeBool("General", "RandomSuitCommand", defaultValue: false, "Enable/Disable the randomsuit terminal command.");
ChatCommands = MakeBool("General", "ChatCommands", defaultValue: false, "Enable/Disable suits commands via chat (!suits/!wear).");
TerminalCommands = MakeBool("General", "TerminalCommands", defaultValue: true, "Enable/Disable the base suits commands via terminal (suits, wear).");
DontRemove = MakeBool("General", "DontRemove", defaultValue: false, "Enable this to stop this mod from removing suits from the rack and make it compatible with other mods like TooManySuits.");
DefaultSuit = MakeString("General", "DefaultSuit", "", "Automatically equip this suit when first loading in (in-place of the default orange\nThis configuration option is disabled if SuitSaver is present.");
DontAddToTerminal = MakeString("General", "DontAddToTerminal", "", "Comma-separated list of suits you do NOT want added to the terminal in any situation. Leave blank to disable this list.");
SuitsOnRack = MakeClampedInt("Rack Settings", "SuitsOnRack", 13, "Number of suits to keep on the rack. (Up to 13)", 0, 13);
SuitsOnRackOnly = MakeString("Rack Settings", "SuitsOnRackOnly", "", "Comma-separated list of suits to display on the rack by name. Leave blank to disable this list.\nNOTE: This will make it so ONLY suits listed here will be added to the rack.\nIf no suits match this configuration item, no suits will be added to the rack.");
DontAddToRack = MakeString("Rack Settings", "DontAddToRack", "", "Comma-separated list of suits you do NOT want added to the rack in any situation. Leave blank to disable this list.");
HideBoots = MakeBool("Rack Settings", "HideBoots", defaultValue: false, "Enable this to hide the boots by the rack.");
HideRack = MakeBool("Rack Settings", "HideRack", defaultValue: false, "Enable this to hide the rack, (rack will not be hidden if DontRemove is enabled, SuitsOnRack integer will be ignored if rack hidden).");
SuitsSortingStyle = MakeClampedString("Rack Settings", "SuitsSortingStyle", "alphabetical (UnlockableName)", "How suits will be sorted in menus & on the rack", new AcceptableValueList<string>(new string[3] { "alphabetical", "numerical", "none" }));
FavoritesMenuList = MakeString("AdvancedTerminalMenu", "FavoritesMenuList", "", "Favorited suit names will be stored here and displayed in the AdvancedTerminalMenu.");
EnablePiPCamera = MakeBool("AdvancedTerminalMenu", "EnablePiPCamera", defaultValue: true, "Disable this to stop the PiP camera from being created");
MenuLeft = MakeString("AdvancedTerminalMenu", "MenuLeft", "LeftArrow", "Set key to press to go to previous page in advanced menu system");
MenuRight = MakeString("AdvancedTerminalMenu", "MenuRight", "RightArrow", "Set key to press to go to next page in advanced menu system");
MenuUp = MakeString("AdvancedTerminalMenu", "MenuUp", "UpArrow", "Set key to press to go to previous item on page in advanced menu system");
MenuDown = MakeString("AdvancedTerminalMenu", "MenuDown", "DownArrow", "Set key to press to go to next item on page in advanced menu system");
LeaveMenu = MakeString("AdvancedTerminalMenu", "LeaveMenu", "Backspace", "Set key to press to leave advanced menu system");
SelectMenu = MakeString("AdvancedTerminalMenu", "SelectMenu", "Enter", "Set key to press to select an item in advanced menu system");
HelpMenu = MakeString("AdvancedTerminalMenu", "HelpMenu", "H", "Set key to press to toggle help & controls page in advanced menu system");
FavItemKey = MakeString("AdvancedTerminalMenu", "FavItemKey", "F", "Set key to press to set an item as a favorite in advanced menu system");
FavMenuKey = MakeString("AdvancedTerminalMenu", "FavMenuKey", "F1", "Set key to press to show favorites menu in advanced menu system");
TogglePiP = MakeString("AdvancedTerminalMenu", "TogglePiP", "F12", "Set key to press to toggle PiP (mirror cam) on/off in advanced menu system");
TogglePiPZoom = MakeString("AdvancedTerminalMenu", "TogglePiPZoom", "Minus", "Set key to press to toggle PiP (mirror cam) zoom in advanced menu system");
TogglePiPRotation = MakeString("AdvancedTerminalMenu", "TogglePiPRotation", "Equals", "Set key to press to toggle PiP (mirror cam) rotation in advanced menu system");
TogglePiPHeight = MakeString("AdvancedTerminalMenu", "TogglePiPHeight", "Backslash", "Set key to press to toggle PiP (mirror cam) height in advanced menu system");
ChatHints = MakeBool("Hints", "ChatHints", defaultValue: false, "Determines whether chat hints are displayed at load in.");
BannerHints = MakeBool("Hints", "BannerHints", defaultValue: true, "Determines whether banner hints are displayed at load in.");
UseOpenBodyCams = MakeBool("OpenBodyCams", "UseOpenBodyCams", defaultValue: true, "Disable this to remove the banner hints displayed at load in.");
ObcResolution = MakeString("OpenBodyCams", "ObcResolution", "1000; 700", "Set the resolution of the Mirror Camera created with OpenBodyCams");
MenuKeyPressDelay = MakeClampedFloat("AdvancedTerminalMenu", "MenuKeyPressDelay", 0.15f, "Regular delay when checking for key presses in the AdvancedTerminalMenu. (This delay will be added ontop of MenuPostSelectDelay)", 0.05f, 1f);
MenuPostSelectDelay = MakeClampedFloat("AdvancedTerminalMenu", "MenuPostSelectDelay", 0.1f, "Delay used after a key press is registered in the AdvancedTerminalMenu.", 0.05f, 1f);
PropertyInfo property = ((object)((BaseUnityPlugin)Plugin.instance).Config).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(((BaseUnityPlugin)Plugin.instance).Config, null);
dictionary.Clear();
((BaseUnityPlugin)Plugin.instance).Config.Save();
}
private static ConfigEntry<bool> MakeBool(string section, string configItemName, bool defaultValue, string configDescription)
{
return ((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>(section, configItemName, defaultValue, configDescription);
}
private static ConfigEntry<int> MakeInt(string section, string configItemName, int defaultValue, string configDescription)
{
return ((BaseUnityPlugin)Plugin.instance).Config.Bind<int>(section, configItemName, defaultValue, configDescription);
}
private static ConfigEntry<string> MakeClampedString(string section, string configItemName, string defaultValue, string configDescription, AcceptableValueList<string> acceptedValues)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
return ((BaseUnityPlugin)Plugin.instance).Config.Bind<string>(section, configItemName, defaultValue, new ConfigDescription(configDescription, (AcceptableValueBase)(object)acceptedValues, Array.Empty<object>()));
}
private static ConfigEntry<int> MakeClampedInt(string section, string configItemName, int defaultValue, string configDescription, int minValue, int maxValue)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
return ((BaseUnityPlugin)Plugin.instance).Config.Bind<int>(section, configItemName, defaultValue, new ConfigDescription(configDescription, (AcceptableValueBase)(object)new AcceptableValueRange<int>(minValue, maxValue), Array.Empty<object>()));
}
private static ConfigEntry<float> MakeClampedFloat(string section, string configItemName, float defaultValue, string configDescription, float minValue, float maxValue)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
return ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>(section, configItemName, defaultValue, new ConfigDescription(configDescription, (AcceptableValueBase)(object)new AcceptableValueRange<float>(minValue, maxValue), Array.Empty<object>()));
}
private static ConfigEntry<string> MakeString(string section, string configItemName, string defaultValue, string configDescription)
{
return ((BaseUnityPlugin)Plugin.instance).Config.Bind<string>(section, configItemName, defaultValue, configDescription);
}
}
internal class Enums
{
internal static IEnumerator ChatHints()
{
if (SConfig.ChatHints.Value)
{
yield return (object)new WaitForSeconds(5f);
Plugin.X("hint in chat.");
if (SConfig.TerminalCommands.Value)
{
HUDManager.Instance.AddTextToChatOnServer("[suitsTerminal]: Access more suits by typing 'suits' in the terminal.", -1);
}
if (SConfig.ChatCommands.Value)
{
HUDManager.Instance.AddTextToChatOnServer("[suitsTerminal]: Access more suits by typing '!suits' in chat.", -1);
}
}
}
internal static IEnumerator HudHints()
{
if (SConfig.BannerHints.Value)
{
yield return (object)new WaitForSeconds(20f);
Plugin.X("hint on hud.");
if (SConfig.SuitsOnRack.Value > 0 && !SConfig.DontRemove.Value && SConfig.TerminalCommands.Value && !SConfig.ChatCommands.Value)
{
HUDManager.Instance.DisplayTip("Suits Access", "Excess suits have been moved to the terminal for storage. Use command 'suits' in the terminal to access them and change your suit!", false, false, "suitsTerminal-Hint");
}
else if (SConfig.SuitsOnRack.Value == 0 && !SConfig.DontRemove.Value && SConfig.TerminalCommands.Value && !SConfig.ChatCommands.Value)
{
HUDManager.Instance.DisplayTip("Suits Access", "All suits have been moved to the terminal for storage. Use command 'suits' in the terminal to access them and change your suit!", false, false, "suitsTerminal-Hint");
}
else if (SConfig.SuitsOnRack.Value == 0 && !SConfig.DontRemove.Value && SConfig.TerminalCommands.Value && SConfig.ChatCommands.Value)
{
HUDManager.Instance.DisplayTip("Suits Access", "All suits have been moved to the terminal for storage. Use command 'suits' in the terminal or !suits in the chat to access them and change your suit!", false, false, "suitsTerminal-Hint");
}
else if (SConfig.SuitsOnRack.Value > 0 && !SConfig.DontRemove.Value && SConfig.TerminalCommands.Value && SConfig.ChatCommands.Value)
{
HUDManager.Instance.DisplayTip("Suits Access", "Excess suits have been moved to the terminal for storage. Use command 'suits' in the terminal or !suits in the chat to access them and change your suit!", false, false, "suitsTerminal-Hint");
}
}
}
}
internal class InitThisPlugin
{
internal static bool initStarted;
internal static void InitSuitsTerm()
{
if (initStarted)
{
Plugin.X("init already started, ending func");
return;
}
initStarted = true;
Plugin.X($"Suits patch, showSuit value: {Misc.suitsOnRack}");
AllSuits.InitSuitsListing();
if (!Misc.hintOnce)
{
if ((Object)(object)Plugin.Terminal == (Object)null)
{
Plugin.Log.LogError((object)"~~ FATAL ERROR ~~");
Plugin.Log.LogError((object)"Terminal instance is NULL");
Plugin.Log.LogError((object)"~~ FATAL ERROR ~~");
}
else
{
((MonoBehaviour)Plugin.Terminal).StartCoroutine(Enums.ChatHints());
((MonoBehaviour)Plugin.Terminal).StartCoroutine(Enums.HudHints());
Misc.hintOnce = true;
}
}
}
}
internal class Misc
{
internal static bool keywordsCreated;
internal static bool rackSituated;
internal static int suitsOnRack;
internal static int weirdSuitNum;
internal static bool hasLaunched;
internal static bool hintOnce;
internal static GameObject GetGameObject(string location)
{
return GameObject.Find(location);
}
internal static string HelpMenuDisplay(bool inHelpMenu)
{
if (inHelpMenu)
{
Plugin.X("Help Menu Enabled, showing help information");
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append("========= AdvancedsuitsMenu Help Page =========\r\n");
stringBuilder.Append("\r\n\r\n");
stringBuilder.Append("Highlight Next Item: [" + AdvancedMenu.downString + "]\r\nHighlight Last Item: [" + AdvancedMenu.upString + "]\r\nFavorite Item: [" + AdvancedMenu.favItemKeyString + "]\r\nShow Favorites Menu: [" + AdvancedMenu.favMenuKeyString + "]\r\n");
if (SConfig.EnablePiPCamera.Value)
{
stringBuilder.Append("Toggle Camera Preview: [" + AdvancedMenu.togglePiPstring + "]\r\nRotate Camera: [" + AdvancedMenu.pipRotateString + "]\r\nChange Camera Height: [" + AdvancedMenu.pipHeightString + "]\r\nChange Camera Zoom: [" + AdvancedMenu.pipZoomString + "]\r\n");
}
stringBuilder.Append("Leave Suits Menu: [" + AdvancedMenu.leaveString + "]\r\nSelect Suit: [" + AdvancedMenu.selectString + "]\r\n");
stringBuilder.Append("\r\n>>>\tReturn to Suit Selection: [" + AdvancedMenu.helpMenuKeyString + "]\t<<\r\n");
return stringBuilder.ToString();
}
Plugin.X("Help Menu disabled, returning to menu selection...");
return StringStuff.AdvancedMenuDisplay(AllSuits.suitListing, AdvancedMenu.activeSelection, 10, AdvancedMenu.currentPage);
}
internal static void SaveToConfig(List<string> stringList, out string configItem)
{
configItem = string.Join(", ", stringList);
Plugin.X("Saving to config\n" + configItem);
}
}
[BepInPlugin("darmuh.suitsTerminal", "suitsTerminal", "1.5.3")]
[BepInDependency("darmuh.OpenLib", "0.2.5")]
public class Plugin : BaseUnityPlugin
{
public static class PluginInfo
{
public const string PLUGIN_GUID = "darmuh.suitsTerminal";
public const string PLUGIN_NAME = "suitsTerminal";
public const string PLUGIN_VERSION = "1.5.3";
}
public static Plugin instance;
internal static bool TerminalStuff;
internal static bool SuitSaver;
public static Terminal Terminal;
internal static ManualLogSource Log;
private void Awake()
{
instance = this;
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)"suitsTerminal version 1.5.3 has been started!");
Misc.keywordsCreated = false;
SConfig.Settings();
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
Subscribers.Subscribe();
}
public static void X(string message)
{
if (SConfig.ExtensiveLogging.Value)
{
Log.LogInfo((object)message);
}
}
public static void WARNING(string message)
{
Log.LogWarning((object)message);
}
public static void ERROR(string message)
{
Log.LogError((object)message);
}
}
internal class StringStuff
{
internal static string GetNumbers(string selectedSuit)
{
int num = selectedSuit.IndexOf("^");
string text;
if (num == -1)
{
text = string.Empty;
}
else
{
int num2 = num + 1;
text = selectedSuit.Substring(num2, selectedSuit.Length - num2);
}
string text2 = text;
return text2.Replace("^", "").Replace("(", "").Replace(")", "");
}
internal static string RemoveNumbers(string selectedSuit)
{
int num = selectedSuit.IndexOf("^");
return (num != -1) ? selectedSuit.Substring(0, num) : selectedSuit;
}
internal static string TerminalFriendlyString(string s)
{
StringBuilder stringBuilder = new StringBuilder();
foreach (char c in s)
{
if (!char.IsPunctuation(c))
{
stringBuilder.Append(c);
}
}
if (stringBuilder.Length > 14)
{
int length = stringBuilder.Length - 14;
stringBuilder.Remove(14, length);
}
return stringBuilder.ToString().ToLower();
}
internal static string ChatListing(SuitListing suitListing, int pageSize, int currentPage)
{
int count = suitListing.SuitsList.Count;
currentPage = Mathf.Clamp(currentPage, 1, Mathf.CeilToInt((float)count / (float)pageSize));
int num = (currentPage - 1) * pageSize;
int num2 = Mathf.Min(num + pageSize, count);
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append("\r\n");
for (int i = num; i < num2; i++)
{
SuitAttributes suitAttributes = suitListing.SuitsList[i];
string text = suitAttributes.Name + (suitAttributes.currentSuit ? " [EQUIPPED]" : "");
stringBuilder.Append($"'!wear {i}' (" + text + ")\r\n");
}
stringBuilder.Append("\r\n");
stringBuilder.Append($"Page {currentPage}/{Mathf.CeilToInt((float)count / (float)pageSize)}\r\n");
return stringBuilder.ToString();
}
internal static int GetListing(SuitListing suitListing)
{
if (AdvancedMenu.inFavsMenu)
{
suitListing.CurrentMenu = 1;
}
else
{
suitListing.CurrentMenu = 0;
}
if (suitListing.CurrentMenu == 0)
{
return suitListing.NameList.Count;
}
return suitListing.FavList.Count;
}
internal static string AdvancedMenuDisplay(SuitListing suitListing, int activeIndex, int pageSize, int currentPage)
{
Plugin.X($"activeIndex: {activeIndex}\npageSize: {pageSize}\ncurrentPage: {currentPage}");
if (suitListing == null)
{
Plugin.ERROR("suitsTerminal FATAL ERROR: suitListing is NULL");
return "suitsTerminal FATAL ERROR: suitListing is NULL";
}
int listing = GetListing(suitListing);
Plugin.X($"listing count: {listing}");
currentPage = Mathf.Clamp(currentPage, 1, Mathf.CeilToInt((float)listing / (float)pageSize));
int num = (currentPage - 1) * pageSize;
int num2 = Mathf.Min(num + pageSize, listing);
int num3 = 0;
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append("============= AdvancedsuitsMenu =============\r\n");
stringBuilder.Append("\r\n");
activeIndex = Mathf.Clamp(activeIndex, num, num2 - 1);
Plugin.X($"activeSelection: {AdvancedMenu.activeSelection} activeIndex: {activeIndex}");
Plugin.X("matching values");
AdvancedMenu.activeSelection = activeIndex;
int i;
for (i = num; i < num2; i++)
{
SuitAttributes suitAttributes = ((suitListing.CurrentMenu != 0) ? suitListing.SuitsList.Where((SuitAttributes x) => x.FavIndex == i).FirstOrDefault() : suitListing.SuitsList.Where((SuitAttributes x) => x.MainMenuIndex == i).FirstOrDefault());
if (suitAttributes == null)
{
Plugin.ERROR($"suitsTerminal FATAL ERROR: Unable to index suit listing @ [ {i} ]");
return $"suitsTerminal FATAL ERROR: Unable to index suit listing @ [ {i} ]";
}
AdvancedMenu.activeSelection = activeIndex;
string text = ((i == activeIndex) ? ("> " + suitAttributes.Name + (suitAttributes.currentSuit ? " [EQUIPPED]" : "") + (suitAttributes.IsFav ? " (*)" : "")) : (suitAttributes.Name + (suitAttributes.currentSuit ? " [EQUIPPED]" : "") + (suitAttributes.IsFav ? " (*)" : "")));
stringBuilder.Append(text + "\r\n");
num3++;
}
int num4 = pageSize - num3;
for (int j = 0; j < num4; j++)
{
stringBuilder.Append("\r\n");
}
stringBuilder.Append("\r\n\r\n");
stringBuilder.Append("Currently Wearing: " + AllSuits.UnlockableItems[StartOfRound.Instance.localPlayerController.currentSuitID].unlockableName + "\r\n\r\n");
stringBuilder.Append($"Page [{AdvancedMenu.leftString}] < {currentPage}/{Mathf.CeilToInt((float)listing / (float)pageSize)} > [{AdvancedMenu.rightString}]\r\n");
stringBuilder.Append("Leave Menu: [" + AdvancedMenu.leaveString + "]\tSelect Suit: [" + AdvancedMenu.selectString + "]\r\n");
stringBuilder.Append("\r\n>>>\tDisplay Help Page: [" + AdvancedMenu.helpMenuKeyString + "]\t<<\r\n");
return stringBuilder.ToString();
}
internal static SuitAttributes GetMenuItemSuit(SuitListing suitListing, int activeIndex)
{
if (suitListing.CurrentMenu == 0)
{
return suitListing.SuitsList.Find((SuitAttributes x) => x.MainMenuIndex == activeIndex);
}
return suitListing.SuitsList.Find((SuitAttributes x) => x.FavIndex == activeIndex);
}
}
internal class AllSuits
{
internal static List<UnlockableItem> UnlockableItems = new List<UnlockableItem>();
internal static Dictionary<int, string> suitNameToID = new Dictionary<int, string>();
internal static SuitListing suitListing = new SuitListing();
private static bool AddSuitToList(UnlockableSuit suit)
{
if (!SConfig.EnforcePaidSuits.Value)
{
return true;
}
if ((Object)(object)UnlockableItems[suit.syncedSuitID.Value].shopSelectionNode == (Object)null)
{
return true;
}
if (!UnlockableItems[suit.syncedSuitID.Value].spawnPrefab)
{
Plugin.WARNING("Locked suit [" + UnlockableItems[suit.syncedSuitID.Value].unlockableName + "] detected, not adding to listings.");
Plugin.X($"hasBeenUnlockedByPlayer: {UnlockableItems[suit.syncedSuitID.Value].hasBeenUnlockedByPlayer} \nalreadyUnlocked: {UnlockableItems[suit.syncedSuitID.Value].alreadyUnlocked}");
return false;
}
return true;
}
private static void RemoveBadSuitIDs()
{
Plugin.X("Removing suits with negative suitID values.");
foreach (UnlockableSuit rawSuits in suitListing.RawSuitsList)
{
if (rawSuits.syncedSuitID.Value < 0)
{
Plugin.X($"Negative value [ {rawSuits.syncedSuitID.Value} ] detected for suit\nRemoving from suitsTerminal listing");
}
}
suitListing.RawSuitsList.RemoveAll((UnlockableSuit suit) => suit.syncedSuitID.Value < 0);
if (SConfig.SuitsSortingStyle.Value == "alphabetical")
{
OrderSuitsByName();
}
else if (SConfig.SuitsSortingStyle.Value == "numerical")
{
OrderSuitsByID();
}
else if (SConfig.SuitsSortingStyle.Value == "none")
{
Plugin.Log.LogInfo((object)"No sorting requested.");
}
else
{
Plugin.WARNING("Config failure, no sorting");
}
}
internal static void InitSuitsListing()
{
Plugin.X("InitSuitsListing");
suitListing.RawSuitsList.Clear();
SuitListing obj = suitListing;
UnlockableSuit[] array = Resources.FindObjectsOfTypeAll<UnlockableSuit>();
List<UnlockableSuit> list = new List<UnlockableSuit>(array.Length);
list.AddRange(array);
obj.RawSuitsList = list;
suitNameToID.Clear();
suitListing.NameList.Clear();
UnlockableItems = StartOfRound.Instance.unlockablesList.unlockables;
RemoveBadSuitIDs();
FixRack();
OldCommands.MakeRandomSuitCommand();
}
private static void OrderSuitsByName()
{
SuitListing obj = suitListing;
List<UnlockableSuit> list = new List<UnlockableSuit>();
list.AddRange(suitListing.RawSuitsList.OrderBy((UnlockableSuit suit) => UnlockableItems[suit.syncedSuitID.Value].unlockableName));
obj.RawSuitsList = list;
}
private static void OrderSuitsByID()
{
SuitListing obj = suitListing;
List<UnlockableSuit> list = new List<UnlockableSuit>();
list.AddRange(suitListing.RawSuitsList.OrderBy((UnlockableSuit suit) => suit.syncedSuitID.Value));
obj.RawSuitsList = list;
}
private static void HideBootsAndRack()
{
if (!Misc.rackSituated)
{
if (SConfig.HideBoots.Value)
{
GameObject gameObject = Misc.GetGameObject("Environment/HangarShip/ScavengerModelSuitParts/Circle.004");
Object.Destroy((Object)(object)gameObject);
}
if (!SConfig.DontRemove.Value && SConfig.HideRack.Value)
{
GameObject gameObject2 = Misc.GetGameObject("Environment/HangarShip/NurbsPath.002");
Object.Destroy((Object)(object)gameObject2);
}
}
}
private static void FixRack()
{
Plugin.X($"Raw Suit Count: {suitListing.RawSuitsList.Count}");
Plugin.X($"Unlockables Count: {UnlockableItems.Count}");
Misc.weirdSuitNum = 0;
HideBootsAndRack();
List<string> suitNames = new List<string>();
foreach (UnlockableSuit rawSuits in suitListing.RawSuitsList)
{
Plugin.X($"checking - {rawSuits.syncedSuitID.Value}");
if (!AddSuitToList(rawSuits))
{
continue;
}
AutoParentToShip component = ((Component)rawSuits).gameObject.GetComponent<AutoParentToShip>();
if (suitListing.Contains(rawSuits, out SuitAttributes thisSuit))
{
thisSuit.UpdateSuit(rawSuits, UnlockableItems, ref suitNameToID);
Plugin.X($"Updated suit attributes for {thisSuit.Name} with ID {thisSuit.UniqueID}");
}
else if (suitListing.Contains(rawSuits.syncedSuitID.Value, out thisSuit))
{
thisSuit.UpdateSuit(rawSuits, UnlockableItems, ref suitNameToID);
Plugin.X($"Updated suit attributes for {thisSuit.Name} with ID {thisSuit.UniqueID}");
}
else
{
thisSuit = new SuitAttributes(rawSuits, UnlockableItems, ref suitNameToID);
suitListing.SuitsList.Add(thisSuit);
}
OldCommands.CreateOldWearCommands(thisSuit, ref suitNames);
if (!SConfig.DontRemove.Value)
{
if (Bools.ShouldShowSuit(thisSuit))
{
thisSuit.IsOnRack = true;
ProcessRack.ProcessVisibleSuit(component, Misc.suitsOnRack);
}
else
{
thisSuit.IsOnRack = false;
ProcessRack.ProcessHiddenSuit(component);
}
if (Misc.suitsOnRack == SConfig.SuitsOnRack.Value && !Misc.rackSituated)
{
Misc.rackSituated = true;
Plugin.X("Max suits are on the rack now. rack is situated, yippeee!!!");
}
}
}
Plugin.X($"Main list count: {suitListing.NameList.Count}\nFav list count: {suitListing.FavList.Count}");
OldCommands.CreateOldPageCommands();
InitThisPlugin.initStarted = false;
}
}
internal class ProcessRack
{
internal static void ProcessHiddenSuit(AutoParentToShip component)
{
component.disableObject = true;
((Renderer)((Component)component).gameObject.GetComponentInChildren<SkinnedMeshRenderer>()).enabled = false;
((Renderer)((Component)component).gameObject.GetComponentInChildren<MeshRenderer>()).enabled = false;
}
internal static void ProcessVisibleSuit(AutoParentToShip component, int suitNumber)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: 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_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: 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_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
component.overrideOffset = true;
float num = 0.18f;
component.positionOffset = new Vector3(-2.45f, 2.75f, -8.41f) + StartOfRound.Instance.rightmostSuitPosition.forward * num * (float)suitNumber;
component.rotationOffset = new Vector3(0f, 90f, 0f);
Misc.suitsOnRack++;
}
}
public class AdvancedMenu
{
internal static Dictionary<Key, string> keyActions = new Dictionary<Key, string>();
internal static Key keyBeingPressed;
internal static Key leaveMenu;
internal static Key selectMenu;
internal static Key togglePiP;
internal static string upString;
internal static string downString;
internal static string leftString;
internal static string rightString;
internal static string leaveString;
internal static string selectString;
internal static string favItemKeyString;
internal static string favMenuKeyString;
internal static string helpMenuKeyString;
internal static string togglePiPstring;
internal static string pipHeightString;
internal static string pipRotateString;
internal static string pipZoomString;
internal static bool inFavsMenu = false;
internal static bool inHelpMenu = false;
internal static int currentPage = 1;
internal static int activeSelection = 0;
internal static bool exitSpecialMenu = false;
public static bool specialMenusActive = false;
internal static TerminalNode menuDisplay = null;
internal static bool initKeySettings = false;
internal static void InitSettings()
{
if (!initKeySettings)
{
initKeySettings = true;
keyActions.Clear();
Plugin.X("Loading keybinds from config");
CollectionOfKeys();
TogglePiPKey();
CreateMenuCommand();
if ((Object)(object)menuDisplay == (Object)null)
{
menuDisplay = AddingThings.CreateDummyNode("suitsTerminal AdvancedMenu", true, "");
}
initKeySettings = false;
}
}
private static void GetCurrentSuitNum()
{
if (StartOfRound.Instance.localPlayerController.currentSuitID >= 0)
{
GetCurrentSuitID();
Plugin.X($"currentSuitID: {StartOfRound.Instance.localPlayerController.currentSuitID}\n UnlockableItems: {AllSuits.UnlockableItems.Count}");
}
}
internal static void CreateMenuCommand()
{
if (SConfig.AdvancedTerminalMenu.Value)
{
CommandHandler.AddCommand(clearText: true, "suits", "advanced_suitsTerm", CommandHandler.AdvancedSuitsTerm, ConfigSetup.defaultListing, "other", "suitsTerminal advanced menu for changing suits");
}
}
private static void CollectionOfKeys()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
CheckKeys(SConfig.MenuUp.Value, out var usingKey, out upString);
BindKeys("previous_item", usingKey, ref upString, "UpArrow", (Key)63);
CheckKeys(SConfig.MenuDown.Value, out var usingKey2, out downString);
BindKeys("next_item", usingKey2, ref downString, "DownArrow", (Key)64);
CheckKeys(SConfig.MenuLeft.Value, out var usingKey3, out leftString);
BindKeys("previous_page", usingKey3, ref leftString, "LeftArrow", (Key)61);
CheckKeys(SConfig.MenuRight.Value, out var usingKey4, out rightString);
BindKeys("next_page", usingKey4, ref rightString, "RightArrow", (Key)62);
CheckKeys(SConfig.LeaveMenu.Value, out var usingKey5, out leaveString);
BindKeys("leave_menu", usingKey5, ref leaveString, "Backspace", (Key)65);
CheckKeys(SConfig.SelectMenu.Value, out var usingKey6, out selectString);
BindKeys("menu_select", usingKey6, ref selectString, "Enter", (Key)2);
CheckKeys(SConfig.FavItemKey.Value, out var usingKey7, out favItemKeyString);
BindKeys("favorite_item", usingKey7, ref favItemKeyString, "F", (Key)20);
CheckKeys(SConfig.FavMenuKey.Value, out var usingKey8, out favMenuKeyString);
BindKeys("favorites_menu", usingKey8, ref favMenuKeyString, "F1", (Key)94);
CheckKeys(SConfig.HelpMenu.Value, out var usingKey9, out helpMenuKeyString);
BindKeys("help_menu", usingKey9, ref helpMenuKeyString, "H", (Key)22);
}
private static void BindKeys(string menuAction, Key givenKey, ref string givenKeyString, string defaultKeyString, Key defaultKey)
{
//IL_0010: 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_0018: Unknown result type (might be due to invalid IL or missing references)
Plugin.X("Binding " + menuAction);
if ((int)givenKey != 0)
{
keyActions.Add(givenKey, menuAction);
Plugin.X(givenKeyString + " bound to " + menuAction);
}
else
{
keyActions.Add(defaultKey, menuAction);
givenKeyString = defaultKeyString;
Plugin.X(givenKeyString + " bound to " + menuAction);
}
}
private static void CheckKeys(string configString, out Key usingKey, out string keyString)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected I4, but got Unknown
if (IsValidKey(configString, out var validKey))
{
usingKey = (Key)(int)validKey;
keyString = configString;
}
else
{
usingKey = (Key)0;
keyString = "FAIL";
}
}
private static void TogglePiPKey()
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
if (SConfig.EnablePiPCamera.Value)
{
CheckKeys(SConfig.TogglePiPHeight.Value, out var usingKey, out pipHeightString);
BindKeys("pip_height", usingKey, ref pipHeightString, "Backslash", (Key)10);
CheckKeys(SConfig.TogglePiPRotation.Value, out var usingKey2, out pipRotateString);
BindKeys("pip_rotate", usingKey2, ref pipRotateString, "Equals", (Key)14);
CheckKeys(SConfig.TogglePiPZoom.Value, out var usingKey3, out pipZoomString);
BindKeys("pip_zoom", usingKey3, ref pipZoomString, "Minus", (Key)13);
if (IsValidKey(SConfig.TogglePiP.Value, out var validKey))
{
togglePiP = validKey;
keyActions.Add(togglePiP, "toggle_pip");
togglePiPstring = SConfig.TogglePiP.Value;
}
else
{
keyActions.Add((Key)105, "toggle_pip");
togglePiPstring = "F12";
}
}
}
private static bool IsValidKey(string key, out Key validKey)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Expected I4, but got Unknown
List<Key> list = new List<Key>(1) { (Key)3 };
if (Enum.TryParse<Key>(key, ignoreCase: true, out Key result))
{
if (list.Contains(result))
{
Plugin.WARNING("Tab Key detected, rejecting bind.");
validKey = (Key)0;
return false;
}
if (keyActions.ContainsKey(result))
{
Plugin.WARNING("Key was already bound to something, returning false");
string text = string.Join(", ", keyActions.Keys);
Plugin.WARNING("Key list: " + text);
validKey = (Key)0;
return false;
}
Plugin.X("Valid Key Detected and being assigned to bind");
validKey = (Key)(int)result;
return true;
}
validKey = (Key)0;
return false;
}
internal static void TerminalInputEnabled(bool state)
{
if (!state)
{
((Selectable)Plugin.Terminal.screenText).interactable = false;
Plugin.Terminal.currentNode.maxCharactersToType = 0;
}
else
{
((Selectable)Plugin.Terminal.screenText).interactable = true;
Plugin.Terminal.currentNode.maxCharactersToType = 25;
}
}
public static bool AnyKeyIsPressed()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
TerminalInputEnabled(state: false);
foreach (KeyValuePair<Key, string> keyAction in keyActions)
{
if (((ButtonControl)Keyboard.current[keyAction.Key]).isPressed)
{
keyBeingPressed = keyAction.Key;
Plugin.X($"Key detected in use: {keyAction.Key}");
return true;
}
}
return false;
}
private static void HandleKeyPress(Key key)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
if (keyActions.ContainsKey(key))
{
keyActions.TryGetValue(key, out string value);
Plugin.X("Attempting to match given key to action: " + value);
HandleKeyAction(value);
}
else
{
Plugin.Log.LogError((object)"Shortcut KeyActions list not updating properly");
}
}
internal static Camera GetCam()
{
if (Plugin.instance.OpenBodyCamsMod && SConfig.UseOpenBodyCams.Value)
{
Plugin.X("Returning Cam from OpenLib OpenBodyCams Compat!");
return OpenBodyCamFuncs.GetCam(OpenBodyCamFuncs.TerminalMirrorCam);
}
PictureInPicture.playerCam = CamStuff.MyCameraHolder.GetComponent<Camera>();
return PictureInPicture.playerCam;
}
private static void HandleKeyAction(string value)
{
Camera cam = GetCam();
if (value == "previous_page" && !inHelpMenu)
{
if (currentPage > 0)
{
currentPage--;
}
menuDisplay.displayText = StringStuff.AdvancedMenuDisplay(AllSuits.suitListing, activeSelection, 10, currentPage);
Plugin.Terminal.LoadNewNode(menuDisplay);
TerminalInputEnabled(state: false);
Plugin.X($"Current Page: {currentPage}\n Current Item: {activeSelection}");
}
else if (value == "next_page" && !inHelpMenu)
{
currentPage++;
menuDisplay.displayText = StringStuff.AdvancedMenuDisplay(AllSuits.suitListing, activeSelection, 10, currentPage);
Plugin.Terminal.LoadNewNode(menuDisplay);
TerminalInputEnabled(state: false);
Plugin.X($"Current Page: {currentPage}\n Current Item: {activeSelection}");
}
else if (value == "previous_item" && !inHelpMenu)
{
if (activeSelection > 0)
{
activeSelection--;
}
menuDisplay.displayText = StringStuff.AdvancedMenuDisplay(AllSuits.suitListing, activeSelection, 10, currentPage);
Plugin.Terminal.LoadNewNode(menuDisplay);
TerminalInputEnabled(state: false);
Plugin.X($"Current Page: {currentPage}\n Current Item: {activeSelection}");
}
else if (value == "next_item" && !inHelpMenu)
{
activeSelection++;
menuDisplay.displayText = StringStuff.AdvancedMenuDisplay(AllSuits.suitListing, activeSelection, 10, currentPage);
Plugin.Terminal.LoadNewNode(menuDisplay);
TerminalInputEnabled(state: false);
Plugin.X($"Current Page: {currentPage}\n Current Item: {activeSelection}");
}
else if (value == "leave_menu")
{
exitSpecialMenu = true;
TerminalInputEnabled(state: true);
}
else if (value == "menu_select" && !inHelpMenu)
{
SuitAttributes menuItemSuit = StringStuff.GetMenuItemSuit(AllSuits.suitListing, activeSelection);
CommandHandler.BetterSuitPick(menuItemSuit);
Plugin.X($"Current Page: {currentPage}\n Current Item: {activeSelection}");
GetCurrentSuitNum();
menuDisplay.displayText = StringStuff.AdvancedMenuDisplay(AllSuits.suitListing, activeSelection, 10, currentPage);
Plugin.Terminal.LoadNewNode(menuDisplay);
TerminalInputEnabled(state: false);
}
else if (value == "toggle_pip" && !inHelpMenu)
{
PictureInPicture.TogglePiP(!PictureInPicture.pipActive);
Plugin.X($"Toggling PiP to state {!PictureInPicture.pipActive}");
}
else if (value == "pip_height" && !inHelpMenu)
{
if (!((Object)(object)cam == (Object)null))
{
PictureInPicture.MoveCamera(((Component)cam).transform, ref PictureInPicture.heightStep);
Plugin.X($"Changing PiP height to {PictureInPicture.heightStep}");
}
}
else if (value == "pip_rotate" && !inHelpMenu)
{
if (!((Object)(object)cam == (Object)null))
{
PictureInPicture.RotateCameraAroundPlayer(StartOfRound.Instance.localPlayerController.meshContainer, ((Component)cam).transform);
Plugin.X("Rotating PiP around player");
}
}
else if (value == "pip_zoom" && !inHelpMenu)
{
if (!((Object)(object)cam == (Object)null))
{
PictureInPicture.ChangeCamZoom(cam, ref PictureInPicture.zoomStep);
Plugin.X($"Changing PiP zoom to zoomStep: [{PictureInPicture.zoomStep}]");
}
}
else if (value == "favorite_item" && !inHelpMenu)
{
SuitAttributes menuItemSuit2 = StringStuff.GetMenuItemSuit(AllSuits.suitListing, activeSelection);
if (AllSuits.suitListing.FavList.Contains(menuItemSuit2.Name))
{
menuItemSuit2.RemoveFromFavs();
foreach (SuitAttributes suits in AllSuits.suitListing.SuitsList)
{
suits.RefreshFavIndex();
}
Plugin.Log.LogInfo((object)(menuItemSuit2.Name + " removed from favorites listing"));
}
else
{
menuItemSuit2.AddToFavs();
Plugin.Log.LogInfo((object)(menuItemSuit2.Name + " added to favorites listing"));
}
Misc.SaveToConfig(AllSuits.suitListing.FavList, out string configItem);
SConfig.FavoritesMenuList.Value = configItem;
Plugin.X($"Current Page: {currentPage}\n Current Item: {activeSelection}");
menuDisplay.displayText = StringStuff.AdvancedMenuDisplay(AllSuits.suitListing, activeSelection, 10, currentPage);
Plugin.Terminal.LoadNewNode(menuDisplay);
TerminalInputEnabled(state: false);
}
else if (value == "favorites_menu" && !inHelpMenu)
{
inFavsMenu = !inFavsMenu;
currentPage = 1;
GetCurrentSuitNum();
menuDisplay.displayText = StringStuff.AdvancedMenuDisplay(AllSuits.suitListing, 0, 10, currentPage);
Plugin.Terminal.LoadNewNode(menuDisplay);
TerminalInputEnabled(state: false);
}
else if (value == "help_menu")
{
inHelpMenu = !inHelpMenu;
currentPage = 1;
GetCurrentSuitNum();
menuDisplay.displayText = Misc.HelpMenuDisplay(inHelpMenu);
PictureInPicture.TogglePiP(!inHelpMenu);
Plugin.Terminal.LoadNewNode(menuDisplay);
TerminalInputEnabled(state: false);
}
}
internal static void GetCurrentSuitID()
{
foreach (SuitAttributes suits in AllSuits.suitListing.SuitsList)
{
if (suits.Suit.suitID == StartOfRound.Instance.localPlayerController.currentSuitID || suits.Suit.syncedSuitID.Value == StartOfRound.Instance.localPlayerController.currentSuitID)
{
suits.currentSuit = true;
Plugin.X("Detected wearing - " + suits.Name);
}
else
{
suits.currentSuit = false;
}
}
}
private static void PiPSetParent()
{
if (SConfig.EnablePiPCamera.Value)
{
((Component)PictureInPicture.pipRawImage).transform.SetParent(((Component)((Selectable)Plugin.Terminal.screenText).image).transform);
}
}
internal static IEnumerator ActiveMenu()
{
if (specialMenusActive)
{
yield break;
}
specialMenusActive = true;
inFavsMenu = false;
PictureInPicture.rotateStep = 0;
PictureInPicture.heightStep = 0;
PictureInPicture.zoomStep = 1;
GetCurrentSuitNum();
PictureInPicture.TogglePiP(state: true);
Plugin.Terminal.screenText.DeactivateInputField(false);
((Selectable)Plugin.Terminal.screenText).interactable = false;
yield return (object)new WaitForSeconds(0.2f);
Plugin.X("ActiveMenu Coroutine");
currentPage = 1;
activeSelection = 0;
PiPSetParent();
while (Plugin.Terminal.terminalInUse && SConfig.AdvancedTerminalMenu.Value && !exitSpecialMenu)
{
if (AnyKeyIsPressed())
{
HandleKeyPress(keyBeingPressed);
yield return (object)new WaitForSeconds(SConfig.MenuKeyPressDelay.Value);
}
else
{
yield return (object)new WaitForSeconds(SConfig.MenuPostSelectDelay.Value);
}
}
if (!Plugin.Terminal.terminalInUse)
{
Plugin.X("Terminal no longer in use");
}
if (exitSpecialMenu)
{
exitSpecialMenu = false;
}
specialMenusActive = false;
PictureInPicture.TogglePiP(state: false);
yield return (object)new WaitForSeconds(0.1f);
Plugin.Terminal.screenText.ActivateInputField();
((Selectable)Plugin.Terminal.screenText).interactable = true;
Plugin.Terminal.LoadNewNode(Plugin.Terminal.terminalNodes.specialNodes[13]);
}
}
internal class CommandHandler
{
internal static string RandomSuit()
{
Plugin.X($"Suit Count: {AllSuits.suitListing.SuitsList.Count}");
Random random = new Random();
int num = random.Next(AllSuits.suitListing.SuitsList.Count);
SuitAttributes suitAttributes = AllSuits.suitListing.SuitsList[num];
suitAttributes.Suit.SwitchSuitToThis(StartOfRound.Instance.localPlayerController);
return $"Rolled random number [ {num} ]\n\n\nChanging suit to {suitAttributes.Name}!\r\n\r\n";
}
internal static string SuitPickCommand()
{
return PickSuit();
}
internal static string AdvancedSuitsTerm()
{
((MonoBehaviour)Plugin.Terminal).StartCoroutine(AdvancedMenu.ActiveMenu());
return StringStuff.AdvancedMenuDisplay(AllSuits.suitListing, 0, 10, 1);
}
internal static void BetterSuitPick(SuitAttributes suit)
{
if ((Object)(object)suit.Suit == (Object)null)
{
Plugin.ERROR("suit is null!");
return;
}
suit.Suit.SwitchSuitToThis(StartOfRound.Instance.localPlayerController);
Plugin.Log.LogMessage((object)("Switched suit to " + suit.Name));
}
internal static string PickSuit()
{
Plugin.X($"Suit Count: {AllSuits.suitListing.SuitsList.Count}");
Plugin.X($"Unlockables Count: {AllSuits.UnlockableItems.Count}");
string text = CommonStringStuff.GetCleanedScreenText(Plugin.Terminal).ToLower();
foreach (SuitAttributes suits in AllSuits.suitListing.SuitsList)
{
if (suits.Suit.syncedSuitID.Value >= 0)
{
string text2 = StringStuff.TerminalFriendlyString(suits.Name);
if (text.Equals("wear " + text2))
{
suits.Suit.SwitchSuitToThis(StartOfRound.Instance.localPlayerController);
return "Changing suit to " + suits.Name + "\r\n";
}
Plugin.X("SuitName: " + suits.Name + " doesn't match Cleaned Text: " + text);
}
else
{
Plugin.X($"suit ID was {suits.Suit.syncedSuitID.Value}");
}
}
return "Unable to set suit to match command: " + text;
}
internal static void AddCommand(bool clearText, string keyWord, string nodeName, Func<string> methodName, MainListing nodeListing, string category = "", string description = "")
{
TerminalNode val = AddingThings.AddNodeManual(nodeName, keyWord, methodName, clearText, 0, nodeListing, 0, (Func<string>)null, (Func<string>)null, "", "", false, 1, "", false, "");
TerminalNode val2 = default(TerminalNode);
if (category.ToLower() == "other" && LogicHandling.TryGetFromAllNodes("OtherCommands", ref val2))
{
AddingThings.AddToExistingNodeText("\n>" + keyWord.ToUpper() + "\n" + description, ref val2);
}
}
internal static void AddBasicCommand(string nodeName, string keyWord, string displayText, string category = "", string description = "")
{
AddingThings.AddBasicCommand(nodeName, keyWord, displayText, false, true, category, description);
}
}
internal class OldCommands
{
internal static void CreateOldWearCommands(SuitAttributes suit, ref List<string> suitNames)
{
if (!SConfig.TerminalCommands.Value || SConfig.AdvancedTerminalMenu.Value || suit.HideFromTerminal)
{
return;
}
if (suit.Suit.syncedSuitID.Value >= 0 && !Misc.keywordsCreated)
{
suit.Name = StringStuff.TerminalFriendlyString(suit.Name);
if (suitNames.Contains(suit.Name.ToLower()))
{
suit.Name += "z";
Plugin.WARNING("Duplicate found. Updated SuitName: " + suit.Name);
}
suitNames.Add(suit.Name.ToLower());
CommandHandler.AddCommand(clearText: true, "wear " + suit.Name, suit.Name, CommandHandler.SuitPickCommand, ConfigSetup.defaultListing);
Plugin.X("Keyword for " + suit.Name + " added");
}
else if (suit.Suit.syncedSuitID.Value >= 0 && Misc.keywordsCreated)
{
suit.Name = StringStuff.TerminalFriendlyString(suit.Name);
CommandHandler.AddCommand(clearText: true, "wear " + suit.Name, suit.Name, CommandHandler.SuitPickCommand, ConfigSetup.defaultListing);
Plugin.X("Keyword for " + suit.Name + " updated");
}
else if (suit.Suit.syncedSuitID.Value < 0)
{
Misc.weirdSuitNum++;
Plugin.WARNING($"Skipping suit with invalid ID number: {suit.Suit.syncedSuitID.Value}");
}
else
{
Plugin.WARNING("Unexpected condition in CreateOldWearCommands!");
}
}
internal static void CreateOldPageCommands()
{
if (SConfig.TerminalCommands.Value && !SConfig.AdvancedTerminalMenu.Value)
{
if ((Object)(object)Plugin.Terminal != (Object)null && !Misc.keywordsCreated)
{
StringBuilder suitsList = BuildSuitsList();
CreateSuitPages(suitsList);
Misc.keywordsCreated = true;
}
else if (Misc.keywordsCreated)
{
StringBuilder suitsList2 = BuildSuitsList();
UpdateOrRecreateSuitKeywords(suitsList2);
}
}
}
private static StringBuilder BuildSuitsList()
{
StringBuilder stringBuilder = new StringBuilder();
Misc.weirdSuitNum = 0;
foreach (SuitAttributes suits in AllSuits.suitListing.SuitsList)
{
if ((Object)(object)suits.Suit == (Object)null)
{
Plugin.WARNING(suits.Name + " contains NULL suit ref");
}
else if (!suits.HideFromTerminal)
{
if (suits.Suit.syncedSuitID.Value >= 0)
{
string name = suits.Name;
name = StringStuff.TerminalFriendlyString(name);
stringBuilder.AppendLine("> wear " + name + "\n");
}
else
{
Misc.weirdSuitNum++;
Plugin.X("Skipping suit.");
}
}
}
Plugin.X($"Full Suit List: {stringBuilder}");
return stringBuilder;
}
private static void CreateSuitPages(StringBuilder suitsList)
{
List<Page> list = PageSplitter.SplitTextIntoPages(suitsList.ToString(), 6);
if (!SConfig.TerminalCommands.Value)
{
return;
}
foreach (Page item in list)
{
if (item.PageNumber == 1)
{
CreateOrUpdateMainSuitCommand(item);
}
else
{
CreateOrUpdateSuitPage(item);
}
}
}
private static void UpdateOrRecreateSuitKeywords(StringBuilder suitsList)
{
List<Page> list = PageSplitter.SplitTextIntoPages(suitsList.ToString(), 6);
if (!SConfig.TerminalCommands.Value)
{
return;
}
foreach (Page item in list)
{
if (item.PageNumber == 1)
{
CreateOrUpdateMainSuitCommand(item);
}
else
{
CreateOrUpdateSuitPage(item);
}
}
}
private static void CreateOrUpdateMainSuitCommand(Page page)
{
CommandHandler.AddBasicCommand("suits (main)", "suits", $"{page.Content}", "other", "Display a listing of available suits to wear");
Plugin.X("Updating main suits command");
}
private static void CreateOrUpdateSuitPage(Page page)
{
Plugin.X($"Creating page {page.PageNumber} keyword");
CommandHandler.AddBasicCommand("suits (pg.{page.PageNumber})", $"suits {page.PageNumber}", $"{page.Content}");
}
internal static void MakeRandomSuitCommand()
{
if (SConfig.RandomSuitCommand.Value)
{
CommandHandler.AddCommand(clearText: true, "randomsuit", "random suit command", CommandHandler.RandomSuit, ConfigSetup.defaultListing, "other", "Equip a random suit");
}
}
}
internal class PictureInPicture
{
internal static bool PiPCreated;
internal static GameObject pipGameObject;
internal static int cullingMaskInt;
internal static Camera playerCam;
internal static RenderTexture camTexture;
internal static RawImage pipRawImage;
internal static bool pipActive;
internal static int heightStep;
internal static int zoomStep;
internal static int rotateStep;
internal static ShadowCastingMode shadowDefault;
internal static int modelLayerDefault;
internal static void InitPiP()
{
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
if (PiPCreated || !SConfig.EnablePiPCamera.Value)
{
return;
}
if ((Object)(object)Plugin.Terminal.terminalImage == (Object)null)
{
Plugin.WARNING("Original terminalImage not found");
return;
}
if ((Object)(object)pipGameObject != (Object)null && (Object)(object)pipGameObject.gameObject != (Object)null)
{
Object.Destroy((Object)(object)pipGameObject.gameObject);
}
pipGameObject = Object.Instantiate<GameObject>(((Component)Plugin.Terminal.terminalImage).gameObject, ((Component)Plugin.Terminal.terminalImage).transform.parent);
((Object)pipGameObject).name = "suitsTerminal PiP (Clone)";
if ((Object)(object)pipGameObject.GetComponent<VideoPlayer>() != (Object)null)
{
VideoPlayer component = pipGameObject.GetComponent<VideoPlayer>();
Object.Destroy((Object)(object)component);
Plugin.X("extra videoPlayer deleted");
}
pipRawImage = pipGameObject.GetComponent<RawImage>();
SetRawImageDimensionsAndPosition(((Graphic)pipRawImage).rectTransform, 0.45f, 0.33f, 90f, -12f);
((Graphic)pipRawImage).color = new Color(1f, 1f, 1f, 0.9f);
pipGameObject.SetActive(false);
PiPCreated = true;
}
private static void SetRawImageDimensionsAndPosition(RectTransform rectTransform, float heightPercentage, float widthPercentage, float anchoredPosX, float anchoredPosY)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: 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_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: 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)
RectTransform component = ((Component)Plugin.Terminal.terminalUIScreen).GetComponent<RectTransform>();
Rect rect = component.rect;
float num = ((Rect)(ref rect)).height * heightPercentage;
rect = component.rect;
float num2 = ((Rect)(ref rect)).width * widthPercentage;
rectTransform.sizeDelta = new Vector2(num2, num);
rectTransform.anchoredPosition = new Vector2(anchoredPosX, anchoredPosY);
}
internal static void RotateCameraAroundPlayer(Transform playerTransform, Transform cameraTransform)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: 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_0023: 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_002c: 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_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: 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_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: 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_0051: Unknown result type (might be due to invalid IL or missing references)
Quaternion val = Quaternion.LookRotation(-playerTransform.right, playerTransform.up);
Quaternion rotation = val * cameraTransform.rotation;
cameraTransform.rotation = rotation;
Vector3 val2 = cameraTransform.position - playerTransform.position;
Vector3 position = playerTransform.position + val * val2;
cameraTransform.position = position;
}
internal static void ChangeCamZoom(Camera camera, ref int currentStep)
{
float[] array = new float[4] { 120f, 60f, 80f, 100f };
currentStep++;
if (currentStep >= array.Length)
{
currentStep = 0;
}
camera.fieldOfView = array[currentStep];
}
internal static void MoveCamera(Transform cameraTransform, ref int currentStep)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
float[] array = new float[5] { 0f, 0.2f, -2.2f, -1.2f, -0.7f };
currentStep++;
if (currentStep >= array.Length)
{
currentStep = 0;
}
float y = ((Component)Plugin.Terminal.terminalImage).transform.position.y + array[currentStep];
Vector3 position = cameraTransform.position;
position.y = y;
cameraTransform.position = position;
}
internal static void TogglePiP(bool state)
{
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
if (!SConfig.EnablePiPCamera.Value)
{
return;
}
Plugin.X($"TogglePiP: {state}");
pipActive = state;
((Behaviour)pipRawImage).enabled = state;
pipGameObject.SetActive(state);
if (Plugin.instance.OpenBodyCamsMod && SConfig.UseOpenBodyCams.Value)
{
Plugin.X("OpenBodyCams detected, using OBC for Mirror");
OpenBodyCamFuncs.OpenBodyCamsMirrorStatus(state, SConfig.ObcResolution.Value, 0.1f, false, ref CamStuff.ObcCameraHolder);
Camera cam = OpenBodyCamFuncs.GetCam(OpenBodyCamFuncs.TerminalMirrorCam);
cam.fieldOfView = 100f;
Plugin.X($"isActive [ Cam ] - {((Behaviour)cam).isActiveAndEnabled}");
pipRawImage.texture = OpenBodyCamFuncs.GetTexture(OpenBodyCamFuncs.TerminalMirrorCam);
}
else
{
if ((Object)(object)playerCam == (Object)null)
{
playerCam = CamStuff.HomebrewCam(ref camTexture, ref CamStuff.MyCameraHolder);
}
CamStuff.CamInitMirror(CamStuff.MyCameraHolder, playerCam, 0.1f, false);
CamStuff.HomebrewCameraState(state, playerCam);
playerCam.fieldOfView = 100f;
pipRawImage.texture = (Texture)(object)playerCam.targetTexture;
if (!Plugin.instance.ModelReplacement)
{
if (state)
{
((Renderer)StartOfRound.Instance.localPlayerController.thisPlayerModel).shadowCastingMode = (ShadowCastingMode)0;
}
else
{
((Renderer)StartOfRound.Instance.localPlayerController.thisPlayerModel).shadowCastingMode = shadowDefault;
}
}
}
Plugin.X($"isActive [ pipGameObject ] - {pipGameObject.activeSelf}\nisActive [ pipRawImage ] {((Behaviour)pipRawImage).isActiveAndEnabled}\nisActive [ pipActive ] - {pipActive}");
}
}
}
namespace suitsTerminal.Suit_Stuff
{
internal class SuitListing
{
internal List<SuitAttributes> SuitsList = new List<SuitAttributes>();
internal List<UnlockableSuit> RawSuitsList = new List<UnlockableSuit>();
internal int CurrentMenu;
internal List<string> NameList = new List<string>();
internal List<string> FavList = new List<string>();
internal bool Contains(int query, out SuitAttributes thisSuit)
{
foreach (SuitAttributes suits in SuitsList)
{
if (suits.UniqueID == query)
{
thisSuit = suits;
return true;
}
}
thisSuit = null;
return false;
}
internal bool Contains(UnlockableSuit query, out SuitAttributes thisSuit)
{
foreach (SuitAttributes suits in SuitsList)
{
if ((Object)(object)suits.Suit == (Object)(object)query)
{
thisSuit = suits;
return true;
}
}
thisSuit = null;
return false;
}
}
internal class SuitAttributes
{
internal UnlockableSuit Suit;
internal bool HideFromTerminal;
internal bool IsOnRack;
internal string Name = "placeholder";
internal int UniqueID = -1;
internal bool IsFav;
internal int MainMenuIndex = -1;
internal int FavIndex = -1;
internal bool currentSuit;
internal SuitAttributes(UnlockableSuit item, List<UnlockableItem> UnlockableItems, ref Dictionary<int, string> suitNameToID)
{
Suit = item;
Name = GetName(item, UnlockableItems, ref suitNameToID);
UniqueID = item.syncedSuitID.Value;
AllSuits.suitListing.NameList.Add(Name);
HideFromTerminal = ShouldHideTerm();
IsFav = IsFavorite();
SetIndex();
Plugin.X("SuitAttributes created for " + Name);
}
internal void UpdateSuit(UnlockableSuit item, List<UnlockableItem> UnlockableItems, ref Dictionary<int, string> suitNameToID)
{
Suit = item;
Name = GetName(item, UnlockableItems, ref suitNameToID);
UniqueID = item.syncedSuitID.Value;
AllSuits.suitListing.NameList.Add(Name);
HideFromTerminal = ShouldHideTerm();
IsFav = IsFavorite();
SetIndex();
Plugin.X("SuitAttributes updated for " + Name);
}
internal void SetIndex()
{
if (HideFromTerminal)
{
MainMenuIndex = -1;
AllSuits.suitListing.NameList.Remove(Name);
}
MainMenuIndex = AllSuits.suitListing.NameList.IndexOf(Name);
if (IsFav)
{
AddToFavs();
}
}
internal int GetIndex(List<string> listing)
{
if (listing.Contains(Name))
{
return listing.IndexOf(Name);
}
return -1;
}
internal bool IsFavorite()
{
List<string> keywordsPerConfigItem = CommonStringStuff.GetKeywordsPerConfigItem(SConfig.FavoritesMenuList.Value, ',');
if (keywordsPerConfigItem.Any((string x) => x.ToLower() == Name.ToLower()))
{
Plugin.X(Name + " is detected in favorites list");
return true;
}
Plugin.X(Name + " is *NOT* a favorite");
return false;
}
internal void RemoveFromFavs()
{
IsFav = false;
AllSuits.suitListing.FavList.Remove(Name);
FavIndex = -1;
}
internal void AddToFavs()
{
IsFav = true;
AllSuits.suitListing.FavList.Add(Name);
FavIndex = AllSuits.suitListing.FavList.IndexOf(Name);
}
internal void RefreshFavIndex()
{
if (AllSuits.suitListing.FavList.Contains(Name))
{
FavIndex = AllSuits.suitListing.FavList.IndexOf(Name);
}
}
internal bool ShouldHideTerm()
{
List<string> listToLower = CommonStringStuff.GetListToLower(CommonStringStuff.GetKeywordsPerConfigItem(SConfig.DontAddToTerminal.Value, ','));
if (listToLower.Any((string x) => x.ToLower() == Name.ToLower()))
{
return true;
}
return false;
}
internal static string GetName(UnlockableSuit item, List<UnlockableItem> UnlockableItems, ref Dictionary<int, string> suitNameToID)
{
string text = UnlockableItems[item.syncedSuitID.Value].unlockableName;
if (AllSuits.suitListing.NameList.Contains(text) && SConfig.AdvancedTerminalMenu.Value)
{
text += "(1)";
}
if (!SConfig.AdvancedTerminalMenu.Value)
{
text = StringStuff.TerminalFriendlyString(text);
}
if (!suitNameToID.ContainsKey(item.syncedSuitID.Value))
{
suitNameToID.Add(item.syncedSuitID.Value, text);
}
else
{
Plugin.WARNING($"WARNING: duplicate suitID detected: {item.syncedSuitID.Value}\n{text} will not be added to listing");
}
return text;
}
}
}
namespace suitsTerminal.EventSub
{
internal class Subscribers
{
[CompilerGenerated]
private static class <>O
{
public static ParameterEvent<Terminal> <0>__OnTerminalAwake;
public static Event <1>__SetDefaultSuit;
public static ParameterEvent<TerminalNode> <2>__OnLoadAffordable;
public static Event <3>__OnGameStart;
public static Event <4>__OnPlayerSpawn;
}
internal static void Subscribe()
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Expected O, but got Unknown
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Expected O, but got Unknown
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Expected O, but got Unknown
EventManager.TerminalAwake.AddListener((ParameterEvent<Terminal>)OnTerminalAwake);
CustomEvent terminalDelayStart = EventManager.TerminalDelayStart;
object obj = <>O.<1>__SetDefaultSuit;
if (obj == null)
{
Event val = SetDefaultSuit;
<>O.<1>__SetDefaultSuit = val;
obj = (object)val;
}
terminalDelayStart.AddListener((Event)obj);
EventManager.TerminalLoadIfAffordable.AddListener((ParameterEvent<TerminalNode>)TerminalGeneral.OnLoadAffordable);
CustomEvent gameNetworkManagerStart = EventManager.GameNetworkManagerStart;
object obj2 = <>O.<3>__OnGameStart;
if (obj2 == null)
{
Event val2 = OnGameStart;
<>O.<3>__OnGameStart = val2;
obj2 = (object)val2;
}
gameNetworkManagerStart.AddListener((Event)obj2);
CustomEvent playerSpawn = EventManager.PlayerSpawn;
object obj3 = <>O.<4>__OnPlayerSpawn;
if (obj3 == null)
{
Event val3 = OnPlayerSpawn;
<>O.<4>__OnPlayerSpawn = val3;
obj3 = (object)val3;
}
playerSpawn.AddListener((Event)obj3);
}
internal static void SetDefaultSuit()
{
DefaultSuit();
}
internal static void OnTerminalAwake(Terminal instance)
{
Plugin.Terminal = instance;
Plugin.X("Setting suitsTerminal.Terminal");
ResetVars();
}
private static void ResetVars()
{
Misc.hasLaunched = false;
Misc.suitsOnRack = 0;
Misc.hintOnce = false;
Misc.rackSituated = false;
PictureInPicture.PiPCreated = false;
Plugin.X("set initial variables");
}
internal static void OnGameStart()
{
CompatibilityCheck();
}
private static void CompatibilityCheck()
{
if (StartGame.SoftCompatibility("darmuh.TerminalStuff", ref Plugin.TerminalStuff))
{
Plugin.X("darmuhsTerminalStuff compatibility enabled!");
}
if (StartGame.SoftCompatibility("Hexnet.lethalcompany.suitsaver", ref Plugin.SuitSaver))
{
Plugin.X("Suitsaver compatibility enabled!\nDefaultSuit will not be loaded");
}
}
private static void DefaultSuit()
{
if (SConfig.DefaultSuit.Value.Length < 1 || SConfig.DefaultSuit.Value.ToLower() == "default")
{
return;
}
if (Plugin.SuitSaver)
{
Plugin.WARNING("Suitsaver detected, default suit will not be loaded.");
}
else if (AllSuits.suitListing.SuitsList.Any((SuitAttributes x) => x.Name.ToLower() == SConfig.DefaultSuit.Value.ToLower()))
{
SuitAttributes suit = AllSuits.suitListing.SuitsList.Find((SuitAttributes x) => x.Name.ToLower() == SConfig.DefaultSuit.Value.ToLower());
CommandHandler.BetterSuitPick(suit);
}
else
{
Plugin.WARNING("Could not set default suit to " + SConfig.DefaultSuit.Value);
}
}
internal static void OnPlayerSpawn()
{
if (!Misc.rackSituated)
{
Plugin.X("player loaded & rackSituated is false, fixing suits rack");
PiPStuff();
AdvancedMenu.InitSettings();
InitThisPlugin.InitSuitsTerm();
PictureInPicture.InitPiP();
Misc.hasLaunched = true;
}
}
private static void PiPStuff()
{
//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)
PictureInPicture.shadowDefault = ((Renderer)StartOfRound.Instance.localPlayerController.thisPlayerModel).shadowCastingMode;
PictureInPicture.modelLayerDefault = ((Component)StartOfRound.Instance.localPlayerController.thisPlayerModel).gameObject.layer;
}
}
internal class TerminalDisable
{
internal static void OnTerminalDisable()
{
}
}
internal class TerminalGeneral
{
internal static void OnLoadAffordable(TerminalNode node)
{
if (node.shipUnlockableID >= 0 && node.shipUnlockableID <= StartOfRound.Instance.unlockablesList.unlockables.Count && StartOfRound.Instance.unlockablesList.unlockables[node.shipUnlockableID].unlockableType == 0)
{
Plugin.X("suit purchase detected, refreshing suitsTerminal");
InitThisPlugin.InitSuitsTerm();
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}