Decompiled source of ButteRyBalance v0.2.1

ButteRyBalance.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using ButteRyBalance.NetcodePatcher;
using ButteRyBalance.Network;
using ButteRyBalance.Overrides;
using ButteRyBalance.Overrides.Moons;
using ButteRyBalance.Patches;
using DunGen;
using GameNetcodeStuff;
using HarmonyLib;
using LobbyCompatibility.Enums;
using LobbyCompatibility.Features;
using Microsoft.CodeAnalysis;
using MonoMod.Utils;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: AssemblyCompany("ButteRyBalance")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Buttery's rebalances")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+86d43d25890ba2c8eece2fe675fb2c4a44a2b40d")]
[assembly: AssemblyProduct("ButteRyBalance")]
[assembly: AssemblyTitle("ButteRyBalance")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<bool>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<bool>();
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[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 ButteRyBalance
{
	internal class Common
	{
		internal const int NUM_LEVELS = 13;

		internal static bool INSTALLED_ARTIFICE_BLIZZARD;

		internal static bool INSTALLED_BARBER_FIXES;

		internal static bool INSTALLED_VENT_SPAWN_FIX;

		internal static GameObject artificeBlizzard;

		internal static Dictionary<string, EnemyType> enemies = new Dictionary<string, EnemyType>();

		internal static void Disconnect()
		{
			enemies.Clear();
			StartOfRoundPatches.skipWeatherPatch = true;
		}

		internal static bool IsSnowLevel()
		{
			if (StartOfRound.Instance.currentLevel.levelIncludesSnowFootprints)
			{
				if (!((Object)(object)artificeBlizzard == (Object)null))
				{
					return artificeBlizzard.activeSelf;
				}
				return true;
			}
			return false;
		}
	}
	internal class Configuration
	{
		private static ConfigFile configFile;

		internal static ConfigEntry<bool> coilheadStunReset;

		internal static ConfigEntry<bool> jesterWalkThrough;

		internal static ConfigEntry<bool> butlerManorChance;

		internal static ConfigEntry<bool> butlerStealthStab;

		internal static ConfigEntry<bool> butlerLongCooldown;

		internal static ConfigEntry<bool> jesterLongCooldown;

		internal static ConfigEntry<bool> butlerKnifePrice;

		internal static ConfigEntry<bool> knifeShortCooldown;

		internal static ConfigEntry<bool> knifeAutoSwing;

		internal static ConfigEntry<bool> maneaterLimitGrowth;

		internal static ConfigEntry<bool> maneaterWideTurns;

		internal static ConfigEntry<bool> maneaterScrapGrowth;

		internal static ConfigEntry<bool> moonsKillSwitch;

		internal static ConfigEntry<bool> dineReduceButlers;

		internal static ConfigEntry<bool> barberDynamicSpawns;

		internal static ConfigEntry<bool> foggyLimit;

		internal static ConfigEntry<bool> experimentationNoEvents;

		internal static ConfigEntry<bool> experimentationNoGiants;

		internal static ConfigEntry<bool> experimentationNoEggs;

		internal static ConfigEntry<bool> experimentationNoNuts;

		internal static ConfigEntry<bool> experimentationBuffScrap;

		internal static ConfigEntry<bool> randomIndoorFog;

		internal static ConfigEntry<bool> assuranceNerfScrap;

		internal static ConfigEntry<bool> assuranceMasked;

		internal static ConfigEntry<bool> vowAdjustScrap;

		internal static ConfigEntry<bool> vowNoCoils;

		internal static ConfigEntry<bool> vowMineshafts;

		internal static ConfigEntry<bool> shrinkMineshafts;

		internal static ConfigEntry<bool> offenseBuffScrap;

		internal static ConfigEntry<bool> offenseMineshafts;

		internal static ConfigEntry<bool> offenseMasked;

		internal static ConfigEntry<bool> offenseNerfEclipse;

		internal static ConfigEntry<bool> vowNoTraps;

		internal static ConfigEntry<bool> marchShrink;

		internal static ConfigEntry<bool> marchBuffScrap;

		internal static ConfigEntry<bool> marchRainy;

		internal static ConfigEntry<bool> multiplayerWeather;

		internal static ConfigEntry<bool> butlerSquishy;

		internal static ConfigEntry<bool> adamanceBuffScrap;

		internal static ConfigEntry<bool> adamanceReduceChaos;

		internal static ConfigEntry<bool> coilheadCurves;

		internal static ConfigEntry<bool> rendMineshafts;

		internal static ConfigEntry<bool> rendShrink;

		internal static ConfigEntry<bool> rendAdjustIndoor;

		internal static ConfigEntry<bool> rendAdjustScrap;

		internal static ConfigEntry<bool> rendWorms;

		internal static ConfigEntry<bool> metalSheetPrice;

		internal static ConfigEntry<bool> coilheadPower;

		internal static ConfigEntry<bool> dineAdjustIndoor;

		internal static ConfigEntry<bool> dineBuffScrap;

		internal static ConfigEntry<bool> dineAdjustOutdoor;

		internal static ConfigEntry<bool> dineAdjustCurves;

		internal static ConfigEntry<bool> titanBuffScrap;

		internal static ConfigEntry<bool> titanAddGold;

		internal static ConfigEntry<bool> titanMineshafts;

		internal static ConfigEntry<bool> titanAdjustEnemies;

		internal static ConfigEntry<bool> titanWeeds;

		internal static ConfigEntry<bool> dineMasked;

		internal static ConfigEntry<bool> giantSnowSight;

		internal static ConfigEntry<bool> dineFloods;

		internal static ConfigEntry<bool> robotFog;

		internal static ConfigEntry<bool> nutcrackerGunPrice;

		internal static ConfigEntry<bool> nutcrackerKevlar;

		internal static ConfigEntry<bool> jetpackBattery;

		internal static ConfigEntry<bool> jetpackReduceDiscount;

		internal static ConfigEntry<bool> tzpExpandCapacity;

		internal static ConfigEntry<bool> jetpackInertia;

		internal static ConfigEntry<bool> artificeBuffScrap;

		internal static ConfigEntry<bool> artificeInteriors;

		internal static ConfigEntry<bool> artificeTurrets;

		internal static ConfigEntry<bool> zapGunPrice;

		internal static ConfigEntry<bool> radarBoosterPrice;

		internal static ConfigEntry<bool> stunGrenadePrice;

		internal static ConfigEntry<bool> scrapAdjustWeights;

		internal static ConfigEntry<bool> maneaterPower;

		internal static ConfigEntry<bool> embrionMineshafts;

		internal static ConfigEntry<bool> embrionBuffScrap;

		internal static ConfigEntry<bool> embrionWeeds;

		internal static ConfigEntry<bool> embrionAdjustEnemies;

		internal static ConfigEntry<bool> embrionMega;

		internal static ConfigEntry<bool> infestationRework;

		internal static ConfigEntry<bool> infestationButlers;

		internal static ConfigEntry<bool> infestationMasked;

		internal static ConfigEntry<bool> infestationBarbers;

		internal static ConfigEntry<bool> foxSquishy;

		internal static ConfigEntry<bool> zapGunBattery;

		internal static ConfigEntry<bool> offenseBees;

		internal static ConfigEntry<bool> apparatusPrice;

		internal static ConfigEntry<bool> robotRider;

		internal static ConfigEntry<bool> jetpackShortCircuit;

		internal static void Init(ConfigFile cfg)
		{
			configFile = cfg;
			MiscConfig();
			InfestationConfig();
			EnemyConfig();
			ItemConfig();
			MoonConfig();
			MigrateLegacyConfig();
		}

		private static void ItemConfig()
		{
			scrapAdjustWeights = configFile.Bind<bool>("Items", "Adjust Scrap Weights", false, "Makes some minor alterations to the weight of several scrap items.");
			apparatusPrice = configFile.Bind<bool>("Item.Apparatus", "Randomize Price", true, "Randomizes the price of the apparatus once it has been unplugged.");
			jetpackBattery = configFile.Bind<bool>("Item.Jetpack", "Reduce Battery", true, "Reduces jetpack battery back to 40s (from 50s), like the v50 beta.");
			jetpackReduceDiscount = configFile.Bind<bool>("Item.Jetpack", "Reduce Max Discount", true, "Jetpack price will never go beyond 60% off ($360)");
			jetpackInertia = configFile.Bind<bool>("Item.Jetpack", "v49 Controls", false, "Re-enables v49 jetpack controls, which had much greater inertia. This value can be enabled client-side, but will additionally be enforced for all players if enabled by the host.");
			knifeShortCooldown = configFile.Bind<bool>("Item.KitchenKnife", "Short Cooldown", true, "The knife will deal damage faster.");
			knifeAutoSwing = configFile.Bind<bool>("Item.KitchenKnife", "Auto-Swing", true, "(Client-side) Holding the attack button will automatically swing the knife. When damage is dealt, your swing speed will decrease to avoid wasting hits.");
			radarBoosterPrice = configFile.Bind<bool>("Item.RadarBooster", "Buff Price", true, "Reduces the cost of the radar booster from $60 to $50, like in v40.");
			stunGrenadePrice = configFile.Bind<bool>("Item.StunGrenade", "Nerf Price", true, "Increases the cost of stun grenades from $30 to $40, like in v40.");
			metalSheetPrice = configFile.Bind<bool>("Item.MetalSheet", "Increase Value", true, "Increases the average sell value of metal sheets.");
			tzpExpandCapacity = configFile.Bind<bool>("Item.TZPInhalant", "Expand Capacity", true, "Increases capacity of TZP inhalant from 22s to 34s.");
			zapGunPrice = configFile.Bind<bool>("Item.ZapGun", "Buff Price", true, "Reduces the cost of the zap gun from $400 to $200, like in v9.");
			zapGunBattery = configFile.Bind<bool>("Item.ZapGun", "Increase Battery", true, "Increases zap gun battery back to 120s (from 22s), like v9.");
		}

		private static void EnemyConfig()
		{
			barberDynamicSpawns = configFile.Bind<bool>("Enemy.Barber", "Dynamic Spawn Settings", true, "Barbers will spawn in pairs, up to 8 total, in factories and manors. In mineshafts, they are limited to 1 total.");
			butlerManorChance = configFile.Bind<bool>("Enemy.Butler", "Manor Increased Chance", true, "Butlers have an increased chance to spawn in manor interiors.");
			butlerStealthStab = configFile.Bind<bool>("Enemy.Butler", "Stealth Stab", true, "When triggering a Butler to attack by bumping into it (rare chance), it will no longer \"berserk\", unless the offending player is alone.");
			butlerLongCooldown = configFile.Bind<bool>("Enemy.Butler", "Slow Attacks", true, "Butlers will deal damage slower, as long as they haven't been attacked before. In singleplayer, this setting will also increase their HP from 2 to 3.");
			butlerSquishy = configFile.Bind<bool>("Enemy.Butler", "Squishy", true, "Butlers take bonus damage from shotgun shots and explosions, allowing those to kill in one hit.");
			butlerKnifePrice = configFile.Bind<bool>("Enemy.Butler", "Randomize Knife Price", true, "Restores the kitchen knife's price randomization. On average, it will be significantly more valuable than $35, the vanilla price.");
			coilheadStunReset = configFile.Bind<bool>("Enemy.Coilhead", "Stuns Reset", true, "Coil-heads will begin \"recharging\" when they are stunned by stun grenades, radar boosters, or homemade flashbangs.");
			coilheadCurves = configFile.Bind<bool>("Enemy.Coilhead", "Adjust Spawn Curves", true, "Adds two multipliers to Coil-head spawn rates; one reduces their chances earlier in the day, and the other reduces the chance of multiple spawning in one day.");
			coilheadPower = configFile.Bind<bool>("Enemy.Coilhead", "Increase Power Level", true, "Increase Coil-heads' power level from 1 to 2, to reduce the potential for forming bad enemy combos.");
			giantSnowSight = configFile.Bind<bool>("Enemy.ForestKeeper", "Treat Blizzard Like Fog", true, "On snowy moons, Forest Keepers will have their line-of-sight range reduced, the same way as in foggy weather.");
			foxSquishy = configFile.Bind<bool>("Enemy.KidnapperFox", "Squishy", true, "Reduce kidnapper fox HP from 7 to 6, and shotgun deals bonus damasge. This allows the fox to be killed easier with a single explosion (like easter eggs) or both barrels from the shotgun.");
			jesterWalkThrough = configFile.Bind<bool>("Enemy.Jester", "Walk-Through", true, "Lets you walk through Jesters once they begin winding up.");
			jesterLongCooldown = configFile.Bind<bool>("Enemy.Jester", "Long Cooldown", true, "Slightly increase the average time before a Jester winds, in multiplayer.");
			maneaterPower = configFile.Bind<bool>("Enemy.Maneater", "Increase Power Level", true, "Increase the Maneater's power level from 2 to 3, to reduce the potential for forming bad enemy combos.");
			maneaterLimitGrowth = configFile.Bind<bool>("Enemy.Maneater", "Limit Growth", true, "Sharply limits (or completely prevents) the Maneater's ability to transform before it has been encountered by a player.");
			maneaterScrapGrowth = configFile.Bind<bool>("Enemy.Maneater", "Metabolism", true, "Eating scrap will permanently reduce the speed at which a Maneater transforms from crying.");
			maneaterWideTurns = configFile.Bind<bool>("Enemy.Maneater", "Limit Turn Speed", true, "Adult Maneaters will have far worse turning speed when lunging, as long as they are inside the building.");
			nutcrackerGunPrice = configFile.Bind<bool>("Enemy.Nutcracker", "Randomize Shotgun Price", true, "Restores randomization for the shotgun's price.");
			nutcrackerKevlar = configFile.Bind<bool>("Enemy.Nutcracker", "Last Stand", true, "Nutcrackers will resist instant death from a shotgun blast if they are at full health, immediately entering \"berserk\" state.");
			robotFog = configFile.Bind<bool>("Enemy.OldBird", "See Through Fog", true, "Old Birds can see through fog with their powerful searchlights.");
			robotRider = configFile.Bind<bool>("Enemy.OldBird", "Restore Mech Riding", true, "Lets you ride and drop items on top of Old Birds, like in v64.");
		}

		private static void MoonConfig()
		{
			moonsKillSwitch = configFile.Bind<bool>("Moons", "Kill Switch", false, "If this setting is enabled, all other settings in the \"Moon\" category will be disabled. This is helpful if you want to use an external mod to configure them.");
			experimentationBuffScrap = configFile.Bind<bool>("Moon.Experimentation", "Buff Scrap", true, "Increases the amount of scrap that spawns on Experimentation, like in v9. (8-11 -> 11-15)");
			experimentationNoEvents = configFile.Bind<bool>("Moon.Experimentation", "No Random Events", true, "Disables all random events on Experimentation. (Meteor showers, infestations, spooky fog)");
			experimentationNoGiants = configFile.Bind<bool>("Moon.Experimentation", "No Forest Keepers", true, "Forest Keepers no longer have a random chance to spawn on Experimentation.");
			experimentationNoNuts = configFile.Bind<bool>("Moon.Experimentation", "No Nutcrackers", false, "Nutcrackers no longer have a random chance to spawn on Experimentation.");
			experimentationNoEggs = configFile.Bind<bool>("Moon.Experimentation", "No Easter Eggs", true, "Easter eggs no longer appear in Experimentation's loot pool.");
			assuranceNerfScrap = configFile.Bind<bool>("Moon.Assurance", "Nerf Scrap", true, "Reduces scrap counts on Assurance from 13-15 to 11-15, like in v9. Swaps several items' rarities with the corresponding values from Offense's loot pool.");
			assuranceMasked = configFile.Bind<bool>("Moon.Assurance", "Spawn Masked", true, "Allow \"Masked\" enemies to spawn very rarely on Assurance, since Comedy and Tragedy spawn there.");
			vowAdjustScrap = configFile.Bind<bool>("Moon.Vow", "Adjust Scrap", true, "Slightly reduce the \"quality\" of scrap items on Vow, to keep it more in line with Experimentation and Assurance, and a little below March.");
			vowMineshafts = configFile.Bind<bool>("Moon.Vow", "Mostly Mineshafts", true, "Significantly reduce the likelihood of factory interiors on Vow.");
			vowNoCoils = configFile.Bind<bool>("Moon.Vow", "No Coil-heads", true, "Coil-heads no longer have a random chance to spawn on Vow.");
			vowNoTraps = configFile.Bind<bool>("Moon.Vow", "No Traps", true, "Removes landmines and turrets from Vow, like in v9.");
			offenseBuffScrap = configFile.Bind<bool>("Moon.Offense", "Buff Scrap", true, "Swaps several items' rarities with the corresponding values from Assurance's loot pool.");
			offenseBees = configFile.Bind<bool>("Moon.Offense", "Circuit Bees", true, "Allow circuit bees to spawn on Offense, like Assurance.");
			offenseMineshafts = configFile.Bind<bool>("Moon.Offense", "Mostly Mineshafts", true, "Significantly reduce the likelihood of factory interiors on Offense.");
			offenseMasked = configFile.Bind<bool>("Moon.Offense", "Spawn Masked", true, "Allow \"Masked\" enemies to spawn rarely on Offense, since Comedy spawns there.");
			offenseNerfEclipse = configFile.Bind<bool>("Moon.Offense", "Nerf Eclipse", true, "Reduces enemy spawns per \"wave\" during eclipses on Offense from 4 to 3.");
			marchBuffScrap = configFile.Bind<bool>("Moon.March", "Buff Scrap", true, "Increases the amount of scrap that spawns on March, like in v9. (13-16 -> 16-20)");
			marchShrink = configFile.Bind<bool>("Moon.March", "Shrink Interior", true, "Reduces March's interior size multiplier from 2x to 1.8x, like in v9.");
			marchRainy = configFile.Bind<bool>("Moon.March", "Always Rainy", true, "Rainy weather becomes the new default weather on March, and mild weather becomes a rare alternate weather, like eclipses and storms.");
			adamanceBuffScrap = configFile.Bind<bool>("Moon.Adamance", "Buff Scrap", true, "Increases the amount of scrap that spawns on Adamance, like in the v50 betas. (16-18 -> 19-23)");
			adamanceReduceChaos = configFile.Bind<bool>("Moon.Adamance", "Reduce Chaos", true, "Curbs the Artifice-level shenanigans by reducing outdoor power from 13 to 10. Eclipses spawn 2 enemies per wave instead of 3.");
			rendMineshafts = configFile.Bind<bool>("Moon.Rend", "Rare Mineshafts", true, "Sharply reduce mineshaft chance on Rend, so it goes back to being almost always manors.");
			rendShrink = configFile.Bind<bool>("Moon.Rend", "Shrink Interior", true, "Reduces Rend's interior size multiplier from 1.8x to 1.6x.");
			rendAdjustIndoor = configFile.Bind<bool>("Moon.Rend", "Adjust Indoor Enemies", true, "Increase the variety of enemies that spawn inside the building on Rend, to reduce total nutcracker domination.");
			rendAdjustScrap = configFile.Bind<bool>("Moon.Rend", "Adjust Scrap", true, "Slightly reduces the overall quality of items on Rend.");
			rendWorms = configFile.Bind<bool>("Moon.Rend", "Restore Earth Leviathans", true, "Allow Earth Leviathans, which were removed from Rend in v56, to spawn again.");
			dineBuffScrap = configFile.Bind<bool>("Moon.Dine", "Buff Scrap", true, "Significantly improves average quality of scrap on Dine. Also increases scrap counts from 22-25 to 22-27, like in v50 betas.");
			dineReduceButlers = configFile.Bind<bool>("Moon.Dine", "Reduce Butler Chance", true, "Reduces the spawn weight of Butlers on Dine. Intended to be combined with the \"Manor Increased Chance\" setting for Butlers.");
			dineAdjustIndoor = configFile.Bind<bool>("Moon.Dine", "Adjust Indoor Enemies", true, "Increase the variety of enemies that spawn inside the building on Dine.");
			dineAdjustOutdoor = configFile.Bind<bool>("Moon.Dine", "Adjust Outdoor Enemies", true, "Decrease giants' and dogs' spawn chance, resulting in more robots and worms.");
			dineAdjustCurves = configFile.Bind<bool>("Moon.Dine", "Adjust Spawn Curves", true, "Rolls back the outdoor spawn curve from v60, to match the one from v56. This will significantly reduce enemies spawning outside in the early morning hours.");
			dineFloods = configFile.Bind<bool>("Moon.Dine", "Fix Floods", true, "Reduces the water level at the start of flooded weather days on Dine, so that the main entrance no longer starts out underwater.");
			dineMasked = configFile.Bind<bool>("Moon.Dine", "Add Masked", true, "Allow \"Masked\" enemies to spawn on Dine, since Comedy and Tragedy spawn there.");
			titanBuffScrap = configFile.Bind<bool>("Moon.Titan", "Buff Scrap", true, "Significantly improves average quality of scrap on Titan. Also increases scrap counts from 28-31 to 28-35, like in v50 betas.");
			titanAddGold = configFile.Bind<bool>("Moon.Titan", "Gold Rush", true, "Adds gold bars to Titan's loot pool as a rare find.");
			titanMineshafts = configFile.Bind<bool>("Moon.Titan", "Reduce Mineshafts", true, "Reduces mineshaft chance on Titan, since they are often far larger than any other moon's interiors.");
			titanAdjustEnemies = configFile.Bind<bool>("Moon.Titan", "Adjust Enemies", true, "Adjusts enemy balance, mainly to reduce Jesters and giants. Also slightly increases Old Birds.");
			titanWeeds = configFile.Bind<bool>("Moon.Titan", "No Vain Shrouds", true, "Disable vain shroud growth on Titan, to prevent the Kidnapper Fox from camping the ship.");
			artificeBuffScrap = configFile.Bind<bool>("Moon.Artifice", "Buff Scrap", true, "Restores Artifice's scrap counts from v56 (26-30 to 31-37), and also restores original gold bar spawn chance.");
			artificeInteriors = configFile.Bind<bool>("Moon.Artifice", "Adjust Interiors", true, "Adjusts interior chances to make manor dominant again. (15%/35%/50% -> 15%/50%/35%) Also increases the size of manors and factories from 1.8x to 2.0x, but mineshafts are not affected.");
			artificeTurrets = configFile.Bind<bool>("Moon.Artifice", "Increase Turrets", true, "Drastically increase the spawn rate of turrets, like in the v50 betas.");
			embrionBuffScrap = configFile.Bind<bool>("Moon.Embrion", "Buff Scrap", true, "Significantly improves the quality of scrap found on Embrion.");
			embrionMineshafts = configFile.Bind<bool>("Moon.Embrion", "Increase Mineshafts", true, "Significantly increase the chance of mineshafts on Embrion.");
			embrionWeeds = configFile.Bind<bool>("Moon.Embrion", "No Vain Shrouds", true, "Disable vain shroud growth on Embrion, since there is limited biological life on the surface.");
			embrionAdjustEnemies = configFile.Bind<bool>("Moon.Embrion", "Adjust Indoor Enemies", true, "Increase the spawn rates of non-biological enemies in the interior.");
			embrionMega = configFile.Bind<bool>("Moon.Embrion", "Bigger on the Inside", false, "Double the interior size, dramatically reduce the chance of factories, and greatly increase the number of scrap items.");
		}

		private static void MiscConfig()
		{
			multiplayerWeather = configFile.Bind<bool>("Misc", "Multiplayer Weather Multiplier", true, "Re-enable some unused code in vanilla to increase the frequency of random weather in multiplayer.");
			foggyLimit = configFile.Bind<bool>("Misc", "Nerf Foggy Weather", true, "Reduce the maximum intensity of foggy weather.");
			randomIndoorFog = configFile.Bind<bool>("Misc", "Random Indoor Fog", true, "When the indoor fog event occurs, its density will be randomized between the vanilla value and a much less extreme value.");
			shrinkMineshafts = configFile.Bind<bool>("Misc", "Shrink Mineshafts", true, "Slightly reduce the overall size of mineshaft interiors.");
		}

		private static void InfestationConfig()
		{
			infestationRework = configFile.Bind<bool>("Infestations", "Rework Mechanics", true, "Infestations no longer override a moon's power level, and enemy spawn chances are no longer equalized. The \"infestation enemy\" takes up no power level during the event, and \"bonus spawns\" only occur until the infestation enemy hits their spawn cap.");
			infestationButlers = configFile.Bind<bool>("Infestations", "Butler Infestations", true, "Allow butlers to be selected as the subject of an infestation.");
			infestationMasked = configFile.Bind<bool>("Infestations", "Masked Infestations", true, "Allow \"masked\" to be selected as the subject of an infestation.");
			infestationBarbers = configFile.Bind<bool>("Infestations", "Barber Infestations", true, "Allow Barbers to be selected as the subject of an infestation. Other enemy spawns will be disabled. Won't occur inside mineshafts.");
		}

		private static void MigrateLegacyConfig()
		{
			if (foggyLimit.Value)
			{
				if (!configFile.Bind<bool>("Misc", "Rework Foggy Weather", true, "Legacy setting, doesn't work").Value)
				{
					foggyLimit.Value = false;
				}
				configFile.Remove(configFile["Misc", "Rework Foggy Weather"].Definition);
			}
		}
	}
	internal static class LobbyCompatibility
	{
		internal static void Init()
		{
			PluginHelper.RegisterPlugin("butterystancakes.lethalcompany.butterybalance", Version.Parse("0.2.1"), (CompatibilityLevel)2, (VersionStrictness)3);
		}
	}
	[BepInPlugin("butterystancakes.lethalcompany.butterybalance", "ButteRyBalance", "0.2.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal const string PLUGIN_GUID = "butterystancakes.lethalcompany.butterybalance";

		internal const string PLUGIN_NAME = "ButteRyBalance";

		internal const string PLUGIN_VERSION = "0.2.1";

		internal static ManualLogSource Logger;

		private const string GUID_LOBBY_COMPATIBILITY = "BMX.LobbyCompatibility";

		private const string GUID_ARTIFICE_BLIZZARD = "butterystancakes.lethalcompany.artificeblizzard";

		private const string GUID_BARBER_FIXES = "butterystancakes.lethalcompany.barberfixes";

		private const string GUID_VENT_SPAWN_FIX = "butterystancakes.lethalcompany.ventspawnfix";

		private void Awake()
		{
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			NetcodePatch();
			Logger = ((BaseUnityPlugin)this).Logger;
			if (Chainloader.PluginInfos.ContainsKey("BMX.LobbyCompatibility"))
			{
				Logger.LogInfo((object)"CROSS-COMPATIBILITY - Lobby Compatibility detected");
				LobbyCompatibility.Init();
			}
			if (Chainloader.PluginInfos.ContainsKey("butterystancakes.lethalcompany.artificeblizzard"))
			{
				Logger.LogInfo((object)"CROSS-COMPATIBILITY - Artifice Blizzard detected");
				Common.INSTALLED_ARTIFICE_BLIZZARD = true;
			}
			if (Chainloader.PluginInfos.ContainsKey("butterystancakes.lethalcompany.barberfixes"))
			{
				Logger.LogInfo((object)"CROSS-COMPATIBILITY - Barber Fixes detected");
				Common.INSTALLED_BARBER_FIXES = true;
			}
			if (Chainloader.PluginInfos.ContainsKey("butterystancakes.lethalcompany.ventspawnfix"))
			{
				Logger.LogInfo((object)"CROSS-COMPATIBILITY - Vent Spawn Fix detected");
				Common.INSTALLED_VENT_SPAWN_FIX = true;
			}
			Configuration.Init(((BaseUnityPlugin)this).Config);
			new Harmony("butterystancakes.lethalcompany.butterybalance").PatchAll();
			Logger.LogInfo((object)"ButteRyBalance v0.2.1 loaded");
		}

		private void NetcodePatch()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			for (int i = 0; i < types.Length; i++)
			{
				MethodInfo[] methods = types[i].GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				foreach (MethodInfo methodInfo in methods)
				{
					if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "ButteRyBalance";

		public const string PLUGIN_NAME = "ButteRyBalance";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace ButteRyBalance.Patches
{
	[HarmonyPatch(typeof(GameNetworkManager))]
	internal class GameNetworkManagerPatches
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void GameNetworkManager_Post_Start()
		{
			BRBNetworker.Init();
		}

		[HarmonyPatch("Disconnect")]
		[HarmonyPostfix]
		public static void GameNetworkManager_Post_Disconnect()
		{
			if ((Object)(object)RoundManager.Instance != (Object)null && ((NetworkBehaviour)RoundManager.Instance).IsServer)
			{
				InfestationOverrides.EndInfestation();
			}
			Common.Disconnect();
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatches
	{
		private static bool wasCrouching;

		[HarmonyPatch("UpdatePlayerAnimationsToOtherClients")]
		[HarmonyPrefix]
		public static void PlayerControllerB_Pre_UpdatePlayerAnimationsToOtherClients(PlayerControllerB __instance, ref float __state)
		{
			__state = __instance.updatePlayerAnimationsInterval;
		}

		[HarmonyPatch("UpdatePlayerAnimationsToOtherClients")]
		[HarmonyPostfix]
		public static void PlayerControllerB_Post_UpdatePlayerAnimationsToOtherClients(PlayerControllerB __instance, float __state)
		{
			if (((NetworkBehaviour)__instance).IsOwner && __instance.updatePlayerAnimationsInterval < __state && __instance.isCrouching != wasCrouching)
			{
				wasCrouching = __instance.isCrouching;
				BRBNetworker.Instance.SyncCrouchingServerRpc((int)__instance.playerClientId, __instance.isCrouching);
			}
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class RoundManagerPatches
	{
		[HarmonyPatch("RefreshEnemiesList")]
		[HarmonyPostfix]
		private static void RoundManager_Post_RefreshEnemiesList(RoundManager __instance)
		{
			InfestationOverrides.EndInfestation();
			if (((Object)__instance.currentLevel).name == "ExperimentationLevel" && BRBNetworker.Instance.ExperimentationNoEvents.Value && !BRBNetworker.Instance.MoonsKillSwitch.Value)
			{
				__instance.enemyRushIndex = -1;
				__instance.currentMaxInsidePower = __instance.currentLevel.maxEnemyPowerCount;
				((Component)__instance.indoorFog).gameObject.SetActive(false);
			}
			else
			{
				if (((NetworkBehaviour)__instance).IsServer && __instance.enemyRushIndex >= 0 && Configuration.infestationRework.Value)
				{
					InfestationOverrides.CustomInfestation((((Object)__instance.currentLevel.Enemies[__instance.enemyRushIndex].enemyType).name == "ClaySurgeon") ? __instance.enemyRushIndex : (-1));
				}
				if (((Component)__instance.indoorFog).gameObject.activeSelf && BRBNetworker.Instance.RandomIndoorFog.Value)
				{
					__instance.indoorFog.parameters.meanFreePath = new Random(StartOfRound.Instance.randomMapSeed + 5781).Next(5, 11);
				}
			}
			if (!((NetworkBehaviour)__instance).IsServer || !Configuration.barberDynamicSpawns.Value)
			{
				return;
			}
			if (Common.enemies.TryGetValue("ClaySurgeon", out var value))
			{
				if (RoundManager.Instance.currentDungeonType == 4 && InfestationOverrides.GetInfesterName() != "ClaySurgeon")
				{
					value.MaxCount = 1;
					value.spawnInGroupsOf = 1;
					Plugin.Logger.LogDebug((object)"Barber - Dynamic Spawn Settings: 1/1 (Mineshaft)");
				}
				else if (Common.INSTALLED_BARBER_FIXES)
				{
					value.MaxCount = 8;
					if (Common.INSTALLED_VENT_SPAWN_FIX)
					{
						value.spawnInGroupsOf = 2;
						Plugin.Logger.LogDebug((object)$"Barber - Dynamic Spawn Settings: 2/8 (Interior ID: {RoundManager.Instance.currentDungeonType})");
					}
					else
					{
						Plugin.Logger.LogWarning((object)"Can't increase Barber spawn group because Vent Spawn Fix is not loaded. Please install it and make sure it works correctly");
					}
				}
				else
				{
					Plugin.Logger.LogWarning((object)"Can't increase Barber max count because Barber Fixes is not loaded. Please install it and make sure it works correctly, or disable \"Dynamic Spawn Settings\" in the \"Enemy.Barber\" config");
				}
			}
			else
			{
				Plugin.Logger.LogWarning((object)"Failed to reference Barber enemy type. This should never happen");
			}
		}

		[HarmonyPatch("GenerateNewFloor")]
		[HarmonyPrefix]
		private static void RoundManager_Pre_GenerateNewFloor(RoundManager __instance)
		{
			switch (((Object)__instance.currentLevel).name)
			{
			case "VowLevel":
				if (BRBNetworker.Instance.VowMineshafts.Value)
				{
					MoonOverrides.AdjustInteriors(__instance.currentLevel, VowOverrides.adjustedInteriors);
				}
				break;
			case "OffenseLevel":
				if (BRBNetworker.Instance.OffenseMineshafts.Value)
				{
					MoonOverrides.AdjustInteriors(__instance.currentLevel, OffenseOverrides.adjustedInteriors);
				}
				break;
			case "RendLevel":
				if (BRBNetworker.Instance.RendMineshafts.Value)
				{
					MoonOverrides.AdjustInteriors(__instance.currentLevel, RendOverrides.adjustedInteriors);
				}
				break;
			case "TitanLevel":
				if (BRBNetworker.Instance.TitanMineshafts.Value)
				{
					MoonOverrides.AdjustInteriors(__instance.currentLevel, TitanOverrides.adjustedInteriors);
				}
				break;
			case "ArtificeLevel":
				if (BRBNetworker.Instance.ArtificeInteriors.Value)
				{
					MoonOverrides.AdjustInteriors(__instance.currentLevel, ArtificeOverrides.adjustedInteriors);
				}
				break;
			case "EmbrionLevel":
				if (BRBNetworker.Instance.EmbrionMineshafts.Value)
				{
					MoonOverrides.AdjustInteriors(__instance.currentLevel, EmbrionOverrides.adjustedInteriors);
				}
				if (BRBNetworker.Instance.EmbrionMega.Value)
				{
					MoonOverrides.AdjustInteriors(__instance.currentLevel, EmbrionOverrides.megaInteriors);
				}
				break;
			}
		}

		[HarmonyPatch("FinishGeneratingNewLevelClientRpc")]
		[HarmonyPostfix]
		private static void RoundManager_Post_FinishGeneratingNewLevelClientRpc(RoundManager __instance)
		{
			if (((Object)StartOfRound.Instance.currentLevel).name == "ArtificeLevel" && Common.INSTALLED_ARTIFICE_BLIZZARD)
			{
				Common.artificeBlizzard = GameObject.Find("/Systems/Audio/BlizzardAmbience");
				if ((Object)(object)Common.artificeBlizzard != (Object)null)
				{
					Plugin.Logger.LogDebug((object)"Artifice Blizzard compatibility success");
				}
			}
		}

		[HarmonyPatch("SetToCurrentLevelWeather")]
		[HarmonyPostfix]
		private static void RoundManager_Post_SetToCurrentLevelWeather(RoundManager __instance)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			if (((Object)__instance.currentLevel).name == "DineLevel" && (int)TimeOfDay.Instance.currentLevelWeather == 4 && BRBNetworker.Instance.DineFloods.Value)
			{
				TimeOfDay.Instance.currentWeatherVariable = -16f;
				TimeOfDay.Instance.currentWeatherVariable2 = -5f;
			}
		}

		[HarmonyPatch("SpawnOutsideHazards")]
		[HarmonyPrefix]
		private static void RoundManager_Pre_SpawnOutsideHazards(RoundManager __instance)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.currentLevel.levelID >= 13)
			{
				return;
			}
			if ((Object)(object)RoundManager.Instance?.mapPropsContainer == (Object)null)
			{
				Plugin.Logger.LogWarning((object)"Can't create SpawnDenialPoint(s) because mapPropsContainer is missing, this *might* cause desync with other clients");
				return;
			}
			EntranceTeleport[] array = Object.FindObjectsByType<EntranceTeleport>((FindObjectsSortMode)0);
			foreach (EntranceTeleport val in array)
			{
				if (val.isEntranceToBuilding)
				{
					CreateSpawnDenialPoint(val.entrancePoint.position);
					Plugin.Logger.LogDebug((object)(((Object)__instance.currentLevel).name + ": SpawnDenialPoint (Entrance)"));
				}
			}
			InteractTrigger[] array2 = Object.FindObjectsByType<InteractTrigger>((FindObjectsSortMode)0);
			foreach (InteractTrigger val2 in array2)
			{
				if (val2.isLadder && (Object)(object)val2.bottomOfLadderPosition != (Object)null)
				{
					CreateSpawnDenialPoint(val2.bottomOfLadderPosition.position);
					Plugin.Logger.LogDebug((object)(((Object)__instance.currentLevel).name + ": SpawnDenialPoint (Ladder)"));
				}
			}
		}

		private static void CreateSpawnDenialPoint(Vector3 pos)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = new GameObject("SpawnDenialPointBRB")
			{
				tag = "SpawnDenialPoint"
			}.transform;
			transform.SetParent(RoundManager.Instance.mapPropsContainer.transform);
			transform.position = pos;
		}

		[HarmonyPatch("SpawnEnemiesOutside")]
		[HarmonyPostfix]
		private static void RoundManager_Post_SpawnEnemiesOutside(RoundManager __instance)
		{
			if (((NetworkBehaviour)__instance).IsServer)
			{
				InfestationOverrides.SpawnInfestationWave();
			}
		}

		[HarmonyPatch("AdvanceHourAndSpawnNewBatchOfEnemies")]
		[HarmonyPostfix]
		private static void RoundManager_Post_AdvanceHourAndSpawnNewBatchOfEnemies(RoundManager __instance)
		{
			if (!((NetworkBehaviour)__instance).IsServer)
			{
				return;
			}
			__instance.enemySpawnTimes.Clear();
			EnemyVent[] allEnemyVents = __instance.allEnemyVents;
			foreach (EnemyVent val in allEnemyVents)
			{
				if (val.occupied)
				{
					__instance.enemySpawnTimes.Add((int)val.spawnTime);
				}
			}
			__instance.enemySpawnTimes.Sort();
		}

		[HarmonyPatch("BeginEnemySpawning")]
		[HarmonyPrefix]
		private static void RoundManager_Pre_BeginEnemySpawning(RoundManager __instance)
		{
			if (((NetworkBehaviour)__instance).IsServer)
			{
				InfestationOverrides.SpawnInfestationWave();
			}
		}

		[HarmonyPatch("SpawnScrapInLevel")]
		[HarmonyPrefix]
		private static void RoundManager_Pre_SpawnScrapInLevel(RoundManager __instance)
		{
			if (((Object)__instance.currentLevel).name == "AdamanceLevel" && Configuration.adamanceBuffScrap.Value)
			{
				if (__instance.currentDungeonType != 4)
				{
					__instance.currentLevel.minScrap = 19;
					__instance.currentLevel.maxScrap = 24;
				}
				else
				{
					__instance.currentLevel.minScrap = 16;
					__instance.currentLevel.maxScrap = 19;
				}
			}
		}
	}
	[HarmonyPatch(typeof(RuntimeDungeon))]
	internal class RuntimeDungeonPatches
	{
		private const float REND_DINE_DIFF = 0.923077f;

		[HarmonyPatch("Generate")]
		[HarmonyPrefix]
		private static void RuntimeDungeon_Pre_Generate(RuntimeDungeon __instance)
		{
			bool flag = RoundManager.Instance.currentDungeonType == 4 && BRBNetworker.Instance.ShrinkMineshafts.Value;
			if (flag)
			{
				DungeonGenerator generator = __instance.Generator;
				generator.LengthMultiplier *= 0.80999994f;
				Plugin.Logger.LogDebug((object)"Invert mineshaft MapTileSize");
			}
			switch (((Object)RoundManager.Instance.currentLevel).name)
			{
			case "MarchLevel":
				if (BRBNetworker.Instance.MarchShrink.Value)
				{
					DungeonGenerator generator5 = __instance.Generator;
					generator5.LengthMultiplier *= 0.9f;
					Plugin.Logger.LogDebug((object)"Shrunk March interior");
				}
				break;
			case "DineLevel":
				if (BRBNetworker.Instance.RendShrink.Value && flag)
				{
					DungeonGenerator generator6 = __instance.Generator;
					generator6.LengthMultiplier *= 0.923077f;
					Plugin.Logger.LogDebug((object)"Shrunk Dine mineshaft");
				}
				break;
			case "TitanLevel":
				if (flag)
				{
					DungeonGenerator generator3 = __instance.Generator;
					generator3.LengthMultiplier /= 1.1f;
					Plugin.Logger.LogDebug((object)"Shrunk Titan mineshaft");
				}
				break;
			case "ArtificeLevel":
				if (RoundManager.Instance.currentDungeonType != 4 && BRBNetworker.Instance.ArtificeInteriors.Value)
				{
					DungeonGenerator generator4 = __instance.Generator;
					generator4.LengthMultiplier /= 0.9f;
					Plugin.Logger.LogDebug((object)"Increase Artifice factory/manor");
				}
				break;
			case "EmbrionLevel":
				if (BRBNetworker.Instance.EmbrionMega.Value)
				{
					switch (RoundManager.Instance.currentDungeonType)
					{
					case 0:
						__instance.Generator.LengthMultiplier = 2.35f * RoundManager.Instance.mapSizeMultiplier;
						break;
					case 1:
						__instance.Generator.LengthMultiplier = 2.4f * RoundManager.Instance.mapSizeMultiplier;
						break;
					case 4:
						__instance.Generator.LengthMultiplier = 2.4444447f * RoundManager.Instance.mapSizeMultiplier;
						break;
					default:
					{
						DungeonGenerator generator2 = __instance.Generator;
						generator2.LengthMultiplier *= 2f;
						break;
					}
					}
				}
				break;
			}
			__instance.Generator.LengthMultiplier = Mathf.Floor(__instance.Generator.LengthMultiplier * 100f) / 100f;
			Plugin.Logger.LogDebug((object)$"Final length multiplier: {__instance.Generator.LengthMultiplier} (Interior #{RoundManager.Instance.currentDungeonType}, seed: {StartOfRound.Instance.randomMapSeed})");
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatches
	{
		internal static bool skipWeatherPatch = true;

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void StartOfRound_Post_Awake(StartOfRound __instance)
		{
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Expected O, but got Unknown
			if (Common.enemies.Count < 1)
			{
				SelectableLevel val = Object.FindAnyObjectByType<QuickMenuManager>()?.testAllEnemiesLevel;
				if ((Object)(object)val != (Object)null)
				{
					List<SpawnableEnemyWithRarity>[] array = new List<SpawnableEnemyWithRarity>[3] { val.Enemies, val.OutsideEnemies, val.DaytimeEnemies };
					for (int i = 0; i < array.Length; i++)
					{
						foreach (SpawnableEnemyWithRarity item in array[i])
						{
							if (!Common.enemies.ContainsKey(((Object)item.enemyType).name))
							{
								Common.enemies.Add(((Object)item.enemyType).name, item.enemyType);
							}
						}
					}
				}
			}
			EnemyType masked = Common.enemies["MaskedPlayerEnemy"];
			if ((Object)(object)masked != (Object)null)
			{
				SelectableLevel[] levels = __instance.levels;
				foreach (SelectableLevel val2 in levels)
				{
					if ((val2.sceneName == "Level2Assurance" || val2.sceneName == "Level6Dine" || val2.sceneName == "Level7Offense") && !val2.Enemies.Any((SpawnableEnemyWithRarity enemy) => (Object)(object)enemy.enemyType == (Object)(object)masked))
					{
						val2.Enemies.Add(new SpawnableEnemyWithRarity
						{
							enemyType = masked,
							rarity = 0
						});
						Plugin.Logger.LogDebug((object)("Added Masked to " + ((Object)val2).name + " pool on client (fallback)"));
					}
				}
			}
			else
			{
				Plugin.Logger.LogWarning((object)"Failed to reference Masked enemy type. This should never happen");
			}
			BRBNetworker.Create();
		}

		[HarmonyPatch("SetPlanetsWeather")]
		[HarmonyPrefix]
		private static void StartOfRound_Pre_SetPlanetsWeather(StartOfRound __instance, ref int connectedPlayersOnServer)
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Expected O, but got Unknown
			if (skipWeatherPatch)
			{
				skipWeatherPatch = false;
				return;
			}
			if (BRBNetworker.Instance.MultiplayerWeather.Value)
			{
				connectedPlayersOnServer = __instance.connectedPlayersAmount;
			}
			if (!BRBNetworker.Instance.MarchRainy.Value)
			{
				return;
			}
			SelectableLevel val = ((IEnumerable<SelectableLevel>)__instance.levels).FirstOrDefault((Func<SelectableLevel, bool>)((SelectableLevel level) => ((Object)level).name == "MarchLevel"));
			if ((Object)(object)val != (Object)null)
			{
				val.overrideWeatherType = (LevelWeatherType)1;
				val.overrideWeather = true;
				if (!val.randomWeathers.Any((RandomWeatherWithVariables randomWeather) => (int)randomWeather.weatherType == -1))
				{
					CollectionExtensions.AddItem<RandomWeatherWithVariables>((IEnumerable<RandomWeatherWithVariables>)val.randomWeathers, new RandomWeatherWithVariables
					{
						weatherType = (LevelWeatherType)(-1)
					});
					Plugin.Logger.LogDebug((object)("Added mild weather to " + ((Object)val).name + " pool"));
				}
			}
		}
	}
	[HarmonyPatch(typeof(TimeOfDay))]
	internal class TimeOfDayPatches
	{
		[HarmonyPatch("SetWeatherBasedOnVariables")]
		[HarmonyPostfix]
		private static void TimeOfDay_Post_SetWeatherBasedOnVariables(TimeOfDay __instance)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Invalid comparison between Unknown and I4
			string text = "/Environment/Lighting/BrightDay/Local Volumetric Fog";
			if (StartOfRound.Instance.currentLevel.sceneName == "Level5Rend")
			{
				GameObject val = GameObject.Find(text + " (2)");
				if ((Object)(object)val != (Object)null)
				{
					val.SetActive(false);
				}
			}
			else if ((int)StartOfRound.Instance.currentLevel.currentWeather == 3 && ((Behaviour)__instance.foggyWeather).enabled && BRBNetworker.Instance.FoggyLimit.Value)
			{
				__instance.foggyWeather.parameters.meanFreePath = Mathf.Max(__instance.foggyWeather.parameters.meanFreePath, 7f);
			}
		}

		[HarmonyPatch("DecideRandomDayEvents")]
		[HarmonyPrefix]
		private static bool TimeOfDay_Pre_DecideRandomDayEvents(TimeOfDay __instance)
		{
			if (((NetworkBehaviour)__instance).IsServer && Configuration.experimentationNoEvents.Value)
			{
				return !BRBNetworker.Instance.MoonsKillSwitch.Value;
			}
			return true;
		}

		[HarmonyPatch("CalculateLuckValue")]
		[HarmonyPrefix]
		private static void TimeOfDay_Pre_CalculateLuckValue(TimeOfDay __instance)
		{
			for (int i = 0; i < StartOfRound.Instance.unlockablesList.unlockables.Count; i++)
			{
				if (StartOfRound.Instance.unlockablesList.unlockables[i].luckValue < 0f && StartOfRound.Instance.unlockablesList.unlockables[i].hasBeenUnlockedByPlayer && !__instance.furniturePlacedAtQuotaStart.Contains(i))
				{
					__instance.furniturePlacedAtQuotaStart.Add(i);
				}
			}
		}
	}
}
namespace ButteRyBalance.Patches.Items
{
	[HarmonyPatch(typeof(LungProp))]
	internal class ApparatusPatches
	{
		[HarmonyPatch("EquipItem")]
		[HarmonyPrefix]
		private static void LungProp_Pre_EquipItem(LungProp __instance)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)__instance).IsOwner && __instance.isLungDocked && ((GrabbableObject)__instance).scrapValue == 80 && BRBNetworker.Instance.ApparatusPrice.Value)
			{
				BRBNetworker.Instance.SyncScrapPriceServerRpc(NetworkObjectReference.op_Implicit(((Component)__instance).GetComponent<NetworkObject>()), new Random(StartOfRound.Instance.randomMapSeed).Next(40, 131));
			}
		}
	}
	[HarmonyPatch(typeof(JetpackItem))]
	internal class JetpackPatches
	{
		[HarmonyPatch("EquipItem")]
		[HarmonyPostfix]
		private static void JetpackItem_Post_EquipItem(JetpackItem __instance)
		{
			if (BRBNetworker.Instance.JetpackBattery.Value)
			{
				((GrabbableObject)__instance).itemProperties.batteryUsage = 40f;
			}
			if (BRBNetworker.Instance.JetpackInertia.Value || Configuration.jetpackInertia.Value)
			{
				__instance.jetpackForceChangeSpeed = 1f;
				__instance.jetpackDeaccelleration = 75f;
			}
			else
			{
				__instance.jetpackForceChangeSpeed = 50f;
			}
		}

		[HarmonyPatch(typeof(JetpackItem), "Update")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> JetpackItem_Trans_Update(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Expected O, but got Unknown
			List<CodeInstruction> list = instructions.ToList();
			for (int i = 1; i < list.Count - 3; i++)
			{
				if (list[i].opcode == OpCodes.Ldc_R4 && (float)list[i].operand == 50f && list[i + 1].opcode == OpCodes.Mul)
				{
					list[i].opcode = OpCodes.Ldfld;
					list[i].operand = AccessTools.Field(typeof(JetpackItem), "jetpackForceChangeSpeed");
					list.Insert(i, new CodeInstruction(OpCodes.Ldarg_0, (object)null));
					Plugin.Logger.LogDebug((object)"Transpiler (Jetpack): Dynamic inertia");
					return list;
				}
			}
			return instructions;
		}
	}
	[HarmonyPatch(typeof(KnifeItem))]
	internal class KnifePatches
	{
		private static float knifeCooldown = 0.43f;

		private static float timeAtLastSwing;

		private static InputAction activateItem;

		[HarmonyPatch(typeof(GrabbableObject), "Start")]
		[HarmonyPostfix]
		private static void GrabbableObject_Post_Start(GrabbableObject __instance)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)__instance).IsServer && !StartOfRound.Instance.inShipPhase && __instance.scrapValue == 35 && Configuration.butlerKnifePrice.Value && __instance is KnifeItem)
			{
				Plugin.Logger.LogInfo((object)"Trying to sync knife price on server");
				BRBNetworker.Instance.SyncScrapPriceClientRpc(NetworkObjectReference.op_Implicit(((Component)__instance).GetComponent<NetworkObject>()), Random.Range(28, 84));
			}
		}

		[HarmonyPatch("EquipItem")]
		[HarmonyPostfix]
		private static void KnifeItem_Post_EquipItem(KnifeItem __instance)
		{
			knifeCooldown = (BRBNetworker.Instance.KnifeShortCooldown.Value ? 0.37f : 0.43f);
		}

		[HarmonyPatch("HitKnife")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> KnifeItem_Trans_HitKnife(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> list = instructions.ToList();
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].opcode == OpCodes.Ldc_R4 && (float)list[i].operand == 0.43f)
				{
					list[i].opcode = OpCodes.Ldsfld;
					list[i].operand = AccessTools.Field(typeof(KnifePatches), "knifeCooldown");
					Plugin.Logger.LogDebug((object)"Transpiler (Knife): Dynamic cooldown");
					return list;
				}
			}
			return instructions;
		}

		[HarmonyPatch(typeof(PlayerControllerB), "OnEnable")]
		[HarmonyPostfix]
		private static void PlayerControllerB_Post_OnEnable()
		{
			activateItem = IngamePlayerSettings.Instance.playerInput.actions.FindAction("ActivateItem", false);
		}

		[HarmonyPatch(typeof(PlayerControllerB), "Update")]
		[HarmonyPostfix]
		private static void PlayerControllerB_Post_Update(PlayerControllerB __instance)
		{
			if (!((Object)(object)__instance.currentlyHeldObjectServer != (Object)null) || !(__instance.timeSinceSwitchingSlots >= 0.075f))
			{
				return;
			}
			GrabbableObject currentlyHeldObjectServer = __instance.currentlyHeldObjectServer;
			KnifeItem val = (KnifeItem)(object)((currentlyHeldObjectServer is KnifeItem) ? currentlyHeldObjectServer : null);
			if (val != null && Configuration.knifeAutoSwing.Value && __instance.CanUseItem() && activateItem.IsPressed() && Time.realtimeSinceStartup - timeAtLastSwing > 0.12f && Time.realtimeSinceStartup - val.timeAtLastDamageDealt > knifeCooldown)
			{
				if (Time.realtimeSinceStartup - timeAtLastSwing <= 0.5f)
				{
					ShipBuildModeManager.Instance.CancelBuildMode(true);
					__instance.currentlyHeldObjectServer.UseItemOnClient(true);
					__instance.timeSinceSwitchingSlots = 0f;
				}
				timeAtLastSwing = Time.realtimeSinceStartup;
			}
		}
	}
	[HarmonyPatch(typeof(TetraChemicalItem))]
	internal class TZPPatches
	{
		private static float tzpCapacity = 22f;

		[HarmonyPatch("EquipItem")]
		[HarmonyPostfix]
		private static void TetraChemicalItem_Post_EquipItem(KnifeItem __instance)
		{
			tzpCapacity = (BRBNetworker.Instance.TZPExpandCapacity.Value ? 34f : 22f);
		}

		[HarmonyPatch("Update")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> TetraChemicalItem_Trans_Update(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> list = instructions.ToList();
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].opcode == OpCodes.Ldc_R4 && (float)list[i].operand == 22f)
				{
					list[i].opcode = OpCodes.Ldsfld;
					list[i].operand = AccessTools.Field(typeof(TZPPatches), "tzpCapacity");
					Plugin.Logger.LogDebug((object)"Transpiler (TZP): Dynamic capacity");
					return list;
				}
			}
			return instructions;
		}
	}
	[HarmonyPatch(typeof(PatcherTool))]
	internal class ZapGunPatches
	{
		[HarmonyPatch("EquipItem")]
		[HarmonyPostfix]
		private static void PatcherTool_Post_EquipItem(PatcherTool __instance)
		{
			if (BRBNetworker.Instance.ZapGunBattery.Value)
			{
				((GrabbableObject)__instance).itemProperties.batteryUsage = 120f;
			}
		}
	}
}
namespace ButteRyBalance.Patches.Enemies
{
	[HarmonyPatch(typeof(ButlerEnemyAI))]
	internal class ButlerPatches
	{
		[HarmonyPatch("OnCollideWithPlayer")]
		[HarmonyPrefix]
		private static bool ButlerEnemyAI_Pre_OnCollideWithPlayer(ButlerEnemyAI __instance, Collider other)
		{
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			if (!BRBNetworker.Instance.ButlerStealthStab.Value && !BRBNetworker.Instance.ButlerLongCooldown.Value)
			{
				return true;
			}
			if (((EnemyAI)__instance).isEnemyDead)
			{
				return false;
			}
			if (((EnemyAI)__instance).currentBehaviourStateIndex != 2 && __instance.berserkModeTimer <= 0f)
			{
				if (Time.realtimeSinceStartup - __instance.timeSinceStealthStab < 10f)
				{
					return false;
				}
				__instance.timeSinceStealthStab = Time.realtimeSinceStartup;
				if (Random.Range(0, 100) < 95)
				{
					return false;
				}
			}
			float num = 0.25f;
			if (BRBNetworker.Instance.ButlerLongCooldown.Value && __instance.timeAtLastButlerDamage <= 0f && __instance.berserkModeTimer <= 3f)
			{
				num = 0.35f;
			}
			if (__instance.timeSinceHittingPlayer < num)
			{
				return false;
			}
			PlayerControllerB val = ((EnemyAI)__instance).MeetsStandardPlayerCollisionConditions(other, false, false);
			if ((Object)(object)val != (Object)null)
			{
				__instance.timeSinceHittingPlayer = 0f;
				val.DamagePlayer(10, true, true, (CauseOfDeath)14, 0, false, default(Vector3));
				bool flag = ((EnemyAI)__instance).currentBehaviourStateIndex != 2;
				if (flag && BRBNetworker.Instance.ButlerStealthStab.Value)
				{
					flag = !val.NearOtherPlayers(val, 15f);
					if (flag)
					{
						for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
						{
							if (!((Object)(object)StartOfRound.Instance.allPlayerScripts[i] == (Object)(object)GameNetworkManager.Instance.localPlayerController) && !StartOfRound.Instance.allPlayerScripts[i].isPlayerDead && StartOfRound.Instance.allPlayerScripts[i].isPlayerControlled && ((EnemyAI)__instance).CheckLineOfSightForPosition(((Component)StartOfRound.Instance.allPlayerScripts[i].gameplayCamera).transform.position, 110f, 60, 2f, (Transform)null))
							{
								flag = false;
								break;
							}
						}
					}
				}
				if (flag)
				{
					__instance.berserkModeTimer = 3f;
				}
				__instance.StabPlayerServerRpc((int)val.playerClientId, flag);
			}
			return false;
		}

