Decompiled source of UsualScrap v1.9.8

UsualScrap.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using Dawn;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;
using UsualScrap.Behaviors;
using UsualScrap.Behaviors.Effects;
using UsualScrap.NetcodePatcher;

[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("UsualScrap")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Adds many new unique items that expand on the available scrap items and interactions!")]
[assembly: AssemblyFileVersion("1.9.8.0")]
[assembly: AssemblyInformationalVersion("1.9.8")]
[assembly: AssemblyProduct("UsualScrap")]
[assembly: AssemblyTitle("UsualScrap")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.9.8.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
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 UsualScrap
{
	[BepInPlugin("Emil.UsualScrap", "UsualScrap", "1.9.8")]
	public class Plugin : BaseUnityPlugin
	{
		public static class ScrapPackKeys
		{
			public static NamespacedKey<DawnItemInfo> US_PocketWatch = NamespacedKey<DawnItemInfo>.From("Usual_Scrap", "US_Pocket_Watch");

			public static NamespacedKey<DawnItemInfo> US_ServantBell = NamespacedKey<DawnItemInfo>.From("Usual_Scrap", "US_Servant_Bell");

			public static NamespacedKey<DawnItemInfo> US_ChessPieces = NamespacedKey<DawnItemInfo>.From("Usual_Scrap", "US_Chess_Pieces");

			public static NamespacedKey<DawnItemInfo> US_GoldenChessPieces = NamespacedKey<DawnItemInfo>.From("Usual_Scrap", "US_Golden_Chess_Pieces");

			public static NamespacedKey<DawnItemInfo> US_TrafficCone = NamespacedKey<DawnItemInfo>.From("Usual_Scrap", "US_Traffic_Cone");

			public static NamespacedKey<DawnItemInfo> US_MereGear = NamespacedKey<DawnItemInfo>.From("Usual_Scrap", "US_Mere_Gear");
		}

		public static class ScrapItemKeys
		{
			public static NamespacedKey<DawnItemInfo> US_Ticket = NamespacedKey<DawnItemInfo>.From("Usual_Scrap", "US_Ticket");

			public static NamespacedKey<DawnItemInfo> US_GoldenTicket = NamespacedKey<DawnItemInfo>.From("Usual_Scrap", "US_Golden_Ticket");

			public static NamespacedKey<DawnItemInfo> US_Rose = NamespacedKey<DawnItemInfo>.From("Usual_Scrap", "US_Rose");

			public static NamespacedKey<DawnItemInfo> US_SizableScissors = NamespacedKey<DawnItemInfo>.From("Usual_Scrap", "US_SizableScissors");

			public static NamespacedKey<DawnItemInfo> US_WalkingCane = NamespacedKey<DawnItemInfo>.From("Usual_Scrap", "US_Walking_Cane");

			public static NamespacedKey<DawnItemInfo> US_CandyDispenser = NamespacedKey<DawnItemInfo>.From("Usual_Scrap", "US_Candy_Dispenser");

			public static NamespacedKey<DawnItemInfo> US_PieceofCandy = NamespacedKey<DawnItemInfo>.From("Usual_Scrap", "US_Piece_of_Candy");

			public static NamespacedKey<DawnItemInfo> US_FuelCylinder = NamespacedKey<DawnItemInfo>.From("Usual_Scrap", "US_Fuel_Cylinder");

			public static NamespacedKey<DawnItemInfo> US_RadioactiveCell = NamespacedKey<DawnItemInfo>.From("Usual_Scrap", "US_Radioactive_Cell");

			public static NamespacedKey<DawnItemInfo> US_GloomyCapsule = NamespacedKey<DawnItemInfo>.From("Usual_Scrap", "US_Gloomy_Capsule");

			public static NamespacedKey<DawnItemInfo> US_FrigidCapsule = NamespacedKey<DawnItemInfo>.From("Usual_Scrap", "US_Frigid_Capsule");

			public static NamespacedKey<DawnItemInfo> US_BloodyCapsule = NamespacedKey<DawnItemInfo>.From("Usual_Scrap", "US_Bloody_Capsule");

			public static NamespacedKey<DawnItemInfo> US_Padlock = NamespacedKey<DawnItemInfo>.From("Usual_Scrap", "US_Padlock");

			public static NamespacedKey<DawnItemInfo> US_Crowbar = NamespacedKey<DawnItemInfo>.From("Usual_Scrap", "US_Crowbar");
		}

		public static class StoreItemKeys
		{
			public static NamespacedKey<DawnItemInfo> US_HandLamp = NamespacedKey<DawnItemInfo>.From("Usual_Scrap", "US_Hand_Lamp");

			public static NamespacedKey<DawnItemInfo> US_Bandages = NamespacedKey<DawnItemInfo>.From("Usual_Scrap", "US_Bandages");

			public static NamespacedKey<DawnItemInfo> US_MedicalKit = NamespacedKey<DawnItemInfo>.From("Usual_Scrap", "US_Medical_Kit");

			public static NamespacedKey<DawnItemInfo> US_Defibrillator = NamespacedKey<DawnItemInfo>.From("Usual_Scrap", "US_Defibrillator");

			public static NamespacedKey<DawnItemInfo> US_ProductivityAutoinjector = NamespacedKey<DawnItemInfo>.From("Usual_Scrap", "US_Productivity_Autoinjector");

			public static NamespacedKey<DawnItemInfo> US_ShiftController = NamespacedKey<DawnItemInfo>.From("Usual_Scrap", "US_Shift_Controller");

			public static NamespacedKey<DawnItemInfo> US_Toolkit = NamespacedKey<DawnItemInfo>.From("Usual_Scrap", "US_Toolkit");
		}

		public const string PLUGIN_GUID = "Emil.UsualScrap";

		public const string PLUGIN_NAME = "UsualScrap";

		public const string PLUGIN_VERSION = "1.9.8";

		public static Plugin instance;

		internal static UsualScrapConfigs BoundConfig { get; private set; }

		public void InitializeItem(GrabbableObject itemScript, bool grabbable, bool grabbableToEnemies, Item itemProperties)
		{
			DawnLib.RegisterNetworkPrefab(itemProperties.spawnPrefab);
			Utilities.FixMixerGroups(itemProperties.spawnPrefab);
			itemScript.grabbable = grabbable;
			itemScript.grabbableToEnemies = grabbableToEnemies;
			itemScript.itemProperties = itemProperties;
		}

		public void Awake()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
			List<Item> list = new List<Item>();
			instance = this;
			BoundConfig = new UsualScrapConfigs(((BaseUnityPlugin)this).Config);
			new UsualScrapConfigs(((BaseUnityPlugin)this).Config);
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "usualscrapassetbundle"));
			if (BoundConfig.MansionScrapPackEnabled.Value)
			{
				try
				{
					Item val2 = val.LoadAsset<Item>("Assets/UsualScrapContent/ScrapPackItems/PocketWatchAssets/US_PocketWatchItem.asset");
					list.Add(val2);
					PhysicsProp itemScript = val2.spawnPrefab.AddComponent<PhysicsProp>();
					InitializeItem((GrabbableObject)(object)itemScript, grabbable: true, grabbableToEnemies: true, val2);
					DawnLib.DefineItem(ScrapPackKeys.US_PocketWatch, val2, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
					{
						builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
						{
							scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
							{
								weightBuilder.SetGlobalWeight(15);
							});
						});
					});
				}
				catch
				{
					Debug.LogError((object)"USUAL SCRAP - Pocket Watch scrap pack item experienced an error while loading. Skipping...");
				}
				try
				{
					Item val3 = val.LoadAsset<Item>("Assets/UsualScrapContent/ScrapPackItems/ServantBellAssets/US_ServantBellItem.asset");
					list.Add(val3);
					NoiseMakerScript itemScript2 = val3.spawnPrefab.AddComponent<NoiseMakerScript>();
					InitializeItem((GrabbableObject)(object)itemScript2, grabbable: true, grabbableToEnemies: true, val3);
					DawnLib.DefineItem(ScrapPackKeys.US_ServantBell, val3, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
					{
						builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
						{
							scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
							{
								weightBuilder.SetGlobalWeight(20);
							});
						});
					});
				}
				catch
				{
					Debug.LogError((object)"USUAL SCRAP - Servant Bell scrap pack item experienced an error while loading. Skipping...");
				}
				try
				{
					Item val4 = val.LoadAsset<Item>("Assets/UsualScrapContent/ScrapPackItems/ChessPiecesAssets/US_ChessPiecesItem.asset");
					list.Add(val4);
					RandomModelBNWScript randomModelBNWScript = val4.spawnPrefab.AddComponent<RandomModelBNWScript>();
					randomModelBNWScript.changeColor = true;
					InitializeItem((GrabbableObject)(object)randomModelBNWScript, grabbable: true, grabbableToEnemies: true, val4);
					DawnLib.DefineItem(ScrapPackKeys.US_ChessPieces, val4, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
					{
						builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
						{
							scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
							{
								weightBuilder.SetGlobalWeight(30);
							});
						});
					});
				}
				catch
				{
					Debug.LogError((object)"USUAL SCRAP - Chess Pieces scrap pack item experienced an error while loading. Skipping...");
				}
				try
				{
					Item val5 = val.LoadAsset<Item>("Assets/UsualScrapContent/ScrapPackItems/GoldenChessPiecesAssets/US_GoldenChessPiecesItem.asset");
					list.Add(val5);
					RandomModelBNWScript randomModelBNWScript2 = val5.spawnPrefab.AddComponent<RandomModelBNWScript>();
					randomModelBNWScript2.changeColor = false;
					InitializeItem((GrabbableObject)(object)randomModelBNWScript2, grabbable: true, grabbableToEnemies: true, val5);
					DawnLib.DefineItem(ScrapPackKeys.US_GoldenChessPieces, val5, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
					{
						builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
						{
							scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
							{
								weightBuilder.SetGlobalWeight(10);
							});
						});
					});
				}
				catch
				{
					Debug.LogError((object)"USUAL SCRAP - Golden Chess Pieces scrap pack item experienced an error while loading. Skipping...");
				}
			}
			if (BoundConfig.FacilityScrapPackEnabled.Value)
			{
				try
				{
					Item val6 = val.LoadAsset<Item>("Assets/UsualScrapContent/ScrapPackItems/TrafficConeAssets/US_TrafficConeItem.asset");
					list.Add(val6);
					PhysicsProp itemScript3 = val6.spawnPrefab.AddComponent<PhysicsProp>();
					InitializeItem((GrabbableObject)(object)itemScript3, grabbable: true, grabbableToEnemies: true, val6);
					DawnLib.DefineItem(ScrapPackKeys.US_TrafficCone, val6, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
					{
						builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
						{
							scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
							{
								weightBuilder.SetGlobalWeight(20);
							});
						});
					});
				}
				catch
				{
					Debug.LogError((object)"USUAL SCRAP - Traffic Cone scrap pack item experienced an error while loading. Skipping...");
				}
				try
				{
					Item val7 = val.LoadAsset<Item>("Assets/UsualScrapContent/ScrapPackItems/MereGearAssets/US_MereGearItem.asset");
					list.Add(val7);
					PhysicsProp itemScript4 = val7.spawnPrefab.AddComponent<PhysicsProp>();
					InitializeItem((GrabbableObject)(object)itemScript4, grabbable: true, grabbableToEnemies: true, val7);
					DawnLib.DefineItem(ScrapPackKeys.US_MereGear, val7, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
					{
						builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
						{
							scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
							{
								weightBuilder.SetGlobalWeight(30);
							});
						});
					});
				}
				catch
				{
					Debug.LogError((object)"USUAL SCRAP - Mere Gear scrap pack item experienced an error while loading. Skipping...");
				}
			}
			try
			{
				if (BoundConfig.TicketLoaded.Value)
				{
					Item US_Ticket = val.LoadAsset<Item>("Assets/UsualScrapContent/Items/TicketAssets/US_TicketItem.asset");
					list.Add(US_Ticket);
					TicketScript itemScript5 = US_Ticket.spawnPrefab.AddComponent<TicketScript>();
					InitializeItem((GrabbableObject)(object)itemScript5, grabbable: true, grabbableToEnemies: true, US_Ticket);
					if (BoundConfig.TicketSpawnsAsScrap.Value)
					{
						string[] ticketMoonStrings = BoundConfig.TicketMoonSpawnWeights.Value.Split(',');
						DawnLib.DefineItem(ScrapItemKeys.US_Ticket, US_Ticket, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
						{
							builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
							{
								scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
								{
									buildweights(weightBuilder, ticketMoonStrings, BoundConfig.TicketGlobalSpawnWeight.Value, US_Ticket);
								});
							});
						});
					}
					else
					{
						Items.RegisterItem(US_Ticket);
					}
				}
			}
			catch
			{
				Debug.LogError((object)"USUAL SCRAP - Ticket experienced an error while loading. Skipping...");
			}
			try
			{
				if (BoundConfig.GoldenTicketLoaded.Value)
				{
					Item US_GoldenTicket = val.LoadAsset<Item>("Assets/UsualScrapContent/Items/GoldenTicketAssets/US_GoldenTicketItem.asset");
					list.Add(US_GoldenTicket);
					GoldenTicketScript itemScript6 = US_GoldenTicket.spawnPrefab.AddComponent<GoldenTicketScript>();
					InitializeItem((GrabbableObject)(object)itemScript6, grabbable: true, grabbableToEnemies: true, US_GoldenTicket);
					if (BoundConfig.GoldenTicketSpawnsAsScrap.Value)
					{
						string[] goldenTicketMoonStrings = BoundConfig.GoldenTicketMoonSpawnWeights.Value.Split(',');
						DawnLib.DefineItem(ScrapItemKeys.US_GoldenTicket, US_GoldenTicket, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
						{
							builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
							{
								scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
								{
									buildweights(weightBuilder, goldenTicketMoonStrings, BoundConfig.GoldenTicketGlobalSpawnWeight.Value, US_GoldenTicket);
								});
							});
						});
					}
					else
					{
						Items.RegisterItem(US_GoldenTicket);
					}
				}
			}
			catch
			{
				Debug.LogError((object)"USUAL SCRAP - Golden Ticket experienced an error while loading. Skipping...");
			}
			try
			{
				if (BoundConfig.RoseLoaded.Value)
				{
					Item US_Rose = val.LoadAsset<Item>("Assets/UsualScrapContent/Items/RoseAssets/US_RoseItem.asset");
					list.Add(US_Rose);
					RoseScript itemScript7 = US_Rose.spawnPrefab.AddComponent<RoseScript>();
					InitializeItem((GrabbableObject)(object)itemScript7, grabbable: true, grabbableToEnemies: true, US_Rose);
					if (BoundConfig.RoseSpawnsAsScrap.Value)
					{
						string[] roseMoonStrings = BoundConfig.RoseMoonSpawnWeights.Value.Split(',');
						DawnLib.DefineItem(ScrapItemKeys.US_Rose, US_Rose, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
						{
							builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
							{
								scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
								{
									buildweights(weightBuilder, roseMoonStrings, BoundConfig.RoseGlobalSpawnWeight.Value, US_Rose);
								});
							});
						});
					}
					else
					{
						Items.RegisterItem(US_Rose);
					}
				}
			}
			catch
			{
				Debug.LogError((object)"USUAL SCRAP - Rose experienced an error while loading. Skipping...");
			}
			try
			{
				if (BoundConfig.SizableScissorsLoaded.Value)
				{
					Item US_SizableScissors = val.LoadAsset<Item>("Assets/UsualScrapContent/Items/SizableScissorsAssets/US_SizableScissorsItem.asset");
					list.Add(US_SizableScissors);
					SizableScissorsScript itemScript8 = US_SizableScissors.spawnPrefab.AddComponent<SizableScissorsScript>();
					InitializeItem((GrabbableObject)(object)itemScript8, grabbable: true, grabbableToEnemies: true, US_SizableScissors);
					if (BoundConfig.SizableScissorsSpawnsAsScrap.Value)
					{
						string[] sizableScissorsMoonStrings = BoundConfig.SizableScissorsMoonSpawnWeights.Value.Split(',');
						DawnLib.DefineItem(ScrapItemKeys.US_SizableScissors, US_SizableScissors, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
						{
							builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
							{
								scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
								{
									buildweights(weightBuilder, sizableScissorsMoonStrings, BoundConfig.SizableScissorsGlobalSpawnWeight.Value, US_SizableScissors);
								});
							});
						});
					}
					else
					{
						Items.RegisterItem(US_SizableScissors);
					}
				}
			}
			catch
			{
				Debug.LogError((object)"USUAL SCRAP - Scissors experienced an error while loading. Skipping...");
			}
			try
			{
				if (BoundConfig.WalkingCaneLoaded.Value)
				{
					Item US_WalkingCane = val.LoadAsset<Item>("Assets/UsualScrapContent/Items/WalkingCaneAssets/US_WalkingCaneItem.asset");
					list.Add(US_WalkingCane);
					WalkingCaneScript itemScript9 = US_WalkingCane.spawnPrefab.AddComponent<WalkingCaneScript>();
					InitializeItem((GrabbableObject)(object)itemScript9, grabbable: true, grabbableToEnemies: true, US_WalkingCane);
					if (BoundConfig.WalkingCaneSpawnsAsScrap.Value)
					{
						string[] walkingCaneMoonStrings = BoundConfig.WalkingCaneMoonSpawnWeights.Value.Split(',');
						DawnLib.DefineItem(ScrapItemKeys.US_WalkingCane, US_WalkingCane, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
						{
							builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
							{
								scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
								{
									buildweights(weightBuilder, walkingCaneMoonStrings, BoundConfig.WalkingCaneGlobalSpawnWeight.Value, US_WalkingCane);
								});
							});
						});
					}
					else
					{
						Items.RegisterItem(US_WalkingCane);
					}
				}
			}
			catch
			{
				Debug.LogError((object)"USUAL SCRAP - Walking Cane experienced an error while loading. Skipping...");
			}
			try
			{
				if (BoundConfig.CandyDispenserLoaded.Value)
				{
					Item US_CandyDispenser = val.LoadAsset<Item>("Assets/UsualScrapContent/Items/CandyDispenserAssets/US_CandyDispenserItem.asset");
					list.Add(US_CandyDispenser);
					CandyDispenserScript itemScript10 = US_CandyDispenser.spawnPrefab.AddComponent<CandyDispenserScript>();
					InitializeItem((GrabbableObject)(object)itemScript10, grabbable: true, grabbableToEnemies: true, US_CandyDispenser);
					Item val8 = val.LoadAsset<Item>("Assets/UsualScrapContent/Items/PieceofCandyAssets/US_PieceofCandyItem.asset");
					list.Add(val8);
					PieceofCandyScript itemScript11 = val8.spawnPrefab.AddComponent<PieceofCandyScript>();
					InitializeItem((GrabbableObject)(object)itemScript11, grabbable: true, grabbableToEnemies: true, val8);
					if (BoundConfig.CandyDispenserSpawnsAsScrap.Value)
					{
						string[] candyDispenserMoonStrings = BoundConfig.CandyDispenserMoonSpawnWeights.Value.Split(',');
						DawnLib.DefineItem(ScrapItemKeys.US_CandyDispenser, US_CandyDispenser, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
						{
							builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
							{
								scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
								{
									buildweights(weightBuilder, candyDispenserMoonStrings, BoundConfig.CandyDispenserGlobalSpawnWeight.Value, US_CandyDispenser);
								});
							});
						});
						DawnLib.DefineItem(ScrapItemKeys.US_PieceofCandy, val8, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
						{
							builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
							{
								scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
								{
									weightBuilder.SetGlobalWeight(0);
								});
							});
						});
					}
					else
					{
						Items.RegisterItem(US_CandyDispenser);
						Items.RegisterItem(val8);
					}
				}
			}
			catch
			{
				Debug.LogError((object)"USUAL SCRAP - Candy Dispenser experienced an error while loading. Skipping...");
			}
			try
			{
				if (BoundConfig.FuelCylinderLoaded.Value)
				{
					Item US_FuelCylinder = val.LoadAsset<Item>("Assets/UsualScrapContent/Items/FuelCylinderAssets/US_FuelCylinderItem.asset");
					list.Add(US_FuelCylinder);
					FuelCylinderScript itemScript12 = US_FuelCylinder.spawnPrefab.AddComponent<FuelCylinderScript>();
					InitializeItem((GrabbableObject)(object)itemScript12, grabbable: true, grabbableToEnemies: true, US_FuelCylinder);
					if (BoundConfig.FuelCylinderSpawnsAsScrap.Value)
					{
						string[] fuelCylinderMoonStrings = BoundConfig.FuelCylinderMoonSpawnWeights.Value.Split(',');
						DawnLib.DefineItem(ScrapItemKeys.US_FuelCylinder, US_FuelCylinder, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
						{
							builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
							{
								scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
								{
									buildweights(weightBuilder, fuelCylinderMoonStrings, BoundConfig.FuelCylinderGlobalSpawnWeight.Value, US_FuelCylinder);
								});
							});
						});
					}
					else
					{
						Items.RegisterItem(US_FuelCylinder);
					}
				}
			}
			catch
			{
				Debug.LogError((object)"USUAL SCRAP - Fuel Cylinder experienced an error while loading. Skipping...");
			}
			try
			{
				if (BoundConfig.RadioactiveCellLoaded.Value)
				{
					Item US_RadioactiveCell = val.LoadAsset<Item>("Assets/UsualScrapContent/Items/RadioactiveCellAssets/US_RadioactiveCellItem.asset");
					list.Add(US_RadioactiveCell);
					RadioactiveCellScript itemScript13 = US_RadioactiveCell.spawnPrefab.AddComponent<RadioactiveCellScript>();
					InitializeItem((GrabbableObject)(object)itemScript13, grabbable: true, grabbableToEnemies: true, US_RadioactiveCell);
					if (BoundConfig.RadioactiveCellSpawnsAsScrap.Value)
					{
						string[] radioactiveCellMoonStrings = BoundConfig.RadioactiveCellMoonSpawnWeights.Value.Split(',');
						DawnLib.DefineItem(ScrapItemKeys.US_RadioactiveCell, US_RadioactiveCell, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
						{
							builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
							{
								scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
								{
									buildweights(weightBuilder, radioactiveCellMoonStrings, BoundConfig.RadioactiveCellGlobalSpawnWeight.Value, US_RadioactiveCell);
								});
							});
						});
					}
					else
					{
						Items.RegisterItem(US_RadioactiveCell);
					}
				}
			}
			catch
			{
				Debug.LogError((object)"USUAL SCRAP - Radioactive Cell experienced an error while loading. Skipping...");
			}
			try
			{
				if (BoundConfig.GloomyCapsuleLoaded.Value)
				{
					Item US_GloomyCapsule = val.LoadAsset<Item>("Assets/UsualScrapContent/Items/GloomyCapsuleAssets/US_GloomyCapsuleItem.asset");
					list.Add(US_GloomyCapsule);
					GloomyCapsuleScript itemScript14 = US_GloomyCapsule.spawnPrefab.AddComponent<GloomyCapsuleScript>();
					InitializeItem((GrabbableObject)(object)itemScript14, grabbable: true, grabbableToEnemies: true, US_GloomyCapsule);
					if (BoundConfig.GloomyCapsuleSpawnsAsScrap.Value)
					{
						string[] gloomyCapsuleMoonStrings = BoundConfig.GloomyCapsuleMoonSpawnWeights.Value.Split(',');
						DawnLib.DefineItem(ScrapItemKeys.US_GloomyCapsule, US_GloomyCapsule, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
						{
							builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
							{
								scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
								{
									buildweights(weightBuilder, gloomyCapsuleMoonStrings, BoundConfig.GloomyCapsuleGlobalSpawnWeight.Value, US_GloomyCapsule);
								});
							});
						});
					}
					else
					{
						Items.RegisterItem(US_GloomyCapsule);
					}
				}
			}
			catch
			{
				Debug.LogError((object)"USUAL SCRAP - Gloomy Capsule experienced an error while loading. Skipping...");
			}
			try
			{
				if (BoundConfig.FrigidCapsuleLoaded.Value)
				{
					Item US_FrigidCapsule = val.LoadAsset<Item>("Assets/UsualScrapContent/Items/FrigidCapsuleAssets/US_FrigidCapsuleItem.asset");
					list.Add(US_FrigidCapsule);
					FrigidCapsuleScript itemScript15 = US_FrigidCapsule.spawnPrefab.AddComponent<FrigidCapsuleScript>();
					InitializeItem((GrabbableObject)(object)itemScript15, grabbable: true, grabbableToEnemies: true, US_FrigidCapsule);
					if (BoundConfig.FrigidCapsuleSpawnsAsScrap.Value)
					{
						string[] frigidCapsuleMoonStrings = BoundConfig.FrigidCapsuleMoonSpawnWeights.Value.Split(',');
						DawnLib.DefineItem(ScrapItemKeys.US_FrigidCapsule, US_FrigidCapsule, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
						{
							builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
							{
								scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
								{
									buildweights(weightBuilder, frigidCapsuleMoonStrings, BoundConfig.FrigidCapsuleGlobalSpawnWeight.Value, US_FrigidCapsule);
								});
							});
						});
					}
					else
					{
						Items.RegisterItem(US_FrigidCapsule);
					}
				}
			}
			catch
			{
				Debug.LogError((object)"USUAL SCRAP - Frigid Capsule experienced an error while loading. Skipping...");
			}
			try
			{
				if (BoundConfig.BloodyCapsuleLoaded.Value)
				{
					Item US_BloodyCapsule = val.LoadAsset<Item>("Assets/UsualScrapContent/Items/BloodyCapsuleAssets/US_BloodyCapsuleItem.asset");
					list.Add(US_BloodyCapsule);
					BloodyCapsuleScript itemScript16 = US_BloodyCapsule.spawnPrefab.AddComponent<BloodyCapsuleScript>();
					InitializeItem((GrabbableObject)(object)itemScript16, grabbable: true, grabbableToEnemies: true, US_BloodyCapsule);
					if (BoundConfig.BloodyCapsuleSpawnsAsScrap.Value)
					{
						string[] bloodyCapsuleMoonStrings = BoundConfig.BloodyCapsuleMoonSpawnWeights.Value.Split(',');
						DawnLib.DefineItem(ScrapItemKeys.US_BloodyCapsule, US_BloodyCapsule, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
						{
							builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
							{
								scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
								{
									buildweights(weightBuilder, bloodyCapsuleMoonStrings, BoundConfig.BloodyCapsuleGlobalSpawnWeight.Value, US_BloodyCapsule);
								});
							});
						});
					}
					else
					{
						Items.RegisterItem(US_BloodyCapsule);
					}
				}
			}
			catch
			{
				Debug.LogError((object)"USUAL SCRAP - Bloody Capsule experienced an error while loading. Skipping...");
			}
			try
			{
				if (BoundConfig.PadlockLoaded.Value)
				{
					Item US_Padlock = val.LoadAsset<Item>("Assets/UsualScrapContent/Items/PadlockAssets/US_PadlockItem.asset");
					list.Add(US_Padlock);
					PadlockScript itemScript17 = US_Padlock.spawnPrefab.AddComponent<PadlockScript>();
					InitializeItem((GrabbableObject)(object)itemScript17, grabbable: true, grabbableToEnemies: true, US_Padlock);
					if (BoundConfig.PadlockSpawnsAsScrap.Value)
					{
						string[] padlockMoonStrings = BoundConfig.PadlockMoonSpawnWeights.Value.Split(',');
						DawnLib.DefineItem(ScrapItemKeys.US_Padlock, US_Padlock, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
						{
							builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
							{
								scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
								{
									buildweights(weightBuilder, padlockMoonStrings, BoundConfig.PadlockGlobalSpawnWeight.Value, US_Padlock);
								});
							});
						});
					}
					else
					{
						Items.RegisterItem(US_Padlock);
					}
				}
			}
			catch
			{
				Debug.LogError((object)"USUAL SCRAP - Padlock experienced an error while loading. Skipping...");
			}
			try
			{
				if (BoundConfig.CrowbarLoaded.Value)
				{
					Item US_Crowbar = val.LoadAsset<Item>("Assets/UsualScrapContent/Items/CrowbarAssets/US_CrowbarItem.asset");
					list.Add(US_Crowbar);
					CrowbarScript itemScript18 = US_Crowbar.spawnPrefab.AddComponent<CrowbarScript>();
					InitializeItem((GrabbableObject)(object)itemScript18, grabbable: true, grabbableToEnemies: true, US_Crowbar);
					if (BoundConfig.CrowbarSpawnsAsScrap.Value)
					{
						string[] crowbarMoonStrings = BoundConfig.CrowbarMoonSpawnWeights.Value.Split(',');
						DawnLib.DefineItem(ScrapItemKeys.US_Crowbar, US_Crowbar, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
						{
							builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
							{
								scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
								{
									buildweights(weightBuilder, crowbarMoonStrings, BoundConfig.CrowbarGlobalSpawnWeight.Value, US_Crowbar);
								});
							});
						});
					}
					else
					{
						Items.RegisterItem(US_Crowbar);
					}
				}
			}
			catch
			{
				Debug.LogError((object)"USUAL SCRAP - Crowbar experienced an error while loading. Skipping...");
			}
			try
			{
				if (BoundConfig.HandlampLoaded.Value)
				{
					Item val9 = val.LoadAsset<Item>("Assets/UsualScrapContent/Items/HandlampAssets/US_HandlampItem.asset");
					list.Add(val9);
					TerminalNode US_HandlampNode = val.LoadAsset<TerminalNode>("Assets/Items/HandlampAssets/US_HandlampNode.asset");
					HandlampScript itemScript19 = val9.spawnPrefab.AddComponent<HandlampScript>();
					InitializeItem((GrabbableObject)(object)itemScript19, grabbable: true, grabbableToEnemies: true, val9);
					if (BoundConfig.HandlampIsStoreItem.Value && BoundConfig.HandlampStorePrice.Value >= 0)
					{
						DawnLib.DefineItem(StoreItemKeys.US_HandLamp, val9, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
						{
							builder.DefineShop((Action<ShopBuilder>)delegate(ShopBuilder shopBuilder)
							{
								shopBuilder.OverrideCost(BoundConfig.HandlampStorePrice.Value).OverrideInfoNode(US_HandlampNode);
							});
						});
					}
				}
			}
			catch
			{
				Debug.LogError((object)"USUAL SCRAP - Handlamp experienced an error while loading. Skipping...");
			}
			try
			{
				if (BoundConfig.BandagesLoaded.Value)
				{
					Item val10 = val.LoadAsset<Item>("Assets/UsualScrapContent/Items/BandagesAssets/US_BandagesItem.asset");
					list.Add(val10);
					TerminalNode US_BandagesNode = val.LoadAsset<TerminalNode>("Assets/Items/BandagesAssets/US_BandagesNode.asset");
					BandagesScript itemScript20 = val10.spawnPrefab.AddComponent<BandagesScript>();
					InitializeItem((GrabbableObject)(object)itemScript20, grabbable: true, grabbableToEnemies: true, val10);
					if (BoundConfig.BandagesIsStoreItem.Value && BoundConfig.BandagesStorePrice.Value >= 0)
					{
						DawnLib.DefineItem(StoreItemKeys.US_Bandages, val10, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
						{
							builder.DefineShop((Action<ShopBuilder>)delegate(ShopBuilder shopBuilder)
							{
								shopBuilder.OverrideCost(BoundConfig.BandagesStorePrice.Value).OverrideInfoNode(US_BandagesNode);
							});
						});
					}
				}
			}
			catch
			{
				Debug.LogError((object)"USUAL SCRAP - Bandages experienced an error while loading. Skipping...");
			}
			try
			{
				if (BoundConfig.MedicalKitLoaded.Value)
				{
					Item val11 = val.LoadAsset<Item>("Assets/UsualScrapContent/Items/MedicalKitAssets/US_MedicalKitItem.asset");
					list.Add(val11);
					TerminalNode US_MedicalKitNode = val.LoadAsset<TerminalNode>("Assets/Items/MedicalKitAssets/US_MedicalKitNode.asset");
					MedicalKitScript itemScript21 = val11.spawnPrefab.AddComponent<MedicalKitScript>();
					InitializeItem((GrabbableObject)(object)itemScript21, grabbable: true, grabbableToEnemies: true, val11);
					if (BoundConfig.MedicalKitIsStoreItem.Value && BoundConfig.MedicalKitStorePrice.Value >= 0)
					{
						DawnLib.DefineItem(StoreItemKeys.US_MedicalKit, val11, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
						{
							builder.DefineShop((Action<ShopBuilder>)delegate(ShopBuilder shopBuilder)
							{
								shopBuilder.OverrideCost(BoundConfig.MedicalKitStorePrice.Value).OverrideInfoNode(US_MedicalKitNode);
							});
						});
					}
				}
			}
			catch
			{
				Debug.LogError((object)"USUAL SCRAP - Medical Kit experienced an error while loading. Skipping...");
			}
			try
			{
				if (BoundConfig.DefibrillatorLoaded.Value)
				{
					Item val12 = val.LoadAsset<Item>("Assets/UsualScrapContent/Items/DefibrillatorAssets/US_DefibrillatorItem.asset");
					list.Add(val12);
					TerminalNode US_DefibrillatorNode = val.LoadAsset<TerminalNode>("Assets/Items/DefibrillatorAssets/US_DefibrillatorNode.asset");
					DefibrillatorScript itemScript22 = val12.spawnPrefab.AddComponent<DefibrillatorScript>();
					InitializeItem((GrabbableObject)(object)itemScript22, grabbable: true, grabbableToEnemies: true, val12);
					if (BoundConfig.DefibrillatorIsStoreItem.Value && BoundConfig.DefibrillatorStorePrice.Value >= 0)
					{
						DawnLib.DefineItem(StoreItemKeys.US_Defibrillator, val12, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
						{
							builder.DefineShop((Action<ShopBuilder>)delegate(ShopBuilder shopBuilder)
							{
								shopBuilder.OverrideCost(BoundConfig.DefibrillatorStorePrice.Value).OverrideInfoNode(US_DefibrillatorNode);
							});
						});
					}
				}
			}
			catch
			{
				Debug.LogError((object)"USUAL SCRAP - Defibrillator experienced an error while loading. Skipping...");
			}
			try
			{
				if (BoundConfig.ProductivityAutoinjectorLoaded.Value)
				{
					Item val13 = val.LoadAsset<Item>("Assets/UsualScrapContent/Items/ProductivityAutoinjectorAssets/US_ProductivityAutoinjectorItem.asset");
					list.Add(val13);
					TerminalNode US_ProductivityAutoinjectorNode = val.LoadAsset<TerminalNode>("Assets/Items/ProductivityAutoinjectorAssets/US_ProductivityAutoinjectorNode.asset");
					ProductivityAutoinjectorScript itemScript23 = val13.spawnPrefab.AddComponent<ProductivityAutoinjectorScript>();
					InitializeItem((GrabbableObject)(object)itemScript23, grabbable: true, grabbableToEnemies: true, val13);
					if (BoundConfig.ProductivityAutoinjectorIsStoreItem.Value && BoundConfig.ProductivityAutoinjectorStorePrice.Value >= 0)
					{
						DawnLib.DefineItem(StoreItemKeys.US_ProductivityAutoinjector, val13, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
						{
							builder.DefineShop((Action<ShopBuilder>)delegate(ShopBuilder shopBuilder)
							{
								shopBuilder.OverrideCost(BoundConfig.ProductivityAutoinjectorStorePrice.Value).OverrideInfoNode(US_ProductivityAutoinjectorNode);
							});
						});
					}
				}
			}
			catch
			{
				Debug.LogError((object)"USUAL SCRAP - Productivity Autoinjector experienced an error while loading. Skipping...");
			}
			try
			{
				if (BoundConfig.ToolkitLoaded.Value)
				{
					Item val14 = val.LoadAsset<Item>("Assets/UsualScrapContent/Items/ToolkitAssets/US_ToolkitItem.asset");
					list.Add(val14);
					TerminalNode US_ToolkitNode = val.LoadAsset<TerminalNode>("Assets/Items/ToolkitAssets/US_ToolkitNode.asset");
					ToolkitScript itemScript24 = val14.spawnPrefab.AddComponent<ToolkitScript>();
					InitializeItem((GrabbableObject)(object)itemScript24, grabbable: true, grabbableToEnemies: true, val14);
					if (BoundConfig.ToolkitIsStoreItem.Value && BoundConfig.ToolkitStorePrice.Value >= 0)
					{
						DawnLib.DefineItem(StoreItemKeys.US_Toolkit, val14, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
						{
							builder.DefineShop((Action<ShopBuilder>)delegate(ShopBuilder shopBuilder)
							{
								shopBuilder.OverrideCost(BoundConfig.ToolkitStorePrice.Value).OverrideInfoNode(US_ToolkitNode);
							});
						});
					}
				}
			}
			catch
			{
				Debug.LogError((object)"USUAL SCRAP - Toolkit experienced an error while loading. Skipping...");
			}
			try
			{
				if (BoundConfig.ShiftControllerLoaded.Value)
				{
					Item val15 = val.LoadAsset<Item>("Assets/UsualScrapContent/Items/ShiftControllerAssets/US_ShiftControllerItem.asset");
					list.Add(val15);
					TerminalNode US_ShiftControllerNode = val.LoadAsset<TerminalNode>("Assets/Items/ShiftControllerAssets/US_ShiftControllerNode.asset");
					ShiftControllerScript itemScript25 = val15.spawnPrefab.AddComponent<ShiftControllerScript>();
					InitializeItem((GrabbableObject)(object)itemScript25, grabbable: true, grabbableToEnemies: true, val15);
					if (BoundConfig.ShiftControllerIsStoreItem.Value && BoundConfig.ShiftControllerStorePrice.Value >= 0)
					{
						DawnLib.DefineItem(StoreItemKeys.US_ShiftController, val15, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
						{
							builder.DefineShop((Action<ShopBuilder>)delegate(ShopBuilder shopBuilder)
							{
								shopBuilder.OverrideCost(BoundConfig.ShiftControllerStorePrice.Value).OverrideInfoNode(US_ShiftControllerNode);
							});
						});
					}
				}
			}
			catch
			{
				Debug.LogError((object)"USUAL SCRAP - Shift Controller experienced an error while loading. Skipping...");
			}
			if (BoundConfig.DisableItemIcons.Value)
			{
				foreach (Item item in list)
				{
					item.itemIcon = null;
				}
			}
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "Emil.UsualScrap");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Emil.UsualScrap is loaded!");
			static void buildweights(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> builder, string[] pulledString, int globalWeight, Item item)
			{
				if (globalWeight >= 0)
				{
					if (BoundConfig.DebugLogging.Value)
					{
						MonoBehaviour.print((object)$"SETTING GLOBAL SPAWN WEIGHT FOR [{item}] TO [{globalWeight}]");
					}
					builder.SetGlobalWeight(globalWeight);
				}
				else if (BoundConfig.DebugLogging.Value)
				{
					MonoBehaviour.print((object)$"GLOBAL SPAWN WEIGHT DISABLED FOR [{item}]");
				}
				foreach (string text in pulledString)
				{
					try
					{
						string[] array3 = text.Split('=');
						string text2 = array3[0].Trim().ToLowerInvariant();
						string s = array3[1].Trim();
						int num = int.Parse(s);
						if (num <= -1)
						{
							if (BoundConfig.DebugLogging.Value)
							{
								MonoBehaviour.print((object)$"{text2} weight skipped for {item}");
							}
						}
						else
						{
							switch (text2)
							{
							case "experimentation":
								builder.AddWeight(MoonKeys.Experimentation, num);
								if (BoundConfig.DebugLogging.Value)
								{
									MonoBehaviour.print((object)$"Setting {item}'s moonWeight to {num} for experimentation");
								}
								break;
							case "vow":
								builder.AddWeight(MoonKeys.Vow, num);
								if (BoundConfig.DebugLogging.Value)
								{
									MonoBehaviour.print((object)$"Setting {item}'s moonWeight to {num} for vow");
								}
								break;
							case "march":
								builder.AddWeight(MoonKeys.March, num);
								if (BoundConfig.DebugLogging.Value)
								{
									MonoBehaviour.print((object)$"Setting {item}'s moonWeight to {num} for march");
								}
								break;
							case "assurance":
								builder.AddWeight(MoonKeys.Assurance, num);
								if (BoundConfig.DebugLogging.Value)
								{
									MonoBehaviour.print((object)$"Setting {item}'s moonWeight to {num} for assurance");
								}
								break;
							case "offense":
								builder.AddWeight(MoonKeys.Offense, num);
								if (BoundConfig.DebugLogging.Value)
								{
									MonoBehaviour.print((object)$"Setting {item}'s moonWeight to {num} for offense");
								}
								break;
							case "rend":
								builder.AddWeight(MoonKeys.Rend, num);
								if (BoundConfig.DebugLogging.Value)
								{
									MonoBehaviour.print((object)$"Setting {item}'s moonWeight to {num} for rend");
								}
								break;
							case "dine":
								builder.AddWeight(MoonKeys.Dine, num);
								if (BoundConfig.DebugLogging.Value)
								{
									MonoBehaviour.print((object)$"Setting {item}'s moonWeight to {num} for dine");
								}
								break;
							case "titan":
								builder.AddWeight(MoonKeys.Titan, num);
								if (BoundConfig.DebugLogging.Value)
								{
									MonoBehaviour.print((object)$"Setting {item}'s moonWeight to {num} for titan");
								}
								break;
							case "adamance":
								builder.AddWeight(MoonKeys.Adamance, num);
								if (BoundConfig.DebugLogging.Value)
								{
									MonoBehaviour.print((object)$"Setting {item}'s moonWeight to {num} for adamance");
								}
								break;
							case "artifice":
								builder.AddWeight(MoonKeys.Artifice, num);
								if (BoundConfig.DebugLogging.Value)
								{
									MonoBehaviour.print((object)$"Setting {item}'s moonWeight to {num} for artifice");
								}
								break;
							case "embrion":
								builder.AddWeight(MoonKeys.Embrion, num);
								if (BoundConfig.DebugLogging.Value)
								{
									MonoBehaviour.print((object)$"Setting {item}'s moonWeight to {num} for embrion");
								}
								break;
							default:
								Debug.LogWarning((object)$"Config [{text2}] from [{item}] returned a readable format error, please check that the moon you entered is an available option and that it is spelled correctly.");
								break;
							}
						}
					}
					catch
					{
						Debug.LogWarning((object)$"Moon weight config [{text}] from [{item}] is unreadable and returned an error. Check your formatting or report this to the mod maker if you need support, thanks.");
					}
				}
			}
		}
	}
	internal class UsualScrapConfigs
	{
		public readonly ConfigEntry<bool> MansionScrapPackEnabled;

		public readonly ConfigEntry<bool> FacilityScrapPackEnabled;

		public readonly ConfigEntry<bool> TicketLoaded;

		public readonly ConfigEntry<bool> TicketSpawnsAsScrap;

		public readonly ConfigEntry<string> TicketMoonSpawnWeights;

		public readonly ConfigEntry<int> TicketGlobalSpawnWeight;

		public readonly ConfigEntry<bool> GoldenTicketLoaded;

		public readonly ConfigEntry<bool> GoldenTicketSpawnsAsScrap;

		public readonly ConfigEntry<string> GoldenTicketMoonSpawnWeights;

		public readonly ConfigEntry<int> GoldenTicketGlobalSpawnWeight;

		public readonly ConfigEntry<bool> RoseLoaded;

		public readonly ConfigEntry<bool> RoseSpawnsAsScrap;

		public readonly ConfigEntry<string> RoseMoonSpawnWeights;

		public readonly ConfigEntry<int> RoseGlobalSpawnWeight;

		public readonly ConfigEntry<bool> SizableScissorsLoaded;

		public readonly ConfigEntry<bool> SizableScissorsSpawnsAsScrap;

		public readonly ConfigEntry<string> SizableScissorsMoonSpawnWeights;

		public readonly ConfigEntry<int> SizableScissorsGlobalSpawnWeight;

		public readonly ConfigEntry<bool> WalkingCaneLoaded;

		public readonly ConfigEntry<bool> WalkingCaneSpawnsAsScrap;

		public readonly ConfigEntry<string> WalkingCaneMoonSpawnWeights;

		public readonly ConfigEntry<int> WalkingCaneGlobalSpawnWeight;

		public readonly ConfigEntry<bool> CandyDispenserLoaded;

		public readonly ConfigEntry<bool> CandyDispenserSpawnsAsScrap;

		public readonly ConfigEntry<string> CandyDispenserMoonSpawnWeights;

		public readonly ConfigEntry<int> CandyDispenserGlobalSpawnWeight;

		public readonly ConfigEntry<bool> FuelCylinderLoaded;

		public readonly ConfigEntry<bool> FuelCylinderSpawnsAsScrap;

		public readonly ConfigEntry<string> FuelCylinderMoonSpawnWeights;

		public readonly ConfigEntry<int> FuelCylinderGlobalSpawnWeight;

		public readonly ConfigEntry<bool> RadioactiveCellLoaded;

		public readonly ConfigEntry<bool> RadioactiveCellSpawnsAsScrap;

		public readonly ConfigEntry<string> RadioactiveCellMoonSpawnWeights;

		public readonly ConfigEntry<int> RadioactiveCellGlobalSpawnWeight;

		public readonly ConfigEntry<bool> GloomyCapsuleLoaded;

		public readonly ConfigEntry<bool> GloomyCapsuleSpawnsAsScrap;

		public readonly ConfigEntry<string> GloomyCapsuleMoonSpawnWeights;

		public readonly ConfigEntry<int> GloomyCapsuleGlobalSpawnWeight;

		public readonly ConfigEntry<bool> FrigidCapsuleLoaded;

		public readonly ConfigEntry<bool> FrigidCapsuleSpawnsAsScrap;

		public readonly ConfigEntry<string> FrigidCapsuleMoonSpawnWeights;

		public readonly ConfigEntry<int> FrigidCapsuleGlobalSpawnWeight;

		public readonly ConfigEntry<bool> BloodyCapsuleLoaded;

		public readonly ConfigEntry<bool> BloodyCapsuleSpawnsAsScrap;

		public readonly ConfigEntry<string> BloodyCapsuleMoonSpawnWeights;

		public readonly ConfigEntry<int> BloodyCapsuleGlobalSpawnWeight;

		public readonly ConfigEntry<bool> PadlockLoaded;

		public readonly ConfigEntry<bool> PadlockSpawnsAsScrap;

		public readonly ConfigEntry<string> PadlockMoonSpawnWeights;

		public readonly ConfigEntry<int> PadlockGlobalSpawnWeight;

		public readonly ConfigEntry<bool> CrowbarLoaded;

		public readonly ConfigEntry<bool> CrowbarSpawnsAsScrap;

		public readonly ConfigEntry<string> CrowbarMoonSpawnWeights;

		public readonly ConfigEntry<int> CrowbarGlobalSpawnWeight;

		public readonly ConfigEntry<bool> HandlampLoaded;

		public readonly ConfigEntry<bool> HandlampIsStoreItem;

		public readonly ConfigEntry<int> HandlampStorePrice;

		public readonly ConfigEntry<bool> BandagesLoaded;

		public readonly ConfigEntry<bool> BandagesIsStoreItem;

		public readonly ConfigEntry<int> BandagesStorePrice;

		public readonly ConfigEntry<bool> MedicalKitLoaded;

		public readonly ConfigEntry<bool> MedicalKitIsStoreItem;

		public readonly ConfigEntry<int> MedicalKitStorePrice;

		public readonly ConfigEntry<bool> DefibrillatorLoaded;

		public readonly ConfigEntry<bool> DefibrillatorIsStoreItem;

		public readonly ConfigEntry<int> DefibrillatorStorePrice;

		public readonly ConfigEntry<bool> DefibrillatorRequiresBattery;

		public readonly ConfigEntry<bool> DefibrillatorUsesLimited;

		public readonly ConfigEntry<int> DefibrillatorUseLimit;

		public readonly ConfigEntry<bool> DefibrillatorPermaDeathRule;

		public readonly ConfigEntry<bool> DefibrillatorRefillsOnLanding;

		public readonly ConfigEntry<bool> ProductivityAutoinjectorLoaded;

		public readonly ConfigEntry<bool> ProductivityAutoinjectorIsStoreItem;

		public readonly ConfigEntry<int> ProductivityAutoinjectorStorePrice;

		public readonly ConfigEntry<bool> ToolkitLoaded;

		public readonly ConfigEntry<bool> ToolkitIsStoreItem;

		public readonly ConfigEntry<int> ToolkitStorePrice;

		public readonly ConfigEntry<bool> ShiftControllerLoaded;

		public readonly ConfigEntry<bool> ShiftControllerIsStoreItem;

		public readonly ConfigEntry<int> ShiftControllerStorePrice;

		public readonly ConfigEntry<int> ShiftControllerGreatRange;

		public readonly ConfigEntry<int> ShiftControllerPoorRange;

		public readonly ConfigEntry<bool> CapsulesDisabledOnTheShip;

		public readonly ConfigEntry<bool> TicketsFunctionOnCheapItems;

		public readonly ConfigEntry<bool> DisableItemIcons;

		public readonly ConfigEntry<bool> TrueSurvivorPreset;

		public readonly ConfigEntry<bool> NoScrapItemsPreset;

		public readonly ConfigEntry<bool> NoStoreItemsPreset;

		public readonly ConfigEntry<bool> DebugLogging;

		public UsualScrapConfigs(ConfigFile cfg)
		{
			cfg.SaveOnConfigSet = false;
			DebugLogging = cfg.Bind<bool>("1. Debugging", "Log actions for debugging purposes", false, "Whether or not to log actions for debugging purposes");
			DisableItemIcons = cfg.Bind<bool>("2. General Options", "Disable Item Icons", false, "Whether or not to disable this mod's items icons (For use with runtime icons and similar mods)");
			TrueSurvivorPreset = cfg.Bind<bool>("3. Presets (General Overrides)", "True Survivor Preset Enabled", true, "This mods version of hardmode");
			NoScrapItemsPreset = cfg.Bind<bool>("3. Presets (General Overrides)", "Scrap Only Preset Enabled", true, "If enabled, only this mod's scrap items will be enabled (Along with vanilla and other mods)");
			NoStoreItemsPreset = cfg.Bind<bool>("3. Presets (General Overrides)", "Store Only Preset Enabled", true, "If enabled, only this mod's store items will be enabled (Along with vanilla and other mods)");
			MansionScrapPackEnabled = cfg.Bind<bool>("4. Scrap Packs", "Mansion Scrap Pack Enabled", false, "Whether or not the Mansion Scrap Pack is enabled. Scrap Packs include thematic items that have little to no function besides being scrap, they could be considered bloat and so they are toggleable.");
			FacilityScrapPackEnabled = cfg.Bind<bool>("4. Scrap Packs", "Facility Scrap Pack Enabled", false, "Whether or not the Facility Scrap Pack is enabled. Scrap Packs include thematic items that have little to no function besides being scrap, they could be considered bloat and so they are toggleable.");
			TicketsFunctionOnCheapItems = cfg.Bind<bool>("Scrap Items - Tickets", "Tickets function on cheap items", true, "Whether or not tickets function when used on items with a value below 5 (Meaning tickets will no longer work on most equipment whose value is normally 0)");
			TicketLoaded = cfg.Bind<bool>("Scrap Items - Tickets", "Ticket is loaded", true, "Whether or not the Ticket is loaded");
			TicketSpawnsAsScrap = cfg.Bind<bool>("Scrap Items - Tickets", "Ticket is a scrap item", true, "Whether or not the Ticket spawns as scrap");
			TicketMoonSpawnWeights = cfg.Bind<string>("Scrap Items - Tickets", "Ticket Moon Spawning", "experimentation=-1, vow=-1, march=-1, assurance=-1, offense=-1, rend=-1, dine=-1, titan=-1, adamance=-1, artifice=-1, embrion=-1", "Where and how often the Ticket will spawn (Moon spawn weights will individually overwrite global spawn weights, set to -1 or leave blank to disable. Correct spelling and formatting is critical, shown, and a log will appear pointing out unreadable/disabled configs");
			TicketGlobalSpawnWeight = cfg.Bind<int>("Scrap Items - Tickets", "Ticket Global Spawning", 40, "How often the Ticket will spawn globally (Will affect all moons including modded moons unless overwritten by moon spawn weights, -1 to disable)");
			GoldenTicketLoaded = cfg.Bind<bool>("Scrap Items - Tickets", "Golden Ticket is loaded", true, "Whether or not the Golden Ticket is loaded");
			GoldenTicketSpawnsAsScrap = cfg.Bind<bool>("Scrap Items - Tickets", "Golden Ticket is a scrap item", true, "Whether or not the Golden Ticket spawns as scrap");
			GoldenTicketMoonSpawnWeights = cfg.Bind<string>("Scrap Items - Tickets", "Golden Ticket Moon Spawning", "experimentation=-1, vow=-1, march=-1, assurance=-1, offense=-1, rend=-1, dine=-1, titan=-1, adamance=-1, artifice=-1, embrion=-1", "Where and how often the Golden Ticket will spawn (Moon spawn weights will individually overwrite global spawn weights, set to -1 or leave blank to disable. Correct spelling and formatting is critical, shown, and a log will appear pointing out unreadable/disabled configs");
			GoldenTicketGlobalSpawnWeight = cfg.Bind<int>("Scrap Items - Tickets", "Golden Ticket Global Spawning", 5, "How often the Golden Ticket will spawn globally (Will affect all moons including modded moons unless overwritten by moon spawn weights, -1 to disable)");
			RoseLoaded = cfg.Bind<bool>("Scrap Item - Rose", "Rose is loaded", true, "Whether or not the Rose is loaded");
			RoseSpawnsAsScrap = cfg.Bind<bool>("Scrap Item - Rose", "Rose is a scrap item", true, "Whether or not the Rose spawns as scrap");
			RoseMoonSpawnWeights = cfg.Bind<string>("Scrap Item - Rose", "Rose Moon Spawning", "experimentation=-1, vow=-1, march=-1, assurance=-1, offense=-1, rend=-1, dine=-1, titan=-1, adamance=-1, artifice=-1, embrion=-1", "Where and how often the Rose will spawn (Moon spawn weights will individually overwrite global spawn weights, set to -1 or leave blank to disable. Correct spelling and formatting is critical, shown, and a log will appear pointing out unreadable/disabled configs");
			RoseGlobalSpawnWeight = cfg.Bind<int>("Scrap Item - Rose", "Rose Global Spawning", 30, "How often the Rose will spawn globally (Will affect all moons including modded moons unless overwritten by moon spawn weights, -1 to disable)");
			SizableScissorsLoaded = cfg.Bind<bool>("Scrap Item - Sizable Scissors", "Sizable Scissors is loaded", true, "Whether or not the Sizable Scissors is loaded");
			SizableScissorsSpawnsAsScrap = cfg.Bind<bool>("Scrap Item - Sizable Scissors", "Sizable Scissors is a scrap item", true, "Whether or not the Sizable Scissors spawns as scrap");
			SizableScissorsMoonSpawnWeights = cfg.Bind<string>("Scrap Item - Sizable Scissors", "Sizable Scissors Moon Spawning", "experimentation=-1, vow=-1, march=-1, assurance=-1, offense=-1, rend=-1, dine=-1, titan=-1, adamance=-1, artifice=-1, embrion=-1", "Where and how often the Sizable Scissors will spawn (Moon spawn weights will individually overwrite global spawn weights, set to -1 or leave blank to disable. Correct spelling and formatting is critical, shown, and a log will appear pointing out unreadable/disabled configs");
			SizableScissorsGlobalSpawnWeight = cfg.Bind<int>("Scrap Item - Sizable Scissors", "Sizable Scissors Global Spawning", 20, "How often the Sizable Scissors will spawn globally (Will affect all moons including modded moons unless overwritten by moon spawn weights, -1 to disable)");
			WalkingCaneLoaded = cfg.Bind<bool>("Scrap Item - Walking Cane", "Walking Cane is loaded", true, "Whether or not the Walking Cane is loaded");
			WalkingCaneSpawnsAsScrap = cfg.Bind<bool>("Scrap Item - Walking Cane", "Walking Cane is a scrap item", true, "Whether or not the Walking Cane spawns as scrap");
			WalkingCaneMoonSpawnWeights = cfg.Bind<string>("Scrap Item - Walking Cane", "Walking Cane Moon Spawning", "experimentation=-1, vow=-1, march=-1, assurance=-1, offense=-1, rend=-1, dine=-1, titan=-1, adamance=-1, artifice=-1, embrion=-1", "Where and how often the Walking Cane will spawn (Moon spawn weights will individually overwrite global spawn weights, set to -1 or leave blank to disable. Correct spelling and formatting is critical, shown, and a log will appear pointing out unreadable/disabled configs");
			WalkingCaneGlobalSpawnWeight = cfg.Bind<int>("Scrap Item - Walking Cane", "Walking Cane Global Spawning", 15, "How often the Walking Cane will spawn globally (Will affect all moons including modded moons unless overwritten by moon spawn weights, -1 to disable)");
			CandyDispenserLoaded = cfg.Bind<bool>("Scrap Item - Candy Dispenser", "Candy Dispenser is loaded", true, "Whether or not the Candy Dispenser is loaded");
			CandyDispenserSpawnsAsScrap = cfg.Bind<bool>("Scrap Item - Candy Dispenser", "Candy Dispenser is a scrap item", true, "Whether or not the Candy Dispenser spawns as scrap");
			CandyDispenserMoonSpawnWeights = cfg.Bind<string>("Scrap Item - Candy Dispenser", "Candy Dispenser Moon Spawning", "experimentation=-1, vow=-1, march=-1, assurance=-1, offense=-1, rend=-1, dine=-1, titan=-1, adamance=-1, artifice=-1, embrion=-1", "Where and how often the Candy Dispenser will spawn (Moon spawn weights will individually overwrite global spawn weights, set to -1 or leave blank to disable. Correct spelling and formatting is critical, shown, and a log will appear pointing out unreadable/disabled configs");
			CandyDispenserGlobalSpawnWeight = cfg.Bind<int>("Scrap Item - Candy Dispenser", "Candy Dispenser Global Spawning", 30, "How often the Candy Dispenser will spawn globally (Will affect all moons including modded moons unless overwritten by moon spawn weights, -1 to disable)");
			FuelCylinderLoaded = cfg.Bind<bool>("Scrap Item - Fuel Cylinder", "Fuel Cylinder is loaded", true, "Whether or not the Fuel Cylinder is loaded");
			FuelCylinderSpawnsAsScrap = cfg.Bind<bool>("Scrap Item - Fuel Cylinder", "Fuel Cylinder is a scrap item", true, "Whether or not the Fuel Cylinder spawns as scrap");
			FuelCylinderMoonSpawnWeights = cfg.Bind<string>("Scrap Item - Fuel Cylinder", "Fuel Cylinder Moon Spawning", "experimentation=-1, vow=-1, march=-1, assurance=-1, offense=-1, rend=-1, dine=-1, titan=-1, adamance=-1, artifice=-1, embrion=-1", "Where and how often the Fuel Cylinder will spawn (Moon spawn weights will individually overwrite global spawn weights, set to -1 or leave blank to disable. Correct spelling and formatting is critical, shown, and a log will appear pointing out unreadable/disabled configs");
			FuelCylinderGlobalSpawnWeight = cfg.Bind<int>("Scrap Item - Fuel Cylinder", "Fuel Cylinder Global Spawning", 20, "How often the Fuel Cylinder will spawn globally (Will affect all moons including modded moons unless overwritten by moon spawn weights, -1 to disable)");
			RadioactiveCellLoaded = cfg.Bind<bool>("Scrap Item - Radioactive Cell", "Radioactive Cell is loaded", true, "Whether or not the Radioactive Cell is loaded");
			RadioactiveCellSpawnsAsScrap = cfg.Bind<bool>("Scrap Item - Radioactive Cell", "Radioactive Cell is a scrap item", true, "Whether or not the Radioactive Cell spawns as scrap");
			RadioactiveCellMoonSpawnWeights = cfg.Bind<string>("Scrap Item - Radioactive Cell", "Radioactive Cell Moon Spawning", "experimentation=-1, vow=-1, march=-1, assurance=-1, offense=-1, rend=-1, dine=-1, titan=-1, adamance=-1, artifice=-1, embrion=-1", "Where and how often the Radioactive Cell will spawn (Moon spawn weights will individually overwrite global spawn weights, set to -1 or leave blank to disable. Correct spelling and formatting is critical, shown, and a log will appear pointing out unreadable/disabled configs");
			RadioactiveCellGlobalSpawnWeight = cfg.Bind<int>("Scrap Item - Radioactive Cell", "Radioactive Cell Global Spawning", 20, "How often the Radioactive Cell will spawn globally (Will affect all moons including modded moons unless overwritten by moon spawn weights, -1 to disable)");
			CapsulesDisabledOnTheShip = cfg.Bind<bool>("Scrap Items - Capsules", "Capsules Disabled On The Ship", true, "Whether or not capsules are disabled inside the ship when landed (Capsules are disabled in orbit always)");
			GloomyCapsuleLoaded = cfg.Bind<bool>("Scrap Items - Capsules", "Gloomy Capsule is loaded", true, "Whether or not the Gloomy Capsule is loaded");
			GloomyCapsuleSpawnsAsScrap = cfg.Bind<bool>("Scrap Items - Capsules", "Gloomy Capsule is a scrap item", true, "Whether or not the Gloomy Capsule spawns as scrap");
			GloomyCapsuleMoonSpawnWeights = cfg.Bind<string>("Scrap Items - Capsules", "Gloomy Capsule Moon Spawning", "experimentation=-1, vow=-1, march=-1, assurance=-1, offense=-1, rend=-1, dine=-1, titan=-1, adamance=-1, artifice=-1, embrion=-1", "Where and how often the Gloomy Capsule will spawn (Moon spawn weights will individually overwrite global spawn weights, set to -1 or leave blank to disable. Correct spelling and formatting is critical, shown, and a log will appear pointing out unreadable/disabled configs");
			GloomyCapsuleGlobalSpawnWeight = cfg.Bind<int>("Scrap Items - Capsules", "Gloomy Capsule Global Spawning", 15, "How often the Gloomy Capsule will spawn globally (Will affect all moons including modded moons unless overwritten by moon spawn weights, -1 to disable)");
			FrigidCapsuleLoaded = cfg.Bind<bool>("Scrap Items - Capsules", "Frigid Capsule is loaded", true, "Whether or not the Frigid Capsule is loaded");
			FrigidCapsuleSpawnsAsScrap = cfg.Bind<bool>("Scrap Items - Capsules", "Frigid Capsule is a scrap item", true, "Whether or not the Frigid Capsule spawns as scrap");
			FrigidCapsuleMoonSpawnWeights = cfg.Bind<string>("Scrap Items - Capsules", "Frigid Capsule Moon Spawning", "experimentation=-1, vow=-1, march=-1, assurance=-1, offense=-1, rend=-1, dine=-1, titan=-1, adamance=-1, artifice=-1, embrion=-1", "Where and how often the Frigid Capsule will spawn (Moon spawn weights will individually overwrite global spawn weights, set to -1 or leave blank to disable. Correct spelling and formatting is critical, shown, and a log will appear pointing out unreadable/disabled configs");
			FrigidCapsuleGlobalSpawnWeight = cfg.Bind<int>("Scrap Items - Capsules", "Frigid Capsule Global Spawning", 15, "How often the Frigid Capsule will spawn globally (Will affect all moons including modded moons unless overwritten by moon spawn weights, -1 to disable)");
			BloodyCapsuleLoaded = cfg.Bind<bool>("Scrap Items - Capsules", "Bloody Capsule is loaded", true, "Whether or not the Bloody Capsule is loaded");
			BloodyCapsuleSpawnsAsScrap = cfg.Bind<bool>("Scrap Items - Capsules", "Bloody Capsule is a scrap item", true, "Whether or not the Bloody Capsule spawns as scrap");
			BloodyCapsuleMoonSpawnWeights = cfg.Bind<string>("Scrap Items - Capsules", "Bloody Capsule Moon Spawning", "experimentation=-1, vow=-1, march=-1, assurance=-1, offense=-1, rend=-1, dine=-1, titan=-1, adamance=-1, artifice=-1, embrion=-1", "Where and how often the Bloody Capsule will spawn (Moon spawn weights will individually overwrite global spawn weights, set to -1 or leave blank to disable. Correct spelling and formatting is critical, shown, and a log will appear pointing out unreadable/disabled configs");
			BloodyCapsuleGlobalSpawnWeight = cfg.Bind<int>("Scrap Items - Capsules", "Bloody Capsule Global Spawning", 15, "How often the Bloody Capsule will spawn globally (Will affect all moons including modded moons unless overwritten by moon spawn weights, -1 to disable)");
			PadlockLoaded = cfg.Bind<bool>("Item - Padlock", "Padlock is loaded", true, "Whether or not the Padlock is loaded");
			PadlockSpawnsAsScrap = cfg.Bind<bool>("Item - Padlock", "Padlock is a scrap item", true, "Whether or not the Padlock spawns as scrap");
			PadlockMoonSpawnWeights = cfg.Bind<string>("Item - Padlock", "Padlock Moon Spawning", "experimentation=-1, vow=-1, march=-1, assurance=-1, offense=-1, rend=-1, dine=-1, titan=-1, adamance=-1, artifice=-1, embrion=-1", "Where and how often the Padlock will spawn (Moon spawn weights will individually overwrite global spawn weights, set to -1 or leave blank to disable. Correct spelling and formatting is critical, shown, and a log will appear pointing out unreadable/disabled configs");
			PadlockGlobalSpawnWeight = cfg.Bind<int>("Item - Padlock", "Padlock Global Spawning", 30, "How often the Padlock will spawn globally (Will affect all moons including modded moons unless overwritten by moon spawn weights, -1 to disable)");
			CrowbarLoaded = cfg.Bind<bool>("Item - Crowbar", "Crowbar is loaded", true, "Whether or not the Crowbar is loaded");
			CrowbarSpawnsAsScrap = cfg.Bind<bool>("Item - Crowbar", "Crowbar is a scrap item", true, "Whether or not the Crowbar spawns as scrap");
			CrowbarMoonSpawnWeights = cfg.Bind<string>("Item - Crowbar", "Crowbar Moon Spawning", "experimentation=-1, vow=-1, march=-1, assurance=-1, offense=-1, rend=-1, dine=-1, titan=-1, adamance=-1, artifice=-1, embrion=-1", "Where and how often the Crowbar will spawn (Moon spawn weights will individually overwrite global spawn weights, set to -1 or leave blank to disable. Correct spelling and formatting is critical, shown, and a log will appear pointing out unreadable/disabled configs");
			CrowbarGlobalSpawnWeight = cfg.Bind<int>("Item - Crowbar", "Crowbar Global Spawning", 30, "How often the Crowbar will spawn globally (Will affect all moons including modded moons unless overwritten by moon spawn weights, -1 to disable)");
			HandlampLoaded = cfg.Bind<bool>("Store Item - Handlamp", "Handlamp is loaded", true, "Whether or not the Handlamp is loaded");
			HandlampIsStoreItem = cfg.Bind<bool>("Store Item - Handlamp", "Handlamp is a store item", true, "Whether or not the Handlamp is a store item");
			HandlampStorePrice = cfg.Bind<int>("Store Item - Handlamp", "Handlamp store price", 25, "The store price of the Handlamp (Cannot be a negative number)");
			BandagesLoaded = cfg.Bind<bool>("Store Item - Bandages", "Bandages are loaded", true, "Whether or not the Bandages are loaded");
			BandagesIsStoreItem = cfg.Bind<bool>("Store Item - Bandages", "Bandages are a store item", true, "Whether or not the Bandages are a store item");
			BandagesStorePrice = cfg.Bind<int>("Store Item - Bandages", "Bandages store price", 20, "The store price of the Bandages (Cannot be a negative number)");
			MedicalKitLoaded = cfg.Bind<bool>("Store Item - Medical Kit", "Medical Kit is loaded", true, "Whether or not the Medical Kit is loaded");
			MedicalKitIsStoreItem = cfg.Bind<bool>("Store Item - Medical Kit", "Medical Kit is a store item", true, "Whether or not the Medical Kit is a store item");
			MedicalKitStorePrice = cfg.Bind<int>("Store Item - Medical Kit", "Medical Kit store price", 120, "The store price of the Medical Kit (Cannot be a negative number)");
			DefibrillatorLoaded = cfg.Bind<bool>("Store Item - Defibrillator", "Defibrillator is loaded", true, "Whether or not the Defibrillator is loaded");
			DefibrillatorIsStoreItem = cfg.Bind<bool>("Store Item - Defibrillator", "Defibrillator is a store item", true, "Whether or not the Defibrillator is a store item");
			DefibrillatorStorePrice = cfg.Bind<int>("Store Item - Defibrillator", "Defibrillator store price", 375, "The store price of the Defibrillator (Cannot be a negative number)");
			DefibrillatorRequiresBattery = cfg.Bind<bool>("Store Item - Defibrillator", "Defibrillator requires battery", true, "Whether or not the Defibrillator requires battery");
			DefibrillatorUsesLimited = cfg.Bind<bool>("Store Item - Defibrillator", "Defibrillator uses are limited", true, "Whether or not Defibrillators have limited uses");
			DefibrillatorUseLimit = cfg.Bind<int>("Store Item - Defibrillator", "Defibrillators use limit", 3, "The number of uses each Defibrillator has (Uses have a minimum of 1, uses are used up on players successfully revived only)");
			DefibrillatorRefillsOnLanding = cfg.Bind<bool>("Store Item - Defibrillator", "Defibrillator refills every moon landing", false, "Whether or not existing Defibrillators will refill their uses upon landing on a moon");
			DefibrillatorPermaDeathRule = cfg.Bind<bool>("Store Item - Defibrillator", "Defibrillator follows perma-death rules", true, "Whether or not specific causes of death will prevent the defibrillator from reviving players (Ex - Corpses decapitated by CoilHeads, Corpses snipped in half by a Barber, Corpses head popped by the Ghost Girl)");
			ProductivityAutoinjectorLoaded = cfg.Bind<bool>("Store Item - Productivity Autoinjector", "Productivity Autoinjector is loaded", true, "Whether or not the Productivity Autoinjector is loaded");
			ProductivityAutoinjectorIsStoreItem = cfg.Bind<bool>("Store Item - Productivity Autoinjector", "Productivity Autoinjector is a store item", true, "Whether or not the Productivity Autoinjector is a store item");
			ProductivityAutoinjectorStorePrice = cfg.Bind<int>("Store Item - Productivity Autoinjector", "Productivity Autoinjector store price", 90, "The store price of the Productivity Autoinjector");
			ToolkitLoaded = cfg.Bind<bool>("Store Item - Toolkit", "Toolkit is loaded", true, "Whether or not the Toolkit is loaded");
			ToolkitIsStoreItem = cfg.Bind<bool>("Store Item - Toolkit", "Toolkit is a store item", true, "Whether or not the Toolkit is a store item");
			ToolkitStorePrice = cfg.Bind<int>("Store Item - Toolkit", "Toolkit store price", 115, "The store price of the Toolkit");
			ShiftControllerLoaded = cfg.Bind<bool>("Store Item - Shift Controller", "Shift Controller is loaded", true, "Whether or not the Shift Controller is loaded");
			ShiftControllerIsStoreItem = cfg.Bind<bool>("Store Item - Shift Controller", "Shift Controller is a store item", true, "Whether or not the Shift Controller is a store item");
			ShiftControllerStorePrice = cfg.Bind<int>("Store Item - Shift Controller", "Shift Controller store price", 225, "The store price of the Shift Controller");
			ShiftControllerGreatRange = cfg.Bind<int>("Store Item - Shift Controller", "Shift Controllers great/first connection range", 50, "The max range of the Shift Controller's great/first connection range. (The great/first connection range starts at 0 and stops at this value, The average/middle connection range starts at this value)");
			ShiftControllerPoorRange = cfg.Bind<int>("Store Item - Shift Controller", "Shift Controllers poor/last connection range", 175, "The range where the Shift Controller enters it's poor/last connection range. (The average/middle connection range stops at this value, The poor/last connection range starts at this value)");
			ClearOrphanedEntries(cfg);
			cfg.Save();
			cfg.SaveOnConfigSet = true;
		}

		private static void ClearOrphanedEntries(ConfigFile cfg)
		{
			PropertyInfo propertyInfo = AccessTools.Property(typeof(ConfigFile), "OrphanedEntries");
			Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)propertyInfo.GetValue(cfg);
			dictionary.Clear();
		}
	}
}
namespace UsualScrap.Behaviors
{
	public class BandagesScript : GrabbableObject
	{
		public NetworkVariable<int> savedUses = new NetworkVariable<int>(3, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		private int uses = 3;

		private ParticleSystem particle;

		public void Awake()
		{
			particle = ((Component)this).GetComponentInChildren<ParticleSystem>();
		}

		public override int GetItemDataToSave()
		{
			((GrabbableObject)this).GetItemDataToSave();
			savedUses.Value = uses;
			return savedUses.Value;
		}

		public override void LoadItemSaveData(int saveData)
		{
			((GrabbableObject)this).LoadItemSaveData(saveData);
			uses = saveData;
			MonoBehaviour.print((object)uses);
		}

		public override void GrabItem()
		{
			((GrabbableObject)this).GrabItem();
			if (base.heldByPlayerOnServer)
			{
				base.itemProperties.toolTips[0] = $"Remaining Uses - {uses}";
				((GrabbableObject)this).SetControlTipsForItem();
			}
		}

		public override void EquipItem()
		{
			((GrabbableObject)this).EquipItem();
			if (base.heldByPlayerOnServer)
			{
				base.itemProperties.toolTips[0] = $"Remaining Uses - {uses}";
				((GrabbableObject)this).SetControlTipsForItem();
			}
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (buttonDown && base.playerHeldBy.health < 100)
			{
				HealServerRpc();
				if (base.heldByPlayerOnServer)
				{
					base.itemProperties.toolTips[0] = $"Remaining Uses - {uses}";
					((GrabbableObject)this).SetControlTipsForItem();
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void HealServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(87823207u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 87823207u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					HealClientRpc();
				}
			}
		}

		[ClientRpc]
		public void HealClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2085797069u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2085797069u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					Heal();
				}
			}
		}

