Decompiled source of Furry Company v1.1.2

BepInEx/plugins/Diversity.dll

Decompiled 10 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Diversity.Items;
using Diversity.Misc;
using Diversity.Monsters;
using Diversity.Patches;
using Diversity.Player;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Audio;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Diversity")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Diversity")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("6163c54c-2d5b-4683-ac86-9337d16cc4fd")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
public enum Condition
{
	BrokenLeg,
	BrokenArm,
	FracturedLeg,
	FracturedArm,
	Bleeding,
	Blindness,
	Concussed
}
public enum DamageType
{
	GunShotted,
	Mauled,
	Electrified,
	Falling,
	Bitten,
	Concussed,
	Burned,
	Gas
}
namespace Diversity
{
	public class Configuration
	{
		public static ConfigEntry<bool> spiderRevamp;

		public static ConfigEntry<float> spiderSlowAmount;

		public static ConfigEntry<bool> crawlerRevamp;

		public static ConfigEntry<float> crawlerSlowAmount;

		public static ConfigEntry<bool> centipedeRevamp;

		public static ConfigEntry<int> clickAmount;

		public static ConfigEntry<int> hurtChance;

		public static ConfigEntry<bool> brakenRevamp;

		public static ConfigEntry<bool> brakenSpace;

		public static ConfigEntry<float> brakenRange;

		public static ConfigEntry<bool> brakenAnger;

		public static ConfigEntry<float> brakenAngerTime;

		public static ConfigEntry<int> flickerChance;

		public static ConfigEntry<int> breakerChance;

		public static ConfigEntry<bool> apparatusAnger;

		public static ConfigEntry<bool> chaseTriggerer;

		public static ConfigEntry<bool> dressGirlRevamp;

		public static ConfigEntry<float> walkieTalkieFrequency;

		public static ConfigEntry<bool> dressGirlIsolation;

		public static ConfigEntry<bool> playerConditions;

		public static ConfigEntry<bool> fullDarkness;

		public static ConfigEntry<float> fullDarknessIntensity;

		public static ConfigEntry<float> interactRange;

		public static ConfigEntry<bool> fracturedLeg;

		public static ConfigEntry<float> fracturedLegTime;

		public static ConfigEntry<bool> fracturedArm;

		public static ConfigEntry<float> fracturedArmTime;

		public static ConfigEntry<bool> brokenLeg;

		public static ConfigEntry<bool> brokenArm;

		public static ConfigEntry<bool> bleeding;

		public static ConfigEntry<float> bleedingTime;

		public static ConfigEntry<bool> blindness;

		public static ConfigEntry<float> blindnessTime;

		public static ConfigEntry<bool> concussed;

		public static void Load()
		{
			spiderRevamp = Diversity.config.Bind<bool>("Spider", "SpiderRevamp", true, "Should spider revamp be enabled?");
			spiderSlowAmount = Diversity.config.Bind<float>("Spider", "SpiderSlow", 0.8f, "How much slown should spiders be on hit?");
			crawlerRevamp = Diversity.config.Bind<bool>("Crawler", "CrawlerRevamp", true, "Should crawler revamp be enabled?");
			crawlerSlowAmount = Diversity.config.Bind<float>("Crawler", "CrawlerSlow", 0.9f, "How much slown should crawlers be on hit?");
			centipedeRevamp = Diversity.config.Bind<bool>("Centipede", "CentipedeRevamp", true, "Should centipede revamp be enabled?");
			clickAmount = Diversity.config.Bind<int>("Centipede", "ClickAmount", 30, "How many times should you have to click to remove the centipede from someone's head?");
			hurtChance = Diversity.config.Bind<int>("Centipede", "HurtChance", 10, "Chance of hurting the player when trying to free the centipede.");
			brakenRevamp = Diversity.config.Bind<bool>("Bracken", "BrakenRevamp", true, "Should Bracken revamp be enabled?");
			brakenSpace = Diversity.config.Bind<bool>("Bracken", "BrakenPersonnalSpace", true, "Should the Bracken have his own personnal space?");
			brakenRange = Diversity.config.Bind<float>("Bracken", "BrakenRange", 15f, "From how far should the Bracken be able to turn off lights?");
			brakenAnger = Diversity.config.Bind<bool>("Bracken", "BrakenAnger", true, "Should Bracken get angered from the breaker box?");
			brakenAngerTime = Diversity.config.Bind<float>("Bracken", "BrakenAngerTime", 90f, "How long should the Bracken stay angered when fully angered?");
			flickerChance = Diversity.config.Bind<int>("Bracken", "FlickerChance", 100, "Chance on flickering and turning off lights.");
			breakerChance = Diversity.config.Bind<int>("Bracken", "BreakerChance", 75, "Chance for the Bracken to turn off the breaker box.");
			apparatusAnger = Diversity.config.Bind<bool>("Bracken", "ApparatusAnger", true, "Should taking the Apparatus anger the Bracken?");
			chaseTriggerer = Diversity.config.Bind<bool>("Bracken", "ChaseTriggerer", true, "Should the Bracken chase the one who angered him?");
			dressGirlRevamp = Diversity.config.Bind<bool>("Dress Girl", "DressGirlRevamp", true, "Should Dress girl revamp be enabled?");
			walkieTalkieFrequency = Diversity.config.Bind<float>("Dress Girl", "WalkieTalkieFrequency", 1f, "How frequent should the Dress girl haunt the walkie-talkie?");
			dressGirlIsolation = Diversity.config.Bind<bool>("Dress Girl", "DressGirlIsolation", true, "Should Dress girl be able to isolate you and give you hallucinations? (Requires DressGirlRevamp to be enabled.)");
			playerConditions = Diversity.config.Bind<bool>("Player", "PlayerConditions", true, "Should players be able to gain conditions?");
			fullDarkness = Diversity.config.Bind<bool>("Player", "FullDarkness", true, "Should players with no light source be completely in the dark?");
			fullDarknessIntensity = Diversity.config.Bind<float>("Player", "FullDarknessIntensity", 1f, "How intense should full darkness be?");
			interactRange = Diversity.config.Bind<float>("Player", "InteractRange", 3f, "How far can players remove centipede from their head?");
			fracturedLeg = Diversity.config.Bind<bool>("Conditions", "Fractured Leg", true, "Can players fracture their legs? (Will also disable broken legs.)");
			fracturedLegTime = Diversity.config.Bind<float>("Conditions", "Fractured Leg Time", 60f, "How long should fractured legs last?");
			fracturedArm = Diversity.config.Bind<bool>("Conditions", "Fractured Arm", true, "Can players fracture their arms? (Will also disable broken arms.");
			fracturedArmTime = Diversity.config.Bind<float>("Conditions", "Fractured Arm Time", 60f, "How long should fractured arms last?");
			brokenLeg = Diversity.config.Bind<bool>("Conditions", "Broken Leg", true, "Can players break their legs?");
			brokenArm = Diversity.config.Bind<bool>("Conditions", "Broken Arm", true, "Can players break their arms?");
			bleeding = Diversity.config.Bind<bool>("Conditions", "Bleeding", true, "Can players bleed?");
			bleedingTime = Diversity.config.Bind<float>("Conditions", "Bleeding Time", 300f, "How long should bleeding last?");
			blindness = Diversity.config.Bind<bool>("Conditions", "Blindness", true, "Can players be blinded?");
			blindnessTime = Diversity.config.Bind<float>("Conditions", "Blindness Time", 30f, "How long should blindness last? (in seconds)");
			concussed = Diversity.config.Bind<bool>("Conditions", "Concussed", true, "Can players concussed?");
		}
	}
	public class Content
	{
		public static AssetBundle MainAssets;

		public static void TryLoadAssets()
		{
			if ((Object)(object)MainAssets == (Object)null)
			{
				MainAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "diversity"));
				Diversity.mls.LogInfo((object)"Loaded asset bundle!");
			}
		}
	}
	public class DiversityAssets : MonoBehaviour
	{
		[Serializable]
		public class RandomSoundAudioClip
		{
			public DiversitySoundManager.SoundType soundType;

			public AudioClip[] audioClips;
		}

		[Serializable]
		public class SoundAudioClip
		{
			public DiversitySoundManager.SoundType soundType;

			public AudioClip audioClip;
		}

		public SoundAudioClip[] soundAudioClipArray;

		public RandomSoundAudioClip[] randomSoundAudioClipArray;

		public static DiversityAssets Instance { get; private set; }

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
				Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			}
			else
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}
	public class DiversitySoundManager : MonoBehaviour
	{
		public enum SoundType
		{
			SteamLeak,
			LightOn,
			LightBuzz,
			Ambience,
			Fracture,
			BrokenBone,
			Hurt,
			BrackenScream,
			BrackenSpeech,
			DressGirlSpeech,
			DressGirlVoices,
			HeartBeat,
			DoorSlam,
			WalkerFootStep
		}

		public static GameObject oneShot;

		public static AudioSource oneShotAudio;

		public static GameObject oneShotBypass;

		public static AudioSource oneShotAudioBypass;

		public List<GameObject> current3Daudios = new List<GameObject>();

		public List<GameObject> currentGirlAudios = new List<GameObject>();

		public static DiversitySoundManager Instance { get; private set; }

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
				Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			}
			else
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		public static void PlaySound(SoundType soundType, bool random, float volume, float pan, bool loop, Vector3 position)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			AudioMixerGroup outputAudioMixerGroup = SoundManager.Instance.diageticMixer.FindMatchingGroups("SFX")[0];
			GameObject val = new GameObject("Sound");
			val.transform.position = position;
			AudioSource val2 = val.AddComponent<AudioSource>();
			val2.spatialBlend = 1f;
			val2.playOnAwake = false;
			val2.dopplerLevel = 0f;
			val2.spread = 70f;
			val2.reverbZoneMix = 1f;
			val2.outputAudioMixerGroup = outputAudioMixerGroup;
			val2.loop = loop;
			val2.panStereo = pan;
			if (random)
			{
				val2.clip = GetRandomAudioClipByType(soundType);
			}
			else
			{
				val2.clip = GetAudioClipByType(soundType);
			}
			val2.rolloffMode = (AudioRolloffMode)1;
			if (soundType == SoundType.LightOn)
			{
				val2.maxDistance = 100f;
			}
			else if (soundType == SoundType.SteamLeak || soundType == SoundType.LightBuzz)
			{
				val2.maxDistance = 32f;
			}
			else
			{
				val2.maxDistance = 32f;
			}
			val2.volume = volume;
			val2.Play();
			if (soundType == SoundType.DressGirlSpeech)
			{
				Instance.currentGirlAudios.Add(val);
			}
			else if (!loop)
			{
				Object.Destroy((Object)(object)val, val2.clip.length);
			}
			else
			{
				Instance.current3Daudios.Add(val);
			}
		}

		public static void PlaySound(SoundType soundType, bool random, float volume, float pan)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			AudioMixerGroup outputAudioMixerGroup = SoundManager.Instance.diageticMixer.FindMatchingGroups("SFX")[0];
			if ((Object)(object)oneShot == (Object)null)
			{
				oneShot = new GameObject("OneShotSound");
				oneShotAudio = oneShot.AddComponent<AudioSource>();
			}
			oneShotAudio.outputAudioMixerGroup = outputAudioMixerGroup;
			oneShotAudio.panStereo = pan;
			if (random)
			{
				oneShotAudio.PlayOneShot(GetRandomAudioClipByType(soundType), volume);
			}
			else
			{
				oneShotAudio.PlayOneShot(GetAudioClipByType(soundType), volume);
			}
		}

		public static void DeleteAudio(GameObject audio)
		{
			Object.Destroy((Object)(object)audio);
		}

		public static void PlaySoundBypass(SoundType soundType, bool random, float volume, float pan, bool loop, Vector3 position)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Sound");
			val.transform.position = position;
			AudioSource val2 = val.AddComponent<AudioSource>();
			val2.spatialBlend = 1f;
			val2.playOnAwake = false;
			val2.dopplerLevel = 0f;
			val2.spread = 70f;
			val2.reverbZoneMix = 1f;
			val2.bypassListenerEffects = true;
			val2.loop = loop;
			val2.panStereo = pan;
			if (random)
			{
				val2.clip = GetRandomAudioClipByType(soundType);
			}
			else
			{
				val2.clip = GetAudioClipByType(soundType);
			}
			val2.rolloffMode = (AudioRolloffMode)1;
			if (soundType == SoundType.LightOn)
			{
				val2.maxDistance = 100f;
			}
			else if (soundType == SoundType.SteamLeak || soundType == SoundType.LightBuzz)
			{
				val2.maxDistance = 32f;
			}
			else
			{
				val2.maxDistance = 32f;
			}
			val2.volume = volume;
			val2.Play();
			if (soundType == SoundType.DressGirlSpeech)
			{
				Instance.currentGirlAudios.Add(val);
			}
			else if (!loop)
			{
				Object.Destroy((Object)(object)val, val2.clip.length);
			}
			else
			{
				Instance.current3Daudios.Add(val);
			}
		}

		public static void PlaySoundBypass(SoundType soundType, bool random, float volume = 1f, float pan = 1f)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			if ((Object)(object)oneShotBypass == (Object)null)
			{
				oneShotBypass = new GameObject("OneShotSound");
				oneShotAudioBypass = oneShotBypass.AddComponent<AudioSource>();
				oneShotAudioBypass.bypassListenerEffects = true;
			}
			oneShotAudioBypass.panStereo = pan;
			if (random)
			{
				oneShotAudioBypass.PlayOneShot(GetRandomAudioClipByType(soundType), volume);
			}
			else
			{
				oneShotAudioBypass.PlayOneShot(GetAudioClipByType(soundType), volume);
			}
		}

		public static void StopSound()
		{
			if ((Object)(object)oneShot != (Object)null)
			{
				oneShotAudio.Stop();
			}
		}

		public static void StopSoundBypass()
		{
			if ((Object)(object)oneShot != (Object)null)
			{
				oneShotAudioBypass.Stop();
			}
		}

		public static Vector3 CheckPosition(PlayerControllerB player)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)player))
			{
				if (!player.isPlayerDead)
				{
					return ((Component)player.gameplayCamera).transform.position;
				}
				return player.spectateCameraPivot.position;
			}
			return Vector3.zero;
		}

		private static AudioClip GetAudioClipByType(SoundType soundType)
		{
			Diversity.mls.LogInfo((object)DiversityAssets.Instance.soundAudioClipArray);
			DiversityAssets.SoundAudioClip[] soundAudioClipArray = DiversityAssets.Instance.soundAudioClipArray;
			foreach (DiversityAssets.SoundAudioClip soundAudioClip in soundAudioClipArray)
			{
				if (soundAudioClip.soundType == soundType)
				{
					return soundAudioClip.audioClip;
				}
			}
			Diversity.mls.LogError((object)("No audio of type:" + soundType));
			return null;
		}

		private static AudioClip GetRandomAudioClipByType(SoundType soundType)
		{
			DiversityAssets.RandomSoundAudioClip[] randomSoundAudioClipArray = DiversityAssets.Instance.randomSoundAudioClipArray;
			foreach (DiversityAssets.RandomSoundAudioClip randomSoundAudioClip in randomSoundAudioClipArray)
			{
				if (randomSoundAudioClip.soundType == soundType)
				{
					return randomSoundAudioClip.audioClips[Random.Range(0, randomSoundAudioClip.audioClips.Length)];
				}
			}
			Diversity.mls.LogError((object)("No audio of type:" + soundType));
			return null;
		}
	}
	[BepInPlugin("Chaos.Diversity", "Diversity", "1.1.10")]
	public class Diversity : BaseUnityPlugin
	{
		private const string modGUID = "Chaos.Diversity";

		private const string modName = "Diversity";

		private const string modVersion = "1.1.10";

		private readonly Harmony harmony = new Harmony("Chaos.Diversity");

		public static Diversity Instance;

		public static ManualLogSource mls;

		public static ConfigFile config;

		public static EnemyType longBoiType;

		private void Awake()
		{
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Expected O, but got Unknown
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = ((BaseUnityPlugin)this).Logger;
			config = ((BaseUnityPlugin)this).Config;
			Configuration.Load();
			Content.TryLoadAssets();
			harmony.PatchAll(typeof(BaboonBirdAIPatch));
			harmony.PatchAll(typeof(BlobAIPatch));
			harmony.PatchAll(typeof(BreakerBoxPatch));
			harmony.PatchAll(typeof(CentipedeAIPatch));
			harmony.PatchAll(typeof(CrawlerAIPatch));
			harmony.PatchAll(typeof(DressGirlAIPatch));
			harmony.PatchAll(typeof(FlashlightPatch));
			harmony.PatchAll(typeof(FlowermanAIPatch));
			harmony.PatchAll(typeof(HoarderBugAIPatch));
			harmony.PatchAll(typeof(HUDPatch));
			harmony.PatchAll(typeof(LungPropPatch));
			harmony.PatchAll(typeof(ManualCameraRendererPatch));
			harmony.PatchAll(typeof(PlayerControllerBPatch));
			harmony.PatchAll(typeof(PufferAIPatch));
			harmony.PatchAll(typeof(RadarBoosterItemPatch));
			harmony.PatchAll(typeof(RedLocustBeesPatch));
			harmony.PatchAll(typeof(RoundManagerPatch));
			harmony.PatchAll(typeof(SandSpiderAIPatch));
			harmony.PatchAll(typeof(ShipTeleporterPatch));
			harmony.PatchAll(typeof(SoundManagerPatch));
			harmony.PatchAll(typeof(SpringManAIPatch));
			harmony.PatchAll(typeof(StartOfRoundPatch));
			harmony.PatchAll(typeof(SteamValveHazardPatch));
			harmony.PatchAll(typeof(Diversity));
			longBoiType = Content.MainAssets.LoadAsset<EnemyType>("Assets/custom/diversity/walker/WalkerType.asset");
			GameObject val = new GameObject("DiversitySoundManagerAssets");
			val.AddComponent<DiversitySoundManager>();
			DiversityAssets diversityAssets = val.AddComponent<DiversityAssets>();
			diversityAssets.soundAudioClipArray = new DiversityAssets.SoundAudioClip[4];
			diversityAssets.randomSoundAudioClipArray = new DiversityAssets.RandomSoundAudioClip[6];
			DiversityAssets.SoundAudioClip soundAudioClip = new DiversityAssets.SoundAudioClip();
			soundAudioClip.soundType = DiversitySoundManager.SoundType.SteamLeak;
			soundAudioClip.audioClip = Content.MainAssets.LoadAsset<AudioClip>("Assets/custom/diversity/bracken/rooms/audio/steam.ogg");
			DiversityAssets.SoundAudioClip soundAudioClip2 = new DiversityAssets.SoundAudioClip();
			soundAudioClip2.soundType = DiversitySoundManager.SoundType.LightOn;
			soundAudioClip2.audioClip = Content.MainAssets.LoadAsset<AudioClip>("Assets/custom/diversity/bracken/rooms/audio/lighton.ogg");
			DiversityAssets.SoundAudioClip soundAudioClip3 = new DiversityAssets.SoundAudioClip();
			soundAudioClip3.soundType = DiversitySoundManager.SoundType.LightBuzz;
			soundAudioClip3.audioClip = Content.MainAssets.LoadAsset<AudioClip>("Assets/custom/diversity/bracken/rooms/audio/lightbuzz.ogg");
			DiversityAssets.SoundAudioClip soundAudioClip4 = new DiversityAssets.SoundAudioClip();
			soundAudioClip4.soundType = DiversitySoundManager.SoundType.HeartBeat;
			soundAudioClip4.audioClip = Content.MainAssets.LoadAsset<AudioClip>("Assets/custom/diversity/player/audio/heartbeat.ogg");
			DiversityAssets.RandomSoundAudioClip randomSoundAudioClip = new DiversityAssets.RandomSoundAudioClip();
			AudioClip[] audioClips = (AudioClip[])(object)new AudioClip[1] { Content.MainAssets.LoadAsset<AudioClip>("Assets/custom/diversity/bracken/ambience.ogg") };
			randomSoundAudioClip.soundType = DiversitySoundManager.SoundType.Ambience;
			randomSoundAudioClip.audioClips = audioClips;
			DiversityAssets.RandomSoundAudioClip randomSoundAudioClip2 = new DiversityAssets.RandomSoundAudioClip();
			AudioClip[] audioClips2 = (AudioClip[])(object)new AudioClip[1] { Content.MainAssets.LoadAsset<AudioClip>("Assets/custom/diversity/bracken/brakenScream.mp3") };
			randomSoundAudioClip2.soundType = DiversitySoundManager.SoundType.BrackenScream;
			randomSoundAudioClip2.audioClips = audioClips2;
			DiversityAssets.RandomSoundAudioClip randomSoundAudioClip3 = new DiversityAssets.RandomSoundAudioClip();
			AudioClip[] audioClips3 = (AudioClip[])(object)new AudioClip[1] { Content.MainAssets.LoadAsset<AudioClip>("Assets/custom/diversity/bracken/you're next.mp3") };
			randomSoundAudioClip3.soundType = DiversitySoundManager.SoundType.BrackenSpeech;
			randomSoundAudioClip3.audioClips = audioClips3;
			DiversityAssets.RandomSoundAudioClip randomSoundAudioClip4 = new DiversityAssets.RandomSoundAudioClip();
			AudioClip[] audioClips4 = (AudioClip[])(object)new AudioClip[17]
			{
				Content.MainAssets.LoadAsset<AudioClip>("Assets/custom/diversity/girl/voice/voice_Insert 1.wav"),
				Content.MainAssets.LoadAsset<AudioClip>("Assets/custom/diversity/girl/voice/voice_Insert 2.wav"),
				Content.MainAssets.LoadAsset<AudioClip>("Assets/custom/diversity/girl/voice/voice_Insert 3.wav"),
				Content.MainAssets.LoadAsset<AudioClip>("Assets/custom/diversity/girl/voice/voice_Insert 4.wav"),
				Content.MainAssets.LoadAsset<AudioClip>("Assets/custom/diversity/girl/voice/voice_Insert 5.wav"),
				Content.MainAssets.LoadAsset<AudioClip>("Assets/custom/diversity/girl/voice/voice_Insert 6.wav"),
				Content.MainAssets.LoadAsset<AudioClip>("Assets/custom/diversity/girl/voice/voice_Insert 7.wav"),
				Content.MainAssets.LoadAsset<AudioClip>("Assets/custom/diversity/girl/voice/voice_Insert 8.wav"),
				Content.MainAssets.LoadAsset<AudioClip>("Assets/custom/diversity/girl/voice/voice_Insert 9.wav"),
				Content.MainAssets.LoadAsset<AudioClip>("Assets/custom/diversity/girl/voice/voice_Insert 10.wav"),
				Content.MainAssets.LoadAsset<AudioClip>("Assets/custom/diversity/girl/voice/voice_Insert 11.wav"),
				Content.MainAssets.LoadAsset<AudioClip>("Assets/custom/diversity/girl/voice/voice_Insert 12.wav"),
				Content.MainAssets.LoadAsset<AudioClip>("Assets/custom/diversity/girl/voice/voice_Insert 14.wav"),
				Content.MainAssets.LoadAsset<AudioClip>("Assets/custom/diversity/girl/voice/voice_Insert 15.wav"),
				Content.MainAssets.LoadAsset<AudioClip>("Assets/custom/diversity/girl/voice/voice_Insert 16.wav"),
				Content.MainAssets.LoadAsset<AudioClip>("Assets/custom/diversity/girl/voice/voice_Insert 17.wav"),
				Content.MainAssets.LoadAsset<AudioClip>("Assets/custom/diversity/girl/voice/voice_Insert 18.wav")
			};
			randomSoundAudioClip4.soundType = DiversitySoundManager.SoundType.DressGirlSpeech;
			randomSoundAudioClip4.audioClips = audioClips4;
			DiversityAssets.RandomSoundAudioClip randomSoundAudioClip5 = new DiversityAssets.RandomSoundAudioClip();
			AudioClip[] audioClips5 = (AudioClip[])(object)new AudioClip[4]
			{
				Content.MainAssets.LoadAsset<AudioClip>("Assets/custom/diversity/walker/audios/footsteps/step1.ogg"),
				Content.MainAssets.LoadAsset<AudioClip>("Assets/custom/diversity/walker/audios/footsteps/step2.ogg"),
				Content.MainAssets.LoadAsset<AudioClip>("Assets/custom/diversity/walker/audios/footsteps/step3.ogg"),
				Content.MainAssets.LoadAsset<AudioClip>("Assets/custom/diversity/walker/audios/footsteps/step4.ogg")
			};
			randomSoundAudioClip5.soundType = DiversitySoundManager.SoundType.WalkerFootStep;
			randomSoundAudioClip5.audioClips = audioClips5;
			DiversityAssets.RandomSoundAudioClip randomSoundAudioClip6 = new DiversityAssets.RandomSoundAudioClip();
			AudioClip[] audioClips6 = (AudioClip[])(object)new AudioClip[2]
			{
				Content.MainAssets.LoadAsset<AudioClip>("Assets/custom/diversity/walker/audios/DoorBash/DoorSlam1.ogg"),
				Content.MainAssets.LoadAsset<AudioClip>("Assets/custom/diversity/walker/audios/DoorBash/DoorSlam2.ogg")
			};
			randomSoundAudioClip6.soundType = DiversitySoundManager.SoundType.DoorSlam;
			randomSoundAudioClip6.audioClips = audioClips6;
			diversityAssets.soundAudioClipArray[0] = soundAudioClip;
			diversityAssets.soundAudioClipArray[1] = soundAudioClip2;
			diversityAssets.soundAudioClipArray[2] = soundAudioClip3;
			diversityAssets.soundAudioClipArray[3] = soundAudioClip4;
			diversityAssets.randomSoundAudioClipArray[0] = randomSoundAudioClip;
			diversityAssets.randomSoundAudioClipArray[1] = randomSoundAudioClip2;
			diversityAssets.randomSoundAudioClipArray[2] = randomSoundAudioClip3;
			diversityAssets.randomSoundAudioClipArray[3] = randomSoundAudioClip4;
			diversityAssets.randomSoundAudioClipArray[4] = randomSoundAudioClip6;
			diversityAssets.randomSoundAudioClipArray[5] = randomSoundAudioClip5;
			((Object)val).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)val);
			mls.LogInfo((object)"Diversity started.");
		}
	}
	public class DiversityBehaviour : MonoBehaviour
	{
		public int anger = 3;

		private void Update()
		{
		}
	}
}
namespace Diversity.Player
{
	public class PlayerRevamp : MonoBehaviour
	{
		public List<Condition> conditions = new List<Condition>();