		[HarmonyPatch("HitEnemy")]
		[HarmonyPrefix]
		private static void ButlerEnemyAI_Pre_HitEnemy(ButlerEnemyAI __instance, ref int force)
		{
			if (force > 2 && BRBNetworker.Instance.ButlerSquishy.Value)
			{
				force += 3;
			}
		}

		[HarmonyPatch("HitEnemy")]
		[HarmonyPostfix]
		private static void ButlerEnemyAI_Post_HitEnemy(ButlerEnemyAI __instance, PlayerControllerB playerWhoHit)
		{
			if ((Object)(object)playerWhoHit != (Object)null && BRBNetworker.Instance.ButlerLongCooldown.Value)
			{
				__instance.timeAtLastButlerDamage = Time.realtimeSinceStartup;
			}
		}

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void ButlerEnemyAI_Post_Start(ButlerEnemyAI __instance)
		{
			if (BRBNetworker.Instance.ButlerLongCooldown.Value)
			{
				((EnemyAI)__instance).enemyHP = Mathf.Max(((EnemyAI)__instance).enemyHP, 3);
			}
		}
	}
	[HarmonyPatch(typeof(SpringManAI))]
	internal class CoilHeadPatches
	{
		[HarmonyPatch(typeof(EnemyAI), "SetEnemyStunned")]
		[HarmonyPrefix]
		private static void EnemyAI_Pre_SetEnemyStunned(EnemyAI __instance, float setToStunTime)
		{
			SpringManAI val = (SpringManAI)(object)((__instance is SpringManAI) ? __instance : null);
			if (val != null && ((NetworkBehaviour)__instance).IsServer && Configuration.coilheadStunReset.Value && val.onCooldownPhase <= 0f && setToStunTime > 0.5f)
			{
				val.onCooldownPhase = setToStunTime * __instance.enemyType.stunTimeMultiplier;
				val.setOnCooldown = true;
				val.inCooldownAnimation = true;
				val.SetCoilheadOnCooldownServerRpc(true);
			}
		}

