Decompiled source of RouteRandomRedexed v1.4.0

Index154.RouteRandomRedexed.dll

Decompiled 5 hours ago
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 BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LethalConstellations.PluginCore;
using Microsoft.CodeAnalysis;
using RouteRandomRedexed.Helpers;
using TMPro;
using UnityEngine;
using UnityEngine.Video;

[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: AssemblyCompany("Index154.RouteRandomRedexed")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.4.0.0")]
[assembly: AssemblyInformationalVersion("1.4.0+a3318dc14122b5adda861ec6723ee50d28a7dd7b")]
[assembly: AssemblyProduct("RouteRandomRedexed")]
[assembly: AssemblyTitle("Index154.RouteRandomRedexed")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.4.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace RouteRandomRedexed
{
	internal class ConstellationsCompat
	{
		internal static bool IsLevelInConstellation(SelectableLevel level)
		{
			return ClassMapper.IsLevelInConstellation(level, "");
		}
	}
	[BepInPlugin("Index154.RouteRandomRedexed", "RouteRandomRedexed", "1.4.0")]
	public class RouteRandomRedexed : BaseUnityPlugin
	{
		public static bool constellationsLoaded;

		public static ConfigEntry<bool> ConfigAllowMildWeather;

		public static ConfigEntry<bool> ConfigAllowDustCloudsWeather;

		public static ConfigEntry<bool> ConfigAllowRainyWeather;

		public static ConfigEntry<bool> ConfigAllowStormyWeather;

		public static ConfigEntry<bool> ConfigAllowFoggyWeather;

		public static ConfigEntry<bool> ConfigAllowFloodedWeather;

		public static ConfigEntry<bool> ConfigAllowEclipsedWeather;

		public static ConfigEntry<bool> ConfigAllowCostlyPlanets;

		public static ConfigEntry<bool> ConfigRemoveCostOfCostlyPlanets;

		public static ConfigEntry<bool> ConfigSkipConfirmation;

		public static ConfigEntry<bool> ConfigDifferentPlanetEachTime;

		public static ConfigEntry<bool> ConfigHidePlanet;

		public static ConfigEntry<bool> ConfigConstellationSupport;

		public static RouteRandomRedexed Instance { get; private set; }

		internal static ManualLogSource Log { get; private set; }

		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			LoadConfigs();
			if (Harmony == null)
			{
				Harmony = new Harmony("Index154.RouteRandomRedexed");
			}
			Harmony.PatchAll();
			Log.LogInfo((object)"Index154.RouteRandomRedexed has loaded!");
		}

		internal static void Unpatch()
		{
			Log.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Log.LogDebug((object)"Finished unpatching!");
		}

		private void LoadConfigs()
		{
			ConfigAllowMildWeather = ((BaseUnityPlugin)this).Config.Bind<bool>("Allowed Weathers", "AllowMildWeather", true, "Whether or not to allow the 'Mild' weather to be chosen by the 'route randomfilterweather' command");
			ConfigAllowDustCloudsWeather = ((BaseUnityPlugin)this).Config.Bind<bool>("Allowed Weathers", "AllowDustCloudsWeather", false, "Whether or not to allow the 'Dust Clouds' weather to be chosen by the 'route randomfilterweather' command");
			ConfigAllowRainyWeather = ((BaseUnityPlugin)this).Config.Bind<bool>("Allowed Weathers", "AllowRainyWeather", false, "Whether or not to allow the 'Rainy' weather to be chosen by the 'route randomfilterweather' command");
			ConfigAllowStormyWeather = ((BaseUnityPlugin)this).Config.Bind<bool>("Allowed Weathers", "AllowStormyWeather", false, "Whether or not to allow the 'Stormy' weather to be chosen by the 'route randomfilterweather' command");
			ConfigAllowFoggyWeather = ((BaseUnityPlugin)this).Config.Bind<bool>("Allowed Weathers", "AllowFoggyWeather", false, "Whether or not to allow the 'Foggy' weather to be chosen by the 'route randomfilterweather' command");
			ConfigAllowFloodedWeather = ((BaseUnityPlugin)this).Config.Bind<bool>("Allowed Weathers", "AllowFloodedWeather", false, "Whether or not to allow the 'Flooded' weather to be chosen by the 'route randomfilterweather' command");
			ConfigAllowEclipsedWeather = ((BaseUnityPlugin)this).Config.Bind<bool>("Allowed Weathers", "AllowEclipsedWeather", false, "Whether or not to allow the 'Eclipsed' weather to be chosen by the 'route randomfilterweather' command");
			ConfigAllowCostlyPlanets = ((BaseUnityPlugin)this).Config.Bind<bool>("Costly Planets", "AllowCostlyPlanets", false, "Whether or not to allow costly planets (85-Rend, 7-Dine, 8-Titan). NOTE: You will still be prompted to pay the fee to fly there, enable the MakeCostlyPlanetsFree option to avoid that");
			ConfigRemoveCostOfCostlyPlanets = ((BaseUnityPlugin)this).Config.Bind<bool>("Costly Planets", "RemoveCostOfCostlyPlanets", false, "Whether or not to remove the cost of costly planets when they're chosen randomly and allows them to be chosen even when AllowCostlyPlanets is false");
			ConfigSkipConfirmation = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "SkipConfirmation", false, "Whether or not to skip the confirmation screen when using 'route random' or 'route randomwithweather' commands");
			ConfigDifferentPlanetEachTime = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DifferentPlanetEachTime", false, "Prevents 'route random' and 'route randomwithweather' commands from choosing the same planet you're on");
			ConfigHidePlanet = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "HidePlanet", false, "Hides the planet you get randomly routed to, both in the terminal response and at the helm. NOTE: This will ALWAYS hide the orbited planet (even when selected manually) and will skip the confirmation screen");
			ConfigConstellationSupport = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "LethalConstellationsSupport", true, "Turns on compatibility logic for the mod LethalConstellations. Route random will only select moons from the current constellation if enabled");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Index154.RouteRandomRedexed";

		public const string PLUGIN_NAME = "RouteRandomRedexed";

		public const string PLUGIN_VERSION = "1.4.0";
	}
}
namespace RouteRandomRedexed.Patches
{
	[HarmonyPatch(typeof(StartOfRound))]
	public class StartOfRoundPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		private static void ConstellationsCompat()
		{
			if (Chainloader.PluginInfos.ContainsKey("com.github.darmuh.LethalConstellations"))
			{
				RouteRandomRedexed.constellationsLoaded = true;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("SetMapScreenInfoToCurrentLevel")]
		public static void HideMapScreenInfo(StartOfRound __instance, VideoPlayer ___screenLevelVideoReel, TextMeshProUGUI ___screenLevelDescription)
		{
			if (!(((Object)__instance.currentLevel).name == "CompanyBuildingLevel") && RouteRandomRedexed.ConfigHidePlanet.Value)
			{
				((TMP_Text)___screenLevelDescription).text = "Orbiting: [REDACTED]\nPopulation: Unknown\nConditions: Unknown\nFauna: Unknown\nWeather: Unknown";
				((Behaviour)___screenLevelVideoReel).enabled = false;
				___screenLevelVideoReel.clip = null;
				((Component)___screenLevelVideoReel).gameObject.SetActive(false);
				___screenLevelVideoReel.Stop();
			}
		}
	}
	[HarmonyPatch(typeof(Terminal))]
	public class TerminalPatch
	{
		private static readonly TerminalNode noSuitablePlanetsNode = new TerminalNode
		{
			name = "NoSuitablePlanets",
			displayText = "\nNo suitable planets found.\nConsider route random.\n\n\n",
			clearPreviousText = true
		};

