using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using LethalLevelLoader;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("ShowMoonPriceLLL")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Add the moon prices to the console when using LethalLevelLoader")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+3ad8a6e4ce14558dfe0f2c0e7da3273492304832")]
[assembly: AssemblyProduct("ShowMoonPriceLLL")]
[assembly: AssemblyTitle("ShowMoonPriceLLL")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace ShowMoonPriceLLL
{
[BepInPlugin("ShowMoonPriceLLL", "ShowMoonPriceLLL", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public static ShowMoonPriceLLLConfig MoonPriceConfig { get; internal set; }
private void Awake()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
MoonPriceConfig = new ShowMoonPriceLLLConfig(((BaseUnityPlugin)this).Config);
Harmony val = new Harmony("ShowMoonPriceLLL");
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin ShowMoonPriceLLL is loaded!");
val.PatchAll(typeof(Terminal_Patch_Override));
}
}
public class ShowMoonPriceLLLConfig
{
public static ConfigEntry<bool> showRisk;
public static ConfigEntry<bool> showPrice;
public ShowMoonPriceLLLConfig(ConfigFile cfg)
{
showRisk = cfg.Bind<bool>("General.Toggles", "ShowRisk", true, "To show the risk factor of the planet in moons menu");
showPrice = cfg.Bind<bool>("General.Toggles", "ShowPrice", true, "To show the price of the planet in moons menu");
}
}
public class Terminal_Patch_Override
{
private static Terminal _terminal;
internal static Terminal Terminal
{
get
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Expected O, but got Unknown
if ((Object)_terminal != (Object)null)
{
return _terminal;
}
_terminal = GameObject.Find("TerminalScript").GetComponent<Terminal>();
if ((Object)_terminal != (Object)null)
{
return _terminal;
}
Debug.LogError((object)"LethaLib: Failed To Grab Terminal Reference!");
return null;
}
}
[HarmonyPatch(typeof(Terminal), "TextPostProcess")]
[HarmonyPrefix]
[HarmonyPriority(0)]
internal static void TextPostProcess_Prefix(ref string modifiedDisplayText)
{
bool value = ShowMoonPriceLLLConfig.showRisk.Value;
bool value2 = ShowMoonPriceLLLConfig.showPrice.Value;
if (!modifiedDisplayText.Contains("Welcome to the exomoons catalogue"))
{
return;
}
string text = "";
string[] array = modifiedDisplayText.Split("\n");
foreach (string text2 in array)
{
if (text2.StartsWith("* "))
{
ExtendedLevel levelFromLine = getLevelFromLine(text2);
text = text + getFormattedLine(text2, levelFromLine, value, value2) + "\n";
}
else
{
text = text + text2 + "\n";
}
}
modifiedDisplayText = text.Substring(0, text.Length);
}
private static ExtendedLevel getLevelFromLine(string line)
{
ExtendedLevel val = null;
foreach (SelectableLevel item in Terminal.moonsCatalogueList.ToList())
{
val = LevelManager.GetExtendedLevel(item);
if (val != null && val.NumberlessPlanetName != null && string.Equals(val.NumberlessPlanetName.Trim(), getNameFromLine(line)))
{
return val;
}
}
return null;
}
private static string getNameFromLine(string line)
{
return line.Substring(2).Split('(')[0].Trim().Split('[')[0].Trim();
}
private static string getFormattedLine(string pLine, ExtendedLevel level, bool pShowRisk, bool pShowPrice)
{
if (level != null && level.SelectableLevel != null)
{
string text = pLine;
if (pShowRisk && pLine.Length < 33 && level.SelectableLevel.riskLevel != null)
{
text += level.SelectableLevel.riskLevel.PadLeft(33 - text.Length + level.SelectableLevel.riskLevel.Length);
}
if (pShowPrice && pLine.Length < 44 && level.SelectableLevel.riskLevel != null)
{
text += ("$" + level.RoutePrice).PadLeft(44 - text.Length);
}
return text;
}
return pLine;
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "ShowMoonPriceLLL";
public const string PLUGIN_NAME = "ShowMoonPriceLLL";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}