		[HarmonyPatch("SetCoilheadOnCooldownClientRpc")]
		[HarmonyPostfix]
		private static void SpringManAI_Post_SetCoilheadOnCooldownClientRpc(SpringManAI __instance, bool setTrue)
		{
			if (setTrue)
			{
				__instance.onCooldownPhase = Mathf.Max(__instance.onCooldownPhase, ((EnemyAI)__instance).stunNormalizedTimer * ((EnemyAI)__instance).enemyType.stunTimeMultiplier);
			}
		}
	}
	[HarmonyPatch(typeof(ForestGiantAI))]
	internal class ForestKeeperPatches
	{
		[HarmonyPatch(typeof(EnemyAI), "GetAllPlayersInLineOfSight")]
		[HarmonyPrefix]
		private static void EnemyAI_Pre_GetAllPlayersInLineOfSight(EnemyAI __instance, ref int range)
		{
			if (__instance.isOutside && !__instance.enemyType.canSeeThroughFog && range > 30 && ((NetworkBehaviour)__instance).IsOwner && __instance is ForestGiantAI && Configuration.giantSnowSight.Value && Common.IsSnowLevel())
			{
				range = 30;
			}
		}
	}
	[HarmonyPatch(typeof(JesterAI))]
	internal class JesterPatches
	{
		[HarmonyPatch(typeof(EnemyAI), "SwitchToBehaviourStateOnLocalClient")]
		[HarmonyPostfix]
		private static void EnemyAI_Post_SwitchToBehaviourStateOnLocalClient(EnemyAI __instance, int stateIndex)
		{
			JesterAI val = (JesterAI)(object)((__instance is JesterAI) ? __instance : null);
			if (val != null && stateIndex == 1 && BRBNetworker.Instance.JesterWalkThrough.Value)
			{
				val.mainCollider.isTrigger = true;
			}
		}