		private static readonly TerminalNode hidePlanetHackNode = new TerminalNode
		{
			name = "HidePlanetHack",
			displayText = "\nRouting autopilot to [REDACTED].\nYour new balance is [playerCredits].\n\nPlease enjoy your flight.\n\n\n",
			clearPreviousText = true
		};

		private static TerminalKeyword routeKeyword;

		private static TerminalKeyword randomKeyword;

		private static TerminalKeyword randomFilterWeatherKeyword;

		private static CompatibleNoun routeRandomCompatibleNoun;

		private static CompatibleNoun routeRandomFilterWeatherCompatibleNoun;

		private static readonly Random rand = new Random();

		[HarmonyPostfix]
		[HarmonyPatch("Awake")]
		public static void AddNewTerminalWords(Terminal __instance)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			//IL_00be: Expected O, but got Unknown
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Expected O, but got Unknown
			//IL_00fc: Expected O, but got Unknown
			try
			{
				routeKeyword = __instance.GetKeyword("Route");
				randomKeyword = new TerminalKeyword
				{
					word = "random",
					name = "Random",
					defaultVerb = routeKeyword,
					compatibleNouns = Array.Empty<CompatibleNoun>()
				};
				randomFilterWeatherKeyword = new TerminalKeyword
				{
					word = "randomfilterweather",
					name = "RandomFilterWeather",
					defaultVerb = routeKeyword,
					compatibleNouns = Array.Empty<CompatibleNoun>()
				};
				routeRandomCompatibleNoun = new CompatibleNoun
				{
					noun = randomKeyword,
					result = new TerminalNode
					{
						name = "routeRandom",
						buyRerouteToMoon = -1,
						terminalOptions = Array.Empty<CompatibleNoun>()
					}
				};
				routeRandomFilterWeatherCompatibleNoun = new CompatibleNoun
				{
					noun = randomFilterWeatherKeyword,
					result = new TerminalNode
					{
						name = "routeRandomFilterWeather",
						buyRerouteToMoon = -1,
						terminalOptions = Array.Empty<CompatibleNoun>()
					}
				};
				TerminalKeyword keyword = __instance.GetKeyword("Moons");
				TerminalNode specialKeywordResult = keyword.specialKeywordResult;
				specialKeywordResult.displayText += "* Random   //   Routes you to a random moon, regardless of weather conditions\n* RandomFilterWeather   //   Routes you to a random moon, filtering out disallowed weather conditions\n\n";
				__instance.AddKeywords(randomKeyword, randomFilterWeatherKeyword);
				__instance.AddCompatibleNounsToKeyword("Route", routeRandomCompatibleNoun, routeRandomFilterWeatherCompatibleNoun);
			}
			catch (Exception ex)
			{
				RouteRandomRedexed.Log.LogError((object)"Failed to add Terminal keywords and compatible nouns!");
				RouteRandomRedexed.Log.LogError((object)ex);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("ParsePlayerSentence")]
		public static TerminalNode RouteToRandomPlanet(TerminalNode __result, Terminal __instance)
		{
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			if (__result == null || __instance == null)
			{
				RouteRandomRedexed.Log.LogInfo((object)$"Terminal node was null? ({__result == null})");
				RouteRandomRedexed.Log.LogInfo((object)$"Terminal was null? ({__instance == null})");
				return __result;
			}
			bool flag = ((Object)__result).name == "routeRandom";
			bool flag2 = ((Object)__result).name == "routeRandomFilterWeather";
			if (!flag && !flag2)
			{
				RouteRandomRedexed.Log.LogInfo((object)("Didn't choose random or randomfilterweather (chose " + ((Object)__result).name + ")"));
				return __result;
			}
			List<CompatibleNoun> list = routeKeyword.compatibleNouns.Where((CompatibleNoun noun) => noun.ResultIsRealMoon() && noun.ResultIsAffordable()).Distinct(new CompatibleNounComparer()).ToList();
			RouteRandomRedexed.Log.LogInfo((object)$"Moons before filtering: {list.Count}");
			if (flag2)
			{
				foreach (CompatibleNoun item in list.ToList())
				{
					TerminalNode nodeAfterConfirmation = item.result.GetNodeAfterConfirmation();
					SelectableLevel val = StartOfRound.Instance.levels[nodeAfterConfirmation.buyRerouteToMoon];
					if (!WeatherIsAllowed(val.currentWeather))
					{
						list.Remove(item);
					}
				}
				RouteRandomRedexed.Log.LogInfo((object)$"Moons after filtering weather: {list.Count}");
			}
			if (RouteRandomRedexed.constellationsLoaded && RouteRandomRedexed.ConfigConstellationSupport.Value)
			{
				foreach (CompatibleNoun item2 in list.ToList())
				{
					TerminalNode nodeAfterConfirmation2 = item2.result.GetNodeAfterConfirmation();
					SelectableLevel level = StartOfRound.Instance.levels[nodeAfterConfirmation2.buyRerouteToMoon];
					if (!ConstellationsCompat.IsLevelInConstellation(level))
					{
						list.Remove(item2);
					}
				}
				RouteRandomRedexed.Log.LogInfo((object)$"Moons after filtering constellation: {list.Count}");
			}
			if (RouteRandomRedexed.ConfigDifferentPlanetEachTime.Value)
			{
				list.RemoveAll((CompatibleNoun rpn) => rpn.result.GetNodeAfterConfirmation().NodeRoutesToCurrentOrbitedMoon());
				RouteRandomRedexed.Log.LogInfo((object)$"Moons after filtering orbited moon: {list.Count}");
			}
			if (list.Count <= 0)
			{
				RouteRandomRedexed.Log.LogInfo((object)"No suitable moons found D:");
				return noSuitablePlanetsNode;
			}
			TerminalNode val2 = rand.NextFromCollection(list).result;
			RouteRandomRedexed.Log.LogInfo((object)("Chosen moon: " + ((Object)val2).name));
			if (RouteRandomRedexed.ConfigRemoveCostOfCostlyPlanets.Value)
			{
				if (TerminalHelper.TryMakeRouteMoonNodeFree(val2, out TerminalNode freeMoonNode))
				{
					val2 = freeMoonNode;
				}
				RouteRandomRedexed.Log.LogInfo((object)"Made moon free!");
			}
			if (RouteRandomRedexed.ConfigHidePlanet.Value)
			{
				TerminalNode nodeAfterConfirmation3 = val2.GetNodeAfterConfirmation();
				hidePlanetHackNode.buyRerouteToMoon = nodeAfterConfirmation3.buyRerouteToMoon;
				hidePlanetHackNode.itemCost = ((!RouteRandomRedexed.ConfigRemoveCostOfCostlyPlanets.Value) ? nodeAfterConfirmation3.itemCost : 0);
				RouteRandomRedexed.Log.LogInfo((object)"Hidden moon!");
				return hidePlanetHackNode;
			}
			return (TerminalNode)(RouteRandomRedexed.ConfigSkipConfirmation.Value ? ((object)val2.GetNodeAfterConfirmation()) : ((object)val2));
		}

