using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using LethalConfig;
using LethalConstellations.Compat;
using LethalConstellations.ConfigManager;
using LethalConstellations.EventStuff;
using LethalConstellations.PluginCore;
using LethalLevelLoader;
using LethalNetworkAPI;
using LethalNetworkAPI.Utils;
using Microsoft.CodeAnalysis;
using OpenLib;
using OpenLib.Common;
using OpenLib.Compat;
using OpenLib.ConfigManager;
using OpenLib.CoreMethods;
using OpenLib.Events;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("LethalConstellations")]
[assembly: AssemblyDescription("https://github.com/darmuh/LethalConstellations")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LethalConstellations")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e2700abc-7bc7-4bd0-b787-effe68445b6a")]
[assembly: AssemblyFileVersion("0.3.0")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.3.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;
}
}
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}
namespace LethalConstellations
{
[BepInPlugin("com.github.darmuh.LethalConstellations", "LethalConstellations", "0.3.0")]
[BepInDependency("imabatby.lethallevelloader", "1.3.8")]
[BepInDependency("darmuh.OpenLib", "0.2.12")]
public class Plugin : BaseUnityPlugin
{
public static class PluginInfo
{
public const string PLUGIN_GUID = "com.github.darmuh.LethalConstellations";
public const string PLUGIN_NAME = "LethalConstellations";
public const string PLUGIN_VERSION = "0.3.0";
}
public static Plugin instance;
internal static ManualLogSource Log;
public bool LethalMoonUnlocks;
public bool LethalNetworkAPI;
public Terminal Terminal;
public TerminalNode dummyNode;
public void Awake()
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Expected O, but got Unknown
instance = this;
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)"LethalConstellations is loading with version 0.3.0!");
Subscribers.Subscribe();
Configuration.GeneratedConfig = new ConfigFile(Path.Combine(Paths.ConfigPath, "LethalConstellations_Generated.cfg"), true);
Configuration.BindConfigSettings();
Log.LogInfo((object)"LethalConstellations load complete!");
}
internal static void MoreLogs(string message)
{
if (Configuration.ExtensiveLogging.Value)
{
Log.LogInfo((object)message);
}
}
internal static void Spam(string message)
{
if (Configuration.DeveloperLogging.Value)
{
Log.LogDebug((object)message);
}
}
internal static void ERROR(string message)
{
Log.LogError((object)message);
}
internal static void WARNING(string message)
{
Log.LogWarning((object)message);
}
}
}
namespace LethalConstellations.Properties
{
[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[DebuggerNonUserCode]
[CompilerGenerated]
internal class Resources
{
private static ResourceManager resourceMan;
private static CultureInfo resourceCulture;
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static ResourceManager ResourceManager
{
get
{
if (resourceMan == null)
{
ResourceManager resourceManager = new ResourceManager("LethalConstellations.Properties.Resources", typeof(Resources).Assembly);
resourceMan = resourceManager;
}
return resourceMan;
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
internal Resources()
{
}
}
}
namespace LethalConstellations.ConfigManager
{
public static class Configuration
{
public static ConfigFile GeneratedConfig;
internal static ConfigEntry<string> MainConfigCode;
internal static ConfigEntry<string> GeneratedConfigCode;
public static ConfigEntry<bool> ExtensiveLogging { get; internal set; }
public static ConfigEntry<bool> DeveloperLogging { get; internal set; }
public static ConfigEntry<string> ConstellationList { get; internal set; }
public static ConfigEntry<string> ManualSetupListing { get; internal set; }
public static ConfigEntry<bool> HideUnaffordableConstellations { get; internal set; }
public static ConfigEntry<bool> ModifyMoonPrices { get; internal set; }
public static ConfigEntry<string> IgnoreList { get; internal set; }
public static ConfigEntry<bool> RequireConfirmation { get; internal set; }
public static ConfigEntry<string> AddHintTo { get; internal set; }
public static ConfigEntry<string> CompanyDefaultConstellation { get; internal set; }
public static ConfigEntry<string> StartingConstellation { get; internal set; }
public static ConfigEntry<string> AcceptableStartingConstellations { get; internal set; }
public static ConfigEntry<bool> ReturnToLastConstellationFromCompany { get; internal set; }
public static ConfigEntry<bool> AddConstellationPositionData { get; internal set; }
public static ConfigEntry<int> CostPerDistanceUnit { get; internal set; }
public static ConfigEntry<string> ConstellationsWord { get; internal set; }
public static ConfigEntry<string> ConstellationWord { get; internal set; }
public static ConfigEntry<string> ConstellationsShortcuts { get; internal set; }
public static ConfigEntry<string> ConstellationsHintText { get; internal set; }
public static ConfigEntry<string> ConstellationsInfoText { get; internal set; }
public static ConfigEntry<int> ConstellationsPerPage { get; internal set; }
public static ConfigEntry<string> UpMenuKey { get; internal set; }
public static ConfigEntry<string> DownMenuKey { get; internal set; }
public static ConfigEntry<string> RightMenuKey { get; internal set; }
public static ConfigEntry<string> LeftMenuKey { get; internal set; }
public static ConfigEntry<string> SelectMenuKey { get; internal set; }
public static ConfigEntry<string> ExitMenuKey { get; internal set; }
public static ConfigEntry<bool> ConstellationSpecificInfoNodes { get; internal set; }
public static void BindConfigSettings()
{
Plugin.Log.LogInfo((object)"Binding configuration settings");
ExtensiveLogging = ConfigSetup.MakeBool(((BaseUnityPlugin)Plugin.instance).Config, "Debug", "ExtensiveLogging", false, "Enable or Disable extensive logging for this mod.");
DeveloperLogging = ConfigSetup.MakeBool(((BaseUnityPlugin)Plugin.instance).Config, "Debug", "DeveloperLogging", false, "Enable or Disable developer logging for this mod. (this will fill your log file FAST)");
ConstellationList = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "Setup", "ConstellationList", "", "Comma separated list of your ConstellationWord Names, or leave blank for default LLL moon tags\nWARNING: Changing this setting will reset your generated config!\nThis setting cannot be updated in-game!");
ManualSetupListing = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "Setup", "ManualSetupListing", "Constellation1:experimentation,assurance,vow;Constellation2:titan,rend,dine;Constellation3:offense,march,artifice,embrion", "This configuration item will attempt to match constellation names listed in ConstellationList to moon names.\nThis can be left blank if you are already working within your generated config and is mostly here as an option to streamline initial setup\nNOTE: This will not override an already generated config!");
CompanyDefaultConstellation = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "Setup", "CompanyDefaultConstellation", "", "The company's default constellation.\nThis constellation will be assigned when loading saves starting at the company moon.");
AcceptableStartingConstellations = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "Setup", "AcceptableStartingConstellations", "", "When StartingConstellation is set to \"~random~\" this comma separated list will be used to choose a random starting constellation.\nLeave blank to choose from all possible constellations!\nNOTE: You can put duplicate entries of a constellation name to raise the odds that it will be chosen, this list does not need to have unique entries.");
StartingConstellation = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "Setup", "StartingConstellation", "", "Set this to customize the constellation you start at on a new save.\nIf set to \"~random~\" you will be routed to a random constellation at game start.\nIf set to a valid constellation, you will be routed to the default moon of the constellation when starting a new game.\nLeave blank to leave starting moon unaffected (experimentation or handled by another mod)\n");
IgnoreList = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "Setup", "IgnoreList", "Liquidation,Moon2Example", "Comma separated list of moon names that should not be touched by this mod.\nGenerally you'll almost always have Liquidation in this list until it's a real moon as well as any moons you dont want associated with any particular constellation");
ModifyMoonPrices = ConfigSetup.MakeBool(((BaseUnityPlugin)Plugin.instance).Config, "Setup", "ModifyMoonPrices", true, "Disable this to stop this mod from modifying any moon prices");
RequireConfirmation = ConfigSetup.MakeBool(((BaseUnityPlugin)Plugin.instance).Config, "Setup", "RequireConfirmation", true, "Enable this to require add a confirmation check before routing to a constellation and spending credits");
HideUnaffordableConstellations = ConfigSetup.MakeBool(((BaseUnityPlugin)Plugin.instance).Config, "Setup", "HideUnaffordableConstellations", false, "Enable this to hide constellations that you can't afford to route to.");
AddHintTo = ConfigSetup.MakeClampedString(((BaseUnityPlugin)Plugin.instance).Config, "Setup", "AddHintTo", "both", "Choose where to add hints to the main 'constellations' command", new AcceptableValueList<string>(new string[4] { "both", "none", "help", "other" }));
ConstellationSpecificInfoNodes = ConfigSetup.MakeBool(((BaseUnityPlugin)Plugin.instance).Config, "Setup", "ConstellationSpecificInfoNodes", false, "Enable this to add config options to the dynamic config for each constellation to have info nodes with customizable text");
ReturnToLastConstellationFromCompany = ConfigSetup.MakeBool(((BaseUnityPlugin)Plugin.instance).Config, "Setup", "ReturnToLastConstellationFromCompany", true, "Disable this to always travel to the CompanyDefaultConstellation when returning from the company moon.\nEnable this if you wish to return to the constellation you routed to the company moon from.");
AddConstellationPositionData = ConfigSetup.MakeBool(((BaseUnityPlugin)Plugin.instance).Config, "PositionalData", "AddConstellationPositionData", false, "Enable this if you wish to add positional data for each constellation that can affect constellation pricing.");
CostPerDistanceUnit = ConfigSetup.MakeClampedInt(((BaseUnityPlugin)Plugin.instance).Config, "PositionalData", "CostPerDistanceUnit", 2, "When PostionalPricingMode for a particular constellation is set to SetPriceByDistance, the route price will set it's route cost based on it's distance from the current constellation multiplied by this number", 0, 100);
ConstellationsWord = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "Customization", "ConstellationsWord", "Constellations", "Use this config item to change any instance of the word 'Constellations' with your own specific word.\nThe terminal keyword will use this one!!!\nWARNING: Changing this setting will reset your generated config!\nThis setting cannot be updated in-game!");
ConstellationWord = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "Customization", "ConstellationWord", "Constellation", "Use this config item to change any instance of the word 'Constellation' with your own specific word.\nWARNING: Changing this setting will reset your generated config!\nThis setting cannot be updated in-game!");
ConstellationsShortcuts = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "Customization", "ConstellationsShortcut", "", "Specify a list of shortcuts to use for the constellations menu command.\nEach shortcut keyword is separated by a ','");
ConstellationsHintText = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "Customization", "ConstellationsHintText", ">[keyword]\nTo display Constellations available for routing", "text displayed for the hint added to commands like 'help' and 'other' regarding the constellations menu command");
ConstellationsInfoText = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "Customization", "ConstellationsInfoText", "Use this command to display Constellations available for routing.\n\nRoute to a specific constellation to update your moons listing!\r\n\r\n", "Use this config item to change any instance of the word 'ConstellationWord' with your own specific word");
MainConfigCode = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "Tools", "MainConfigCode", "", "Paste a code here from the web config editor for the main config\nWARNING: Some settings require a complete relaunch of the game and sometimes even deleting a previously generated config!");
GeneratedConfigCode = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "Tools", "GeneratedConfigCode", "", "Paste a code here from the web config editor for the generated config.\nThis will only apply if you have already loaded into the lobby once.");
ConstellationsPerPage = ConfigSetup.MakeClampedInt(((BaseUnityPlugin)Plugin.instance).Config, "Menu Settings", "ConstellationsPerPage", 3, "The number of constellations (with applicable info) to display per page in the constellations menu. Set to 3 by default to prevent the need to scroll within the menu with all info text enabled.\nWARNING: Setting this number too high can result in having to scroll to find the option you are on.", 1, 100);
LeftMenuKey = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "Menu Settings", "LeftMenuKey", "LeftArrow", "Set key to press to go to previous page in constellations menu");
RightMenuKey = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "Menu Settings", "RightMenuKey", "RightArrow", "Set key to press to go to next page in constellations menu");
UpMenuKey = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "Menu Settings", "UpMenuKey", "UpArrow", "Set key to press to go to previous item on page in constellations menu");
DownMenuKey = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "Menu Settings", "DownMenuKey", "DownArrow", "Set key to press to go to next item on page in constellations menu");
ExitMenuKey = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "Menu Settings", "ExitMenuKey", "Backspace", "Set key to press to leave constellations menu");
SelectMenuKey = ConfigSetup.MakeString(((BaseUnityPlugin)Plugin.instance).Config, "Menu Settings", "SelectMenuKey", "Enter", "Set key to press to select a constellation in constellations menu");
((BaseUnityPlugin)Plugin.instance).Config.Save();
ConfigSetup.RemoveOrphanedEntries(((BaseUnityPlugin)Plugin.instance).Config);
Collections.ConstellationWord = ConstellationWord.Value;
Collections.ConstellationsWord = ConstellationsWord.Value;
}
}
}
namespace LethalConstellations.PluginCore
{
public class ClassMapper
{
public string consName;
public List<string> constelMoons = new List<string>();
public List<string> stayHiddenMoons = new List<string>();
public bool buyOnce;
public int constelPrice;
public Vector3 RelativePosition;
internal string positionalPriceMode;
public float originalDistance;
public string defaultMoon;
public ExtendedLevel defaultMoonLevel;
internal string menuText;
internal string infoText;
public bool isHidden;
public string optionalParams = "";
public bool isLocked;
public bool oneTimePurchase;
public bool canRouteCompany;
internal List<string> shortcutList;
internal ClassMapper(string cName, int cPrice = 0, string defMoon = "", string mText = "")
{
consName = cName;
constelPrice = cPrice;
defaultMoon = defMoon;
menuText = mText;
oneTimePurchase = false;
isLocked = false;
}
internal void SetPosition(string value)
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
List<string> list = value.Split(new char[1] { ',' }).ToList();
list.RemoveAll((string x) => x.Length == 0);
RelativePosition = Vector3.zero;
int num = 0;
int num2 = 0;
int num3 = 0;
if (list.Count != 3)
{
return;
}
bool flag = true;
for (int i = 0; i < list.Count; i++)
{
if (int.TryParse(list[i], out var result))
{
switch (i)
{
case 0:
num = result;
break;
case 1:
num2 = result;
break;
default:
num3 = result;
break;
}
}
else
{
flag = false;
}
}
if (flag)
{
RelativePosition = new Vector3((float)num, (float)num2, (float)num3);
}
}
internal void SetOriginalDistance()
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
originalDistance = Vector3.Distance(RelativePosition, Collections.StarterConstellation.RelativePosition);
if (positionalPriceMode == "SetPriceByDistance")
{
constelPrice = Configuration.CostPerDistanceUnit.Value * (int)originalDistance;
}
Plugin.Spam($"Price for constellation set to {constelPrice} ({Configuration.CostPerDistanceUnit.Value} x (int)originalDistance)");
}
internal void OneTimePurchase()
{
if (!oneTimePurchase && buyOnce && Plugin.instance.LethalNetworkAPI)
{
Plugin.Spam("Updating oneTimePurchase to true");
oneTimePurchase = true;
constelPrice = 0;
if (!Collections.ConstellationsOTP.Contains(consName))
{
Collections.ConstellationsOTP.Add(consName);
SaveManager.SaveUnlocks(Collections.ConstellationsOTP);
NetworkThings.SyncUnlockSet(Collections.ConstellationsOTP);
}
else
{
Plugin.WARNING("--- Error with oneTimePurchaseCheck, already in list ---");
}
}
}
internal int GetDistance()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
if (!Configuration.AddConstellationPositionData.Value)
{
return -1;
}
if (Collections.CurrentConstellationCM == null)
{
return -1;
}
return (int)Vector3.Distance(Collections.CurrentConstellationCM.RelativePosition, RelativePosition);
}
internal static void UpdateCNames(List<ClassMapper> constellations, Dictionary<string, string> fixedNames)
{
if (constellations.Count < 1 || fixedNames.Count < 1)
{
return;
}
foreach (KeyValuePair<string, string> fixedName in fixedNames)
{
if (CheckForAndUpdateCName(constellations, fixedName.Key, fixedName.Value))
{
Plugin.Spam("CheckForAndUpadteCName success");
}
}
}
public static bool IsLevelInConstellation(SelectableLevel level, string constellation = "")
{
if ((Object)(object)level == (Object)null)
{
return false;
}
if (constellation.Length < 1)
{
constellation = Collections.CurrentConstellation;
}
string numberlessPlanetName = ExtendedLevel.GetNumberlessPlanetName(level);
if (TryGetConstellation(Collections.ConstellationStuff, constellation, out ClassMapper outConst))
{
if (outConst.constelMoons.Contains(numberlessPlanetName))
{
return true;
}
return false;
}
return false;
}
public static bool TryGetConstellation(List<ClassMapper> constellations, string query, out ClassMapper outConst)
{
string query2 = query;
Plugin.Spam("TryGetConstellation:");
Plugin.Spam(query2);
if (constellations.Count < 1 || query2.Length < 1)
{
Plugin.Spam("Invalid search in TryGetConstellation()");
outConst = null;
return false;
}
foreach (ClassMapper constellation in constellations)
{
if (constellation.consName.ToLowerInvariant() == query2.ToLowerInvariant() || constellation.shortcutList.Any((string x) => x.ToLowerInvariant() == query2.ToLowerInvariant()))
{
Plugin.Spam("constellation found with name: " + constellation.consName);
outConst = constellation;
return true;
}
}
Plugin.Spam("Cannot find " + query2);
outConst = null;
return false;
}
internal static bool CheckForAndUpdateCName(List<ClassMapper> constellations, string query, string newValue)
{
if (constellations.Count < 1 || query.Length < 1)
{
Plugin.Spam("Invalid search in CheckForCName()");
return false;
}
foreach (ClassMapper constellation in constellations)
{
if (constellation.consName == query)
{
constellation.consName = newValue;
Plugin.Spam("bad name " + query + " updated to " + constellation.consName);
return true;
}
}
Plugin.Spam("Unable to find bad name - " + query);
return false;
}
internal static void UpdateConstellationUnlocks()
{
if (Collections.ConstellationsOTP.Count == 0)
{
return;
}
foreach (string item in Collections.ConstellationsOTP)
{
if (TryGetConstellation(Collections.ConstellationStuff, item, out ClassMapper outConst) && outConst != null)
{
if (outConst.buyOnce && !outConst.oneTimePurchase)
{
outConst.oneTimePurchase = true;
}
Plugin.Spam(outConst.consName + " detected as unlocked from save file");
}
}
}
internal static void ResetUnlockedConstellations(List<ClassMapper> constellations)
{
if (constellations.Count == 0)
{
return;
}
foreach (ClassMapper constellation in constellations)
{
constellation.oneTimePurchase = false;
Plugin.Spam(constellation.consName + " OTP has been reset");
}
}
}
public class Collections
{
internal static List<string> ConstellationsList = new List<string>();
internal static Dictionary<string, string> ManualSetupList = new Dictionary<string, string>();
internal static Random Rand = new Random();
public static List<ClassMapper> ConstellationStuff = new List<ClassMapper>();
public static List<ClassMapper> DisplayConstellations = new List<ClassMapper>();
internal static Dictionary<string, string> ConstellationCats = new Dictionary<string, string>();
internal static Dictionary<ExtendedLevel, int> MoonPrices = new Dictionary<ExtendedLevel, int>();
internal static Dictionary<string, string> CNameFix = new Dictionary<string, string>();
internal static string CompanyMoon = "Gordion";
public static string CurrentConstellation = "";
public static ClassMapper CurrentConstellationCM;
internal static string ConstellationsWord;
internal static string ConstellationWord;
internal static TerminalNode ConstellationsNode;
internal static TerminalNode RouteShortcutNode;
internal static List<string> ConstellationsOTP = new List<string>();
internal static ClassMapper StarterConstellation;
internal static void Start()
{
MoonPrices.Clear();
}
internal static bool TryGetConstellationFromScreenText(out ClassMapper outConst, out string failText)
{
failText = "General Error, unexpected screen text...\r\n\r\n";
Plugin.Spam("Getting screen text");
string text = Plugin.instance.Terminal.screenText.text.Substring(Plugin.instance.Terminal.screenText.text.Length - Plugin.instance.Terminal.textAdded);
Plugin.Spam(text);
Plugin.Spam($"{ConstellationStuff.Count}");
if (ClassMapper.TryGetConstellation(ConstellationStuff, text, out outConst))
{
Plugin.Spam("Current Constellation: " + CurrentConstellation);
if (CurrentConstellation == outConst.consName)
{
failText = "You are already located at " + ConstellationWord + " - " + CurrentConstellation + "...\r\n\r\n";
return false;
}
if (outConst.isLocked)
{
failText = "Unable to travel to " + outConst.consName + ". " + ConstellationWord + " is locked!\r\n\r\n";
return false;
}
return true;
}
failText = "Unable to travel to " + ConstellationWord + " provided in command [ " + text + " ]\r\n\r\n";
return false;
}
}
internal class MenuStuff
{
[CompilerGenerated]
private static class <>O
{
public static Event <0>__AnyKeyEvent;
public static Func<string> <1>__EnterMenu;
public static Func<string> <2>__RouteShortcut;
}
internal static InteractiveMenu ConstellationsMenu = new InteractiveMenu("Constellations_Menu", (Action)LoadPage, (Action)MenuSelect, (Action)ExitToTerminal, (Dictionary<Key, Action>)null);
internal static List<Key> KeysBound = new List<Key>();
internal static bool ConfirmationCheck = false;
internal static Color transparent = new Color(0f, 0f, 0f, 0f);
internal static void PreInit()
{
if (FixBadConfig())
{
Plugin.Spam("ConstellationWord custom words updated to " + Collections.ConstellationsWord);
}
Init();
}
internal static void LoadSpecial(string message)
{
((MonoBehaviour)Plugin.instance.Terminal).StartCoroutine(DelayUpdateText(message));
}
internal static void LoadPage()
{
((MonoBehaviour)Plugin.instance.Terminal).StartCoroutine(DelayUpdateText());
}
internal static IEnumerator DelayUpdateText(string newText = "")
{
yield return (object)new WaitForEndOfFrame();
if (newText.Length < 1)
{
Collections.ConstellationsNode.displayText = MainMenuText(ConstellationsMenu.activeSelection, ref ConstellationsMenu.currentPage);
}
else
{
Collections.ConstellationsNode.displayText = newText;
}
yield return (object)new WaitForEndOfFrame();
if (Plugin.instance.TerminalStuff)
{
TerminalStuffMod.LoadAndSync(Collections.ConstellationsNode);
}
else
{
Plugin.instance.Terminal.LoadNewNode(Collections.ConstellationsNode);
}
yield return (object)new WaitForEndOfFrame();
}
internal static void AnyKeyEvent()
{
if (ConfirmationCheck)
{
Plugin.Spam("Confirmation check for " + Collections.DisplayConstellations[ConstellationsMenu.activeSelection].consName + "!");
if (((ButtonControl)Keyboard.current[(Key)2]).isPressed)
{
int constPrice = LevelStuff.GetConstPrice(Collections.DisplayConstellations[ConstellationsMenu.activeSelection]);
TravelToNewConstellation(constPrice, ConstellationsMenu.activeSelection);
ConfirmationCheck = false;
}
if (((ButtonControl)Keyboard.current[(Key)65]).isPressed)
{
LoadSpecial("Route to " + Collections.ConstellationWord + " " + Collections.DisplayConstellations[ConstellationsMenu.activeSelection].consName.ToUpper() + " has been canceled.\r\n\r\n\tPress any key to continue...\r\n");
ConfirmationCheck = false;
}
}
else
{
Plugin.Spam("Accepting any key to continue!");
ConstellationsMenu.acceptAnything = false;
LoadPage();
}
}
internal static void MenuSelect()
{
int constPrice = LevelStuff.GetConstPrice(Collections.DisplayConstellations[ConstellationsMenu.activeSelection]);
Plugin.Spam($"Price of {Collections.DisplayConstellations[ConstellationsMenu.activeSelection].consName} is {constPrice}!");
if (CannotRoute(constPrice, ConstellationsMenu.activeSelection, out string message))
{
ConstellationsMenu.acceptAnything = true;
LoadSpecial(message);
}
else if (Configuration.RequireConfirmation.Value)
{
ConstellationsMenu.acceptAnything = true;
ConfirmationCheck = true;
LoadSpecial("Travel to " + Collections.ConstellationWord + " - " + Collections.DisplayConstellations[ConstellationsMenu.activeSelection].consName.ToUpper() + "?\n\n\tPress [ ENTER ] to CONFIRM\n\tPress [ BACKSPACE ] to DENY\n");
}
else
{
TravelToNewConstellation(constPrice, ConstellationsMenu.activeSelection);
}
}
internal static string RouteShortcut()
{
Collections.DisplayConstellations = Collections.ConstellationStuff;
if (Collections.TryGetConstellationFromScreenText(out ClassMapper outConst, out string failText))
{
int num = Collections.DisplayConstellations.IndexOf(outConst);
int constPrice = LevelStuff.GetConstPrice(Collections.DisplayConstellations[num]);
if (CannotRoute(constPrice, Collections.DisplayConstellations.IndexOf(outConst), out failText))
{
ConfirmationCheck = true;
((MonoBehaviour)Plugin.instance.Terminal).StartCoroutine(MenuStart(acceptAnything: true));
return failText;
}
if (Configuration.RequireConfirmation.Value)
{
ConfirmationCheck = true;
((MonoBehaviour)Plugin.instance.Terminal).StartCoroutine(MenuStart(acceptAnything: true));
ConstellationsMenu.activeSelection = num;
return "Travel to " + Collections.ConstellationWord + " - " + Collections.DisplayConstellations[num].consName.ToUpper() + "?\n\n\tPress [ ENTER ] to CONFIRM\n\tPress [ BACKSPACE ] to DENY\n";
}
TravelToNewConstellation(constPrice, num);
return "";
}
return failText;
}
internal static void TravelToNewConstellation(int getPrice, int indexNum)
{
Collections.CurrentConstellation = Collections.DisplayConstellations[indexNum].consName;
Collections.CurrentConstellationCM = Collections.DisplayConstellations[indexNum];
Plugin.Spam($"oldcreds: {Plugin.instance.Terminal.groupCredits}");
int num = Plugin.instance.Terminal.groupCredits - getPrice;
Plugin.Spam($"newCreds amount = {Plugin.instance.Terminal.groupCredits}");
StartOfRound.Instance.ChangeLevelServerRpc(Collections.CurrentConstellationCM.defaultMoonLevel.SelectableLevel.levelID, num);
if (getPrice > 0)
{
Plugin.instance.Terminal.PlayTerminalAudioServerRpc(0);
}
NewEvents.RouteConstellationSuccess.Invoke();
Collections.DisplayConstellations[indexNum].OneTimePurchase();
ConstellationsMenu.acceptAnything = true;
LoadSpecial($"Travelling to {Collections.ConstellationWord} - {Collections.CurrentConstellation.ToUpper()}\nYour new credits balance: ${num}\r\n\r\nPress any key to continue...\r\n");
}
internal static void ExitToTerminal()
{
ExitMenu(enableInput: true);
}
internal static void ExitMenu(bool enableInput)
{
((MonoBehaviour)Plugin.instance.Terminal).StartCoroutine(MenuClose(enableInput));
}
internal static IEnumerator MenuClose(bool enableInput)
{
yield return (object)new WaitForEndOfFrame();
ConstellationsMenu.inMenu = false;
ConfirmationCheck = false;
yield return (object)new WaitForEndOfFrame();
if (Plugin.instance.TerminalStuff)
{
TerminalStuffMod.LoadAndSync(Plugin.instance.Terminal.terminalNodes.specialNodes[13]);
}
else
{
Plugin.instance.Terminal.LoadNewNode(Plugin.instance.Terminal.terminalNodes.specialNodes[13]);
}
yield return (object)new WaitForEndOfFrame();
CommonTerminal.ChangeCaretColor(CommonTerminal.CaretOriginal, false);
if (enableInput)
{
Plugin.instance.Terminal.screenText.ActivateInputField();
((Selectable)Plugin.instance.Terminal.screenText).interactable = true;
}
}
internal static IEnumerator MenuStart(bool acceptAnything)
{
if (!ConstellationsMenu.inMenu)
{
yield return (object)new WaitForEndOfFrame();
CommonTerminal.ChangeCaretColor(transparent, true);
ConstellationsMenu.inMenu = true;
ConstellationsMenu.acceptAnything = acceptAnything;
yield return (object)new WaitForEndOfFrame();
Plugin.instance.Terminal.screenText.DeactivateInputField(false);
((Selectable)Plugin.instance.Terminal.screenText).interactable = false;
}
}
internal static void Init()
{
Plugin.Spam("ConstellationsKeywords()");
ConstellationsKeywords();
MoonStuff.ModifyMoonPrices();
InteractiveMenuStuff();
}
internal static void InteractiveMenuStuff()
{
//IL_003b: 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_0046: Expected O, but got Unknown
ConstellationsMenu.isMenuEnabled = true;
ConstellationsMenu.activeSelection = 0;
ConstellationsMenu.currentPage = 1;
CustomEvent acceptAnyKeyEvent = ConstellationsMenu.AcceptAnyKeyEvent;
object obj = <>O.<0>__AnyKeyEvent;
if (obj == null)
{
Event val = AnyKeyEvent;
<>O.<0>__AnyKeyEvent = val;
obj = (object)val;
}
acceptAnyKeyEvent.AddListener((Event)obj);
KeysBound.Clear();
TrySetKey(ref ConstellationsMenu.upMenu, Configuration.UpMenuKey.Value);
TrySetKey(ref ConstellationsMenu.downMenu, Configuration.DownMenuKey.Value);
TrySetKey(ref ConstellationsMenu.rightMenu, Configuration.RightMenuKey.Value);
TrySetKey(ref ConstellationsMenu.leftMenu, Configuration.LeftMenuKey.Value);
TrySetKey(ref ConstellationsMenu.selectMenu, Configuration.SelectMenuKey.Value);
TrySetKey(ref ConstellationsMenu.leaveMenu, Configuration.ExitMenuKey.Value);
}
internal static void TrySetKey(ref Key original, string config)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Invalid comparison between I4 and Unknown
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Expected I4, but got Unknown
Key val = default(Key);
if (!CommonStringStuff.TryGetKey(config, ref val))
{
return;
}
if (KeysBound.Contains(val))
{
Plugin.WARNING($"Unable to set to key {val}, it is already in use!");
}
else if ((int)original != (int)val)
{
Plugin.Log.LogInfo((object)$"Changing default binding of {original} to {val}");
KeysBound.Add(val);
Key find = original;
Action value = ConstellationsMenu.MainActions.FirstOrDefault((KeyValuePair<Key, Action> x) => x.Key == find).Value;
if (value == null)
{
Plugin.WARNING($"UNABLE TO REPLACE KEY {original}! Action undefined!");
return;
}
ConstellationsMenu.MainActions.Remove(original);
ConstellationsMenu.MainActions.Add(val, value);
original = (Key)(int)val;
}
else
{
Plugin.Log.LogInfo((object)$"Default binding of {original} is already set.");
KeysBound.Add(original);
}
}
internal static bool FixBadConfig()
{
if (DynamicBools.TryGetKeyword(Collections.ConstellationsWord))
{
Collections.ConstellationsWord = GetCleanKeyWord();
Collections.ConstellationWord = Collections.ConstellationsWord;
return true;
}
return false;
}
internal static string GetCleanKeyWord()
{
for (int i = 0; i < StartOfRound.Instance.randomNames.Length - 1; i++)
{
int num = Collections.Rand.Next(0, StartOfRound.Instance.randomNames.Length);
string text = StartOfRound.Instance.randomNames[num];
if (!DynamicBools.TryGetKeyword(text))
{
return text;
}
}
return "invalidWord";
}
internal static void ConstellationsKeywords()
{
Plugin.Spam($"{Collections.ConstellationCats.Count}");
Collections.ConstellationsNode = AddingThings.AddNodeManual("Constellations_Menu", Collections.ConstellationsWord, (Func<string>)EnterMenu, true, 0, ConfigSetup.defaultListing, 0, (Func<string>)null, (Func<string>)null, "", "", false, 1, "", false, "");
TerminalNode val = BasicTerminal.CreateNewTerminalNode();
val.displayText = Configuration.ConstellationsInfoText.Value + "\r\n";
val.clearPreviousText = true;
TerminalKeyword val2 = default(TerminalKeyword);
if (DynamicBools.TryGetKeyword("info", ref val2))
{
AddingThings.AddCompatibleNoun(ref val2, Collections.ConstellationsWord.ToLower(), val);
Plugin.Spam("Adding info stuff");
}
if (Configuration.ConstellationsShortcuts.Value.Length > 0)
{
List<string> keywordsPerConfigItem = CommonStringStuff.GetKeywordsPerConfigItem(Configuration.ConstellationsShortcuts.Value, ',');
foreach (string item in keywordsPerConfigItem)
{
AddingThings.AddKeywordToExistingNode(item, Collections.ConstellationsNode, true);
Plugin.Spam(item + " added to ConstellationsNode");
if ((Object)(object)val2 != (Object)null)
{
AddingThings.AddCompatibleNoun(ref val2, item.ToLower(), val);
Plugin.Spam(item + " info command added!");
}
}
}
foreach (ClassMapper item2 in Collections.ConstellationStuff)
{
RouteShortcuts(item2, val2);
}
AddHintsToNodes();
}
internal static void RouteShortcuts(ClassMapper cons, TerminalKeyword infokeyword)
{
Plugin.Spam("Setting shortcuts for:");
Plugin.Spam(cons.consName);
if (cons.shortcutList.Count == 0)
{
return;
}
TerminalNode val = null;
bool flag = cons.infoText.Length > 0;
if (flag)
{
val = BasicTerminal.CreateNewTerminalNode();
val.displayText = Configuration.ConstellationsInfoText.Value + "\r\n";
val.clearPreviousText = true;
}
Collections.RouteShortcutNode = AddingThings.AddNodeManual("Constellations_Menu", cons.consName + " shortcutword", (Func<string>)RouteShortcut, true, 0, ConfigSetup.defaultListing, 0, (Func<string>)null, (Func<string>)null, "", "", false, 1, "", false, "");
foreach (string shortcut in cons.shortcutList)
{
AddingThings.AddKeywordToExistingNode(shortcut, Collections.RouteShortcutNode, true);
if (flag && (Object)(object)infokeyword != (Object)null)
{
AddingThings.AddCompatibleNoun(ref infokeyword, shortcut.ToLower(), val);
Plugin.Spam(shortcut + " info command added!");
}
}
}
internal static void AddHintsToNodes()
{
string text = Configuration.ConstellationsHintText.Value.Replace("[keyword]", Collections.ConstellationsWord.ToUpper() ?? "");
TerminalNode val = default(TerminalNode);
if (LogicHandling.TryGetFromAllNodes("OtherCommands", ref val))
{
if (Configuration.AddHintTo.Value == "both" || Configuration.AddHintTo.Value == "help")
{
AddingThings.AddToHelpCommand(text ?? "");
}
if (Configuration.AddHintTo.Value == "both" || Configuration.AddHintTo.Value == "other")
{
AddingThings.AddToExistingNodeText("\n" + text, ref val);
}
}
}
internal static string EnterMenu()
{
ConstellationsMenu.currentPage = 1;
((MonoBehaviour)Plugin.instance.Terminal).StartCoroutine(MenuStart(acceptAnything: false));
return MainMenuText(0, ref ConstellationsMenu.currentPage);
}
internal static string MainMenuText(int activeIndex, ref int currentPage)
{
//IL_031b: Unknown result type (might be due to invalid IL or missing references)
//IL_035b: Unknown result type (might be due to invalid IL or missing references)
//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
//IL_0389: Unknown result type (might be due to invalid IL or missing references)
//IL_0398: Unknown result type (might be due to invalid IL or missing references)
if (Collections.ConstellationStuff.Count == 0)
{
return "Unable to route to any " + Collections.ConstellationsWord + " at this time!\r\n\r\n\t" + Collections.ConstellationWord + " count is 0!!!\r\n\r\n";
}
Collections.DisplayConstellations = Collections.ConstellationStuff;
if (Configuration.HideUnaffordableConstellations.Value)
{
Collections.DisplayConstellations = Collections.DisplayConstellations.FindAll((ClassMapper x) => LevelStuff.GetConstPrice(x) <= Plugin.instance.Terminal.groupCredits);
}
if (Collections.DisplayConstellations.Count == 0)
{
return "Unable to route to any " + Collections.ConstellationsWord + "! All constellations cannot be afforded!";
}
currentPage = Mathf.Clamp(currentPage, 1, Mathf.CeilToInt((float)Collections.DisplayConstellations.Count / (float)Configuration.ConstellationsPerPage.Value));
int num = (currentPage - 1) * Configuration.ConstellationsPerPage.Value;
int num2 = ((Collections.DisplayConstellations.Count <= Configuration.ConstellationsPerPage.Value) ? Collections.DisplayConstellations.Count : Mathf.Min(num + Configuration.ConstellationsPerPage.Value, Collections.DisplayConstellations.Count));
activeIndex = Mathf.Clamp(activeIndex, num, num2 - 1);
ConstellationsMenu.activeSelection = activeIndex;
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append("========== " + Collections.ConstellationsWord + " Routing Matrix ==========\n");
for (int i = num; i < num2; i++)
{
ClassMapper classMapper = Collections.DisplayConstellations[i];
string menuText = classMapper.menuText;
string defaultMoon = classMapper.defaultMoon;
string newValue = "";
if ((Object)(object)classMapper.defaultMoonLevel == (Object)null)
{
Plugin.WARNING(classMapper.consName + " defaultMoonLevel is NULL. This will affect performance of the mod");
}
else
{
newValue = TerminalManager.GetWeatherConditions(classMapper.defaultMoonLevel);
}
int constPrice = LevelStuff.GetConstPrice(Collections.DisplayConstellations[i]);
int distance = classMapper.GetDistance();
string text = ((distance != -1) ? distance.ToString() : "[Unknown]");
menuText = menuText.Replace("[~t]", "\t").Replace("[~n]", "\n").Replace("[name]", classMapper.consName)
.Replace("[price]", $"{constPrice}")
.Replace("[defaultmoon]", defaultMoon ?? "")
.Replace("[currentweather]", newValue)
.Replace("[currentdistance]", "Distance: " + text)
.Replace("[optionals]", classMapper.optionalParams);
if (menuText.Length < 1)
{
menuText = classMapper.consName.ToUpperInvariant();
}
if (i == activeIndex)
{
stringBuilder.Append("> " + menuText + "\n\n");
}
else
{
stringBuilder.Append(menuText + "\n\n");
}
}
stringBuilder.Append("Current " + Collections.ConstellationWord + ": " + Collections.CurrentConstellation + "\r\n\r\n");
stringBuilder.Append($"Page [{ConstellationsMenu.leftMenu}] < {currentPage}/{Mathf.CeilToInt((float)Collections.DisplayConstellations.Count / (float)Configuration.ConstellationsPerPage.Value)} > [{ConstellationsMenu.rightMenu}]\r\n");
if (Configuration.ConstellationsPerPage.Value > 1)
{
stringBuilder.Append($"Next [{ConstellationsMenu.downMenu}] / Previous [{ConstellationsMenu.upMenu}]\r\n");
}
stringBuilder.Append($"Select [{ConstellationsMenu.selectMenu}] / Exit [{ConstellationsMenu.leaveMenu}]");
return stringBuilder.ToString();
}
internal static bool CannotRoute(int getPrice, int selection, out string message)
{
if (Collections.DisplayConstellations.Count < 1)
{
message = "Configuration failure detected!\r\n\r\nPress any key to continue...\r\n\r\n";
return true;
}
if (StartOfRound.Instance.travellingToNewLevel)
{
message = "Ship is currently in motion, unable to change routing at this time!\r\n\r\nPress any key to continue...\r\n\r\n";
return true;
}
if (!StartOfRound.Instance.inShipPhase)
{
message = "Ship needs to be in orbit in order to travel to new " + Collections.ConstellationWord + "!\r\n\r\nPress any key to continue...\r\n\r\n";
return true;
}
if (Plugin.instance.Terminal.groupCredits < getPrice)
{
message = "Unable to afford to travel to " + Collections.ConstellationWord + " - " + Collections.DisplayConstellations[selection].consName.ToUpper() + "\r\n\r\nPress any key to continue...\r\n\r\n";
return true;
}
if (Collections.DisplayConstellations[selection].isLocked)
{
message = "Unable to travel to " + Collections.DisplayConstellations[selection].consName + ". " + Collections.ConstellationWord + " is locked!\r\n\r\nPress any key to continue...\r\n\r\n";
return true;
}
message = "";
return false;
}
}
internal class MoonStuff
{
internal static void ModifyMoonPrices()
{
Plugin.Spam("MODIFYMOONPRICES");
if (Collections.MoonPrices.Count < 1 || !Configuration.ModifyMoonPrices.Value)
{
return;
}
foreach (KeyValuePair<ExtendedLevel, int> moonPrice in Collections.MoonPrices)
{
Plugin.Spam($"Modifying {moonPrice.Key.NumberlessPlanetName} price from {moonPrice.Key.RoutePrice} to {moonPrice.Value}");
moonPrice.Key.RoutePrice = moonPrice.Value;
}
}
internal static ExtendedLevel GetExtendedLevel(string levelName)
{
foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels)
{
if (extendedLevel.NumberlessPlanetName.ToLower() == levelName.ToLower())
{
return extendedLevel;
}
}
Plugin.WARNING("WARNING: Unable to get extendedLevel from " + levelName + "!!");
return null;
}
internal static bool TryGetMoon(string levelName, Dictionary<string, int> moonPrices, out int price)
{
price = -1;
if (moonPrices.Count == 0)
{
return false;
}
foreach (KeyValuePair<string, int> moonPrice in moonPrices)
{
if (moonPrice.Key.ToLower() == levelName.ToLower())
{
price = moonPrice.Value;
return true;
}
}
return false;
}
}
internal class SaveManager
{
internal static void InitSave()
{
Plugin.Spam("InitSave");
if (!Plugin.instance.LethalNetworkAPI)
{
Plugin.WARNING("Networking is disabled!");
LevelStuff.DefaultConstellation();
return;
}
Collections.ConstellationsOTP.Clear();
ClassMapper.ResetUnlockedConstellations(Collections.ConstellationStuff);
NetworkThings.InitNetworkThings();
if (!GameNetworkManager.Instance.isHostingGame)
{
NetworkThings.RequestSyncFromHost();
return;
}
InitUnlocks();
InitCurrent();
}
internal static void InitHostStuff()
{
if (!GameNetworkManager.Instance.isHostingGame || StartOfRound.Instance.gameStats.daysSpent != 0 || StartOfRound.Instance.defaultPlanet != StartOfRound.Instance.currentLevelID || Configuration.StartingConstellation.Value.Length <= 0)
{
return;
}
if (Configuration.StartingConstellation.Value == "~random~")
{
ClassMapper outConst = null;
if (Configuration.AcceptableStartingConstellations.Value.Length > 0)
{
List<string> keywordsPerConfigItem = CommonStringStuff.GetKeywordsPerConfigItem(Configuration.AcceptableStartingConstellations.Value, ',');
keywordsPerConfigItem.RemoveAll((string x) => x.Length < 1);
int num = 0;
do
{
int index = Collections.Rand.Next(keywordsPerConfigItem.Count);
num++;
if (ClassMapper.TryGetConstellation(Collections.ConstellationStuff, keywordsPerConfigItem[index], out outConst))
{
Plugin.Spam("Random Starter Constellation Chosen! [ " + outConst.consName + " ]");
}
else if (num > 10)
{
Plugin.WARNING("FAILED TO GRAB A VALID RANDOM STARTER CONSTELLATION FROM LIST [ " + Configuration.AcceptableStartingConstellations.Value + " ]");
Plugin.WARNING($"Setting Constellation to ANY random constellation from listing (Count:{Collections.ConstellationStuff.Count}");
outConst = Collections.ConstellationStuff[Collections.Rand.Next(Collections.ConstellationStuff.Count)];
}
}
while (outConst == null);
}
else
{
outConst = Collections.ConstellationStuff[Collections.Rand.Next(Collections.ConstellationStuff.Count)];
}
SetStarterConstellation(outConst);
}
if (ClassMapper.TryGetConstellation(Collections.ConstellationStuff, Configuration.StartingConstellation.Value, out ClassMapper outConst2))
{
SetStarterConstellation(outConst2);
}
else
{
Plugin.WARNING("Unable to set constellation to StartingConstellation config - [ " + Configuration.StartingConstellation.Value + " ]");
}
}
internal static void SetStarterConstellation(ClassMapper starter)
{
if ((Object)(object)StartOfRound.Instance.currentLevel != (Object)(object)starter.defaultMoonLevel.SelectableLevel)
{
StartOfRound.Instance.ChangeLevelServerRpc(starter.defaultMoonLevel.SelectableLevel.levelID, Plugin.instance.Terminal.groupCredits);
Plugin.Spam("Setting level to [ " + starter.defaultMoonLevel.NumberlessPlanetName + " ]");
}
LevelStuff.AdjustToNewConstellation(starter.defaultMoon, starter.consName);
StartOfRound.Instance.defaultPlanet = starter.defaultMoonLevel.SelectableLevel.levelID;
Plugin.Spam("Starter Constellation set to [ " + starter.consName + " ]!");
Collections.StarterConstellation = starter;
SetAllDistances();
}
internal static void SetAllDistances()
{
foreach (ClassMapper item in Collections.ConstellationStuff)
{
item.SetOriginalDistance();
}
}
internal static void InitUnlocks()
{
if (!ES3.KeyExists("LethalConstellations_Unlocks", GameNetworkManager.Instance.currentSaveFileName))
{
Plugin.Spam("Creating save key for LethalConstellations_Unlocks");
ES3.Save<List<string>>("LethalConstellations_Unlocks", Collections.ConstellationsOTP, GameNetworkManager.Instance.currentSaveFileName);
NetworkThings.SyncUnlockSet(Collections.ConstellationsOTP);
}
else
{
Collections.ConstellationsOTP = ES3.Load<List<string>>("LethalConstellations_Unlocks", GameNetworkManager.Instance.currentSaveFileName);
Plugin.Spam("Updating constellation unlocks from save file");
NetworkThings.SyncUnlockSet(Collections.ConstellationsOTP);
ClassMapper.UpdateConstellationUnlocks();
}
}
internal static void SaveUnlocks(List<string> unlockList)
{
if (GameNetworkManager.Instance.isHostingGame)
{
Plugin.Spam("saving LethalConstellations_Unlocks");
ES3.Save<List<string>>("LethalConstellations_Unlocks", unlockList, GameNetworkManager.Instance.currentSaveFileName);
}
}
internal static void InitCurrent()
{
if (!ES3.KeyExists("LethalConstellations_Current", GameNetworkManager.Instance.currentSaveFileName))
{
Plugin.Spam("Creating save key for LethalConstellations_Current");
string currentConstellation = Collections.CurrentConstellation;
Plugin.Spam("CurrentConstellation: " + Collections.CurrentConstellation);
ES3.Save<string>("LethalConstellations_Current", Collections.CurrentConstellation, GameNetworkManager.Instance.currentSaveFileName);
NetworkThings.SyncCurrentSet(currentConstellation);
}
else
{
string text = ES3.Load<string>("LethalConstellations_Current", GameNetworkManager.Instance.currentSaveFileName);
Plugin.Spam("CurrentConstellation fromSave: " + text);
Plugin.Spam("Updating current constellation from save file");
NetworkThings.SyncCurrentSet(text);
}
}
internal static void SaveCurrentConstellation(string currentConstellation)
{
if (GameNetworkManager.Instance.isHostingGame)
{
Plugin.Spam("saving LethalConstellations_Current");
ES3.Save<string>("LethalConstellations_Current", currentConstellation, GameNetworkManager.Instance.currentSaveFileName);
}
}
}
internal class LevelStuff
{
internal static bool gotConstellation = false;
internal static bool cancelConfirmation = false;
internal static string constellationName = "";
internal static ClassMapper nextConstellation;
internal static void ResetConstVars()
{
cancelConfirmation = true;
gotConstellation = false;
constellationName = "";
}
internal static void UpdateLevelList(ClassMapper thisConstellation, bool enableMoons)
{
if (!enableMoons)
{
Plugin.Spam("Disabling all moons in: " + thisConstellation.consName);
{
foreach (string constelMoon in thisConstellation.constelMoons)
{
AdjustExtendedLevel(constelMoon, thisConstellation, thisConstellation: false);
}
return;
}
}
Plugin.Spam("Enabling all moons in: " + thisConstellation.consName);
foreach (string constelMoon2 in thisConstellation.constelMoons)
{
AdjustExtendedLevel(constelMoon2, thisConstellation, thisConstellation: true);
}
}
internal static void AdjustExtendedLevel(string levelName, ClassMapper myConst, bool thisConstellation)
{
if (Plugin.instance.LethalMoonUnlocks)
{
return;
}
foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels)
{
if (!(extendedLevel.NumberlessPlanetName.ToLower() == levelName.ToLower()))
{
continue;
}
if (!thisConstellation)
{
Plugin.Spam(extendedLevel.NumberlessPlanetName + " should be DISABLED");
extendedLevel.IsRouteHidden = true;
extendedLevel.IsRouteLocked = true;
extendedLevel.LockedRouteNodeText = extendedLevel.NumberlessPlanetName + " is not located in this " + Collections.ConstellationWord + ".\n\n\tType \"" + Collections.ConstellationsWord + "\" to see a listing of LethalConstellations.\r\n\r\n";
}
else
{
Plugin.Spam(extendedLevel.NumberlessPlanetName + " should be ENABLED");
extendedLevel.IsRouteLocked = false;
if (!myConst.stayHiddenMoons.Contains(extendedLevel.NumberlessPlanetName) && extendedLevel.NumberlessPlanetName.ToLower() != Collections.CompanyMoon.ToLower())
{
extendedLevel.IsRouteHidden = false;
}
extendedLevel.LockedRouteNodeText = "";
}
}
}
internal static void AdjustToNewConstellation(string levelName, string constellationName)
{
if (constellationName.Length == 0)
{
Plugin.WARNING("Invalid constellationName at AdjustToNewConstellation");
return;
}
Plugin.Spam("Adjusting to " + constellationName + " from " + levelName);
if (levelName.ToLower() == Collections.CompanyMoon.ToLower() && ClassMapper.TryGetConstellation(Collections.ConstellationStuff, constellationName, out ClassMapper outConst))
{
AdjustExtendedLevel(outConst.defaultMoon, outConst, outConst.canRouteCompany);
return;
}
foreach (ClassMapper item in Collections.ConstellationStuff)
{
if (item.consName == constellationName)
{
UpdateLevelList(item, enableMoons: true);
if (item.canRouteCompany)
{
AdjustExtendedLevel(Collections.CompanyMoon, item, thisConstellation: true);
}
else
{
AdjustExtendedLevel(Collections.CompanyMoon, item, thisConstellation: false);
}
}
else
{
UpdateLevelList(item, enableMoons: false);
}
}
Collections.CurrentConstellation = constellationName;
if (GameNetworkManager.Instance.isHostingGame)
{
SaveManager.SaveCurrentConstellation(Collections.CurrentConstellation);
}
}
internal static void GetCurrentConstellation(string levelName, bool mustUpdate)
{
if (levelName.Length == 0)
{
Plugin.WARNING("Invalid levelName at GetCurrentConstellation");
return;
}
if (levelName.ToLower() == Collections.CompanyMoon.ToLower() && mustUpdate)
{
DefaultConstellation();
return;
}
foreach (ClassMapper item in Collections.ConstellationStuff)
{
List<string> list = item.constelMoons.ConvertAll((string x) => x.ToLower());
if (list.Contains(levelName.ToLower()))
{
Collections.CurrentConstellation = item.consName;
Collections.CurrentConstellationCM = item;
Plugin.Spam("DefaultConstellation set to " + Collections.CurrentConstellation);
AdjustToNewConstellation(levelName, Collections.CurrentConstellation);
}
}
}
internal static int GetConstPrice(ClassMapper item)
{
//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)
int constelPrice = item.constelPrice;
if (!Configuration.AddConstellationPositionData.Value)
{
return constelPrice;
}
if (item.positionalPriceMode == "None")
{
return constelPrice;
}
float num = Vector3.Distance(Collections.CurrentConstellationCM.RelativePosition, item.RelativePosition);
if (item.positionalPriceMode == "SetPriceByDistance")
{
return Configuration.CostPerDistanceUnit.Value * (int)num;
}
if (item.originalDistance == 0f)
{
item.originalDistance = 0.1f;
}
Plugin.Spam($"Getting Dynamic Price from PositionalData:\n\nPrice ({item.constelPrice}) * currentDistance ({num}) / originalDistance {item.originalDistance}");
float num2 = (float)item.constelPrice * (num / item.originalDistance);
constelPrice = ((num > 0f) ? ((int)num2) : 0);
constelPrice = Mathf.Clamp(constelPrice, 0, 99999);
Plugin.Spam($"result - {constelPrice}");
return constelPrice;
}
internal static void DefaultConstellation()
{
string text = ((!((Object)(object)LevelManager.CurrentExtendedLevel == (Object)null)) ? LevelManager.CurrentExtendedLevel.NumberlessPlanetName : ExtendedLevel.GetNumberlessPlanetName(StartOfRound.Instance.currentLevel));
if (text.ToLower() == Collections.CompanyMoon.ToLower() && (Collections.CurrentConstellation.Length < 1 || !Configuration.ReturnToLastConstellationFromCompany.Value))
{
Plugin.Log.LogInfo((object)"Currently located at the Company! Setting to default constellation!");
if (TryGetDefaultConstellation(out ClassMapper theConst) && theConst.canRouteCompany)
{
AdjustToNewConstellation(theConst.defaultMoon, theConst.consName);
Collections.CurrentConstellationCM = theConst;
}
else
{
Plugin.WARNING("Unable to load default constellation from config item. Setting to first contellation in list.");
AdjustToNewConstellation(Collections.ConstellationStuff[0].defaultMoon, Collections.ConstellationStuff[0].consName);
Collections.CurrentConstellationCM = Collections.ConstellationStuff[0];
}
}
}
internal static bool TryGetDefaultConstellation(out ClassMapper theConst)
{
if (Collections.ConstellationStuff.Count == 0)
{
Plugin.ERROR("Unable to detect ConstellationStuff listing!!");
theConst = null;
return false;
}
if (ClassMapper.TryGetConstellation(Collections.ConstellationStuff, Configuration.CompanyDefaultConstellation.Value, out theConst))
{
Plugin.Spam("Returning " + theConst.consName);
return true;
}
Plugin.Spam("Config item not matching anything, returning first constellation: " + Collections.ConstellationStuff[0].consName);
theConst = Collections.ConstellationStuff[0];
return true;
}
}
}
namespace LethalConstellations.EventStuff
{
public class NewEvents
{
public static CustomEvent RouteConstellationSuccess = new CustomEvent();
}
internal class LLLStuff
{
internal static bool usingTags;
public static void LLLSetup()
{
Collections.Start();
if (Configuration.ConstellationList.Value.Length < 1)
{
Collections.ConstellationsList = GetDefaultConsellations();
}
else
{
Collections.ConstellationsList = CommonStringStuff.GetKeywordsPerConfigItem(Configuration.ConstellationList.Value, ',');
Collections.ConstellationsList.RemoveAll((string x) => x.Length < 1);
if (Configuration.ManualSetupListing.Value.Length > 0)
{
List<string> list = Configuration.ManualSetupListing.Value.Split(new char[1] { ';' }).ToList();
foreach (string item in list)
{
List<string> list2 = item.Split(new char[1] { ':' }).ToList();
string value = "FailedToParseConsName";
for (int i = 0; i < list2.Count; i++)
{
if (!Enumerable.Contains(list2[i], ','))
{
value = list2[i];
continue;
}
List<string> list3 = list2[i].Split(new char[1] { ',' }).ToList();
for (int j = 0; j < list3.Count; j++)
{
Collections.ManualSetupList.Add(list3[j], value);
}
}
}
}
}
if (Collections.ConstellationsList.Count != Collections.ConstellationsList.Distinct<string>(StringComparer.CurrentCultureIgnoreCase).Count())
{
Plugin.WARNING($"REMOVING DUPLICATE CONSTELLATION NAMES!!\nOriginal [ {Collections.ConstellationsList.Count} ]\nDistinct [ {Collections.ConstellationsList.Distinct<string>(StringComparer.CurrentCultureIgnoreCase).Count()} ]");
}
Collections.ConstellationsList = Collections.ConstellationsList.Distinct<string>(StringComparer.CurrentCultureIgnoreCase).ToList();
Plugin.Spam("ConstellationList:");
foreach (string constellations in Collections.ConstellationsList)
{
Plugin.Spam(constellations);
}
Plugin.Spam("ManualSetupList:");
foreach (KeyValuePair<string, string> manualSetup in Collections.ManualSetupList)
{
Plugin.Spam(manualSetup.Key + " - " + manualSetup.Value);
}
List<string> keywordsPerConfigItem = CommonStringStuff.GetKeywordsPerConfigItem(Configuration.IgnoreList.Value, ',');
keywordsPerConfigItem = keywordsPerConfigItem.ConvertAll((string s) => s.ToLower());
Plugin.Spam("ignoreList created");
foreach (string constellations2 in Collections.ConstellationsList)
{
string text = CommonStringStuff.BepinFriendlyString(constellations2);
ConfigEntry<string> val = ConfigSetup.MakeString(Configuration.GeneratedConfig, Collections.ConstellationWord + " " + text, text + " menuText", "Route to System $[price] [name][~n]Default Moon:[defaultmoon] [currentweather][~n][currentdistance] [optionals]", "The text displayed for this " + Collections.ConstellationWord + "'s menu item\n[price] will display price information\n[name] will display the constellation name\n[~n] will create a new line\n[~t] will create a tab indent\n[defaultmoon] will display a constellation's default moon\n[currentweather] will display a moons current weather (retrieved from LLL)\n[currentdistance] will display the current distance value determined by positional data\n[optionals] will allow for other mods to add their own flavor text to this menu item.");
ConfigEntry<string> val2 = ConfigSetup.MakeString(Configuration.GeneratedConfig, Collections.ConstellationWord + " " + text, text + " shortcuts", "", "Specify a list of shortcuts to use for routing to the " + text + " " + Collections.ConstellationWord + ".\nEach shortcut keyword is separated by a ','");
ConfigEntry<bool> val3 = ConfigSetup.MakeBool(Configuration.GeneratedConfig, Collections.ConstellationWord + " " + text, text + " isHidden", false, "Enable this to hide this " + Collections.ConstellationWord + " from the constellation listing");
ConfigEntry<bool> val4 = ConfigSetup.MakeBool(Configuration.GeneratedConfig, Collections.ConstellationWord + " " + text, text + " canRouteCompany", true, "Enable this to allow this " + Collections.ConstellationWord + " to route to the company moon");
ConfigEntry<bool> val5 = ConfigSetup.MakeBool(Configuration.GeneratedConfig, Collections.ConstellationWord + " " + text, text + " One-Time Purchase", false, "Enable this to allow routing to this " + Collections.ConstellationWord + " for free after paying for it once");
ClassMapper classMapper = new ClassMapper(constellations2)
{
menuText = val.Value,
isHidden = val3.Value,
canRouteCompany = val4.Value,
shortcutList = CommonStringStuff.GetKeywordsPerConfigItem(val2.Value, ','),
buyOnce = val5.Value
};
if (Configuration.ConstellationSpecificInfoNodes.Value)
{
ConfigEntry<string> val6 = ConfigSetup.MakeString(Configuration.GeneratedConfig, Collections.ConstellationWord + " " + text, text + " infoText", Collections.ConstellationWord + " - " + text + "\n\n\nThis [ConstellationWord] contains moons in it. Route to it and find out which!\r\n\r\n", "The text that displays with the info command for this " + Collections.ConstellationWord + "'s shortcut keywords");
if (val6.Value.Contains("[ConstellationWord]"))
{
val6.Value = val6.Value.Replace("[ConstellationWord]", Collections.ConstellationWord);
}
classMapper.infoText = val6.Value;
}
classMapper.constelMoons = new List<string>();
classMapper.stayHiddenMoons = new List<string>();
Collections.ConstellationStuff.Add(classMapper);
}
Plugin.Spam("about to sort through extendedlevel");
GetLLLStuffForConfig(PatchedContent.ExtendedLevels, keywordsPerConfigItem);
SetDefaultMoon(Collections.ConstellationStuff);
Plugin.Spam($"ConfigCount: {Configuration.GeneratedConfig.Count}");
Configuration.GeneratedConfig.Save();
ConfigSetup.RemoveOrphanedEntries(Configuration.GeneratedConfig);
LethalConfigStuff();
}
internal static void LethalConfigStuff()
{
if (Plugin.instance.LethalConfig)
{
LConfig.QueueConfig(Configuration.GeneratedConfig);
}
}
internal static List<string> GetDefaultConsellations()
{
List<string> result = new List<string>(3) { "Alpha", "Bravo", "Charlie" };
List<string> list = new List<string>(3) { "safe", "corruption detected", "???" };
List<string> list2 = new List<string>();
if (PatchedContent.ExtendedLevels.Count < 1)
{
return result;
}
foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels)
{
Plugin.Spam("---------------- Checking " + extendedLevel.NumberlessPlanetName + " tags ----------------");
string firstUniqueTag = GetFirstUniqueTag(extendedLevel);
if (!list2.Contains(firstUniqueTag))
{
list2.Add(firstUniqueTag);
}
Plugin.Spam("---------------- End of checks ----------------");
}
usingTags = true;
return list2;
}
internal static string GetDefaultCName(List<string> constList, string levelName = "")
{
if (constList.Count < 1)
{
return "default";
}
if (Collections.ManualSetupList.Count > 0 && levelName.Length > 0)
{
Plugin.Spam("Attempting to get MANUAL constellation setup for [ " + levelName + " ]");
if (Collections.ManualSetupList.TryGetValue(levelName.ToLower(), out string value))
{
return value;
}
return IndexRandom(constList);
}
return IndexRandom(constList);
}
private static string IndexRandom(List<string> listing)
{
Plugin.Spam("Setting IndexRandom string from given listing!");
int index = Collections.Rand.Next(0, listing.Count);
return listing[index];
}
private static bool DoesLevelHaveTag(ExtendedLevel level, string query)
{
foreach (ContentTag contentTag in ((ExtendedContent)level).ContentTags)
{
if (contentTag.contentTagName.ToLower() == query.ToLower())
{
return true;
}
}
return false;
}
private static string GetFirstUniqueTag(ExtendedLevel level)
{
List<string> list = new List<string>(5) { "free", "paid", "custom", "vanilla", "company" };
foreach (ContentTag contentTag in ((ExtendedContent)level).ContentTags)
{
if (!list.Contains(contentTag.contentTagName.ToLower()) && contentTag.contentTagName.Length >= 3 && !Enumerable.Contains(contentTag.contentTagName, ' '))
{
return contentTag.contentTagName;
}
}
return "Unknown";
}
internal static string GetTagInfo(ExtendedLevel level, List<string> constList)
{
string defaultCName = GetDefaultCName(constList, level.NumberlessPlanetName);
foreach (string @const in constList)
{
if (DoesLevelHaveTag(level, @const))
{
return @const;
}
}
if (constList.Contains("Unknown Tier"))
{
return "Unknown Tier";
}
return defaultCName;
}
internal static void SetDefaultMoon(List<ClassMapper> allConstell)
{
Plugin.Spam("Getting Default Moons/Prices");
foreach (ClassMapper item in allConstell)
{
Plugin.Spam("Setting defaults for " + item.consName);
string randomDefault = GetRandomDefault(item);
int moonPrice = GetMoonPrice(randomDefault);
Plugin.Spam($"constelMoons - {item.constelMoons.Count}");
ConfigEntry<string> val = ConfigSetup.MakeString(Configuration.GeneratedConfig, Collections.ConstellationWord + " " + item.consName, item.consName + " defaultMoon", randomDefault, "Default moon to route to when selecting this " + Collections.ConstellationWord);
item.defaultMoon = val.Value;
Plugin.Spam("Default Moon for " + item.consName + " set to " + val.Value);
item.defaultMoonLevel = MoonStuff.GetExtendedLevel(item.defaultMoon);
if ((Object)(object)item.defaultMoonLevel == (Object)null)
{
Plugin.WARNING("defaultMoonLevel was NULL due to invalid config item.\n\nSetting default moon to new random and updating config item!");
string levelName = (val.Value = (item.defaultMoon = GetRandomDefault(item)));
item.defaultMoonLevel = MoonStuff.GetExtendedLevel(levelName);
}
ConfigEntry<int> val2 = ConfigSetup.MakeClampedInt(Configuration.GeneratedConfig, Collections.ConstellationWord + " " + item.consName, item.consName + " constellationPrice", moonPrice, "Set the price to route to this " + Collections.ConstellationWord + " and its defaultMoon", 0, 9999);
item.constelPrice = val2.Value;
if (Configuration.AddConstellationPositionData.Value)
{
ConfigEntry<string> val3 = ConfigSetup.MakeClampedString(Configuration.GeneratedConfig, Collections.ConstellationWord + " " + item.consName, item.consName + " PostionalPricingMode", "SetPriceByDistance", "Determine how pricing for this constellation will be affected by positional data.\nUseOriginalPrice will use constellationPrice configuration item as starting route cost and the CostPerDistanceUnit value will not be used.\nSetPriceByDistance will ignore constellationPrice and set constellation's price to a new price value based on it's starting position (relative to the starter constellation).\nNone will keep from adjusting constellations based on distance when AddConstellationPositionData is enabled", new AcceptableValueList<string>(new string[3] { "UseOriginalPrice", "SetPriceByDistance", "None" }));
item.positionalPriceMode = val3.Value;
}
ConfigEntry<string> val4 = ConfigSetup.MakeString(Configuration.GeneratedConfig, Collections.ConstellationWord + " " + item.consName, item.consName + " constellationPosition", $"{Collections.Rand.Next(0, 200)}, {Collections.Rand.Next(0, 200)}, {Collections.Rand.Next(0, 200)}", "Set the relative position of " + item.consName + " in space\n0 will be considered the center of the universe, will affect route price");
item.SetPosition(val4.Value);
}
}
internal static void GetLLLStuffForConfig(List<ExtendedLevel> extendedLevels, List<string> ignoreList)
{
foreach (ExtendedLevel extendedLevel in extendedLevels)
{
if ((Object)(object)extendedLevel == (Object)null)
{
continue;
}
string text = CommonStringStuff.BepinFriendlyString(extendedLevel.NumberlessPlanetName);
Plugin.Spam("moonName is " + text);
if (text.Length < 1 || ignoreList.Contains(text.ToLower()) || text.ToLower() == Collections.CompanyMoon.ToLower())
{
continue;
}
string defaultCName = GetDefaultCName(Collections.ConstellationsList, text);
Plugin.Spam(text + " default constellation set to - " + defaultCName);
ConfigEntry<int> val = ConfigSetup.MakeClampedInt(Configuration.GeneratedConfig, "Moons", text + " Price", extendedLevel.RoutePrice, "Set a custom route price for this moon (should autopopulate with the correct default price)", 0, 99999);
ConfigEntry<bool> val2 = ConfigSetup.MakeBool(Configuration.GeneratedConfig, "Moons", text + " Stay Hidden", extendedLevel.IsRouteHidden, "Set this to true to keep " + text + " hidden even when you're in it's " + Collections.ConstellationWord);
if (usingTags)
{
string tagInfo = GetTagInfo(extendedLevel, Collections.ConstellationsList);
ConfigEntry<string> val3 = ConfigSetup.MakeClampedString(Configuration.GeneratedConfig, "Moons", text + " " + Collections.ConstellationWord, tagInfo, "Specify which " + Collections.ConstellationWord + " " + text + " belongs to.\nClamped to what is set in [ConstellationList] (default listing)", new AcceptableValueList<string>(Collections.ConstellationsList.ToArray()));
AddToConstelMoons(text, val3.Value, val2.Value);
}
else
{
ConfigEntry<string> levelToConstellation = ConfigSetup.MakeString(Configuration.GeneratedConfig, "Moons", text + " " + Collections.ConstellationWord, defaultCName, "Specify which " + Collections.ConstellationWord + " " + text + " belongs to.\nShould match an item from [ConstellationList]\nIf adding to multiple " + Collections.ConstellationsWord + ", separate each " + Collections.ConstellationWord + " by a comma.\nWill be autoset to a random " + Collections.ConstellationWord + " if not matching one.");
if (levelToConstellation.Value.Contains(","))
{
List<string> keywordsPerConfigItem = CommonStringStuff.GetKeywordsPerConfigItem(levelToConstellation.Value, ',');
foreach (string item in keywordsPerConfigItem)
{
AddToConstelMoons(text, item, val2.Value);
}
}
else if (Collections.ConstellationsList.Any((string c) => c.ToLower() == levelToConstellation.Value.ToLower()))
{
AddToConstelMoons(text, levelToConstellation.Value, val2.Value);
}
else
{
int index = Collections.Rand.Next(0, Collections.ConstellationsList.Count);
levelToConstellation.Value = Collections.ConstellationsList[index];
AddToConstelMoons(text, levelToConstellation.Value, val2.Value);
}
}
Collections.MoonPrices.Add(extendedLevel, val.Value);
}
}
internal static void AddToConstelMoons(string newMoon, string cName, bool stayHidden)
{
if (Collections.ConstellationStuff.Count < 0)
{
return;
}
foreach (ClassMapper item in Collections.ConstellationStuff)
{
if (item.consName == cName && !item.constelMoons.Contains(newMoon))
{
item.constelMoons.Add(newMoon);
if (stayHidden)
{
item.stayHiddenMoons.Add(newMoon);
}
Plugin.Spam($"adding {newMoon} to {cName} / stayHidden: {stayHidden}");
}
}
}
internal static int GetMoonPrice(string moonName)
{
if (Collections.MoonPrices.Count < 1)
{
return 0;
}
foreach (KeyValuePair<ExtendedLevel, int> moonPrice in Collections.MoonPrices)
{
if (moonPrice.Key.NumberlessPlanetName.ToLower() == moonName.ToLower())
{
return moonPrice.Value;
}
}
return 0;
}
internal static string GetRandomDefault(ClassMapper constellation)
{
if (constellation.constelMoons.Count == 0)
{
return "";
}
Random random = new Random();
int index = random.Next(0, constellation.constelMoons.Count);
return constellation.constelMoons[index];
}
internal static string BepinFriendlyString(string input)
{
char[] source = new char[7] { '\'', '\n', '\t', '\\', '"', '[', ']' };
string text = "";
for (int i = 0; i < input.Length; i++)
{
char value = input[i];
if (!source.Contains(value))
{
text += value;
}
}
return text;
}
}
public class Subscribers
{
[CompilerGenerated]
private static class <>O
{
public static ParameterEvent<Terminal> <0>__OnTerminalAwake;
public static Event <1>__OnTerminalQuit;
public static ParameterEvent<TerminalNode> <2>__OnLoadNode;
public static Event <3>__OnLevelChange;
public static Event <4>__OnStartup;
public static Event <5>__NewLobbyStuff;
public static Action <6>__LLLSetup;
public static Action <7>__LoadCodesButton;
public static Action <8>__GenerateWebConfig;
}
public static void Subscribe()
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Expected O, but got Unknown
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Expected O, but got Unknown
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Expected O, but got Unknown
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Expected O, but got Unknown
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: 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);
EventManager.TerminalLoadNewNode.AddListener((ParameterEvent<TerminalNode>)OnLoadNode);
CustomEvent startOfRoundChangeLevel = EventManager.StartOfRoundChangeLevel;
object obj2 = <>O.<3>__OnLevelChange;
if (obj2 == null)
{
Event val2 = OnLevelChange;
<>O.<3>__OnLevelChange = val2;
obj2 = (object)val2;
}
startOfRoundChangeLevel.AddListener((Event)obj2);
CustomEvent gameNetworkManagerStart = EventManager.GameNetworkManagerStart;
object obj3 = <>O.<4>__OnStartup;
if (obj3 == null)
{
Event val3 = OnStartup;
<>O.<4>__OnStartup = val3;
obj3 = (object)val3;
}
gameNetworkManagerStart.AddListener((Event)obj3);
CustomEvent startOfRoundStart = EventManager.StartOfRoundStart;
object obj4 = <>O.<5>__NewLobbyStuff;
if (obj4 == null)
{
Event val4 = NewLobbyStuff;
<>O.<5>__NewLobbyStuff = val4;
obj4 = (object)val4;
}
startOfRoundStart.AddListener((Event)obj4);
CustomEvent shipReset = EventManager.ShipReset;
object obj5 = <>O.<5>__NewLobbyStuff;
if (obj5 == null)
{
Event val5 = NewLobbyStuff;
<>O.<5>__NewLobbyStuff = val5;
obj5 = (object)val5;
}
shipReset.AddListener((Event)obj5);
Plugin.onSetupComplete += LLLStuff.LLLSetup;
}
public static void OnTerminalAwake(Terminal instance)
{
Plugin.instance.Terminal = instance;
Plugin.MoreLogs("Setting Plugin.instance.Terminal");
}
public static void OnTerminalQuit()
{
if (MenuStuff.ConstellationsMenu.inMenu)
{
MenuStuff.ExitMenu(enableInput: false);
}
}
public static void NewLobbyStuff()
{
MenuStuff.PreInit();
SaveManager.InitSave();
if (GameNetworkManager.Instance.isHostingGame)
{
SaveManager.InitHostStuff();
}
}
public static void OnLoadNode(TerminalNode node)
{
if (LevelStuff.cancelConfirmation)
{
LevelStuff.cancelConfirmation = false;
Plugin.Spam("cancelConfirmation is true and node is in confirmation, routing to dummy node");
Plugin.instance.dummyNode.displayText = node.displayText;
Plugin.instance.Terminal.LoadNewNode(Plugin.instance.dummyNode);
}
}
public static void OnLevelChange()
{
Plugin.Spam("setting currentLevel");
Plugin.Spam($"{LevelManager.CurrentExtendedLevel.NumberlessPlanetName}, {LevelManager.CurrentExtendedLevel.IsRouteLocked}, {LevelManager.CurrentExtendedLevel.IsRouteHidden}, {LevelManager.CurrentExtendedLevel.LockedRouteNodeText}");
LevelStuff.GetCurrentConstellation(LevelManager.CurrentExtendedLevel.NumberlessPlanetName, mustUpdate: false);
}
public static void OnStartup()
{
if (Plugin.instance.LobbyCompat)
{
Plugin.Log.LogInfo((object)"BMX_LobbyCompat detected!");
BMX_LobbyCompat.SetBMXCompat(false);
}
if (StartGame.SoftCompatibility("com.xmods.lethalmoonunlocks", ref Plugin.instance.LethalMoonUnlocks))
{
Plugin.Log.LogInfo((object)"LethalMoonUnlocks Detected! Disabling moon unlock/hiding from this mod.");
}
if (StartGame.SoftCompatibility("LethalNetworkAPI", ref Plugin.instance.LethalNetworkAPI))
{
Plugin.Log.LogInfo((object)"NetworkApi detected, networking unlocked!");
}
if (Plugin.instance.LethalConfig)
{
Plugin.Log.LogInfo((object)"LethalConfig Detected!");
LethalConfigSoft.AddButton("Tools", "LoadCodes", "Click this to refresh all mod configs from code values assigned to [GeneratedConfigCode] and [MainConfigCode]", "Load Config Codes", (Action)LConfig.LoadCodesButton);
LethalConfigSoft.AddButton("Tools", "GenerateWebConfigs", "Click this to generate web pages for both config files.\nThese web pages can be used to generate config codes", "Generate WebConfigs", (Action)LConfig.GenerateWebConfig);
Plugin.Spam("Buttons added!");
}
}
public static void OnClientConnected()
{
if (GameNetworkManager.Instance.isHostingGame && Plugin.instance.LethalNetworkAPI && Collections.ConstellationsOTP != null && Collections.ConstellationsOTP.Count != 0)
{
NetworkThings.SyncUnlockSet(Collections.ConstellationsOTP);
}
}
}
}
namespace LethalConstellations.Compat
{
internal class LConfig
{
internal static void QueueConfig(ConfigFile configName)
{
if (Plugin.instance.LethalConfig && LethalConfigSoft.IsLethalConfigUpdated())
{
Plugin.Spam("Queuing file " + configName.ConfigFilePath);
LethalConfigManager.QueueCustomConfigFileForLateAutoGeneration(configName);
}
}
internal static void LoadCodesButton()
{
if (Plugin.instance.LethalConfig)
{
if (Configuration.GeneratedConfigCode.Value.Length > 1)
{
WebHelper.ReadCompressedConfig(ref Configuration.GeneratedConfigCode, Configuration.GeneratedConfig);
}
if (Configuration.MainConfigCode.Value.Length > 1)
{
WebHelper.ReadCompressedConfig(ref Configuration.MainConfigCode, ((BaseUnityPlugin)Plugin.instance).Config);
}
}
}
internal static void GenerateWebConfig()
{
if (Plugin.instance.LethalConfig)
{
WebHelper.WebConfig(Configuration.GeneratedConfig);
WebHelper.WebConfig(((BaseUnityPlugin)Plugin.instance).Config);
}
}
}
internal class NetworkThings
{
internal static void InitNetworkThings()
{
if (Plugin.instance.LethalNetworkAPI)
{
LNetworkEvent val = LNetworkEvent.Connect("consUnlockedSyncREQ", (Action<ulong>)HostClientSync, (Action)null, (Action<ulong>)null);
LNetworkMessage<List<string>> val2 = LNetworkMessage<List<string>>.Connect("constellationsUnlocked", (Action<List<string>, ulong>)SyncUnlockHost, (Action<List<string>>)SyncUnlockClient, (Action<List<string>, ulong>)null);
LNetworkMessage<string> val3 = LNetworkMessage<string>.Connect("currentConst", (Action<string, ulong>)SyncCurrentHost, (Action<string>)SyncCurrentClient, (Action<string, ulong>)null);
}
}
internal static void SyncUnlockSet(List<string> unlockedConst)
{
if (Plugin.instance.LethalNetworkAPI)
{
if (unlockedConst.Count == 0)
{
Plugin.WARNING("Attempting to sync blank ConstellationsOTP!!!");
}
LNetworkMessage<List<string>> val = LNetworkMessage<List<string>>.Connect("constellationsUnlocked", (Action<List<string>, ulong>)SyncUnlockHost, (Action<List<string>>)SyncUnlockClient, (Action<List<string>, ulong>)null);
if (LNetworkUtils.IsHostOrServer)
{
val.SendClients(unlockedConst, LNetworkUtils.AllConnectedClients);
}
else
{
val.SendServer(unlockedConst);
}
}
}
internal static void SyncCurrentSet(string currentConstellation)
{
if (Plugin.instance.LethalNetworkAPI)
{
if (currentConstellation.Length == 0)
{
Plugin.WARNING("Attempting to sync blank currentConstellation!!!");
}
LNetworkMessage<string> val = LNetworkMessage<string>.Connect("currentConst", (Action<string, ulong>)SyncCurrentHost, (Action<string>)SyncCurrentClient, (Action<string, ulong>)null);
if (LNetworkUtils.IsHostOrServer)
{
val.SendClients(currentConstellation, LNetworkUtils.AllConnectedClients);
}
else
{
val.SendServer(currentConstellation);
}
}
}
internal static void RequestSyncFromHost()
{
if (Plugin.instance.LethalNetworkAPI)
{
Plugin.Spam("Requesting sync from host");
LNetworkMessage<List<string>> val = LNetworkMessage<List<string>>.Connect("constellationsUnlocked", (Action<List<string>, ulong>)null, (Action<List<string>>)SyncUnlockClient, (Action<List<string>, ulong>)null);
LNetworkEvent val2 = LNetworkEvent.Connect("consUnlockedSyncREQ", (Action<ulong>)HostClientSync, (Action)null, (Action<ulong>)null);
val2.InvokeServer();
}
}
internal static void HostClientSync(ulong clientRequesting)
{
if (Plugin.instance.LethalNetworkAPI)
{
Plugin.Spam($"HostClientSync, requested by {clientRequesting}");
if (LNetworkUtils.IsHostOrServer)
{
Plugin.Spam("Host sending collection");
SyncUnlockSet(Collections.ConstellationsOTP);
SyncCurrentSet(Collections.CurrentConstellation);
}
}
}
internal static void SyncUnlockHost(List<string> newValue, ulong clientSending)
{
if (Plugin.instance.LethalNetworkAPI && Collections.ConstellationsOTP != newValue)
{
Plugin.Spam("SYNCING NEW UNLOCK LIST - HOST");
Collections.ConstellationsOTP = newValue;
ClassMapper.UpdateConstellationUnlocks();
SyncUnlockSet(Collections.ConstellationsOTP);
SaveManager.SaveUnlocks(Collections.ConstellationsOTP);
}
}
internal static void SyncUnlockClient(List<string> newValue)
{
if (Plugin.instance.LethalNetworkAPI && !LNetworkUtils.IsHostOrServer && Collections.ConstellationsOTP != newValue)
{
Plugin.Spam("SYNCING NEW UNLOCK LIST");
Collections.ConstellationsOTP = newValue;
ClassMapper.UpdateConstellationUnlocks();
}
}
internal static void SyncCurrentHost(string newValue, ulong clientSending)
{
if (Plugin.instance.LethalNetworkAPI && !(Collections.CurrentConstellation == newValue))
{
Plugin.Spam("SYNCING NEW UNLOCK LIST - HOST");
Collections.CurrentConstellation = newValue;
ClassMapper.UpdateConstellationUnlocks();
SaveManager.SaveCurrentConstellation(Collections.CurrentConstellation);
}
}
internal static void SyncCurrentClient(string newValue)
{
if (Plugin.instance.LethalNetworkAPI && !LNetworkUtils.IsHostOrServer && !(Collections.CurrentConstellation == newValue))
{
Plugin.Spam("SYNCING NEW UNLOCK LIST");
Collections.CurrentConstellation = newValue;
}
}
}
}