		public bool isHaunted = false;

		public bool dressGirlHaunt = false;

		public Light lastLight;

		public int lastID = 0;

		public bool kidnapped = false;

		public float filter = 0f;

		public float dressGirlHauntTime = 0f;

		public float heartBeatInterval = 1f;

		public float voicesTime = 0f;

		public float voicesInterval = 1f;

		public float heartBeatTime = 0f;

		public float heartBeatCooldown = 0f;

		private static float timeElapsed;

		private bool fullDarknessSet = false;

		private bool playersHidden = false;

		public List<Vector3> nearbySounds = new List<Vector3>();

		private float timeFracturedLeg = 0f;

		private float timeFracturedArm = 0f;

		private float timeBleeding = 0f;

		private float timeBlinded = 0f;

		private float soundCheckInterval = 0f;

		private bool instanciated = false;

		public bool updated = false;

		private bool unfinished = false;

		public bool sinkingFromWalker = false;

		private bool currentlySinking = false;

		private float sinkingTime = 0f;

		public bool forceLook = false;

		public Vector3 forceLookPosition = Vector3.zero;

		public void ApplyConditions(DamageType damageType, float modifier)
		{
			Diversity.mls.LogInfo((object)("Player took damage type: " + damageType));
			if (damageType == DamageType.Falling && Configuration.fracturedLeg.Value)
			{
				float value = Random.value;
				if (value <= 0.1f * modifier)
				{
					bool flag = false;
					foreach (Condition condition in conditions)
					{
						if (condition == Condition.FracturedLeg)
						{
							flag = true;
						}
					}
					if (!flag)
					{
						conditions.Add(Condition.FracturedLeg);
						Diversity.mls.LogInfo((object)("Player just received condition:" + Condition.FracturedLeg));
					}
					else if (Configuration.brokenLeg.Value)
					{
						bool flag2 = false;
						foreach (Condition condition2 in conditions)
						{
							if (condition2 == Condition.BrokenLeg)
							{
								flag2 = true;
							}
						}
						if (!flag2)
						{
							conditions.Remove(Condition.FracturedLeg);
							Diversity.mls.LogInfo((object)("Player just lost condition:" + Condition.FracturedLeg));
							conditions.Add(Condition.BrokenLeg);
							Diversity.mls.LogInfo((object)("Player just received condition:" + Condition.BrokenLeg));
						}
					}
				}
			}
			else if ((damageType == DamageType.GunShotted || damageType == DamageType.Mauled || damageType == DamageType.Bitten) && Configuration.bleeding.Value)
			{
				float value2 = Random.value;
				if (value2 <= 0.15f * modifier || damageType == DamageType.GunShotted)
				{
					bool flag3 = false;
					foreach (Condition condition3 in conditions)
					{
						if (condition3 == Condition.Bleeding)
						{
							flag3 = true;
						}
					}
					if (!flag3)
					{
						conditions.Add(Condition.Bleeding);
						Diversity.mls.LogInfo((object)("Player just received condition:" + Condition.Bleeding));
					}
				}
			}
			if (damageType == DamageType.Mauled && Configuration.fracturedArm.Value)
			{
				float value3 = Random.value;
				if (value3 <= 0.15f * modifier)
				{
					bool flag4 = false;
					foreach (Condition condition4 in conditions)
					{
						if (condition4 == Condition.FracturedArm)
						{
							flag4 = true;
						}
					}
					if (!flag4)
					{
						conditions.Add(Condition.FracturedArm);
						Diversity.mls.LogInfo((object)("Player just received condition:" + Condition.FracturedArm));
					}
					if (flag4 && value3 <= 0.05f && Configuration.brokenArm.Value)
					{
						bool flag5 = false;
						foreach (Condition condition5 in conditions)
						{
							if (condition5 == Condition.BrokenArm)
							{
								flag5 = true;
							}
						}
						if (!flag5)
						{
							conditions.Remove(Condition.FracturedArm);
							Diversity.mls.LogInfo((object)("Player just lost condition:" + Condition.FracturedArm));
							conditions.Add(Condition.BrokenArm);
							Diversity.mls.LogInfo((object)("Player just received condition:" + Condition.BrokenArm));
						}
					}
				}
			}
			if (damageType == DamageType.Gas && Configuration.blindness.Value)
			{
				float value4 = Random.value;
				if (value4 <= 0.15f * modifier)
				{
					bool flag6 = false;
					foreach (Condition condition6 in conditions)
					{
						if (condition6 == Condition.Blindness)
						{
							flag6 = true;
						}
					}
					if (!flag6)
					{
						conditions.Add(Condition.Blindness);
						Diversity.mls.LogInfo((object)("Player just received condition:" + Condition.Blindness));
					}
				}
			}
			if (damageType != DamageType.Concussed || !Configuration.concussed.Value)
			{
				return;
			}
			float value5 = Random.value;
			if (!(value5 <= 0.35f * modifier))
			{
				return;
			}
			bool flag7 = false;
			foreach (Condition condition7 in conditions)
			{
				if (condition7 == Condition.Concussed)
				{
					flag7 = true;
				}
			}
			if (!flag7)
			{
				conditions.Add(Condition.Concussed);
				Diversity.mls.LogInfo((object)("Player just received condition:" + Condition.Concussed));
			}
		}

		public void CheckConditions(PlayerControllerB player)
		{
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			if (!Configuration.playerConditions.Value || !player.AllowPlayerDeath())
			{
				return;
			}
			using List<Condition>.Enumerator enumerator = conditions.ToList().GetEnumerator();
			while (enumerator.MoveNext())
			{
				switch (enumerator.Current)
				{
				case Condition.FracturedLeg:
					if (((NetworkBehaviour)player).IsOwner)
					{
						timeFracturedLeg += Time.deltaTime;
						if (timeFracturedLeg >= Configuration.fracturedLegTime.Value)
						{
							timeFracturedLeg = 0f;
							player.jumpForce = 13f;
							conditions.Remove(Condition.FracturedLeg);
						}
						else
						{
							player.jumpForce = 10f;
						}
					}
					break;
				case Condition.BrokenLeg:
					if (((NetworkBehaviour)player).IsOwner)
					{
						player.playerBodyAnimator.SetBool("Limp", true);
						player.jumpForce = 9f;
					}
					break;
				case Condition.FracturedArm:
					if ((Object)(object)player.currentlyHeldObject != (Object)null)
					{
						timeFracturedArm += Time.deltaTime;
						if (timeFracturedArm >= Configuration.fracturedArmTime.Value)
						{
							conditions.Remove(Condition.FracturedArm);
							timeFracturedArm = 0f;
						}
						GrabbableObject currentlyHeldObject2 = player.currentlyHeldObject;
						if (((NetworkBehaviour)player).IsOwner)
						{
							Item itemProperties3 = currentlyHeldObject2.itemProperties;
							if (itemProperties3.weight > 25f)
							{
								player.DiscardHeldObject(false, (NetworkObject)null, default(Vector3), true);
							}
						}
					}
					else
					{
						if (!((Object)(object)player.currentlyHeldObjectServer != (Object)null))
						{
							break;
						}
						GrabbableObject currentlyHeldObjectServer2 = player.currentlyHeldObjectServer;
						if (((NetworkBehaviour)player).IsOwner)
						{
							Item itemProperties4 = currentlyHeldObjectServer2.itemProperties;
							if (itemProperties4.weight > 25f)
							{
								player.DiscardHeldObject(false, (NetworkObject)null, default(Vector3), true);
							}
						}
					}
					break;
				case Condition.BrokenArm:
					if ((Object)(object)player.currentlyHeldObject != (Object)null)
					{
						GrabbableObject currentlyHeldObject = player.currentlyHeldObject;
						if (((NetworkBehaviour)player).IsOwner)
						{
							Item itemProperties = currentlyHeldObject.itemProperties;
							if (itemProperties.weight > 15f)
							{
								player.DiscardHeldObject(false, (NetworkObject)null, default(Vector3), true);
							}
						}
					}
					else
					{
						if (!((Object)(object)player.currentlyHeldObjectServer != (Object)null))
						{
							break;
						}
						GrabbableObject currentlyHeldObjectServer = player.currentlyHeldObjectServer;
						if (((NetworkBehaviour)player).IsOwner)
						{
							Item itemProperties2 = currentlyHeldObjectServer.itemProperties;
							if (itemProperties2.weight > 15f)
							{
								player.DiscardHeldObject(false, (NetworkObject)null, default(Vector3), true);
							}
						}
					}
					break;
				case Condition.Bleeding:
					if (((NetworkBehaviour)player).IsOwner)
					{
						timeBleeding += Time.deltaTime;
						if (timeBleeding >= Configuration.bleedingTime.Value)
						{
							timeBleeding = 0f;
							player.bleedingHeavily = false;
							conditions.Remove(Condition.Bleeding);
						}
						else
						{
							player.healthRegenerateTimer = 1f;
							player.bleedingHeavily = true;
						}
					}
					break;
				case Condition.Blindness:
				{
					if (!((NetworkBehaviour)player).IsOwner)
					{
						break;
					}
					PlayerControllerB localPlayerController2 = StartOfRound.Instance.localPlayerController;
					if (Object.op_Implicit((Object)(object)localPlayerController2) && (localPlayerController2.playerSteamId == player.playerSteamId || localPlayerController2.actualClientId == player.actualClientId))
					{
						HUDManagerRevamp component2 = ((Component)HUDManager.Instance).gameObject.GetComponent<HUDManagerRevamp>();
						if (!Object.op_Implicit((Object)(object)component2))
						{
							return;
						}
						timeBlinded += Time.deltaTime;
						Diversity.mls.LogInfo((object)(timeBlinded + " >= " + Configuration.blindnessTime.Value));
						if (timeBlinded >= Configuration.blindnessTime.Value)
						{
							timeBlinded = 0f;
							component2.blindnessIntensity = 0f;
							conditions.Remove(Condition.Blindness);
						}
						else
						{
							component2.blindnessIntensity = 1f;
						}
					}
					break;
				}
				case Condition.Concussed:
				{
					if (!((NetworkBehaviour)player).IsOwner)
					{
						break;
					}
					PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
					if (Object.op_Implicit((Object)(object)localPlayerController) && (localPlayerController.playerSteamId == player.playerSteamId || localPlayerController.actualClientId == player.actualClientId))
					{
						HUDManagerRevamp component = ((Component)HUDManager.Instance).gameObject.GetComponent<HUDManagerRevamp>();
						if (!Object.op_Implicit((Object)(object)component))
						{
							return;
						}
						component.concussedIntensity = 1f;
					}
					break;
				}
				}
			}
		}

		private void OnTriggerEnter(Collider col)
		{
			if (((Object)((Component)col).gameObject).name == "RoomCollider" && !updated)
			{
				BrakenRevamp[] array = Object.FindObjectsOfType<BrakenRevamp>();
				BrakenRevamp[] array2 = array;
				foreach (BrakenRevamp brakenRevamp in array2)
				{
					brakenRevamp.kidnapped = true;
				}
				kidnapped = true;
				updated = true;
			}
		}