		private static bool WeatherIsAllowed(LevelWeatherType weatherType)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected I4, but got Unknown
			if (1 == 0)
			{
			}
			bool result = (weatherType - -1) switch
			{
				0 => RouteRandomRedexed.ConfigAllowMildWeather.Value, 
				1 => RouteRandomRedexed.ConfigAllowDustCloudsWeather.Value, 
				2 => RouteRandomRedexed.ConfigAllowRainyWeather.Value, 
				3 => RouteRandomRedexed.ConfigAllowStormyWeather.Value, 
				4 => RouteRandomRedexed.ConfigAllowFoggyWeather.Value, 
				5 => RouteRandomRedexed.ConfigAllowFloodedWeather.Value, 
				6 => RouteRandomRedexed.ConfigAllowEclipsedWeather.Value, 
				_ => false, 
			};
			if (1 == 0)
			{
			}
			return result;
		}
	}
	internal class CompatibleNounComparer : EqualityComparer<CompatibleNoun>
	{
		public override bool Equals(CompatibleNoun x, CompatibleNoun y)
		{
			return x != null && ((Object)x.result).name.Equals((y != null) ? ((Object)y.result).name : null, StringComparison.InvariantCultureIgnoreCase);
		}

		public override int GetHashCode(CompatibleNoun obj)
		{
			return ((object)obj.result).GetHashCode();
		}
	}
}
namespace RouteRandomRedexed.Helpers
{
	public static class RandomHelper
	{
		public static TSource NextFromCollection<TSource>(this Random rand, List<TSource> collection)
		{
			int index = rand.Next(collection.Count);
			return collection[index];
		}
	}
	public static class TerminalHelper
	{
		public static TerminalKeyword GetKeyword(this Terminal terminal, string keywordName)
		{
			string keywordName2 = keywordName;
			return terminal.terminalNodes.allKeywords.First((TerminalKeyword kw) => ((Object)kw).name == keywordName2);
		}

