Decompiled source of ZetasMoonDiscounts v1.2.0

ZetasMoonDiscounts.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LethalLevelLoader;
using UnityEngine;
using WeatherRegistry;
using WeatherTweaks.Definitions;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ZetasMoonDiscounts")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ZetasMoonDiscounts")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("051aec3d-698c-48a7-b7ba-2445de4e8117")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ZetasMoonDiscounts;

[BepInPlugin("ZetaArcade.ZetasMoonDiscounts", "ZetasMoonDiscounts", "1.2.0")]
public class ZetasMoonDiscountsBase : BaseUnityPlugin
{
	internal class LevelPairedWithPrice
	{
		public ExtendedLevel Level;

		public int OriginalPrice;
	}

	internal class LevelPairedWithRisk
	{
		public ExtendedLevel Level;

		public string OriginalRiskLevel;
	}

	[HarmonyPatch(typeof(Terminal), "Start")]
	internal class TerminalPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void TerminalStartPatch(ref Terminal __instance)
		{
			Logger.LogDebug((object)"Terminal patch detected");
			Instance.SaveDefaultMoonPrices();
			Instance.SaveDefaultMoonRiskLevels();
			Instance.CalculateMoonPrices();
			Instance.CalculateMoonRiskLevels();
		}

		[HarmonyPatch("BeginUsingTerminal")]
		[HarmonyPostfix]
		private static void TerminalBeginUsePatch(ref Terminal __instance)
		{
			Logger.LogDebug((object)"Terminal begin use patch detected");
			Instance.CalculateMoonPrices();
			Instance.CalculateMoonRiskLevels();
		}
	}

	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPatch("PassTimeToNextDay")]
		[HarmonyPostfix]
		private static void PassTimeToNextDay()
		{
			Logger.LogDebug((object)"PassTimeToNextDay patch detected");
			Instance.CalculateMoonPrices();
			Instance.CalculateMoonRiskLevels();
		}

		[HarmonyPatch("ArriveAtLevel")]
		[HarmonyPostfix]
		private static void ArriveAtLevelPatch()
		{
			Logger.LogDebug((object)"ArriveAtLevel patch detected");
			Instance.CalculateMoonPrices();
			Instance.CalculateMoonRiskLevels();
		}
	}

	[HarmonyPatch(typeof(GameNetworkManager))]
	internal class GameNetworkManagerPatch
	{
		[HarmonyPatch("SaveGame")]
		[HarmonyPostfix]
		private static void SaveGameValuesPatch()
		{
			Instance.CalculateMoonPrices();
			Instance.CalculateMoonRiskLevels();
		}

		[HarmonyPatch("ResetSavedGameValues")]
		[HarmonyPostfix]
		private static void ResetSavedGameValuesPatch()
		{
			Instance.CalculateMoonPrices();
			Instance.CalculateMoonRiskLevels();
		}
	}

	[HarmonyPatch(typeof(TimeOfDay))]
	internal class TimeOfDayPatch
	{
		[HarmonyPatch("SetNewProfitQuota")]
		[HarmonyPrefix]
		private static void SetNewProfitQuotaPatch()
		{
			Instance.CalculateMoonPrices();
			Instance.CalculateMoonRiskLevels();
		}

		[HarmonyPostfix]
		[HarmonyPatch("SetBuyingRateForDay")]
		private static void setBuyingRateForDayPatch()
		{
			Instance.ModifyBuyingRate();
		}

		[HarmonyPostfix]
		[HarmonyPatch("SetNewProfitQuota")]
		private static void setNewProfitQuotaPatch()
		{
			Instance.ModifyBuyingRate();
		}
	}

	private const string modGUID = "ZetaArcade.ZetasMoonDiscounts";

	private const string modName = "ZetasMoonDiscounts";

	private const string modVersion = "1.2.0";

	private readonly Harmony harmony = new Harmony("ZetaArcade.ZetasMoonDiscounts");

	public static ManualLogSource Logger;

	public static ZetasMoonDiscountsBase Instance;

	public ConfigEntry<bool> ApplyBuyingChanges;

	public ConfigEntry<float> NormalSellRate;

	public ConfigEntry<float> ZeroDaysSelLRate;

	public ConfigEntry<int> FreeThreshold;

	public ConfigEntry<int> FreeThresholdCap;

	public ConfigEntry<int> DowngradeCost;

	public ConfigEntry<int> UpgradeThreshold;

	public ConfigEntry<string> IronmanMoons;

	public ConfigEntry<bool> IronmanMode;

	public ConfigEntry<bool> ApplyRiskLevelChanges;

	public ConfigEntry<float> DefaultWeatherRiskLevelIncrease;

	public ConfigEntry<string> WeathersAndRiskLevels;

	private List<LevelPairedWithPrice> MoonDefaultCosts = new List<LevelPairedWithPrice>();

	private List<LevelPairedWithRisk> MoonDefaultRiskLevels = new List<LevelPairedWithRisk>();

	private void Awake()
	{
		if ((Object)(object)Instance == (Object)null)
		{
			Instance = this;
		}
		ApplyBuyingChanges = ((BaseUnityPlugin)this).Config.Bind<bool>("Buying Rate Changes", "Toggle Buying Rate Changes", true, "If true, the below 2 configs will be applied to the Company Buying Rate (How many credits you get for selling things)");
		NormalSellRate = ((BaseUnityPlugin)this).Config.Bind<float>("Buying Rate Changes", "Normal Selling Rate", 1f, "The selling rate at the company on all days except the final day, where 1f = 100%, 0.5f = 50% etc.");
		ZeroDaysSelLRate = ((BaseUnityPlugin)this).Config.Bind<float>("Buying Rate Changes", "Zero Days Selling Rate", 1f, "The selling rate at the company on the final day, where 1f = 100%, 0.5f = 50% etc.");
		FreeThreshold = ((BaseUnityPlugin)this).Config.Bind<int>("Discount Settings", "Free Threshold", 300, "When at Moon A, if Moon B is this amount cheaper (or even cheaper!) it becomes free to route to. E.g. with the default value of 300, if Moon A costs 800 and you route to it, then any moons that cost 500 or less are free to route to.");
		FreeThresholdCap = ((BaseUnityPlugin)this).Config.Bind<int>("Discount Settings", "Free Threshold Cap", 1000, "A Cap for the above config, where if a moon costs this amount or more, then other moons cannot route down to it for free. Note moons that are $3500 cheaper than the current moon or more are set to free anyways, bypassing this config");
		DowngradeCost = ((BaseUnityPlugin)this).Config.Bind<int>("Discount Settings", "Downgrade Cost", 50, "When at Moon A, if Moon B is cheaper but isn't cheap enough to become free with the above config (or costs the same amount as Moon A), then it will be this route price instead.");
		UpgradeThreshold = ((BaseUnityPlugin)this).Config.Bind<int>("Discount Settings", "Upgrade Threshold", 500, "When at Moon A, if Moon B is more expensive, then if it's within the range of this config then you can route 'up' to it, only paying the difference in cost to route. E.g. (with default config at 500) if Moon A costs 400, Moon B costs 800, and Moon C costs 1200, then you can route from Moon A to B for 400 (Since its less than 500 in difference), but Moon C will cost the full 1200.");
		IronmanMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Ironman Settings", "Ironman Mode", false, "When true, will just use the Ironman section of the config instead for moon prices. See mod desc. for how Ironman mode works.");
		IronmanMoons = ((BaseUnityPlugin)this).Config.Bind<string>("Ironman Settings", "Ironman Moon List", "", "List of groups of moons, starting with a price for that group of moons, in the format of: Price@[email protected]. ; e.g. 0@Exp@Vow;300@Assurance@Solace; Only works if Ironman Mode is enabled.");
		ApplyRiskLevelChanges = ((BaseUnityPlugin)this).Config.Bind<bool>("Dynamic Risk Level Settings", "Toggle Risk Level Changes", false, "If true, a moon's risk level will change depending on the current weather and below settings.");
		DefaultWeatherRiskLevelIncrease = ((BaseUnityPlugin)this).Config.Bind<float>("Dynamic Risk Level Settings", "Default Weather Risk Level Increase", 1f, "The default difficulty increase for a weather where unspecified below.");
		WeathersAndRiskLevels = ((BaseUnityPlugin)this).Config.Bind<string>("Dynamic Risk Level Settings", "Weathers and Risk Levels", "", "A list of weathers paired with how much they should increase the difficulty rating, in the format WeatherName@DifficultyIncreaseAmount; e.g. None@0;[email protected]; Be careful to not include any whitespace unless it's a part of the weather name!");
		Logger = ((BaseUnityPlugin)this).Logger;
		Logger.LogInfo((object)"Plugin is loaded!");
		harmony.PatchAll(typeof(ZetasMoonDiscountsBase));
		harmony.PatchAll(typeof(TerminalPatch));
		harmony.PatchAll(typeof(StartOfRoundPatch));
		harmony.PatchAll(typeof(TimeOfDayPatch));
		harmony.PatchAll(typeof(GameNetworkManagerPatch));
	}

	public void ModifyBuyingRate()
	{
		if (ApplyBuyingChanges.Value && Object.op_Implicit((Object)(object)TimeOfDay.Instance) && Object.op_Implicit((Object)(object)StartOfRound.Instance))
		{
			if (TimeOfDay.Instance.daysUntilDeadline != 0)
			{
				StartOfRound.Instance.companyBuyingRate = NormalSellRate.Value;
			}
			else
			{
				StartOfRound.Instance.companyBuyingRate = ZeroDaysSelLRate.Value;
			}
		}
	}

	public void CalculateMoonPrices()
	{
		Logger.LogDebug((object)"Attempting CalculateMoonPrices");
		if (MoonDefaultCosts.Count < 1 && !IronmanMode.Value)
		{
			Logger.LogDebug((object)"Default moon prices have not been set, skipping Calculation of moon prices");
			return;
		}
		Logger.LogDebug((object)"Default moon prices been set, continuing");
		if (!Object.op_Implicit((Object)(object)StartOfRound.Instance) || !Object.op_Implicit((Object)(object)StartOfRound.Instance.currentLevel))
		{
			return;
		}
		SelectableLevel currentLevel = StartOfRound.Instance.currentLevel;
		Logger.LogDebug((object)"Got current level ref");
		ExtendedLevel val = PatchedContent.ExtendedLevels.Find((ExtendedLevel x) => (Object)(object)x.SelectableLevel == (Object)(object)currentLevel);
		if (!IronmanMode.Value)
		{
			foreach (ExtendedLevel level2 in PatchedContent.ExtendedLevels)
			{
				level2.RoutePrice = MoonDefaultCosts.Find((LevelPairedWithPrice x) => (Object)(object)x.Level == (Object)(object)level2).OriginalPrice;
			}
			if (val.NumberlessPlanetName == "Gordion" || val.NumberlessPlanetName == "Galetry" || val.NumberlessPlanetName == "Oxyde" || val.RoutePrice == 0)
			{
				Logger.LogDebug((object)("Current moon " + val.NumberlessPlanetName + " is free/company/oxyde, so no discounts will be applied"));
				return;
			}
			Logger.LogDebug((object)("Current moon " + val.NumberlessPlanetName + " is not free/company/oxyde, so discounts will be applied"));
			{
				foreach (ExtendedLevel level in PatchedContent.ExtendedLevels)
				{
					if (level.NumberlessPlanetName == "Gordion" || level.NumberlessPlanetName == "Galetry" || level.NumberlessPlanetName == "Oxyde" || level.NumberlessPlanetName == val.NumberlessPlanetName || level.RoutePrice == 0)
					{
						level.RoutePrice = MoonDefaultCosts.Find((LevelPairedWithPrice x) => (Object)(object)x.Level == (Object)(object)level).OriginalPrice;
						continue;
					}
					int num = val.RoutePrice - level.RoutePrice;
					if ((num >= FreeThreshold.Value && level.RoutePrice < FreeThresholdCap.Value) || num >= 3500)
					{
						level.RoutePrice = 0;
						Logger.LogDebug((object)("Current moon " + val.NumberlessPlanetName + "(" + val.RoutePrice + ") --> " + level.NumberlessPlanetName + "(" + level.RoutePrice + ") Meets the free discount criteria"));
						continue;
					}
					if (level.RoutePrice <= val.RoutePrice)
					{
						level.RoutePrice = DowngradeCost.Value;
						Logger.LogDebug((object)("Current moon " + val.NumberlessPlanetName + "(" + val.RoutePrice + ") --> " + level.NumberlessPlanetName + "(" + level.RoutePrice + ") Meets the downgrade discount criteria"));
						continue;
					}
					num = level.RoutePrice - val.RoutePrice;
					if (num <= UpgradeThreshold.Value)
					{
						level.RoutePrice = num;
						Logger.LogDebug((object)("Current moon " + val.NumberlessPlanetName + "(" + val.RoutePrice + ") --> " + level.NumberlessPlanetName + "(" + level.RoutePrice + ") Meets the upgrade discount criteria"));
						continue;
					}
					level.RoutePrice = MoonDefaultCosts.Find((LevelPairedWithPrice x) => (Object)(object)x.Level == (Object)(object)level).OriginalPrice;
					Logger.LogDebug((object)("Current moon " + val.NumberlessPlanetName + "(" + val.RoutePrice + ") --> " + level.NumberlessPlanetName + "(" + level.RoutePrice + ") Does not meet any discount criteria"));
				}
				return;
			}
		}
		Logger.LogDebug((object)"Ironman Mode Detected");
		if (val.NumberlessPlanetName == "Gordion" || val.NumberlessPlanetName == "Galetry" || val.NumberlessPlanetName == "Oxyde")
		{
			Logger.LogDebug((object)"Ironman Is Company");
			string[] array = IronmanMoons.Value.ToString().Split(new char[1] { ';' }, StringSplitOptions.RemoveEmptyEntries);
			string[] array2 = array;
			foreach (string text in array2)
			{
				Logger.LogDebug((object)("Ironman currently on entry " + text));
				string[] array3 = text.Split(new char[1] { '@' }, StringSplitOptions.RemoveEmptyEntries);
				int num2 = 0;
				string[] array4 = array3;
				foreach (string pair in array4)
				{
					Logger.LogDebug((object)("Ironman currently on pair " + pair));
					if (num2 != 0)
					{
						ExtendedLevel val2 = PatchedContent.ExtendedLevels.Find((ExtendedLevel x) => (Object)(object)x.SelectableLevel == (Object)(object)ConfigHelper.ConvertStringToLevels(pair)[0]);
						if (int.TryParse(array3[0].ToString(), out var result))
						{
							Logger.LogDebug((object)("Setting " + val2.NumberlessPlanetName + " route price to " + result));
							val2.RoutePrice = result;
						}
					}
					num2++;
				}
			}
			return;
		}
		Logger.LogDebug((object)"Ironman is a normal moon");
		bool flag = false;
		List<string> list = new List<string>();
		string[] array5 = IronmanMoons.Value.ToString().Split(new char[1] { ';' }, StringSplitOptions.RemoveEmptyEntries);
		string[] array6 = array5;
		foreach (string text2 in array6)
		{
			string[] pairs = text2.Split(new char[1] { '@' }, StringSplitOptions.RemoveEmptyEntries);
			int index = 0;
			string[] array7 = pairs;
			foreach (string text3 in array7)
			{
				if (index != 0)
				{
					ExtendedLevel val3 = PatchedContent.ExtendedLevels.Find((ExtendedLevel x) => (Object)(object)x.SelectableLevel == (Object)(object)ConfigHelper.ConvertStringToLevels(pairs[index])[0]);
					Logger.LogDebug((object)("Current level is: " + val.NumberlessPlanetName + " and Current config level is " + val3.NumberlessPlanetName));
					if (val.NumberlessPlanetName == val3.NumberlessPlanetName)
					{
						flag = true;
						int index2 = 0;
						string[] array8 = pairs;
						foreach (string text4 in array8)
						{
							if (index2 != 0)
							{
								ExtendedLevel val4 = PatchedContent.ExtendedLevels.Find((ExtendedLevel x) => (Object)(object)x.SelectableLevel == (Object)(object)ConfigHelper.ConvertStringToLevels(pairs[index2])[0]);
								Logger.LogDebug((object)("Trying to add " + pairs[index2] + " passed as " + (object)val4));
								list.Add(val4.NumberlessPlanetName);
							}
							index2++;
						}
					}
				}
				index++;
			}
		}
		foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels)
		{
			if (!(extendedLevel.NumberlessPlanetName != "Gordion") || !(extendedLevel.NumberlessPlanetName != "Galetry") || !(extendedLevel.NumberlessPlanetName != "Oxyde") || !(extendedLevel.NumberlessPlanetName != val.NumberlessPlanetName))
			{
				continue;
			}
			bool flag2 = false;
			foreach (string item in list)
			{
				Logger.LogDebug((object)("Ironman current level checked is " + extendedLevel.NumberlessPlanetName + " vs. " + item));
				if (extendedLevel.NumberlessPlanetName == item)
				{
					Logger.LogDebug((object)"Ironman they are a match");
					flag2 = true;
				}
				else
				{
					Logger.LogDebug((object)"Ironman they are not a match");
				}
			}
			if (!flag2)
			{
				extendedLevel.RoutePrice = 9999;
			}
			else
			{
				extendedLevel.RoutePrice = 0;
			}
		}
	}

	public void CalculateMoonRiskLevels()
	{
		Logger.LogDebug((object)"Attempting CalculateMoonRiskLevels");
		if (MoonDefaultRiskLevels.Count < 1 || !ApplyRiskLevelChanges.Value)
		{
			Logger.LogDebug((object)"Default moon risk levels have not been set or the option is disabled, skipping Calculation of moon risk levels");
			return;
		}
		Logger.LogDebug((object)"Default moon risk levels have been set, continuing");
		if (!Object.op_Implicit((Object)(object)StartOfRound.Instance) || !Object.op_Implicit((Object)(object)StartOfRound.Instance.currentLevel))
		{
			return;
		}
		Logger.LogDebug((object)"Got current level ref");
		if (!ApplyRiskLevelChanges.Value)
		{
			return;
		}
		foreach (ExtendedLevel level in PatchedContent.ExtendedLevels)
		{
			level.SelectableLevel.riskLevel = MoonDefaultRiskLevels.Find((LevelPairedWithRisk x) => (Object)(object)x.Level == (Object)(object)level).OriginalRiskLevel;
			if (level.NumberlessPlanetName == "Gordion" || level.NumberlessPlanetName == "Galetry" || level.NumberlessPlanetName == "Oxyde")
			{
				Logger.LogDebug((object)("Current moon " + level.NumberlessPlanetName + " is free/company/oxyde, so no risk level changes will be applied"));
				continue;
			}
			Logger.LogDebug((object)("Current moon " + level.NumberlessPlanetName + " is not free/company/oxyde, so risk level changes will be applied"));
			bool isCombined;
			float floatRiskLevel = ConvertRiskLevelToFloat(level.SelectableLevel.riskLevel) + GetWeatherRiskLevelFloat(WeatherManager.GetCurrentWeather(level.SelectableLevel), out isCombined);
			level.SelectableLevel.riskLevel = ConvertFloatToRiskLevel(floatRiskLevel);
			if (isCombined)
			{
				SelectableLevel selectableLevel = level.SelectableLevel;
				selectableLevel.riskLevel += "?";
			}
		}
	}

	public float SwapLetterForRiskFloat(char target)
	{
		float num = 0f;
		return target switch
		{
			'X' => 10f, 
			'S' => 6f, 
			'A' => 5f, 
			'B' => 4f, 
			'C' => 3f, 
			'D' => 2f, 
			'E' => 1f, 
			'F' => 0f, 
			_ => 0f, 
		};
	}

	public float SwapSymbolsForRiskFloat(string target)
	{
		float num = 0f;
		return target switch
		{
			"-" => 0.31f, 
			"+" => 0.66f, 
			"++" => 0.76f, 
			"*" => 0.86f, 
			_ => 0.5f, 
		};
	}

	public string SwapIntForRiskLetter(int riskInt)
	{
		string text = "";
		if (riskInt > 10)
		{
			return "X";
		}
		if (riskInt > 6)
		{
			return "S";
		}
		return riskInt switch
		{
			0 => "F", 
			1 => "E", 
			2 => "D", 
			3 => "C", 
			4 => "B", 
			5 => "A", 
			6 => "S", 
			10 => "X", 
			_ => "?", 
		};
	}

	public string SwapFloatDecimalsForRiskSymbol(float riskFloat)
	{
		string text = "";
		float num = riskFloat - (float)(int)riskFloat;
		double num2 = Math.Round(num, 2);
		if (num2 >= 0.85)
		{
			return "*";
		}
		if (num2 >= 0.75)
		{
			return "++";
		}
		if (num2 >= 0.65)
		{
			return "+";
		}
		if (num2 >= 0.3)
		{
			return "";
		}
		return "-";
	}

	public float ConvertRiskLevelToFloat(string riskLevel)
	{
		float num = 0f;
		float num2 = 0f;
		float num3 = 0f;
		char[] array = riskLevel.ToCharArray();
		num2 = SwapLetterForRiskFloat(array[0]);
		string text = riskLevel.TrimStart(new char[1] { array[0] });
		num3 = ((text.Length <= 0) ? 0.5f : SwapSymbolsForRiskFloat(text));
		Logger.LogDebug((object)("Converted " + riskLevel + " to " + num2 + " + " + num3));
		return num2 + num3;
	}

	public string ConvertFloatToRiskLevel(float floatRiskLevel)
	{
		string text = "";
		string text2 = SwapIntForRiskLetter((int)floatRiskLevel);
		string text3 = SwapFloatDecimalsForRiskSymbol(floatRiskLevel);
		return text2 + text3;
	}

	public float GetWeatherRiskLevelFloat(Weather weather, out bool isCombined)
	{
		isCombined = false;
		float num = 0f;
		WeatherTweaksWeather val = (WeatherTweaksWeather)(object)((weather is WeatherTweaksWeather) ? weather : null);
		if (val != null)
		{
			float num2 = 0f;
			float num3 = 0f;
			float num4 = 0f;
			float num5 = 0f;
			float num6 = 0f;
			List<string> list = new List<string>();
			for (int i = 0; i < val.WeatherTypes.Count; i++)
			{
				float num7 = ConvertWeatherNameToRiskFloat(val.WeatherTypes[i].WeatherName);
				num3 += num7;
				if (!list.Contains(val.WeatherTypes[i].WeatherName))
				{
					list.Add(val.WeatherTypes[i].WeatherName);
					if (val.WeatherTypes[i].WeatherName != "None" || val.WeatherTypes[i].WeatherName != "Clear" || val.WeatherTypes[i].WeatherName != "Cloudy" || val.WeatherTypes[i].WeatherName != "NightShift")
					{
						num5 += 0.15f;
					}
				}
				if (num2 < num7)
				{
					num2 = num7;
				}
			}
			num4 = num3 / (float)val.WeatherTypes.Count;
			num4 += num5;
			num6 = num2 + num5;
			num = num6;
			isCombined = true;
		}
		else
		{
			num = ConvertWeatherNameToRiskFloat(weather.Name);
		}
		return num;
	}

	public float ConvertWeatherNameToRiskFloat(string weatherName)
	{
		Logger.LogDebug((object)"Started converting weather name to risk");
		float num = 0f;
		Dictionary<string, float> dictionary = new Dictionary<string, float>();
		string[] array = WeathersAndRiskLevels.Value.ToString().Split(new char[1] { ';' }, StringSplitOptions.RemoveEmptyEntries);
		string[] array2 = array;
		foreach (string text in array2)
		{
			string[] array3 = text.Split(new char[1] { '@' }, StringSplitOptions.RemoveEmptyEntries);
			float num2 = 0f;
			if (float.TryParse(array3[1], out var result))
			{
				Logger.LogDebug((object)("Succesfully parsed " + text + "'s second part as a float (" + result + ")"));
				num2 = result;
			}
			else
			{
				Logger.LogDebug((object)("Couldn't parse " + text + "'s second part as a float, so setting to default value instead"));
				num2 = DefaultWeatherRiskLevelIncrease.Value;
			}
			Logger.LogDebug((object)("Now trying to parse weather " + array3[0] + " in the ConfigHelper"));
			List<Weather> list = new List<Weather>();
			try
			{
				list = ConfigHelper.ResolveStringToWeathers(array3[0]);
			}
			catch (Exception)
			{
				Logger.LogDebug((object)("Exception caught, Could not resolve weather " + text + " in the ConfigHelper"));
			}
			bool flag = false;
			string text2 = "";
			foreach (Weather weather in list)
			{
				try
				{
					WeatherManager.Weathers.Find((Weather x) => x.Name == weather.name);
					Logger.LogDebug((object)("Found weather " + text + " in the WeatherManager"));
					flag = true;
					text2 = weather.Name;
				}
				catch (Exception)
				{
					Logger.LogDebug((object)("Exception caught, could not find " + text + " in the WeatherManager"));
				}
			}
			if (flag)
			{
				try
				{
					dictionary.Add(text2, num2);
					Logger.LogDebug((object)("Added " + text2 + " to the Config Dictionary, with a value of " + num2));
				}
				catch (ArgumentException)
				{
					Logger.LogDebug((object)("Couldn't add weather " + array3[0] + " to Config Dictionary as it is already in there"));
				}
			}
			else
			{
				Logger.LogDebug((object)("Couldn't find weather " + array3[0] + ", so it will not be added to the Config Dictionary"));
			}
		}
		float value = DefaultWeatherRiskLevelIncrease.Value;
		if (dictionary.TryGetValue(ConfigHelper.ResolveStringToWeather(weatherName).Name, out value))
		{
			Logger.LogDebug((object)("Found weather " + weatherName + " in Dictionary of weathers from config, outputting it's risk level"));
			return value;
		}
		Logger.LogDebug((object)("Could not find weather " + weatherName + " in Dictionary of weathers from config, risk level will be default"));
		return DefaultWeatherRiskLevelIncrease.Value;
	}

	public void SaveDefaultMoonRiskLevels()
	{
		Logger.LogDebug((object)"Attempting to save moon default difficulty ratings");
		if (MoonDefaultRiskLevels.Count > 1)
		{
			Logger.LogDebug((object)"Default difficulty levels have already have been set, skipping");
			return;
		}
		int num = 0;
		foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels)
		{
			LevelPairedWithRisk levelPairedWithRisk = new LevelPairedWithRisk();
			levelPairedWithRisk.Level = extendedLevel;
			levelPairedWithRisk.OriginalRiskLevel = extendedLevel.SelectableLevel.riskLevel;
			MoonDefaultRiskLevels.Add(levelPairedWithRisk);
			Logger.LogDebug((object)("Saved " + extendedLevel.NumberlessPlanetName + " default difficulty level as " + extendedLevel.SelectableLevel.riskLevel));
			num++;
		}
		Logger.LogDebug((object)"Finished setting moon default risk levels");
	}

	public void SaveDefaultMoonPrices()
	{
		Logger.LogDebug((object)"Attempting to save moon default prices");
		Logger.LogDebug((object)("ExtendedLevels Count is: " + PatchedContent.ExtendedLevels.Count));
		if (MoonDefaultCosts.Count > 1)
		{
			Logger.LogDebug((object)"Default prices already have been set, skipping");
			return;
		}
		int num = 0;
		foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels)
		{
			Logger.LogDebug((object)"In loop");
			Logger.LogDebug((object)("Looping through level, current is: " + extendedLevel.NumberlessPlanetName));
			LevelPairedWithPrice levelPairedWithPrice = new LevelPairedWithPrice();
			levelPairedWithPrice.Level = extendedLevel;
			levelPairedWithPrice.OriginalPrice = extendedLevel.RoutePrice;
			MoonDefaultCosts.Add(levelPairedWithPrice);
			Logger.LogDebug((object)("Saved " + extendedLevel.NumberlessPlanetName + " default price as " + extendedLevel.RoutePrice));
			num++;
		}
		Logger.LogDebug((object)"Finished setting moon default prices");
	}
}