Decompiled source of ButteRyBalance v0.4.1

ButteRyBalance.dll

Decompiled a week ago
using System;
using System.Collections;
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;
using UnityEngine.Rendering.HighDefinition;

[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+9d72c3e712a79fed547f053bbec8506872ed2ad7")]
[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]
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 enum DamageID
		{
			Unknown = -1,
			Shovel = 1,
			Knife = 5,
			Cruiser = 331
		}

		internal const int NUM_LEVELS = 13;

		internal static bool INSTALLED_ARTIFICE_BLIZZARD;

		internal static bool INSTALLED_BARBER_FIXES;

		internal static bool INSTALLED_SPAWN_CYCLE_FIXES;

		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
	{
		internal enum DineScrap
		{
			DontChange,
			Consolidate,
			Rollback
		}

		internal enum SnowmanFrequency
		{
			None,
			Rare,
			Lots
		}

		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> experimentationBuffScrap;

		internal static ConfigEntry<bool> randomIndoorFog;

		internal static ConfigEntry<bool> assuranceNerfScrap;

		internal static ConfigEntry<bool> assuranceMasked;

		internal static ConfigEntry<bool> vowNoCoils;

		internal static ConfigEntry<bool> vowMineshafts;

		internal static ConfigEntry<bool> offenseBuffScrap;

		internal static ConfigEntry<bool> offenseMasked;

		internal static ConfigEntry<bool> offenseNerfEclipse;

		internal static ConfigEntry<bool> vowNoTraps;

		internal static ConfigEntry<bool> marchBuffScrap;

		internal static ConfigEntry<bool> butlerSquishy;

		internal static ConfigEntry<bool> adamanceBuffScrap;

		internal static ConfigEntry<bool> coilheadCurves;

		internal static ConfigEntry<bool> rendShrink;

		internal static ConfigEntry<bool> rendWorms;

		internal static ConfigEntry<bool> metalSheetPrice;

		internal static ConfigEntry<bool> coilheadPower;

		internal static ConfigEntry<bool> dineAdjustOutdoor;

		internal static ConfigEntry<bool> titanBuffScrap;

		internal static ConfigEntry<bool> titanAddGold;

		internal static ConfigEntry<bool> titanAdjustEnemies;

		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> 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> 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> zapGunBattery;

		internal static ConfigEntry<bool> offenseBees;

		internal static ConfigEntry<bool> apparatusPrice;

		internal static ConfigEntry<bool> spikeTrapDistance;

		internal static ConfigEntry<bool> infestationThumpers;

		internal static ConfigEntry<bool> coilheadPersistence;

		internal static ConfigEntry<bool> giantSquishy;

		internal static ConfigEntry<bool> hoarderAngerManagement;

		internal static ConfigEntry<bool> infestationSnareFlea;

		internal static ConfigEntry<bool> infestationCoilhead;

		internal static ConfigEntry<bool> foxSlender;

		internal static ConfigEntry<bool> adamanceNerfEclipse;

		internal static ConfigEntry<bool> cadaversPower;

		internal static ConfigEntry<bool> pufferPower;

		internal static ConfigEntry<bool> spikeTrapMineshaft;

		internal static ConfigEntry<bool> jetpackUtility;

		internal static ConfigEntry<bool> infestationGunkfish;

		internal static ConfigEntry<bool> adamanceInteriors;

		internal static ConfigEntry<bool> adamanceNoMasks;

		internal static ConfigEntry<bool> offenseNerfTraps;

		internal static ConfigEntry<bool> assuranceGiants;

		internal static ConfigEntry<bool> dineMineshafts;

		internal static ConfigEntry<bool> proFlashlightPrice;

		internal static ConfigEntry<bool> vowMisty;

		internal static ConfigEntry<bool> nerfNightVision;

		internal static ConfigEntry<bool> marchAdjustEnemies;

		internal static ConfigEntry<bool> gunkfishSquishy;

		internal static ConfigEntry<bool> shovelBuffer;

		internal static ConfigEntry<DineScrap> dineScrapPool;

		internal static ConfigEntry<SnowmanFrequency> rendSnowmen;

		internal static ConfigEntry<SnowmanFrequency> dineSnowmen;

		internal static ConfigEntry<SnowmanFrequency> titanSnowmen;

		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", false, "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.");
			jetpackUtility = configFile.Bind<bool>("Item.Jetpack", "No Utility Belt", true, "Blacklists the jetpack from the utility belt, like shovels. This means you can only fly 3 scraps at a time like before.");
			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.");
			proFlashlightPrice = configFile.Bind<bool>("Item.ProFlashlight", "Nerf Price", true, "Increases the cost of pro-flashlights from $28 to $32, like the first v80 beta.");
			radarBoosterPrice = configFile.Bind<bool>("Item.RadarBooster", "Buff Price", true, "Reduces the cost of the radar booster from $60 to $50, like in v40.");
			shovelBuffer = configFile.Bind<bool>("Item.Shovel", "Input Buffer", true, "(Client-side) Clicking the attack button shortly before the shovel is readied will \"buffer\" your input, winding up as soon as the shovel finishes its swing.");
			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", false, "Increases the average sell value of metal sheets.");
			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()
		{
			gunkfishSquishy = configFile.Bind<bool>("Enemy.BackwaterGunkfish", "Squishy", false, "Reduce the Backwater Gunkfish's HP from 4 to 3.");
			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", false, "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", false, "Restores the kitchen knife's price randomization. On average, it will be significantly more valuable than $35, the vanilla price.");
			cadaversPower = configFile.Bind<bool>("Enemy.CadaverGrowths", "Increase Power Level", true, "Increase Cadaver Growths' power level from 2 to 4, to keep the day's threats more solitarily focused.");
			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", false, "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.");
			coilheadPersistence = configFile.Bind<bool>("Enemy.Coilhead", "Persistence", false, "Coil-heads no longer recharge from just chasing players, behaving akin to their pre-v60 iteration.");
			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.");
			giantSquishy = configFile.Bind<bool>("Enemy.ForestKeeper", "Squishy", true, "Forest Keepers are instantly killed if the Cruiser is rammed into them at high speeds, just like before v70.");
			hoarderAngerManagement = configFile.Bind<bool>("Enemy.HoardingBug", "Anger Management", true, "Hoarding bug \"annoyance\" (from player proximity) will reset when they enter chase, which makes them less likely to get stuck in an aggro loop on players who don't steal from them.");
			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. Only works in games with 4 players or less.");
			foxSlender = configFile.Bind<bool>("Enemy.KidnapperFox", "No Roadkill", true, "Make the kidnapper fox immune to the Company Cruiser. This is already the case in vanilla, but CruiserImproved fixes the bug causing it, which pseudo-nerfs the fox");
			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", false, "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", false, "Restores randomization for the shotgun's price.");
			nutcrackerKevlar = configFile.Bind<bool>("Enemy.Nutcracker", "Last Stand", false, "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.");
			pufferPower = configFile.Bind<bool>("Enemy.SporeLizard", "Decrease Power Level", true, "Decrease spore lizard's power level from 1 to 0.5, as like the Backwater Gunkfish, it is mostly passive to players and only incidentally dangerous.");
		}

		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.");
			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, "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.");
			assuranceGiants = configFile.Bind<bool>("Moon.Assurance", "More Forest Giants", true, "Swaps Assurance's forest giant spawn chance with Offense's chances. This will also reduce forest giants on Offense.");
			vowMineshafts = configFile.Bind<bool>("Moon.Vow", "Mostly Mineshafts", true, "Significantly reduce the likelihood of factory interiors on Vow. Fewer \"mineshaft bonus items\" will spawn, and outside spawns will be slightly increased, to compensate for increased profits.");
			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", false, "Removes landmines and turrets from Vow, like in v9.");
			vowMisty = configFile.Bind<bool>("Moon.Vow", "Misty", true, "Makes Vow's natural fog much denser, like it was before v72.");
			offenseBuffScrap = configFile.Bind<bool>("Moon.Offense", "Buff Scrap", true, "Swaps several items' rarities with the corresponding values from Assurance's loot pool. Also adds gold bars as a very rare spawn.");
			offenseBees = configFile.Bind<bool>("Moon.Offense", "Circuit Bees", false, "Allow circuit bees to spawn on Offense, like Assurance.");
			offenseMasked = configFile.Bind<bool>("Moon.Offense", "Spawn Masked", true, "Allow \"Masked\" enemies to spawn rarely on Offense, since Comedy spawns there - these rare spawns will completely replace brackens.");
			offenseNerfEclipse = configFile.Bind<bool>("Moon.Offense", "Nerf Eclipse", false, "Reduces enemy spawns per \"wave\" during eclipses on Offense from 4 to 3.");
			offenseNerfTraps = configFile.Bind<bool>("Moon.Offense", "Reduce Traps", true, "Reduces trap spawns (landmines and turrets) to pre-v80 spawn rates.");
			marchBuffScrap = configFile.Bind<bool>("Moon.March", "Buff Scrap", false, "Slightly increase the amount and quality of scrap that spawns on March, to bring it a little closer with Adamance.");
			marchAdjustEnemies = configFile.Bind<bool>("Moon.March", "Adjust Outdoor Enemies", false, "Decreases dogs and increases giants.");
			adamanceBuffScrap = configFile.Bind<bool>("Moon.Adamance", "Buff Scrap", false, "Increases the amount of scrap that spawns on Adamance, like before v80. (14-16 -> 16-18)");
			adamanceNerfEclipse = configFile.Bind<bool>("Moon.Adamance", "Nerf Eclipse", false, "Reduces enemy spawns per \"wave\" during eclipses on Adamance from 3 to 2.");
			adamanceInteriors = configFile.Bind<bool>("Moon.Adamance", "Adjust Interiors", false, "Increases mineshaft chance (like before v80) and also slightly increases manor chance (like v50 beta). Also adds butlers back to the spawn pool, as a bonus.");
			adamanceNoMasks = configFile.Bind<bool>("Moon.Adamance", "No Masked", true, "\"Masked\" no longer have a random chance to spawn on Adamance.");
			rendShrink = configFile.Bind<bool>("Moon.Rend", "Shrink Interior", false, "Reduces Rend's interior size multiplier from 1.8x to 1.6x.");
			rendWorms = configFile.Bind<bool>("Moon.Rend", "Restore Earth Leviathans", false, "Allow Earth Leviathans, which were removed from Rend in v56, to spawn again.");
			rendSnowmen = configFile.Bind<SnowmanFrequency>("Moon.Rend", "Snowmen", SnowmanFrequency.Rare, "Allow snowmen, which were removed in v70, to spawn again.");
			dineScrapPool = configFile.Bind<DineScrap>("Moon.Dine", "Scrap Pool", DineScrap.Consolidate, "What sort of scrap should spawn on Dine?\n\"DontChange\" will avoid making any changes, letting vanilla or other mods take priority.\n\"Consolidate\" will use V73+'s spawn pool, but 40% as many items will spawn with 1.75x value each.\n\"Rollback\" will revert the scrap pool to what it was in ButteRyBalance before v73.");
			dineMineshafts = configFile.Bind<bool>("Moon.Dine", "Dineshaft", true, "Increase the chance of mineshafts again, much like it was before v80.");
			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.");
			dineAdjustOutdoor = configFile.Bind<bool>("Moon.Dine", "Adjust Outdoor Enemies", true, "Decreases spawn chance for giants and increases spawn chance for Old Birds, leading to more varied outdoor gameplay.");
			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.");
			dineSnowmen = configFile.Bind<SnowmanFrequency>("Moon.Dine", "Snowmen", SnowmanFrequency.Rare, "Allow snowmen, which were removed in v70, to spawn again.");
			titanBuffScrap = configFile.Bind<bool>("Moon.Titan", "Buff Scrap", true, "Increases scrap counts on Titan from 28-31 to 28-35, like in v50 betas.");
			titanAddGold = configFile.Bind<bool>("Moon.Titan", "Gold Rush", false, "Adds gold bars to Titan's loot pool as a rare find.");
			titanAdjustEnemies = configFile.Bind<bool>("Moon.Titan", "Adjust Enemies", true, "Decreases giants and increases Old Birds. Also slightly adjusts interior spawns to reduce the frequency of the Jester.");
			titanSnowmen = configFile.Bind<SnowmanFrequency>("Moon.Titan", "Snowmen", SnowmanFrequency.Rare, "Allow snowmen, which were removed in v70, to spawn again.");
			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", false, "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.");
			embrionMega = configFile.Bind<bool>("Moon.Embrion", "Bigger on the Inside", false, "Double the interior size, dramatically increase the chance of mineshafts, and greatly increase the number of scrap items.");
			embrionAdjustEnemies = configFile.Bind<bool>("Moon.Embrion", "Adjust Indoor Enemies", false, "Increase the spawn rates of non-biological enemies in the interior.");
		}

		private static void MiscConfig()
		{
			nerfNightVision = configFile.Bind<bool>("Misc", "Reduce Night Vision", true, "Lower the distance you can see clearly in the dark without a light source, as it was in the original v80 beta.");
			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.");
			spikeTrapDistance = configFile.Bind<bool>("Misc", "Safely Distance Spike Traps", true, "Spike traps are no longer allowed to spawn directly on top of building entrances.");
			spikeTrapMineshaft = configFile.Bind<bool>("Misc", "Mineshaft Spike Traps", false, "Spike traps will be allowed in mineshaft interiors again, like before v80. It is *strongly recommended* to use \"Safely Distance Spike Traps\" in conjunction with this setting, or else spike traps will be allowed to spawn on top of the elevator!");
		}

		private static void InfestationConfig()
		{
			infestationRework = configFile.Bind<bool>("Infestations", "Rework Mechanics", true, "(REQUIRES SPAWN CYCLE FIXES!) Infestations no longer override a moon's power level, and enemy spawn chances are no longer altered. 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", false, "Allow Barbers to be selected as the subject of an infestation. Other enemy spawns will be disabled. Won't occur inside mineshafts.");
			infestationThumpers = configFile.Bind<bool>("Infestations", "Thumper Infestations", false, "Allow thumpers to be selected as the subject of an infestation.");
			infestationSnareFlea = configFile.Bind<bool>("Infestations", "Snare Flea Infestations", false, "Allow snare fleas to be selected as the subject of an infestation.");
			infestationCoilhead = configFile.Bind<bool>("Infestations", "Coil-head Infestations", false, "Allow coil-heads to be selected as the subject of an infestation.");
			infestationGunkfish = configFile.Bind<bool>("Infestations", "Backwater Gunkfish Infestations", false, "Allow Backwater Gunkfish to be selected as the subject of an infestation.");
		}

		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);
			}
			if (!adamanceNerfEclipse.Value)
			{
				if (configFile.Bind<bool>("Moon.Adamance", "Reduce Chaos", false, "Legacy setting, doesn't work").Value)
				{
					adamanceNerfEclipse.Value = true;
				}
				configFile.Remove(configFile["Moon.Adamance", "Reduce Chaos"].Definition);
			}
			(string, string)[] array = new(string, string)[23]
			{
				("Enemy.ForestKeeper", "Forget Out-of-Sight Players"),
				("Item.TZPInhalant", "Expand Capacity"),
				("Moon.Dine", "Buff Scrap"),
				("Moon.Titan", "No Vain Shrouds"),
				("Moon.Embrion", "No Vain Shrouds"),
				("Enemy.OldBird", "Restore Mech Riding"),
				("Moon.March", "Shrink Interior"),
				("Moon.March", "Always Rainy"),
				("Misc", "Multiplayer Weather Multiplier"),
				("Moon.Offense", "Mostly Mineshafts"),
				("Misc", "Shrink Mineshafts"),
				("Moon.Vow", "Adjust Scrap"),
				("Moon.Experimentation", "No Nutcrackers"),
				("Moon.Rend", "Rare Mineshafts"),
				("Moon.Rend", "Adjust Scrap"),
				("Moon.Dine", "Adjust Indoor Enemies"),
				("Moon.Dine", "Adjust Spawn Curves"),
				("Moon.Dine", "Add Masked"),
				("Moon.Embrion", "Buff Scrap"),
				("Moon.Embrion", "Increase Mineshafts"),
				("Moon.Rend", "Adjust Indoor Enemies"),
				("Enemy.KidnapperFox", "Squishy"),
				("Moon.Titan", "Reduce Mineshafts")
			};
			for (int i = 0; i < array.Length; i++)
			{
				(string, string) tuple = array[i];
				try
				{
					configFile.Bind<string>(tuple.Item1, tuple.Item2, string.Empty, "Legacy setting, doesn't work");
					configFile.Remove(configFile[tuple.Item1, tuple.Item2].Definition);
				}
				catch
				{
					Plugin.Logger.LogWarning((object)("Can't delete \"" + tuple.Item1 + "\" - \"" + tuple.Item2 + "\" from config"));
				}
			}
			configFile.Save();
		}
	}
	internal static class LobbyCompatibility
	{
		internal static void Init()
		{
			PluginHelper.RegisterPlugin("butterystancakes.lethalcompany.butterybalance", Version.Parse("0.4.1"), (CompatibilityLevel)2, (VersionStrictness)3);
		}
	}
	[BepInPlugin("butterystancakes.lethalcompany.butterybalance", "ButteRyBalance", "0.4.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[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.4.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_SPAWN_CYCLE_FIXES = "butterystancakes.lethalcompany.spawncyclefixes";

		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.spawncyclefixes"))
			{
				Logger.LogInfo((object)"CROSS-COMPATIBILITY - Spawn Cycle Fixes detected");
				Common.INSTALLED_SPAWN_CYCLE_FIXES = true;
			}
			Configuration.Init(((BaseUnityPlugin)this).Config);
			new Harmony("butterystancakes.lethalcompany.butterybalance").PatchAll();
			Logger.LogInfo((object)"ButteRyBalance v0.4.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 static class GameNetworkManagerPatches
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void GameNetworkManager_Post_Start()
		{
			BRBNetworker.Init();
		}

		[HarmonyPatch("Disconnect")]
		[HarmonyPostfix]
		private static void GameNetworkManager_Post_Disconnect()
		{
			if ((Object)(object)RoundManager.Instance != (Object)null && ((NetworkBehaviour)RoundManager.Instance).IsServer)
			{
				InfestationOverrides.EndInfestation();
			}
			Common.Disconnect();
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class RoundManagerPatches
	{
		[HarmonyPatch("RefreshEnemiesList")]
		[HarmonyPostfix]
		private static void RoundManager_Post_RefreshEnemiesList(RoundManager __instance)
		{
			InfestationOverrides.EndInfestation();
			Random random = new Random(StartOfRound.Instance.randomMapSeed + 5781);
			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 || (((Object)__instance.currentLevel).name == "EmbrionLevel" && BRBNetworker.Instance.EmbrionMega.Value && random.Next(100) <= 8)) && Configuration.infestationRework.Value && Common.INSTALLED_SPAWN_CYCLE_FIXES)
				{
					InfestationOverrides.CustomInfestation((__instance.enemyRushIndex >= 0 && ((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 = random.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_SPAWN_CYCLE_FIXES)
					{
						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 Spawn Cycle Fixes 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)
		{
			if (BRBNetworker.Instance.MoonsKillSwitch.Value)
			{
				return;
			}
			switch (((Object)__instance.currentLevel).name)
			{
			case "VowLevel":
				if (BRBNetworker.Instance.VowMineshafts.Value)
				{
					MoonOverrides.AdjustInteriors(__instance.currentLevel, VowOverrides.adjustedInteriors);
				}
				break;
			case "AdamanceLevel":
				if (BRBNetworker.Instance.AdamanceInteriors.Value)
				{
					MoonOverrides.AdjustInteriors(__instance.currentLevel, AdamanceOverrides.adjustedInteriors);
				}
				break;
			case "DineLevel":
				if (BRBNetworker.Instance.DineMineshafts.Value)
				{
					MoonOverrides.AdjustInteriors(__instance.currentLevel, DineOverrides.adjustedInteriors);
				}
				break;
			case "ArtificeLevel":
				if (BRBNetworker.Instance.ArtificeInteriors.Value)
				{
					MoonOverrides.AdjustInteriors(__instance.currentLevel, ArtificeOverrides.adjustedInteriors);
				}
				break;
			case "EmbrionLevel":
				if (BRBNetworker.Instance.EmbrionMega.Value)
				{
					MoonOverrides.AdjustInteriors(__instance.currentLevel, EmbrionOverrides.adjustedInteriors);
				}
				break;
			}
		}

		[HarmonyPatch("FinishGeneratingNewLevelClientRpc")]
		[HarmonyPostfix]
		private static void RoundManager_Post_FinishGeneratingNewLevelClientRpc(RoundManager __instance)
		{
			//IL_02d8: 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_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			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");
				}
			}
			string text = "/Environment/Lighting/BrightDay/Local Volumetric Fog";
			if (StartOfRound.Instance.currentLevel.sceneName == "Level3Vow")
			{
				if (BRBNetworker.Instance.VowMisty.Value)
				{
					GameObject obj = GameObject.Find(text);
					LocalVolumetricFog val = ((obj != null) ? obj.GetComponent<LocalVolumetricFog>() : null);
					if ((Object)(object)val != (Object)null)
					{
						val.parameters.meanFreePath = 15.1f;
					}
				}
			}
			else if (StartOfRound.Instance.currentLevel.sceneName == "Level5Rend")
			{
				GameObject val2 = GameObject.Find(text + " (2)");
				if ((Object)(object)val2 != (Object)null)
				{
					val2.SetActive(false);
				}
				return;
			}
			if (!((NetworkBehaviour)__instance).IsServer)
			{
				return;
			}
			if (Configuration.spikeTrapDistance.Value)
			{
				SpikeRoofTrap[] array = Object.FindObjectsByType<SpikeRoofTrap>((FindObjectsSortMode)0);
				EntranceTeleport[] array2 = Object.FindObjectsByType<EntranceTeleport>((FindObjectsSortMode)0);
				MineshaftElevatorController val3 = __instance.currentMineshaftElevator ?? Object.FindAnyObjectByType<MineshaftElevatorController>();
				SpikeRoofTrap[] array3 = array;
				foreach (SpikeRoofTrap val4 in array3)
				{
					bool flag = false;
					if ((Object)(object)val3?.elevatorBottomPoint != (Object)null && Vector3.Distance(((Component)val4.spikeTrapAudio).transform.position, val3.elevatorBottomPoint.position) < 7f)
					{
						Plugin.Logger.LogDebug((object)$"Spike trap #{((Object)val4).GetInstanceID()} will be destroyed (too close to the elevator)");
						flag = true;
					}
					if (!flag)
					{
						EntranceTeleport[] array4 = array2;
						foreach (EntranceTeleport val5 in array4)
						{
							if (!val5.isEntranceToBuilding && !((Object)(object)val5.entrancePoint == (Object)null) && Vector3.Distance(((Component)val4.spikeTrapAudio).transform.position, val5.entrancePoint.position) < 4.5f)
							{
								flag = true;
								Plugin.Logger.LogDebug((object)$"Spike trap #{((Object)val4).GetInstanceID()} will be destroyed (too close to entrance \"{((Object)val5).name}\")");
								break;
							}
						}
					}
					if (flag)
					{
						NetworkObject componentInParent = ((Component)val4).GetComponentInParent<NetworkObject>();
						if ((Object)(object)componentInParent != (Object)null && componentInParent.IsSpawned)
						{
							componentInParent.Despawn(true);
						}
						else
						{
							Plugin.Logger.LogWarning((object)"Error occurred while despawning spike trap (could not find network object, or it was not network spawned yet)");
						}
					}
				}
			}
			if ((__instance.currentDungeonType == 0 || __instance.currentDungeonType == 2 || __instance.currentDungeonType == 3) && BRBNetworker.Instance.ApparatusPrice.Value)
			{
				LungProp componentInChildren = __instance.mapPropsContainer.GetComponentInChildren<LungProp>();
				if ((Object)(object)componentInChildren != (Object)null && componentInChildren.isLungDocked && ((GrabbableObject)componentInChildren).scrapValue == 80)
				{
					BRBNetworker.Instance.SyncScrapPriceRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)componentInChildren).NetworkObject), new Random(StartOfRound.Instance.randomMapSeed).Next(40, 131), node: false);
				}
			}
		}

		[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)"));
				}
			}
			if (!BRBNetworker.Instance.MoonsKillSwitch.Value)
			{
				int num = ((Object)__instance.currentLevel).name switch
				{
					"RendLevel" => BRBNetworker.Instance.RendSnowmen.Value, 
					"DineLevel" => BRBNetworker.Instance.DineSnowmen.Value, 
					"TitanLevel" => BRBNetworker.Instance.TitanSnowmen.Value, 
					_ => 0, 
				};
				if (num > 0)
				{
					MoonOverrides.RestoreSnowmen(__instance.currentLevel, num > 1);
				}
			}
		}

		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("PlotOutEnemiesForNextHour")]
		[HarmonyPrefix]
		private static void RoundManager_Pre_PlotOutEnemiesForNextHour(RoundManager __instance)
		{
			if (((NetworkBehaviour)__instance).IsServer)
			{
				InfestationOverrides.SpawnInfestationWave();
			}
		}

		[HarmonyPatch("SpawnEnemiesOutside")]
		[HarmonyPostfix]
		private static void RoundManager_Post_SpawnEnemiesOutside(RoundManager __instance)
		{
			if (((NetworkBehaviour)__instance).IsServer && __instance.allEnemyVents.Length != 0 && __instance.cannotSpawnMoreInsideEnemies)
			{
				InfestationOverrides.SpawnInfestationWave();
			}
		}

		[HarmonyPatch("SpawnScrapInLevel")]
		[HarmonyPrefix]
		private static void RoundManager_Pre_SpawnScrapInLevel(RoundManager __instance, ref float[] __state)
		{
			__state = new float[2] { 1f, 1f };
			if (BRBNetworker.Instance.MoonsKillSwitch.Value)
			{
				return;
			}
			switch (((Object)__instance.currentLevel).name)
			{
			case "VowLevel":
				if (BRBNetworker.Instance.VowMineshafts.Value)
				{
					if (__instance.currentDungeonType != 4)
					{
						__instance.currentLevel.minScrap = 12;
						__instance.currentLevel.maxScrap = 15;
					}
					else
					{
						__instance.currentLevel.minScrap = 10;
						__instance.currentLevel.maxScrap = 13;
					}
				}
				break;
			case "AdamanceLevel":
				if (Configuration.adamanceBuffScrap.Value)
				{
					if (__instance.currentDungeonType != 4 || !BRBNetworker.Instance.AdamanceInteriors.Value)
					{
						__instance.currentLevel.minScrap = 16;
						__instance.currentLevel.maxScrap = 19;
					}
					else
					{
						__instance.currentLevel.minScrap = 14;
						__instance.currentLevel.maxScrap = 17;
					}
				}
				break;
			case "DineLevel":
				if (Configuration.dineScrapPool.Value == Configuration.DineScrap.Consolidate)
				{
					__state[0] *= 0.4f;
					__instance.scrapAmountMultiplier *= __state[0];
					__state[1] *= 1.75f;
					__instance.scrapValueMultiplier *= __state[1];
				}
				break;
			case "TitanLevel":
				if (Configuration.titanBuffScrap.Value)
				{
					if (__instance.currentDungeonType != 4)
					{
						__instance.currentLevel.minScrap = 28;
						__instance.currentLevel.maxScrap = 36;
					}
					else
					{
						__instance.currentLevel.minScrap = 28;
						__instance.currentLevel.maxScrap = 32;
					}
				}
				break;
			case "ArtificeLevel":
				if (Configuration.artificeBuffScrap.Value)
				{
					if (__instance.currentDungeonType != 4)
					{
						__instance.currentLevel.minScrap = 31;
						__instance.currentLevel.maxScrap = 38;
					}
					else
					{
						__instance.currentLevel.minScrap = 26;
						__instance.currentLevel.maxScrap = 31;
					}
				}
				break;
			}
		}

		[HarmonyPatch("SpawnScrapInLevel")]
		[HarmonyPostfix]
		private static void RoundManager_Post_SpawnScrapInLevel(RoundManager __instance, float[] __state)
		{
			BRBNetworker.Instance.SetScanValueMultiplierRpc(__instance.scrapValueMultiplier);
			__instance.scrapAmountMultiplier /= __state[0];
			__instance.scrapValueMultiplier /= __state[1];
		}
	}
	[HarmonyPatch(typeof(RuntimeDungeon))]
	internal static class RuntimeDungeonPatches
	{
		[HarmonyPatch("Generate")]
		[HarmonyPrefix]
		private static void RuntimeDungeon_Pre_Generate(RuntimeDungeon __instance)
		{
			if (!BRBNetworker.Instance.MoonsKillSwitch.Value)
			{
				switch (((Object)RoundManager.Instance.currentLevel).name)
				{
				case "RendLevel":
					if (BRBNetworker.Instance.RendShrink.Value)
					{
						DungeonGenerator generator2 = __instance.Generator;
						generator2.LengthMultiplier /= 1.125f;
						Plugin.Logger.LogDebug((object)"Shrink Rend");
					}
					break;
				case "ArtificeLevel":
					if (RoundManager.Instance.currentDungeonType != 4 && BRBNetworker.Instance.ArtificeInteriors.Value)
					{
						DungeonGenerator generator3 = __instance.Generator;
						generator3.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 generator = __instance.Generator;
							generator.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 static class StartOfRoundPatches
	{
		internal static bool skipWeatherPatch = true;

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void StartOfRound_Post_Awake(StartOfRound __instance)
		{
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Expected O, but got Unknown
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: 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"];
			EnemyType butler = Common.enemies["Butler"];
			if ((Object)(object)masked != (Object)null && (Object)(object)butler != (Object)null)
			{
				SelectableLevel[] levels = __instance.levels;
				foreach (SelectableLevel val2 in levels)
				{
					if ((Object)(object)masked != (Object)null && (val2.sceneName == "Level2Assurance" || val2.sceneName == "Level7Offense") && !val2.Enemies.Any((SpawnableEnemyWithRarity enemy) => (Object)(object)enemy.enemyType == (Object)(object)masked))
					{
						val2.Enemies.Add(new SpawnableEnemyWithRarity(masked, 0));
						Plugin.Logger.LogDebug((object)("Added Masked to " + ((Object)val2).name + " pool on client (fallback)"));
					}
					else if ((Object)(object)butler != (Object)null && val2.sceneName == "Level10Adamance" && !val2.Enemies.Any((SpawnableEnemyWithRarity enemy) => (Object)(object)enemy.enemyType == (Object)(object)butler))
					{
						val2.Enemies.Add(new SpawnableEnemyWithRarity(butler, 0));
						Plugin.Logger.LogDebug((object)("Added butlers to " + ((Object)val2).name + " pool on client (fallback)"));
					}
				}
			}
			else
			{
				Plugin.Logger.LogWarning((object)"Failed to reference \"masked\" or butler enemy types. This should never happen");
			}
			BRBNetworker.Create();
		}
	}
	[HarmonyPatch(typeof(Terminal))]
	internal static class TerminalPatches
	{
		internal static float fakeValueMultiplier = 0.4f;

		[HarmonyPatch("TextPostProcess")]
		[HarmonyPrefix]
		[HarmonyPriority(500)]
		private static void Terminal_Pre_TextPostProcess(ref float __state)
		{
			__state = RoundManager.Instance.scrapValueMultiplier;
			RoundManager.Instance.scrapValueMultiplier = fakeValueMultiplier;
		}

		[HarmonyPatch("TextPostProcess")]
		[HarmonyPostfix]
		private static void Terminal_Post_TextPostProcess(float __state)
		{
			RoundManager.Instance.scrapValueMultiplier = __state;
		}
	}
	[HarmonyPatch(typeof(TimeOfDay))]
	internal static class TimeOfDayPatches
	{
		[HarmonyPatch("SetWeatherBasedOnVariables")]
		[HarmonyPrefix]
		private static void TimeOfDay_Pre_SetWeatherBasedOnVariables(TimeOfDay __instance)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Invalid comparison between Unknown and I4
			if (!StartOfRound.Instance.isChallengeFile && !BRBNetworker.Instance.MoonsKillSwitch.Value && ((Object)RoundManager.Instance.currentLevel).name == "DineLevel" && (int)__instance.currentLevelWeather == 4 && BRBNetworker.Instance.DineFloods.Value)
			{
				TimeOfDay.Instance.currentWeatherVariable = -16f;
				TimeOfDay.Instance.currentWeatherVariable2 = -5f;
			}
		}

		[HarmonyPatch("SetWeatherBasedOnVariables")]
		[HarmonyPostfix]
		private static void TimeOfDay_Post_SetWeatherBasedOnVariables(TimeOfDay __instance)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Invalid comparison between Unknown and I4
			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(typeof(VehicleController))]
	internal static class VehicleControllerPatches
	{
		[HarmonyPatch("CarReactToObstacle")]
		[HarmonyPrefix]
		private static bool VehicleController_Pre_CarReactToObstacle(VehicleController __instance, EnemyAI enemyScript)
		{
			if (!((Object)(object)enemyScript == (Object)null) && BRBNetworker.Instance.FoxSlender.Value)
			{
				return !(enemyScript is BushWolfEnemy);
			}
			return true;
		}
	}
}
namespace ButteRyBalance.Patches.Items
{
	[HarmonyPatch(typeof(LungProp))]
	internal static class ApparatusPatches
	{
		[HarmonyPatch("EquipItem")]
		[HarmonyPrefix]
		private static void LungProp_Pre_EquipItem(LungProp __instance)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)__instance).IsOwner && __instance.isLungDocked && BRBNetworker.Instance.ApparatusPrice.Value)
			{
				BRBNetworker.Instance.SyncScrapPriceRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance).NetworkObject), ((GrabbableObject)__instance).scrapValue);
			}
		}
	}
	[HarmonyPatch(typeof(JetpackItem))]
	internal static 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 static 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.SyncScrapPriceRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)__instance).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 = InputSystem.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 + Random.Range(0f, 0.01f);
			}
		}
	}
	[HarmonyPatch(typeof(Shovel))]
	internal static class ShovelPatches
	{
		private static float timeLastBuffered;

		private static InputAction activateItem;

		[HarmonyPatch("ItemActivate")]
		[HarmonyPrefix]
		private static void Shovel_Post_ItemActivate(Shovel __instance, bool buttonDown)
		{
			if (buttonDown && __instance.reelingUp)
			{
				timeLastBuffered = Time.realtimeSinceStartup;
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "OnEnable")]
		[HarmonyPostfix]
		private static void PlayerControllerB_Post_OnEnable()
		{
			activateItem = InputSystem.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 && __instance.currentlyHeldObjectServer is Shovel && Configuration.shovelBuffer.Value && __instance.CanUseItem() && activateItem.IsPressed() && Time.realtimeSinceStartup - timeLastBuffered < 0.5f)
			{
				if (Time.realtimeSinceStartup - timeLastBuffered <= 0.5f)
				{
					ShipBuildModeManager.Instance.CancelBuildMode(true);
					__instance.currentlyHeldObjectServer.UseItemOnClient(true);
					__instance.timeSinceSwitchingSlots = 0f;
				}
				timeLastBuffered = Time.realtimeSinceStartup + Random.Range(0f, 0.01f);
			}
		}
	}
	[HarmonyPatch(typeof(PatcherTool))]
	internal static 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(StingrayAI))]
	internal static class BackwaterGunkfishPatches
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StingrayAI_Post_Start(StingrayAI __instance)
		{
			if (BRBNetworker.Instance.GunkfishSquishy.Value)
			{
				((EnemyAI)__instance).enemyHP = 3;
			}
		}
	}
	[HarmonyPatch(typeof(ButlerEnemyAI))]
	internal static 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_018e: 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(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, int hitID)
		{
			if (force > 2 && BRBNetworker.Instance.ButlerSquishy.Value && hitID != 1)
			{
				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 static 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("Update")]
		[HarmonyPostfix]
		private static void SpringManAI_Post_Update(SpringManAI __instance)
		{
			if (!((EnemyAI)__instance).isEnemyDead && !__instance.setOnCooldown && ((EnemyAI)__instance).currentBehaviourStateIndex == 0 && ((EnemyAI)__instance).creatureAnimator.GetFloat("walkSpeed") == 4.7f)
			{
				((EnemyAI)__instance).creatureAnimator.SetFloat("walkSpeed", 2.5f);
			}
			if (((NetworkBehaviour)__instance).IsServer && Configuration.coilheadPersistence.Value)
			{
				__instance.timeSpentMoving = 0f;
			}
		}
	}
	[HarmonyPatch(typeof(ForestGiantAI))]
	internal static 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("HitEnemy")]
		[HarmonyPrefix]
		private static void ForestGiantAI_Pre_HitEnemy(ref int force, int hitID)
		{
			if (force == 12 && BRBNetworker.Instance.GiantSquishy.Value)
			{
				switch (hitID)
				{
				case 1:
				case 5:
					return;
				}
				force += 100;
			}
		}
	}
	[HarmonyPatch(typeof(HoarderBugAI))]
	internal static class HoardingBugPatches
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void HoarderBugAI_Post_Update(HoarderBugAI __instance)
		{
			if (((NetworkBehaviour)__instance).IsOwner && Configuration.hoarderAngerManagement.Value && __instance.angryTimer > 0f)
			{
				__instance.annoyanceMeter = 0f;
			}
		}
	}
	[HarmonyPatch(typeof(JesterAI))]
	internal static 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(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 (setCrying && !((EnemyAI)__instance).isOutside && ((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 = 220f;
				}
				else
				{
					((EnemyAI)__instance).agent.angularSpeed = 700f;
				}
			}
		}
	}
	[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, int hitID)
		{
			if (((NetworkBehaviour)__instance).IsOwner && force == 5 && Configuration.nutcrackerKevlar.Value && hitID == -1)
			{
				force = 4;
			}
		}
	}
}
namespace ButteRyBalance.Overrides
{
	internal class InfestationOverrides
	{
		private static int infestationEnemyIndex = -1;