		public static TerminalNode GetNodeAfterConfirmation(this TerminalNode node)
		{
			return node.terminalOptions.First((CompatibleNoun cn) => ((Object)cn.noun).name == "Confirm").result;
		}

		public static bool NodeRoutesToCurrentOrbitedMoon(this TerminalNode node)
		{
			return (Object)(object)StartOfRound.Instance.levels[node.buyRerouteToMoon] == (Object)(object)StartOfRound.Instance.currentLevel;
		}

		public static void AddKeyword(this Terminal terminal, TerminalKeyword newKeyword)
		{
			terminal.terminalNodes.allKeywords = CollectionExtensions.AddToArray<TerminalKeyword>(terminal.terminalNodes.allKeywords, newKeyword);
		}

		public static void AddKeywords(this Terminal terminal, params TerminalKeyword[] newKeywords)
		{
			foreach (TerminalKeyword newKeyword in newKeywords)
			{
				terminal.AddKeyword(newKeyword);
			}
		}

		public static void AddCompatibleNounToKeyword(this Terminal terminal, string keywordName, CompatibleNoun newCompatibleNoun)
		{
			string keywordName2 = keywordName;
			TerminalKeyword val = ((IEnumerable<TerminalKeyword>)terminal.terminalNodes.allKeywords).FirstOrDefault((Func<TerminalKeyword, bool>)((TerminalKeyword kw) => ((Object)kw).name == keywordName2)) ?? throw new ArgumentException("Failed to find keyword with name " + keywordName2);
			val.compatibleNouns = CollectionExtensions.AddToArray<CompatibleNoun>(val.compatibleNouns, newCompatibleNoun);
		}