		[HarmonyPatch("SetJesterInitialValues")]
		[HarmonyPostfix]
		private static void JesterAI_Post_SetJesterInitialValues(JesterAI __instance)
		{
			if (StartOfRound.Instance.connectedPlayersAmount < 4 && BRBNetworker.Instance.JesterLongCooldown.Value)
			{
				__instance.beginCrankingTimer = Mathf.Max(__instance.beginCrankingTimer, Random.Range(12f, 28f));
			}
		}
	}
	[HarmonyPatch(typeof(BushWolfEnemy))]
	internal class KidnapperFoxPatches
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void BushWolfEnemy_Post_Start(BushWolfEnemy __instance)
		{
			if (((NetworkBehaviour)__instance).IsOwner && Configuration.foxSquishy.Value)
			{
				((EnemyAI)__instance).enemyHP = 6;
			}
		}

		[HarmonyPatch("HitEnemy")]
		[HarmonyPrefix]
		private static void BushWolfEnemy_Pre_HitEnemy(BushWolfEnemy __instance, ref int force)
		{
			if (force == 3 && ((NetworkBehaviour)__instance).IsOwner && Configuration.foxSquishy.Value)
			{
				force++;
			}
		}
	}
	[HarmonyPatch(typeof(CaveDwellerAI))]
	internal class ManeaterPatches
	{
		private static bool playersHaveEnteredBuilding;

		private static float GROWTH_SPEED_MULTIPLIER = 0.045f;

		[HarmonyPatch("HitEnemy")]
		[HarmonyPrefix]
		private static void CaveDwellerAI_Pre_HitEnemy(CaveDwellerAI __instance, ref float __state)
		{
			__state = __instance.growthMeter;
		}

		[HarmonyPatch("HitEnemy")]
		[HarmonyPostfix]
		private static void CaveDwellerAI_Post_HitEnemy(CaveDwellerAI __instance, float __state, PlayerControllerB playerWhoHit)
		{
			if (((NetworkBehaviour)__instance).IsServer && ((EnemyAI)__instance).currentBehaviourStateIndex == 0 && (Object)(object)playerWhoHit == (Object)null && !__instance.hasPlayerFoundBaby && BRBNetworker.Instance.ManeaterLimitGrowth.Value)
			{
				__instance.growthMeter = __state;
			}
		}

		[HarmonyPatch("KillEnemy")]
		[HarmonyPrefix]
		private static void CaveDwellerAI_Pre_KillEnemy(CaveDwellerAI __instance, ref float __state)
		{
			__state = __instance.growthMeter;
		}

		[HarmonyPatch("KillEnemy")]
		[HarmonyPostfix]
		private static void CaveDwellerAI_Post_KillEnemy(CaveDwellerAI __instance, float __state)
		{
			if (((NetworkBehaviour)__instance).IsServer && ((EnemyAI)__instance).currentBehaviourStateIndex == 0 && !__instance.hasPlayerFoundBaby && BRBNetworker.Instance.ManeaterLimitGrowth.Value)
			{
				__instance.growthMeter = __state;
			}
		}

		[HarmonyPatch(typeof(EntranceTeleport), "TeleportPlayerClientRpc")]
		[HarmonyPostfix]
		private static void EntranceTeleport_Post_TeleportPlayerClientRpc()
		{
			playersHaveEnteredBuilding = true;
		}

		[HarmonyPatch(typeof(StartOfRound), "EndOfGameClientRpc")]
		[HarmonyPostfix]
		private static void StartOfRound_Post_EndOfGameClientRpc()
		{
			playersHaveEnteredBuilding = false;
		}

		[HarmonyPatch("SetCryingLocalClient")]
		[HarmonyPrefix]
		private static void CaveDwellerAI_Pre_SetCryingLocalClient(CaveDwellerAI __instance, ref bool setCrying)
		{
			if (((EnemyAI)__instance).currentBehaviourStateIndex == 0 && !playersHaveEnteredBuilding && BRBNetworker.Instance.ManeaterLimitGrowth.Value)
			{
				setCrying = false;
			}
		}

		[HarmonyPatch("IncreaseBabyGrowthMeter")]
		[HarmonyPrefix]
		private static void CaveDwellerAI_Pre_IncreaseBabyGrowthMeter(CaveDwellerAI __instance, ref float __state)
		{
			__state = __instance.growthMeter;
		}

		[HarmonyPatch("IncreaseBabyGrowthMeter")]
		[HarmonyPostfix]
		private static void CaveDwellerAI_Post_IncreaseBabyGrowthMeter(CaveDwellerAI __instance, float __state)
		{
			if (BRBNetworker.Instance.ManeaterLimitGrowth.Value)
			{
				if (!playersHaveEnteredBuilding)
				{
					__instance.growthMeter = 0f;
				}
				else if ((Object)(object)((GrabbableObject)(__instance.propScript?)).playerHeldBy != (Object)null && __instance.rockingBaby < 2 && !__instance.stopCryingWhenReleased)
				{
					__instance.growthMeter = __state + (__instance.growthMeter - __state) / 1.3f;
				}
			}
		}

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void CaveDwellerAI_Post_Start(CaveDwellerAI __instance)
		{
			GROWTH_SPEED_MULTIPLIER = __instance.growthSpeedMultiplier;
		}

		[HarmonyPatch("StopObserving")]
		[HarmonyPostfix]
		private static void CaveDwellerAI_Post_StopObserving(CaveDwellerAI __instance, bool eatScrap)
		{
			if (eatScrap && Configuration.maneaterScrapGrowth.Value)
			{
				if (__instance.scrapEaten == 1)
				{
					__instance.growthSpeedMultiplier = GROWTH_SPEED_MULTIPLIER * 0.75f;
				}
				else
				{
					__instance.growthSpeedMultiplier = GROWTH_SPEED_MULTIPLIER * 0.5f;
				}
			}
		}

		[HarmonyPatch("DoNonBabyUpdateLogic")]
		[HarmonyPostfix]
		private static void CaveDwellerAI_Post_DoNonBabyUpdateLogic(CaveDwellerAI __instance)
		{
			if (((NetworkBehaviour)__instance).IsOwner && BRBNetworker.Instance.ManeaterWideTurns.Value)
			{
				if (__instance.leaping && !((EnemyAI)__instance).isOutside)
				{
					((EnemyAI)__instance).agent.angularSpeed = 320f;
					((EnemyAI)__instance).agent.acceleration = 75f;
				}
				else
				{
					((EnemyAI)__instance).agent.angularSpeed = 700f;
					((EnemyAI)__instance).agent.acceleration = 425f;
				}
			}
		}
	}
	[HarmonyPatch(typeof(NutcrackerEnemyAI))]
	internal class NutcrackerPatches
	{
		[HarmonyPatch(typeof(NutcrackerEnemyAI), "GrabGun")]
		[HarmonyPostfix]
		private static void NutcrackerEnemyAI_Post_GrabGun(NutcrackerEnemyAI __instance)
		{
			if (!((NetworkBehaviour)__instance).IsServer && ((GrabbableObject)__instance.gun).scrapValue == 60 && BRBNetworker.Instance.NutcrackerGunPrice.Value)
			{
				RandomizeShotgunPrice(__instance.gun, __instance.randomSeedNumber);
			}
		}

		[HarmonyPatch(typeof(NutcrackerEnemyAI), "InitializeNutcrackerValuesClientRpc")]
		[HarmonyPostfix]
		private static void NutcrackerEnemyAI_Post_InitializeNutcrackerValuesClientRpc(NutcrackerEnemyAI __instance)
		{
			if ((Object)(object)__instance.gun != (Object)null && BRBNetworker.Instance.NutcrackerGunPrice.Value)
			{
				RandomizeShotgunPrice(__instance.gun, __instance.randomSeedNumber);
			}
		}

		private static void RandomizeShotgunPrice(ShotgunItem gun, int seed)
		{
			((GrabbableObject)gun).SetScrapValue(new Random(seed).Next(25, 90));
		}

		[HarmonyPatch(typeof(NutcrackerEnemyAI), "HitEnemy")]
		[HarmonyPrefix]
		private static void NutcrackerEnemyAI_Pre_HitEnemy(NutcrackerEnemyAI __instance, ref int force)
		{
			if (((NetworkBehaviour)__instance).IsOwner && force == 5 && Configuration.nutcrackerKevlar.Value)
			{
				force = 4;
			}
		}
	}
	[HarmonyPatch(typeof(RadMechAI))]
	internal class OldBirdPatches
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void RadMechAI_Post_Start(RadMechAI __instance)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			if (BRBNetworker.Instance.RobotRider.Value)
			{
				Transform transform = new GameObject("HeadPhysicsRegion").transform;
				((Component)transform).transform.SetParent(__instance.flyingModeEye.parent, false);
				((Component)transform).transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.Euler(0f, -90f, 0f));
				((Component)transform).transform.localScale = Vector3.one;
				((Component)transform).gameObject.layer = 11;
				Transform transform2 = new GameObject("ItemRegion").transform;
				((Component)transform2).transform.SetParent(transform, false);
				((Component)transform2).transform.SetLocalPositionAndRotation(new Vector3(0.084f, 4.22f, -0.016f), Quaternion.Euler(0f, -90f, 0f));
				((Component)transform2).transform.localScale = new Vector3(2.6594927f, 2.3688068f, 6.71593f);
				((Component)transform2).gameObject.layer = 11;
				BoxCollider obj = ((Component)transform).gameObject.AddComponent<BoxCollider>();
				((Collider)obj).isTrigger = true;
				obj.center = new Vector3(0.039966326f, 4.371105f, -0.20368911f);
				obj.size = new Vector3(6.759974f, 2.874863f, 2.946622f);
				BoxCollider val = ((Component)transform).gameObject.AddComponent<BoxCollider>();
				val.center = new Vector3(0.00021445409f, 4.230267f, -0.056250554f);
				val.size = new Vector3(1.4099005f, 0.20658682f, 2.7057087f);
				BoxCollider obj2 = ((Component)transform).gameObject.AddComponent<BoxCollider>();
				obj2.center = new Vector3(-2.0335987f, 3.0949335f, -0.07390101f);
				obj2.size = new Vector3(2.1417093f, 0.44765297f, 1.8748745f);
				BoxCollider obj3 = ((Component)transform).gameObject.AddComponent<BoxCollider>();
				obj3.center = new Vector3(2.0233488f, 3.0949335f, -0.07390126f);
				obj3.size = new Vector3(2.1624248f, 0.44765297f, 1.8748745f);
				Rigidbody obj4 = ((Component)transform).gameObject.AddComponent<Rigidbody>();
				obj4.collisionDetectionMode = (CollisionDetectionMode)1;
				obj4.isKinematic = true;
				BoxCollider val2 = ((Component)transform2).gameObject.AddComponent<BoxCollider>();
				((Collider)val2).isTrigger = true;
				Rigidbody obj5 = ((Component)transform2).gameObject.AddComponent<Rigidbody>();
				obj5.collisionDetectionMode = (CollisionDetectionMode)1;
				obj5.isKinematic = true;
				PlayerPhysicsRegion obj6 = ((Component)transform).gameObject.AddComponent<PlayerPhysicsRegion>();
				obj6.physicsTransform = transform;
				obj6.parentNetworkObject = ((Component)__instance).GetComponent<NetworkObject>();
				obj6.allowDroppingItems = true;
				obj6.priority = 1;
				obj6.physicsCollider = (Collider)(object)val;
				obj6.itemDropCollider = (Collider)(object)val2;
				obj6.maxTippingAngle = 65f;
			}
		}
	}
}
namespace ButteRyBalance.Overrides
{
	internal class InfestationOverrides
	{
		private static int infestationEnemyIndex = -1;