		private static EnemyType infestationEnemy;

		private static float rollbackPowerLevel = -1f;

		private static int rollbackMaxCount = -1;

		private static int hourOfLastInfestationWave = -1;

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

		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");
			}
			if (Configuration.infestationThumpers.Value)
			{
				if (!compatibleEnemies.Contains("Crawler"))
				{
					compatibleEnemies.Add("Crawler");
				}
			}
			else
			{
				compatibleEnemies.Remove("Crawler");
			}
			if (Configuration.infestationSnareFlea.Value)
			{
				if (!compatibleEnemies.Contains("Centipede"))
				{
					compatibleEnemies.Add("Centipede");
				}
			}
			else
			{
				compatibleEnemies.Remove("Centipede");
			}
			if (Configuration.infestationCoilhead.Value)
			{
				if (!compatibleEnemies.Contains("SpringMan"))
				{
					compatibleEnemies.Add("SpringMan");
				}
			}
			else
			{
				compatibleEnemies.Remove("SpringMan");
			}
			if (Configuration.infestationGunkfish.Value)
			{
				if (!compatibleEnemies.Contains("Stingray"))
				{
					compatibleEnemies.Add("Stingray");
				}
			}
			else
			{
				compatibleEnemies.Remove("Stingray");
			}
		}

		internal static void CustomInfestation(int forceIndex = -1)
		{
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Expected O, but got Unknown
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Expected O, but got Unknown
			SelectableLevel currentLevel = RoundManager.Instance.currentLevel;
			infestationEnemyIndex = RoundManager.Instance.enemyRushIndex;
			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 if (compatibleEnemies.Except(new <>z__ReadOnlyArray<string>(new string[2] { "HoardingBug", "Nutcracker" })).Any())
			{
				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(i, value2, (LevelAmbienceLibrary)null));
						}
					}
					else
					{
						infestationEnemies.Add(new IntWithRarity(i, currentLevel.Enemies[i].rarity, (LevelAmbienceLibrary)null));
					}
				}
				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"));
			rollbackPowerLevel = InfestationOverrides.infestationEnemy.PowerLevel;
			InfestationOverrides.infestationEnemy.PowerLevel = 0f;
			switch (((Object)InfestationOverrides.infestationEnemy).name)
			{
			case "HoardingBug":
				rollbackMaxCount = InfestationOverrides.infestationEnemy.MaxCount;
				InfestationOverrides.infestationEnemy.MaxCount = 8;
				break;
			case "Crawler":
				rollbackMaxCount = InfestationOverrides.infestationEnemy.MaxCount;
				InfestationOverrides.infestationEnemy.MaxCount = Mathf.Min(InfestationOverrides.infestationEnemy.MaxCount * 2, 8);
				break;
			case "Centipede":
				rollbackMaxCount = InfestationOverrides.infestationEnemy.MaxCount;
				InfestationOverrides.infestationEnemy.MaxCount = 20;
				break;
			}
			if (((Object)InfestationOverrides.infestationEnemy).name != "ClaySurgeon")
			{
				RoundManager.Instance.currentMaxInsidePower = RoundManager.Instance.currentLevel.maxEnemyPowerCount;
				RoundManager.Instance.increasedInsideEnemySpawnRateIndex = infestationEnemyIndex;
			}
			else
			{
				RoundManager.Instance.currentMaxInsidePower = 0f;
			}
		}

		internal static void EndInfestation()
		{
			hourOfLastInfestationWave = -1;
			if (infestationEnemyIndex >= 0)
			{
				RoundManager.Instance.increasedInsideEnemySpawnRateIndex = -1;
				if (rollbackPowerLevel > 0f)
				{
					infestationEnemy.PowerLevel = rollbackPowerLevel;
					rollbackPowerLevel = -1f;
				}
				if (rollbackMaxCount > 0)
				{
					infestationEnemy.MaxCount = rollbackMaxCount;
					rollbackMaxCount = -1;
				}
				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;
				}
				int num = RoundManager.Instance.AnomalyRandom.Next((int)(TimeOfDay.Instance.lengthOfHours * (float)TimeOfDay.Instance.hour) + 10, (int)(TimeOfDay.Instance.lengthOfHours * (float)(RoundManager.Instance.currentHour + 1)));
				EnemyVent val = list[RoundManager.Instance.AnomalyRandom.Next(list.Count)];
				val.enemyType = infestationEnemy;
				val.enemyTypeIndex = infestationEnemyIndex;
				val.occupied = true;
				val.spawnTime = num;
				if (TimeOfDay.Instance.hour - RoundManager.Instance.currentHour <= 0)
				{
					val.SyncVentSpawnTimeClientRpc(num, infestationEnemyIndex);
				}
				EnemyType obj = infestationEnemy;
				obj.numberSpawned++;
				Plugin.Logger.LogDebug((object)"Added infestation enemy to vent");
				if (!(((Object)infestationEnemy).name == "ClaySurgeon"))
				{
					list.Remove(val);
					continue;
				}
				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()
		{
			List<IndoorMapHazardType> list = new List<IndoorMapHazardType>();
			SelectableLevel[] levels = StartOfRound.Instance.levels;
			foreach (SelectableLevel val in levels)
			{
				if (!BRBNetworker.Instance.MoonsKillSwitch.Value)
				{
					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;
					}
				}
				IndoorMapHazard[] indoorMapHazards = val.indoorMapHazards;
				foreach (IndoorMapHazard val2 in indoorMapHazards)
				{
					if ((Object)(object)val2.hazardType != (Object)null && !list.Contains(val2.hazardType))
					{
						list.Add(val2.hazardType);
					}
				}
			}
			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 "CadaverGrowths":
					if (Configuration.cadaversPower.Value)
					{
						Plugin.Logger.LogDebug((object)$"Cadavers: Power level {enemy.Value.PowerLevel} -> 4");
						enemy.Value.PowerLevel = 4f;
					}
					break;
				case "CaveDweller":
					if (Configuration.maneaterPower.Value)
					{
						Plugin.Logger.LogDebug((object)$"Maneater: Power level {enemy.Value.PowerLevel} -> 3");
						enemy.Value.PowerLevel = 3f;
					}
					break;
				case "Puffer":
					if (Configuration.pufferPower.Value)
					{
						Plugin.Logger.LogDebug((object)$"Spore lizard: Power level {enemy.Value.PowerLevel} -> 0.5");
						enemy.Value.PowerLevel = 0.5f;
					}
					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, 0.5882353f, 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.23f },
				{ "EnginePart1", 1.18f },
				{ "FancyCup", 1.2f },
				{ "FancyLamp", 1.25f },
				{ "Flask", 1.1f },
				{ "GarbageLid", 1.1f },
				{ "Hairdryer", 1.1f },
				{ "MetalSheet", 1.2f },
				{ "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;
					}
					if (BRBNetworker.Instance.JetpackUtility.Value && !items.disallowUtilitySlot)
					{
						items.disallowUtilitySlot = true;
						Plugin.Logger.LogDebug((object)(((Object)items).name + ".item.disallowUtilitySlot: False -> True"));
					}
					break;
				case "ProFlashlight":
					if (BRBNetworker.Instance.ProFlashlightPrice.Value && items.creditsWorth != 32)
					{
						Plugin.Logger.LogDebug((object)$"{((Object)items).name}.creditsWorth: ${items.creditsWorth} -> $32");
						items.creditsWorth = 32;
					}
					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;
				}
			}
			if (!BRBNetworker.Instance.NerfNightVision.Value)
			{
				return;
			}
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				HDAdditionalLightData component = ((Component)val.nightVision).GetComponent<HDAdditionalLightData>();
				if ((Object)(object)component != (Object)null)
				{
					component.intensity = 2488f;
					component.range = 8.3f;
				}
				else
				{
					val.nightVision.intensity = 622f / MathF.PI;
					val.nightVision.range = 8.3f;
				}
			}
		}
	}
}
namespace ButteRyBalance.Overrides.Moons
{
	internal class AdamanceOverrides
	{
		internal static readonly Dictionary<int, int> adjustedInteriors = new Dictionary<int, int>
		{
			{ 1, 17 },
			{ 4, 135 }
		};