		public static void AddCompatibleNounsToKeyword(this Terminal terminal, string keywordName, params CompatibleNoun[] newCompatibleNouns)
		{
			foreach (CompatibleNoun newCompatibleNoun in newCompatibleNouns)
			{
				terminal.AddCompatibleNounToKeyword(keywordName, newCompatibleNoun);
			}
		}

		public static bool ResultIsRealMoon(this CompatibleNoun compatibleNoun)
		{
			return compatibleNoun.result.buyRerouteToMoon == -2;
		}

		public static bool ResultIsAffordable(this CompatibleNoun compatibleNoun)
		{
			return compatibleNoun.result.itemCost <= 0 || RouteRandomRedexed.ConfigAllowCostlyPlanets.Value || RouteRandomRedexed.ConfigRemoveCostOfCostlyPlanets.Value;
		}

		public static bool TryMakeRouteMoonNodeFree(TerminalNode routeMoonNode, out TerminalNode freeMoonNode)
		{
			//IL_0071: 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_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Expected O, but got Unknown
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Expected O, but got Unknown
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Expected O, but got Unknown
			CompatibleNoun val = ((IEnumerable<CompatibleNoun>)routeMoonNode.terminalOptions).FirstOrDefault((Func<CompatibleNoun, bool>)((CompatibleNoun node) => ((Object)node.noun).name == "Confirm"));
			CompatibleNoun val2 = ((IEnumerable<CompatibleNoun>)routeMoonNode.terminalOptions).FirstOrDefault((Func<CompatibleNoun, bool>)((CompatibleNoun node) => ((Object)node.noun).name == "Deny"));
			if (val == null || val2 == null)
			{
				freeMoonNode = null;
				return false;
			}
			TerminalNode result = new TerminalNode
			{
				name = ((Object)val.result).name + "Free",
				buyRerouteToMoon = val.result.buyRerouteToMoon,
				clearPreviousText = true,
				displayText = val.result.displayText,
				itemCost = 0
			};
			TerminalNode val3 = new TerminalNode();
			((Object)val3).name = ((Object)routeMoonNode).name + "Free";
			val3.buyRerouteToMoon = -2;
			val3.clearPreviousText = true;
			val3.displayPlanetInfo = routeMoonNode.displayPlanetInfo;
			val3.displayText = routeMoonNode.displayText;
			val3.itemCost = 0;
			val3.overrideOptions = true;
			val3.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[2]
			{
				val2,
				new CompatibleNoun
				{
					noun = val.noun,
					result = result
				}
			};
			freeMoonNode = val3;
			return true;
		}
	}
}