		private static EnemyType infestationEnemy;

		private static float rollbackPowerLevel;

		private static int hourOfLastInfestationWave = -1;

		private static List<string> compatibleEnemies = new List<string> { "HoarderBug", "Nutcracker", "Butler", "MaskedPlayerEnemy", "ClaySurgeon" };

		private static readonly Dictionary<string, Dictionary<string, int>> vanillaLevels = new Dictionary<string, Dictionary<string, int>>
		{
			{
				"ExperimentationLevel",
				ExperimentationOverrides.infestations
			},
			{
				"AssuranceLevel",
				AssuranceOverrides.infestations
			},
			{
				"VowLevel",
				VowOverrides.infestations
			},
			{
				"OffenseLevel",
				OffenseOverrides.infestations
			},
			{
				"MarchLevel",
				MarchOverrides.infestations
			},
			{
				"AdamanceLevel",
				AdamanceOverrides.infestations
			},
			{
				"RendLevel",
				RendOverrides.infestations
			},
			{
				"DineLevel",
				DineOverrides.infestations
			},
			{
				"TitanLevel",
				TitanOverrides.infestations
			},
			{
				"ArtificeLevel",
				ArtificeOverrides.infestations
			},
			{
				"EmbrionLevel",
				EmbrionOverrides.infestations
			}
		};

