Decompiled source of ScrapOutside v2.0.1

Tomatobird.ScrapOutside.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Tomatobird.ScrapOutside")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.0.1.0")]
[assembly: AssemblyInformationalVersion("2.0.1+4063f7b0328068a0e27e21902f34d1957ab4ba3f")]
[assembly: AssemblyProduct("LC_ScrapOutside")]
[assembly: AssemblyTitle("Tomatobird.ScrapOutside")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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]
	[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 LC_ScrapOutside
{
	public class Configuration
	{
		public string name = "";

		public bool configEnabled;

		public Algorithm scrapCountAlgorithm;

		public float chanceToSpawn;

		public int staticScrapToSpawn;

		public int randomScrapMin;

		public int randomScrapMax;

		public float dynamicBaseScrapAmount;

		public bool scaleScrapByLuck;

		public float luckMultiplier;

		public bool scaleScrapByQuota;

		public bool inverseQuotaBasedMultiplier;

		public int baselineQuotaValue;

		public float quotaValueMultiplierScalar;

		public bool scaleScrapByMoonScrapAmount;

		public float baselineMoonScrapAmount;

		public float moonScrapAmountDifferenceScalar;

		public bool scaleScrapByWeather;

		public string weatherMultipliers = "";

		public int minScrapToSpawn;

		public int maxScrapToSpawn;

		public bool applyRandomVariance;

		public float randomVarianceMin;

		public float randomVarianceMax;

		public ScrapType scrapType;

		public string scrapToSpawn = "";

		public SpawnPositions spawnPositions;

		public float spawnRadius;

		public float spawnRadiusAroundEntrances;

		public string customPositions = "";

		public Configuration(string name, bool useThis = false, Algorithm algorithm = Algorithm.Dynamic, float chance = 1f, int staticScrapAmount = 6, int randomScrapMin = 4, int randomScrapMax = 8, float dynamicBaseAmount = 6f, bool scaleByLuck = true, float luckMultiplier = 2f, bool scaleByQuota = true, int baselineQuotaValue = 1000, float quotaValueMultiplierScalar = 0.5f, bool inverseQuotaBasedMultiplier = false, bool scaleByScrapAmount = true, float baselineMoonScrapAmount = 18f, float moonScrapAmountScalar = 0.5f, bool useWeather = true, string weatherMultipliers = "none:1.0,rainy:1.1,foggy:1.2,flooded:1.3,stormy:1.4,eclipsed:1.5", int minScrapToSpawn = 4, int maxScrapToSpawn = 250, bool applyRandomVariance = true, float randomVarianceMin = 0.7f, float randomVarianceMax = 1.3f, ScrapType scrapType = ScrapType.FromMoon, string scrapToSpawn = "", SpawnPositions spawnPositions = SpawnPositions.OutsideNodes, float spawnRadius = 10f, float spawnRadiusAroundEntrances = 40f, string customPositions = "")
		{
			this.name = name;
			configEnabled = useThis;
			scrapCountAlgorithm = algorithm;
			chanceToSpawn = chance;
			staticScrapToSpawn = staticScrapAmount;
			this.randomScrapMin = randomScrapMin;
			this.randomScrapMax = randomScrapMax;
			dynamicBaseScrapAmount = dynamicBaseAmount;
			scaleScrapByLuck = scaleByLuck;
			this.luckMultiplier = luckMultiplier;
			scaleScrapByQuota = scaleByQuota;
			this.baselineQuotaValue = baselineQuotaValue;
			this.quotaValueMultiplierScalar = quotaValueMultiplierScalar;
			this.inverseQuotaBasedMultiplier = inverseQuotaBasedMultiplier;
			scaleScrapByMoonScrapAmount = scaleByScrapAmount;
			this.baselineMoonScrapAmount = baselineMoonScrapAmount;
			moonScrapAmountDifferenceScalar = moonScrapAmountScalar;
			scaleScrapByWeather = useWeather;
			this.weatherMultipliers = weatherMultipliers;
			this.minScrapToSpawn = minScrapToSpawn;
			this.maxScrapToSpawn = maxScrapToSpawn;
			this.applyRandomVariance = applyRandomVariance;
			this.randomVarianceMin = randomVarianceMin;
			this.randomVarianceMax = randomVarianceMax;
			this.scrapType = scrapType;
			this.scrapToSpawn = scrapToSpawn;
			this.spawnPositions = spawnPositions;
			this.spawnRadius = spawnRadius;
			this.spawnRadiusAroundEntrances = spawnRadiusAroundEntrances;
			this.customPositions = customPositions;
		}
	}
	public enum Algorithm
	{
		Static,
		Random,
		Dynamic
	}
	public enum ScrapType
	{
		FromMoon,
		CustomList
	}
	public enum SpawnPositions
	{
		OutsideNodes,
		NodesNearEntrances,
		NodesNearMain,
		CustomList
	}
	[BepInPlugin("Tomatobird.ScrapOutside", "LC_ScrapOutside", "2.0.1")]
	public class LC_ScrapOutside : BaseUnityPlugin
	{
		public static List<Configuration> configurations = new List<Configuration>();

		public static ConfigEntry<bool> announceInChat = null;

		public static ConfigEntry<string> announcementMessage = null;

		public static ConfigEntry<bool> useInternalLuckValue = null;

		public static ConfigEntry<bool> luckyRoll = null;

		public static ConfigEntry<float> maxLuckyLuck = null;

		public static ConfigEntry<float> maxLuckyChance = null;

		public static ConfigEntry<float> luckyRollMultiplier = null;

		public static LC_ScrapOutside Instance { get; private set; } = null;

		internal static ManualLogSource Logger { get; private set; } = null;

		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Expected O, but got Unknown
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			announceInChat = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Announce In Chat", true, "When scrap is spawned outside, annouce the amount spawned in chat.");
			announcementMessage = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Announcement Message", "Spawned &# scrap outside!", "What should the chat announcement read? Available placeholders: &# - Amount of scrap spawned outside, &$ - Value of the scrap spawned outside, &= - Total count of all scrap spawned outside in the current session, &% - Total value of all scrap spawned outside in the current session.");
			useInternalLuckValue = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Use Internal Luck Value", false, "Instead of calculating the current furniture luck immediately from the currently placed furniture, should the internal luck value be used? The internal value only updates each quota after quota 2.");
			luckyRoll = ((BaseUnityPlugin)this).Config.Bind<bool>("Luck Bonus", "Lucky Bonus", true, "Enable a bonus luck check that multiplies the amount of scrap outside if it passes. Uses furniture luck to determine the chance to succeed.");
			maxLuckyLuck = ((BaseUnityPlugin)this).Config.Bind<float>("Luck Bonus", "Max Luck", 0.2135f, "Furniture luck max cap. Default is all vanilla furniture without signal translator. Increase if you have mods that add more furniture with luck.");
			maxLuckyChance = ((BaseUnityPlugin)this).Config.Bind<float>("Luck Bonus", "Success Chance", 0.2f, new ConfigDescription("Chance of success at max luck.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			luckyRollMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Luck Bonus", "Scrap Multiplier", 3f, "The amount of scrap outside is multiplied by this if the luck check is successful.");
			configurations.Add(new Configuration("default", useThis: true, ((BaseUnityPlugin)this).Config.Bind<Algorithm>("default", "Scrap Count Algorithm", Algorithm.Dynamic, "Which method to use for calculating scrap amount.").Value, ((BaseUnityPlugin)this).Config.Bind<float>("default", "Chance To Spawn", 1f, new ConfigDescription("Chance for outside scrap to spawn. 0 for never, 1 for always", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())).Value, ((BaseUnityPlugin)this).Config.Bind<int>("default", "Static: Scrap Amount", 6, "Amount of scrap to spawn outside. Applies if static algorithm is selected.").Value, ((BaseUnityPlugin)this).Config.Bind<int>("default", "Random: Minimum", 4, "Minimum amount of scrap to spawn. Inclusive. This should always be lower than Maximum. Applies if random algorithm is selected.").Value, ((BaseUnityPlugin)this).Config.Bind<int>("default", "Random: Maximum", 8, "Maximum amount of scrap to spawn. Inclusive. Applies if random algorithm is selected.").Value, ((BaseUnityPlugin)this).Config.Bind<float>("default", "Dynamic: Base Scrap Amount", 6f, "Base amount of scrap to spawn. This and all other settings below apply if dynamic algorithm is selected.").Value, ((BaseUnityPlugin)this).Config.Bind<bool>("default", "Dynamic: Use Furniture Luck", true, "Should scrap amount scale by luck value?").Value, ((BaseUnityPlugin)this).Config.Bind<float>("default", "Dynamic: Furniture Luck Multiplier", 2f, "How much is furniture luck scaled by for the multiplication?").Value, ((BaseUnityPlugin)this).Config.Bind<bool>("default", "Dynamic: Use Quota Value", true, "Should scrap amount scale by quota value?").Value, ((BaseUnityPlugin)this).Config.Bind<int>("default", "Dynamic: Baseline Quota Value", 1000, "The quota value baseline. Values below are decrease scrap amount, values above increase it.").Value, ((BaseUnityPlugin)this).Config.Bind<float>("default", "Dynamic: Quota Value Multiplier Scalar", 0.5f, "How effective is the multiplier? Multiplier^Scalar = Final Multiplier. 1.0 makes this not affect it. Lower values reduce the effect, higher values strengthen it.").Value, ((BaseUnityPlugin)this).Config.Bind<bool>("default", "Dynamic: Inverse Quota Based Multiplier", false, "Should scrap amount decrease as quota increases?").Value, ((BaseUnityPlugin)this).Config.Bind<bool>("default", "Dynamic: Use Moon Scrap Amount", true, "Should scrap amount be based on how many items there are on the moon on average?").Value, ((BaseUnityPlugin)this).Config.Bind<float>("default", "Dynamic: Baseline Moon Scrap Amount", 18f, "The baseline item count where the scrap amount is decreased if the moon average item count is lower, and increased if its higher.").Value, ((BaseUnityPlugin)this).Config.Bind<float>("default", "Dynamic: Moon Scrap Amount Difference Scalar", 0.5f, "How effective should the moon scrap amount multiplier be?").Value, ((BaseUnityPlugin)this).Config.Bind<bool>("default", "Dynamic: Use Weather", true, "Should weathers affect the scrap amount?").Value, ((BaseUnityPlugin)this).Config.Bind<string>("default", "Dynamic: Weather Multipliers", "none:1.0,rainy:1.1,foggy:1.2,flooded:1.3,stormy:1.4,eclipsed:1.5", "Weather Multipliers. Format: weathername:float_value,weathername:float_value").Value, ((BaseUnityPlugin)this).Config.Bind<int>("default", "Dynamic: Min Scrap To Spawn", 1, "Minimum amount of scrap to spawn. Make sure this is lower than maximum scrap to spawn.").Value, ((BaseUnityPlugin)this).Config.Bind<int>("default", "Dynamic: Max Scrap To Spawn", 250, "Maximum amount of scrap to spawn.").Value, ((BaseUnityPlugin)this).Config.Bind<bool>("default", "Dynamic: Apply Extra Variance", true, "Should extra random variance multiplier be applied to this moon?").Value, ((BaseUnityPlugin)this).Config.Bind<float>("default", "Dynamic: Extra Variance Minimum", 0.7f, "Extra variance multiplier minimum.").Value, ((BaseUnityPlugin)this).Config.Bind<float>("default", "Dynamic: Extra Variance Maximum", 1.3f, "Extra variance multiplier maximum.").Value, ((BaseUnityPlugin)this).Config.Bind<ScrapType>("default", "Scrap Types", ScrapType.FromMoon, "What type of scrap to spawn? FromMoon is anything from the moon's scrap pool, CustomList uses the list of items defined in ScrapToSpawn.").Value, ((BaseUnityPlugin)this).Config.Bind<string>("default", "Scrap To Spawn", "", "List of scraps to spawn outside. Define name and rarity separated with a colon. Separate each entry with a comma. Example: Large axle:20,Bell:10,Gold bar:2").Value, ((BaseUnityPlugin)this).Config.Bind<SpawnPositions>("default", "Spawn Positions", SpawnPositions.OutsideNodes, "Where to spawn scrap? OutsideNodes chooses all nodes outside, NodesNearEntrances chooses outside nodes that are near all entrances, NodesNearMain chooses outside nodes that are near Main entrance, CustomList uses the Custom Spawn Positions list.").Value, ((BaseUnityPlugin)this).Config.Bind<float>("default", "Spawn Radius", 10f, "Radius in which to search for a spot on the navmesh to spawn an item to. Set to 0 to spawn exactly on the node/custom position.").Value, ((BaseUnityPlugin)this).Config.Bind<float>("default", "Spawn Radius Around Entrances", 40f, "Radius in which to search for nodes around an entrance to spawn items to. Only used when the respective SpawnPositions value is selected.").Value, ((BaseUnityPlugin)this).Config.Bind<string>("default", "Custom Spawn Positions", "", "List of 3d positions to spawn items to. Separate X Y and Z value with a comma. Separate each entry with a semicolon. Example: 5.51,-1.52,10 ; 15.1,0.67,25.62").Value));
			Patch();
			Logger.LogInfo((object)"Tomatobird.ScrapOutside v2.0.1 has loaded!");
		}

		internal static void Patch()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("Tomatobird.ScrapOutside");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll();
			Logger.LogDebug((object)"Finished patching!");
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Tomatobird.ScrapOutside";

		public const string PLUGIN_NAME = "LC_ScrapOutside";

		public const string PLUGIN_VERSION = "2.0.1";
	}
}
namespace LC_ScrapOutside.Patches
{
	[HarmonyPatch]
	internal class ConfigurationGenerator
	{
		[HarmonyPatch(typeof(StartOfRound), "Start")]
		[HarmonyPostfix]
		internal static void GenerateMoonConfigurations(StartOfRound __instance)
		{
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Expected O, but got Unknown
			LC_ScrapOutside.Logger.LogDebug((object)"Generating configurations for each moon.");
			SelectableLevel[] levels = __instance.levels;
			for (int i = 0; i < levels.Length; i++)
			{
				if (levels[i].spawnEnemiesAndScrap)
				{
					LC_ScrapOutside.configurations.Add(new Configuration(levels[i].PlanetName, ((BaseUnityPlugin)LC_ScrapOutside.Instance).Config.Bind<bool>("Moon: " + levels[i].PlanetName, "Enable Config", false, "Should this configuration be used for the moon? Uses defaults if false.").Value, ((BaseUnityPlugin)LC_ScrapOutside.Instance).Config.Bind<Algorithm>("Moon: " + levels[i].PlanetName, "Scrap Count Algorithm", Algorithm.Dynamic, "Which method to use for calculating scrap amount.").Value, ((BaseUnityPlugin)LC_ScrapOutside.Instance).Config.Bind<float>("Moon: " + levels[i].PlanetName, "Chance To Spawn", 1f, new ConfigDescription("Chance for outside scrap to spawn. 0 for never, 1 for always", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())).Value, ((BaseUnityPlugin)LC_ScrapOutside.Instance).Config.Bind<int>("Moon: " + levels[i].PlanetName, "Static: Scrap Amount", 6, "Amount of scrap to spawn outside. Applies if static algorithm is selected.").Value, ((BaseUnityPlugin)LC_ScrapOutside.Instance).Config.Bind<int>("Moon: " + levels[i].PlanetName, "Random: Minimum", 4, "Minimum amount of scrap to spawn. Inclusive. This should always be lower than Maximum. Applies if random algorithm is selected.").Value, ((BaseUnityPlugin)LC_ScrapOutside.Instance).Config.Bind<int>("Moon: " + levels[i].PlanetName, "Random: Maximum", 8, "Maximum amount of scrap to spawn. Inclusive. Applies if random algorithm is selected.").Value, ((BaseUnityPlugin)LC_ScrapOutside.Instance).Config.Bind<float>("Moon: " + levels[i].PlanetName, "Dynamic: Base Scrap Amount", 6f, "Base amount of scrap to spawn. This and all other settings below apply if dynamic algorithm is selected.").Value, ((BaseUnityPlugin)LC_ScrapOutside.Instance).Config.Bind<bool>("Moon: " + levels[i].PlanetName, "Dynamic: Use Furniture Luck", true, "Should scrap amount scale by luck value?").Value, ((BaseUnityPlugin)LC_ScrapOutside.Instance).Config.Bind<float>("Moon: " + levels[i].PlanetName, "Dynamic: Furniture Luck Multiplier", 2f, "How much is furniture luck scaled by for the multiplication?").Value, ((BaseUnityPlugin)LC_ScrapOutside.Instance).Config.Bind<bool>("Moon: " + levels[i].PlanetName, "Dynamic: Use Quota Value", true, "Should scrap amount scale by quota value?").Value, ((BaseUnityPlugin)LC_ScrapOutside.Instance).Config.Bind<int>("Moon: " + levels[i].PlanetName, "Dynamic: Baseline Quota Value", 1000, "The quota value baseline. Values below are decrease scrap amount, values above increase it.").Value, ((BaseUnityPlugin)LC_ScrapOutside.Instance).Config.Bind<float>("Moon: " + levels[i].PlanetName, "Dynamic: Quota Value Multiplier Scalar", 0.5f, "How effective is the multiplier? Multiplier^Scalar = Final Multiplier. 1.0 makes this not affect it. Lower values reduce the effect, higher values strengthen it.").Value, ((BaseUnityPlugin)LC_ScrapOutside.Instance).Config.Bind<bool>("Moon: " + levels[i].PlanetName, "Dynamic: Inverse Quota Based Multiplier", false, "Should scrap amount decrease as quota increases?").Value, ((BaseUnityPlugin)LC_ScrapOutside.Instance).Config.Bind<bool>("Moon: " + levels[i].PlanetName, "Dynamic: Use Moon Scrap Amount", true, "Should scrap amount be based on how many items there are on the moon on average?").Value, ((BaseUnityPlugin)LC_ScrapOutside.Instance).Config.Bind<float>("Moon: " + levels[i].PlanetName, "Dynamic: Baseline Moon Scrap Amount", 18f, "The baseline item count where the scrap amount is decreased if the moon average item count is lower, and increased if its higher.").Value, ((BaseUnityPlugin)LC_ScrapOutside.Instance).Config.Bind<float>("Moon: " + levels[i].PlanetName, "Dynamic: Moon Scrap Amount Difference Scalar", 0.5f, "How effective should the moon scrap amount multiplier be?").Value, ((BaseUnityPlugin)LC_ScrapOutside.Instance).Config.Bind<bool>("Moon: " + levels[i].PlanetName, "Dynamic: Use Weather", true, "Should weathers affect the scrap amount?").Value, ((BaseUnityPlugin)LC_ScrapOutside.Instance).Config.Bind<string>("Moon: " + levels[i].PlanetName, "Dynamic: Weather Multipliers", "none:1.0,rainy:1.1,foggy:1.2,flooded:1.3,stormy:1.4,eclipsed:1.5", "Weather Multipliers. Format: weathername:float_value,weathername:float_value").Value, ((BaseUnityPlugin)LC_ScrapOutside.Instance).Config.Bind<int>("Moon: " + levels[i].PlanetName, "Dynamic: Min Scrap To Spawn", 1, "Minimum amount of scrap to spawn. Make sure this is lower than maximum scrap to spawn.").Value, ((BaseUnityPlugin)LC_ScrapOutside.Instance).Config.Bind<int>("Moon: " + levels[i].PlanetName, "Dynamic: Max Scrap To Spawn", 250, "Maximum amount of scrap to spawn.").Value, ((BaseUnityPlugin)LC_ScrapOutside.Instance).Config.Bind<bool>("Moon: " + levels[i].PlanetName, "Dynamic: Apply Extra Variance", true, "Should extra random variance multiplier be applied to this moon?").Value, ((BaseUnityPlugin)LC_ScrapOutside.Instance).Config.Bind<float>("Moon: " + levels[i].PlanetName, "Dynamic: Extra Variance Minimum", 0.7f, "Extra variance multiplier minimum.").Value, ((BaseUnityPlugin)LC_ScrapOutside.Instance).Config.Bind<float>("Moon: " + levels[i].PlanetName, "Dynamic: Extra Variance Maximum", 1.3f, "Extra variance multiplier maximum.").Value, ((BaseUnityPlugin)LC_ScrapOutside.Instance).Config.Bind<ScrapType>("Moon: " + levels[i].PlanetName, "Scrap Types", ScrapType.FromMoon, "What type of scrap to spawn? FromMoon is anything from the moon's scrap pool, CustomList uses the list of items defined in ScrapToSpawn.").Value, ((BaseUnityPlugin)LC_ScrapOutside.Instance).Config.Bind<string>("Moon: " + levels[i].PlanetName, "Scrap To Spawn", "", "List of scraps to spawn outside. Define name and rarity separated with a colon. Separate each entry with a comma. Example: Large axle:20,Bell:10,Gold bar:2").Value, ((BaseUnityPlugin)LC_ScrapOutside.Instance).Config.Bind<SpawnPositions>("Moon: " + levels[i].PlanetName, "Spawn Positions", SpawnPositions.OutsideNodes, "Where to spawn scrap? OutsideNodes chooses all nodes outside, NodesNearEntrances chooses outside nodes that are near all entrances, NodesNearMain chooses outside nodes that are near Main entrance, CustomList uses the Custom Spawn Positions list.").Value, ((BaseUnityPlugin)LC_ScrapOutside.Instance).Config.Bind<float>("Moon: " + levels[i].PlanetName, "Spawn Radius", 10f, "Radius in which to search for a spot on the navmesh to spawn an item to. Set to 0 to spawn exactly on the node/custom position.").Value, ((BaseUnityPlugin)LC_ScrapOutside.Instance).Config.Bind<float>("Moon: " + levels[i].PlanetName, "Spawn Radius Around Entrances", 40f, "Radius in which to search for nodes around an entrance to spawn items to. Only used when the respective SpawnPositions value is selected.").Value, ((BaseUnityPlugin)LC_ScrapOutside.Instance).Config.Bind<string>("Moon: " + levels[i].PlanetName, "Custom Spawn Positions", "", "List of 3d positions to spawn items to. Separate X Y and Z value with a comma. Separate each entry with a semicolon. Example: 5.51,-1.52,10 ; 15.1,0.67,25.62").Value));
				}
			}
		}
	}
	[HarmonyPatch]
	public static class SpawnScrap
	{
		internal struct WeightedItem
		{
			public string Name;

			public int Rarity;
		}

		private static int totalOutsideScrapSpawned;

		private static int totalValueOutside;

		private static int outsideScrapSpawned;

		private static int currentIndex;

		private static float luck;

		[HarmonyPatch(typeof(RoundManager), "waitForScrapToSpawnToSync")]
		[HarmonyPrefix]
		public static void WaitForScrapToSpawn_Prefix(ref NetworkObjectReference[] spawnedScrap, ref int[] scrapValues)
		{
			//IL_061d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0685: Unknown result type (might be due to invalid IL or missing references)
			//IL_068a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0652: Unknown result type (might be due to invalid IL or missing references)
			//IL_0661: Unknown result type (might be due to invalid IL or missing references)
			//IL_066d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0672: Unknown result type (might be due to invalid IL or missing references)
			//IL_069a: Unknown result type (might be due to invalid IL or missing references)
			//IL_069c: Unknown result type (might be due to invalid IL or missing references)
			//IL_06af: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0762: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a9: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			for (int i = 0; i < LC_ScrapOutside.configurations.Count; i++)
			{
				if (LC_ScrapOutside.configurations[i].name == RoundManager.Instance.currentLevel.PlanetName)
				{
					if (LC_ScrapOutside.configurations[i].configEnabled)
					{
						currentIndex = i;
					}
					else
					{
						currentIndex = 0;
					}
					flag = true;
					LC_ScrapOutside.Logger.LogInfo((object)("Configuration found for " + RoundManager.Instance.currentLevel.PlanetName + "! " + (LC_ScrapOutside.configurations[i].configEnabled ? "Using custom configurations for this moon." : "Custom configuration for this moon is disabled, using defaults instead.")));
					break;
				}
			}
			if (!flag)
			{
				LC_ScrapOutside.Logger.LogWarning((object)("Configuration for " + RoundManager.Instance.currentLevel.PlanetName + " was not found! Using defaults..."));
				currentIndex = 0;
			}
			if (LC_ScrapOutside.configurations[currentIndex].chanceToSpawn <= 0f)
			{
				LC_ScrapOutside.Logger.LogInfo((object)"Chance for scrap to spawn outside was set to 0, no scrap outside will spawn.");
				return;
			}
			if (LC_ScrapOutside.luckyRoll.Value || LC_ScrapOutside.configurations[currentIndex].scaleScrapByLuck)
			{
				luck = CalculateLuckValue();
			}
			Random random = new Random(StartOfRound.Instance.randomMapSeed + 69420 - 67);
			if (random.NextDouble() >= (double)LC_ScrapOutside.configurations[currentIndex].chanceToSpawn)
			{
				LC_ScrapOutside.Logger.LogInfo((object)$"Unlucky! No scrap will spawn due to ChanceToSpawn: {LC_ScrapOutside.configurations[currentIndex].chanceToSpawn} being lower than the chosen random value.");
				return;
			}
			if (LC_ScrapOutside.configurations[currentIndex].randomVarianceMin > LC_ScrapOutside.configurations[currentIndex].randomVarianceMax)
			{
				LC_ScrapOutside.Logger.LogWarning((object)"ExtraVarianceMin was smaller than ExtraVarianceMax. Please readjust your configuration.");
				LC_ScrapOutside.configurations[currentIndex].randomVarianceMin = LC_ScrapOutside.configurations[currentIndex].randomVarianceMax;
				LC_ScrapOutside.Logger.LogWarning((object)"ExtraVarianceMin was replaced with ExtraVarianceMax to avoid errors.");
			}
			if (LC_ScrapOutside.configurations[currentIndex].minScrapToSpawn > LC_ScrapOutside.configurations[currentIndex].maxScrapToSpawn)
			{
				LC_ScrapOutside.Logger.LogWarning((object)"MinScrapToSpawn was smaller than MaxScrapToSpawn. Please readjust your configuration.");
				LC_ScrapOutside.configurations[currentIndex].minScrapToSpawn = LC_ScrapOutside.configurations[currentIndex].maxScrapToSpawn;
				LC_ScrapOutside.Logger.LogWarning((object)("MinScrapToSpawn for " + LC_ScrapOutside.configurations[currentIndex].name + " was replaced with MaxScrapToSpawn to avoid errors."));
			}
			if (LC_ScrapOutside.configurations[currentIndex].randomScrapMin > LC_ScrapOutside.configurations[currentIndex].randomScrapMax)
			{
				LC_ScrapOutside.Logger.LogWarning((object)"RandomScrapMin was smaller than RandomScrapMax. Please readjust your configuration.");
				LC_ScrapOutside.configurations[currentIndex].randomScrapMin = LC_ScrapOutside.configurations[currentIndex].randomScrapMax;
				LC_ScrapOutside.Logger.LogWarning((object)("RandomScrapMin for " + LC_ScrapOutside.configurations[currentIndex].name + " was replaced with RandomScrapMax to avoid errors."));
			}
			int scrapSpawnAmount = GetScrapSpawnAmount();
			if (scrapSpawnAmount <= 0)
			{
				LC_ScrapOutside.Logger.LogInfo((object)"No scrap to spawn outside.");
				return;
			}
			LC_ScrapOutside.Logger.LogInfo((object)$"Spawning {scrapSpawnAmount} scrap objects outside.");
			List<Item> list = SelectScrap(scrapSpawnAmount);
			if (list.Count == 0)
			{
				LC_ScrapOutside.Logger.LogWarning((object)"No scrap was selected. Outside scrap cannot be spawned.");
				return;
			}
			List<int> list2 = new List<int>();
			List<NetworkObjectReference> list3 = new List<NetworkObjectReference>();
			List<Vector3> list4 = new List<Vector3>();
			float maxRadius = 0f;
			switch (LC_ScrapOutside.configurations[currentIndex].spawnPositions)
			{
			case SpawnPositions.OutsideNodes:
				list4 = (from n in GameObject.FindGameObjectsWithTag("OutsideAINode")
					select n.transform.position).ToList();
				break;
			case SpawnPositions.NodesNearEntrances:
			{
				maxRadius = LC_ScrapOutside.configurations[currentIndex].spawnRadiusAroundEntrances * LC_ScrapOutside.configurations[currentIndex].spawnRadiusAroundEntrances;
				list4 = (from n in GameObject.FindGameObjectsWithTag("OutsideAINode")
					select n.transform.position).ToList();
				List<Vector3> Entrances = (from e in Object.FindObjectsByType<EntranceTeleport>((FindObjectsSortMode)0)
					where e.isEntranceToBuilding
					select ((Component)e).transform.position).ToList();
				list4 = list4.Where((Vector3 node) => Entrances.Any(delegate(Vector3 e)
				{
					//IL_0001: Unknown result type (might be due to invalid IL or missing references)
					//IL_0006: 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_000c: Unknown result type (might be due to invalid IL or missing references)
					Vector3 val3 = node - e;
					return ((Vector3)(ref val3)).sqrMagnitude <= maxRadius;
				})).ToList();
				break;
			}
			case SpawnPositions.NodesNearMain:
			{
				maxRadius = LC_ScrapOutside.configurations[currentIndex].spawnRadiusAroundEntrances * LC_ScrapOutside.configurations[currentIndex].spawnRadiusAroundEntrances;
				list4 = (from n in GameObject.FindGameObjectsWithTag("OutsideAINode")
					select n.transform.position).ToList();
				EntranceTeleport[] EntranceTeleports = Object.FindObjectsByType<EntranceTeleport>((FindObjectsSortMode)0);
				int i2;
				for (i2 = 0; i2 < EntranceTeleports.Length; i2++)
				{
					if (EntranceTeleports[i2].entranceId == 0)
					{
						list4 = list4.Where(delegate(Vector3 node)
						{
							//IL_0000: Unknown result type (might be due to invalid IL or missing references)
							//IL_0018: Unknown result type (might be due to invalid IL or missing references)
							//IL_001d: 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)
							Vector3 val3 = node - ((Component)EntranceTeleports[i2]).transform.position;
							return ((Vector3)(ref val3)).sqrMagnitude <= maxRadius;
						}).ToList();
						break;
					}
				}
				break;
			}
			case SpawnPositions.CustomList:
				list4 = ParseCoordinateList(LC_ScrapOutside.configurations[currentIndex].customPositions);
				break;
			}
			if (list4.Count <= 0)
			{
				LC_ScrapOutside.Logger.LogWarning((object)"No outside nodes found. Outside scrap cannot be spawned.");
				return;
			}
			for (int num = 0; num < list.Count; num++)
			{
				Vector3 val = default(Vector3);
				val = ((!(LC_ScrapOutside.configurations[currentIndex].spawnRadius > 0f)) ? list4[Random.Range(0, list4.Count)] : RoundManager.Instance.GetRandomNavMeshPositionInBoxPredictable(list4[Random.Range(0, list4.Count)], 10f, RoundManager.Instance.navHit, random, -1, 1f));
				GameObject val2 = Object.Instantiate<GameObject>(list[num].spawnPrefab, val + Vector3.up * list[num].verticalOffset, Quaternion.identity, RoundManager.Instance.spawnedScrapContainer);
				GrabbableObject component = val2.GetComponent<GrabbableObject>();
				((Component)component).transform.rotation = Quaternion.Euler(component.itemProperties.restingRotation);
				component.fallTime = 0f;
				list2.Add((int)((float)Random.Range(list[num].minValue, list[num].maxValue) * RoundManager.Instance.scrapValueMultiplier));
				component.scrapValue = list2[list2.Count - 1];
				NetworkObject component2 = val2.GetComponent<NetworkObject>();
				component2.Spawn(false);
				list3.Add(NetworkObjectReference.op_Implicit(component2));
				outsideScrapSpawned++;
			}
			List<NetworkObjectReference> list5 = spawnedScrap.ToList();
			List<int> list6 = scrapValues.ToList();
			for (int num2 = 0; num2 < list3.Count; num2++)
			{
				list5.Add(list3[num2]);
				list6.Add(list2[num2]);
			}
			spawnedScrap = list5.ToArray();
			scrapValues = list6.ToArray();
			totalOutsideScrapSpawned += outsideScrapSpawned;
			int num3 = list2.Sum();
			totalValueOutside += num3;
			if (LC_ScrapOutside.announceInChat.Value && Object.op_Implicit((Object)(object)HUDManager.Instance))
			{
				if (outsideScrapSpawned == 0)
				{
					LC_ScrapOutside.Logger.LogWarning((object)"Got to the end of the scrap spawn function with no scrap spawned! Displaying warning in chat.");
					HUDManager.Instance.AddTextToChatOnServer("Error spawning outside scrap! Check logs.", -1);
				}
				else
				{
					AddAnnouncementMessage(outsideScrapSpawned, num3, totalOutsideScrapSpawned, totalValueOutside);
				}
			}
			outsideScrapSpawned = 0;
		}

		internal static void AddAnnouncementMessage(int count, int value, int totalCount, int totalValue)
		{
			HUDManager.Instance.AddTextToChatOnServer(LC_ScrapOutside.announcementMessage.Value.Replace("&#", count.ToString()).Replace("&$", value.ToString()).Replace("&=", totalCount.ToString())
				.Replace("&%", totalValue.ToString()), -1);
		}

		internal static List<Item> SelectScrap(int amount)
		{
			Random random = new Random(StartOfRound.Instance.randomMapSeed + 64208);
			List<Item> list = new List<Item>();
			List<int> list2 = new List<int>();
			switch (LC_ScrapOutside.configurations[currentIndex].scrapType)
			{
			case ScrapType.FromMoon:
			{
				for (int k = 0; k < RoundManager.Instance.currentLevel.spawnableScrap.Count; k++)
				{
					list2.Add(RoundManager.Instance.currentLevel.spawnableScrap[k].rarity);
				}
				for (int l = 0; l < amount; l++)
				{
					list.Add(RoundManager.Instance.currentLevel.spawnableScrap[RoundManager.Instance.GetRandomWeightedIndex(list2.ToArray(), random)].spawnableItem);
				}
				break;
			}
			case ScrapType.CustomList:
			{
				List<WeightedItem> list3 = ParseItemWeights(LC_ScrapOutside.configurations[currentIndex].scrapToSpawn);
				for (int i = 0; i < list3.Count; i++)
				{
					list2.Add(list3[i].Rarity);
				}
				for (int j = 0; j < amount; j++)
				{
					Item item = GetItem(list3[RoundManager.Instance.GetRandomWeightedIndex(list2.ToArray(), random)].Name);
					if ((Object)(object)item == (Object)null)
					{
						LC_ScrapOutside.Logger.LogError((object)("Item reference was null! " + ((LC_ScrapOutside.configurations[currentIndex].scrapType == ScrapType.CustomList) ? "Item couldn't be found using the parsed custom items list." : "Item couldn't be fetched from the moon's spawnable scrap list.") + " Skipping one item and continuing..."));
					}
					else
					{
						list.Add(item);
					}
				}
				break;
			}
			}
			return list;
		}

		internal static int GetScrapSpawnAmount()
		{
			float num = 0f;
			switch (LC_ScrapOutside.configurations[currentIndex].scrapCountAlgorithm)
			{
			case Algorithm.Static:
				num = GetStaticScrapAmount();
				break;
			case Algorithm.Random:
				num = GetRandomScrapAmount();
				break;
			case Algorithm.Dynamic:
				num = GetDynamicScrapAmount();
				break;
			}
			if (LC_ScrapOutside.luckyRoll.Value)
			{
				if (luck > 0f)
				{
					LC_ScrapOutside.Logger.LogDebug((object)"Luck value was above 0. LuckyRoll will be checked.");
					Random random = new Random(StartOfRound.Instance.randomMapSeed + 6892);
					if ((double)(Mathf.Clamp(luck, 0f, LC_ScrapOutside.maxLuckyLuck.Value) * LC_ScrapOutside.maxLuckyChance.Value / LC_ScrapOutside.maxLuckyLuck.Value) > random.NextDouble())
					{
						LC_ScrapOutside.Logger.LogDebug((object)"Luck check passed! Scrap amount will be multiplied.");
						num *= LC_ScrapOutside.luckyRollMultiplier.Value;
						LC_ScrapOutside.Logger.LogDebug((object)$"Scrap amount after LuckyRoll: {num}");
					}
					else
					{
						LC_ScrapOutside.Logger.LogDebug((object)"No LuckyRoll this time!");
					}
				}
				else
				{
					LC_ScrapOutside.Logger.LogDebug((object)"Luck value was not above 0. LuckyRoll check skipped.");
				}
			}
			return Mathf.RoundToInt(num);
		}

		internal static int GetStaticScrapAmount()
		{
			if (LC_ScrapOutside.configurations[currentIndex].staticScrapToSpawn < 0)
			{
				return 0;
			}
			return LC_ScrapOutside.configurations[currentIndex].staticScrapToSpawn;
		}

		internal static int GetRandomScrapAmount()
		{
			Random random = new Random(StartOfRound.Instance.randomMapSeed + 64914);
			return random.Next(LC_ScrapOutside.configurations[currentIndex].randomScrapMin, LC_ScrapOutside.configurations[currentIndex].randomScrapMax + 1);
		}

		[MethodImpl(MethodImplOptions.NoOptimization)]
		internal static float GetDynamicScrapAmount()
		{
			float num = 1f;
			LC_ScrapOutside.Logger.LogDebug((object)$"Multiplier at Start: {num}");
			if (LC_ScrapOutside.configurations[currentIndex].scaleScrapByLuck)
			{
				num *= luck * LC_ScrapOutside.configurations[currentIndex].luckMultiplier + 1f;
				LC_ScrapOutside.Logger.LogDebug((object)$"Multiplier after luckBasedScrapMultiplier: {num}");
			}
			if (LC_ScrapOutside.configurations[currentIndex].scaleScrapByQuota)
			{
				num *= Mathf.Pow(LC_ScrapOutside.configurations[currentIndex].inverseQuotaBasedMultiplier ? ((float)LC_ScrapOutside.configurations[currentIndex].baselineQuotaValue / (float)TimeOfDay.Instance.profitQuota) : ((float)TimeOfDay.Instance.profitQuota / (float)LC_ScrapOutside.configurations[currentIndex].baselineQuotaValue), LC_ScrapOutside.configurations[currentIndex].quotaValueMultiplierScalar);
				LC_ScrapOutside.Logger.LogDebug((object)$"Multiplier after quotaBasedScrapMultiplier: {num}");
			}
			if (LC_ScrapOutside.configurations[currentIndex].scaleScrapByMoonScrapAmount)
			{
				float num2 = (RoundManager.Instance.currentLevel.maxScrap + RoundManager.Instance.currentLevel.minScrap) / 2;
				num *= Mathf.Pow(num2 / LC_ScrapOutside.configurations[currentIndex].baselineMoonScrapAmount, LC_ScrapOutside.configurations[currentIndex].moonScrapAmountDifferenceScalar);
				LC_ScrapOutside.Logger.LogDebug((object)$"Multiplier after moonScrapAmountBasedMultiplier: {num}");
			}
			if (LC_ScrapOutside.configurations[currentIndex].scaleScrapByWeather)
			{
				Dictionary<string, float> weatherMultipliersDict = GetWeatherMultipliersDict();
				if (weatherMultipliersDict != null)
				{
					if (weatherMultipliersDict.TryGetValue(((object)Unsafe.As<LevelWeatherType, LevelWeatherType>(ref RoundManager.Instance.currentLevel.currentWeather)/*cast due to .constrained prefix*/).ToString().ToLowerInvariant(), out var value))
					{
						num *= value;
					}
					else
					{
						LC_ScrapOutside.Logger.LogWarning((object)("Couldn't get weather multiplier for " + ((object)Unsafe.As<LevelWeatherType, LevelWeatherType>(ref RoundManager.Instance.currentLevel.currentWeather)/*cast due to .constrained prefix*/).ToString().ToLower() + ". weathername:multiplier not found in config."));
					}
				}
				LC_ScrapOutside.Logger.LogDebug((object)$"Multiplier after weatherBasedMultiplier: {num}");
			}
			if (LC_ScrapOutside.configurations[currentIndex].applyRandomVariance)
			{
				num *= GetExtraVariance();
				LC_ScrapOutside.Logger.LogDebug((object)$"Multiplier after extraVariance: {num}");
			}
			return Mathf.Clamp(LC_ScrapOutside.configurations[currentIndex].dynamicBaseScrapAmount * num, (float)LC_ScrapOutside.configurations[currentIndex].minScrapToSpawn, (float)LC_ScrapOutside.configurations[currentIndex].maxScrapToSpawn);
		}

		internal static float GetExtraVariance()
		{
			Random random = new Random(StartOfRound.Instance.randomMapSeed + 35121);
			return (float)random.NextDouble() * (LC_ScrapOutside.configurations[currentIndex].randomVarianceMax - LC_ScrapOutside.configurations[currentIndex].randomVarianceMin) + LC_ScrapOutside.configurations[currentIndex].randomVarianceMin;
		}

		internal static Dictionary<string, float>? GetWeatherMultipliersDict()
		{
			try
			{
				Dictionary<string, float> dictionary = new Dictionary<string, float>();
				string[] array = LC_ScrapOutside.configurations[currentIndex].weatherMultipliers.Split(',');
				if (array.Length == 0)
				{
					return null;
				}
				string[] array2 = array;
				foreach (string text in array2)
				{
					string[] array3 = text.Split(":");
					if (array3.Length == 2)
					{
						if (float.TryParse(array3[1].Trim(), out var result))
						{
							dictionary.Add(array3[0].Trim().ToLowerInvariant(), result);
						}
						else
						{
							LC_ScrapOutside.Logger.LogError((object)("Couldn't parse weather multiplier. Make sure your input is written correctly. Problematic input: " + text));
						}
					}
				}
				return dictionary;
			}
			catch (Exception ex)
			{
				LC_ScrapOutside.Logger.LogError((object)("Failed to get weather multipliers: " + ex.Message));
				return null;
			}
		}

		internal static float CalculateLuckValue()
		{
			if (LC_ScrapOutside.useInternalLuckValue.Value)
			{
				return TimeOfDay.Instance.luckValue;
			}
			float num = 0f;
			List<int> list = new List<int>();
			AutoParentToShip[] array = Object.FindObjectsByType<AutoParentToShip>((FindObjectsSortMode)0);
			for (int i = 0; i < array.Length; i++)
			{
				if (array[i].unlockableID != -1 && StartOfRound.Instance.unlockablesList.unlockables[array[i].unlockableID].spawnPrefab)
				{
					list.Add(array[i].unlockableID);
				}
			}
			for (int j = 0; j < list.Count; j++)
			{
				if (list[j] > StartOfRound.Instance.unlockablesList.unlockables.Count)
				{
					LC_ScrapOutside.Logger.LogWarning((object)$"'Lucky' furniture with id {list[j]} exceeded the unlockables list size; skipping");
				}
				num = Mathf.Clamp(num + StartOfRound.Instance.unlockablesList.unlockables[list[j]].luckValue, -1f, 10f);
			}
			LC_ScrapOutside.Logger.LogDebug((object)$"Luck calculated: {num}");
			return num;
		}

		private static List<WeightedItem> ParseItemWeights(string s)
		{
			List<WeightedItem> list = new List<WeightedItem>();
			try
			{
				string[] array = s.Split(',');
				for (int i = 0; i < array.Length; i++)
				{
					string[] array2 = array[i].Split(":");
					int result;
					if (array2.Length != 2)
					{
						LC_ScrapOutside.Logger.LogError((object)$"Couldn't parse custom item weight input. Follow the example in the config description. Problematic input: {array}");
					}
					else if (int.TryParse(array2[1], out result))
					{
						WeightedItem item = new WeightedItem
						{
							Name = array2[0].Trim().ToLowerInvariant(),
							Rarity = result
						};
						list.Add(item);
					}
					else
					{
						LC_ScrapOutside.Logger.LogError((object)$"Couldn't parse integer from {array}. Please follow the example in the config description.");
					}
				}
			}
			catch (Exception ex)
			{
				LC_ScrapOutside.Logger.LogError((object)("An exception occured while parsing item weights! Make sure your configuration for custom scrap spawns is correct. " + ex.Message));
			}
			return list;
		}

		private static Item? GetItem(string s)
		{
			for (int i = 0; i < StartOfRound.Instance.allItemsList.itemsList.Count; i++)
			{
				if (s == StartOfRound.Instance.allItemsList.itemsList[i].itemName.ToLowerInvariant())
				{
					return StartOfRound.Instance.allItemsList.itemsList[i];
				}
			}
			LC_ScrapOutside.Logger.LogError((object)("Couldn't match string '" + s + "' to any item. Make sure you've written the name of the item correctly."));
			return null;
		}

		private static List<Vector3> ParseCoordinateList(string s)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			List<Vector3> list = new List<Vector3>();
			try
			{
				string[] array = s.Split(';');
				for (int i = 0; i < array.Length; i++)
				{
					list.Add(ParseVector3FromString(array[i].Trim()));
				}
			}
			catch (Exception ex)
			{
				LC_ScrapOutside.Logger.LogError((object)("Something went wrong while trying to parse list of coordinates. " + ex.Message));
			}
			return list;
		}

		private static Vector3 ParseVector3FromString(string s)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				string[] array = s.Split(',');
				return new Vector3(float.Parse(array[0].Trim(), CultureInfo.InvariantCulture), float.Parse(array[1].Trim(), CultureInfo.InvariantCulture), float.Parse(array[2].Trim(), CultureInfo.InvariantCulture));
			}
			catch (IndexOutOfRangeException ex)
			{
				LC_ScrapOutside.Logger.LogError((object)("Specified string could not be parsed for a Vector3. Please use the correct format. Example: '-14.6,4.6,0' " + ex.Message));
			}
			catch (ArgumentOutOfRangeException ex2)
			{
				LC_ScrapOutside.Logger.LogError((object)("Specified string could not be parsed for a Vector3. Please use the correct format. Example: '-14.6,4.6,0' " + ex2.Message));
			}
			catch (ArgumentNullException ex3)
			{
				LC_ScrapOutside.Logger.LogError((object)("ArgumentNullException while trying to parse Vector3. " + ex3.Message));
			}
			catch (FormatException ex4)
			{
				LC_ScrapOutside.Logger.LogError((object)("FormatException while trying to parse Vector3. " + ex4.Message));
			}
			return default(Vector3);
		}
	}
}