		internal static readonly Dictionary<string, int> infestations = new Dictionary<string, int>
		{
			{ "HoarderBug", 225 },
			{ "Nutcracker", 75 },
			{ "MaskedPlayerEnemy", 1 },
			{ "Butler", 10 },
			{ "ClaySurgeon", 50 },
			{ "Crawler", 300 },
			{ "Centipede", 64 },
			{ "SpringMan", 40 },
			{ "Stingray", 200 }
		};

		internal static void Setup(SelectableLevel level)
		{
			if (Configuration.adamanceBuffScrap.Value)
			{
				MoonOverrides.adjustedScrap.Add("EasterEgg", 71);
			}
			if (Configuration.adamanceNerfEclipse.Value)
			{
				MoonOverrides.adjustedEclipse = 2;
			}
			if (Configuration.adamanceInteriors.Value)
			{
				MoonOverrides.adjustedEnemies.Add("Butler", 10);
			}
			if (Configuration.adamanceNoMasks.Value)
			{
				MoonOverrides.adjustedEnemies.Add("MaskedPlayerEnemy", 0);
			}
			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", 207 },
			{ "Nutcracker", 69 },
			{ "MaskedPlayerEnemy", 151 },
			{ "Butler", 100 },
			{ "ClaySurgeon", 64 },
			{ "Crawler", 48 },
			{ "Centipede", 50 },
			{ "SpringMan", 1 },
			{ "Stingray", 75 }
		};