		private static List<IntWithRarity> infestationEnemies = new List<IntWithRarity>();

		internal static void FilterInfestations()
		{
			if (Configuration.infestationButlers.Value)
			{
				if (!compatibleEnemies.Contains("Butler"))
				{
					compatibleEnemies.Add("Butler");
				}
			}
			else
			{
				compatibleEnemies.Remove("Butler");
			}
			if (Configuration.infestationMasked.Value)
			{
				if (!compatibleEnemies.Contains("MaskedPlayerEnemy"))
				{
					compatibleEnemies.Add("MaskedPlayerEnemy");
				}
			}
			else
			{
				compatibleEnemies.Remove("MaskedPlayerEnemy");
			}
			if (Configuration.infestationBarbers.Value && RoundManager.Instance.currentDungeonType != 4)
			{
				if (!compatibleEnemies.Contains("ClaySurgeon"))
				{
					compatibleEnemies.Add("ClaySurgeon");
				}
			}
			else
			{
				compatibleEnemies.Remove("ClaySurgeon");
			}
		}

		internal static void CustomInfestation(int forceIndex = -1)
		{
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Expected O, but got Unknown
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Expected O, but got Unknown
			SelectableLevel currentLevel = RoundManager.Instance.currentLevel;
			RoundManager.Instance.enemyRushIndex = -1;
			infestationEnemies.Clear();
			vanillaLevels.TryGetValue(((Object)currentLevel).name, out var value);
			Random random = new Random(StartOfRound.Instance.randomMapSeed + 5781);
			if (forceIndex >= 0)
			{
				infestationEnemyIndex = forceIndex;
			}
			else
			{
				FilterInfestations();
				for (int i = 0; i < currentLevel.Enemies.Count; i++)
				{
					if (!compatibleEnemies.Contains(((Object)currentLevel.Enemies[i].enemyType).name) || currentLevel.Enemies[i].rarity == 0)
					{
						continue;
					}
					if (value != null)
					{
						if (value.TryGetValue(((Object)currentLevel.Enemies[i].enemyType).name, out var value2))
						{
							infestationEnemies.Add(new IntWithRarity
							{
								id = i,
								rarity = value2
							});
						}
					}
					else
					{
						infestationEnemies.Add(new IntWithRarity
						{
							id = i,
							rarity = currentLevel.Enemies[i].rarity
						});
					}
				}
				Plugin.Logger.LogDebug((object)("Infestation weights for \"" + ((Object)currentLevel).name + "\":"));
				foreach (IntWithRarity infestationEnemy in infestationEnemies)
				{
					Plugin.Logger.LogDebug((object)$"{((Object)currentLevel.Enemies[infestationEnemy.id].enemyType).name} - {infestationEnemy.rarity}");
				}
				infestationEnemyIndex = infestationEnemies[RoundManager.Instance.GetRandomWeightedIndex(infestationEnemies.Select((IntWithRarity x) => x.rarity).ToArray(), random)].id;
			}
			InfestationOverrides.infestationEnemy = currentLevel.Enemies[infestationEnemyIndex].enemyType;
			Plugin.Logger.LogDebug((object)("Starting " + ((Object)InfestationOverrides.infestationEnemy).name + " infestation"));
			InfestationOverrides.infestationEnemy.PowerLevel = 0f;
			RoundManager.Instance.currentMaxInsidePower = RoundManager.Instance.currentLevel.maxEnemyPowerCount;
			if (((Object)InfestationOverrides.infestationEnemy).name != "ClaySurgeon")
			{
				RoundManager.Instance.increasedInsideEnemySpawnRateIndex = infestationEnemyIndex;
			}
			else
			{
				RoundManager.Instance.currentMaxInsidePower = Mathf.Floor(RoundManager.Instance.currentMaxInsidePower / 2f);
			}
		}

		internal static void EndInfestation()
		{
			hourOfLastInfestationWave = -1;
			if (infestationEnemyIndex >= 0)
			{
				RoundManager.Instance.increasedInsideEnemySpawnRateIndex = -1;
				if (rollbackPowerLevel > 0f)
				{
					rollbackPowerLevel = -1f;
					infestationEnemy.PowerLevel = rollbackPowerLevel;
				}
				infestationEnemyIndex = -1;
				infestationEnemy = null;
			}
		}

		internal static void SpawnInfestationWave()
		{
			if (infestationEnemyIndex < 0 || RoundManager.Instance.currentHour == hourOfLastInfestationWave)
			{
				return;
			}
			hourOfLastInfestationWave = RoundManager.Instance.currentHour;
			RoundManager.Instance.currentEnemySpawnIndex = 0;
			if (RoundManager.Instance.firstTimeSpawningEnemies)
			{
				foreach (SpawnableEnemyWithRarity enemy in RoundManager.Instance.currentLevel.Enemies)
				{
					enemy.enemyType.numberSpawned = 0;
				}
				RoundManager.Instance.firstTimeSpawningEnemies = false;
			}
			List<EnemyVent> list = RoundManager.Instance.allEnemyVents.Where((EnemyVent enemyVent) => !enemyVent.occupied).ToList();
			for (int i = 0; i < 2; i++)
			{
				if (infestationEnemy.numberSpawned >= infestationEnemy.MaxCount || list.Count < 1)
				{
					Plugin.Logger.LogDebug((object)"Can no longer spawn infestation enemies");
					break;
				}
				float num = TimeOfDay.Instance.lengthOfHours * (float)RoundManager.Instance.currentHour;
				int num2 = (int)((float)RoundManager.Instance.AnomalyRandom.Next(10, (int)(TimeOfDay.Instance.lengthOfHours * (float)RoundManager.Instance.hourTimeBetweenEnemySpawnBatches)) + num);
				EnemyVent val = list[RoundManager.Instance.AnomalyRandom.Next(list.Count)];
				val.enemyType = infestationEnemy;
				val.enemyTypeIndex = infestationEnemyIndex;
				val.occupied = true;
				val.spawnTime = num2;
				if (TimeOfDay.Instance.hour - RoundManager.Instance.currentHour <= 0)
				{
					val.SyncVentSpawnTimeClientRpc(num2, infestationEnemyIndex);
				}
				EnemyType obj = infestationEnemy;
				obj.numberSpawned++;
				Plugin.Logger.LogDebug((object)"Added infestation enemy to vent");
				if (((Object)infestationEnemy).name == "ClaySurgeon")
				{
					break;
				}
			}
		}

		internal static string GetInfesterName()
		{
			if (infestationEnemyIndex < 0)
			{
				return string.Empty;
			}
			return ((Object)RoundManager.Instance.currentLevel.Enemies[infestationEnemyIndex].enemyType).name;
		}
	}
	internal class OverrideCoordinator
	{
		internal static void ApplyOnServer()
		{
			if (!BRBNetworker.Instance.MoonsKillSwitch.Value)
			{
				SelectableLevel[] levels = StartOfRound.Instance.levels;
				foreach (SelectableLevel val in levels)
				{
					switch (((Object)val).name)
					{
					case "ExperimentationLevel":
						ExperimentationOverrides.Setup(val);
						break;
					case "AssuranceLevel":
						AssuranceOverrides.Setup(val);
						break;
					case "VowLevel":
						VowOverrides.Setup(val);
						break;
					case "OffenseLevel":
						OffenseOverrides.Setup(val);
						break;
					case "MarchLevel":
						MarchOverrides.Setup(val);
						break;
					case "AdamanceLevel":
						AdamanceOverrides.Setup(val);
						break;
					case "RendLevel":
						RendOverrides.Setup(val);
						break;
					case "DineLevel":
						DineOverrides.Setup(val);
						break;
					case "TitanLevel":
						TitanOverrides.Setup(val);
						break;
					case "ArtificeLevel":
						ArtificeOverrides.Setup(val);
						break;
					case "EmbrionLevel":
						EmbrionOverrides.Setup(val);
						break;
					}
				}
			}
			foreach (KeyValuePair<string, EnemyType> enemy in Common.enemies)
			{
				switch (enemy.Key)
				{
				case "Butler":
					if (Configuration.butlerManorChance.Value)
					{
						enemy.Value.increasedChanceInterior = 1;
						Plugin.Logger.LogDebug((object)"Butler: Increased chance in manors");
					}
					break;
				case "CaveDweller":
					if (Configuration.maneaterPower.Value)
					{
						Plugin.Logger.LogDebug((object)$"Maneater: Power level {enemy.Value.PowerLevel} -> 3");
						enemy.Value.PowerLevel = 3f;
					}
					break;
				case "RadMech":
					if (Configuration.robotFog.Value)
					{
						enemy.Value.canSeeThroughFog = true;
						Plugin.Logger.LogDebug((object)"Old Bird: See through fog");
					}
					break;
				case "SpringMan":
					if (Configuration.coilheadCurves.Value)
					{
						enemy.Value.probabilityCurve = AnimationCurve.EaseInOut(0.1f, 43f / 70f, 0.3333333f, 1f);
						Plugin.Logger.LogDebug((object)"Coil-head: Time of day curve");
						enemy.Value.numberSpawnedFalloff = AnimationCurve.EaseInOut(0f, 1f, 1f, 0f);
						enemy.Value.useNumberSpawnedFalloff = true;
						Plugin.Logger.LogDebug((object)"Coil-head: Spawn count curve");
					}
					if (Configuration.coilheadPower.Value)
					{
						Plugin.Logger.LogDebug((object)$"Coil-head: Power level {enemy.Value.PowerLevel} -> 2");
						enemy.Value.PowerLevel = 2f;
					}
					break;
				}
			}
			foreach (Item items in StartOfRound.Instance.allItemsList.itemsList)
			{
				if (((Object)items).name == "MetalSheet" && Configuration.metalSheetPrice.Value)
				{
					Plugin.Logger.LogDebug((object)$"{((Object)items).name}.minValue: {items.minValue} -> 35");
					items.minValue = 35;
					Plugin.Logger.LogDebug((object)$"{((Object)items).name}.maxValue: {items.maxValue} -> 85");
					items.maxValue = 85;
				}
			}
		}

