using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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 TerminalStuff;
using TerminalStuff.EventSub;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering;
using UnityEngine.UI;
using UnityEngine.Video;
using suitsTerminal.Compatibility;
using suitsTerminal.EventSub;
using suitsTerminal.Suit_Stuff;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[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 FixRack func");
Subscribers.ResetSuitPlacementVars(unlocksReset: false);
AllSuits.FixRack();
}
}
}
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 (suit2.Name.Length > 1 && keywordsPerConfigItem.Count > 0 && !keywordsPerConfigItem.Any((string s) => s.ToLower() == suit2.Name.ToLower()))
{
return false;
}
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<bool> PersonalizedFavorites { 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 = ConfigSetup.MakeBool(((BaseUnityPlugin)Plugin.instance).Config, "General", "AdvancedTerminalMenu", true, "Enable this to utilize the advanced menu system and keybinds below");
ExtensiveLogging = ConfigSetup.MakeBool(((BaseUnityPlugin)Plugin.instance).Config, "General", "ExtensiveLogging", false, "Enable or Disable extensive logging for this mod.");
EnforcePaidSuits = ConfigSetup.MakeBool(((BaseUnityPlugin)Plugin.instance).Config, "General", "EnforcePaidSuits", true, "Enable or Disable enforcing paid suits being locked until they are paid for & unlocked.");
RandomSuitCommand = ConfigSetup.MakeBool(((BaseUnityPlugin)Plugin.instance).Config, "General", "RandomSuitCommand", false, "Enable/Disable the randomsuit terminal command.");
ChatCommands = ConfigSetup.MakeBool(((BaseUnityPlugin)Plugin.instance).Config, "General", "ChatCommands", false, "Enable/Disable suits commands via chat (!suits/!wear).");
TerminalCommands = ConfigSetup.MakeBool(((BaseUnityPlugin)Plugin.instance).Config, "General", "TerminalCommands", true, "Enable/Disable the base suits commands via terminal (suits, wear).");
DontRemove = ConfigSetup.MakeBool(((BaseUnityPlugin)Plugin.instance).Config, "General", "DontRemove", false, "Enable this to stop this mod from removing suits from the rack and make it compatible with other mods like TooManySuits.");
DefaultSuit = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "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 = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "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 = ConfigSetup.MakeClampedInt(((BaseUnityPlugin)Plugin.instance).Config, "Rack Settings", "SuitsOnRack", 13, "Number of suits to keep on the rack. (Up to 13)", 0, 13);
SuitsOnRackOnly = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "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 = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "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 = ConfigSetup.MakeBool(((BaseUnityPlugin)Plugin.instance).Config, "Rack Settings", "HideBoots", false, "Enable this to hide the boots by the rack.");
HideRack = ConfigSetup.MakeBool(((BaseUnityPlugin)Plugin.instance).Config, "Rack Settings", "HideRack", 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 = ConfigSetup.MakeClampedString(((BaseUnityPlugin)Plugin.instance).Config, "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 = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "AdvancedTerminalMenu", "FavoritesMenuList", "", "Favorited suit names will be stored here and displayed in the AdvancedTerminalMenu.");
PersonalizedFavorites = ConfigSetup.MakeBool(((BaseUnityPlugin)Plugin.instance).Config, "AdvancedTerminalMenu", "PersonalizedFavorites", false, "Enable this to ignore the FavoritesMenuList configuration item in favor of a personal file saving your favorites list.\nUse this if you dont want your favorites list to be shared with other players in modpacks/profile codes.");
EnablePiPCamera = ConfigSetup.MakeBool(((BaseUnityPlugin)Plugin.instance).Config, "AdvancedTerminalMenu", "EnablePiPCamera", true, "Disable this to stop the PiP camera from being created");
MenuLeft = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "AdvancedTerminalMenu", "MenuLeft", "LeftArrow", "Set key to press to go to previous page in advanced menu system");
MenuRight = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "AdvancedTerminalMenu", "MenuRight", "RightArrow", "Set key to press to go to next page in advanced menu system");
MenuUp = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "AdvancedTerminalMenu", "MenuUp", "UpArrow", "Set key to press to go to previous item on page in advanced menu system");
MenuDown = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "AdvancedTerminalMenu", "MenuDown", "DownArrow", "Set key to press to go to next item on page in advanced menu system");
LeaveMenu = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "AdvancedTerminalMenu", "LeaveMenu", "Backspace", "Set key to press to leave advanced menu system");
SelectMenu = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "AdvancedTerminalMenu", "SelectMenu", "Enter", "Set key to press to select an item in advanced menu system");
HelpMenu = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "AdvancedTerminalMenu", "HelpMenu", "H", "Set key to press to toggle help & controls page in advanced menu system");
FavItemKey = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "AdvancedTerminalMenu", "FavItemKey", "F", "Set key to press to set an item as a favorite in advanced menu system");
FavMenuKey = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "AdvancedTerminalMenu", "FavMenuKey", "F1", "Set key to press to show favorites menu in advanced menu system");
TogglePiP = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "AdvancedTerminalMenu", "TogglePiP", "F12", "Set key to press to toggle PiP (mirror cam) on/off in advanced menu system");
TogglePiPZoom = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "AdvancedTerminalMenu", "TogglePiPZoom", "Minus", "Set key to press to toggle PiP (mirror cam) zoom in advanced menu system");
TogglePiPRotation = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "AdvancedTerminalMenu", "TogglePiPRotation", "Equals", "Set key to press to toggle PiP (mirror cam) rotation in advanced menu system");
TogglePiPHeight = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "AdvancedTerminalMenu", "TogglePiPHeight", "Backslash", "Set key to press to toggle PiP (mirror cam) height in advanced menu system");
ChatHints = ConfigSetup.MakeBool(((BaseUnityPlugin)Plugin.instance).Config, "Hints", "ChatHints", false, "Determines whether chat hints are displayed at load in.");
BannerHints = ConfigSetup.MakeBool(((BaseUnityPlugin)Plugin.instance).Config, "Hints", "BannerHints", true, "Determines whether banner hints are displayed at load in.");
UseOpenBodyCams = ConfigSetup.MakeBool(((BaseUnityPlugin)Plugin.instance).Config, "OpenBodyCams", "UseOpenBodyCams", true, "Disable this to remove the banner hints displayed at load in.");
ObcResolution = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "OpenBodyCams", "ObcResolution", "1000; 700", "Set the resolution of the Mirror Camera created with OpenBodyCams");
ConfigSetup.RemoveOrphanedEntries(((BaseUnityPlugin)Plugin.instance).Config);
((BaseUnityPlugin)Plugin.instance).Config.Save();
((BaseUnityPlugin)Plugin.instance).Config.SettingChanged += OnSettingChanged;
}
private static void OnSettingChanged(object sender, SettingChangedEventArgs settingChangedArg)
{
if (settingChangedArg.ChangedSetting != null)
{
Plugin.X("CONFIG SETTING CHANGE EVENT");
if (settingChangedArg.ChangedSetting == PersonalizedFavorites)
{
AllSuits.InitFavoritesListing(checkList: true);
}
}
}
}
internal class Enums
{
internal static IEnumerator DelayFixRack()
{
yield return (object)new WaitForSeconds(2f);
Misc.suitsOnRack = 0;
Misc.rackSituated = false;
AdvancedMenu.specialMenusActive = false;
Subscribers.ResetSuitPlacementVars(unlocksReset: true);
Plugin.X("ShipResetStuff!");
AllSuits.FixRack();
Subscribers.DefaultSuit();
}
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 bool TryGetGameObject(string location, out GameObject gameobj)
{
gameobj = GameObject.Find(location);
return (Object)(object)gameobj != (Object)null;
}
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\nToggle 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, ref AdvancedMenu.currentPage);
}
internal static void SaveToConfig(List<string> stringList, out string configItem)
{
configItem = string.Join(", ", stringList);
Plugin.X("Saving to config\n" + configItem);
}
internal static void SaveFavorites(string saveText)
{
if (SConfig.PersonalizedFavorites.Value)
{
string name = Path.Combine("%userprofile%\\appdata\\locallow\\ZeekerssRBLX\\Lethal Company", "suitsTerminal") + "\\masterFavsListing.txt";
name = Environment.ExpandEnvironmentVariables(name);
File.WriteAllText(name, saveText);
Plugin.X("Favorites saved to file at " + name);
}
else
{
SConfig.FavoritesMenuList.Value = saveText;
}
}
}
[BepInPlugin("darmuh.suitsTerminal", "suitsTerminal", "1.5.12")]
[BepInDependency("darmuh.OpenLib", "0.2.11")]
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.12";
}
public static Plugin instance;
internal static bool TerminalStuff;
internal static bool SuitSaver;
internal static bool TooManySuits;
public static Terminal Terminal;
internal static ManualLogSource Log;
private void Awake()
{
instance = this;
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)"suitsTerminal version 1.5.12 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, ref 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());
AdvancedMenu.activeSelection = activeIndex;
string text;
if (suitAttributes != null)
{
text = ((i == activeIndex) ? ("> " + suitAttributes.Name + (suitAttributes.currentSuit ? " [EQUIPPED]" : "") + (suitAttributes.IsFav ? " (*)" : "")) : (suitAttributes.Name + (suitAttributes.currentSuit ? " [EQUIPPED]" : "") + (suitAttributes.IsFav ? " (*)" : "")));
}
else
{
text = ((i == activeIndex) ? $"> {i} - **MISSING SUIT**" : $"{i} - **MISSING SUIT**");
Plugin.WARNING($"Unable to find suit at index [ {i} ] of suitsTerminal suitListing!");
}
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();
internal static List<string> favsList = new List<string>();
internal 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;
}
if ((Object)(object)((Component)suit.suitRenderer).gameObject == (Object)null)
{
Plugin.WARNING("Suit [" + UnlockableItems[suit.syncedSuitID.Value].unlockableName + "] game object detected as null, not adding to listings.");
Plugin.X($"hasBeenUnlockedByPlayer: {UnlockableItems[suit.syncedSuitID.Value].hasBeenUnlockedByPlayer} \nalreadyUnlocked: {UnlockableItems[suit.syncedSuitID.Value].alreadyUnlocked}");
return false;
}
Plugin.X($"{UnlockableItems[suit.syncedSuitID.Value].unlockableName}:\nhasBeenUnlockedByPlayer: {UnlockableItems[suit.syncedSuitID.Value].hasBeenUnlockedByPlayer} \nalreadyUnlocked: {UnlockableItems[suit.syncedSuitID.Value].alreadyUnlocked}");
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 InitFavoritesListing(bool checkList = false)
{
if (SConfig.PersonalizedFavorites.Value)
{
string name = Path.Combine("%userprofile%\\appdata\\locallow\\ZeekerssRBLX\\Lethal Company", "suitsTerminal");
name = Environment.ExpandEnvironmentVariables(name);
if (!Directory.Exists(name))
{
Directory.CreateDirectory(name);
}
Plugin.X("Favorites file path - " + name);
if (!File.Exists(name + "\\masterFavsListing.txt"))
{
File.WriteAllText(name + "\\masterFavsListing.txt", SConfig.FavoritesMenuList.Value);
}
string text = File.ReadAllText(name + "\\masterFavsListing.txt");
Plugin.X("favoritesText: " + text);
favsList = CommonStringStuff.GetKeywordsPerConfigItem(text, ',');
foreach (string favs in favsList)
{
Plugin.X("-- " + favs + " --");
}
}
else
{
favsList = CommonStringStuff.GetKeywordsPerConfigItem(SConfig.FavoritesMenuList.Value, ',');
}
suitListing?.RefreshFavorites(checkList);
}
internal static void InitSuitsListing()
{
Plugin.X("InitSuitsListing");
FixRack();
OldCommands.MakeRandomSuitCommand();
}
private static void OrderSuitsByName()
{
suitListing.RawSuitsList = suitListing.RawSuitsList.OrderBy((UnlockableSuit suit) => UnlockableItems[suit.syncedSuitID.Value].unlockableName).ToList();
}
private static void OrderSuitsByID()
{
suitListing.RawSuitsList = suitListing.RawSuitsList.OrderBy((UnlockableSuit suit) => suit.syncedSuitID.Value).ToList();
}
private static void HideBootsAndRack()
{
if (!Misc.rackSituated)
{
if (SConfig.HideBoots.Value && Misc.TryGetGameObject("Environment/HangarShip/ScavengerModelSuitParts/Circle.004", out GameObject gameobj))
{
Object.Destroy((Object)(object)gameobj);
}
if (!SConfig.DontRemove.Value && SConfig.HideRack.Value && Misc.TryGetGameObject("Environment/HangarShip/NurbsPath.002", out GameObject gameobj2))
{
Object.Destroy((Object)(object)gameobj2);
}
}
}
internal static void FixRack()
{
suitListing.RawSuitsList.Clear();
suitListing.RawSuitsList = Object.FindObjectsByType<UnlockableSuit>((FindObjectsInactive)0, (FindObjectsSortMode)0).ToList();
suitNameToID.Clear();
suitListing.NameList.Clear();
UnlockableItems = StartOfRound.Instance.unlockablesList.unlockables;
RemoveBadSuitIDs();
Plugin.X($"Raw Suit Count: {suitListing.RawSuitsList.Count}");
Plugin.X($"Unlockables Count: {UnlockableItems.Count}");
Misc.weirdSuitNum = 0;
Misc.suitsOnRack = 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);
Plugin.X($"Added suit attributes for {thisSuit.Name} with ID {thisSuit.UniqueID}");
}
OldCommands.CreateOldWearCommands(thisSuit, ref suitNames);
if (!SConfig.DontRemove.Value && !Plugin.TooManySuits && (!thisSuit.IsOnRack || !Misc.rackSituated))
{
if (Bools.ShouldShowSuit(thisSuit))
{
thisSuit.IsOnRack = true;
ProcessRack.ProcessVisibleSuit(component, Misc.suitsOnRack);
Plugin.X("Showing suit - [ " + thisSuit.Name + " ]");
}
else
{
thisSuit.IsOnRack = false;
ProcessRack.ProcessHiddenSuit(component);
Plugin.X("Hiding suit - [ " + thisSuit.Name + " ]");
}
if (Misc.suitsOnRack == SConfig.SuitsOnRack.Value && !Misc.rackSituated)
{
Misc.rackSituated = true;
Plugin.X("Max suits are on the rack now. rack is situated, yippeee!!!");
}
}
}
if (SConfig.DontRemove.Value)
{
Plugin.WARNING("suitsTerminal is NOT touching the rack!!!");
}
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_001e: 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_0033: 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_003f: 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_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: 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;
public static Color CaretOriginal;
internal static Color transparent = new Color(0f, 0f, 0f, 0f);
internal static void InitSettings()
{
if (initKeySettings)
{
return;
}
initKeySettings = true;
keyActions.Clear();
Plugin.X("Loading keybinds from config");
CollectionOfKeys();
TogglePiPKey();
CreateMenuCommand();
if ((Object)(object)menuDisplay == (Object)null)
{
TerminalKeyword val = default(TerminalKeyword);
if (DynamicBools.TryGetKeyword("suits", ref val))
{
menuDisplay = val.specialKeywordResult;
}
else
{
Plugin.ERROR("Unable to get suits node for menuDisplay!!!");
}
}
specialMenusActive = false;
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)
{
menuDisplay = AddingThings.AddNodeManual("advanced_suitsTerm", "suits", (Func<string>)CommandHandler.AdvancedSuitsTerm, true, 0, ConfigSetup.defaultListing, 0, (Func<string>)null, (Func<string>)null, "", "", false, 1, "", false, "");
TerminalNode val = default(TerminalNode);
if (LogicHandling.TryGetFromAllNodes("OtherCommands", ref val))
{
AddingThings.AddToExistingNodeText("\n>SUITS\nsuitsTerminal advanced menu for changing & viewing suits", ref val);
}
}
}
private static void CollectionOfKeys()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: 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_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Invalid comparison between Unknown and I4
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: 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_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: 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_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: 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_0022: 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_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: 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;
}
public static bool AnyKeyIsPressed()
{
//IL_001f: 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)
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_0006: 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)
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 val = null;
if (PictureInPicture.pipActive)
{
val = GetCam();
}
if (value == "previous_page" && !inHelpMenu)
{
if (currentPage > 0)
{
currentPage--;
}
LoadPage(menuDisplay, StringStuff.AdvancedMenuDisplay(AllSuits.suitListing, activeSelection, 10, ref currentPage));
Plugin.X($"Current Page: {currentPage}\n Current Item: {activeSelection}");
}
else if (value == "next_page" && !inHelpMenu)
{
currentPage++;
LoadPage(menuDisplay, StringStuff.AdvancedMenuDisplay(AllSuits.suitListing, activeSelection, 10, ref currentPage));
Plugin.X($"Current Page: {currentPage}\n Current Item: {activeSelection}");
}
else if (value == "previous_item" && !inHelpMenu)
{
if (activeSelection > 0)
{
activeSelection--;
}
LoadPage(menuDisplay, StringStuff.AdvancedMenuDisplay(AllSuits.suitListing, activeSelection, 10, ref currentPage));
Plugin.X($"Current Page: {currentPage}\n Current Item: {activeSelection}");
}
else if (value == "next_item" && !inHelpMenu)
{
activeSelection++;
LoadPage(menuDisplay, StringStuff.AdvancedMenuDisplay(AllSuits.suitListing, activeSelection, 10, ref currentPage));
Plugin.X($"Current Page: {currentPage}\n Current Item: {activeSelection}");
}
else if (value == "leave_menu")
{
inHelpMenu = false;
MenuActive(active: false);
}
else if (value == "menu_select" && !inHelpMenu)
{
SuitAttributes menuItemSuit = StringStuff.GetMenuItemSuit(AllSuits.suitListing, activeSelection);
if (menuItemSuit != null)
{
CommandHandler.BetterSuitPick(menuItemSuit);
Plugin.X($"Current Page: {currentPage}\n Current Item: {activeSelection}");
GetCurrentSuitNum();
LoadPage(menuDisplay, StringStuff.AdvancedMenuDisplay(AllSuits.suitListing, activeSelection, 10, ref currentPage));
}
}
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)val == (Object)null))
{
PictureInPicture.MoveCamera(((Component)val).transform, ref PictureInPicture.heightStep);
Plugin.X($"Changing PiP height to {PictureInPicture.heightStep}");
}
}
else if (value == "pip_rotate" && !inHelpMenu)
{
if (!((Object)(object)val == (Object)null))
{
PictureInPicture.RotateCameraAroundPlayer(StartOfRound.Instance.localPlayerController.meshContainer, ((Component)val).transform);
Plugin.X("Rotating PiP around player");
}
}
else if (value == "pip_zoom" && !inHelpMenu)
{
if (!((Object)(object)val == (Object)null))
{
PictureInPicture.ChangeCamZoom(val, 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 (menuItemSuit2 == null)
{
return;
}
if (AllSuits.suitListing.FavList.Contains(menuItemSuit2.Name))
{
menuItemSuit2.RemoveFromFavs();
AllSuits.suitListing.RefreshFavorites();
Plugin.Log.LogInfo((object)(menuItemSuit2.Name + " removed from favorites listing"));
if (AllSuits.suitListing.FavList.Count < 1)
{
inFavsMenu = false;
currentPage = 1;
GetCurrentSuitNum();
LoadPage(menuDisplay, StringStuff.AdvancedMenuDisplay(AllSuits.suitListing, 0, 10, ref currentPage));
Misc.SaveToConfig(AllSuits.suitListing.FavList, out string configItem);
Misc.SaveFavorites(configItem);
return;
}
}
else
{
menuItemSuit2.AddToFavs();
Plugin.Log.LogInfo((object)(menuItemSuit2.Name + " added to favorites listing"));
}
Misc.SaveToConfig(AllSuits.suitListing.FavList, out string configItem2);
Misc.SaveFavorites(configItem2);
Plugin.X($"Current Page: {currentPage}\n Current Item: {activeSelection}");
LoadPage(menuDisplay, StringStuff.AdvancedMenuDisplay(AllSuits.suitListing, activeSelection, 10, ref currentPage));
}
else if (value == "favorites_menu")
{
if (inFavsMenu || AllSuits.suitListing.FavList.Count >= 1)
{
if (inHelpMenu)
{
inHelpMenu = false;
PictureInPicture.TogglePiP(state: true);
}
inFavsMenu = !inFavsMenu;
currentPage = 1;
GetCurrentSuitNum();
LoadPage(menuDisplay, StringStuff.AdvancedMenuDisplay(AllSuits.suitListing, 0, 10, ref currentPage));
}
}
else if (value == "help_menu")
{
inHelpMenu = !inHelpMenu;
GetCurrentSuitNum();
menuDisplay.displayText = Misc.HelpMenuDisplay(inHelpMenu);
PictureInPicture.TogglePiP(!inHelpMenu);
LoadPage(menuDisplay);
}
}
internal static void LoadPage(TerminalNode menu, string displayText = "")
{
if (displayText.Length > 0)
{
menu.displayText = displayText;
}
Plugin.Terminal.LoadNewNode(menu);
if (Plugin.TerminalStuff)
{
TerminalStuffMod.NetSync(menu);
}
}
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 void OnTerminalKeyPress()
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
if (specialMenusActive && SConfig.AdvancedTerminalMenu.Value && AnyKeyIsPressed())
{
HandleKeyPress(keyBeingPressed);
}
}
internal static void MenuActive(bool active, bool enableInput = true)
{
if (active)
{
((MonoBehaviour)Plugin.Terminal).StartCoroutine(SuitsMenuStart());
}
else
{
((MonoBehaviour)Plugin.Terminal).StartCoroutine(SuitsMenuExit(enableInput));
}
}
internal static IEnumerator SuitsMenuExit(bool enableInput)
{
yield return (object)new WaitForEndOfFrame();
specialMenusActive = false;
PictureInPicture.TogglePiP(state: false);
yield return (object)new WaitForEndOfFrame();
Plugin.Terminal.LoadNewNode(Plugin.Terminal.terminalNodes.specialNodes[13]);
if (Plugin.TerminalStuff)
{
TerminalStuffMod.NetSync(Plugin.Terminal.terminalNodes.specialNodes[13]);
}
yield return (object)new WaitForEndOfFrame();
Plugin.Terminal.screenText.caretColor = CaretOriginal;
if (enableInput)
{
Plugin.Terminal.screenText.ActivateInputField();
((Selectable)Plugin.Terminal.screenText).interactable = true;
}
}
internal static IEnumerator SuitsMenuStart()
{
if (!specialMenusActive)
{
yield return (object)new WaitForEndOfFrame();
Plugin.Terminal.screenText.caretColor = transparent;
specialMenusActive = true;
GetCurrentSuitNum();
yield return (object)new WaitForEndOfFrame();
Plugin.Terminal.screenText.DeactivateInputField(false);
((Selectable)Plugin.Terminal.screenText).interactable = false;
yield return (object)new WaitForEndOfFrame();
PictureInPicture.TogglePiP(state: true);
yield return (object)new WaitForEndOfFrame();
PiPSetParent();
}
}
}
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()
{
int currentPage = 1;
AdvancedMenu.inFavsMenu = false;
PictureInPicture.rotateStep = 0;
PictureInPicture.heightStep = 0;
PictureInPicture.zoomStep = 1;
AdvancedMenu.currentPage = 1;
AdvancedMenu.activeSelection = 0;
AdvancedMenu.inHelpMenu = false;
AdvancedMenu.GetCurrentSuitID();
string result = StringStuff.AdvancedMenuDisplay(AllSuits.suitListing, 0, 10, ref currentPage);
AdvancedMenu.MenuActive(active: true);
return result;
}
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 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());
AddingThings.AddNodeManual(suit.Name, "wear " + suit.Name, (Func<string>)CommandHandler.SuitPickCommand, true, 0, ConfigSetup.defaultListing, 0, (Func<string>)null, (Func<string>)null, "", "", false, 1, "", false, "");
Plugin.X("Keyword for " + suit.Name + " added");
}
else if (suit.Suit.syncedSuitID.Value >= 0 && Misc.keywordsCreated)
{
suit.Name = StringStuff.TerminalFriendlyString(suit.Name);
AddingThings.AddNodeManual(suit.Name, "wear " + suit.Name, (Func<string>)CommandHandler.SuitPickCommand, true, 0, ConfigSetup.defaultListing, 0, (Func<string>)null, (Func<string>)null, "", "", false, 1, "", false, "");
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)
{
AddingThings.AddNodeManual("suitsTerminal random", "randomsuit", (Func<string>)CommandHandler.RandomSuit, true, 0, ConfigSetup.defaultListing, 0, (Func<string>)null, (Func<string>)null, "", "", false, 1, "", false, "");
TerminalNode val = default(TerminalNode);
if (LogicHandling.TryGetFromAllNodes("OtherCommands", ref val))
{
AddingThings.AddToExistingNodeText("\n>RANDOMSUIT\nsuitsTerminal equip a random suit", ref val);
}
}
}
}
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_0138: 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_0012: 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_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: 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_0045: 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_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: 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)
//IL_0017: 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)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: 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_0040: 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_0046: 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_004c: 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)
//IL_0053: 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_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: 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)
//IL_005b: 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_01c3: 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 (state:{state})");
OpenBodyCamFuncs.OpenBodyCamsMirrorStatus(state, SConfig.ObcResolution.Value, 0.1f, false, ref CamStuff.ObcCameraHolder);
if (!state)
{
return;
}
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);
if (state)
{
playerCam.fieldOfView = 100f;
pipRawImage.texture = (Texture)(object)playerCam.targetTexture;
}
if (!Plugin.instance.ModelReplacement)
{
if (state)
{
((Renderer)StartOfRound.Instance.localPlayerController.thisPlayerModel).shadowCastingMode = (ShadowCastingMode)0;
Plugin.Log.LogInfo((object)"Showing PlayerModel to player (player should be in terminal)");
}
else
{
((Renderer)StartOfRound.Instance.localPlayerController.thisPlayerModel).shadowCastingMode = shadowDefault;
Plugin.Log.LogInfo((object)"Hiding PlayerModel from player (PiP disabled or leaving suits menu)");
}
}
}
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 = 0;
internal List<string> NameList = new List<string>();
internal List<string> FavList = new List<string>();
internal void ClearAll()
{
NameList.Clear();
FavList.Clear();
CurrentMenu = 0;
SuitsList.ForEach(delegate(SuitAttributes x)
{
x.Reset();
});
}
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 void RefreshFavorites(bool checkList = false)
{
if (AllSuits.suitListing.SuitsList.Count == 0)
{
return;
}
if (checkList)
{
AllSuits.suitListing.FavList = new List<string>();
{
foreach (SuitAttributes suits in SuitsList)
{
suits.FavIndex = -1;
suits.IsFav = suits.IsFavorite();
suits.SetIndex();
Plugin.X("SuitAttributes updated for " + suits.Name);
}
return;
}
}
foreach (SuitAttributes suits2 in SuitsList)
{
suits2.RefreshFavIndex();
}
}
}
internal class SuitAttributes
{
internal UnlockableSuit Suit;
internal bool HideFromTerminal = false;
internal bool IsOnRack = false;
internal string Name = "placeholder";
internal int UniqueID = -1;
internal bool IsFav = false;
internal int MainMenuIndex = -1;
internal int FavIndex = -1;
internal bool currentSuit = false;
internal void Reset()
{
HideFromTerminal = false;
IsOnRack = false;
currentSuit = false;
FavIndex = -1;
IsFav = false;
MainMenuIndex = -1;
}
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 && !AllSuits.suitListing.FavList.Contains(Name))
{
AddToFavs();
}
}
internal int GetIndex(List<string> listing)
{
if (listing.Contains(Name))
{
return listing.IndexOf(Name);
}
return -1;
}
internal bool IsFavorite()
{
if (AllSuits.favsList.Count == 0)
{
return false;
}
if (AllSuits.favsList.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;
if (AllSuits.suitListing.FavList.Contains(Name))
{
FavIndex = AllSuits.suitListing.FavList.IndexOf(Name);
return;
}
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 += $"({item.suitID})";
}
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>__OnTerminalQuit;
public static Event <2>__OnTerminalDisable;
public static Event <3>__OnTerminalDelayStart;
public static ParameterEvent<TerminalNode> <4>__OnLoadAffordable;
public static Event <5>__OnGameStart;
public static Event <6>__OnPlayerSpawn;
public static Event <7>__OnShipReset;
public static Event <8>__OnTerminalKeyPress;
}
internal static void Subscribe()
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Expected O, but got Unknown
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Expected O, but got Unknown
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Expected O, but got Unknown
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Expected O, but got Unknown
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Expected O, but got Unknown
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Expected O, but got Unknown
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Expected O, but got Unknown
EventManager.TerminalAwake.AddListener((ParameterEvent<Terminal>)OnTerminalAwake);
CustomEvent terminalQuit = EventManager.TerminalQuit;
object obj = <>O.<1>__OnTerminalQuit;
if (obj == null)
{
Event val = OnTerminalQuit;
<>O.<1>__OnTerminalQuit = val;
obj = (object)val;
}
terminalQuit.AddListener((Event)obj);
CustomEvent terminalDisable = EventManager.TerminalDisable;
object obj2 = <>O.<2>__OnTerminalDisable;
if (obj2 == null)
{
Event val2 = OnTerminalDisable;
<>O.<2>__OnTerminalDisable = val2;
obj2 = (object)val2;
}
terminalDisable.AddListener((Event)obj2);
CustomEvent terminalDelayStart = EventManager.TerminalDelayStart;
object obj3 = <>O.<3>__OnTerminalDelayStart;
if (obj3 == null)
{
Event val3 = OnTerminalDelayStart;
<>O.<3>__OnTerminalDelayStart = val3;
obj3 = (object)val3;
}
terminalDelayStart.AddListener((Event)obj3);
EventManager.TerminalLoadIfAffordable.AddListener((ParameterEvent<TerminalNode>)TerminalGeneral.OnLoadAffordable);
CustomEvent gameNetworkManagerStart = EventManager.GameNetworkManagerStart;
object obj4 = <>O.<5>__OnGameStart;
if (obj4 == null)
{
Event val4 = OnGameStart;
<>O.<5>__OnGameStart = val4;
obj4 = (object)val4;
}
gameNetworkManagerStart.AddListener((Event)obj4);
CustomEvent playerSpawn = EventManager.PlayerSpawn;
object obj5 = <>O.<6>__OnPlayerSpawn;
if (obj5 == null)
{
Event val5 = OnPlayerSpawn;
<>O.<6>__OnPlayerSpawn = val5;
obj5 = (object)val5;
}
playerSpawn.AddListener((Event)obj5);
CustomEvent shipReset = EventManager.ShipReset;
object obj6 = <>O.<7>__OnShipReset;
if (obj6 == null)
{
Event val6 = OnShipReset;
<>O.<7>__OnShipReset = val6;
obj6 = (object)val6;
}
shipReset.AddListener((Event)obj6);
TerminalUpdatePatch.usePatch = true;
CustomEvent terminalKeyPressed = EventManager.TerminalKeyPressed;
object obj7 = <>O.<8>__OnTerminalKeyPress;
if (obj7 == null)
{
Event val7 = AdvancedMenu.OnTerminalKeyPress;
<>O.<8>__OnTerminalKeyPress = val7;
obj7 = (object)val7;
}
terminalKeyPressed.AddListener((Event)obj7);
}
internal static void OnTerminalDelayStart()
{
DefaultSuit();
}
internal static void OnTerminalQuit()
{
if (SConfig.AdvancedTerminalMenu.Value && AdvancedMenu.specialMenusActive)
{
AdvancedMenu.MenuActive(active: false, enableInput: false);
}
}
internal static void OnTerminalAwake(Terminal instance)
{
Plugin.Terminal = instance;
Plugin.X("Setting suitsTerminal.Terminal");
}
internal static void OnShipReset()
{
((MonoBehaviour)StartOfRound.Instance).StartCoroutine(Enums.DelayFixRack());
}
internal static void OnTerminalDisable()
{
Misc.suitsOnRack = 0;
Misc.hasLaunched = false;
Misc.hintOnce = false;
Misc.rackSituated = false;
PictureInPicture.PiPCreated = false;
AdvancedMenu.specialMenusActive = false;
Plugin.X("set initial variables");
ResetSuitPlacementVars(unlocksReset: true);
}
internal static void ResetSuitPlacementVars(bool unlocksReset)
{
if (AllSuits.suitListing.SuitsList.Count == 0)
{
return;
}
if (unlocksReset)
{
AllSuits.suitListing.ClearAll();
Plugin.X("suitlisting cleared!");
return;
}
AllSuits.suitListing.SuitsList.ForEach(delegate(SuitAttributes s)
{
s.IsOnRack = false;
});
Misc.rackSituated = false;
}
internal static void OnGameStart()
{
CompatibilityCheck();
AllSuits.InitFavoritesListing();
}
private static void CompatibilityCheck()
{
Plugin.X("Compatibility Check!");
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");
}
if (StartGame.SoftCompatibility("TooManySuits", ref Plugin.TooManySuits))
{
Plugin.X("TooManySuits Compatibility enabled!\nRack will be left untouched!");
}
}
internal 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()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
AdvancedMenu.CaretOriginal = Plugin.Terminal.screenText.caretColor;
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_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: 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 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 suitsTerminal.Compatibility
{
internal class TerminalStuffMod
{
internal static void NetSync(TerminalNode node)
{
if (!((Object)(object)node == (Object)null) && Plugin.TerminalStuff && ConfigSettings.NetworkedNodes.Value && ConfigSettings.ModNetworking.Value)
{
Plugin.X("Syncing node with TerminalStuff");
TerminalParse.NetSync(node);
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}