		public void Heal()
		{
			//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)
			ParticleSystem val = Object.Instantiate<ParticleSystem>(particle, ((Component)base.playerHeldBy).transform.position, Quaternion.identity, ((Component)base.playerHeldBy).transform);
			val.Play();
			if (uses > 1 && base.playerHeldBy.health < 70)
			{
				base.playerHeldBy.health = base.playerHeldBy.health + 30;
				uses--;
			}
			else if (uses > 1 && base.playerHeldBy.health >= 70 && base.playerHeldBy.health < 100)
			{
				base.playerHeldBy.health = base.playerHeldBy.health + (100 - base.playerHeldBy.health);
				uses--;
			}
			else if (uses <= 1 && base.playerHeldBy.health < 70)
			{
				base.playerHeldBy.health = base.playerHeldBy.health + 30;
				if (base.isHeld)
				{
					base.playerHeldBy.DespawnHeldObject();
				}
			}
			else if (uses <= 1 && base.playerHeldBy.health >= 70 && base.playerHeldBy.health < 100)
			{
				base.playerHeldBy.health = base.playerHeldBy.health + (100 - base.playerHeldBy.health);
				if (base.isHeld)
				{
					base.playerHeldBy.DespawnHeldObject();
				}
			}
			if (base.playerHeldBy.health > 20)
			{
				if (base.playerHeldBy.criticallyInjured || base.playerHeldBy.bleedingHeavily)
				{
					base.playerHeldBy.criticallyInjured = false;
					base.playerHeldBy.bleedingHeavily = false;
				}
				if ((Object)(object)base.playerHeldBy.playerBodyAnimator != (Object)null)
				{
					base.playerHeldBy.playerBodyAnimator.SetBool("Limp", false);
				}
				if ((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)(object)base.playerHeldBy)
				{
					HUDManager.Instance.UpdateHealthUI(base.playerHeldBy.health, false);
				}
			}
		}

