using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using HarmonyLib;
using InteractiveMoonCatalogue.Compat;
using InteractiveMoonCatalogue.NetcodePatcher;
using InteractiveMoonCatalogue.UI.Application;
using InteractiveMoonCatalogue.UI.Cursor;
using InteractiveMoonCatalogue.Util;
using InteractiveTerminalAPI.Compat;
using InteractiveTerminalAPI.UI;
using InteractiveTerminalAPI.UI.Application;
using InteractiveTerminalAPI.UI.Cursor;
using InteractiveTerminalAPI.UI.Page;
using InteractiveTerminalAPI.UI.Screen;
using LethalLevelLoader;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.InputSystem;
[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)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
static <Module>()
{
}
}
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace WeatherProbe.Misc
{
internal static class Metadata
{
public const string GUID = "com.github.WhiteSpike.InteractiveMoonCatalogue";
public const string NAME = "Interactive Moon Catalogue";
public const string VERSION = "1.0.0";
}
}
namespace InteractiveMoonCatalogue
{
[BepInPlugin("com.github.WhiteSpike.InteractiveMoonCatalogue", "Interactive Moon Catalogue", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
internal static readonly Harmony harmony = new Harmony("com.github.WhiteSpike.InteractiveMoonCatalogue");
internal static ManualLogSource mls;
private void Awake()
{
InteractiveTerminalManager.RegisterApplication<MoonCatalogueApplication>("imoons", false);
mls = ((BaseUnityPlugin)this).Logger;
mls.LogInfo((object)"Interactive Moon Catalogue 1.0.0 has been loaded successfully.");
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "InteractiveMoonCatalogue";
public const string PLUGIN_NAME = "ExtendDeadline";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace InteractiveMoonCatalogue.Util
{
internal static class Tools
{
private static Terminal terminal;
internal static Terminal GetTerminal()
{
if ((Object)(object)terminal == (Object)null)
{
terminal = GameObject.Find("TerminalScript").GetComponent<Terminal>();
}
return terminal;
}
}
}
namespace InteractiveMoonCatalogue.UI.Cursor
{
internal class LevelCursorElement : CursorElement
{
public SelectableLevel Level { get; set; }
public TerminalNode RouteNode { get; set; }
public override string GetText(int availableLength)
{
StringBuilder sb = new StringBuilder();
bool flag = false;
string text;
if (LethalLevelLoaderCompat.Enabled && LethalLevelLoaderCompat.IsLocked(Level))
{
text = "[???]";
}
else
{
text = Level.PlanetName.Substring(Level.PlanetName.IndexOf(' ') + 1) ?? "";
if (text.Contains("Gordion"))
{
text += " / The Company";
}
}
Terminal terminal = Tools.GetTerminal();
int groupCredits = terminal.groupCredits;
if (!((CursorElement)this).Active((CursorElement)(object)this))
{
if ((Object)(object)Level == (Object)(object)StartOfRound.Instance.currentLevel)
{
sb.Append("<color=#026440>");
}
else
{
sb.Append("<color=#66666666>");
}
}
sb.Append(text);
if (LethalLevelLoaderCompat.Enabled && LethalLevelLoaderCompat.IsLocked(Level))
{
sb.Append("</color>");
return sb.ToString();
}
sb.Append(new string(' ', Mathf.Max(0, 14 - text.Length)));
string previousText = "";
if (!string.IsNullOrEmpty(Level.riskLevel) && !Level.riskLevel.Contains("Safe"))
{
previousText = ((!Level.riskLevel.Contains("CORRUPTION")) ? (" (" + Level.riskLevel + ")") : " (Corrupted)");
}
if (!string.IsNullOrEmpty(previousText))
{
sb.Append(previousText);
}
AppendPriceText(ref sb, groupCredits, ref previousText);
AppendWeatherText(ref sb, ref previousText);
if (!((CursorElement)this).Active((CursorElement)(object)this))
{
sb.Append("</color>");
}
return sb.ToString();
}
private void AppendPriceText(ref StringBuilder sb, int credits, ref string previousText)
{
int itemCost = RouteNode.itemCost;
if (itemCost <= 0)
{
sb.Append(new string(' ', Mathf.Max(0, 9)));
return;
}
sb.Append(new string(' ', Mathf.Max(0, 9 - previousText.Length)));
if (itemCost > credits)
{
sb.Append("<color=#880000>");
sb.Append(itemCost);
sb.Append("$");
sb.Append("</color>");
}
else
{
sb.Append(itemCost);
sb.Append("$");
}
previousText = itemCost + "$";
}
private void AppendWeatherText(ref StringBuilder sb, ref string previousText)
{
//IL_0021: 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)
//IL_0026: 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_0029: Invalid comparison between Unknown and I4
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
LevelWeatherType val = (Level.overrideWeather ? Level.overrideWeatherType : Level.currentWeather);
if ((int)val != -1)
{
sb.Append(new string(' ', Mathf.Max(0, 9 - previousText.Length)));
sb.Append($"({val})");
}
}
}
}
namespace InteractiveMoonCatalogue.UI.Application
{
internal class MoonCatalogueApplication : PageApplication
{
private TerminalKeyword routeKeyword;
protected override int GetEntriesPerPage<T>(T[] entries)
{
return 12;
}
public override void Initialization()
{
List<SelectableLevel> list = StartOfRound.Instance.levels.ToList();
SelectableLevel[] levels = StartOfRound.Instance.levels;
levels = levels.Where((SelectableLevel x) => !x.PlanetName.Contains("Liquidation")).ToArray();
if (LethalLevelLoaderCompat.Enabled)
{
LethalLevelLoaderCompat.GrabAllAvailableLevels(ref levels);
}
(SelectableLevel[][], CursorMenu[], IScreen[]) pageEntries = ((PageApplication)this).GetPageEntries<SelectableLevel>(levels);
SelectableLevel[][] item = pageEntries.Item1;
CursorMenu[] item2 = pageEntries.Item2;
IScreen[] item3 = pageEntries.Item3;
for (int i = 0; i < item.Length; i++)
{
SelectableLevel[] array = item[i];
CursorElement[] array2 = (CursorElement[])(object)new CursorElement[array.Length];
item2[i] = CursorMenu.Create(0, '>', array2, new Func<CursorElement, CursorElement, int>[7] { CompareName, CompareDescendingPrice, CompareAscendingPrice, CompareDescendingDifficulty, CompareAscendingDifficulty, CompareDescendingWeather, CompareAscendingWeather });
((BaseCursorMenu<CursorElement>)(object)item2[i]).sortingIndex = -1;
CursorMenu val = item2[i];
ITextElement[] elements = (ITextElement[])(object)new ITextElement[3]
{
(ITextElement)TextElement.Create("Select the moon you wish to route to:"),
(ITextElement)TextElement.Create(" "),
(ITextElement)val
};
item3[i] = (IScreen)(object)new BoxedOutputScreen<string, string>
{
Title = "Moon Catalogue",
elements = elements,
Input = GetCurrentSort,
Output = (string x) => x
};
for (int j = 0; j < array.Length; j++)
{
SelectableLevel level = array[j];
if (!((Object)(object)level == (Object)null))
{
TerminalNode routeNode = GetRouteNode(list.IndexOf(level));
int num = j;
LevelCursorElement obj = new LevelCursorElement
{
Level = level,
RouteNode = routeNode
};
((CursorElement)obj).Active = (CursorElement x) => CanPurchaseRoute((LevelCursorElement)(object)x);
((CursorElement)obj).SelectInactive = true;
((CursorElement)obj).Action = delegate
{
PurchaseRoute(level, routeNode);
};
array2[num] = (CursorElement)(object)obj;
}
}
}
base.currentPage = base.initialPage;
((BaseInteractiveApplication<CursorMenu, CursorElement>)this).currentCursorMenu = base.initialPage.GetCurrentCursorMenu();
((TerminalApplication)this).currentScreen = ((PageElement)base.initialPage).GetCurrentScreen();
}
private int CompareName(CursorElement cursor1, CursorElement cursor2)
{
if (cursor1 == null)
{
return 1;
}
if (cursor2 == null)
{
return -1;
}
LevelCursorElement levelCursorElement = cursor1 as LevelCursorElement;
LevelCursorElement levelCursorElement2 = cursor2 as LevelCursorElement;
string text = levelCursorElement.Level.PlanetName.Substring(levelCursorElement.Level.PlanetName.IndexOf(' ') + 1);
string strB = levelCursorElement2.Level.PlanetName.Substring(levelCursorElement2.Level.PlanetName.IndexOf(' ') + 1);
return text.CompareTo(strB);
}
private int CompareDescendingPrice(CursorElement cursor1, CursorElement cursor2)
{
if (cursor1 == null)
{
return 1;
}
if (cursor2 == null)
{
return -1;
}
LevelCursorElement levelCursorElement = cursor1 as LevelCursorElement;
LevelCursorElement levelCursorElement2 = cursor2 as LevelCursorElement;
int itemCost = levelCursorElement.RouteNode.itemCost;
int itemCost2 = levelCursorElement2.RouteNode.itemCost;
return itemCost.CompareTo(itemCost2);
}
private int CompareAscendingPrice(CursorElement cursor1, CursorElement cursor2)
{
if (cursor1 == null)
{
return 1;
}
if (cursor2 == null)
{
return -1;
}
LevelCursorElement levelCursorElement = cursor1 as LevelCursorElement;
LevelCursorElement levelCursorElement2 = cursor2 as LevelCursorElement;
int itemCost = levelCursorElement.RouteNode.itemCost;
int itemCost2 = levelCursorElement2.RouteNode.itemCost;
return itemCost2.CompareTo(itemCost);
}
private int CompareDescendingDifficulty(CursorElement cursor1, CursorElement cursor2)
{
if (cursor1 == null)
{
return 1;
}
if (cursor2 == null)
{
return -1;
}
LevelCursorElement levelCursorElement = cursor1 as LevelCursorElement;
LevelCursorElement levelCursorElement2 = cursor2 as LevelCursorElement;
if (LethalLevelLoaderCompat.Enabled)
{
return LethalLevelLoaderCompat.CompareDescendingDifficulty(levelCursorElement.Level, levelCursorElement2.Level);
}
string riskLevel = levelCursorElement.Level.riskLevel;
string riskLevel2 = levelCursorElement2.Level.riskLevel;
return riskLevel2.CompareTo(riskLevel);
}
private int CompareAscendingDifficulty(CursorElement cursor1, CursorElement cursor2)
{
if (cursor1 == null)
{
return 1;
}
if (cursor2 == null)
{
return -1;
}
LevelCursorElement levelCursorElement = cursor1 as LevelCursorElement;
LevelCursorElement levelCursorElement2 = cursor2 as LevelCursorElement;
if (LethalLevelLoaderCompat.Enabled)
{
return LethalLevelLoaderCompat.CompareAscendingDifficulty(levelCursorElement.Level, levelCursorElement2.Level);
}
string riskLevel = levelCursorElement.Level.riskLevel;
string riskLevel2 = levelCursorElement2.Level.riskLevel;
return riskLevel.CompareTo(riskLevel2);
}
private int CompareDescendingWeather(CursorElement cursor1, CursorElement cursor2)
{
//IL_0050: 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_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: 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_007e: Unknown result type (might be due to invalid IL or missing references)
if (cursor1 == null)
{
return 1;
}
if (cursor2 == null)
{
return -1;
}
LevelCursorElement levelCursorElement = cursor1 as LevelCursorElement;
LevelCursorElement levelCursorElement2 = cursor2 as LevelCursorElement;
LevelWeatherType val = (levelCursorElement.Level.overrideWeather ? levelCursorElement.Level.overrideWeatherType : levelCursorElement.Level.currentWeather);
LevelWeatherType val2 = (levelCursorElement2.Level.overrideWeather ? levelCursorElement2.Level.overrideWeatherType : levelCursorElement2.Level.currentWeather);
return ((Enum)(LevelWeatherType)(ref val)).CompareTo((object?)val2);
}
private int CompareAscendingWeather(CursorElement cursor1, CursorElement cursor2)
{
//IL_0050: 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_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: 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_007e: Unknown result type (might be due to invalid IL or missing references)
if (cursor1 == null)
{
return 1;
}
if (cursor2 == null)
{
return -1;
}
LevelCursorElement levelCursorElement = cursor1 as LevelCursorElement;
LevelCursorElement levelCursorElement2 = cursor2 as LevelCursorElement;
LevelWeatherType val = (levelCursorElement.Level.overrideWeather ? levelCursorElement.Level.overrideWeatherType : levelCursorElement.Level.currentWeather);
LevelWeatherType val2 = (levelCursorElement2.Level.overrideWeather ? levelCursorElement2.Level.overrideWeatherType : levelCursorElement2.Level.currentWeather);
return ((Enum)(LevelWeatherType)(ref val2)).CompareTo((object?)val);
}
private string GetCurrentSort()
{
int sortingIndex = ((BaseCursorMenu<CursorElement>)(object)((BaseInteractiveApplication<CursorMenu, CursorElement>)this).currentCursorMenu).sortingIndex;
if (1 == 0)
{
}
string result = sortingIndex switch
{
0 => "Sort: Alphabetical [" + InputActionRebindingExtensions.GetBindingDisplayString(InputUtils_Compat.ChangeApplicationSortingKey, (DisplayStringOptions)0, (string)null) + "]",
1 => "Sort: Price (Descending) [" + InputActionRebindingExtensions.GetBindingDisplayString(InputUtils_Compat.ChangeApplicationSortingKey, (DisplayStringOptions)0, (string)null) + "]",
2 => "Sort: Price (Ascending) [" + InputActionRebindingExtensions.GetBindingDisplayString(InputUtils_Compat.ChangeApplicationSortingKey, (DisplayStringOptions)0, (string)null) + "]",
3 => "Sort: Difficulty (Descending) [" + InputActionRebindingExtensions.GetBindingDisplayString(InputUtils_Compat.ChangeApplicationSortingKey, (DisplayStringOptions)0, (string)null) + "]",
4 => "Sort: Difficulty (Ascending) [" + InputActionRebindingExtensions.GetBindingDisplayString(InputUtils_Compat.ChangeApplicationSortingKey, (DisplayStringOptions)0, (string)null) + "]",
5 => "Sort: Weather (Descending) [" + InputActionRebindingExtensions.GetBindingDisplayString(InputUtils_Compat.ChangeApplicationSortingKey, (DisplayStringOptions)0, (string)null) + "]",
6 => "Sort: Weather (Ascending) [" + InputActionRebindingExtensions.GetBindingDisplayString(InputUtils_Compat.ChangeApplicationSortingKey, (DisplayStringOptions)0, (string)null) + "]",
_ => "Sort: None [" + InputActionRebindingExtensions.GetBindingDisplayString(InputUtils_Compat.ChangeApplicationSortingKey, (DisplayStringOptions)0, (string)null) + "]",
};
if (1 == 0)
{
}
return result;
}
private TerminalNode GetRouteNode(int levelIndex)
{
if ((Object)(object)routeKeyword == (Object)null)
{
routeKeyword = ((TerminalApplication)this).terminal.terminalNodes.allKeywords.First((TerminalKeyword k) => k.word == "route");
}
for (int i = 0; i < routeKeyword.compatibleNouns.Length; i++)
{
TerminalNode result = routeKeyword.compatibleNouns[i].result;
CompatibleNoun[] terminalOptions = result.terminalOptions;
for (int j = 0; j < terminalOptions.Length; j++)
{
TerminalNode result2 = terminalOptions[j].result;
if (!((Object)(object)result2 == (Object)null) && result2.buyRerouteToMoon == levelIndex)
{
return result2;
}
}
}
return null;
}
private void PurchaseRoute(SelectableLevel level, TerminalNode routeNode)
{
string planetName = level.PlanetName;
Action action = delegate
{
((PageApplication)this).ResetScreen();
};
if (!StartOfRound.Instance.inShipPhase)
{
((InteractiveTerminalApplication)this).ErrorMessage(planetName, action, "You cannot travel to another moon while landed on one!");
return;
}
if (StartOfRound.Instance.travellingToNewLevel)
{
((InteractiveTerminalApplication)this).ErrorMessage(planetName, action, "You cannot travel to another moon while travelling to one!");
return;
}
if (StartOfRound.Instance.isChallengeFile)
{
((InteractiveTerminalApplication)this).ErrorMessage(planetName, action, "You cannot travel to another moon while doing a challenge moon!");
return;
}
if ((Object)(object)StartOfRound.Instance.levels[routeNode.buyRerouteToMoon] == (Object)(object)StartOfRound.Instance.currentLevel)
{
((InteractiveTerminalApplication)this).ErrorMessage(planetName, action, "You have already arrived to this moon!");
return;
}
if (LethalLevelLoaderCompat.Enabled && LethalLevelLoaderCompat.IsLocked(level))
{
((InteractiveTerminalApplication)this).ErrorMessage(planetName, action, "You are unable to route to this moon!");
return;
}
int groupCredits = ((TerminalApplication)this).terminal.groupCredits;
if (groupCredits < routeNode.itemCost)
{
((InteractiveTerminalApplication)this).ErrorMessage(planetName, action, "Not enough credits to purchase this route!");
return;
}
((InteractiveTerminalApplication)this).Confirm(planetName, $"Do you confirm routing to {level.PlanetName}? You will spend {routeNode.itemCost} Company Credits for the routing.", (Action)delegate
{
ConfirmRoute(routeNode);
}, action, "");
}
private void ConfirmRoute(TerminalNode routeNode)
{
StartOfRound.Instance.ChangeLevelServerRpc(routeNode.buyRerouteToMoon, ((TerminalApplication)this).terminal.groupCredits - routeNode.itemCost);
((PageApplication)this).ResetScreen();
}
private bool CanPurchaseRoute(LevelCursorElement element)
{
if (!StartOfRound.Instance.inShipPhase || StartOfRound.Instance.travellingToNewLevel || StartOfRound.Instance.isChallengeFile || (Object)(object)StartOfRound.Instance.levels[element.RouteNode.buyRerouteToMoon] == (Object)(object)StartOfRound.Instance.currentLevel)
{
return false;
}
if (LethalLevelLoaderCompat.Enabled && LethalLevelLoaderCompat.IsLocked(element.Level))
{
return false;
}
int groupCredits = ((TerminalApplication)this).terminal.groupCredits;
return element.RouteNode.itemCost <= groupCredits;
}
}
}
namespace InteractiveMoonCatalogue.Compat
{
internal static class LethalLevelLoaderCompat
{
public static bool Enabled => Chainloader.PluginInfos.ContainsKey("imabatby.lethallevelloader");
internal static void GrabAllAvailableLevels(ref SelectableLevel[] levels)
{
ExtendedLevel val = default(ExtendedLevel);
levels = levels.Where((SelectableLevel x) => PatchedContent.TryGetExtendedContent(x, ref val) && !val.IsRouteHidden).ToArray();
}
internal static int CompareAscendingDifficulty(SelectableLevel level1, SelectableLevel level2)
{
ExtendedLevel val = default(ExtendedLevel);
PatchedContent.TryGetExtendedContent(level1, ref val);
ExtendedLevel val2 = default(ExtendedLevel);
PatchedContent.TryGetExtendedContent(level2, ref val2);
return val2.CalculatedDifficultyRating.CompareTo(val.CalculatedDifficultyRating);
}
internal static int CompareDescendingDifficulty(SelectableLevel level1, SelectableLevel level2)
{
ExtendedLevel val = default(ExtendedLevel);
PatchedContent.TryGetExtendedContent(level1, ref val);
ExtendedLevel val2 = default(ExtendedLevel);
PatchedContent.TryGetExtendedContent(level2, ref val2);
return val.CalculatedDifficultyRating.CompareTo(val2.CalculatedDifficultyRating);
}
internal static bool IsLocked(SelectableLevel level)
{
ExtendedLevel val = default(ExtendedLevel);
PatchedContent.TryGetExtendedContent(level, ref val);
return (Object)(object)val == (Object)null || val.IsRouteLocked;
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}
namespace InteractiveMoonCatalogue.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}