		private void Update()
		{
			//IL_0585: Unknown result type (might be due to invalid IL or missing references)
			//IL_0595: Unknown result type (might be due to invalid IL or missing references)
			//IL_059a: Unknown result type (might be due to invalid IL or missing references)
			//IL_059f: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05be: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0707: Unknown result type (might be due to invalid IL or missing references)
			//IL_07fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0803: Unknown result type (might be due to invalid IL or missing references)
			//IL_0806: Unknown result type (might be due to invalid IL or missing references)
			//IL_080f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0720: Unknown result type (might be due to invalid IL or missing references)
			//IL_072f: Unknown result type (might be due to invalid IL or missing references)
			//IL_094a: Unknown result type (might be due to invalid IL or missing references)
			//IL_075f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0777: Unknown result type (might be due to invalid IL or missing references)
			//IL_0963: Unknown result type (might be due to invalid IL or missing references)
			//IL_0972: Unknown result type (might be due to invalid IL or missing references)
			//IL_0863: Unknown result type (might be due to invalid IL or missing references)
			//IL_087c: Unknown result type (might be due to invalid IL or missing references)
			//IL_088b: Unknown result type (might be due to invalid IL or missing references)
			//IL_08bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d3: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB component = ((Component)this).gameObject.GetComponent<PlayerControllerB>();
			PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
			HUDManagerRevamp component2 = ((Component)HUDManager.Instance).gameObject.GetComponent<HUDManagerRevamp>();
			if (!Object.op_Implicit((Object)(object)component2) || !Object.op_Implicit((Object)(object)component))
			{
				return;
			}
			if (component.isPlayerDead)
			{
				dressGirlHaunt = false;
			}
			if (Configuration.fullDarkness.Value && (Object)(object)component == (Object)(object)localPlayerController && !fullDarknessSet)
			{
				Diversity.mls.LogInfo((object)("Setting full darkness to local player: " + component.playerUsername));
				component.nightVision.intensity = 366.9317f * (1f - Configuration.fullDarknessIntensity.Value);
				fullDarknessSet = true;
			}
			if (Configuration.dressGirlRevamp.Value && Configuration.dressGirlIsolation.Value)
			{
				if (dressGirlHaunt && component.actualClientId == localPlayerController.actualClientId && !component.isPlayerDead)
				{
					heartBeatTime += Time.deltaTime;
					heartBeatCooldown += Time.deltaTime;
					dressGirlHauntTime += Time.deltaTime;
					voicesTime += Time.deltaTime;
					component2.black.weight = Mathf.Lerp(0f, 1f, dressGirlHauntTime / 19f);
					filter = Mathf.Lerp(0f, 1f, dressGirlHauntTime / 19f);
					if (!playersHidden)
					{
						PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
						foreach (PlayerControllerB val in allPlayerScripts)
						{
							if ((Object)(object)val != (Object)null && val.actualClientId != StartOfRound.Instance.localPlayerController.actualClientId)
							{
								((Component)val).gameObject.SetActive(false);
							}
						}
					}
					heartBeatInterval = Mathf.Lerp(1.5f, 0.5f, dressGirlHauntTime / 19f);
					voicesInterval = Mathf.Lerp(3f, 0.75f, dressGirlHauntTime / 19f);
					if (heartBeatTime >= heartBeatInterval)
					{
						DiversitySoundManager.PlaySoundBypass(DiversitySoundManager.SoundType.HeartBeat, random: false, 1f, 0f);
						heartBeatTime = 0f;
					}
					if (voicesTime >= voicesInterval)
					{
						DiversitySoundManager.PlaySoundBypass(DiversitySoundManager.SoundType.DressGirlSpeech, random: true, Mathf.Lerp(0.6f, 0f, dressGirlHauntTime / 15f), 0f, loop: false, RoundManager.Instance.GetRandomPositionInRadius(((Component)component).transform.position, 6f, 11f, (Random)null));
						voicesTime = 0f;
					}
					playersHidden = true;
				}
				else if ((Object)(object)component == (Object)(object)localPlayerController && !dressGirlHaunt)
				{
					dressGirlHauntTime = 0f;
					component2.black.weight = 0f;
					component2.hauntedIntensity = 0f;
					filter = 0f;
					heartBeatTime = 0f;
					heartBeatCooldown = 0f;
					heartBeatInterval = 1f;
					voicesInterval = 1f;
					voicesTime = 0f;
					if (playersHidden)
					{
						PlayerControllerB[] allPlayerScripts2 = StartOfRound.Instance.allPlayerScripts;
						foreach (PlayerControllerB val2 in allPlayerScripts2)
						{
							if ((Object)(object)val2 != (Object)null && val2.actualClientId != StartOfRound.Instance.localPlayerController.actualClientId)
							{
								((Component)val2).gameObject.SetActive(true);
							}
						}
					}
					playersHidden = false;
				}
			}
			if (sinkingFromWalker)
			{
				sinkingTime += Time.deltaTime;
				if (sinkingTime > 8f)
				{
					sinkingTime = 8f;
				}
				component2.black.weight = Mathf.Lerp(0f, 1f, sinkingTime / 8f);
				filter = Mathf.Lerp(0f, 1f, sinkingTime / 8f);
			}
			else if (!dressGirlHaunt)
			{
				sinkingTime -= Time.deltaTime;
				if (sinkingTime > 5f)
				{
					sinkingTime = 5f;
				}
				else if (sinkingTime < 0f)
				{
					sinkingTime = 0f;
				}
				component2.black.weight = Mathf.Lerp(0f, 1f, sinkingTime / 5f);
				filter = Mathf.Lerp(0f, 1f, sinkingTime / 5f);
			}
			if (!component.isPlayerControlled)
			{
				return;
			}
			if (forceLook)
			{
				Vector3 val3 = forceLookPosition - ((Component)component.gameplayCamera).transform.position;
				Vector3 val4 = ((Component)component.gameplayCamera).transform.InverseTransformDirection(val3);
				Vector2 val5 = default(Vector2);
				((Vector2)(ref val5))..ctor(val4.x, val4.y);
				component.CalculateNormalLookingInput(val5);
			}
			soundCheckInterval += Time.deltaTime;
			if (soundCheckInterval >= 0.5f)
			{
				if (!Object.op_Implicit((Object)(object)StartOfRoundRevamp.Instance) || !Object.op_Implicit((Object)(object)StartOfRound.Instance) || !Object.op_Implicit((Object)(object)StartOfRound.Instance.localPlayerController))
				{
					return;
				}
				foreach (GameObject item in StartOfRoundRevamp.Instance.steamSounds.ToList())
				{
					if (!Object.op_Implicit((Object)(object)item))
					{
						return;
					}
					bool flag = false;
					foreach (Vector3 item2 in nearbySounds.ToList())
					{
						if (item2 == item.transform.position)
						{
							flag = true;
						}
					}
					if (!flag && !instanciated)
					{
						DiversitySoundManager.CheckPosition(StartOfRound.Instance.localPlayerController);
						if (false)
						{
							return;
						}
						float num = Vector3.Distance(item.transform.position, DiversitySoundManager.CheckPosition(StartOfRound.Instance.localPlayerController));
						if (num < 32f)
						{
							DiversitySoundManager.PlaySound(DiversitySoundManager.SoundType.SteamLeak, random: false, 0.1f, 0f, loop: true, item.transform.position);
							nearbySounds.Add(item.transform.position);
							instanciated = true;
						}
					}
				}
				foreach (GameObject item3 in StartOfRoundRevamp.Instance.lightBuzz.ToList())
				{
					if (!Object.op_Implicit((Object)(object)item3))
					{
						return;
					}
					bool flag2 = false;
					foreach (Vector3 item4 in nearbySounds.ToList())
					{
						if (item4 == item3.transform.position)
						{
							flag2 = true;
						}
					}
					if (!flag2 && !instanciated)
					{
						DiversitySoundManager.CheckPosition(StartOfRound.Instance.localPlayerController);
						if (false)
						{
							return;
						}
						float num2 = Vector3.Distance(item3.transform.position, DiversitySoundManager.CheckPosition(StartOfRound.Instance.localPlayerController));
						if (num2 < 32f)
						{
							DiversitySoundManager.PlaySound(DiversitySoundManager.SoundType.LightBuzz, random: false, 0.4f, 0f, loop: true, item3.transform.position);
							nearbySounds.Add(item3.transform.position);
							instanciated = true;
						}
					}
				}
				foreach (GameObject item5 in DiversitySoundManager.Instance.current3Daudios.ToList())
				{
					if (!Object.op_Implicit((Object)(object)item5))
					{
						return;
					}
					DiversitySoundManager.CheckPosition(StartOfRound.Instance.localPlayerController);
					if (false)
					{
						return;
					}
					float num3 = Vector3.Distance(item5.transform.position, DiversitySoundManager.CheckPosition(StartOfRound.Instance.localPlayerController));
					if (num3 > 36f)
					{
						Object.Destroy((Object)(object)item5);
						DiversitySoundManager.Instance.current3Daudios.Remove(item5);
					}
				}
				soundCheckInterval = 0f;
				instanciated = false;
			}
			if (Object.op_Implicit((Object)(object)lastLight))
			{
				if (!isHaunted)
				{
					if (!unfinished)
					{
						if (timeElapsed != 1f)
						{
							timeElapsed = 1f - timeElapsed;
						}
						else
						{
							timeElapsed = 0f;
						}
						unfinished = true;
					}
					if (lastID == 0)
					{
						lastLight.intensity = Mathf.Lerp(100f, 486.8536f, timeElapsed / 1f);
					}
					else if (lastID == 1)
					{
						lastLight.intensity = Mathf.Lerp(50f, 397.9603f, timeElapsed / 1f);
					}
					timeElapsed += Time.deltaTime;
				}
				if (isHaunted)
				{
					if (unfinished)
					{
						if (timeElapsed != 1f)
						{
							timeElapsed = 1f - timeElapsed;
						}
						else
						{
							timeElapsed = 0f;
						}
						unfinished = false;
					}
					if (lastID == 0)
					{
						lastLight.intensity = Mathf.Lerp(486.8536f, 100f, timeElapsed / 1f);
					}
					else if (lastID == 1)
					{
						lastLight.intensity = Mathf.Lerp(397.9603f, 50f, timeElapsed / 1f);
					}
					timeElapsed += Time.deltaTime;
				}
				if (timeElapsed >= 1f)
				{
					timeElapsed = 1f;
				}
			}
			GrabbableObject[] itemSlots = component.ItemSlots;
			foreach (GrabbableObject val6 in itemSlots)
			{
				if ((Object)(object)val6 != (Object)null)
				{
					FlashlightRevamp component3 = ((Component)val6).gameObject.GetComponent<FlashlightRevamp>();
					if (Object.op_Implicit((Object)(object)component3))
					{
						component3.haunted = isHaunted;
					}
				}
			}
			if (sinkingFromWalker)
			{
				component.sourcesCausingSinking = 1;
				component.sinkingSpeedMultiplier = 0.1f;
			}
			else
			{
				component.sourcesCausingSinking = 0;
				component.sinkingSpeedMultiplier = 0f;
			}
			if (dressGirlHaunt)
			{
				if (component.actualClientId == localPlayerController.actualClientId || component.playerSteamId == localPlayerController.playerSteamId)
				{
					component2.hauntedIntensity = 1f;
				}
			}
			else if (component.actualClientId == localPlayerController.actualClientId || component.playerSteamId == localPlayerController.playerSteamId)
			{
				component2.hauntedIntensity = 0f;
			}
		}
	}
}
namespace Diversity.Patches
{
	[HarmonyPatch(typeof(BaboonBirdAI))]
	internal class BaboonBirdAIPatch
	{
		[HarmonyPatch(typeof(BaboonBirdAI), "OnCollideWithPlayer")]
		[HarmonyPrefix]
		private static void OnCollideWithPlayer(BaboonBirdAI __instance, Collider other)
		{
			if (__instance.timeSinceHitting < 0.5f)
			{
				return;
			}
			PlayerControllerB val = ((EnemyAI)__instance).MeetsStandardPlayerCollisionConditions(other, ((EnemyAI)__instance).inSpecialAnimation || __instance.doingKillAnimation, false);
			if ((Object)(object)val != (Object)null)
			{
				PlayerRevamp component = ((Component)val).gameObject.GetComponent<PlayerRevamp>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.ApplyConditions(DamageType.Bitten, 1f + (1f - (float)(val.health / 100)));
				}
			}
		}
	}
	[HarmonyPatch(typeof(BlobAI))]
	internal class BlobAIPatch
	{
		[HarmonyPatch(typeof(BlobAI), "OnCollideWithPlayer")]
		[HarmonyPrefix]
		private static void OnCollideWithPlayer(BlobAI __instance, Collider other)
		{
			if (__instance.timeSinceHittingLocalPlayer < 0.25f || (__instance.tamedTimer > 0f && __instance.angeredTimer < 0f))
			{
				return;
			}
			PlayerControllerB val = ((EnemyAI)__instance).MeetsStandardPlayerCollisionConditions(other, false, false);
			if ((Object)(object)val != (Object)null)
			{
				PlayerRevamp component = ((Component)val).gameObject.GetComponent<PlayerRevamp>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.ApplyConditions(DamageType.Burned, 1f + (1f - (float)(val.health / 100)));
				}
			}
		}
	}
	[HarmonyPatch(typeof(BreakerBox))]
	internal class BreakerBoxPatch : MonoBehaviour
	{
		[HarmonyPatch(typeof(BreakerBox), "Start")]
		[HarmonyPostfix]
		public static void Start(BreakerBox __instance)
		{
			BreakerBoxRevamp component = ((Component)__instance).gameObject.GetComponent<BreakerBoxRevamp>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				((Component)__instance).gameObject.AddComponent<BreakerBoxRevamp>();
				Diversity.mls.LogInfo((object)"Added DiversityBehaviour to the RoundManager.");
			}
		}

		[HarmonyPatch(typeof(BreakerBox), "SwitchBreaker")]
		[HarmonyPostfix]
		public static void SwitchBreaker(BreakerBox __instance)
		{
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			int num = 3;
			BreakerBoxRevamp component = ((Component)__instance).gameObject.GetComponent<BreakerBoxRevamp>();
			if (Object.op_Implicit((Object)(object)component))
			{
				num = component.anger;
			}
			Diversity.mls.LogInfo((object)("angerMax: " + num));
			if (!Configuration.brakenAnger.Value || !__instance.isPowerOn)
			{
				return;
			}
			FlowermanAI[] array = (FlowermanAI[])(object)Object.FindObjectsOfType(typeof(FlowermanAI));
			if (!Configuration.brakenRevamp.Value)
			{
				return;
			}
			FlowermanAI[] array2 = array;
			foreach (FlowermanAI val in array2)
			{
				BrakenRevamp component2 = ((Component)val).gameObject.GetComponent<BrakenRevamp>();
				if (!Object.op_Implicit((Object)(object)component2))
				{
					break;
				}
				if (component2.angerLevel < num)
				{
					component2.angerLevel++;
				}
				PlayerControllerB[] allPlayerScripts = __instance.roundManager.playersManager.allPlayerScripts;
				float num2 = 100f;
				PlayerControllerB val2 = null;
				PlayerControllerB[] array3 = allPlayerScripts;
				foreach (PlayerControllerB val3 in array3)
				{
					if ((Object)(object)val3 != (Object)null && Vector3.Distance(((Component)__instance).gameObject.transform.position, ((Component)val3).gameObject.transform.position) < num2)
					{
						num2 = Vector3.Distance(((Component)__instance).gameObject.transform.position, ((Component)val3).gameObject.transform.position);
						val2 = val3;
					}
				}
				if ((Object)(object)val2 != (Object)null)
				{
					Diversity.mls.LogInfo((object)("Closest player from breaker box is: " + ((Object)((Component)val2).gameObject).name));
				}
				component2.CheckAnger(component, __instance.roundManager, val2);
			}
		}
	}
	[HarmonyPatch(typeof(CentipedeAI))]
	internal class CentipedeAIPatch
	{
		[HarmonyPatch(typeof(CentipedeAI), "Start")]
		[HarmonyPrefix]
		public static void Start(CentipedeAI __instance)
		{
			if (Configuration.centipedeRevamp.Value)
			{
				CentipedeRevamp component = ((Component)__instance).gameObject.GetComponent<CentipedeRevamp>();
				if (!Object.op_Implicit((Object)(object)component))
				{
					((Component)__instance).gameObject.AddComponent<CentipedeRevamp>();
					Diversity.mls.LogInfo((object)("Added CentipedeRevamp to: " + ((Object)((Component)__instance).gameObject).name));
				}
			}
		}

		[HarmonyPatch(typeof(CentipedeAI), "DamagePlayerOnIntervals")]
		[HarmonyPrefix]
		private static void DamagePlayerOnIntervals(CentipedeAI __instance)
		{
			if (__instance.damagePlayerInterval <= 0f && !__instance.inDroppingOffPlayerAnim && !(((EnemyAI)__instance).stunNormalizedTimer > 0f) && (StartOfRound.Instance.connectedPlayersAmount > 0 || __instance.clingingToPlayer.health > 15 || __instance.singlePlayerSecondChanceGiven) && (Object)(object)__instance.clingingToPlayer != (Object)null)
			{
				PlayerRevamp component = ((Component)__instance.clingingToPlayer).gameObject.GetComponent<PlayerRevamp>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.ApplyConditions(DamageType.Mauled, 1f + (1f - (float)(__instance.clingingToPlayer.health / 100)));
				}
			}
		}
	}
	[HarmonyPatch(typeof(CrawlerAI))]
	internal class CrawlerAIPatch
	{
		private static CrawlerRevamp crawler;

		[HarmonyPatch(typeof(CrawlerAI), "HitEnemy")]
		[HarmonyPrefix]
		public static void Slow(CrawlerAI __instance)
		{
			if (Configuration.crawlerRevamp.Value)
			{
				crawler = ((Component)__instance).GetComponent<CrawlerRevamp>();
				if (Object.op_Implicit((Object)(object)crawler) && !crawler.onCooldown)
				{
					crawler.hasBeenhit = true;
					crawler.onCooldown = true;
					crawler.previousAgentSpeed = ((EnemyAI)__instance).agent.speed;
					crawler.previousAgentAcceleration = ((EnemyAI)__instance).agent.acceleration;
					crawler.currentAgentSpeed = ((EnemyAI)__instance).agent.speed;
					crawler.currentAgentAcceleration = ((EnemyAI)__instance).agent.acceleration;
					Diversity.mls.LogInfo((object)"Crawler hit!");
				}
			}
		}

		[HarmonyPatch(typeof(CrawlerAI), "Start")]
		[HarmonyPrefix]
		public static void Start(CrawlerAI __instance)
		{
			if (Configuration.crawlerRevamp.Value)
			{
				crawler = ((Component)__instance).gameObject.GetComponent<CrawlerRevamp>();
				if (!Object.op_Implicit((Object)(object)crawler))
				{
					((Component)__instance).gameObject.AddComponent<CrawlerRevamp>();
					Diversity.mls.LogInfo((object)("Added CrawlerRevamp to: " + ((Object)((Component)__instance).gameObject).name));
				}
			}
		}

		[HarmonyPatch(typeof(CrawlerAI), "OnCollideWithPlayer")]
		[HarmonyPrefix]
		private static void OnCollideWithPlayer(CrawlerAI __instance, Collider other)
		{
			if (__instance.timeSinceHittingPlayer < 0.65f)
			{
				return;
			}
			PlayerControllerB val = ((EnemyAI)__instance).MeetsStandardPlayerCollisionConditions(other, false, false);
			if ((Object)(object)val != (Object)null)
			{
				PlayerRevamp component = ((Component)val).gameObject.GetComponent<PlayerRevamp>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.ApplyConditions(DamageType.Bitten, 1f + (1f - (float)(val.health / 100)));
				}
			}
		}
	}
	[HarmonyPatch(typeof(DressGirlAI))]
	internal class DressGirlAIPatch
	{
		[HarmonyPatch(typeof(DressGirlAI), "Start")]
		[HarmonyPrefix]
		private static void Start(DressGirlAI __instance)
		{
			if (Configuration.dressGirlRevamp.Value)
			{
				DressGirlRevamp component = ((Component)__instance).gameObject.GetComponent<DressGirlRevamp>();
				if (!Object.op_Implicit((Object)(object)component))
				{
					((Component)__instance).gameObject.AddComponent<DressGirlRevamp>();
					Diversity.mls.LogInfo((object)("Added DressGirlRevamp to: " + ((Object)((Component)__instance).gameObject).name));
				}
			}
		}

		[HarmonyPatch(typeof(DressGirlAI), "Update")]
		[HarmonyPostfix]
		private static void Update(DressGirlAI __instance)
		{
			if (Configuration.dressGirlRevamp.Value)
			{
				DressGirlRevamp component = ((Component)__instance).gameObject.GetComponent<DressGirlRevamp>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.timeElapsed += Time.deltaTime;
					component.TryWalkieTalkie(__instance.hauntingPlayer);
				}
			}
		}

		[HarmonyPatch(typeof(DressGirlAI), "BeginChasing")]
		[HarmonyPostfix]
		private static void BeginChasing(DressGirlAI __instance)
		{
			if (Configuration.dressGirlRevamp.Value && Configuration.dressGirlIsolation.Value && !((Object)(object)__instance.hauntingPlayer == (Object)null))
			{
				PlayerRevamp component = ((Component)__instance.hauntingPlayer).GetComponent<PlayerRevamp>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.dressGirlHaunt = true;
				}
			}
		}

		[HarmonyPatch(typeof(DressGirlAI), "StopChasing")]
		[HarmonyPostfix]
		private static void StopChasing(DressGirlAI __instance)
		{
			if (!Configuration.dressGirlRevamp.Value || !Configuration.dressGirlIsolation.Value || (Object)(object)__instance.hauntingPlayer == (Object)null)
			{
				return;
			}
			PlayerRevamp component = ((Component)__instance.hauntingPlayer).GetComponent<PlayerRevamp>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return;
			}
			component.dressGirlHaunt = false;
			DiversitySoundManager.StopSoundBypass();
			if (DiversitySoundManager.Instance.currentGirlAudios.Count <= 0)
			{
				return;
			}
			foreach (GameObject item in DiversitySoundManager.Instance.currentGirlAudios.ToList())
			{
				item.GetComponent<AudioSource>().Stop();
				DiversitySoundManager.DeleteAudio(item);
				DiversitySoundManager.Instance.currentGirlAudios.Remove(item);
			}
		}
	}
	[HarmonyPatch(typeof(FlashlightItem))]
	public class FlashlightPatch : MonoBehaviour
	{
		private static bool wasHaunted;

		private static float timeElapsed;

		[HarmonyPatch(typeof(FlashlightItem), "Update")]
		[HarmonyPostfix]
		private static void Update(FlashlightItem __instance)
		{
			if (!Configuration.brakenRevamp.Value)
			{
				return;
			}
			FlashlightRevamp component = ((Component)__instance).gameObject.GetComponent<FlashlightRevamp>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return;
			}
			if (component.haunted)
			{
				if (!wasHaunted)
				{
					wasHaunted = true;
				}
				__instance.flashlightBulb.intensity = component.currentIntensity;
				timeElapsed = 0f;
			}
			else
			{
				timeElapsed += Time.deltaTime;
				if (timeElapsed >= 1f)
				{
					wasHaunted = false;
				}
			}
		}

		[HarmonyPatch(typeof(FlashlightItem), "Start")]
		[HarmonyPrefix]
		public static void Start(FlashlightItem __instance)
		{
			if (Configuration.brakenRevamp.Value)
			{
				FlashlightRevamp component = ((Component)__instance).gameObject.GetComponent<FlashlightRevamp>();
				Rigidbody component2 = ((Component)__instance).gameObject.GetComponent<Rigidbody>();
				if (!Object.op_Implicit((Object)(object)component))
				{
					((Component)__instance).gameObject.AddComponent<FlashlightRevamp>();
					Diversity.mls.LogInfo((object)("Added FlashlightRevamp to: " + ((Object)((Component)__instance).gameObject).name));
				}
				if (!Object.op_Implicit((Object)(object)component2))
				{
					Rigidbody val = ((Component)__instance).gameObject.AddComponent<Rigidbody>();
					val.isKinematic = true;
					Diversity.mls.LogInfo((object)("Added Rigidbody to: " + ((Object)((Component)__instance).gameObject).name));
				}
			}
		}
	}
	[HarmonyPatch(typeof(FlowermanAI))]
	internal class FlowermanAIPatch
	{
		[HarmonyPatch(typeof(FlowermanAI), "Start")]
		[HarmonyPrefix]
		public static void Start(FlowermanAI __instance)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			if (Configuration.brakenRevamp.Value)
			{
				BrakenRevamp component = ((Component)__instance).gameObject.GetComponent<BrakenRevamp>();
				if (!Object.op_Implicit((Object)(object)component))
				{
					((Component)__instance).gameObject.AddComponent<BrakenRevamp>();
					Diversity.mls.LogInfo((object)("Added BrakenRevamp to: " + ((Object)((Component)__instance).gameObject).name));
				}
				GameObject val = new GameObject("CreatureSpeech");
				AudioSource val2 = val.AddComponent<AudioSource>();
				val2.loop = false;
				((Behaviour)val2).enabled = true;
				val2.playOnAwake = false;
				val2.volume = 1f;
				val2.spatialBlend = 0f;
				val2.clip = Content.MainAssets.LoadAsset<AudioClip>("Assets/custom/diversity/bracken/you're next.mp3");
				val.transform.SetParent(((Component)__instance).gameObject.transform);
				Diversity.mls.LogInfo((object)("Added CreatureSpeech to: " + ((Object)((Component)__instance).gameObject).name));
			}
		}

		[HarmonyPatch(typeof(FlowermanAI), "killAnimation")]
		[HarmonyPostfix]
		private static void killAnimation(FlowermanAI __instance)
		{
			if (!Configuration.brakenRevamp.Value || !((Object)(object)((EnemyAI)__instance).inSpecialAnimationWithPlayer != (Object)null))
			{
				return;
			}
			Transform val = ((Component)__instance).gameObject.transform.Find("CreatureSpeech");
			if (Object.op_Implicit((Object)(object)val))
			{
				AudioSource component = ((Component)val).GetComponent<AudioSource>();
				BrakenRevamp component2 = ((Component)__instance).gameObject.GetComponent<BrakenRevamp>();
				if (Object.op_Implicit((Object)(object)component2))
				{
					component2.TransmitWalkie(component.clip);
				}
			}
		}

		[HarmonyPatch(typeof(FlowermanAI), "OnCollideWithPlayer")]
		[HarmonyPrefix]
		private static void OnCollideWithPlayer(FlowermanAI __instance, Collider other)
		{
			if (!Configuration.brakenSpace.Value)
			{
				return;
			}
			BrakenRevamp component = ((Component)__instance).gameObject.GetComponent<BrakenRevamp>();
			StartOfRoundRevamp component2 = ((Component)StartOfRound.Instance).gameObject.GetComponent<StartOfRoundRevamp>();
			PlayerControllerB val = ((EnemyAI)__instance).MeetsStandardPlayerCollisionConditions(other, __instance.inKillAnimation || __instance.startingKillAnimationLocalClient || __instance.carryingPlayerBody, false);
			if ((Object)(object)val != (Object)null && Object.op_Implicit((Object)(object)component) && !component.kidnapped)
			{
				component.kidnapped = true;
				if (Object.op_Implicit((Object)(object)component2))
				{
					component2.Kidnap(val);
					StartOfRound.Instance.allowLocalPlayerDeath = false;
					((Component)((Component)val).gameObject.transform.Find("Misc").Find("MapDot")).gameObject.SetActive(false);
					component.ResetAnimation(__instance);
				}
			}
		}
	}
	[HarmonyPatch(typeof(HoarderBugAI))]
	internal class HoarderBugAIPatch
	{
		[HarmonyPatch(typeof(HoarderBugAI), "OnCollideWithPlayer")]
		[HarmonyPrefix]
		private static void OnCollideWithPlayer(HoarderBugAI __instance, Collider other)
		{
			if (!__instance.inChase || __instance.timeSinceHittingPlayer < 0.5f)
			{
				return;
			}
			PlayerControllerB val = ((EnemyAI)__instance).MeetsStandardPlayerCollisionConditions(other, false, false);
			if ((Object)(object)val != (Object)null)
			{
				PlayerRevamp component = ((Component)val).gameObject.GetComponent<PlayerRevamp>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.ApplyConditions(DamageType.Mauled, 1f + (1f - (float)(val.health / 100)));
				}
			}
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	public class HUDPatch
	{
		public static TextMeshProUGUI tipText;

		public static Image holderBar;

		public static Image clickBar;

		private static readonly string text = "Free from head : [E]";

		private static readonly Color color = Color32.op_Implicit(new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue));

		[HarmonyPatch(typeof(HUDManager), "Start")]
		[HarmonyPostfix]
		private static void Start(ref HUDManager __instance)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Expected O, but got Unknown
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("InteractText");
			val.AddComponent<RectTransform>();
			TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
			RectTransform rectTransform = ((TMP_Text)val2).rectTransform;
			((Transform)rectTransform).SetParent(((TMP_Text)__instance.signalTranslatorText).transform, false);
			Rect rect = rectTransform.rect;
			rectTransform.anchoredPosition = new Vector2((0f - ((Rect)(ref rect)).width) / 4f + 5f, -40f);
			GameObject val3 = new GameObject("InteractBarHolder");
			val3.AddComponent<RectTransform>();
			Image val4 = val3.AddComponent<Image>();
			val4.sprite = Content.MainAssets.LoadAsset<Sprite>("Assets/custom/diversity/hud/holder.png");
			RectTransform component = ((Component)val4).GetComponent<RectTransform>();
			((Transform)component).SetParent(((TMP_Text)__instance.signalTranslatorText).transform, false);
			component.sizeDelta = new Vector2(133.33333f, 20f);
			rect = rectTransform.rect;
			component.anchoredPosition = new Vector2((0f - ((Rect)(ref rect)).width) / 4f + 5f, -70f);
			((Behaviour)val4).enabled = false;
			holderBar = val4;
			GameObject val5 = new GameObject("InteractBarHolder");
			val5.AddComponent<RectTransform>();
			Image val6 = val5.AddComponent<Image>();
			val6.sprite = Content.MainAssets.LoadAsset<Sprite>("Assets/custom/diversity/hud/bar.png");
			RectTransform component2 = ((Component)val6).GetComponent<RectTransform>();
			((Transform)component2).SetParent(((TMP_Text)__instance.signalTranslatorText).transform, false);
			component2.sizeDelta = new Vector2(133.33333f, 20f);
			rect = rectTransform.rect;
			component2.anchoredPosition = new Vector2((0f - ((Rect)(ref rect)).width) / 4f + 5f, -70f);
			((Behaviour)val6).enabled = false;
			clickBar = val6;
			((TMP_Text)val2).alignment = (TextAlignmentOptions)514;
			((TMP_Text)val2).font = ((TMP_Text)__instance.controlTipLines[0]).font;
			((TMP_Text)val2).fontSize = 16f;
			((TMP_Text)val2).text = text;
			((Graphic)val2).color = color;
			((TMP_Text)val2).overflowMode = (TextOverflowModes)0;
			((Behaviour)val2).enabled = false;
			tipText = val2;
			HUDManagerRevamp component3 = ((Component)__instance).gameObject.GetComponent<HUDManagerRevamp>();
			if (!Object.op_Implicit((Object)(object)component3))
			{
				((Component)__instance).gameObject.AddComponent<HUDManagerRevamp>();
				Diversity.mls.LogInfo((object)("Added HUDManagerRevamp to: " + ((Object)((Component)__instance).gameObject).name));
			}
		}

		[HarmonyPatch(typeof(HUDManager), "UnderwaterScreenFilters")]
		[HarmonyPostfix]
		private static void UnderwaterScreenFilters(HUDManager __instance)
		{
			PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
			if (!Object.op_Implicit((Object)(object)localPlayerController))
			{
				return;
			}
			PlayerRevamp component = ((Component)localPlayerController).gameObject.GetComponent<PlayerRevamp>();
			if (Object.op_Implicit((Object)(object)component))
			{
				if (component.filter > 0f)
				{
					((Behaviour)__instance.audioListenerLowPass).enabled = true;
					__instance.audioListenerLowPass.cutoffFrequency = 20000f * (1f - component.filter);
				}
				else
				{
					((Behaviour)__instance.audioListenerLowPass).enabled = false;
					__instance.audioListenerLowPass.cutoffFrequency = 20000f * (1f - component.filter);
				}
			}
		}
	}
	[HarmonyPatch(typeof(LungProp))]
	internal class LungPropPatch
	{
		[HarmonyPatch(typeof(LungProp), "Start")]
		[HarmonyPrefix]
		private static void Start(LungProp __instance)
		{
			if (Configuration.brakenRevamp.Value)
			{
				LungPropRevamp component = ((Component)__instance).gameObject.GetComponent<LungPropRevamp>();
				if (!Object.op_Implicit((Object)(object)component))
				{
					((Component)__instance).gameObject.AddComponent<LungPropRevamp>();
					Diversity.mls.LogInfo((object)("Added LungPropRevamp to: " + ((Object)((Component)__instance).gameObject).name));
				}
			}
		}

		[HarmonyPatch(typeof(LungProp), "DisconnectFromMachinery")]
		[HarmonyPostfix]
		private static void DisconnectFromMachinery(LungProp __instance)
		{
			if (Configuration.brakenRevamp.Value && Configuration.apparatusAnger.Value)
			{
				LungPropRevamp component = ((Component)__instance).gameObject.GetComponent<LungPropRevamp>();
				if (Object.op_Implicit((Object)(object)component) && (Object)(object)((GrabbableObject)__instance).playerHeldBy != (Object)null)
				{
					component.AngerBracken(__instance.roundManager, ((GrabbableObject)__instance).playerHeldBy);
				}
			}
		}
	}
	[HarmonyPatch(typeof(ManualCameraRenderer))]
	internal class ManualCameraRendererPatch
	{
		[HarmonyPatch(typeof(ManualCameraRenderer), "MapCameraFocusOnPosition")]
		[HarmonyPostfix]
		private static void MapCameraFocusOnPosition(ManualCameraRenderer __instance)
		{
			if (!Configuration.brakenSpace.Value || !Object.op_Implicit((Object)(object)__instance.targetedPlayer))
			{
				return;
			}
			PlayerRevamp component = ((Component)__instance.targetedPlayer).gameObject.GetComponent<PlayerRevamp>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return;
			}
			if (component.kidnapped)
			{
				if (__instance.isScreenOn)
				{
					((Behaviour)StartOfRound.Instance.mapScreenPlayerName).enabled = false;
					__instance.mapCamera.cullingMask = LayerMask.GetMask(new string[1] { "MapRadar" });
					Transform val = ((TMP_Text)StartOfRound.Instance.mapScreenPlayerName).transform.parent.Find("ErrorText");
					if (Object.op_Implicit((Object)(object)val))
					{
						((Component)val).gameObject.SetActive(true);
					}
				}
			}
			else if (__instance.isScreenOn)
			{
				((Behaviour)StartOfRound.Instance.mapScreenPlayerName).enabled = true;
				__instance.mapCamera.cullingMask = 16640;
				Transform val2 = ((TMP_Text)StartOfRound.Instance.mapScreenPlayerName).transform.parent.Find("ErrorText");
				if (Object.op_Implicit((Object)(object)val2))
				{
					((Component)val2).gameObject.SetActive(false);
				}
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	public class PlayerControllerBPatch
	{
		public static Transform InteractorSource;

		private static float InteractRange = Configuration.interactRange.Value;

		public static PlayerControllerB player;

		private static CentipedeRevamp revamp;

		[HarmonyPatch(typeof(PlayerControllerB), "Start")]
		[HarmonyPrefix]
		public static void Start(PlayerControllerB __instance)
		{
			PlayerRevamp component = ((Component)__instance).gameObject.GetComponent<PlayerRevamp>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				((Component)__instance).gameObject.AddComponent<PlayerRevamp>();
				Diversity.mls.LogInfo((object)("Added PlayerRevamp to: " + ((Object)((Component)__instance).gameObject).name));
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "CheckConditionsForSinkingInQuicksand")]
		[HarmonyPrefix]
		private static bool CheckConditionsForSinkingInQuicksand(PlayerControllerB __instance, ref bool __result)
		{
			PlayerRevamp component = ((Component)__instance).gameObject.GetComponent<PlayerRevamp>();
			if (component.sinkingFromWalker)
			{
				__result = true;
				return false;
			}
			return true;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "Update")]
		private static void Update(PlayerControllerB __instance)
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0475: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance.currentlyHeldObject != (Object)null && Object.op_Implicit((Object)(object)((Component)__instance.currentlyHeldObject).GetComponent<FlashlightItem>()) && Object.op_Implicit((Object)(object)((Component)__instance).gameObject.GetComponent<PlayerRevamp>()))
			{
				((Component)__instance).gameObject.GetComponent<PlayerRevamp>().lastID = ((Component)__instance.currentlyHeldObject).GetComponent<FlashlightItem>().flashlightTypeID;
			}
			if ((Object)(object)__instance == (Object)(object)StartOfRound.Instance.localPlayerController)
			{
				MovementActions movement = __instance.playerActions.Movement;
				if (((MovementActions)(ref movement)).Interact.WasPressedThisFrame())
				{
					InteractorSource = ((Component)__instance.gameplayCamera).transform;
					Ray val = default(Ray);
					((Ray)(ref val))..ctor(InteractorSource.position, InteractorSource.forward);
					RaycastHit val2 = default(RaycastHit);
					if (Physics.Raycast(val, ref val2, InteractRange, LayerMask.GetMask(new string[4] { "Enemies", "Room", "Terrain", "Railing" })))
					{
						Diversity.mls.LogInfo((object)("Interactor interacted with: " + ((Object)((Component)((RaycastHit)(ref val2)).transform).gameObject).name));
						if (((Object)((Component)((RaycastHit)(ref val2)).transform).gameObject).name == "brackendoor")
						{
							BrackenDoor component = ((Component)((RaycastHit)(ref val2)).transform).gameObject.GetComponent<BrackenDoor>();
							if (!Object.op_Implicit((Object)(object)component))
							{
								return;
							}
							component.CheckClicks(__instance);
						}
						else if (Configuration.centipedeRevamp.Value)
						{
							try
							{
								revamp = ((Component)((Component)((RaycastHit)(ref val2)).collider).transform.parent).gameObject.GetComponent<CentipedeRevamp>();
							}
							catch (Exception)
							{
							}
							if (!Object.op_Implicit((Object)(object)revamp))
							{
								return;
							}
							Diversity.mls.LogInfo((object)("Centipede clinging: " + revamp.clinging));
							Diversity.mls.LogInfo((object)("Amount of click done: " + revamp.clicks));
							if (revamp.clinging)
							{
								revamp.clicks++;
								float value = Random.value;
								if (value < (float)(Configuration.hurtChance.Value / 100))
								{
									__instance.DamagePlayer(5, true, true, (CauseOfDeath)6, 0, false, default(Vector3));
								}
							}
						}
					}
				}
			}
			if ((Object)(object)__instance == (Object)(object)StartOfRound.Instance.localPlayerController)
			{
				InteractorSource = ((Component)__instance.gameplayCamera).transform;
				Ray val3 = default(Ray);
				((Ray)(ref val3))..ctor(InteractorSource.position, InteractorSource.forward);
				RaycastHit val4 = default(RaycastHit);
				if (Physics.Raycast(val3, ref val4, InteractRange, LayerMask.GetMask(new string[4] { "Enemies", "Room", "Terrain", "Railing" })))
				{
					if (((Object)((Component)((RaycastHit)(ref val4)).transform).gameObject).name == "brackendoor")
					{
						BrackenDoor component2 = ((Component)((RaycastHit)(ref val4)).transform).gameObject.GetComponent<BrackenDoor>();
						if (!Object.op_Implicit((Object)(object)component2))
						{
							return;
						}
						((Behaviour)HUDPatch.tipText).enabled = true;
						((TMP_Text)HUDPatch.tipText).text = "Break out! : [E]";
						((Behaviour)HUDPatch.holderBar).enabled = true;
						((Behaviour)HUDPatch.clickBar).enabled = true;
						((Graphic)HUDPatch.clickBar).rectTransform.sizeDelta = new Vector2(8f * (float)component2.clicks / 1.5f, 20f);
					}
					else
					{
						try
						{
							revamp = ((Component)((Component)((RaycastHit)(ref val4)).collider).transform.parent).gameObject.GetComponent<CentipedeRevamp>();
						}
						catch (Exception)
						{
						}
						if (!Object.op_Implicit((Object)(object)revamp))
						{
							return;
						}
						if (revamp.clinging)
						{
							((Behaviour)HUDPatch.tipText).enabled = true;
							((TMP_Text)HUDPatch.tipText).text = "Free from head : [E]";
							((Behaviour)HUDPatch.holderBar).enabled = true;
							((Behaviour)HUDPatch.clickBar).enabled = true;
							((Graphic)HUDPatch.clickBar).rectTransform.sizeDelta = new Vector2((float)(200 / Configuration.clickAmount.Value * revamp.clicks) / 1.5f, 20f);
						}
					}
				}
				else
				{
					((Behaviour)HUDPatch.tipText).enabled = false;
					((Behaviour)HUDPatch.holderBar).enabled = false;
					((Behaviour)HUDPatch.clickBar).enabled = false;
				}
			}
			if (Configuration.playerConditions.Value)
			{
				PlayerRevamp component3 = ((Component)__instance).gameObject.GetComponent<PlayerRevamp>();
				if (Object.op_Implicit((Object)(object)component3))
				{
					component3.CheckConditions(__instance);
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")]
		private static void LateUpdate(PlayerControllerB __instance)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			PlayerRevamp component = ((Component)__instance).gameObject.GetComponent<PlayerRevamp>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return;
			}
			if (((Component)__instance).gameObject.transform.position.y > -350f && !__instance.isPlayerDead)
			{
				component.kidnapped = false;
			}
			if (component.kidnapped)
			{
				__instance.sprintMeter = 1f;
				((Component)__instance.mapRadarDotAnimator).gameObject.SetActive(false);
				return;
			}
			((Component)__instance.mapRadarDotAnimator).gameObject.SetActive(true);
			bool flag = false;
			bool flag2 = false;
			using (List<Condition>.Enumerator enumerator = component.conditions.GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					switch (enumerator.Current)
					{
					case Condition.FracturedLeg:
						flag = true;
						break;
					case Condition.BrokenLeg:
						flag2 = true;
						break;
					}
				}
			}
			float num = 1f;
			if (__instance.drunkness > 0.02f)
			{
				num *= Mathf.Abs(StartOfRound.Instance.drunknessSpeedEffect.Evaluate(__instance.drunkness) - 1.25f);
			}
			if (flag2)
			{
				if (__instance.isSprinting)
				{
					__instance.sprintMeter = Mathf.Clamp(__instance.sprintMeter - Time.deltaTime / (__instance.sprintTime / 1.5f) * __instance.carryWeight * num, 0f, 1f);
				}
				else if (__instance.isMovementHindered > 0)
				{
					if (__instance.isWalking)
					{
						__instance.sprintMeter = Mathf.Clamp(__instance.sprintMeter - Time.deltaTime / (__instance.sprintTime / 1.5f) * num * 0.5f, 0f, 1f);
					}
				}
				else if (!__instance.isWalking)
				{
					__instance.sprintMeter = Mathf.Clamp(__instance.sprintMeter + Time.deltaTime / (__instance.sprintTime / 1.5f + 4f) * num, 0f, 1f);
				}
				else
				{
					__instance.sprintMeter = Mathf.Clamp(__instance.sprintMeter + Time.deltaTime / (__instance.sprintTime / 1.5f + 9f) * num, 0f, 1f);
				}
			}
			else
			{
				if (!flag)
				{
					return;
				}
				if (__instance.isSprinting)
				{
					__instance.sprintMeter = Mathf.Clamp(__instance.sprintMeter - Time.deltaTime / (__instance.sprintTime / 1.2f) * __instance.carryWeight * num, 0f, 1f);
				}
				else if (__instance.isMovementHindered > 0)
				{
					if (__instance.isWalking)
					{
						__instance.sprintMeter = Mathf.Clamp(__instance.sprintMeter - Time.deltaTime / (__instance.sprintTime / 1.2f) * num * 0.5f, 0f, 1f);
					}
				}
				else if (!__instance.isWalking)
				{
					__instance.sprintMeter = Mathf.Clamp(__instance.sprintMeter + Time.deltaTime / (__instance.sprintTime / 1.2f + 4f) * num, 0f, 1f);
				}
				else
				{
					__instance.sprintMeter = Mathf.Clamp(__instance.sprintMeter + Time.deltaTime / (__instance.sprintTime / 1.2f + 9f) * num, 0f, 1f);
				}
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "DamagePlayer")]
		[HarmonyPrefix]
		private static void DamagePlayer(PlayerControllerB __instance, int damageNumber, bool hasDamageSFX = true, bool callRPC = true, CauseOfDeath causeOfDeath = 0, int deathAnimation = 0, bool fallDamage = false, Vector3 force = default(Vector3))
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Invalid comparison between Unknown and I4
			if (!Configuration.playerConditions.Value)
			{
				return;
			}
			PlayerRevamp component = ((Component)__instance).gameObject.GetComponent<PlayerRevamp>();
			if (Object.op_Implicit((Object)(object)component))
			{
				if ((int)causeOfDeath == 2)
				{
					component.ApplyConditions(DamageType.Falling, 1f + (1f - (float)(__instance.health / 100)));
				}
				else if ((int)causeOfDeath == 7)
				{
					component.ApplyConditions(DamageType.GunShotted, 1f + (1f - (float)(__instance.health / 100)));
				}
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")]
		[HarmonyPrefix]
		private static void KillPlayer(PlayerControllerB __instance)
		{
			PlayerRevamp component = ((Component)__instance).gameObject.GetComponent<PlayerRevamp>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return;
			}
			if (component.kidnapped)
			{
				StartOfRoundRevamp component2 = ((Component)StartOfRound.Instance).gameObject.GetComponent<StartOfRoundRevamp>();
				if (!Object.op_Implicit((Object)(object)component2))
				{
					return;
				}
				foreach (GameObject currentEffect in component2.currentEffects)
				{
					currentEffect.SetActive(true);
				}
			}
			if (Configuration.playerConditions.Value)
			{
				component.conditions.Clear();
				HUDManagerRevamp component3 = ((Component)HUDManager.Instance).gameObject.GetComponent<HUDManagerRevamp>();
				if (Object.op_Implicit((Object)(object)component3) && ((Object)(object)__instance == (Object)(object)StartOfRound.Instance.localPlayerController || __instance.actualClientId == StartOfRound.Instance.localPlayerController.actualClientId))
				{
					component3.blindnessIntensity = 0f;
					component3.concussedIntensity = 0f;
				}
			}
		}
	}
	[HarmonyPatch(typeof(PufferAI))]
	internal class PufferAIPatch
	{
		[HarmonyPatch(typeof(PufferAI), "OnCollideWithPlayer")]
		[HarmonyPrefix]
		private static void OnCollideWithPlayer(PufferAI __instance, Collider other)
		{
			PlayerControllerB val = ((EnemyAI)__instance).MeetsStandardPlayerCollisionConditions(other, false, false);
			if ((Object)(object)val != (Object)null && __instance.timeSinceHittingPlayer > 1f)
			{
				PlayerRevamp component = ((Component)val).gameObject.GetComponent<PlayerRevamp>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.ApplyConditions(DamageType.Bitten, 1f + (1f - (float)(val.health / 100)));
				}
			}
		}

		[HarmonyPatch(typeof(PufferAI), "Start")]
		[HarmonyPrefix]
		private static void Start(PufferAI __instance)
		{
			GameObject smokePrefab = __instance.smokePrefab;
			SphereCollider component = smokePrefab.GetComponent<SphereCollider>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				SphereCollider val = smokePrefab.AddComponent<SphereCollider>();
				((Collider)val).isTrigger = true;
				val.radius = 14f;
				Diversity.mls.LogInfo((object)("Added SphereCollider to: " + ((Object)smokePrefab).name));
			}
			Rigidbody component2 = smokePrefab.GetComponent<Rigidbody>();
			if (!Object.op_Implicit((Object)(object)component2))
			{
				Rigidbody val2 = smokePrefab.AddComponent<Rigidbody>();
				val2.isKinematic = true;
				Diversity.mls.LogInfo((object)("Added Rigidbody to: " + ((Object)smokePrefab).name));
			}
			PufferSmokeRevamp component3 = smokePrefab.GetComponent<PufferSmokeRevamp>();
			if (!Object.op_Implicit((Object)(object)component3))
			{
				PufferSmokeRevamp pufferSmokeRevamp = smokePrefab.AddComponent<PufferSmokeRevamp>();
				Diversity.mls.LogInfo((object)("Added PufferSmokeRevamp to: " + ((Object)smokePrefab).name));
			}
		}
	}
	[HarmonyPatch(typeof(RadarBoosterItem), "Start")]
	internal class RadarBoosterItemPatch
	{
		[HarmonyPatch(typeof(RadarBoosterItem), "Start")]
		[HarmonyPostfix]
		public static void Start(RadarBoosterItem __instance)
		{
			RadarBoosterItemRevamp component = ((Component)__instance).gameObject.GetComponent<RadarBoosterItemRevamp>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				((Component)__instance).gameObject.AddComponent<RadarBoosterItemRevamp>();
			}
			StartOfRoundRevamp.Instance.radarBoosters.Add(__instance);
		}
	}
	[HarmonyPatch(typeof(RedLocustBees))]
	internal class RedLocustBeesPatch
	{
		[HarmonyPatch(typeof(RedLocustBees), "OnCollideWithPlayer")]
		[HarmonyPrefix]
		private static void OnCollideWithPlayer(RedLocustBees __instance, Collider other)
		{
			if (__instance.timeSinceHittingPlayer < 0.4f)
			{
				return;
			}
			PlayerControllerB val = ((EnemyAI)__instance).MeetsStandardPlayerCollisionConditions(other, false, false);
			if ((Object)(object)val != (Object)null && (val.health > 10 || !val.criticallyInjured))
			{
				PlayerRevamp component = ((Component)val).gameObject.GetComponent<PlayerRevamp>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.ApplyConditions(DamageType.Electrified, 1f + (1f - (float)(val.health / 100)));
				}
			}
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class RoundManagerPatch : MonoBehaviour
	{
		[HarmonyPatch(typeof(RoundManager), "FinishGeneratingLevel")]
		[HarmonyPostfix]
		public static void FinishGeneratingLevel(RoundManager __instance)
		{
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Expected O, but got Unknown
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Expected O, but got Unknown
			Vector3 startPos = default(Vector3);
			((Vector3)(ref startPos))..ctor(300f, -400f, 0f);
			GameObject test = Content.MainAssets.LoadAsset<GameObject>("Assets/custom/diversity/bracken/rooms/prefabs/test.prefab");
			GameObject start = Content.MainAssets.LoadAsset<GameObject>("Assets/custom/diversity/bracken/rooms/prefabs/start.prefab");
			GameObject end = Content.MainAssets.LoadAsset<GameObject>("Assets/custom/diversity/bracken/rooms/prefabs/end.prefab");
			List<GameObject> list = new List<GameObject>();
			list.Add(Content.MainAssets.LoadAsset<GameObject>("Assets/custom/diversity/bracken/rooms/prefabs/hall1.prefab"));
			list.Add(Content.MainAssets.LoadAsset<GameObject>("Assets/custom/diversity/bracken/rooms/prefabs/hall2.prefab"));
			list.Add(Content.MainAssets.LoadAsset<GameObject>("Assets/custom/diversity/bracken/rooms/prefabs/hall3.prefab"));
			list.Add(Content.MainAssets.LoadAsset<GameObject>("Assets/custom/diversity/bracken/rooms/prefabs/hall4.prefab"));
			list.Add(Content.MainAssets.LoadAsset<GameObject>("Assets/custom/diversity/bracken/rooms/prefabs/hall5.prefab"));
			list.Add(Content.MainAssets.LoadAsset<GameObject>("Assets/custom/diversity/bracken/rooms/prefabs/hall6.prefab"));
			list.Add(Content.MainAssets.LoadAsset<GameObject>("Assets/custom/diversity/bracken/rooms/prefabs/hall7.prefab"));
			list.Add(Content.MainAssets.LoadAsset<GameObject>("Assets/custom/diversity/bracken/rooms/prefabs/hall8.prefab"));
			StartOfRoundRevamp component = ((Component)StartOfRound.Instance).gameObject.GetComponent<StartOfRoundRevamp>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return;
			}
			component.GenerateRoom(StartOfRound.Instance.randomMapSeed, startPos, test, list, start, end, isTest: false);
			Light[] array = Object.FindObjectsOfType<Light>();
			Light[] array2 = array;
			foreach (Light val in array2)
			{
				if (Object.op_Implicit((Object)(object)((Component)val).transform.parent) && (((Object)((Component)val).transform.parent).name.StartsWith("HangingLight") || ((Object)((Component)val).transform.parent).name.StartsWith("WallFixtureLight") || ((Object)((Component)val).transform.parent).name.StartsWith("MansionWallLamp") || ((Object)((Component)val).transform.parent).name.StartsWith("Chandelier")))
				{
					GameObject gameObject = ((Component)val).gameObject;
					StartOfRoundRevamp.Instance.brackenLights.Add(gameObject);
				}
			}
			GameObject val2 = new GameObject("BrakenScreamAudio");
			AudioSource val3 = val2.AddComponent<AudioSource>();
			val3.loop = false;
			((Behaviour)val3).enabled = false;
			val3.playOnAwake = true;
			val3.volume = 1f;
			val3.spatialBlend = 0f;
			val3.clip = Content.MainAssets.LoadAsset<AudioClip>("Assets/custom/diversity/bracken/brakenScream.mp3");
			AnimationCurve val4 = new AnimationCurve();
			val4.AddKey(0f, 1f);
			val4.AddKey(1f, 1f);
			val3.SetCustomCurve((AudioSourceCurveType)0, val4);
			Object.Instantiate<GameObject>(val2);
			Diversity.mls.LogInfo((object)"Bracken scream audio created.");
		}
	}
	[HarmonyPatch(typeof(SandSpiderAI))]
	internal class SandSpiderAIPatch
	{
		private static SpiderRevamp spider;

		[HarmonyPatch(typeof(SandSpiderAI), "HitEnemy")]
		[HarmonyPrefix]
		public static void Slow(SandSpiderAI __instance)
		{
			spider = ((Component)__instance).GetComponent<SpiderRevamp>();
			if (Object.op_Implicit((Object)(object)spider) && !spider.onCooldown)
			{
				spider.hasBeenhit = true;
				spider.onCooldown = true;
				spider.previousAgentSpeed = ((EnemyAI)__instance).agent.speed;
				spider.previousSpiderSpeed = __instance.spiderSpeed;
				spider.currentAgentSpeed = ((EnemyAI)__instance).agent.speed;
				spider.currentSpiderSpeed = __instance.spiderSpeed;
				Diversity.mls.LogInfo((object)"Spider hit!");
			}
		}

		[HarmonyPatch(typeof(SandSpiderAI), "Start")]
		[HarmonyPrefix]
		public static void Start(SandSpiderAI __instance)
		{
			if (Configuration.spiderRevamp.Value)
			{
				spider = ((Component)__instance).gameObject.GetComponent<SpiderRevamp>();
				if (!Object.op_Implicit((Object)(object)spider))
				{
					((Component)__instance).gameObject.AddComponent<SpiderRevamp>();
					Diversity.mls.LogInfo((object)("Added SpiderRevamp to: " + ((Object)((Component)__instance).gameObject).name));
				}
			}
		}

		[HarmonyPatch(typeof(SandSpiderAI), "OnCollideWithPlayer")]
		[HarmonyPrefix]
		private static void OnCollideWithPlayer(SandSpiderAI __instance, Collider other)
		{
			if (((EnemyAI)__instance).isEnemyDead || __instance.onWall)
			{
				return;
			}
			PlayerControllerB val = ((EnemyAI)__instance).MeetsStandardPlayerCollisionConditions(other, __instance.spoolingPlayerBody, false);
			if ((Object)(object)val != (Object)null && __instance.timeSinceHittingPlayer > 1f)
			{
				PlayerRevamp component = ((Component)val).gameObject.GetComponent<PlayerRevamp>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.ApplyConditions(DamageType.Mauled, 1f + (1f - (float)(val.health / 100)));
				}
			}
		}
	}
	[HarmonyPatch(typeof(ShipTeleporter))]
	internal class ShipTeleporterPatch
	{
		[HarmonyPatch(typeof(ShipTeleporter), "Awake")]
		[HarmonyPrefix]
		private static void Awake(ShipTeleporter __instance)
		{
			ShipTeleporterRevamp component = ((Component)__instance).gameObject.GetComponent<ShipTeleporterRevamp>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				((Component)__instance).gameObject.AddComponent<ShipTeleporterRevamp>();
			}
		}
	}
	[HarmonyPatch(typeof(SoundManager))]
	internal class SoundManagerPatch
	{
		[HarmonyPatch(typeof(SoundManager), "SetPlayerVoiceFilters")]
		[HarmonyPostfix]
		private static void SetPlayerVoiceFilters(SoundManager __instance)
		{
			for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
			{
				if (!StartOfRound.Instance.allPlayerScripts[i].isPlayerDead && (Object)(object)StartOfRound.Instance.allPlayerScripts[i] != (Object)(object)StartOfRound.Instance.localPlayerController)
				{
					PlayerRevamp component = ((Component)StartOfRound.Instance.localPlayerController).gameObject.GetComponent<PlayerRevamp>();
					if (!Object.op_Implicit((Object)(object)component))
					{
						break;
					}
					if (component.dressGirlHaunt)
					{
						__instance.diageticMixer.SetFloat($"PlayerVolume{i}", -80f);
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(SpringManAI))]
	internal class SpringManAIPatch
	{
		[HarmonyPatch(typeof(SpringManAI), "OnCollideWithPlayer")]
		[HarmonyPrefix]
		private static void OnCollideWithPlayer(SpringManAI __instance, Collider other)
		{
			if (__instance.stoppingMovement || ((EnemyAI)__instance).currentBehaviourStateIndex != 1 || __instance.timeSinceHittingPlayer >= 0f)
			{
				return;
			}
			PlayerControllerB val = ((EnemyAI)__instance).MeetsStandardPlayerCollisionConditions(other, false, false);
			if ((Object)(object)val != (Object)null)
			{
				PlayerRevamp component = ((Component)val).gameObject.GetComponent<PlayerRevamp>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.ApplyConditions(DamageType.Concussed, 1f + (1f - (float)(val.health / 100)));
				}
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPatch(typeof(StartOfRound), "Start")]
		[HarmonyPrefix]
		private static void Start(StartOfRound __instance)
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			StartOfRoundRevamp component = ((Component)__instance).gameObject.GetComponent<StartOfRoundRevamp>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				((Component)__instance).gameObject.AddComponent<StartOfRoundRevamp>();
				Diversity.mls.LogInfo((object)("Added StartOfRoundRevamp to: " + ((Object)((Component)__instance).gameObject).name));
			}
			if (Configuration.brakenSpace.Value)
			{
				GameObject gameObject = ((Component)((Component)__instance.mapScreenPlayerName).gameObject.transform.parent).gameObject;
				GameObject val = new GameObject("ErrorText");
				val.layer = 14;
				val.AddComponent<RectTransform>();
				val.AddComponent<CanvasRenderer>();
				TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
				((TMP_Text)val2).font = ((TMP_Text)HUDManager.Instance.controlTipLines[0]).font;
				((TMP_Text)val2).fontSize = 17f;
				((TMP_Text)val2).alignment = (TextAlignmentOptions)514;
				((TMP_Text)val2).overflowMode = (TextOverflowModes)0;
				((TMP_Text)val2).text = "THEY ARE PAYING\nTHE PRICE";
				((Graphic)val2).color = Color.red;
				((Behaviour)val2).enabled = true;
				val.transform.SetParent(gameObject.transform);
				val.transform.localPosition = Vector3.zero;
				val.transform.localScale = new Vector3(2f, 2f, 2f);
				val.transform.localRotation = Quaternion.identity;
				val.SetActive(false);
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "EndOfGame")]
		[HarmonyPrefix]
		private static void EndOfGame(StartOfRound __instance)
		{
			PlayerControllerB[] allPlayerScripts = __instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if ((Object)(object)val != (Object)null)
				{
					PlayerRevamp component = ((Component)val).gameObject.GetComponent<PlayerRevamp>();
					if (!Object.op_Implicit((Object)(object)component))
					{
						return;
					}
					component.conditions.Clear();
					component.updated = false;
					val.playerBodyAnimator.SetBool("Limp", false);
					val.jumpForce = 13f;
					val.bleedingHeavily = false;
					val.isMovementHindered = 0;
					val.hinderedMultiplier = 1f;
					component.nearbySounds.Clear();
					DiversitySoundManager.Instance.current3Daudios.Clear();
					StartOfRoundRevamp.Instance.brackenLights.Clear();
					StartOfRoundRevamp.Instance.affectedLights.Clear();
					StartOfRoundRevamp.Instance.steamSounds.Clear();
					StartOfRoundRevamp.Instance.lightBuzz.Clear();
					HUDManagerRevamp component2 = ((Component)HUDManager.Instance).gameObject.GetComponent<HUDManagerRevamp>();
					if (!Object.op_Implicit((Object)(object)component2))
					{
						return;
					}
					component2.blindnessIntensity = 0f;
					component2.concussedIntensity = 0f;
					component.kidnapped = false;
				}
			}
			StartOfRoundRevamp component3 = ((Component)__instance).gameObject.GetComponent<StartOfRoundRevamp>();
			if (Object.op_Implicit((Object)(object)component3))
			{
				component3.Reset();
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "DisableShipSpeakerLocalClient")]
		[HarmonyPostfix]
		private static void DisableShipSpeakerLocalClient(StartOfRound __instance)
		{
		}
	}
	[HarmonyPatch(typeof(SteamValveHazard))]
	internal class SteamValveHazardPatch
	{
		[HarmonyPatch(typeof(SteamValveHazard), "Start")]
		[HarmonyPrefix]
		private static void Start(SteamValveHazard __instance)
		{
			SteamLeakRevamp component = ((Component)__instance).gameObject.GetComponent<SteamLeakRevamp>();
			if (!

BepInEx/plugins/RollingGiant.dll

Decompiled 10 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using RollingGiant;
using RollingGiant.Patches;
using RollingGiant.Settings;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Audio;
using UnityEngine.InputSystem;
using UnityEngine.Pool;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("RollingGiant")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RollingGiant")]
[assembly: AssemblyTitle("RollingGiant")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
internal class <Module>
{
	static <Module>()
	{
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<RollingGiantAiType>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedValueEquals<RollingGiantAiType>();
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<float>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<float>();
	}
}
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 RollingGiant
{
	public class NetworkHandler : NetworkBehaviour
	{
		private static readonly List<RollingGiantAiType> _aiTypes = Enum.GetValues(typeof(RollingGiantAiType)).Cast<RollingGiantAiType>().ToList();

		private NetworkVariable<RollingGiantAiType> _aiType = new NetworkVariable<RollingGiantAiType>((RollingGiantAiType)0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		private static InputAction _gotoPreviousAiType;

		private static InputAction _gotoNextAiType;

		private static InputAction _reloadConfig;

		public static NetworkHandler Instance { get; private set; }

		public static RollingGiantAiType AiType => Instance._aiType.Value;

		public override void OnNetworkSpawn()
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Expected O, but got Unknown
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				if (Object.op_Implicit((Object)(object)Instance))
				{
					((Component)Instance).gameObject.GetComponent<NetworkObject>().Despawn(true);
				}
				_aiType.Value = CustomConfig.AiType.GetFirst();
			}
			Instance = this;
			InputAction gotoPreviousAiType = _gotoPreviousAiType;
			if (gotoPreviousAiType != null)
			{
				gotoPreviousAiType.Disable();
			}
			InputAction gotoPreviousAiType2 = _gotoPreviousAiType;
			if (gotoPreviousAiType2 != null)
			{
				gotoPreviousAiType2.Dispose();
			}
			_gotoPreviousAiType = new InputAction("gotoPreviousAiType", (InputActionType)1, CustomConfig.GotoPreviousAiTypeKey.Value, (string)null, (string)null, (string)null);
			_gotoPreviousAiType.Enable();
			InputAction gotoNextAiType = _gotoNextAiType;
			if (gotoNextAiType != null)
			{
				gotoNextAiType.Disable();
			}
			InputAction gotoNextAiType2 = _gotoNextAiType;
			if (gotoNextAiType2 != null)
			{
				gotoNextAiType2.Dispose();
			}
			_gotoNextAiType = new InputAction("gotoNextAiType", (InputActionType)1, CustomConfig.GotoNextAiTypeKey.Value, (string)null, (string)null, (string)null);
			_gotoNextAiType.Enable();
			InputAction reloadConfig = _reloadConfig;
			if (reloadConfig != null)
			{
				reloadConfig.Disable();
			}
			InputAction reloadConfig2 = _reloadConfig;
			if (reloadConfig2 != null)
			{
				reloadConfig2.Dispose();
			}
			_reloadConfig = new InputAction("reloadConfig", (InputActionType)1, CustomConfig.ReloadConfigKey.Value, (string)null, (string)null, (string)null);
			_reloadConfig.Enable();
			((NetworkBehaviour)this).OnNetworkSpawn();
		}

		public void SetAiType(RollingGiantAiType aiType)
		{
			if (((NetworkBehaviour)this).IsServer || ((NetworkBehaviour)this).IsHost)
			{
				SetNewAiType(aiType, showTip: false);
			}
		}

		private void Update()
		{
			if (!((NetworkBehaviour)this).IsServer && !((NetworkBehaviour)this).IsHost)
			{
				return;
			}
			if (_gotoPreviousAiType.WasPressedThisFrame())
			{
				int num = _aiTypes.IndexOf(_aiType.Value) - 1;
				if (num < 0)
				{
					num = Enum.GetValues(typeof(RollingGiantAiType)).Length - 1;
				}
				SetNewAiType(_aiTypes[num]);
			}
			else if (_gotoNextAiType.WasPressedThisFrame())
			{
				int num2 = _aiTypes.IndexOf(_aiType.Value) + 1;
				if (num2 >= _aiTypes.Count)
				{
					num2 = 0;
				}
				SetNewAiType(_aiTypes[num2]);
			}
			else if (_reloadConfig.WasPressedThisFrame())
			{
				Plugin.Config.Reload();
				SyncedInstance<CustomConfig>.Instance.Reload();
				_aiType.Value = CustomConfig.AiType.GetFirst();
				SetNewAiType(_aiType.Value);
				HUDManager.Instance.DisplayTip("Config reloaded", $"Ai defaulted to {_aiType.Value}", false, false, "LC_Tip1");
			}
		}

		private void SetNewAiType(RollingGiantAiType aiType, bool showTip = true)
		{
			RollingGiantAiType value = _aiType.Value;
			_aiType.Value = aiType;
			CustomConfig.SetCurrentAi();
			EmitSharedServerSettingsClientRpc();
			if (Object.op_Implicit((Object)(object)HUDManager.Instance) && value != aiType && showTip)
			{
				HUDManager.Instance.DisplayTip("Rolling Giant AI changed", aiType.ToString(), false, false, "LC_Tip1");
			}
			Plugin.Log.LogMessage((object)$"Rolling Giant AI changed: {aiType}");
		}

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

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_NetworkHandler()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(4257552972u, new RpcReceiveHandler(__rpc_handler_4257552972));
		}

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

		protected internal override string __getTypeName()
		{
			return "NetworkHandler";
		}
	}
	[BepInPlugin("nomnomab.rollinggiant", "Rolling Giant", "2.3.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "nomnomab.rollinggiant";

		public const string PluginName = "Rolling Giant";

		public const string PluginVersion = "2.3.0";

		private const int SaveFileVersion = 5;

		public static string PluginDirectory;

		public static AssetBundle Bundle;

		public static EnemyType EnemyTypeInside;

		public static EnemyType EnemyTypeOutside;

		public static EnemyType EnemyTypeOutsideDaytime;

		public static TerminalNode EnemyTerminalNode;

		public static TerminalKeyword EnemyTerminalKeyword;

		public static AudioClip WalkSound;

		public static AudioClip[] StopSounds;

		public static GameObject PlayerRagdoll;

		public static Item PosterItem;

		public static Material BlackAndWhiteMaterial;

		internal static ManualLogSource Log;

		public static CustomConfig CustomConfig { get; private set; }

		public static ConfigFile Config { get; private set; }

		private void Awake()
		{
			Config = ((BaseUnityPlugin)this).Config;
			Log = ((BaseUnityPlugin)this).Logger;
			PluginDirectory = ((BaseUnityPlugin)this).Info.Location;
			LoadSettings();
			RemoveOldSettings();
			LoadAssets();
			LoadNetWeaver();
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin RollingGiant is loaded!");
		}

		private void LoadNetWeaver()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			foreach (Type type in types)
			{
				try
				{
					MethodInfo[] methods = type.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);
						}
					}
				}
				catch
				{
					Log.LogWarning((object)("NetWeaver is skipping " + type.FullName));
				}
			}
		}

		private void LoadSettings()
		{
			CustomConfig = new CustomConfig(((BaseUnityPlugin)this).Config);
		}

		private void RemoveOldSettings()
		{
			int value = ((BaseUnityPlugin)this).Config.Bind<int>("z_Ignore", "__version", 0, "The version of this config file. Do not change this.").Value;
			if (value != 5)
			{
				Log.LogMessage((object)$"Removing old settings... ({value} != {5})");
				string configFilePath = ((BaseUnityPlugin)this).Config.ConfigFilePath;
				string destFileName = configFilePath + ".bak";
				File.Copy(configFilePath, destFileName, overwrite: true);
				File.WriteAllText(configFilePath, "");
				((BaseUnityPlugin)this).Config.Reload();
				CustomConfig.Reload(setValues: false);
				((BaseUnityPlugin)this).Config.Bind<int>("z_Ignore", "__version", 5, (ConfigDescription)null).Value = 5;
				CustomConfig.AssignFromSaved();
				((BaseUnityPlugin)this).Config.Save();
			}
			else
			{
				Log.LogMessage((object)$"Settings version is up to date ({value} == {5})");
			}
		}

		private void LoadAssets()
		{
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Bundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(PluginDirectory) ?? throw new Exception("Failed to get directory name!"), "rollinggiant"));
				EnemyTypeInside = Bundle.LoadAsset<EnemyType>("Assets/RollingGiant/Data/RollingGiant_EnemyType.asset");
				EnemyTypeOutside = Bundle.LoadAsset<EnemyType>("Assets/RollingGiant/Data/RollingGiant_EnemyType_Outside.asset");
				EnemyTypeOutsideDaytime = Bundle.LoadAsset<EnemyType>("Assets/RollingGiant/Data/RollingGiant_EnemyType_Outside_Daytime.asset");
				EnemyTypeInside.MaxCount = CustomConfig.MaxPerLevel;
				EnemyTypeOutside.MaxCount = CustomConfig.MaxPerLevel;
				EnemyTypeOutsideDaytime.MaxCount = CustomConfig.MaxPerLevel;
				NetworkPatches.RegisterPrefab(EnemyTypeInside.enemyPrefab);
				NetworkPatches.RegisterPrefab(EnemyTypeOutside.enemyPrefab);
				NetworkPatches.RegisterPrefab(EnemyTypeOutsideDaytime.enemyPrefab);
				EnemyTerminalNode = Bundle.LoadAsset<TerminalNode>("Assets/RollingGiant/Data/RollingGiant_TerminalNode.asset");
				EnemyTerminalKeyword = Bundle.LoadAsset<TerminalKeyword>("Assets/RollingGiant/Data/RollingGiant_TerminalKeyword.asset");
			}
			catch (Exception arg)
			{
				Log.LogError((object)$"Failed to load asset bundle! {arg}");
			}
			try
			{
				WalkSound = Bundle.LoadAsset<AudioClip>("Assets/RollingGiant/Audio/MovingLoop.wav");
				StopSounds = (AudioClip[])(object)new AudioClip[5];
				for (int i = 0; i < 5; i++)
				{
					StopSounds[i] = Bundle.LoadAsset<AudioClip>($"Assets/RollingGiant/Audio/Stopped{i + 1}.wav");
				}
				PlayerRagdoll = Bundle.LoadAsset<GameObject>("Assets/RollingGiant/PlayerRagdollRollingGiant Variant.prefab");
				PlayerRagdoll.AddComponent<RollingGiantDeadBody>();
				PosterItem = Bundle.LoadAsset<Item>("Assets/RollingGiant/Data/RollingGiant_PosterItem.asset");
				Item posterItem = PosterItem;
				posterItem.rotationOffset += new Vector3(45f, 0f, 0f);
				Item posterItem2 = PosterItem;
				posterItem2.positionOffset += new Vector3(-0.1f, -0.12f, 0.15f);
				Object.Destroy((Object)(object)PosterItem.spawnPrefab.GetComponent<PhysicsProp>());
				PosterItem.spawnPrefab.AddComponent<Poster>().Init();
				NetworkPatches.RegisterPrefab(PosterItem.spawnPrefab);
				BlackAndWhiteMaterial = Bundle.LoadAsset<Material>("Assets/RollingGiant/Materials/RollingGiant_Gray.mat");
			}
			catch (Exception arg2)
			{
				Log.LogError((object)$"Failed to load assets! {arg2}");
			}
		}
	}
	[Flags]
	public enum RollingGiantAiType
	{
		Coilhead = 1,
		InverseCoilhead = 2,
		RandomlyMoveWhileLooking = 4,
		LookingTooLongKeepsAgro = 8,
		FollowOnceAgro = 0x10,
		OnceSeenAgroAfterTimer = 0x20
	}
	public static class RollingGiantAiTypeExtensions
	{
		public static RollingGiantAiType GetFirst(this RollingGiantAiType aiType)
		{
			RollingGiantAiType[] array = Enum.GetValues(typeof(RollingGiantAiType)).Cast<RollingGiantAiType>().ToArray();
			foreach (RollingGiantAiType rollingGiantAiType in array)
			{
				if ((aiType & rollingGiantAiType) == rollingGiantAiType)
				{
					return rollingGiantAiType;
				}
			}
			return aiType;
		}

		public static RollingGiantAiType GetRandom(this RollingGiantAiType aiType)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			List<RollingGiantAiType> list = default(List<RollingGiantAiType>);
			PooledObject<List<RollingGiantAiType>> val = CollectionPool<List<RollingGiantAiType>, RollingGiantAiType>.Get(ref list);
			try
			{
				RollingGiantAiType[] array = Enum.GetValues(typeof(RollingGiantAiType)).Cast<RollingGiantAiType>().ToArray();
				foreach (RollingGiantAiType rollingGiantAiType in array)
				{
					if ((aiType & rollingGiantAiType) == rollingGiantAiType)
					{
						list.Add(rollingGiantAiType);
					}
				}
				RollingGiantAiType result = aiType;
				if (list.Count > 1)
				{
					result = list[Random.Range(0, list.Count)];
				}
				else if (list.Count == 0)
				{
					result = array[Random.Range(1, array.Length)];
				}
				return result;
			}
			finally
			{
				((IDisposable)val).Dispose();
			}
		}
	}
	public class Poster : PhysicsProp
	{
		public void Init()
		{
			((GrabbableObject)this).grabbable = true;
			((GrabbableObject)this).itemProperties = Plugin.PosterItem;
			((GrabbableObject)this).isInFactory = true;
			((GrabbableObject)this).mainObjectRenderer = ((Component)this).GetComponent<MeshRenderer>();
			((GrabbableObject)this).grabbableToEnemies = true;
		}

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

		protected internal override string __getTypeName()
		{
			return "Poster";
		}
	}
	public class RollingGiantAI : EnemyAI
	{
		private const float ROAMING_AUDIO_PERCENT = 0.4f;

		[SerializeField]
		private AISearchRoutine _searchForPlayers;

		[SerializeField]
		private Collider _mainCollider;

		[SerializeField]
		private AudioClip[] _stopNoises;

		private AudioSource _rollingSFX;

		private NetworkVariable<float> _velocity = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		private float _timeSinceHittingPlayer;

		private bool _wantsToChaseThisClient;

		private bool _hasEnteredChaseState;

		private bool _wasStopped;

		private bool _wasFeared;

		private bool _isAgro;

		private float _lastSpeed;

		private float _audioFade;

		private float _waitTimer;

		private float _moveTimer;

		private float _lookTimer;

		private float _agroTimer;

		private float _springVelocity;

		private static SharedAiSettings _sharedAiSettings => CustomConfig.SharedAiSettings;

		private static float NextDouble()
		{
			if (!Object.op_Implicit((Object)(object)RoundManager.Instance) || RoundManager.Instance.LevelRandom == null)
			{
				return Random.value;
			}
			return (float)RoundManager.Instance.LevelRandom.NextDouble();
		}

		public override void Start()
		{
			((EnemyAI)this).Start();
			Init();
			if (((NetworkBehaviour)this).IsHost || ((NetworkBehaviour)this).IsOwner)
			{
				AssignInitData_LocalClient();
			}
			Plugin.Log.LogInfo((object)$"Rolling giant spawned with ai type: {NetworkHandler.AiType}, owner? {((NetworkBehaviour)this).IsOwner}");
		}

		private void Init()
		{
			base.agent = ((Component)this).gameObject.GetComponentInChildren<NavMeshAgent>();
			_rollingSFX = ((Component)((Component)this).transform.Find("RollingSFX")).GetComponent<AudioSource>();
			AudioMixerGroup outputAudioMixerGroup = SoundManager.Instance.diageticMixer.outputAudioMixerGroup;
			_rollingSFX.outputAudioMixerGroup = outputAudioMixerGroup;
			base.creatureVoice.outputAudioMixerGroup = outputAudioMixerGroup;
			base.creatureSFX.outputAudioMixerGroup = outputAudioMixerGroup;
			_rollingSFX.loop = true;
			_rollingSFX.clip = Plugin.WalkSound;
			float time = NextDouble() * Plugin.WalkSound.length;
			float pitch = Mathf.Lerp(0.96f, 1.05f, NextDouble());
			_rollingSFX.time = time;
			_rollingSFX.pitch = pitch;
			_rollingSFX.volume = 0f;
			_rollingSFX.Play();
		}

		public override void DaytimeEnemyLeave()
		{
			((EnemyAI)this).DaytimeEnemyLeave();
			Renderer[] componentsInChildren = ((Component)((Component)this).transform).GetComponentsInChildren<Renderer>();
			foreach (Renderer val in componentsInChildren)
			{
				if (!(((Object)val).name == "object_3"))
				{
					val.sharedMaterial = Plugin.BlackAndWhiteMaterial;
				}
			}
			_mainCollider.isTrigger = true;
		}

		public override void DoAIInterval()
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			if (base.daytimeEnemyLeaving)
			{
				_mainCollider.isTrigger = true;
				return;
			}
			((EnemyAI)this).DoAIInterval();
			if (StartOfRound.Instance.livingPlayers == 0 || base.isEnemyDead)
			{
				return;
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
			{
				if (!((NetworkBehaviour)this).IsServer)
				{
					((EnemyAI)this).ChangeOwnershipOfEnemy(StartOfRound.Instance.allPlayerScripts[0].actualClientId);
					break;
				}
				for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
				{
					PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[i];
					if (((EnemyAI)this).PlayerIsTargetable(val, false, base.isOutside) && !Physics.Linecast(((Component)this).transform.position + Vector3.up * 0.5f, ((Component)val.gameplayCamera).transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault) && (double)Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position) < 30.0)
					{
						((EnemyAI)this).SwitchToBehaviourState(1);
						return;
					}
				}
				if (!_searchForPlayers.inProgress)
				{
					((EnemyAI)this).StartSearch(((Component)this).transform.position, _searchForPlayers);
				}
				break;
			}
			case 1:
				if (!TargetClosestPlayer())
				{
					base.movingTowardsTargetPlayer = false;
					if (!_searchForPlayers.inProgress)
					{
						((EnemyAI)this).SwitchToBehaviourState(0);
						((EnemyAI)this).ChangeOwnershipOfEnemy(StartOfRound.Instance.allPlayerScripts[0].actualClientId);
					}
				}
				else if (_searchForPlayers.inProgress)
				{
					((EnemyAI)this).StopSearch(_searchForPlayers, true);
					base.movingTowardsTargetPlayer = true;
				}
				break;
			}
		}

		public override void Update()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_03be: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0401: Unknown result type (might be due to invalid IL or missing references)
			//IL_0406: Unknown result type (might be due to invalid IL or missing references)
			//IL_0418: Unknown result type (might be due to invalid IL or missing references)
			if (base.daytimeEnemyLeaving)
			{
				_mainCollider.isTrigger = true;
				return;
			}
			Vector3 velocity2;
			if (((NetworkBehaviour)this).IsHost || ((NetworkBehaviour)this).IsServer)
			{
				NetworkVariable<float> velocity = _velocity;
				velocity2 = base.agent.velocity;
				velocity.Value = ((Vector3)(ref velocity2)).magnitude;
			}
			((EnemyAI)this).Update();
			if (base.isEnemyDead)
			{
				return;
			}
			velocity2 = base.agent.velocity;
			_lastSpeed = ((Vector3)(ref velocity2)).magnitude;
			CalculateAgentSpeed();
			_timeSinceHittingPlayer += Time.deltaTime;
			_mainCollider.isTrigger = !_wasStopped;
			float value = _velocity.Value;
			_rollingSFX.volume = Mathf.Lerp(0f, Mathf.Clamp01(0.4f * value + 0.05f), value / _sharedAiSettings.moveSpeed);
			GameNetworkManager instance = GameNetworkManager.Instance;
			PlayerControllerB localPlayerController = instance.localPlayerController;
			if (_wasStopped && !_wasFeared && localPlayerController.HasLineOfSightToPosition(base.eye.position, 70f, 25, -1f))
			{
				_wasFeared = true;
				float num = Vector3.Distance(((Component)this).transform.position, ((Component)localPlayerController).transform.position);
				if (num < 4f)
				{
					instance.localPlayerController.JumpToFearLevel(0.9f, true);
				}
				else if (num < 9f)
				{
					instance.localPlayerController.JumpToFearLevel(0.4f, true);
				}
				if (_lastSpeed > 1f)
				{
					RoundManager.PlayRandomClip(base.creatureVoice, _stopNoises, false, 1f, 0);
				}
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				if (_hasEnteredChaseState)
				{
					_hasEnteredChaseState = false;
					_wantsToChaseThisClient = false;
					_wasStopped = false;
					_wasFeared = false;
					_isAgro = false;
					_agroTimer = 0f;
					_waitTimer = 0f;
					_moveTimer = 0f;
					_lookTimer = 0f;
					_springVelocity = 0f;
					base.agent.stoppingDistance = 0f;
					base.agent.speed = _sharedAiSettings.moveSpeed;
					base.agent.acceleration = 200f;
				}
				if (((NetworkBehaviour)this).IsOwner && TargetClosestPlayer(1.5f, requireLineOfSight: true) && (Object)(object)base.targetPlayer == (Object)(object)localPlayerController && !_wantsToChaseThisClient)
				{
					_wantsToChaseThisClient = true;
					BeginChasingPlayer_ServerRpc((int)base.targetPlayer.playerClientId);
					((EnemyAI)this).ChangeOwnershipOfEnemy(base.targetPlayer.actualClientId);
				}
				break;
			case 1:
			{
				if (!_hasEnteredChaseState)
				{
					_hasEnteredChaseState = true;
					_wantsToChaseThisClient = false;
					_wasStopped = false;
					_wasFeared = false;
					_isAgro = false;
					_agroTimer = 0f;
					_waitTimer = 0f;
					_moveTimer = 0f;
					_lookTimer = 0f;
					_springVelocity = 0f;
					base.agent.stoppingDistance = 0f;
					base.agent.speed = 0f;
					base.agent.acceleration = 200f;
				}
				if (base.stunNormalizedTimer > 0f)
				{
					break;
				}
				PlayerControllerB targetPlayer = base.targetPlayer;
				if (((NetworkBehaviour)this).IsOwner)
				{
					if (!TargetClosestPlayer())
					{
						EndChasingPlayer_ServerRpc();
						break;
					}
					if (_wasStopped && _sharedAiSettings.rotateToLookAtPlayer)
					{
						if (_lookTimer >= _sharedAiSettings.delayBeforeLookingAtPlayer)
						{
							Vector3 position = ((Component)base.targetPlayer).transform.position;
							Vector3 position2 = ((Component)this).transform.position;
							Vector3 val = position - position2;
							val.y = 0f;
							((Vector3)(ref val)).Normalize();
							Quaternion val2 = Quaternion.LookRotation(val);
							((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, val2, Time.deltaTime / _sharedAiSettings.lookAtPlayerDuration);
						}
					}
					else if (!_wasStopped)
					{
						_ = _sharedAiSettings.rotateToLookAtPlayer;
					}
				}
				RollingGiantAiType aiType = NetworkHandler.AiType;
				PlayerControllerB closestPlayer;
				switch (aiType)
				{
				case RollingGiantAiType.Coilhead:
					if (AmIBeingLookedAt(out closestPlayer))
					{
						_wasStopped = true;
						return;
					}
					break;
				case RollingGiantAiType.InverseCoilhead:
					if (!AmIBeingLookedAt(out closestPlayer) && _isAgro)
					{
						_wasStopped = true;
						return;
					}
					break;
				case RollingGiantAiType.RandomlyMoveWhileLooking:
					if (AmIBeingLookedAt(out closestPlayer) && _moveTimer <= 0f)
					{
						_wasStopped = true;
						return;
					}
					break;
				case RollingGiantAiType.LookingTooLongKeepsAgro:
					if (AmIBeingLookedAt(out closestPlayer) && _agroTimer < _sharedAiSettings.lookTimeBeforeAgro)
					{
						_wasStopped = true;
						return;
					}
					break;
				case RollingGiantAiType.OnceSeenAgroAfterTimer:
					if (_isAgro && _waitTimer >= 0f)
					{
						_wasStopped = true;
						return;
					}
					break;
				default:
					Plugin.Log.LogWarning((object)$"Unknown ai type: {aiType}");
					break;
				case RollingGiantAiType.FollowOnceAgro:
					break;
				}
				_wasStopped = false;
				_wasFeared = false;
				if (((NetworkBehaviour)this).IsOwner && !((Object)(object)targetPlayer == (Object)(object)base.targetPlayer) && !((Object)(object)base.targetPlayer != (Object)(object)localPlayerController))
				{
					((EnemyAI)this).SetMovingTowardsTargetPlayer(base.targetPlayer);
					((EnemyAI)this).ChangeOwnershipOfEnemy(base.targetPlayer.actualClientId);
				}
				break;
			}
			}
		}

		public bool TargetClosestPlayer(float bufferDistance = 1.5f, bool requireLineOfSight = false, float viewWidth = 70f)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			base.mostOptimalDistance = 2000f;
			PlayerControllerB targetPlayer = base.targetPlayer;
			base.targetPlayer = null;
			for (int i = 0; i < StartOfRound.Instance.connectedPlayersAmount + 1; i++)
			{
				PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[i];
				if (((EnemyAI)this).PlayerIsTargetable(val, false, base.isOutside) && !((EnemyAI)this).PathIsIntersectedByLineOfSight(((Component)val).transform.position, false, false) && (!requireLineOfSight || ((EnemyAI)this).HasLineOfSightToPosition(((Component)val.gameplayCamera).transform.position, viewWidth, 40, -1f)))
				{
					base.tempDist = Vector3.Distance(((Component)this).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position);
					if ((double)base.tempDist < (double)base.mostOptimalDistance)
					{
						base.mostOptimalDistance = base.tempDist;
						base.targetPlayer = StartOfRound.Instance.allPlayerScripts[i];
					}
				}
			}
			if (Object.op_Implicit((Object)(object)base.targetPlayer) && (double)bufferDistance > 0.0 && Object.op_Implicit((Object)(object)targetPlayer) && (double)Mathf.Abs(base.mostOptimalDistance - Vector3.Distance(((Component)this).transform.position, ((Component)targetPlayer).transform.position)) < (double)bufferDistance)
			{
				base.targetPlayer = targetPlayer;
			}
			return Object.op_Implicit((Object)(object)base.targetPlayer);
		}

		private static float SmoothLerp(float a, float b, float t)
		{
			return a + t * t * (b - a);
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			if (base.daytimeEnemyLeaving)
			{
				return;
			}
			((EnemyAI)this).OnCollideWithPlayer(other);
			if (!(_timeSinceHittingPlayer < 0.6f))
			{
				PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
				if (Object.op_Implicit((Object)(object)val))
				{
					_timeSinceHittingPlayer = 0.2f;
					int num = StartOfRound.Instance.playerRagdolls.IndexOf(Plugin.PlayerRagdoll);
					val.DamagePlayer(90, true, true, (CauseOfDeath)4, num, false, default(Vector3));
					base.agent.speed = 0f;
					GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(1f, true);
				}
			}
		}

		private void CalculateAgentSpeed()
		{
			if (base.stunNormalizedTimer >= 0f)
			{
				base.agent.speed = 0f;
				base.agent.acceleration = 200f;
			}
			else if (base.currentBehaviourStateIndex == 0)
			{
				base.agent.speed = ((_sharedAiSettings.moveAcceleration == 0f) ? _sharedAiSettings.moveSpeed : Mathf.Lerp(base.agent.speed, _sharedAiSettings.moveSpeed, Time.deltaTime / _sharedAiSettings.moveAcceleration));
				base.agent.acceleration = 200f;
			}
			else
			{
				if (base.currentBehaviourStateIndex != 1)
				{
					return;
				}
				if (!IsAgentOnNavMesh(((Component)base.agent).gameObject))
				{
					MoveAccelerate();
					return;
				}
				PlayerControllerB closestPlayer;
				bool flag = AmIBeingLookedAt(out closestPlayer);
				if (flag)
				{
					_lookTimer += Time.deltaTime;
				}
				else
				{
					_lookTimer = 0f;
				}
				RollingGiantAiType aiType = NetworkHandler.AiType;
				switch (aiType)
				{
				case RollingGiantAiType.Coilhead:
					if (flag)
					{
						MoveDecelerate();
					}
					else
					{
						MoveAccelerate();
					}
					break;
				case RollingGiantAiType.InverseCoilhead:
					if (!flag && _isAgro)
					{
						MoveDecelerate();
						break;
					}
					MoveAccelerate();
					_isAgro = true;
					break;
				case RollingGiantAiType.RandomlyMoveWhileLooking:
					if (flag)
					{
						if (_waitTimer <= 0f && _moveTimer <= 0f)
						{
							GenerateWaitTime_LocalClient();
						}
						if (_waitTimer > 0f && _moveTimer <= 0f)
						{
							MoveDecelerate();
							_waitTimer -= Time.deltaTime;
							if (_waitTimer <= 0f)
							{
								GenerateMoveTime_LocalClient();
							}
							break;
						}
					}
					MoveAccelerate();
					if (_moveTimer > 0f)
					{
						_moveTimer -= Time.deltaTime;
						if (_moveTimer <= 0f)
						{
							GenerateWaitTime_LocalClient();
						}
					}
					break;
				case RollingGiantAiType.LookingTooLongKeepsAgro:
					if (!_isAgro)
					{
						if (flag)
						{
							_agroTimer = Mathf.SmoothDamp(_agroTimer, _sharedAiSettings.lookTimeBeforeAgro + 0.5f, ref _springVelocity, 0.5f);
							if (_agroTimer >= _sharedAiSettings.lookTimeBeforeAgro)
							{
								_isAgro = true;
							}
							MoveDecelerate();
						}
						else
						{
							_agroTimer = Mathf.Lerp(_agroTimer, 0f, Time.deltaTime / (_sharedAiSettings.lookTimeBeforeAgro / 2f));
						}
					}
					else
					{
						MoveAccelerate();
					}
					break;
				case RollingGiantAiType.FollowOnceAgro:
					if (!_isAgro && flag)
					{
						_isAgro = true;
						MoveDecelerate();
					}
					else
					{
						MoveAccelerate();
					}
					break;
				case RollingGiantAiType.OnceSeenAgroAfterTimer:
					if (!_isAgro)
					{
						if (flag)
						{
							_isAgro = true;
							GenerateWaitTime_LocalClient();
							MoveDecelerate();
						}
					}
					else if (_waitTimer >= 0f)
					{
						_waitTimer -= Time.deltaTime;
						_ = _waitTimer;
						_ = 0f;
						MoveDecelerate();
					}
					else
					{
						MoveAccelerate();
					}
					break;
				default:
					Plugin.Log.LogWarning((object)$"Unknown ai type: {aiType}");
					break;
				}
			}
		}

		private void MoveAccelerate()
		{
			base.agent.speed = ((_sharedAiSettings.moveAcceleration == 0f) ? _sharedAiSettings.moveSpeed : Mathf.Lerp(base.agent.speed, _sharedAiSettings.moveSpeed, Time.deltaTime / _sharedAiSettings.moveAcceleration));
			base.agent.acceleration = Mathf.Lerp(base.agent.acceleration, 200f, Time.deltaTime);
		}

		private void MoveDecelerate()
		{
			base.agent.speed = ((_sharedAiSettings.moveDeceleration == 0f) ? 0f : Mathf.Lerp(base.agent.speed, 0f, Time.deltaTime / _sharedAiSettings.moveDeceleration));
			base.agent.acceleration = 200f;
		}

		private bool AmIBeingLookedAt(out PlayerControllerB closestPlayer)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			float num = float.MaxValue;
			closestPlayer = null;
			PlayerControllerB[] array = allPlayerScripts;
			foreach (PlayerControllerB val in array)
			{
				if (((EnemyAI)this).PlayerIsTargetable(val, false, base.isOutside) && val.HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up * 1.6f, 68f, 60, -1f))
				{
					float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position);
					if (num2 < num)
					{
						num = num2;
						closestPlayer = val;
					}
				}
			}
			return Object.op_Implicit((Object)(object)closestPlayer);
		}

		private bool IsAgentOnNavMesh(GameObject agentObject)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = agentObject.transform.position;
			NavMeshHit val = default(NavMeshHit);
			if (NavMesh.SamplePosition(position, ref val, 3f, -1) && Mathf.Approximately(position.x, ((NavMeshHit)(ref val)).position.x) && Mathf.Approximately(position.z, ((NavMeshHit)(ref val)).position.z))
			{
				return position.y >= ((NavMeshHit)(ref val)).position.y;
			}
			return false;
		}

		[ServerRpc(RequireOwnership = false)]
		private void BeginChasingPlayer_ServerRpc(int playerId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(913739805u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 913739805u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					BeginChasingPlayer_ClientRpc(playerId);
				}
			}
		}

		[ClientRpc]
		private void BeginChasingPlayer_ClientRpc(int playerId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2111596117u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2111596117u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(1);
					PlayerControllerB movingTowardsTargetPlayer = StartOfRound.Instance.allPlayerScripts[playerId];
					((EnemyAI)this).SetMovingTowardsTargetPlayer(movingTowardsTargetPlayer);
				}
			}
		}

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

		[ClientRpc]
		private void EndChasingPlayer_ClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1947504516u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1947504516u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					base.moveTowardsDestination = false;
					base.movingTowardsTargetPlayer = false;
					((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(0);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void GenerateWaitTime_ServerRpc(float waitTime)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2506095827u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref waitTime, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2506095827u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					_waitTimer = waitTime;
				}
			}
		}

		private void GenerateWaitTime_LocalClient()
		{
			GenerateWaitTime_ServerRpc(_waitTimer = Mathf.Lerp(_sharedAiSettings.waitTimeMin, _sharedAiSettings.waitTimeMax, NextDouble()));
		}

		[ServerRpc(RequireOwnership = false)]
		private void GenerateMoveTime_ServerRpc(float moveTime)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2605455828u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref moveTime, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2605455828u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					_moveTimer = moveTime;
					GenerateMoveTime_ClientRpc(moveTime);
				}
			}
		}

		private void GenerateMoveTime_LocalClient()
		{
			GenerateMoveTime_ServerRpc(_moveTimer = Mathf.Lerp(_sharedAiSettings.randomMoveTimeMin, _sharedAiSettings.randomMoveTimeMax, NextDouble()));
		}

		[ClientRpc]
		private void GenerateMoveTime_ClientRpc(float moveTime)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4167209315u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref moveTime, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4167209315u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					_moveTimer = moveTime;
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void AssignInitData_ServerRpc(float scale)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2584131514u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref scale, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2584131514u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((Component)base.agent).transform.localScale = Vector3.one * scale;
					AssignInitData_ClientRpc(scale);
				}
			}
		}

		private void AssignInitData_LocalClient()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			CustomConfig instance = SyncedInstance<CustomConfig>.Instance;
			float num = Mathf.Lerp(instance.GiantScaleMin, instance.GiantScaleMax, NextDouble());
			((Component)base.agent).transform.localScale = Vector3.one * num;
			AssignInitData_ServerRpc(num);
		}

		[ClientRpc]
		private void AssignInitData_ClientRpc(float scale)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3644677666u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref scale, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3644677666u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					Init();
					((Component)base.agent).transform.localScale = Vector3.one * scale;
				}
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_RollingGiantAI()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(913739805u, new RpcReceiveHandler(__rpc_handler_913739805));
			NetworkManager.__rpc_func_table.Add(2111596117u, new RpcReceiveHandler(__rpc_handler_2111596117));
			NetworkManager.__rpc_func_table.Add(3771085912u, new RpcReceiveHandler(__rpc_handler_3771085912));
			NetworkManager.__rpc_func_table.Add(1947504516u, new RpcReceiveHandler(__rpc_handler_1947504516));
			NetworkManager.__rpc_func_table.Add(2506095827u, new RpcReceiveHandler(__rpc_handler_2506095827));
			NetworkManager.__rpc_func_table.Add(2605455828u, new RpcReceiveHandler(__rpc_handler_2605455828));
			NetworkManager.__rpc_func_table.Add(4167209315u, new RpcReceiveHandler(__rpc_handler_4167209315));
			NetworkManager.__rpc_func_table.Add(2584131514u, new RpcReceiveHandler(__rpc_handler_2584131514));
			NetworkManager.__rpc_func_table.Add(3644677666u, new RpcReceiveHandler(__rpc_handler_3644677666));
		}

		private static void __rpc_handler_913739805(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int playerId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((RollingGiantAI)(object)target).BeginChasingPlayer_ServerRpc(playerId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2111596117(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int playerId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((RollingGiantAI)(object)target).BeginChasingPlayer_ClientRpc(playerId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

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

		private static void __rpc_handler_2506095827(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				float waitTime = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref waitTime, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((RollingGiantAI)(object)target).GenerateWaitTime_ServerRpc(waitTime);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2605455828(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				float moveTime = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref moveTime, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((RollingGiantAI)(object)target).GenerateMoveTime_ServerRpc(moveTime);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_4167209315(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				float moveTime = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref moveTime, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((RollingGiantAI)(object)target).GenerateMoveTime_ClientRpc(moveTime);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2584131514(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				float scale = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref scale, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((RollingGiantAI)(object)target).AssignInitData_ServerRpc(scale);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3644677666(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				float scale = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref scale, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((RollingGiantAI)(object)target).AssignInitData_ClientRpc(scale);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "RollingGiantAI";
		}
	}
	public class RollingGiantDeadBody : MonoBehaviour
	{
	}
	public static class Utility
	{
		public static object InvokeNotOverride(this MethodInfo methodInfo, object targetObject, params object[] arguments)
		{
			ParameterInfo[] parameters = methodInfo.GetParameters();
			if (parameters.Length == 0)
			{
				if (arguments != null && arguments.Length != 0)
				{
					throw new Exception("Arguments cont doesn't match");
				}
			}
			else if (parameters.Length != arguments.Length)
			{
				throw new Exception("Arguments cont doesn't match");
			}
			Type returnType = null;
			if (methodInfo.ReturnType != typeof(void))
			{
				returnType = methodInfo.ReturnType;
			}
			Type type = targetObject.GetType();
			DynamicMethod dynamicMethod = new DynamicMethod("", returnType, new Type[2]
			{
				type,
				typeof(object)
			}, type);
			ILGenerator iLGenerator = dynamicMethod.GetILGenerator();
			iLGenerator.Emit(OpCodes.Ldarg_0);
			for (int i = 0; i < parameters.Length; i++)
			{
				ParameterInfo obj = parameters[i];
				iLGenerator.Emit(OpCodes.Ldarg_1);
				iLGenerator.Emit(OpCodes.Ldc_I4_S, i);
				iLGenerator.Emit(OpCodes.Ldelem_Ref);
				Type parameterType = obj.ParameterType;
				if (parameterType.IsPrimitive)
				{
					iLGenerator.Emit(OpCodes.Unbox_Any, parameterType);
				}
				else if (!(parameterType == typeof(object)))
				{
					iLGenerator.Emit(OpCodes.Castclass, parameterType);
				}
			}
			iLGenerator.Emit(OpCodes.Call, methodInfo);
			iLGenerator.Emit(OpCodes.Ret);
			return dynamicMethod.Invoke(null, new object[2] { targetObject, arguments });
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "RollingGiant";

		public const string PLUGIN_NAME = "RollingGiant";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace RollingGiant.Settings
{
	public struct SharedAiSettings : INetworkSerializable
	{
		public float moveSpeed;

		public float moveAcceleration;

		public float moveDeceleration;

		public bool rotateToLookAtPlayer;

		public float delayBeforeLookingAtPlayer;

		public float lookAtPlayerDuration;

		public float waitTimeMin;

		public float waitTimeMax;

		public float randomMoveTimeMin;

		public float randomMoveTimeMax;

		public float lookTimeBeforeAgro;

		public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
			((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref moveSpeed, default(ForPrimitives));
			((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref moveAcceleration, default(ForPrimitives));
			((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref moveDeceleration, default(ForPrimitives));
			((BufferSerializer<bool>*)(&serializer))->SerializeValue<bool>(ref rotateToLookAtPlayer, default(ForPrimitives));
			((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref delayBeforeLookingAtPlayer, default(ForPrimitives));
			((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref lookAtPlayerDuration, default(ForPrimitives));
			((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref waitTimeMin, default(ForPrimitives));
			((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref waitTimeMax, default(ForPrimitives));
			((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref randomMoveTimeMin, default(ForPrimitives));
			((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref randomMoveTimeMax, default(ForPrimitives));
			((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref lookTimeBeforeAgro, default(ForPrimitives));
		}

		public override string ToString()
		{
			return $"moveSpeed: {moveSpeed}, moveAcceleration: {moveAcceleration}, moveDeceleration: {moveDeceleration}, rotateToLookAtPlayer: {rotateToLookAtPlayer}, delayBeforeLookingAtPlayer: {delayBeforeLookingAtPlayer}, lookAtPlayerDuration: {lookAtPlayerDuration}, waitTimeMin: {waitTimeMin}, waitTimeMax: {waitTimeMax}, randomMoveTimeMin: {randomMoveTimeMin}, randomMoveTimeMax: {randomMoveTimeMax}, lookTimeBeforeAgro: {lookTimeBeforeAgro}";
		}
	}
	[Serializable]
	public class CustomConfig : SyncedInstance<CustomConfig>
	{
		public const string ROLLINGGIANT_ONREQUESTCONFIGSYNC = "RollingGiant_OnRequestConfigSync";

		public const string ROLLINGGIANT_ONRECEIVECONFIGSYNC = "RollingGiant_OnReceiveConfigSync";

		private static ConfigFile _config;

		public const string Name1 = "1. General Settings";

		public const string Name2 = "2. AI Settings";

		public const string AiTypeDescription = "The AI type of the Rolling Giant.\n- Putting multiple will randomly choose between them each time you land on a moon\nCoilhead = Coilhead AI\nInverseCoilhead = Move when player is looking at it\nRandomlyMoveWhileLooking = Randomly move while the player is looking at it\nLookingTooLongKeepsAgro = If the player looks at it for too long it doesn't stop chasing\nFollowOnceAgro = Once the player is noticed, the Rolling Giant will follow the player constantly\nOnceSeenAgroAfterTimer = Once the player sees the Rolling Giant, it will chase the player after a timer";

		public const string MoveSpeedDescription = "The speed of the Rolling Giant in m/s².";

		public const string MoveAccelerationDescription = "How long it takes the Rolling Giant to get to its movement speed. in seconds";

		public const string MoveDecelerationDescription = "How long it takes the Rolling Giant to stop moving in seconds.";

		public const string RotateToLookAtPlayerDescription = "If the Rolling Giant should rotate to look at the player.";

		public const string DelayBeforeLookingAtPlayerDescription = "The delay before the Rolling Giant looks at the player in seconds.";

		public const string LookAtPlayerDurationDescription = "The duration the Rolling Giant looks at the player in seconds.";

		public static SharedAiSettings SharedAiSettings { get; private set; }

		public static ConfigEntry<string> GotoPreviousAiTypeKey { get; private set; }

		public static ConfigEntry<string> GotoNextAiTypeKey { get; private set; }

		public static ConfigEntry<string> ReloadConfigKey { get; private set; }

		public static ConfigEntry<string> SpawnInEntry { get; private set; }

		public static ConfigEntry<bool> SpawnInAnyEntry { get; private set; }

		public static ConfigEntry<int> SpawnInAnyChanceEntry { get; private set; }

		public static ConfigEntry<bool> CanSpawnInsideEntry { get; private set; }

		public static ConfigEntry<bool> CanSpawnOutsideEntry { get; private set; }

		public static ConfigEntry<bool> DisableOutsideAtNightEntry { get; private set; }

		public static ConfigEntry<int> MaxPerLevelEntry { get; private set; }

		public static ConfigEntry<string> SpawnPosterInEntry { get; private set; }

		public float GiantScaleMin { get; private set; }

		public float GiantScaleMax { get; private set; }

		public static string SpawnIn { get; private set; }

		public static bool SpawnInAny { get; private set; }

		public static int SpawnInAnyChance { get; private set; }

		public static bool CanSpawnInside { get; private set; }

		public static bool CanSpawnOutside { get; private set; }

		public static bool DisableOutsideAtNight { get; private set; }

		public static int MaxPerLevel { get; private set; }

		public static string SpawnPosterIn { get; private set; }

		public static RollingGiantAiType AiType { get; internal set; }

		public float MoveSpeed { get; private set; }

		public float MoveAcceleration { get; private set; }

		public float MoveDeceleration { get; private set; }

		public bool RotateToLookAtPlayer { get; private set; }

		public float DelayBeforeLookingAtPlayer { get; private set; }

		public float LookAtPlayerDuration { get; private set; }

		public float RandomlyMoveWhenLooking_WaitTimeMin { get; private set; }

		public float RandomlyMoveWhenLooking_WaitTimeMax { get; private set; }

		public float RandomlyMoveWhenLooking_RandomMoveTimeMin { get; private set; }

		public float RandomlyMoveWhenLooking_RandomMoveTimeMax { get; private set; }

		public float LookingTooLongKeepsAgro_LookTimeBeforeAgro { get; private set; }

		public float OnceSeenAgroAfterTimer_WaitTimeMin { get; private set; }

		public float OnceSeenAgroAfterTimer_WaitTimeMax { get; private set; }

		public static ConfigEntry<float> GiantScaleMinEntry { get; private set; }

		public static ConfigEntry<float> GiantScaleMaxEntry { get; private set; }

		public static ConfigEntry<RollingGiantAiType> AiTypeEntry { get; private set; }

		public static ConfigEntry<float> MoveSpeedEntry { get; private set; }

		public static ConfigEntry<float> MoveAccelerationEntry { get; private set; }

		public static ConfigEntry<float> MoveDecelerationEntry { get; private set; }

		public static ConfigEntry<bool> RotateToLookAtPlayerEntry { get; private set; }

		public static ConfigEntry<float> DelayBeforeLookingAtPlayerEntry { get; private set; }

		public static ConfigEntry<float> LookAtPlayerDurationEntry { get; private set; }

		public static ConfigEntry<float> RandomlyMoveWhenLooking_WaitTimeMinEntry { get; private set; }

		public static ConfigEntry<float> RandomlyMoveWhenLooking_WaitTimeMaxEntry { get; private set; }

		public static ConfigEntry<float> RandomlyMoveWhenLooking_RandomMoveTimeMinEntry { get; private set; }

		public static ConfigEntry<float> RandomlyMoveWhenLooking_RandomMoveTimeMaxEntry { get; private set; }

		public static ConfigEntry<float> LookingTooLongKeepsAgro_LookTimeBeforeAgroEntry { get; private set; }

		public static ConfigEntry<float> OnceSeenAgroAfterTimer_WaitTimeMinEntry { get; private set; }

		public static ConfigEntry<float> OnceSeenAgroAfterTimer_WaitTimeMaxEntry { get; private set; }

		public CustomConfig(ConfigFile config)
		{
			_config = config;
			InitInstance(this);
			Reload();
		}

		public void Save()
		{
			if (_config == null)
			{
				throw new NullReferenceException("Config is null.");
			}
			_config.Save();
		}

		public void AssignFromSaved()
		{
			GiantScaleMinEntry.Value = GiantScaleMin;
			GiantScaleMaxEntry.Value = GiantScaleMax;
			SpawnInEntry.Value = SpawnIn;
			SpawnInAnyEntry.Value = SpawnInAny;
			SpawnInAnyChanceEntry.Value = SpawnInAnyChance;
			CanSpawnInsideEntry.Value = CanSpawnInside;
			CanSpawnOutsideEntry.Value = CanSpawnOutside;
			DisableOutsideAtNightEntry.Value = DisableOutsideAtNight;
			MaxPerLevelEntry.Value = MaxPerLevel;
			SpawnPosterInEntry.Value = SpawnPosterIn;
			AiTypeEntry.Value = AiType;
			MoveSpeedEntry.Value = MoveSpeed;
			MoveAccelerationEntry.Value = MoveAcceleration;
			MoveDecelerationEntry.Value = MoveDeceleration;
			RotateToLookAtPlayerEntry.Value = RotateToLookAtPlayer;
			DelayBeforeLookingAtPlayerEntry.Value = DelayBeforeLookingAtPlayer;
			LookAtPlayerDurationEntry.Value = LookAtPlayerDuration;
			RandomlyMoveWhenLooking_WaitTimeMinEntry.Value = RandomlyMoveWhenLooking_WaitTimeMin;
			RandomlyMoveWhenLooking_WaitTimeMaxEntry.Value = RandomlyMoveWhenLooking_WaitTimeMax;
			RandomlyMoveWhenLooking_RandomMoveTimeMinEntry.Value = RandomlyMoveWhenLooking_RandomMoveTimeMin;
			RandomlyMoveWhenLooking_RandomMoveTimeMaxEntry.Value = RandomlyMoveWhenLooking_RandomMoveTimeMax;
			LookingTooLongKeepsAgro_LookTimeBeforeAgroEntry.Value = LookingTooLongKeepsAgro_LookTimeBeforeAgro;
			OnceSeenAgroAfterTimer_WaitTimeMinEntry.Value = OnceSeenAgroAfterTimer_WaitTimeMin;
			OnceSeenAgroAfterTimer_WaitTimeMaxEntry.Value = OnceSeenAgroAfterTimer_WaitTimeMax;
		}

		public void Reload(bool setValues = true)
		{
			GiantScaleMinEntry = _config.Bind<float>("1. General Settings", "GiantScaleMin", 0.9f, "The minimum scale of the Rolling Giant.\nThis changes how small the Giant can be.\nThis is a multiplier, so 0.5 is half as large.");
			GiantScaleMaxEntry = _config.Bind<float>("1. General Settings", "GiantScaleMax", 1.1f, "The maximum scale of the Rolling Giant.\nThis changes how big the Giant can be.\nThis is a multiplier, so 2 is twice as large.");
			SpawnInEntry = _config.Bind<string>("1. General Settings", "SpawnIn", "Vow:45,March:45,Rend:54,Dine:65,Offense:45,Titan:65", "Where the Rolling Giant can spawn.\nSeparate each level with a comma, and put a chance (no decimals) separated by a colon.\nVanilla caps at 100, but you can go farther.\nThis chance is also a weight, not a percentage.\nHigher chance = higher chance to get picked\nThe names are what you see in the terminal\nExample: Vow:6,March:10");
			SpawnInAnyEntry = _config.Bind<bool>("1. General Settings", "SpawnInAny", false, "If the Rolling Giant can spawn in any level.");
			SpawnInAnyChanceEntry = _config.Bind<int>("1. General Settings", "SpawnInAnyChance", 45, "The chance for the Rolling Giant to spawn in any level.\nRequires SpawnInAny to be enabled!\nThis is a weight, not a percentage.\nHigher chance = higher chance to get picked");
			CanSpawnInsideEntry = _config.Bind<bool>("1. General Settings", "CanSpawnInside", true, "If the Rolling Giant can spawn inside.");
			CanSpawnOutsideEntry = _config.Bind<bool>("1. General Settings", "CanSpawnOutside", false, "If the Rolling Giant can spawn outside.");
			DisableOutsideAtNightEntry = _config.Bind<bool>("1. General Settings", "DisableOutsideAtNight", false, "If the Rolling Giant will turn off if it is outside at night.");
			MaxPerLevelEntry = _config.Bind<int>("1. General Settings", "MaxPerLevel", 3, "The maximum amount of Rolling Giants that can spawn in a level.");
			SpawnPosterInEntry = _config.Bind<string>("1. General Settings", "SpawnPosterIn", "Vow:12,March:12,Rend:12,Dine:12,Offense:12,Titan:12", "Where the Rolling Giant poster scrap can spawn.\nSeparate each level with a comma, and put a chance separated by a colon.\nVanilla caps at 100, but you can go farther.\nThis chance is also a weight, not a percentage.\nHigher chance = higher chance to get picked\nThe names are what you see in the terminal\nExample: Vow:12,March:12,Rend:12,Dine:12,Offense:12,Titan:12");
			if (GotoPreviousAiTypeKey == null)
			{
				GotoPreviousAiTypeKey = _config.Bind<string>("Host", "GotoPreviousAiTypeKey", "<Keyboard>/numpad7", "The key to go to the previous AI type. This uses Unity's New Input System's key-bind names.\nhttps://docs.unity3d.com/Packages/[email protected]/manual/Controls.html#control-paths");
			}
			if (GotoNextAiTypeKey == null)
			{
				GotoNextAiTypeKey = _config.Bind<string>("Host", "GotoNextAiTypeKey", "<Keyboard>/numpad8", "The key to go to the next AI type. This uses Unity's New Input System's key-bind names.\nhttps://docs.unity3d.com/Packages/[email protected]/manual/Controls.html#control-paths");
			}
			if (ReloadConfigKey == null)
			{
				ReloadConfigKey = _config.Bind<string>("Host", "ReloadConfigKey", "<Keyboard>/numpad9", "The key to reload the config. Does not update spawn conditions. This uses Unity's New Input System's key-bind names.\nhttps://docs.unity3d.com/Packages/[email protected]/manual/Controls.html#control-paths");
			}
			AiTypeEntry = _config.Bind<RollingGiantAiType>("2. AI Settings", "AiType", RollingGiantAiType.RandomlyMoveWhileLooking, "The AI type of the Rolling Giant.\n- Putting multiple will randomly choose between them each time you land on a moon\nCoilhead = Coilhead AI\nInverseCoilhead = Move when player is looking at it\nRandomlyMoveWhileLooking = Randomly move while the player is looking at it\nLookingTooLongKeepsAgro = If the player looks at it for too long it doesn't stop chasing\nFollowOnceAgro = Once the player is noticed, the Rolling Giant will follow the player constantly\nOnceSeenAgroAfterTimer = Once the player sees the Rolling Giant, it will chase the player after a timer");
			MoveSpeedEntry = _config.Bind<float>("2. AI Settings", "MoveSpeed", 6f, "The speed of the Rolling Giant in m/s².");
			MoveAccelerationEntry = _config.Bind<float>("2. AI Settings", "MoveAcceleration", 2f, "How long it takes the Rolling Giant to get to its movement speed. in seconds");
			MoveDecelerationEntry = _config.Bind<float>("2. AI Settings", "MoveDeceleration", 0.5f, "How long it takes the Rolling Giant to stop moving in seconds.");
			RotateToLookAtPlayerEntry = _config.Bind<bool>("2. AI Settings", "RotateToLookAtPlayer", true, "If the Rolling Giant should rotate to look at the player.");
			DelayBeforeLookingAtPlayerEntry = _config.Bind<float>("2. AI Settings", "DelayBeforeLookingAtPlayer", 2f, "The delay before the Rolling Giant looks at the player in seconds.");
			LookAtPlayerDurationEntry = _config.Bind<float>("2. AI Settings", "LookAtPlayerDuration", 3f, "The duration the Rolling Giant looks at the player in seconds.");
			RandomlyMoveWhenLooking_WaitTimeMinEntry = _config.Bind<float>("AI.RandomlyMoveWhenLooking", "WaitTimeMin", 1f, "The minimum duration in seconds that the Rolling Giant waits before moving again.");
			RandomlyMoveWhenLooking_WaitTimeMaxEntry = _config.Bind<float>("AI.RandomlyMoveWhenLooking", "WaitTimeMax", 3f, "The maximum duration in seconds that the Rolling Giant waits before moving again.");
			RandomlyMoveWhenLooking_RandomMoveTimeMinEntry = _config.Bind<float>("AI.RandomlyMoveWhenLooking", "RandomMoveTimeMin", 1f, "The minimum duration in seconds that the Rolling Giant moves for.");
			RandomlyMoveWhenLooking_RandomMoveTimeMaxEntry = _config.Bind<float>("AI.RandomlyMoveWhenLooking", "RandomMoveTimeMax", 3f, "The maximum duration in seconds that the Rolling Giant moves for.");
			LookingTooLongKeepsAgro_LookTimeBeforeAgroEntry = _config.Bind<float>("AI.LookingTooLongKeepsAgro", "LookTimeBeforeAgro", 10f, "How long the player can look at the Rolling Giant before it starts chasing in seconds.");
			OnceSeenAgroAfterTimer_WaitTimeMinEntry = _config.Bind<float>("AI.OnceSeenAgroAfterTimer", "WaitTimeMin", 30f, "The minimum duration in seconds the Rolling Giant waits before chasing the player.");
			OnceSeenAgroAfterTimer_WaitTimeMaxEntry = _config.Bind<float>("AI.OnceSeenAgroAfterTimer", "WaitTimeMax", 60f, "The minimum duration in seconds the Rolling Giant waits before chasing the player.");
			if (setValues)
			{
				GiantScaleMin = GiantScaleMinEntry.Value;
				GiantScaleMax = GiantScaleMaxEntry.Value;
				SpawnIn = SpawnInEntry.Value;
				SpawnInAny = SpawnInAnyEntry.Value;
				SpawnInAnyChance = SpawnInAnyChanceEntry.Value;
				CanSpawnInside = CanSpawnInsideEntry.Value;
				CanSpawnOutside = CanSpawnOutsideEntry.Value;
				DisableOutsideAtNight = DisableOutsideAtNightEntry.Value;
				MaxPerLevel = MaxPerLevelEntry.Value;
				SpawnPosterIn = SpawnPosterInEntry.Value;
				AiType = AiTypeEntry.Value;
				MoveSpeed = MoveSpeedEntry.Value;
				MoveAcceleration = MoveAccelerationEntry.Value;
				MoveDeceleration = MoveDecelerationEntry.Value;
				RotateToLookAtPlayer = RotateToLookAtPlayerEntry.Value;
				DelayBeforeLookingAtPlayer = DelayBeforeLookingAtPlayerEntry.Value;
				LookAtPlayerDuration = LookAtPlayerDurationEntry.Value;
				RandomlyMoveWhenLooking_WaitTimeMin = RandomlyMoveWhenLooking_WaitTimeMinEntry.Value;
				RandomlyMoveWhenLooking_WaitTimeMax = RandomlyMoveWhenLooking_WaitTimeMaxEntry.Value;
				RandomlyMoveWhenLooking_RandomMoveTimeMin = RandomlyMoveWhenLooking_RandomMoveTimeMinEntry.Value;
				RandomlyMoveWhenLooking_RandomMoveTimeMax = RandomlyMoveWhenLooking_RandomMoveTimeMaxEntry.Value;
				LookingTooLongKeepsAgro_LookTimeBeforeAgro = LookingTooLongKeepsAgro_LookTimeBeforeAgroEntry.Value;
				OnceSeenAgroAfterTimer_WaitTimeMin = OnceSeenAgroAfterTimer_WaitTimeMinEntry.Value;
				OnceSeenAgroAfterTimer_WaitTimeMax = OnceSeenAgroAfterTimer_WaitTimeMaxEntry.Value;
				SetCurrentAi();
			}
			Plugin.Log.LogInfo((object)"Config reloaded.");
		}

		public static SharedAiSettings GetSharedAiSettings()
		{
			SharedAiSettings result = default(SharedAiSettings);
			result.moveSpeed = SyncedInstance<CustomConfig>.Instance.MoveSpeed;
			result.moveAcceleration = SyncedInstance<CustomConfig>.Instance.MoveAcceleration;
			result.moveDeceleration = SyncedInstance<CustomConfig>.Instance.MoveDeceleration;
			result.rotateToLookAtPlayer = SyncedInstance<CustomConfig>.Instance.RotateToLookAtPlayer;
			result.delayBeforeLookingAtPlayer = SyncedInstance<CustomConfig>.Instance.DelayBeforeLookingAtPlayer;
			result.lookAtPlayerDuration = SyncedInstance<CustomConfig>.Instance.LookAtPlayerDuration;
			return result;
		}

		public static void RequestSync()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if (!SyncedInstance<CustomConfig>.IsClient)
			{
				Plugin.Log.LogError((object)"Config sync error: Not a client.");
				return;
			}
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(SyncedInstance<CustomConfig>.IntSize, (Allocator)2, -1);
			try
			{
				SyncedInstance<CustomConfig>.MessageManager.SendNamedMessage("RollingGiant_OnRequestConfigSync", 0uL, val, (NetworkDelivery)3);
				Plugin.Log.LogInfo((object)"Config sync request sent.");
			}
			finally
			{
				((IDisposable)(FastBufferWriter)(ref val)).Dispose();
			}
		}

		public static void OnRequestSync(ulong clientId, FastBufferReader _)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			if (!SyncedInstance<CustomConfig>.IsHost)
			{
				Plugin.Log.LogError((object)"Config sync error: Not a host.");
				return;
			}
			Plugin.Log.LogInfo((object)$"Config sync request received from client: {clientId}");
			byte[] array = SyncedInstance<CustomConfig>.SerializeToBytes(SyncedInstance<CustomConfig>.Instance);
			int num = array.Length;
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(num + SyncedInstance<CustomConfig>.IntSize, (Allocator)2, -1);
			try
			{
				((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteBytesSafe(array, -1, 0);
				SyncedInstance<CustomConfig>.MessageManager.SendNamedMessage("RollingGiant_OnReceiveConfigSync", clientId, val, (NetworkDelivery)4);
				Plugin.Log.LogInfo((object)$"Config sync sent to client: {clientId}");
			}
			catch (Exception arg)
			{
				Plugin.Log.LogError((object)$"Error occurred syncing config with client: {clientId}\n{arg}");
			}
			finally
			{
				((IDisposable)(FastBufferWriter)(ref val)).Dispose();
			}
		}

		public static void OnReceiveSync(ulong _, FastBufferReader reader)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			if (!((FastBufferReader)(ref reader)).TryBeginRead(SyncedInstance<CustomConfig>.IntSize))
			{
				Plugin.Log.LogError((object)"Config sync error: Could not begin reading buffer.");
				return;
			}
			int num = default(int);
			((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives));
			if (!((FastBufferReader)(ref reader)).TryBeginRead(num))
			{
				Plugin.Log.LogError((object)"Config sync error: Host could not sync.");
				return;
			}
			byte[] data = new byte[num];
			((FastBufferReader)(ref reader)).ReadBytesSafe(ref data, num, 0);
			SyncedInstance<CustomConfig>.SyncInstance(data);
			SetCurrentAi();
			Plugin.Log.LogInfo((object)"Successfully synced config with host.");
		}

		public static void SetCurrentAi()
		{
			if (Object.op_Implicit((Object)(object)NetworkHandler.Instance))
			{
				RollingGiantAiType aiType = NetworkHandler.AiType;
				SharedAiSettings sharedAiSettings2;
				switch (aiType)
				{
				case RollingGiantAiType.Coilhead:
					sharedAiSettings2 = GetSharedAiSettings();
					break;
				case RollingGiantAiType.InverseCoilhead:
					sharedAiSettings2 = GetSharedAiSettings();
					break;
				case RollingGiantAiType.RandomlyMoveWhileLooking:
				{
					SharedAiSettings sharedAiSettings = GetSharedAiSettings();
					sharedAiSettings.waitTimeMin = SyncedInstance<CustomConfig>.Instance.RandomlyMoveWhenLooking_WaitTimeMin;
					sharedAiSettings.waitTimeMax = SyncedInstance<CustomConfig>.Instance.RandomlyMoveWhenLooking_WaitTimeMax;
					sharedAiSettings.randomMoveTimeMin = SyncedInstance<CustomConfig>.Instance.RandomlyMoveWhenLooking_RandomMoveTimeMin;
					sharedAiSettings.randomMoveTimeMax = SyncedInstance<CustomConfig>.Instance.RandomlyMoveWhenLooking_RandomMoveTimeMax;
					sharedAiSettings2 = sharedAiSettings;
					break;
				}
				case RollingGiantAiType.LookingTooLongKeepsAgro:
				{
					SharedAiSettings sharedAiSettings = GetSharedAiSettings();
					sharedAiSettings.lookTimeBeforeAgro = SyncedInstance<CustomConfig>.Instance.LookingTooLongKeepsAgro_LookTimeBeforeAgro;
					sharedAiSettings2 = sharedAiSettings;
					break;
				}
				case RollingGiantAiType.FollowOnceAgro:
					sharedAiSettings2 = GetSharedAiSettings();
					break;
				case RollingGiantAiType.OnceSeenAgroAfterTimer:
				{
					SharedAiSettings sharedAiSettings = GetSharedAiSettings();
					sharedAiSettings.waitTimeMin = SyncedInstance<CustomConfig>.Instance.OnceSeenAgroAfterTimer_WaitTimeMin;
					sharedAiSettings.waitTimeMax = SyncedInstance<CustomConfig>.Instance.OnceSeenAgroAfterTimer_WaitTimeMax;
					sharedAiSettings2 = sharedAiSettings;
					break;
				}
				default:
					throw new ArgumentOutOfRangeException();
				}
				SharedAiSettings = sharedAiSettings2;
				Plugin.Log.LogInfo((object)$"[{aiType}]: {SharedAiSettings}");
			}
		}
	}
	public class GeneralSettings
	{
		public const string Name = "1. General Settings";

		public ConfigEntry<float> ChanceForGiant;

		public ConfigEntry<float> GiantScaleMin;

		public ConfigEntry<float> GiantScaleMax;

		public ConfigEntry<bool> SpawnInAllLevels;

		public ConfigEntry<bool> SpawnInLevelsWithCoilHead;

		public ConfigEntry<bool> SpawnInside;

		public ConfigEntry<bool> SpawnDaytime;

		public ConfigEntry<bool> SpawnOutside;

		public ConfigEntry<int> Version;

		public ConfigEntry<string> GotoPreviousAiTypeKey;

		public ConfigEntry<string> GotoNextAiTypeKey;

		public GeneralSettings(ConfigFile configFile)
		{
			ChanceForGiant = configFile.Bind<float>("1. General Settings", "ChanceForGiant", 0.4f, "0.0-1.0: Chance for a Rolling Giant to spawn. Higher means more chances for a Rolling Giant.");
			GiantScaleMin = configFile.Bind<float>("1. General Settings", "GiantScaleMin", 1f, "The minimum scale of the Rolling Giant.");
			GiantScaleMax = configFile.Bind<float>("1. General Settings", "GiantScaleMax", 1f, "The maximum scale of the Rolling Giant.");
			SpawnInAllLevels = configFile.Bind<bool>("1. General Settings", "SpawnInAllLevels", false, "If the Rolling Giant should spawn in all levels.");
			SpawnInLevelsWithCoilHead = configFile.Bind<bool>("1. General Settings", "SpawnInLevelsWithCoilHead", true, "If the Rolling Giant should spawn in levels with a Coilhead.");
			SpawnInside = configFile.Bind<bool>("1. General Settings", "SpawnInside", true, "If the Rolling Giant should spawn inside.");
			SpawnDaytime = configFile.Bind<bool>("1. General Settings", "SpawnDaytime", false, "If the Rolling Giant should spawn during the day.");
			SpawnOutside = configFile.Bind<bool>("1. General Settings", "SpawnOutside", false, "If the Rolling Giant should spawn outside.");
			Version = configFile.Bind<int>("z_Ignore", "__version", 0, "The version of this config file. Do not change this.");
			GotoPreviousAiTypeKey = configFile.Bind<string>("Dev", "GotoPreviousAiTypeKey", "<Keyboard>/numpad7", "The key to go to the previous AI type. This uses Unity's New Input System's key-bind names.");
			GotoNextAiTypeKey = configFile.Bind<string>("Dev", "GotoNextAiTypeKey", "<Keyboard>/numpad9", "The key to go to the next AI type. This uses Unity's New Input System's key-bind names.");
		}

		public float GetRandomScale(Random rng)
		{
			float num = (float)rng.NextDouble();
			float value = GiantScaleMin.Value;
			float value2 = GiantScaleMax.Value;
			return Mathf.Lerp(value, value2, num);
		}
	}
	[Serializable]
	public class SyncedInstance<T>
	{
		[NonSerialized]
		protected static int IntSize = 4;

		internal static CustomMessagingManager MessageManager => NetworkManager.Singleton.CustomMessagingManager;

		internal static bool IsClient => NetworkManager.Singleton.IsClient;

		internal static bool IsHost => NetworkManager.Singleton.IsHost;

		public static T Default { get; private set; }

		public static T Instance { get; private set; }

		public static bool Synced { get; internal set; }

		protected void InitInstance(T instance)
		{
			Default = instance;
			Instance = instance;
			IntSize = 4;
		}

		internal static void SyncInstance(byte[] data)
		{
			Instance = DeserializeFromBytes(data);
			Synced = true;
		}

		internal static void RevertSync()
		{
			Instance = Default;
			Synced = false;
		}

		public static byte[] SerializeToBytes(T val)
		{
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			using MemoryStream memoryStream = new MemoryStream();
			try
			{
				binaryFormatter.Serialize(memoryStream, val);
				return memoryStream.ToArray();
			}
			catch (Exception arg)
			{
				Plugin.Log.LogError((object)$"Error serializing instance: {arg}");
				return null;
			}
		}

		public static T DeserializeFromBytes(byte[] data)
		{
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			using MemoryStream serializationStream = new MemoryStream(data);
			try
			{
				return (T)binaryFormatter.Deserialize(serializationStream);
			}
			catch (Exception arg)
			{
				Plugin.Log.LogError((object)$"Error deserializing instance: {arg}");
				return default(T);
			}
		}
	}
}
namespace RollingGiant.Patches
{
	[HarmonyPatch]
	public static class EnemyPatches
	{
		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		[HarmonyPostfix]
		private static void RegisterEnemy(StartOfRound __instance)
		{
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Expected O, but got Unknown
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Expected O, but got Unknown
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Expected O, but got Unknown
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Expected O, but got Unknown
			(string, int)[] levelChances = GetLevelChances(CustomConfig.SpawnIn);
			(string, int)[] levelChances2 = GetLevelChances(CustomConfig.SpawnPosterIn);
			if (!__instance.allItemsList.itemsList.Contains(Plugin.PosterItem))
			{
				__instance.allItemsList.itemsList.Add(Plugin.PosterItem);
			}
			bool spawnInAny = CustomConfig.SpawnInAny;
			SelectableLevel[] levels = __instance.levels;
			foreach (SelectableLevel val in levels)
			{
				try
				{
					string levelName = val.PlanetName.ToLower().Replace(" ", string.Empty);
					(string, int)[] array = levelChances;
					for (int j = 0; j < array.Length; j++)
					{
						var (value, num) = array[j];
						if (!spawnInAny && !levelName.Contains(value))
						{
							continue;
						}
						if (spawnInAny)
						{
							num = CustomConfig.SpawnInAnyChance;
						}
						if (!val.spawnableScrap.Any((SpawnableItemWithRarity x) => (Object)(object)x.spawnableItem == (Object)(object)Plugin.PosterItem))
						{
							(string, int) tuple2 = levelChances2.FirstOrDefault(((string, int) x) => levelName.Contains(x.Item1));
							if (!string.IsNullOrEmpty(tuple2.Item1))
							{
								val.spawnableScrap.Add(new SpawnableItemWithRarity
								{
									spawnableItem = Plugin.PosterItem,
									rarity = tuple2.Item2
								});
								Plugin.Log.LogMessage((object)$"Added {Plugin.PosterItem.itemName} to {val.PlanetName} with chance of {tuple2.Item2}");
							}
						}
						if (CustomConfig.CanSpawnInside && val.Enemies.All((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType != (Object)(object)Plugin.EnemyTypeInside))
						{
							val.Enemies.Add(new SpawnableEnemyWithRarity
							{
								enemyType = Plugin.EnemyTypeInside,
								rarity = num
							});
							Plugin.Log.LogMessage((object)$"Added {Plugin.EnemyTypeOutside.enemyName} to {val.PlanetName} with chance of {num} (inside)");
						}
						if (!CustomConfig.DisableOutsideAtNight && CustomConfig.CanSpawnOutside && val.OutsideEnemies.All((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType != (Object)(object)Plugin.EnemyTypeOutside))
						{
							val.OutsideEnemies.Add(new SpawnableEnemyWithRarity
							{
								enemyType = Plugin.EnemyTypeOutside,
								rarity = num
							});
							Plugin.Log.LogMessage((object)$"Added {Plugin.EnemyTypeOutside.enemyName} to {val.PlanetName} with chance of {num} (outside)");
						}
						if (CustomConfig.DisableOutsideAtNight && CustomConfig.CanSpawnOutside && val.DaytimeEnemies.All((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType != (Object)(object)Plugin.EnemyTypeOutsideDaytime))
						{
							val.DaytimeEnemies.Add(new SpawnableEnemyWithRarity
							{
								enemyType = Plugin.EnemyTypeOutsideDaytime,
								rarity = num
							});
							Plugin.Log.LogMessage((object)$"Added {Plugin.EnemyTypeOutsideDaytime.enemyName} to {val.PlanetName} with chance of {num} (daytime)");
						}
					}
				}
				catch (Exception arg)
				{
					Plugin.Log.LogError((object)$"Failed to add enemy to {val.PlanetName}!\n{arg}");
				}
			}
		}

		private static (string, int)[] GetLevelChances(string str)
		{
			if (string.IsNullOrEmpty(str))
			{
				return new(string, int)[0];
			}
			return str.Replace(" ", string.Empty).Split(",").Select(delegate(string x)
			{
				if (!x.Contains(":"))
				{
					return (x.ToLower().Replace(" ", string.Empty), 0);
				}
				string[] array = x.Split(":");
				if (!int.TryParse(array[1], out var result))
				{
					result = 0;
				}
				return (array[0].ToLower().Replace(" ", string.Empty), result);
			})
				.ToArray();
		}

		[HarmonyPatch(typeof(QuickMenuManager), "Debug_SetEnemyDropdownOptions")]
		[HarmonyPrefix]
		private static void AddGiantToDebugList(QuickMenuManager __instance)
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_00