		internal static void ApplyOnAllClients()
		{
			Dictionary<string, float> dictionary = new Dictionary<string, float>
			{
				{ "BottleBin", 1.15f },
				{ "Brush", 1.07f },
				{ "Candy", 1f },
				{ "ChemicalJug", 1.4f },
				{ "Clock", 1.2f },
				{ "Cog1", 1.2f },
				{ "EnginePart1", 1.18f },
				{ "FancyCup", 1.2f },
				{ "FancyLamp", 1.25f },
				{ "Flask", 1.1f },
				{ "GarbageLid", 1.1f },
				{ "Hairdryer", 1.1f },
				{ "MetalSheet", 1.23f },
				{ "Ring", 1.08f },
				{ "SoccerBall", 1.13f },
				{ "StopSign", 1.2f },
				{ "TeaKettle", 1.15f },
				{ "YieldSign", 1.3f }
			};
			foreach (Item items in StartOfRound.Instance.allItemsList.itemsList)
			{
				switch (((Object)items).name)
				{
				case "Jetpack":
					if (BRBNetworker.Instance.JetpackReduceDiscount.Value && items.highestSalePercentage != 60)
					{
						Plugin.Logger.LogDebug((object)$"{((Object)items).name}.highestSalePercentage: {items.highestSalePercentage}% -> 60%");
						items.highestSalePercentage = 60;
					}
					break;
				case "RadarBooster":
					if (BRBNetworker.Instance.RadarBoosterPrice.Value && items.creditsWorth != 50)
					{
						Plugin.Logger.LogDebug((object)$"{((Object)items).name}.creditsWorth: ${items.creditsWorth} -> $50");
						items.creditsWorth = 50;
					}
					break;
				case "StunGrenade":
					if (BRBNetworker.Instance.StunGrenadePrice.Value && items.creditsWorth != 40)
					{
						Plugin.Logger.LogDebug((object)$"{((Object)items).name}.creditsWorth: ${items.creditsWorth} -> $40");
						items.creditsWorth = 40;
					}
					break;
				case "ZapGun":
					if (BRBNetworker.Instance.ZapGunPrice.Value && items.creditsWorth != 200)
					{
						Plugin.Logger.LogDebug((object)$"{((Object)items).name}.creditsWorth: ${items.creditsWorth} -> $200");
						items.creditsWorth = 200;
					}
					break;
				}
				if (BRBNetworker.Instance.ScrapAdjustWeights.Value && dictionary.TryGetValue(((Object)items).name, out var value) && items.weight != value)
				{
					Plugin.Logger.LogDebug((object)$"{((Object)items).name}.weight: ${items.weight} -> {value}");
					items.weight = value;
				}
			}
			SelectableLevel[] levels = StartOfRound.Instance.levels;
			foreach (SelectableLevel val in levels)
			{
				if (((Object)val).name == "TitanLevel")
				{
					val.timeToArrive = 4f;
				}
			}
		}
	}
}
namespace ButteRyBalance.Overrides.Moons
{
	internal class AdamanceOverrides
	{
		internal static readonly Dictionary<string, int> infestations = new Dictionary<string, int>
		{
			{ "HoarderBug", 300 },
			{ "Nutcracker", 100 },
			{ "MaskedPlayerEnemy", 10 },
			{ "Butler", 1 },
			{ "ClaySurgeon", 3 }
		};

		internal static void Setup(SelectableLevel level)
		{
			if (Configuration.adamanceReduceChaos.Value)
			{
				MoonOverrides.outsidePowerCount = 10;
				MoonOverrides.adjustedEclipse = 2;
			}
			MoonOverrides.Apply(level);
		}
	}
	internal class ArtificeOverrides
	{
		internal static readonly Dictionary<int, int> adjustedInteriors = new Dictionary<int, int>
		{
			{ 0, 94 },
			{ 1, 300 }
		};

		internal static readonly Dictionary<string, int> infestations = new Dictionary<string, int>
		{
			{ "HoarderBug", 300 },
			{ "Nutcracker", 100 },
			{ "MaskedPlayerEnemy", 200 },
			{ "Butler", 69 },
			{ "ClaySurgeon", 64 }
		};

		internal static void Setup(SelectableLevel level)
		{
			if (Configuration.artificeBuffScrap.Value)
			{
				MoonOverrides.minScrap = 31;
				MoonOverrides.maxScrap = 38;
				MoonOverrides.adjustedScrap.Add("GoldBar", 36);
			}
			if (Configuration.artificeTurrets.Value)
			{
				SpawnableMapObject val = ((IEnumerable<SpawnableMapObject>)level.spawnableMapObjects).FirstOrDefault((Func<SpawnableMapObject, bool>)delegate(SpawnableMapObject spawnableMapObject)
				{
					GameObject prefabToSpawn2 = spawnableMapObject.prefabToSpawn;
					return ((prefabToSpawn2 != null) ? ((Object)prefabToSpawn2).name : null) == "TurretContainer";
				});
				if (val != null)
				{
					AnimationCurve val2 = ((IEnumerable<SpawnableMapObject>)((IEnumerable<SelectableLevel>)StartOfRound.Instance.levels).FirstOrDefault((Func<SelectableLevel, bool>)((SelectableLevel x) => ((Object)x).name == "LiquidationLevel"))?.spawnableMapObjects).FirstOrDefault((Func<SpawnableMapObject, bool>)delegate(SpawnableMapObject spawnableMapObject)
					{
						GameObject prefabToSpawn = spawnableMapObject.prefabToSpawn;
						return ((prefabToSpawn != null) ? ((Object)prefabToSpawn).name : null) == "TurretContainer";
					})?.numberToSpawn;
					if (val2 != null)
					{
						val.numberToSpawn = val2;
						Plugin.Logger.LogDebug((object)(((Object)level).name + ".spawnableMapObjects." + ((Object)val.prefabToSpawn).name));
					}
				}
			}
			MoonOverrides.Apply(level);
		}
	}
	internal class AssuranceOverrides
	{
		internal static readonly Dictionary<string, int> infestations = new Dictionary<string, int>
		{
			{ "HoarderBug", 300 },
			{ "Nutcracker", 100 },
			{ "MaskedPlayerEnemy", 3 },
			{ "ClaySurgeon", 1 }
		};

		internal static void Setup(SelectableLevel level)
		{
			if (Configuration.assuranceNerfScrap.Value)
			{
				MoonOverrides.minScrap = 11;
				MoonOverrides.maxScrap = 16;
				Extensions.AddRange<string, int>(MoonOverrides.adjustedScrap, new Dictionary<string, int>
				{
					{ "Cog1", 94 },
					{ "EnginePart1", 80 },
					{ "MetalSheet", 100 },
					{ "BigBolt", 89 },
					{ "ToyCube", 11 },
					{ "FlashLaserPointer", 4 },
					{ "BottleBin", 67 },
					{ "Remote", 10 },
					{ "RobotToy", 2 },
					{ "MagnifyingGlass", 4 },
					{ "Mug", 0 },
					{ "SodaCanRed", 2 },
					{ "Phone", 0 },
					{ "Hairdryer", 0 },
					{ "ClownHorn", 4 },
					{ "Airhorn", 4 },
					{ "StopSign", 27 },
					{ "CashRegister", 0 },
					{ "YieldSign", 28 },
					{ "DiyFlashbang", 13 },
					{ "TragedyMask", 0 },
					{ "ToiletPaperRolls", 18 },
					{ "Bell", 33 },
					{ "WhoopieCushion", 49 },
					{ "Candy", 16 }
				});
			}
			if (Configuration.assuranceMasked.Value)
			{
				MoonOverrides.adjustedEnemies.Add("MaskedPlayerEnemy", 2);
			}
			MoonOverrides.Apply(level);
		}
	}
	internal class DineOverrides
	{
		internal static readonly Dictionary<string, int> infestations = new Dictionary<string, int>
		{
			{ "HoarderBug", 3 },
			{ "Nutcracker", 1 },
			{ "MaskedPlayerEnemy", 40 },
			{ "Butler", 300 },
			{ "ClaySurgeon", 14 }
		};

		internal static void Setup(SelectableLevel level)
		{
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Expected O, but got Unknown
			if (Configuration.dineBuffScrap.Value)
			{
				MoonOverrides.minScrap = 22;
				MoonOverrides.maxScrap = 28;
				Extensions.AddRange<string, int>(MoonOverrides.adjustedScrap, new Dictionary<string, int>
				{
					{ "Cog1", 15 },
					{ "EnginePart1", 14 },
					{ "BottleBin", 30 },
					{ "FancyLamp", 54 },
					{ "Ring", 26 },
					{ "RobotToy", 26 },
					{ "PerfumeBottle", 34 },
					{ "Hairdryer", 22 },
					{ "Airhorn", 16 },
					{ "ClownHorn", 17 },
					{ "CashRegister", 12 },
					{ "TragedyMask", 64 },
					{ "GiftBox", 69 },
					{ "PillBottle", 4 },
					{ "Toothpaste", 24 },
					{ "TeaKettle", 25 },
					{ "Candy", 15 },
					{ "Brush", 25 },
					{ "MagnifyingGlass", 37 },
					{ "Bell", 49 },
					{ "DustPan", 32 }
				});
			}
			if (Configuration.dineReduceButlers.Value)
			{
				MoonOverrides.adjustedEnemies.Add("Butler", 15);
			}
			if (Configuration.dineAdjustIndoor.Value)
			{
				Extensions.AddRange<string, int>(MoonOverrides.adjustedEnemies, new Dictionary<string, int>
				{
					{ "DressGirl", 3 },
					{ "SandSpider", 7 },
					{ "Blob", 3 },
					{ "HoarderBug", 8 },
					{ "Jester", 5 },
					{ "Centipede", 6 }
				});
				MoonOverrides.powerCount = 15;
			}
			if (Configuration.dineMasked.Value)
			{
				MoonOverrides.adjustedEnemies.Add("MaskedPlayerEnemy", 4);
			}
			if (Configuration.dineAdjustOutdoor.Value)
			{
				MoonOverrides.adjustedEnemies.Add("ForestGiant", 28);
				MoonOverrides.outsidePowerCount = 10;
			}
			if (Configuration.dineAdjustCurves.Value)
			{
				level.outsideEnemySpawnChanceThroughDay = new AnimationCurve((Keyframe[])(object)new Keyframe[3]
				{
					new Keyframe(-7.7369623E-07f, -2.8875f),
					new Keyframe(0.47669196f, 0.6959345f),
					new Keyframe(1.0052626f, 5.3594007f)
				});
				Plugin.Logger.LogDebug((object)(((Object)level).name + ".outsideEnemySpawnChanceThroughDay"));
			}
			MoonOverrides.Apply(level);
		}
	}
	internal class EmbrionOverrides
	{
		internal static readonly Dictionary<int, int> adjustedInteriors = new Dictionary<int, int> { { 4, 118 } };

		internal static readonly Dictionary<int, int> megaInteriors = new Dictionary<int, int>
		{
			{ 0, 17 },
			{ 1, 4 }
		};

		internal static readonly Dictionary<string, int> infestations = new Dictionary<string, int>
		{
			{ "HoarderBug", 300 },
			{ "Nutcracker", 100 },
			{ "ClaySurgeon", 250 }
		};

		internal static void Setup(SelectableLevel level)
		{
			if (Configuration.embrionBuffScrap.Value)
			{
				MoonOverrides.minScrap = 14;
				MoonOverrides.maxScrap = 18;
				Extensions.AddRange<string, int>(MoonOverrides.adjustedScrap, new Dictionary<string, int>
				{
					{ "YieldSign", 12 },
					{ "Cog1", 37 },
					{ "EnginePart1", 40 },
					{ "BigBolt", 55 },
					{ "FlashLaserPointer", 10 },
					{ "Ring", 15 },
					{ "BottleBin", 42 },
					{ "RobotToy", 49 },
					{ "TeaKettle", 23 },
					{ "Dentures", 37 },
					{ "Phone", 45 },
					{ "Airhorn", 39 },
					{ "ClownHorn", 31 },
					{ "MetalSheet", 40 },
					{ "DustPan", 83 }
				});
			}
			if (Configuration.embrionMega.Value)
			{
				MoonOverrides.minScrap = 28;
				MoonOverrides.maxScrap = 45;
			}
			if (Configuration.embrionAdjustEnemies.Value)
			{
				Extensions.AddRange<string, int>(MoonOverrides.adjustedEnemies, new Dictionary<string, int>
				{
					{ "Nutcracker", 37 },
					{ "SpringMan", 42 },
					{ "ClaySurgeon", 61 }
				});
			}
			if (Configuration.embrionWeeds.Value)
			{
				Plugin.Logger.LogDebug((object)$"{((Object)level).name}.canSpawnMold: {level.canSpawnMold} -> False");
				level.canSpawnMold = false;
			}
			MoonOverrides.Apply(level);
		}
	}
	internal class ExperimentationOverrides
	{
		internal static readonly Dictionary<string, int> infestations = new Dictionary<string, int>
		{
			{ "HoarderBug", 300 },
			{ "Nutcracker", 100 }
		};