		protected override void __initializeVariables()
		{
			if (savedUses == null)
			{
				throw new Exception("BandagesScript.savedUses cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)savedUses).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)savedUses, "savedUses");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)savedUses);
			((GrabbableObject)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(87823207u, new RpcReceiveHandler(__rpc_handler_87823207), "HealServerRpc");
			((NetworkBehaviour)this).__registerRpc(2085797069u, new RpcReceiveHandler(__rpc_handler_2085797069), "HealClientRpc");
			((GrabbableObject)this).__initializeRpcs();
		}

		private static void __rpc_handler_87823207(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((BandagesScript)(object)target).HealServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2085797069(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((BandagesScript)(object)target).HealClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "BandagesScript";
		}
	}
	public class BloodyCapsuleScript : GrabbableObject
	{
		private ParticleSystem chargedParticles;

		private ParticleSystem chargingParticles;

		private ParticleSystem drainingParticles;

		private AudioSource[] sounds;

		private AudioClip pulse;

		private Light light;

		private bool chargingParticlePlaying = false;

		private bool chargedParticlesPlaying = false;

		private Coroutine detectCoroutine = null;

		private int charge = 0;

		private bool disabledInShip;

		internal static UsualScrapConfigs BoundConfig { get; private set; }

		public void Awake()
		{
			BoundConfig = Plugin.BoundConfig;
			try
			{
				chargedParticles = ((Component)((Component)this).transform.Find("ChargedParticles")).GetComponent<ParticleSystem>();
				chargingParticles = ((Component)((Component)this).transform.Find("ChargingParticles")).GetComponent<ParticleSystem>();
				drainingParticles = ((Component)((Component)this).transform.Find("DrainingParticles")).GetComponent<ParticleSystem>();
				sounds = ((Component)((Component)this).transform.Find("BloodyCapsuleSounds")).gameObject.GetComponents<AudioSource>();
				light = ((Component)((Component)this).transform.Find("Point Light")).GetComponent<Light>();
				pulse = sounds[0].clip;
			}
			catch
			{
				if ((Object)(object)chargedParticles == (Object)null)
				{
					MonoBehaviour.print((object)"Bloody Capsule missing charged particles! - USUAL SCRAP");
				}
				if ((Object)(object)chargingParticles == (Object)null)
				{
					MonoBehaviour.print((object)"Bloody Capsule missing charging particles! - USUAL SCRAP");
				}
				if ((Object)(object)drainingParticles == (Object)null)
				{
					MonoBehaviour.print((object)"Bloody Capsule missing draining particles! - USUAL SCRAP");
				}
				if (sounds == null)
				{
					MonoBehaviour.print((object)"Bloody Capsule missing sounds! - USUAL SCRAP");
				}
			}
			disabledInShip = BoundConfig.CapsulesDisabledOnTheShip.Value;
			((MonoBehaviour)this).StartCoroutine(Glow());
		}

		private IEnumerator Glow()
		{
			float maxintensity = light.intensity * 1.5f;
			float minintensity = light.intensity * 0.5f;
			while (true)
			{
				if (!((Behaviour)light).enabled)
				{
					yield return (object)new WaitUntil((Func<bool>)(() => ((Behaviour)light).enabled));
				}
				float t = (MathF.Sin(Time.time * 1f) + 1f) / 2f;
				light.intensity = minintensity + (maxintensity - minintensity) * t;
				yield return null;
			}
		}

		public override void PocketItem()
		{
			((GrabbableObject)this).PocketItem();
			if (((Behaviour)light).enabled)
			{
				((Behaviour)light).enabled = false;
			}
		}

		public override void EquipItem()
		{
			((GrabbableObject)this).EquipItem();
			if (!((Behaviour)light).enabled)
			{
				((Behaviour)light).enabled = true;
			}
		}

		public override void DiscardItem()
		{
			((GrabbableObject)this).DiscardItem();
			if (!((Behaviour)light).enabled)
			{
				((Behaviour)light).enabled = true;
			}
		}

		public override void GrabItem()
		{
			((GrabbableObject)this).GrabItem();
			if (!StartOfRound.Instance.inShipPhase && detectCoroutine == null)
			{
				detectCoroutine = ((MonoBehaviour)this).StartCoroutine(Detecting());
			}
		}

		private IEnumerator Detecting()
		{
			while (true)
			{
				yield return (object)new WaitForSeconds(1f);
				if (chargingParticlePlaying)
				{
					chargingParticles.Stop();
					chargingParticlePlaying = false;
				}
				if (StartOfRound.Instance.inShipPhase || !StartOfRound.Instance.shipHasLanded || !TimeOfDay.Instance.currentLevel.planetHasTime)
				{
					continue;
				}
				if (disabledInShip && base.isInShipRoom)
				{
					yield return null;
					continue;
				}
				while (((int)TimeOfDay.Instance.dayMode == 3 && !base.isInFactory) || ((int)TimeOfDay.Instance.dayMode == 2 && !base.isInFactory))
				{
					yield return (object)new WaitForSeconds(3f);
					if (StartOfRound.Instance.inShipPhase || (disabledInShip && base.isInShipRoom))
					{
						charge = 0;
						break;
					}
					if (base.isPocketed)
					{
						chargingParticles.Stop(true, (ParticleSystemStopBehavior)0);
						chargingParticlePlaying = false;
					}
					else if (!chargingParticlePlaying)
					{
						chargingParticles.Play();
						chargingParticlePlaying = true;
					}
					Collider[] playerColliderArray = Physics.OverlapSphere(((Component)this).transform.position, 4f, LayerMask.GetMask(new string[1] { "Player" }), (QueryTriggerInteraction)2);
					HashSet<PlayerControllerB> drainedPlayers = new HashSet<PlayerControllerB>();
					if (playerColliderArray.Length != 0)
					{
						Collider[] array = playerColliderArray;
						foreach (Collider collider in array)
						{
							PlayerControllerB targetPlayer = ((Component)collider).gameObject.GetComponent<PlayerControllerB>();
							if ((Object)(object)targetPlayer != (Object)null && !drainedPlayers.Contains(targetPlayer))
							{
								targetPlayer.DamagePlayer(10, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
								drainedPlayers.Add(targetPlayer);
								ParticleSystem DrainingParticle = Object.Instantiate<ParticleSystem>(drainingParticles, ((Component)collider).transform.position, Quaternion.identity, ((Component)targetPlayer).transform);
								DrainingParticle.Play();
								sounds[0].PlayOneShot(pulse);
								charge++;
							}
						}
					}
					if (charge >= 20)
					{
						chargingParticles.Stop();
						chargingParticlePlaying = false;
						chargedParticles.Play();
						chargedParticlesPlaying = true;
						chargedParticles.Stop();
						chargedParticlesPlaying = false;
						charge = 0;
						break;
					}
				}
			}
		}

		protected override void __initializeVariables()
		{
			((GrabbableObject)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			((GrabbableObject)this).__initializeRpcs();
		}

		protected internal override string __getTypeName()
		{
			return "BloodyCapsuleScript";
		}
	}
	public class CandyDispenserScript : GrabbableObject
	{
		private RaycastHit[] objectsHitByMeleeWeapon;

		private List<RaycastHit> objectsHitByMeleeWeaponList = new List<RaycastHit>();

		private bool isHoldingButton;

		private bool reelingUp;

		private Coroutine reelingUpCoroutine;

		private PlayerControllerB previousPlayerHeldBy;

		private static Item _candyItem;

		private GameObject dispenserBase;

		private MeshRenderer dispenserMesh;

		private int meleeWeaponMask = 1084754248;

		private int meleeWeaponHitForce = 1;

		private AudioSource dispenserAudio;

		private AudioClip swing;

		private AudioClip Dispense;

		private AudioClip[] hitSFX;

		private Color setColor;

		public void Awake()
		{
			dispenserAudio = ((Component)((Component)this).transform.Find("CandyDispenserSounds")).gameObject.GetComponent<AudioSource>();
			AudioSource[] components = ((Component)((Component)this).transform.Find("CandyDispenserSounds")).gameObject.GetComponents<AudioSource>();
			swing = components[1].clip;
			Dispense = components[2].clip;
			hitSFX = (AudioClip[])(object)new AudioClip[1] { dispenserAudio.clip };
		}

		public override void DiscardItem()
		{
			if ((Object)(object)base.playerHeldBy != (Object)null)
			{
				base.playerHeldBy.activatingItem = false;
			}
			((GrabbableObject)this).DiscardItem();
		}

		public override void Start()
		{
			((GrabbableObject)this).Start();
			SetColorServerRPC();
		}

		[ServerRpc(RequireOwnership = false)]
		public void SetColorServerRPC()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3606619266u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3606619266u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					byte b = (byte)new Random().Next(1, 256);
					byte b2 = (byte)new Random().Next(1, 256);
					byte b3 = (byte)new Random().Next(1, 256);
					setColor = Color32.op_Implicit(new Color32(b, b2, b3, byte.MaxValue));
					SetColorClientRPC(setColor);
				}
			}
		}

		[ClientRpc]
		public void SetColorClientRPC(Color color)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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_011f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(809217553u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref color);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 809217553u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					dispenserBase = ((Component)((Component)((Component)this).transform.Find("CandyDispenserModel")).gameObject.transform.Find("DispenserBase")).gameObject;
					dispenserMesh = dispenserBase.GetComponent<MeshRenderer>();
					((Renderer)dispenserMesh).material.color = color;
				}
			}
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			if ((Object)(object)base.playerHeldBy == (Object)null)
			{
				return;
			}
			isHoldingButton = buttonDown;
			if (!reelingUp && !reelingUp && buttonDown)
			{
				reelingUp = true;
				previousPlayerHeldBy = base.playerHeldBy;
				if (reelingUpCoroutine != null)
				{
					((MonoBehaviour)this).StopCoroutine(reelingUpCoroutine);
				}
				reelingUpCoroutine = ((MonoBehaviour)this).StartCoroutine(reelUpMeleeWeapon());
			}
		}