		internal static void Setup(SelectableLevel level)
		{
			if (Configuration.artificeBuffScrap.Value)
			{
				MoonOverrides.adjustedScrap.Add("GoldBar", 36);
			}
			if (Configuration.artificeTurrets.Value)
			{
				IndoorMapHazard val = ((IEnumerable<IndoorMapHazard>)level.indoorMapHazards).FirstOrDefault((Func<IndoorMapHazard, bool>)delegate(IndoorMapHazard indoorMapHazard)
				{
					IndoorMapHazardType hazardType = indoorMapHazard.hazardType;
					object obj;
					if (hazardType == null)
					{
						obj = null;
					}
					else
					{
						GameObject prefabToSpawn2 = hazardType.prefabToSpawn;
						obj = ((prefabToSpawn2 != null) ? ((Object)prefabToSpawn2).name : null);
					}
					return (string?)obj == "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 + ".indoorMapHazards." + ((Object)val.hazardType).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 },
			{ "Crawler", 75 },
			{ "Centipede", 300 },
			{ "Stingray", 40 }
		};

		internal static void Setup(SelectableLevel level)
		{
			if (Configuration.assuranceNerfScrap.Value)
			{
				Extensions.AddRange<string, int>(MoonOverrides.adjustedScrap, new Dictionary<string, int>
				{
					{ "Cog1", 94 },
					{ "EnginePart1", 80 },
					{ "BigBolt", 89 },
					{ "ToyCube", 11 },
					{ "BottleBin", 67 },
					{ "MetalSheet", 65 },
					{ "StopSign", 27 },
					{ "YieldSign", 28 },
					{ "DiyFlashbang", 13 },
					{ "ToiletPaperRolls", 18 },
					{ "Candy", 50 }
				});
			}
			if (Configuration.assuranceMasked.Value)
			{
				MoonOverrides.adjustedEnemies.Add("MaskedPlayerEnemy", 2);
			}
			if (Configuration.assuranceGiants.Value)
			{
				MoonOverrides.adjustedEnemies.Add("ForestGiant", 9);
			}
			MoonOverrides.Apply(level);
		}
	}
	internal class DineOverrides
	{
		internal const float CONSOLIDATE_AMOUNT = 0.4f;

		internal const float CONSOLIDATE_VALUE = 1.75f;

		internal static readonly Dictionary<int, int> adjustedInteriors = new Dictionary<int, int> { { 4, 140 } };

		internal static readonly Dictionary<string, int> infestations = new Dictionary<string, int>
		{
			{ "HoarderBug", 3 },
			{ "Nutcracker", 1 },
			{ "MaskedPlayerEnemy", 40 },
			{ "Butler", 300 },
			{ "ClaySurgeon", 14 },
			{ "Crawler", 17 },
			{ "Centipede", 8 },
			{ "SpringMan", 4 },
			{ "Stingray", 94 }
		};

		internal static void Setup(SelectableLevel level)
		{
			if (Configuration.dineScrapPool.Value != 0)
			{
				if (Configuration.dineScrapPool.Value == Configuration.DineScrap.Rollback)
				{
					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 },
						{ "FishTestProp", 5 },
						{ "BigBolt", 4 },
						{ "ToyCube", 33 },
						{ "PickleJar", 30 },
						{ "FlashLaserPointer", 5 },
						{ "FancyCup", 36 },
						{ "FancyPainting", 44 },
						{ "Mug", 48 },
						{ "Phone", 8 },
						{ "SodaCanRed", 50 },
						{ "Dentures", 44 },
						{ "7Ball", 24 },
						{ "RubberDuck", 25 },
						{ "DiyFlashbang", 20 },
						{ "ComedyMask", 47 },
						{ "WhoopieCushion", 12 },
						{ "EasterEgg", 44 },
						{ "GarbageLid", 22 },
						{ "ToiletPaperRolls", 28 },
						{ "Zeddog", 1 },
						{ "SeveredHand", 0 },
						{ "SeveredBone", 0 },
						{ "SeveredBoneRib", 0 },
						{ "SeveredEar", 0 },
						{ "SeveredFoot", 0 },
						{ "SeveredThigh", 0 },
						{ "SeveredHeart", 0 },
						{ "SeveredTongue", 0 }
					});
				}
				else
				{
					MoonOverrides.minScrap = 200;
					MoonOverrides.maxScrap = 250;
					Extensions.AddRange<string, int>(MoonOverrides.adjustedScrap, new Dictionary<string, int>
					{
						{ "SeveredHand", 100 },
						{ "SeveredBone", 79 },
						{ "SeveredBoneRib", 79 },
						{ "SeveredEar", 41 },
						{ "SeveredFoot", 100 },
						{ "SeveredThigh", 55 },
						{ "SeveredHeart", 6 },
						{ "SeveredTongue", 32 },
						{ "Cog1", 0 },
						{ "EnginePart1", 0 },
						{ "FishTestProp", 0 },
						{ "BigBolt", 0 },
						{ "FancyLamp", 0 },
						{ "ToyCube", 0 },
						{ "PickleJar", 0 },
						{ "FlashLaserPointer", 0 },
						{ "FancyCup", 0 },
						{ "FancyPainting", 0 },
						{ "Bell", 0 },
						{ "Ring", 0 },
						{ "RobotToy", 0 },
						{ "Toothpaste", 0 },
						{ "Brush", 0 },
						{ "PillBottle", 0 },
						{ "PerfumeBottle", 0 },
						{ "Mug", 0 },
						{ "BottleBin", 0 },
						{ "MagnifyingGlass", 0 },
						{ "Hairdryer", 0 },
						{ "Phone", 0 },
						{ "SodaCanRed", 0 },
						{ "Dentures", 0 },
						{ "7Ball", 0 },
						{ "RubberDuck", 0 },
						{ "TeaKettle", 0 },
						{ "Airhorn", 0 },
						{ "ClownHorn", 0 },
						{ "CashRegister", 0 },
						{ "Candy", 0 },
						{ "DiyFlashbang", 0 },
						{ "GiftBox", 0 },
						{ "TragedyMask", 0 },
						{ "ComedyMask", 0 },
						{ "WhoopieCushion", 1 },
						{ "EasterEgg", 1 },
						{ "GarbageLid", 0 },
						{ "ToiletPaperRolls", 0 },
						{ "Zeddog", 0 }
					});
				}
			}
			if (Configuration.dineReduceButlers.Value)
			{
				MoonOverrides.adjustedEnemies.Add("Butler", 12);
			}
			if (Configuration.dineAdjustOutdoor.Value)
			{
				Extensions.AddRange<string, int>(MoonOverrides.adjustedEnemies, new Dictionary<string, int>
				{
					{ "ForestGiant", 28 },
					{ "RadMech", 13 }
				});
				MoonOverrides.outsidePowerCount = 10;
			}
			MoonOverrides.Apply(level);
		}
	}
	internal class EmbrionOverrides
	{
		internal static readonly Dictionary<int, int> adjustedInteriors = new Dictionary<int, int>
		{
			{ 0, 13 },
			{ 1, 4 },
			{ 4, 118 }
		};