		internal static void Setup(SelectableLevel level)
		{
			level.riskLevel = "D";
			if (Configuration.experimentationBuffScrap.Value)
			{
				MoonOverrides.minScrap = 11;
				MoonOverrides.maxScrap = 16;
				MoonOverrides.adjustedScrap.Add("CashRegister", 6);
			}
			if (Configuration.experimentationNoEggs.Value)
			{
				MoonOverrides.adjustedScrap.Add("EasterEgg", 0);
			}
			if (Configuration.experimentationNoGiants.Value)
			{
				MoonOverrides.adjustedEnemies.Add("ForestGiant", 0);
			}
			if (Configuration.experimentationNoNuts.Value)
			{
				MoonOverrides.adjustedEnemies.Add("Nutcracker", 0);
			}
			MoonOverrides.Apply(level);
		}
	}
	internal class MarchOverrides
	{
		internal static readonly Dictionary<string, int> infestations = new Dictionary<string, int>
		{
			{ "HoarderBug", 300 },
			{ "Nutcracker", 100 }
		};

		internal static void Setup(SelectableLevel level)
		{
			level.riskLevel = "C";
			if (Configuration.marchBuffScrap.Value)
			{
				MoonOverrides.minScrap = 16;
				MoonOverrides.maxScrap = 21;
				Extensions.AddRange<string, int>(MoonOverrides.adjustedScrap, new Dictionary<string, int>
				{
					{ "BigBolt", 59 },
					{ "ToyCube", 24 },
					{ "FlashLaserPointer", 8 },
					{ "Remote", 16 },
					{ "RobotToy", 6 },
					{ "MagnifyingGlass", 21 },
					{ "Mug", 12 },
					{ "SodaCanRed", 12 },
					{ "Phone", 7 },
					{ "Hairdryer", 4 },
					{ "Cog1", 25 },
					{ "EnginePart1", 25 },
					{ "FishTestProp", 32 },
					{ "EggBeater", 50 },
					{ "ToiletPaperRolls", 34 },
					{ "PlasticCup", 22 },
					{ "Bell", 28 },
					{ "MetalSheet", 65 },
					{ "BottleBin", 46 }
				});
				MoonOverrides.adjustedEnemies.Add("RedLocustBees", 72);
			}
			MoonOverrides.Apply(level);
		}
	}
	internal class MoonOverrides
	{
		internal static int minScrap = -1;

		internal static int maxScrap = -1;

		internal static int adjustedEclipse = -1;

		internal static int powerCount = -1;

		internal static int outsidePowerCount = -1;

		internal static Dictionary<string, int> adjustedScrap = new Dictionary<string, int>();

		internal static Dictionary<string, int> adjustedEnemies = new Dictionary<string, int>();

		internal static void Apply(SelectableLevel level)
		{
			AdjustScrap(level);
			AdjustEnemies(level);
			if (adjustedEclipse >= 0)
			{
				RandomWeatherWithVariables val = ((IEnumerable<RandomWeatherWithVariables>)level.randomWeathers).FirstOrDefault((Func<RandomWeatherWithVariables, bool>)((RandomWeatherWithVariables randomWeather) => (int)randomWeather.weatherType == 5));
				if (val != null)
				{
					Plugin.Logger.LogDebug((object)$"{((Object)level).name}.randomWeathers.Eclipsed.weatherVariable: {val.weatherVariable} -> {adjustedEclipse}");
					val.weatherVariable = adjustedEclipse;
				}
				adjustedEclipse = -1;
			}
		}

		private static void AdjustScrap(SelectableLevel level)
		{
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Expected O, but got Unknown
			if (minScrap >= 0)
			{
				Plugin.Logger.LogDebug((object)$"{((Object)level).name}.minScrap: {level.minScrap} => {minScrap}");
				level.minScrap = minScrap;
				minScrap = -1;
			}
			if (maxScrap >= 0)
			{
				Plugin.Logger.LogDebug((object)$"{((Object)level).name}.maxScrap: {level.maxScrap} => {maxScrap}");
				level.maxScrap = maxScrap;
				maxScrap = -1;
			}
			if (adjustedScrap.Count <= 0)
			{
				return;
			}
			foreach (SpawnableItemWithRarity item in level.spawnableScrap)
			{
				if (adjustedScrap.TryGetValue(((Object)item.spawnableItem).name, out var value))
				{
					Plugin.Logger.LogDebug((object)$"{((Object)level).name}.spawnableScrap: {item.spawnableItem.itemName} - {item.rarity} => {value}");
					item.rarity = value;
					adjustedScrap.Remove(((Object)item.spawnableItem).name);
				}
			}
			if (adjustedScrap.Count > 0)
			{
				foreach (KeyValuePair<string, int> itemID in adjustedScrap)
				{
					Item val = ((IEnumerable<Item>)StartOfRound.Instance.allItemsList.itemsList).FirstOrDefault((Func<Item, bool>)((Item item) => ((Object)item).name == itemID.Key));
					if ((Object)(object)val != (Object)null)
					{
						level.spawnableScrap.Add(new SpawnableItemWithRarity
						{
							spawnableItem = val,
							rarity = itemID.Value
						});
					}
					Plugin.Logger.LogDebug((object)$"{((Object)level).name}.spawnableScrap: +({val.itemName}, {itemID.Value})");
				}
			}
			adjustedScrap.Clear();
		}

		private static void AdjustEnemies(SelectableLevel level)
		{
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Expected O, but got Unknown
			if (powerCount >= 0)
			{
				Plugin.Logger.LogDebug((object)$"{((Object)level).name}.maxEnemyPowerCount: {level.maxEnemyPowerCount} => {powerCount}");
				level.maxEnemyPowerCount = powerCount;
				powerCount = -1;
			}
			if (outsidePowerCount >= 0)
			{
				Plugin.Logger.LogDebug((object)$"{((Object)level).name}.maxOutsideEnemyPowerCount: {level.maxOutsideEnemyPowerCount} => {outsidePowerCount}");
				level.maxOutsideEnemyPowerCount = outsidePowerCount;
				outsidePowerCount = -1;
			}
			if (adjustedEnemies.Count <= 0)
			{
				return;
			}
			foreach (KeyValuePair<string, int> adjustedEnemy in adjustedEnemies)
			{
				if (Common.enemies.TryGetValue(adjustedEnemy.Key, out var enemy))
				{
					List<SpawnableEnemyWithRarity> list = null;
					list = (enemy.isDaytimeEnemy ? level.DaytimeEnemies : ((!enemy.isOutsideEnemy || !(((Object)enemy).name != "MaskedPlayerEnemy")) ? level.Enemies : level.OutsideEnemies));
					SpawnableEnemyWithRarity val = ((IEnumerable<SpawnableEnemyWithRarity>)list).FirstOrDefault((Func<SpawnableEnemyWithRarity, bool>)((SpawnableEnemyWithRarity spawnableEnemyWithRarity) => (Object)(object)spawnableEnemyWithRarity.enemyType == (Object)(object)enemy));
					if (val != null)
					{
						Plugin.Logger.LogDebug((object)$"{((Object)level).name}: {val.enemyType.enemyName} - {val.rarity} => {adjustedEnemy.Value}");
						val.rarity = adjustedEnemy.Value;
					}
					else if (enemy.isOutsideEnemy)
					{
						list.Add(new SpawnableEnemyWithRarity
						{
							enemyType = enemy,
							rarity = adjustedEnemy.Value
						});
						Plugin.Logger.LogDebug((object)$"{((Object)level).name}: +({enemy.enemyName}, {adjustedEnemy.Value})");
					}
				}
			}
			adjustedEnemies.Clear();
		}

		internal static void AdjustInteriors(SelectableLevel level, Dictionary<int, int> adjustedInteriors)
		{
			IntWithRarity[] dungeonFlowTypes = level.dungeonFlowTypes;
			foreach (IntWithRarity val in dungeonFlowTypes)
			{
				if (adjustedInteriors.TryGetValue(val.id, out var value))
				{
					Plugin.Logger.LogDebug((object)$"{((Object)level).name}.dungeonFlowTypes: {((Object)RoundManager.Instance.dungeonFlowTypes[val.id].dungeonFlow).name}, {val.rarity} -> {value}");
					val.rarity = value;
				}
			}
		}
	}
	internal class OffenseOverrides
	{
		internal static readonly Dictionary<int, int> adjustedInteriors = new Dictionary<int, int>
		{
			{ 0, 150 },
			{ 4, 300 }
		};

		internal static readonly Dictionary<string, int> infestations = new Dictionary<string, int>
		{
			{ "HoarderBug", 150 },
			{ "Nutcracker", 50 },
			{ "MaskedPlayerEnemy", 300 }
		};

		internal static void Setup(SelectableLevel level)
		{
			if (Configuration.offenseBuffScrap.Value)
			{
				MoonOverrides.minScrap = 14;
				MoonOverrides.maxScrap = 19;
				Extensions.AddRange<string, int>(MoonOverrides.adjustedScrap, new Dictionary<string, int>
				{
					{ "YieldSign", 12 },
					{ "Cog1", 30 },
					{ "EnginePart1", 40 },
					{ "MetalSheet", 23 },
					{ "ToyCube", 31 },
					{ "StopSign", 40 },
					{ "CashRegister", 3 },
					{ "DiyFlashbang", 14 },
					{ "TragedyMask", 3 },
					{ "SodaCanRed", 12 },
					{ "Bell", 16 },
					{ "GoldBar", 4 },
					{ "Mug", 18 },
					{ "BottleBin", 30 },
					{ "ClownHorn", 35 },
					{ "RubberDuck", 24 }
				});
			}
			if (Configuration.offenseMasked.Value)
			{
				MoonOverrides.adjustedEnemies.Add("MaskedPlayerEnemy", 9);
			}
			if (Configuration.offenseNerfEclipse.Value)
			{
				MoonOverrides.adjustedEclipse = 3;
			}
			if (Configuration.offenseBees.Value)
			{
				MoonOverrides.adjustedEnemies.Add("RedLocustBees", 31);
				level.daytimeEnemySpawnChanceThroughDay = AnimationCurve.EaseInOut(0f, -1.272499f, 1f, -14.8181f);
			}
			MoonOverrides.Apply(level);
		}
	}
	internal class RendOverrides
	{
		internal static readonly Dictionary<int, int> adjustedInteriors = new Dictionary<int, int> { { 4, 14 } };

		internal static readonly Dictionary<string, int> infestations = new Dictionary<string, int>
		{
			{ "Nutcracker", 300 },
			{ "MaskedPlayerEnemy", 150 },
			{ "Butler", 4 },
			{ "ClaySurgeon", 75 }
		};

		internal static void Setup(SelectableLevel level)
		{
			if (Configuration.rendAdjustScrap.Value)
			{
				Extensions.AddRange<string, int>(MoonOverrides.adjustedScrap, new Dictionary<string, int>
				{
					{ "GiftBox", 49 },
					{ "BottleBin", 58 },
					{ "PillBottle", 29 },
					{ "Toothpaste", 41 },
					{ "Candy", 50 },
					{ "CashRegister", 22 },
					{ "Brush", 31 },
					{ "7Ball", 16 },
					{ "WhoopieCushion", 26 },
					{ "ControlPad", 14 },
					{ "TeaKettle", 47 }
				});
			}
			if (Configuration.rendAdjustIndoor.Value)
			{
				Extensions.AddRange<string, int>(MoonOverrides.adjustedEnemies, new Dictionary<string, int>
				{
					{ "Jester", 71 },
					{ "DressGirl", 28 },
					{ "ClaySurgeon", 20 },
					{ "Blob", 24 },
					{ "Flowerman", 66 },
					{ "SpringMan", 70 },
					{ "MaskedPlayerEnemy", 43 }
				});
			}
			if (Configuration.rendWorms.Value)
			{
				MoonOverrides.adjustedEnemies.Add("SandWorm", 18);
			}
			MoonOverrides.Apply(level);
		}
	}
	internal class TitanOverrides
	{
		internal static readonly Dictionary<int, int> adjustedInteriors = new Dictionary<int, int> { { 4, 69 } };

		internal static readonly Dictionary<string, int> infestations = new Dictionary<string, int>
		{
			{ "HoarderBug", 135 },
			{ "Nutcracker", 45 },
			{ "MaskedPlayerEnemy", 300 }
		};

		internal static void Setup(SelectableLevel level)
		{
			if (Configuration.titanBuffScrap.Value)
			{
				MoonOverrides.minScrap = 28;
				MoonOverrides.maxScrap = 36;
				Extensions.AddRange<string, int>(MoonOverrides.adjustedScrap, new Dictionary<string, int>
				{
					{ "Cog1", 19 },
					{ "EnginePart1", 19 },
					{ "FancyLamp", 29 },
					{ "FancyPainting", 44 },
					{ "Brush", 18 },
					{ "PerfumeBottle", 16 },
					{ "Mug", 44 },
					{ "7Ball", 30 },
					{ "DiyFlashbang", 10 },
					{ "WhoopieCushion", 18 },
					{ "GiftBox", 67 }
				});
			}
			if (Configuration.titanAddGold.Value)
			{
				MoonOverrides.adjustedScrap.Add("GoldBar", 9);
			}
			if (Configuration.titanAdjustEnemies.Value)
			{
				Extensions.AddRange<string, int>(MoonOverrides.adjustedEnemies, new Dictionary<string, int>
				{
					{ "ForestGiant", 20 },
					{ "DressGirl", 28 },
					{ "RadMech", 13 },
					{ "Blob", 41 },
					{ "HoarderBug", 55 },
					{ "Jester", 60 }
				});
			}
			if (Configuration.titanWeeds.Value)
			{
				Plugin.Logger.LogDebug((object)$"{((Object)level).name}.canSpawnMold: {level.canSpawnMold} -> False");
				level.canSpawnMold = false;
			}
			MoonOverrides.Apply(level);
		}
	}
	internal class VowOverrides
	{
		internal static readonly Dictionary<int, int> adjustedInteriors = new Dictionary<int, int>
		{
			{ 0, 75 },
			{ 4, 300 }
		};

		internal static readonly Dictionary<string, int> infestatio