		private IEnumerator reelUpMeleeWeapon()
		{
			base.playerHeldBy.activatingItem = true;
			base.playerHeldBy.twoHanded = true;
			base.playerHeldBy.playerBodyAnimator.ResetTrigger("shovelHit");
			base.playerHeldBy.playerBodyAnimator.SetBool("reelingUp", true);
			yield return (object)new WaitForSeconds(0.35f);
			yield return (object)new WaitUntil((Func<bool>)(() => !isHoldingButton || !base.isHeld));
			SwingMeleeWeapon(!base.isHeld);
			yield return (object)new WaitForSeconds(0.13f);
			yield return (object)new WaitForEndOfFrame();
			HitMeleeWeapon(!base.isHeld);
			yield return (object)new WaitForSeconds(0.3f);
			reelingUp = false;
			reelingUpCoroutine = null;
		}

		public void SwingMeleeWeapon(bool cancel = false)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			previousPlayerHeldBy.playerBodyAnimator.SetBool("reelingUp", false);
			if (!cancel)
			{
				dispenserAudio.PlayOneShot(swing);
				previousPlayerHeldBy.UpdateSpecialAnimationValue(true, (short)((Component)previousPlayerHeldBy).transform.localEulerAngles.y, 0.4f, false);
			}
		}

		public void HitMeleeWeapon(bool cancel = false)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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_04b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)previousPlayerHeldBy == (Object)null)
			{
				return;
			}
			previousPlayerHeldBy.activatingItem = false;
			bool flag = false;
			bool flag2 = false;
			bool flag3 = false;
			int num = -1;
			if (!cancel)
			{
				previousPlayerHeldBy.twoHanded = false;
				objectsHitByMeleeWeapon = Physics.SphereCastAll(((Component)previousPlayerHeldBy.gameplayCamera).transform.position + ((Component)previousPlayerHeldBy.gameplayCamera).transform.right * -0.35f, 0.8f, ((Component)previousPlayerHeldBy.gameplayCamera).transform.forward, 1.5f, meleeWeaponMask, (QueryTriggerInteraction)2);
				objectsHitByMeleeWeaponList = objectsHitByMeleeWeapon.OrderBy(delegate(RaycastHit x)
				{
					//IL_0000: Unknown result type (might be due to invalid IL or missing references)
					//IL_0001: Unknown result type (might be due to invalid IL or missing references)
					RaycastHit val4 = x;
					return ((RaycastHit)(ref val4)).distance;
				}).ToList();
				List<EnemyAI> list = new List<EnemyAI>();
				IHittable val2 = default(IHittable);
				RaycastHit val3 = default(RaycastHit);
				for (int i = 0; i < objectsHitByMeleeWeaponList.Count; i++)
				{
					RaycastHit val = objectsHitByMeleeWeaponList[i];
					if (((Component)((RaycastHit)(ref val)).transform).gameObject.layer != 8)
					{
						val = objectsHitByMeleeWeaponList[i];
						if (((Component)((RaycastHit)(ref val)).transform).gameObject.layer != 11)
						{
							val = objectsHitByMeleeWeaponList[i];
							if (!((Component)((RaycastHit)(ref val)).transform).TryGetComponent<IHittable>(ref val2))
							{
								continue;
							}
							val = objectsHitByMeleeWeaponList[i];
							if ((Object)(object)((RaycastHit)(ref val)).transform == (Object)(object)((Component)previousPlayerHeldBy).transform)
							{
								continue;
							}
							val = objectsHitByMeleeWeaponList[i];
							if (!(((RaycastHit)(ref val)).point == Vector3.zero))
							{
								Vector3 position = ((Component)previousPlayerHeldBy.gameplayCamera).transform.position;
								val = objectsHitByMeleeWeaponList[i];
								if (Physics.Linecast(position, ((RaycastHit)(ref val)).point, ref val3, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
								{
									continue;
								}
							}
							flag = true;
							Vector3 forward = ((Component)previousPlayerHeldBy.gameplayCamera).transform.forward;
							try
							{
								val = objectsHitByMeleeWeaponList[i];
								EnemyAICollisionDetect component = ((Component)((RaycastHit)(ref val)).transform).GetComponent<EnemyAICollisionDetect>();
								if ((Object)(object)component != (Object)null)
								{
									if ((Object)(object)component.mainScript == (Object)null || list.Contains(component.mainScript))
									{
										continue;
									}
									goto IL_0369;
								}
								val = objectsHitByMeleeWeaponList[i];
								if (!((Object)(object)((Component)((RaycastHit)(ref val)).transform).GetComponent<PlayerControllerB>() != (Object)null))
								{
									goto IL_0369;
								}
								if (flag3)
								{
									continue;
								}
								flag3 = true;
								goto IL_0369;
								IL_0369:
								bool flag4 = val2.Hit(meleeWeaponHitForce, forward, previousPlayerHeldBy, true, 1);
								if (flag4 && (Object)(object)component != (Object)null)
								{
									list.Add(component.mainScript);
								}
								if (!flag2)
								{
									flag2 = flag4;
								}
							}
							catch (Exception arg)
							{
								MonoBehaviour.print((object)$"Error hitting object with Candy Dispenser {arg}, caused by playerInital: {previousPlayerHeldBy.playerClientId}");
							}
							continue;
						}
					}
					val = objectsHitByMeleeWeaponList[i];
					if (((RaycastHit)(ref val)).collider.isTrigger)
					{
						continue;
					}
					flag = true;
					val = objectsHitByMeleeWeaponList[i];
					string tag = ((Component)((RaycastHit)(ref val)).collider).gameObject.tag;
					for (int j = 0; j < StartOfRound.Instance.footstepSurfaces.Length; j++)
					{
						if (StartOfRound.Instance.footstepSurfaces[j].surfaceTag == tag)
						{
							num = j;
							dispenserAudio.PlayOneShot(StartOfRound.Instance.footstepSurfaces[j].hitSurfaceSFX);
							break;
						}
					}
				}
				float num2 = new Random().Next(1, 25);
				if (num2 == 1f)
				{
					if (StartOfRound.Instance.inShipPhase || !StartOfRound.Instance.shipHasLanded || !TimeOfDay.Instance.currentLevel.planetHasTime)
					{
						MonoBehaviour.print((object)"US - Candy spawning disabled here, land at a moon with a time cycle!");
						return;
					}
					dispenserAudio.PlayOneShot(Dispense);
					SpawnScrapServerRpc();
				}
			}
			if (flag)
			{
				int num3 = RoundManager.PlayRandomClip(dispe