		internal static readonly Dictionary<string, int> infestations = new Dictionary<string, int>
		{
			{ "HoarderBug", 300 },
			{ "Nutcracker", 100 },
			{ "ClaySurgeon", 250 },
			{ "Crawler", 115 },
			{ "Centipede", 140 },
			{ "SpringMan", 150 }
		};

		internal static void Setup(SelectableLevel level)
		{
			if (Configuration.embrionMega.Value)
			{
				MoonOverrides.minScrap = 28;
				MoonOverrides.maxScrap = 45;
				Extensions.AddRange<string, int>(MoonOverrides.adjustedScrap, new Dictionary<string, int>
				{
					{ "YieldSign", 12 },
					{ "EasterEgg", 92 },
					{ "FlashLaserPointer", 10 },
					{ "RobotToy", 49 },
					{ "MagnifyingGlass", 37 },
					{ "Phone", 45 },
					{ "Airhorn", 39 },
					{ "DiyFlashbang", 13 }
				});
			}
			if (Configuration.embrionAdjustEnemies.Value)
			{
				Extensions.AddRange<string, int>(MoonOverrides.adjustedEnemies, new Dictionary<string, int>
				{
					{ "Nutcracker", 37 },
					{ "SpringMan", 42 },
					{ "ClaySurgeon", 61 },
					{ "HoarderBug", 57 }
				});
			}
			MoonOverrides.Apply(level);
		}
	}
	internal class ExperimentationOverrides
	{
		internal static readonly Dictionary<string, int> infestations = new Dictionary<string, int>
		{
			{ "HoarderBug", 300 },
			{ "Nutcracker", 100 },
			{ "Crawler", 14 },
			{ "Centipede", 300 },
			{ "Stingray", 50 }
		};

		internal static void Setup(SelectableLevel level)
		{
			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);
			}
			MoonOverrides.Apply(level);
		}
	}
	internal class MarchOverrides
	{
		internal static readonly Dictionary<string, int> infestations = new Dictionary<string, int>
		{
			{ "HoarderBug", 192 },
			{ "Nutcracker", 64 },
			{ "Crawler", 151 },
			{ "Centipede", 150 },
			{ "SpringMan", 28 },
			{ "Stingray", 300 }
		};

		internal static void Setup(SelectableLevel level)
		{
			if (Configuration.marchBuffScrap.Value)
			{
				MoonOverrides.minScrap = 14;
				MoonOverrides.maxScrap = 18;
				Extensions.AddRange<string, int>(MoonOverrides.adjustedScrap, new Dictionary<string, int>
				{
					{ "ToyCube", 24 },
					{ "MagnifyingGlass", 21 },
					{ "FishTestProp", 32 }
				});
				MoonOverrides.adjustedEnemies.Add("RedLocustBees", 72);
			}
			if (Configuration.marchAdjustEnemies.Value)
			{
				Extensions.AddRange<string, int>(MoonOverrides.adjustedEnemies, new Dictionary<string, int>
				{
					{ "ForestGiant", 81 },
					{ "MouthDog", 38 }
				});
			}
			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>();

		private static SpawnableOutsideObject snowman;

		private static SpawnableOutsideObject snowmanTall;

		private static AnimationCurve snowmanCurve;

		private static AnimationCurve snowmanTallCurve;

		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)
		{