Decompiled source of GreenDemonChallenge v1.3.2

plugins/com.github.MiiMii1205.GreenDemonChallenge.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using DG.Tweening;
using GreenDemonChallenge.Behaviour;
using GreenDemonChallenge.Behaviour.GUI;
using GreenDemonChallenge.Compatibility;
using GreenDemonChallenge.Data;
using GreenDemonChallenge.Patchers;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PEAKLib.Core;
using PEAKLib.Core.Extensions;
using Peak.Afflictions;
using Peak.Network;
using Photon.Pun;
using Photon.Realtime;
using Photon.Voice.Unity.Demos;
using PhotonCustomPropsUtils;
using TMPro;
using TimeTheme;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.TextCore;
using UnityEngine.UI;
using UnityEngine.UI.Extensions;
using UnnamedProducts;
using UnnamedProducts.Behaviours;
using UnnamedProducts.Behaviours.Item.GarbageBag;
using Zorro.Core;
using Zorro.Core.CLI;
using Zorro.Core.Serizalization;
using pworld.Scripts.Extensions;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.MiiMii1205.GreenDemonChallenge")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.3.2.0")]
[assembly: AssemblyInformationalVersion("1.3.2+4c6b6631aeff1ceb174c5bb669516119e8734517")]
[assembly: AssemblyProduct("com.github.MiiMii1205.GreenDemonChallenge")]
[assembly: AssemblyTitle("GreenDemonChallenge")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace GreenDemonChallenge
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.github.MiiMii1205.GreenDemonChallenge", "GreenDemonChallenge", "1.3.2")]
	public class GreenDemonChallenge : BaseUnityPlugin
	{
		public static GreenDemonCaughtEffects RoomGreenDemonCaughtEffect = GreenDemonCaughtEffects.KILL;

		public static Dictionary<BiomeType, bool> RoomBiomeConfig = null;

		private static TMP_FontAsset? _darumaFontAsset;

		private static Material? _darumaShadowMaterial;

		public static GreenDemonSpeeds RoomGreenDemonSpeed = GreenDemonSpeeds.MEDIUM;

		public static int RoomGreenDemonAmount = 1;

		public static bool RoomEnableGreenDemonInTheKiln;

		public static float RoomGreenDemonDelay;

		public static GreenDemonRandomTypes RoomGreenDemonRandomType;

		public static GreenDemonModes RoomGreenDemonMode;

		private static readonly int UnderlayDilate = Shader.PropertyToID("_UnderlayDilate");

		private static readonly int UnderlayOffsetY = Shader.PropertyToID("_UnderlayOffsetY");

		private static readonly int UnderlaySoftness = Shader.PropertyToID("_UnderlaySoftness");

		private static readonly int UnderlayColor = Shader.PropertyToID("_UnderlayColor");

		public const string Id = "com.github.MiiMii1205.GreenDemonChallenge";

		public static GameObject GreenDemonPrefab
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get;
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			private set;
		} = null;


		internal static ManualLogSource Log
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get;
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			private set;
		} = null;


		public static PhotonScopedManager? Manager
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get;
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			private set;
		}

		public static ConfigEntry<GreenDemonCaughtEffects> GreenDemonCaughtEffect
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get;
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			private set;
		} = null;


		public static ConfigEntry<GreenDemonTrackerSettings> GreenDemonTrackerSetting
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get;
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			private set;
		} = null;


		public static ConfigEntry<float> GreenDemonVolume
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get;
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			private set;
		} = null;


		public static Dictionary<BiomeType, ConfigEntry<bool>> BiomeConfig
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get;
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			private set;
		} = null;


		public static GameObject TriggerEntryPrefab
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get;
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			private set;
		} = null;


		public static GameObject TriggerExitPrefab
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get;
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			private set;
		} = null;


		public static GameObject TheDemonIsHerePrefab
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get;
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			private set;
		} = null;


		public static GameObject TrackerPrefab
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get;
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			private set;
		} = null;


		public static GameObject PoisonCloudPrefab
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get;
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			private set;
		} = null;


		public static GameObject SporeCloudPrefab
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get;
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			private set;
		} = null;


		public static GameObject IceCloudPrefab
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get;
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			private set;
		} = null;


		public static GameObject FireCloudPrefab
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get;
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			private set;
		} = null;


		public static TMP_FontAsset DarumaDropOne
		{
			get
			{
				if ((Object)(object)_darumaFontAsset == (Object)null)
				{
					TMP_FontAsset[] source = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
					_darumaFontAsset = ((IEnumerable<TMP_FontAsset>)source).FirstOrDefault((Func<TMP_FontAsset, bool>)delegate(TMP_FontAsset fontAsset)
					{
						//IL_0001: Unknown result type (might be due to invalid IL or missing references)
						//IL_0006: Unknown result type (might be due to invalid IL or missing references)
						FaceInfo faceInfo = ((TMP_Asset)fontAsset).faceInfo;
						return ((FaceInfo)(ref faceInfo)).familyName == "Daruma Drop One";
					});
					Log.LogInfo((object)"Daruma Drop One font found!");
				}
				return _darumaFontAsset;
			}
		}

		public static Material DarumaDropOneFogShadowMaterial
		{
			get
			{
				//IL_0097: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)_darumaShadowMaterial == (Object)null)
				{
					_darumaShadowMaterial = ThrowHelper.ThrowIfArgumentNull<Material>(Object.Instantiate<Material>(((TMP_Asset)DarumaDropOne).material), "Instantiate(DarumaDropOne.material)");
					_darumaShadowMaterial.EnableKeyword("UNDERLAY_ON");
					_darumaShadowMaterial.SetFloat(UnderlayDilate, 1f);
					_darumaShadowMaterial.SetFloat(UnderlayOffsetY, -0.7f);
					_darumaShadowMaterial.SetFloat(UnderlaySoftness, 1f);
					_darumaShadowMaterial.SetColor(UnderlayColor, new Color(0f, 0f, 0f, 0.1960784f));
					Log.LogInfo((object)"Shadow material for Green Demon Challenge was successfully generated!");
				}
				return _darumaShadowMaterial;
			}
		}

		private static bool IsRunStarted
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get
			{
				return RunManager.Instance?.runStarted ?? false;
			}
		}

		public static ConfigEntry<int> GreenDemonAmount
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get;
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			set;
		} = null;


		public static ConfigEntry<bool> EnableGreenDemonInTheKiln
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get;
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			private set;
		} = null;


		public static ConfigEntry<bool> StopGreenDemonInTomb
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get;
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			private set;
		} = null;


		public static ConfigEntry<GreenDemonSpeeds> GreenDemonSpeed
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get;
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			set;
		} = null;


		public static ConfigEntry<float> GreenDemonDelay
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get;
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			set;
		} = null;


		public static ConfigEntry<GreenDemonModes> GreenDemonMode
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get;
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			set;
		} = null;


		public static ConfigEntry<GreenDemonRandomTypes> GreenDemonRandomType
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get;
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			set;
		} = null;


		public static string Name => "GreenDemonChallenge";

		public static string Version => "1.3.2";

		private void Awake()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Expected O, but got Unknown
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_032c: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_061c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0622: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Manager = PhotonCustomPropsUtilsPlugin.GetManager("com.github.MiiMii1205.GreenDemonChallenge");
			ConfigDescription val = new ConfigDescription("What happens to players caught by Green Demons", (AcceptableValueBase)(object)new AcceptableEnumList<GreenDemonCaughtEffects>(GetValidEffects()), Array.Empty<object>());
			GreenDemonCaughtEffect = ((BaseUnityPlugin)this).Config.Bind<GreenDemonCaughtEffects>("General", "Green Demon Caught Effect", GreenDemonCaughtEffects.KILL, val);
			GreenDemonVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Gameplay", "Green Demon Volume", 1f, new ConfigDescription("The volume of the Green Demon Music", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>()));
			GreenDemonTrackerSetting = ((BaseUnityPlugin)this).Config.Bind<GreenDemonTrackerSettings>("Gameplay", "Green Demon Tracker Mode", GreenDemonTrackerSettings.OFFSCREEN, "When on-screen trackers should appear.");
			GreenDemonAmount = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Green Demon amount", 1, new ConfigDescription("The amount of Green Demons that spawns in.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10), Array.Empty<object>()));
			GreenDemonSpeed = ((BaseUnityPlugin)this).Config.Bind<GreenDemonSpeeds>("General", "Green Demon Speed", GreenDemonSpeeds.MEDIUM, "How fast green demons goes.");
			GreenDemonDelay = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Green Demon Delay", 1f, "How long the demon has to wait before starting to chase players after spawning.");
			GreenDemonMode = ((BaseUnityPlugin)this).Config.Bind<GreenDemonModes>("General", "Green Demon Mode", GreenDemonModes.NORMAL, "The current Green Demon Challenge mode. 'NORMAL' despawns all active demons after starting a campfire, 'HARD' stops them momentarily but max out demon count to \"Green Demon amount\", 'VERY_HARD' is 'HARD' but demon keeps spawning .");
			GreenDemonRandomType = ((BaseUnityPlugin)this).Config.Bind<GreenDemonRandomTypes>("General", "Type of Green Demon Random Effects", GreenDemonRandomTypes.STANDARD, "Restricts the kind of effects that can happen when the Caught Effect is RANDOM. 'CASUAL' removes the harsher effects (like 'KILL', 'POOR_BOY'), 'HARDCORE' removes the softer effects (like 'SLIP' or 'BEES'), and 'STANDARD' keeps every effects.");
			GreenDemonCaughtEffect.SettingChanged += UpdateGreenDemonConfig;
			GreenDemonAmount.SettingChanged += UpdateGreenDemonConfig;
			GreenDemonSpeed.SettingChanged += UpdateGreenDemonConfig;
			GreenDemonMode.SettingChanged += UpdateGreenDemonConfig;
			GreenDemonRandomType.SettingChanged += UpdateGreenDemonConfig;
			GreenDemonVolume.SettingChanged += UpdateDemonVolumes;
			GreenDemonTrackerSetting.SettingChanged += UpdateTrackersSettings;
			BiomeConfig = new Dictionary<BiomeType, ConfigEntry<bool>>();
			RoomBiomeConfig = new Dictionary<BiomeType, bool>();
			foreach (object enumValue in typeof(BiomeType).GetEnumValues())
			{
				if ((int)enumValue <= 7)
				{
					string text = typeof(BiomeType).GetEnumName((object)(BiomeType)enumValue)?.Replace("Volcano", "Caldera");
					ConfigEntry<bool> val2 = ((BaseUnityPlugin)this).Config.Bind<bool>("Biomes", "Enable " + text, true, "Enables/disables Green Demons for " + text);
					val2.SettingChanged += UpdateGreenDemonConfig;
					BiomeConfig.Add((BiomeType)enumValue, val2);
					RoomBiomeConfig.Add((BiomeType)enumValue, val2.Value);
				}
			}
			EnableGreenDemonInTheKiln = ((BaseUnityPlugin)this).Config.Bind<bool>("Biomes", "Enable The Kiln", true, "Enables/Disables the Green Demon for The Kiln");
			EnableGreenDemonInTheKiln.SettingChanged += UpdateGreenDemonConfig;
			GreenDemonDelay.SettingChanged += UpdateGreenDemonConfig;
			RoomGreenDemonAmount = GreenDemonAmount.Value;
			RoomGreenDemonSpeed = GreenDemonSpeed.Value;
			RoomGreenDemonCaughtEffect = GreenDemonCaughtEffect.Value;
			RoomEnableGreenDemonInTheKiln = EnableGreenDemonInTheKiln.Value;
			RoomGreenDemonDelay = GreenDemonDelay.Value;
			RoomGreenDemonMode = GreenDemonMode.Value;
			RoomGreenDemonRandomType = GreenDemonRandomType.Value;
			BundleLoader.LoadBundleAndContentsWithName((BaseUnityPlugin)(object)this, "greendemon.peakbundle", (Action<PeakBundle>)delegate(PeakBundle bundle)
			{
				//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c0: Expected O, but got Unknown
				//IL_031c: Unknown result type (might be due to invalid IL or missing references)
				//IL_032d: Unknown result type (might be due to invalid IL or missing references)
				GreenDemonPrefab = bundle.LoadAsset<GameObject>("GreenDemon.prefab");
				TriggerEntryPrefab = bundle.LoadAsset<GameObject>("GreenDemonEntry.prefab");
				TriggerExitPrefab = bundle.LoadAsset<GameObject>("GreenDemonExit.prefab");
				TheDemonIsHerePrefab = bundle.LoadAsset<GameObject>("TheDemonIsHere.prefab");
				TrackerPrefab = bundle.LoadAsset<GameObject>("GreenDemonTracker.prefab");
				TrackerPrefab.GetComponentInChildren<CanvasGroup>(true).alpha = 0f;
				ExtGameObject.GetOrAddComponent<GreenDemonTombTrigger>(TriggerEntryPrefab);
				ExtGameObject.GetOrAddComponent<GreenDemonTombTrigger>(TriggerExitPrefab);
				PoisonCloudPrefab = bundle.LoadAsset<GameObject>("PoisonCloud.prefab");
				SporeCloudPrefab = bundle.LoadAsset<GameObject>("SporeCloud.prefab");
				IceCloudPrefab = bundle.LoadAsset<GameObject>("IceCloud.prefab");
				FireCloudPrefab = bundle.LoadAsset<GameObject>("FireCloud.prefab");
				GameObject val4 = bundle.LoadAsset<GameObject>("GreenDemonConsumeVFX.prefab");
				GameObject val5 = bundle.LoadAsset<GameObject>("GreenDemonPoofVFX.prefab");
				ShaderExtensions.ReplaceShaders(val4);
				ShaderExtensions.ReplaceShaders(val5);
				ReplaceShaders(new List<string>(16)
				{
					"W/Peak_Standard", "W/Character", "W/Peak_Transparent", "W/Peak_Glass", "W/Peak_Clip", "W/Peak_glass_liquid", "W/Peak_GroundTransition", "W/Peak_Guidebook", "W/Peak_Honey", "W/Peak_Ice",
					"W/Peak_Rock", "W/Peak_Rope", "W/Peak_Splash", "W/Peak_Waterfall", "GD/FireParticle", "SmokeParticle"
				}, val4);
				ReplaceShaders(new List<string>(16)
				{
					"W/Peak_Standard", "W/Character", "W/Peak_Transparent", "W/Peak_Glass", "W/Peak_Clip", "W/Peak_glass_liquid", "W/Peak_GroundTransition", "W/Peak_Guidebook", "W/Peak_Honey", "W/Peak_Ice",
					"W/Peak_Rock", "W/Peak_Rope", "W/Peak_Splash", "W/Peak_Waterfall", "GD/FireParticle", "SmokeParticle"
				}, val5);
				DestroyAfterEmit orAddComponent = ExtGameObject.GetOrAddComponent<DestroyAfterEmit>(val4);
				orAddComponent.m_particle = val4.GetComponent<ParticleSystem>();
				DestroyAfterEmit orAddComponent2 = ExtGameObject.GetOrAddComponent<DestroyAfterEmit>(val5);
				orAddComponent2.m_particle = val5.GetComponent<ParticleSystem>();
				GreenDemon orAddComponent3 = ExtGameObject.GetOrAddComponent<GreenDemon>(GreenDemonPrefab);
				orAddComponent3.mainRenderer = GreenDemonPrefab.GetComponentInChildren<Renderer>();
				orAddComponent3.m_demonTransform = ((Component)orAddComponent3.mainRenderer).transform.parent;
				GameObject val6 = new GameObject("GreenDemonTrigger");
				GreenDemonDetector greenDemonDetector = val6.AddComponent<GreenDemonDetector>();
				SphereCollider val7 = val6.AddComponent<SphereCollider>();
				orAddComponent3.m_detector = greenDemonDetector;
				((Collider)val7).isTrigger = true;
				float detectorRadius = (val7.radius = 100f);
				greenDemonDetector.m_detectorRadius = detectorRadius;
				val6.transform.SetParent(((Component)orAddComponent3.mainRenderer).transform, false);
				val6.transform.localPosition = ExtDataTypes.ToVec(0);
				val6.transform.localRotation = Quaternion.identity;
				Item val8 = default(Item);
				Item val9 = default(Item);
				if (ItemDatabase.TryGetItem((ushort)158, ref val8) && ItemDatabase.TryGetItem((ushort)13, ref val9))
				{
					ItemImpactSFX component = ((Component)val8).GetComponent<ItemImpactSFX>();
					ItemImpactSFX component2 = ((Component)val9).GetComponent<ItemImpactSFX>();
					orAddComponent3.m_impact = CollectionExtensions.AddRangeToArray<SFX_Instance>(orAddComponent3.m_impact, component.impact);
					SFX_Instance[] impact = component2.impact;
					foreach (SFX_Instance val10 in impact)
					{
						if (((Object)val10).name == "SFXI BingBong 2")
						{
							orAddComponent3.m_impact = CollectionExtensions.AddToArray<SFX_Instance>(orAddComponent3.m_impact, val10);
						}
					}
				}
				SFX_PlayOneShot component3 = GreenDemonPrefab.GetComponent<SFX_PlayOneShot>();
				SFX_Instance[] sfxs = component3.sfxs;
				SFX_Instance[] array = sfxs;
				foreach (SFX_Instance val11 in array)
				{
					if (((Object)val11).name == "SFXI Heal Hunger Stamina")
					{
						orAddComponent3.consumedSfx = CollectionExtensions.AddToArray<SFX_Instance>(orAddComponent3.consumedSfx, val11);
					}
				}
				orAddComponent3.shrunkSfx = CollectionExtensions.AddToArray<SFX_Instance>(orAddComponent3.shrunkSfx, bundle.LoadAsset<SFX_Instance>("SFXI Demon_Despawn.asset"));
				orAddComponent3.consumedSfx = CollectionExtensions.AddToArray<SFX_Instance>(CollectionExtensions.AddToArray<SFX_Instance>(orAddComponent3.consumedSfx, bundle.LoadAsset<SFX_Instance>("SFXI Demon_Consume.asset")), bundle.LoadAsset<SFX_Instance>("SFXI Demon_Consume_Jingle.asset"));
				orAddComponent3.m_vfxPrefab = val4;
				orAddComponent3.m_poofVfxPrefab = val5;
				Object.Destroy((Object)(object)component3);
				orAddComponent3.source = GreenDemonPrefab.GetComponent<AudioSource>();
				GameObject val12 = Resources.Load<GameObject>("Character");
				orAddComponent3.source.outputAudioMixerGroup = val12.GetComponentInChildren<AmbienceAudio>(true).mainMusic.outputAudioMixerGroup;
				ReplaceShaders(new List<string>(16)
				{
					"W/Peak_Standard", "W/Character", "W/Peak_Transparent", "W/Peak_Glass", "W/Peak_Clip", "W/Peak_glass_liquid", "W/Peak_GroundTransition", "W/Peak_Guidebook", "W/Peak_Honey", "W/Peak_Ice",
					"W/Peak_Rock", "W/Peak_Rope", "W/Peak_Splash", "W/Peak_Waterfall", "GD/FireParticle", "W/Vine"
				}, GreenDemonPrefab);
				ReplaceShaders(new List<string>(2) { "Scouts/UI", "TextMeshPro/Distance Field" }, TheDemonIsHerePrefab);
				ReplaceShaders(new List<string>(2) { "Scouts/UI", "TextMeshPro/Distance Field" }, TrackerPrefab);
				ShaderExtensions.ReplaceShaders(TheDemonIsHerePrefab);
				ShaderExtensions.ReplaceShaders(TrackerPrefab);
				ShaderExtensions.ReplaceShaders(GreenDemonPrefab);
				ShaderExtensions.ReplaceShaders(PoisonCloudPrefab);
				ShaderExtensions.ReplaceShaders(SporeCloudPrefab);
				ShaderExtensions.ReplaceShaders(IceCloudPrefab);
				ShaderExtensions.ReplaceShaders(FireCloudPrefab);
				ReplaceAudioMixerOutput(TheDemonIsHerePrefab);
				ReplaceAudioMixerOutput(TrackerPrefab);
				ReplaceAudioMixerOutput(GreenDemonPrefab);
				ReplaceAudioMixerOutput(PoisonCloudPrefab);
				ReplaceAudioMixerOutput(SporeCloudPrefab);
				ReplaceAudioMixerOutput(IceCloudPrefab);
				ReplaceAudioMixerOutput(FireCloudPrefab);
				TMP_Text[] componentsInChildren = TheDemonIsHerePrefab.GetComponentsInChildren<TMP_Text>();
				foreach (TMP_Text val13 in componentsInChildren)
				{
					val13.font = DarumaDropOne;
					val13.fontMaterial = DarumaDropOneFogShadowMaterial;
				}
				NetworkPrefabManager.TryRegisterNetworkPrefab(((Object)GreenDemonPrefab).name, GreenDemonPrefab);
				NetworkPrefabManager.TryRegisterNetworkPrefab(((Object)PoisonCloudPrefab).name, PoisonCloudPrefab);
				NetworkPrefabManager.TryRegisterNetworkPrefab(((Object)SporeCloudPrefab).name, SporeCloudPrefab);
				NetworkPrefabManager.TryRegisterNetworkPrefab(((Object)IceCloudPrefab).name, IceCloudPrefab);
				NetworkPrefabManager.TryRegisterNetworkPrefab(((Object)FireCloudPrefab).name, FireCloudPrefab);
				GreenDemonTracker orAddComponent4 = ExtGameObject.GetOrAddComponent<GreenDemonTracker>(TrackerPrefab);
				AnimationCurve val14 = AnimationCurve.EaseInOut(0f, 0f, 1.25f, 1f);
				val14.preWrapMode = (WrapMode)4;
				val14.postWrapMode = (WrapMode)4;
				orAddComponent4.m_pulseTintCurve = val14;
				orAddComponent4.m_group = ((Component)orAddComponent4).GetComponent<CanvasGroup>();
				orAddComponent4.m_rotatorTransform = ((Component)((Component)orAddComponent4).transform.Find("DemonArrowRotator")).GetComponent<RectTransform>();
				orAddComponent4.m_arrowImage = ((Component)((Transform)orAddComponent4.m_rotatorTransform).Find("Arrow").Find("Image")).GetComponent<Image>();
				orAddComponent4.m_demonTransform = ((Component)((Component)orAddComponent4).transform.Find("DemonImage")).GetComponent<RectTransform>();
				orAddComponent4.m_demonImage = ((Component)orAddComponent4.m_demonTransform).GetComponent<RawImage>();
				bundle.Mod.RegisterContent();
				Log.LogInfo((object)"Green Demon bundle is loaded!");
			});
			Manager.RegisterRoomProperty<int>("RoomGreenDemonSpeed", (RoomEventType)2, (Action<int>)delegate(int v)
			{
				if (!PhotonNetwork.IsMasterClient)
				{
					Log.LogInfo((object)string.Format("Received {0} as new {1}!", (GreenDemonSpeeds)v, "RoomGreenDemonSpeed"));
					RoomGreenDemonSpeed = (GreenDemonSpeeds)v;
				}
			});
			Manager.RegisterRoomProperty<int>("RoomGreenDemonAmount", (RoomEventType)2, (Action<int>)delegate(int v)
			{
				if (!PhotonNetwork.IsMasterClient)
				{
					Log.LogInfo((object)string.Format("Received {0} as new {1}!", v, "RoomGreenDemonAmount"));
					RoomGreenDemonAmount = v;
				}
			});
			Manager.RegisterRoomProperty<bool>("RoomEnableGreenDemonInTheKiln", (RoomEventType)2, (Action<bool>)delegate(bool v)
			{
				if (!PhotonNetwork.IsMasterClient)
				{
					Log.LogInfo((object)string.Format("Received {0} as new {1}!", v, "RoomEnableGreenDemonInTheKiln"));
					RoomEnableGreenDemonInTheKiln = v;
				}
			});
			Manager.RegisterRoomProperty<int>("RoomGreenDemonRandomType", (RoomEventType)2, (Action<int>)delegate(int v)
			{
				if (!PhotonNetwork.IsMasterClient)
				{
					Log.LogInfo((object)string.Format("Received {0} as new {1}!", v, "RoomGreenDemonRandomType"));
					RoomGreenDemonRandomType = (GreenDemonRandomTypes)v;
				}
			});
			Manager.RegisterRoomProperty<int>("RoomGreenDemonCaughtEffect", (RoomEventType)2, (Action<int>)delegate(int v)
			{
				if (!PhotonNetwork.IsMasterClient)
				{
					Log.LogInfo((object)string.Format("Received {0} as new {1}!", (GreenDemonCaughtEffects)v, "RoomGreenDemonCaughtEffect"));
					RoomGreenDemonCaughtEffect = (GreenDemonCaughtEffects)v;
				}
			});
			Manager.RegisterRoomProperty<float>("RoomGreenDemonDelay", (RoomEventType)2, (Action<float>)delegate(float v)
			{
				if (!PhotonNetwork.IsMasterClient)
				{
					Log.LogInfo((object)string.Format("Received {0} as new {1}!", v, "RoomGreenDemonDelay"));
					RoomGreenDemonDelay = v;
				}
			});
			foreach (KeyValuePair<BiomeType, bool> keyValuePair in RoomBiomeConfig)
			{
				string text2 = string.Format("{0}_{1}", keyValuePair.Key, "RoomBiomeConfig");
				Manager.RegisterRoomProperty<bool>(text2, (RoomEventType)2, (Action<bool>)delegate(bool v)
				{
					//IL_0022: 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)
					if (!PhotonNetwork.IsMasterClient)
					{
						Log.LogInfo((object)string.Format("Received {0} as new {1}[{2}]!", v, "RoomBiomeConfig", keyValuePair.Key));
						RoomBiomeConfig[keyValuePair.Key] = v;
					}
				});
			}
			Manager.RegisterOnJoinedRoom((Action<Player>)SetupGreenDemonSettings);
			AddLocalizedTextCsv();
			Harmony val3 = new Harmony("com.github.MiiMii1205.GreenDemonChallenge");
			val3.PatchAll(typeof(GreenDemonPatcher));
			if (LuckyBlocksCompatibilityHandler.Enabled)
			{
				LuckyBlocksCompatibilityHandler.PatchLuckyBlocks(val3);
			}
			if (TimeThemeCompatibilityHandler.Enabled)
			{
				TimeThemeCompatibilityHandler.Init();
			}
			Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
		}

		private void ReplaceAudioMixerOutput(GameObject trackerPrefab)
		{
			AudioMixerGroup[] source = Resources.FindObjectsOfTypeAll<AudioMixerGroup>();
			AudioSource[] componentsInChildren = trackerPrefab.GetComponentsInChildren<AudioSource>(true);
			foreach (AudioSource s in componentsInChildren)
			{
				Log.LogInfo((object)("MixerGroup name is " + ((Object)s.outputAudioMixerGroup).name));
				AudioMixerGroup outputAudioMixerGroup = source.First((AudioMixerGroup g) => ((Object)g).name == ((Object)s.outputAudioMixerGroup).name);
				s.outputAudioMixerGroup = outputAudioMixerGroup;
			}
		}

		private static void UpdateDemonVolumes(object sender, EventArgs e)
		{
			foreach (GreenDemon allDemon in GreenDemon.AllDemons)
			{
				allDemon.RefreshVolume();
			}
		}

		private static void UpdateTrackersSettings(object sender, EventArgs e)
		{
			foreach (GreenDemonTracker allTracker in GreenDemonTracker.AllTrackers)
			{
				allTracker.RefreshTrackerVisibility();
			}
		}

		private static GreenDemonCaughtEffects[] GetValidEffects()
		{
			List<GreenDemonCaughtEffects> list = new List<GreenDemonCaughtEffects>();
			foreach (GreenDemonCaughtEffects value in Enum.GetValues(typeof(GreenDemonCaughtEffects)))
			{
				switch (value)
				{
				case GreenDemonCaughtEffects.SET_FIRE:
				case GreenDemonCaughtEffects.FIREBALL:
				case GreenDemonCaughtEffects.UNNAMIFY:
					if (UnnamedCompatibilityHandler.Enabled)
					{
						list.Add(value);
					}
					break;
				case GreenDemonCaughtEffects.SPAWN_LUCKY_BLOCK:
					if (LuckyBlocksCompatibilityHandler.Enabled)
					{
						list.Add(value);
					}
					break;
				default:
					list.Add(value);
					break;
				}
			}
			return list.ToArray();
		}

		private static void UpdateGreenDemonConfig(object sender, EventArgs e)
		{
			if (!IsRunStarted)
			{
				SetupGreenDemonSettings(PhotonNetwork.LocalPlayer);
			}
			else
			{
				Log.LogWarning((object)"Run has already started. Can't change the settings mid-run...");
			}
		}

		private static void SetupGreenDemonSettings(Player player)
		{
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			if (!player.IsMasterClient)
			{
				Log.LogWarning((object)$"{player} is NOT the host. Can't send our Settings.");
			}
			if (!PhotonNetwork.InRoom || !player.IsMasterClient || Manager == null)
			{
				return;
			}
			Log.LogInfo((object)string.Format("Sending our current {0} of {1}...", "RoomGreenDemonSpeed", GreenDemonSpeed.Value));
			RoomGreenDemonSpeed = GreenDemonSpeed.Value;
			Manager.SetRoomProperty("RoomGreenDemonSpeed", (object)(int)GreenDemonSpeed.Value);
			Log.LogInfo((object)string.Format("Sending our current {0} of {1}...", "RoomGreenDemonAmount", GreenDemonAmount.Value));
			RoomGreenDemonAmount = GreenDemonAmount.Value;
			Manager.SetRoomProperty("RoomGreenDemonAmount", (object)GreenDemonAmount.Value);
			Log.LogInfo((object)string.Format("Sending our current {0} in the kiln of {1}...", "RoomEnableGreenDemonInTheKiln", EnableGreenDemonInTheKiln.Value));
			RoomEnableGreenDemonInTheKiln = EnableGreenDemonInTheKiln.Value;
			Manager.SetRoomProperty("RoomEnableGreenDemonInTheKiln", (object)EnableGreenDemonInTheKiln.Value);
			Log.LogInfo((object)string.Format("Sending our current {0} of {1}...", "RoomGreenDemonCaughtEffect", GreenDemonCaughtEffect.Value));
			RoomGreenDemonCaughtEffect = GreenDemonCaughtEffect.Value;
			Manager.SetRoomProperty("RoomGreenDemonCaughtEffect", (object)(int)GreenDemonCaughtEffect.Value);
			Log.LogInfo((object)string.Format("Sending our current {0} of {1}...", "RoomGreenDemonMode", GreenDemonMode.Value));
			RoomGreenDemonMode = GreenDemonMode.Value;
			Manager.SetRoomProperty("RoomGreenDemonMode", (object)(int)GreenDemonMode.Value);
			Log.LogInfo((object)string.Format("Sending our current {0} of {1}...", "RoomGreenDemonDelay", GreenDemonDelay.Value));
			RoomGreenDemonDelay = GreenDemonDelay.Value;
			Manager.SetRoomProperty("RoomGreenDemonDelay", (object)GreenDemonDelay.Value);
			Log.LogInfo((object)string.Format("Sending our current {0} of {1}...", "RoomGreenDemonRandomType", GreenDemonRandomType.Value));
			RoomGreenDemonRandomType = GreenDemonRandomType.Value;
			Manager.SetRoomProperty("RoomGreenDemonRandomType", (object)GreenDemonRandomType.Value);
			foreach (KeyValuePair<BiomeType, ConfigEntry<bool>> item in BiomeConfig)
			{
				string text = string.Format("{0}_{1}", item.Key, "RoomBiomeConfig");
				Log.LogInfo((object)string.Format("Sending our current ${0}[{1}] of {2}...", "RoomBiomeConfig", item.Key, item.Value.Value));
				RoomBiomeConfig[item.Key] = item.Value.Value;
				Manager.SetRoomProperty(text, (object)item.Value.Value);
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private static void ReplaceShaders(List<string> shaderNames, GameObject go)
		{
			Renderer[] componentsInChildren = go.GetComponentsInChildren<Renderer>();
			foreach (Renderer ren in componentsInChildren)
			{
				ReplaceAllShaderInRenderer(shaderNames, ren);
			}
		}

		private static void ReplaceAllShaderInRenderer(List<string> shaderNames, Renderer ren)
		{
			foreach (string shaderName in shaderNames)
			{
				Shader val = Shader.Find(shaderName);
				if ((Object)(object)val == (Object)null)
				{
					Log.LogWarning((object)(": Shader " + shaderName + " was not found."));
					continue;
				}
				Material[] sharedMaterials = ren.sharedMaterials;
				foreach (Material mat in sharedMaterials)
				{
					ReplaceShader(val, mat);
				}
				Material[] materials = ren.materials;
				foreach (Material mat2 in materials)
				{
					ReplaceShader(val, mat2);
				}
			}
		}

		private void AddLocalizedTextCsv()
		{
			using StreamReader streamReader = new StreamReader(Path.Join((ReadOnlySpan<char>)Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), (ReadOnlySpan<char>)"GreenDemonChallengeLocalizedText.csv"));
			int num = 0;
			while (!streamReader.EndOfStream)
			{
				string text = streamReader.ReadLine();
				if (text == null)
				{
					break;
				}
				num++;
				List<string> list = new List<string>(CSVReader.SplitCsvLine(text, true));
				string text2 = ExtCollections.Deque<string>(list);
				string text3 = ExtCollections.Pop<string>(list);
				if (text3 != "ENDLINE")
				{
					Log.LogError((object)$"Invalid localization at line {num}");
				}
				if (text2 != "CURRENT_LANGUAGE")
				{
					LocalizedText.mainTable[text2.ToUpper()] = list;
					Log.LogDebug((object)("Added localization of " + text2.ToUpper()));
				}
			}
			Log.LogDebug((object)$"Added {num - 1} localizations");
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private static void ReplaceShader(Shader shader, Material mat)
		{
			if (((Object)mat.shader).name == ((Object)shader).name)
			{
				mat.shader = shader;
			}
		}

		private void OnGUI()
		{
		}

		[ConsoleCommand]
		public static void SpawnGreenDemons(int nb)
		{
			GreenDemonHandler.Instance.SpawnGreenDemon(nb);
		}

		[ConsoleCommand]
		public static void SpawnGreenDemons()
		{
			GreenDemonHandler.Instance.SpawnGreenDemon(1);
		}

		[ConsoleCommand]
		public static void DespawnGreenDemons()
		{
			GreenDemonHandler.Instance.ShrinkAllDemons();
		}

		[ConsoleCommand]
		public static void SpawnIceCloud()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			Object.Instantiate<GameObject>(IceCloudPrefab, Character.localCharacter.Center, Quaternion.identity);
		}

		[ConsoleCommand]
		public static void SpawnFireCloud()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			Object.Instantiate<GameObject>(FireCloudPrefab, Character.localCharacter.Center, Quaternion.identity);
		}

		[ConsoleCommand]
		public static void SpawnSporeCloud()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			Object.Instantiate<GameObject>(SporeCloudPrefab, Character.localCharacter.Center, Quaternion.identity);
		}

		[ConsoleCommand]
		public static void SpawnPoisonCloud()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			Object.Instantiate<GameObject>(PoisonCloudPrefab, Character.localCharacter.Center, Quaternion.identity);
		}
	}
}
namespace GreenDemonChallenge.Patchers
{
	public static class GreenDemonPatcher
	{
		[HarmonyPatch(typeof(RunManager), "Awake")]
		[HarmonyPostfix]
		public static void RunManagerAwakePostfix(RunManager __instance)
		{
			GreenDemonHandler orAddComponent = ExtensionMethods.GetOrAddComponent<GreenDemonHandler>(((Component)__instance).gameObject);
			if ((Object)(object)orAddComponent == (Object)null)
			{
				GreenDemonChallenge.Log.LogError((object)string.Format("{0} was not found on {1}", "GreenDemonHandler", ((Component)__instance).gameObject));
			}
		}

		[HarmonyPatch(typeof(GUIManager), "Awake")]
		[HarmonyPostfix]
		public static void GUIManagerAwakePostfix(GUIManager __instance)
		{
			GreenDemonGUIManager orAddComponent = ExtensionMethods.GetOrAddComponent<GreenDemonGUIManager>(((Component)__instance).gameObject);
			if ((Object)(object)orAddComponent == (Object)null)
			{
				GreenDemonChallenge.Log.LogError((object)string.Format("{0} was not found on {1}", "GreenDemonGUIManager", ((Component)__instance).gameObject));
			}
		}

		[HarmonyPatch(typeof(PeakHandler), "EndScreenComplete")]
		[HarmonyPostfix]
		public static void EndCutsceneCreditAwakePostfix(PeakHandler __instance)
		{
			GreenDemonHandler.Instance.ShrinkAllDemons();
		}

		[HarmonyPatch(typeof(MapHandler), "JumpToSegment")]
		[HarmonyPostfix]
		public static void JumpToPostfix(MapHandler __instance, Segment segment)
		{
			switch (GreenDemonChallenge.RoomGreenDemonMode)
			{
			case GreenDemonModes.NORMAL:
				GreenDemonHandler.Instance.ShrinkAllDemons();
				break;
			case GreenDemonModes.HARD:
			case GreenDemonModes.VERY_HARD:
				GreenDemonHandler.Instance.StopAllDemon((MapHandler.PreviousCampfire?.burnsFor ?? 0f) + 0.25f);
				break;
			default:
				throw new ArgumentOutOfRangeException();
			}
			GreenDemonHandler.Instance.ResumeSpawning((MapHandler.PreviousCampfire?.burnsFor ?? 0f) + 0.25f);
		}

		[HarmonyPatch(typeof(TriggerEvent), "OnTriggerEnter")]
		[HarmonyPrefix]
		public static void TriggerEventPrefix(TriggerEvent __instance, Collider other, ref bool __runOriginal)
		{
			if (__instance is GreenDemonTombTrigger greenDemonTombTrigger)
			{
				__runOriginal = false;
				greenDemonTombTrigger.OnGDCTriggerEnter(other);
			}
		}

		[HarmonyPatch(typeof(CharacterInput), "GetMovementInput")]
		[HarmonyPostfix]
		public static void TriggerEventPrefix(CharacterInput __instance, ref Vector2 __result)
		{
			if ((Object)(object)GreenDemonHandler.Instance != (Object)null && GreenDemonHandler.IsWKeyStuck)
			{
				__result.y = 1f;
			}
		}

		[HarmonyPatch(typeof(Campfire), "Light_Rpc")]
		[HarmonyPostfix]
		public static void LightPostfix(Campfire __instance, bool updateSegment)
		{
			if (updateSegment)
			{
				switch (GreenDemonChallenge.RoomGreenDemonMode)
				{
				case GreenDemonModes.NORMAL:
					GreenDemonHandler.Instance.ShrinkAllDemons();
					break;
				case GreenDemonModes.HARD:
				case GreenDemonModes.VERY_HARD:
					GreenDemonHandler.Instance.StopAllDemon(__instance.burnsFor + 1f);
					break;
				default:
					throw new ArgumentOutOfRangeException();
				}
				GreenDemonHandler.Instance.ResumeSpawning(__instance.burnsFor + 1f);
			}
		}
	}
}
namespace GreenDemonChallenge.Data
{
	public class AcceptableEnumList<T> : AcceptableValueBase where T : Enum
	{
		public virtual T[] AcceptableValues { get; }

		public AcceptableEnumList(params T[] acceptableValues)
			: base(typeof(T))
		{
			if (acceptableValues == null)
			{
				throw new ArgumentNullException("acceptableValues");
			}
			if (acceptableValues.Length == 0)
			{
				throw new ArgumentException("At least one acceptable value is needed", "acceptableValues");
			}
			AcceptableValues = acceptableValues;
		}

		public override object Clamp(object value)
		{
			if (!((AcceptableValueBase)this).IsValid(value))
			{
				return AcceptableValues[0];
			}
			return value;
		}

		public override bool IsValid(object value)
		{
			if (value is T)
			{
				T e = (T)value;
				return AcceptableValues.Any((T x) => x.Equals(e));
			}
			return false;
		}

		public override string ToDescriptionString()
		{
			return "# Acceptable values: " + string.Join(", ", AcceptableValues.Select((T x) => x.ToString()).ToArray());
		}
	}
	public enum GreenDemonCaughtEffects
	{
		RANDOM,
		KILL,
		ZOMBIFY,
		FULL_INJURY,
		HALF_INJURY,
		FULL_POISON,
		HALF_POISON,
		FULL_SPORES,
		HALF_SPORES,
		CURSE,
		EPPY,
		NO_STAM,
		ASTORNAUT,
		EXPLODE,
		POISON_CLOUD,
		SPORE_CLOUD,
		FIRE_CLOUD,
		ICE_CLOUD,
		BIOME_CLOUD,
		TORNADO,
		DYNA_BRUH,
		MANDRAKE,
		SCORPION,
		BEES,
		SCOUTMASTER,
		BLINDS,
		FALL,
		BAD_SHROOMBERRY,
		NUMBS,
		FLING,
		GO_BACK,
		SLIP,
		W_KEY_STUCK,
		POOR_BOY,
		COOKED,
		NO_FLARE,
		SET_FIRE,
		FIREBALL,
		SPAWN_LUCKY_BLOCK,
		UNNAMIFY
	}
	public enum GreenDemonModes
	{
		NORMAL,
		HARD,
		VERY_HARD
	}
	public enum GreenDemonRandomTypes
	{
		CASUAL,
		STANDARD,
		HARDCORE
	}
	public enum GreenDemonSpeeds
	{
		SLOW,
		MEDIUM,
		FAST
	}
	public enum GreenDemonTrackerSettings
	{
		OFFSCREEN,
		ALWAYS,
		NEVER
	}
}
namespace GreenDemonChallenge.Compatibility
{
	public static class LuckyBlocksCompatibilityHandler
	{
		private static bool? _enabled;

		public static bool Enabled
		{
			get
			{
				if (!_enabled.HasValue)
				{
					_enabled = Chainloader.PluginInfos.ContainsKey("legocool.LuckyBlocks");
					GreenDemonChallenge.Log.LogInfo((object)("LuckyBlocks support is " + (_enabled.Value ? "enabled" : "disabled")));
				}
				return _enabled.Value;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void PatchLuckyBlocks(Harmony harmony)
		{
			Outcomes.AddOutcome((Action<LuckyBreakable, Collision>)SpawnDemon, 1, "Green Demon Spawn");
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void SpawnDemon(LuckyBreakable lb, Collision coll)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			GreenDemonHandler.Instance.SpawnGreenDemon(((Component)lb).transform.position);
		}
	}
	public static class TimeThemeCompatibilityHandler
	{
		private static bool? _enabled;

		private static readonly Color TrackerArrowColorDay = new Color(139f / 159f, 0.8567384f, 0.7615007f, 1f);

		private static readonly Color TrackerArrowColorNight = new Color(0.6509804f, 32f / 85f, 64f / 85f, 1f);

		public static bool Enabled
		{
			get
			{
				if (!_enabled.HasValue)
				{
					_enabled = Chainloader.PluginInfos.ContainsKey("com.github.MiiMii1205.TimeTheme");
					GreenDemonChallenge.Log.LogInfo((object)("TimeTheme support is " + (_enabled.Value ? "enabled" : "disabled")));
				}
				return _enabled.Value;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void Init()
		{
			TimeThemePlugin.OnThemeChanged = (Action<bool>)Delegate.Combine(TimeThemePlugin.OnThemeChanged, new Action<bool>(UpdateAllTrackers));
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private static void UpdateAllTrackers(bool isDay)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			Color val = (isDay ? TrackerArrowColorDay : TrackerArrowColorNight);
			int i = 0;
			for (int count = GreenDemonTracker.AllTrackers.Count; i < count; i++)
			{
				GreenDemonTracker greenDemonTracker = GreenDemonTracker.AllTrackers[i];
				if (greenDemonTracker.m_group.alpha > 0f)
				{
					DOTweenModuleUI.DOColor(greenDemonTracker.m_arrowImage, val, 0.25f);
				}
				else
				{
					((Graphic)greenDemonTracker.m_arrowImage).color = val;
				}
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void InitTracker(GreenDemonTracker tracker)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: 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)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			Color val = (TimeThemePlugin.IsDarkTheme ? TrackerArrowColorNight : TrackerArrowColorDay);
			if (tracker.m_group.alpha > 0f)
			{
				DOTweenModuleUI.DOColor(tracker.m_arrowImage, val, 0.25f);
			}
			else
			{
				((Graphic)tracker.m_arrowImage).color = val;
			}
		}
	}
	public static class UnnamedCompatibilityHandler
	{
		private static bool? _enabled;

		public static bool Enabled
		{
			get
			{
				if (!_enabled.HasValue)
				{
					_enabled = Chainloader.PluginInfos.ContainsKey("com.github.MiiMii1205.UnnamedProducts");
					GreenDemonChallenge.Log.LogInfo((object)("UnnamedProducts support is " + (_enabled.Value ? "enabled" : "disabled")));
				}
				return _enabled.Value;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void SetCharacterOnFire(Character character)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			Bodypart head = character.refs.head;
			GameObject val = PhotonNetwork.Instantiate(((Object)StickyFireballController.FireballPrefab).name, ((Component)head.rig).transform.position, ((Component)head.rig).transform.rotation, (byte)0, (object[])null);
			StickyFireballController component = val.GetComponent<StickyFireballController>();
			component.StickTo(((Component)character.refs.head).gameObject);
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void SpawnFireball(Character character)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = default(GameObject);
			if (NetworkPrefabManager.TryGetNetworkPrefab("com.github.MiiMii1205.UnnamedProducts:AntifreezeExplosion", ref val))
			{
				Object.Instantiate<GameObject>(val, character.Center, Quaternion.identity);
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool IsUnnamed(Item it)
		{
			return UnnamedPlugin.IsUnnamed(((Component)it).gameObject);
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void UnnamifyInventory(Character character)
		{
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			Item currentItem = character.data.currentItem;
			if (GreenDemon.IsHoldingSomethingTemporary(character) && Object.op_Implicit((Object)(object)currentItem))
			{
				if (IsGarbageBag(currentItem))
				{
					num += UnnamifyGarbageBags(character.player.tempFullSlot.prefab, currentItem.data);
				}
				else if (UnnamedPlugin.HasUnnamedVariant(currentItem))
				{
					ItemInstanceData data = currentItem.data;
					GameObject unnamedVariant = UnnamedPlugin.GetUnnamedVariant(currentItem);
					character.player.tempFullSlot.EmptyOut();
					character.player.tempFullSlot.SetItem(unnamedVariant.GetComponent<Item>(), data);
					num++;
				}
			}
			if (!((ItemSlot)character.player.backpackSlot).IsEmpty())
			{
				if (GreenDemon.IsHoldingBackpack(character) && Object.op_Implicit((Object)(object)currentItem))
				{
					Backpack val = (Backpack)(object)((currentItem is Backpack) ? currentItem : null);
					BackpackData backpackData = default(BackpackData);
					BackpackVisuals backpackVisuals = default(BackpackVisuals);
					if (val != null && ((Item)val).data.TryGetDataEntry<BackpackData>((DataEntryKey)7, ref backpackData) && ((Component)val).TryGetComponent<BackpackVisuals>(ref backpackVisuals))
					{
						num += ChangeBackpackItems(backpackData, backpackVisuals);
					}
				}
				else if (character.player.backpackSlot.hasBackpack)
				{
					BackpackVisuals componentInChildren = ((Component)character.refs.backpackTransform).GetComponentInChildren<BackpackVisuals>(true);
					BackpackData backpackData2 = default(BackpackData);
					if (componentInChildren != null && ((ItemSlot)character.player.backpackSlot).data.TryGetDataEntry<BackpackData>((DataEntryKey)7, ref backpackData2))
					{
						num += ChangeBackpackItems(backpackData2, componentInChildren);
					}
				}
			}
			for (int num2 = character.player.itemSlots.Length - 1; num2 >= 0; num2--)
			{
				ItemSlot itemSlot = character.player.GetItemSlot((byte)num2);
				if (!itemSlot.IsEmpty())
				{
					if (IsGarbageBag(itemSlot.prefab))
					{
						num += UnnamifyGarbageBags(itemSlot.prefab, itemSlot.data);
					}
					else if (GreenDemon.IsHoldingOutSlot(character, itemSlot) && Object.op_Implicit((Object)(object)currentItem))
					{
						if (UnnamedPlugin.HasUnnamedVariant(currentItem))
						{
							ItemInstanceData data2 = currentItem.data;
							GameObject unnamedVariant2 = UnnamedPlugin.GetUnnamedVariant(currentItem);
							character.player.EmptySlot(Optionable<byte>.Some((byte)num2));
							itemSlot.SetItem(unnamedVariant2.GetComponent<Item>(), data2);
							num++;
						}
					}
					else if (UnnamedPlugin.HasUnnamedVariant(itemSlot.prefab))
					{
						GameObject unnamedVariant3 = UnnamedPlugin.GetUnnamedVariant(itemSlot.prefab);
						itemSlot.prefab = unnamedVariant3.GetComponent<Item>();
						num++;
					}
				}
			}
			character.view.RPC("SyncInventoryRPC", (RpcTarget)1, new object[2]
			{
				IBinarySerializable.ToManagedArray<InventorySyncData>(new InventorySyncData(character.player.itemSlots, character.player.backpackSlot, character.player.tempFullSlot)),
				false
			});
			GreenDemonChallenge.Log.LogInfo((object)$"Unnameified {num} item(s).");
		}

		private static int ChangeBackpackItems(BackpackData backpackData, BackpackVisuals backpackVisuals)
		{
			int num = 0;
			for (int i = 0; i < backpackData.itemSlots.Length; i++)
			{
				if (!backpackData.itemSlots[i].IsEmpty())
				{
					Item val = backpackVisuals.spawnedVisualItems[(byte)i];
					if (IsGarbageBag(val))
					{
						num += UnnamifyGarbageBags(backpackData.itemSlots[i].prefab, backpackData.itemSlots[i].data);
					}
					else if (UnnamedPlugin.HasUnnamedVariant(val))
					{
						ItemInstanceData data = val.data;
						GameObject unnamedVariant = UnnamedPlugin.GetUnnamedVariant(val);
						backpackData.itemSlots[(byte)i].EmptyOut();
						backpackVisuals.RefreshVisuals();
						backpackData.itemSlots[(byte)i].SetItem(unnamedVariant.GetComponent<Item>(), data);
						num++;
					}
				}
			}
			return num;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void RespawnFlares(Vector3 spawnPos, int amountToRespawn)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			Item val = default(Item);
			if (ItemDatabase.TryGetItem((ushort)32, ref val))
			{
				for (int i = 0; i < amountToRespawn; i++)
				{
					Item val2 = (UnnamedPlugin.ShouldBeUnnamed ? UnnamedPlugin.GetUnnamedVariant(val).GetComponent<Item>() : val);
					PhotonNetwork.InstantiateItemRoom(((Object)((Component)val2).gameObject).name, spawnPos + Vector3.up * 0.09147437f * (float)i, Quaternion.identity);
				}
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void RespawnUnnamedFlares(Vector3 spawnPos, int amountToRespawn)
		{
			//IL_0029: 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)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			Item val = default(Item);
			Item val2 = default(Item);
			if (ItemDatabase.TryGetItem((ushort)32, ref val) && UnnamedPlugin.GetUnnamedVariant(val).TryGetComponent<Item>(ref val2))
			{
				for (int i = 0; i < amountToRespawn; i++)
				{
					PhotonNetwork.InstantiateItemRoom(((Object)((Component)val2).gameObject).name, spawnPos + Vector3.up * 0.09147437f * (float)i, Quaternion.identity);
				}
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void RemoveFlairsFormGarbageBags(Item sPrefab, ItemInstanceData sData, ref int flareRemoved, ref int unnamedFlareRemoved)
		{
			UnnamedGarbageBagController val = default(UnnamedGarbageBagController);
			BackpackData val2 = default(BackpackData);
			if (!((Component)sPrefab).TryGetComponent<UnnamedGarbageBagController>(ref val) || !sData.TryGetDataEntry<BackpackData>((DataEntryKey)7, ref val2))
			{
				return;
			}
			Flare val4 = default(Flare);
			UnnamedGarbageBagController val5 = default(UnnamedGarbageBagController);
			for (int i = 0; i < val2.itemSlots.Length; i++)
			{
				ItemSlot val3 = val2.itemSlots[i];
				if (val3.IsEmpty())
				{
					continue;
				}
				if (((Component)val3.prefab).TryGetComponent<Flare>(ref val4))
				{
					if (IsUnnamed(val3.prefab))
					{
						unnamedFlareRemoved++;
					}
					else
					{
						flareRemoved++;
					}
					val3.EmptyOut();
				}
				else if (((Component)val3.prefab).TryGetComponent<UnnamedGarbageBagController>(ref val5))
				{
					RemoveFlairsFormGarbageBags(val3.prefab, val3.data, ref flareRemoved, ref unnamedFlareRemoved);
				}
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static int CookGarbageBags(Item sPrefab, ItemInstanceData sData, Item? bakcpackItem = null)
		{
			int num = 0;
			UnnamedGarbageBagController val = default(UnnamedGarbageBagController);
			BackpackData val2 = default(BackpackData);
			if (((Component)sPrefab).TryGetComponent<UnnamedGarbageBagController>(ref val) && sData.TryGetDataEntry<BackpackData>((DataEntryKey)7, ref val2))
			{
				UnnamedGarbageBagController val4 = default(UnnamedGarbageBagController);
				IntItemData val5 = default(IntItemData);
				for (int i = 0; i < val2.itemSlots.Length; i++)
				{
					ItemSlot val3 = val2.itemSlots[i];
					if (!val3.IsEmpty())
					{
						if (((Component)val3.prefab).TryGetComponent<UnnamedGarbageBagController>(ref val4))
						{
							num += CookGarbageBags(val3.prefab, val3.data);
						}
						if (val3.data.TryGetDataEntry<IntItemData>((DataEntryKey)1, ref val5))
						{
							IntItemData obj = val5;
							obj.Value++;
							num++;
						}
						num++;
					}
				}
				IntItemData val6 = default(IntItemData);
				if (Object.op_Implicit((Object)(object)bakcpackItem))
				{
					bakcpackItem.cooking.FinishCooking();
					num++;
				}
				else if (sData.TryGetDataEntry<IntItemData>((DataEntryKey)1, ref val6))
				{
					IntItemData obj2 = val6;
					obj2.Value++;
					num++;
				}
			}
			return num;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static int UnnamifyGarbageBags(Item sPrefab, ItemInstanceData sData)
		{
			int num = 0;
			UnnamedGarbageBagController val = default(UnnamedGarbageBagController);
			BackpackData val2 = default(BackpackData);
			if (((Component)sPrefab).TryGetComponent<UnnamedGarbageBagController>(ref val) && sData.TryGetDataEntry<BackpackData>((DataEntryKey)7, ref val2))
			{
				UnnamedGarbageBagController val4 = default(UnnamedGarbageBagController);
				for (int i = 0; i < val2.itemSlots.Length; i++)
				{
					ItemSlot val3 = val2.itemSlots[i];
					if (!val3.IsEmpty())
					{
						if (((Component)val3.prefab).TryGetComponent<UnnamedGarbageBagController>(ref val4))
						{
							num += UnnamifyGarbageBags(val3.prefab, val3.data);
						}
						else if (UnnamedPlugin.HasUnnamedVariant(val3.prefab))
						{
							ItemInstanceData data = val3.data;
							GameObject unnamedVariant = UnnamedPlugin.GetUnnamedVariant(val3.prefab);
							val2.itemSlots[(byte)i].EmptyOut();
							val2.itemSlots[(byte)i].SetItem(unnamedVariant.GetComponent<Item>(), data);
							num++;
						}
					}
				}
			}
			return num;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool IsGarbageBag(Item sPrefab)
		{
			UnnamedGarbageBagController val = default(UnnamedGarbageBagController);
			return ((Component)sPrefab).TryGetComponent<UnnamedGarbageBagController>(ref val);
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool HasAnyFlares(Character character)
		{
			Flare val3 = default(Flare);
			if (!((ItemSlot)character.player.backpackSlot).IsEmpty())
			{
				BackpackData val4 = default(BackpackData);
				if (GreenDemon.IsHoldingBackpack(character) && Object.op_Implicit((Object)(object)character.data.currentItem))
				{
					Backpack val = default(Backpack);
					if (((Component)character.data.currentItem).TryGetComponent<Backpack>(ref val))
					{
						(byte, BackpackReference) value = ((Item)val).backpackReference.Value;
						ItemSlot[] itemSlots = ((BackpackReference)(ref value.Item2)).GetData().itemSlots;
						foreach (ItemSlot val2 in itemSlots)
						{
							if (!val2.IsEmpty() && (((Component)val2.prefab).TryGetComponent<Flare>(ref val3) || CheckForFlareInGarbageBag(val2)))
							{
								return true;
							}
						}
					}
				}
				else if (character.player.backpackSlot.hasBackpack && ((ItemSlot)character.player.backpackSlot).data.TryGetDataEntry<BackpackData>((DataEntryKey)7, ref val4))
				{
					ItemSlot[] itemSlots2 = val4.itemSlots;
					foreach (ItemSlot val5 in itemSlots2)
					{
						if (!val5.IsEmpty() && (((Component)val5.prefab).TryGetComponent<Flare>(ref val3) || CheckForFlareInGarbageBag(val5)))
						{
							return true;
						}
					}
				}
			}
			ItemSlot[] itemSlots3 = character.player.itemSlots;
			foreach (ItemSlot val6 in itemSlots3)
			{
				if (!val6.IsEmpty() && (((Component)val6.prefab).TryGetComponent<Flare>(ref val3) || CheckForFlareInGarbageBag(val6)))
				{
					return true;
				}
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private static bool CheckForFlareInGarbageBag(ItemSlot itemSlot)
		{
			UnnamedGarbageBagController val = default(UnnamedGarbageBagController);
			BackpackData val2 = default(BackpackData);
			if (((Component)itemSlot.prefab).TryGetComponent<UnnamedGarbageBagController>(ref val) && itemSlot.data.TryGetDataEntry<BackpackData>((DataEntryKey)7, ref val2))
			{
				ItemSlot[] itemSlots = val2.itemSlots;
				Flare val4 = default(Flare);
				foreach (ItemSlot val3 in itemSlots)
				{
					if (!itemSlot.IsEmpty() && (((Component)val3.prefab).TryGetComponent<Flare>(ref val4) || CheckForFlareInGarbageBag(val3)))
					{
						return true;
					}
				}
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void TryTurnIntoUnnamed(ref Item item)
		{
			Item val = default(Item);
			if (UnnamedPlugin.HasUnnamedVariant(item) && UnnamedPlugin.ShouldBeUnnamed && UnnamedPlugin.GetUnnamedVariant(item).TryGetComponent<Item>(ref val))
			{
				item = val;
			}
		}
	}
}
namespace GreenDemonChallenge.Behaviour
{
	public class DestroyAfterEmit : MonoBehaviour
	{
		public ParticleSystem m_particle;

		private void Awake()
		{
			if (m_particle == null)
			{
				m_particle = ((Component)this).GetComponent<ParticleSystem>();
			}
		}

		private IEnumerator Start()
		{
			m_particle.Play();
			yield return (object)new WaitUntil((Func<bool>)(() => !m_particle.IsAlive()));
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}
	public class GreenDemon : MonoBehaviourPunCallbacks
	{
		public static List<GreenDemon> AllDemons = new List<GreenDemon>();

		public SphereCollider collider;

		public float mass = 5f;

		public Rigidbody rig;

		public AudioSource source;

		public Transform m_demonTransform;

		public Renderer mainRenderer;

		public Animator animator;

		public float m_catchRadius = 1f;

		private float m_chaseTimeout;

		private float m_chaseUpdateCooldown = 3f;

		private readonly LayerMask m_characterLayerMask = LayerMask.op_Implicit(1024);

		private Character m_chasingCharacter;

		private float m_destroyTick;

		private bool m_inActiveChase;

		private bool m_isConsumed;

		private bool m_isShrinking;

		private const float MovementForce = 250f;

		public float m_stopTick;

		public Action? OnPlayerCaught;

		public Action? OnShrink;

		private PhysicsSyncer m_physSyncer;

		private float m_shrinkDuration = 1.25f;

		private double m_timeSinceTick;

		private PhotonView view;

		private bool m_isSpawning = true;

		public float vel;

		public SFX_Instance[] m_impact;

		public float velMult = 10f;

		public SFX_Instance[] consumedSfx = Array.Empty<SFX_Instance>();

		public SFX_Instance[] shrunkSfx = Array.Empty<SFX_Instance>();

		public GameObject? m_vfxPrefab;

		public GameObject? m_poofVfxPrefab;

		private Vector3 m_movement = Vector3.forward;

		private float m_minSpeedSqrDistance;

		private float m_maxSpeedSqrDistance;

		private Vector3 m_baseSpeed;

		private Vector3 m_kilnBaseSpeed;

		private float m_roomSpeedMultiplier;

		public GreenDemonDetector m_detector;

		public int m_demonIndex;

		public Vector3 Center
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				if (ClassExtensionsMethods.UnityObjectExists<Renderer>(mainRenderer))
				{
					Bounds bounds = mainRenderer.bounds;
					return ((Bounds)(ref bounds)).center;
				}
				return ((Component)this).transform.position;
			}
		}

		public bool IsChasingLocalPlayer
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get;
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			private set;
		}

		private bool ShouldSearchForAnotherTarget
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get
			{
				if (HasTarget)
				{
					return !m_chasingCharacter.IsLocal;
				}
				return true;
			}
		}

		private float ChaseDelay
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get
			{
				if (m_demonIndex <= 0)
				{
					return 0f;
				}
				return (float)m_demonIndex * (GreenDemonChallenge.RoomGreenDemonDelay / 2f) + RandomDelayOffset;
			}
		}

		private static float RandomDelayOffset
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get
			{
				return Random.Range((0f - GreenDemonChallenge.RoomGreenDemonDelay) / 4f, GreenDemonChallenge.RoomGreenDemonDelay / 4f);
			}
		}

		public Vector3 TargetPosition
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get
			{
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				Character chasingCharacter = m_chasingCharacter;
				if (chasingCharacter == null)
				{
					return GreenDemonHandler.Instance.GroupPosition;
				}
				return chasingCharacter.Center;
			}
		}

		private Vector3 BaseSpeed
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get
			{
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: 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)
				if (Singleton<MapHandler>.Instance.currentSegment != 3)
				{
					if (Singleton<MapHandler>.Instance.currentSegment != 4 || GreenDemonHandler.Instance.m_reachedPeak)
					{
						return m_baseSpeed;
					}
					return m_kilnBaseSpeed;
				}
				return Vector3.one;
			}
		}

		private Vector3 MoveSpeed
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//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)
				//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_0054: Unknown result type (might be due to invalid IL or missing references)
				Vector3 val = BaseSpeed + ExtDataTypes.ToVec(0);
				float minSpeedSqrDistance = m_minSpeedSqrDistance;
				float maxSpeedSqrDistance = m_maxSpeedSqrDistance;
				Vector3 val2 = TargetPosition - Center;
				return val * (Util.RangeLerp(0.5f, 1f, minSpeedSqrDistance, maxSpeedSqrDistance, ((Vector3)(ref val2)).sqrMagnitude, true, (AnimationCurve)null) * (250f * m_roomSpeedMultiplier));
			}
		}

		public bool HasTarget
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get
			{
				return Object.op_Implicit((Object)(object)m_chasingCharacter);
			}
		}

		private void Awake()
		{
			if (view == null)
			{
				view = ((Component)this).GetComponent<PhotonView>();
			}
			AddPhysics();
			if (m_physSyncer == null)
			{
				m_physSyncer = ((Component)this).GetComponent<PhysicsSyncer>();
			}
			if (animator == null)
			{
				animator = ((Component)this).GetComponent<Animator>();
			}
			if (source == null)
			{
				source = ((Component)this).GetComponent<AudioSource>();
			}
			if (mainRenderer == null)
			{
				mainRenderer = ((Component)this).GetComponent<Renderer>();
			}
			if (m_demonTransform == null)
			{
				m_demonTransform = ((Component)mainRenderer).transform;
			}
		}

		private void Start()
		{
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: 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)
			GreenDemonChallenge.Log.LogInfo((object)"SPAWN A GREEN DEMON!");
			GreenDemonGUIManager.Instance.TheDemonIsHere();
			source.volume = GreenDemonChallenge.GreenDemonVolume.Value;
			m_inActiveChase = true;
			AllDemons.Add(this);
			GreenDemonGUIManager.Instance.AddDemonTracker(this);
			m_minSpeedSqrDistance = Mathf.Pow(source.minDistance, 2f);
			m_maxSpeedSqrDistance = Mathf.Pow(source.maxDistance, 2f);
			m_baseSpeed = new Vector3(1f, 0.5f, 1f);
			m_kilnBaseSpeed = new Vector3(0.8f, 0.95f, 0.8f);
			m_roomSpeedMultiplier = GreenDemonChallenge.RoomGreenDemonSpeed switch
			{
				GreenDemonSpeeds.SLOW => 0.5f, 
				GreenDemonSpeeds.MEDIUM => 1f, 
				GreenDemonSpeeds.FAST => 2f, 
				_ => throw new ArgumentOutOfRangeException(), 
			};
			((MonoBehaviour)this).StartCoroutine(WaitForSpawnAnimationToFinish());
		}

		private IEnumerator WaitForSpawnAnimationToFinish()
		{
			m_isSpawning = true;
			yield return (object)new WaitUntil((Func<bool>)(() => !PExt.IsPlaying(animator, "GreenDemonSpawn", 0)));
			yield return (object)new WaitForSecondsRealtime(GreenDemonChallenge.RoomGreenDemonDelay + ChaseDelay);
			m_isSpawning = false;
			source.Play();
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private void PlayImpactSound(Vector3 pos)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			int i = 0;
			for (int num = m_impact.Length; i < num; i++)
			{
				m_impact[i].Play(pos);
			}
		}

		private void Update()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			if (!m_isSpawning && !m_isConsumed)
			{
				UpdateChase();
			}
			if (Object.op_Implicit((Object)(object)rig) && !rig.isKinematic)
			{
				vel = Mathf.Lerp(vel, Vector3.SqrMagnitude(rig.linearVelocity) * velMult, 10f * Time.deltaTime);
			}
		}

		private void FixedUpdate()
		{
			//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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			if (m_isSpawning || !PhotonNetwork.InRoom || m_isConsumed)
			{
				return;
			}
			m_chaseTimeout += Time.fixedDeltaTime;
			if (m_stopTick > 0f)
			{
				m_stopTick -= Time.fixedDeltaTime;
			}
			else
			{
				if (!view.IsMine)
				{
					return;
				}
				if (HasTarget)
				{
					Vector3 val = TargetPosition - Center;
					Vector3 val2 = Vector3.Scale(((Vector3)(ref val)).normalized, MoveSpeed);
					rig.AddForce(val2 * Time.fixedDeltaTime, (ForceMode)5);
					m_movement = ((Vector3)(ref val2)).normalized;
					CheckForCaughtPlayers();
				}
				Vector3 val3 = TargetPosition - Center;
				foreach (GreenDemon value in m_detector.m_demons.Values)
				{
					if (Object.op_Implicit((Object)(object)value))
					{
						Vector3 val4 = value.Center - Center;
						Vector3 val5 = Vector3.Scale(((Vector3)(ref val4)).normalized, -MoveSpeed * Util.RangeLerp(Util.RangeLerp(0.125f, 0.75f, m_minSpeedSqrDistance, m_maxSpeedSqrDistance, Vector3.SqrMagnitude(val3), true, (AnimationCurve)null), 0f, 0f, m_detector.m_detectorRadius * m_detector.m_detectorRadius, Vector3.SqrMagnitude(val4), true, (AnimationCurve)null));
						rig.AddForce(val5 * Time.fixedDeltaTime, (ForceMode)5);
					}
				}
			}
		}

		public void RefreshVolume()
		{
			source.volume = GreenDemonChallenge.GreenDemonVolume.Value;
		}

		private void OnDestroy()
		{
			AllDemons.Remove(this);
		}

		private void PlayImpactSounds(Collision collision)
		{
			//IL_0021: 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)
			if (Object.op_Implicit((Object)(object)rig))
			{
				if (vel > 4f && !ExtGameObject.IsInLayer(collision.gameObject, m_characterLayerMask))
				{
					view.RPC("RPC_PlayImpactSFX", (RpcTarget)0, new object[1] { Center });
				}
				vel = 0f;
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private Vector3 CalculateCollisionForce(Collision col)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: 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_00bf: 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_002b: 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_003d: 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_004b: 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_004f: 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_0061: 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_006c: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = col.impulse;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			if (col.contactCount > 0)
			{
				Vector3 val2 = Vector3.zero;
				for (int num = col.contacts.Length - 1; num >= 0; num--)
				{
					val2 += ((ContactPoint)(ref col.contacts[num])).normal;
				}
				Vector3 val3 = normalized;
				val = Vector3.Lerp(normalized, ((Vector3)(ref val2)).normalized, 0.65f);
				normalized = val3 + Vector3.Scale(((Vector3)(ref val)).normalized, MoveSpeed);
			}
			else
			{
				normalized = Vector3.Scale(normalized, MoveSpeed);
			}
			Vector3 val4 = normalized;
			val = TargetPosition - Center;
			return val4 + Vector3.Scale(((Vector3)(ref val)).normalized, -MoveSpeed) * Time.fixedDeltaTime;
		}

		private void OnCollisionEnter(Collision col)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			if (m_inActiveChase && ExtGameObject.IsInLayer(col.gameObject, m_characterLayerMask))
			{
				Character componentInParent = col.gameObject.GetComponentInParent<Character>();
				if (componentInParent != null && Object.op_Implicit((Object)(object)componentInParent) && componentInParent.IsLocal && TargetIsValid(componentInParent))
				{
					CatchPlayer(Character.localCharacter);
					return;
				}
			}
			rig.AddForce(CalculateCollisionForce(col), (ForceMode)5);
			if (view.IsMine)
			{
				PlayImpactSounds(col);
			}
		}

		private void OnCollisionStay(Collision col)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			if (!ExtGameObject.IsInLayer(col.gameObject, m_characterLayerMask))
			{
				rig.AddForce(CalculateCollisionForce(col), (ForceMode)5);
				if (view.IsMine)
				{
					PlayImpactSounds(col);
				}
			}
		}

		private void AddPhysics()
		{
			if (rig == null)
			{
				rig = ExtGameObject.GetOrAddComponent<Rigidbody>(((Component)this).gameObject);
			}
			rig.mass = mass;
			rig.interpolation = (RigidbodyInterpolation)1;
			rig.collisionDetectionMode = (CollisionDetectionMode)2;
			if (collider == null)
			{
				collider = ((Component)this).GetComponent<SphereCollider>();
			}
			m_catchRadius = collider.radius * 1.25f;
		}

		private void ForceSyncForFrames(int frames = 10)
		{
			if (Object.op_Implicit((Object)(object)m_physSyncer))
			{
				m_physSyncer.forceSyncFrames = frames;
			}
		}

		public override void OnPlayerEnteredRoom(Player newPlayer)
		{
			((MonoBehaviourPunCallbacks)this).OnPlayerEnteredRoom(newPlayer);
			if (view.IsMine)
			{
				ForceSyncForFrames();
				view.RPC("UpdateNewChasingCharacter", newPlayer, new object[1] { m_chasingCharacter.view.ViewID });
			}
		}

		[PunRPC]
		public void RequestUpdatePlayerChase(int viewId, float distSqr)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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)
			Vector3 center = Center;
			Character val = default(Character);
			if (!HasTarget || (Character.GetCharacterWithPhotonID(viewId, ref val) && Object.op_Implicit((Object)(object)val) && (Object)(object)val != (Object)(object)m_chasingCharacter && TargetIsValid(val) && distSqr < Vector3.SqrMagnitude(m_chasingCharacter.Center - center)))
			{
				GreenDemonChallenge.Log.LogInfo((object)"Sending update for chase change");
				view.RPC("UpdateNewChasingCharacter", (RpcTarget)0, new object[1] { viewId });
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private static bool TargetIsValid(Character target)
		{
			if (!target.isBot && !target.data.dead && !target.data.fullyPassedOut)
			{
				return GreenDemonHandler.Instance.ShouldChaseCharacter(target);
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsHoldingSomethingTemporary(Character c)
		{
			if (!c.player.tempFullSlot.IsEmpty() && c.refs.items.currentSelectedSlot.IsSome)
			{
				return c.refs.items.currentSelectedSlot.Value == c.player.tempFullSlot.itemSlotID;
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsHoldingBackpack(Character c)
		{
			if (!((ItemSlot)c.player.backpackSlot).IsEmpty() && c.refs.items.currentSelectedSlot.IsSome)
			{
				return c.refs.items.currentSelectedSlot.Value == ((ItemSlot)c.player.backpackSlot).itemSlotID;
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsHoldingOutSlot(Character c, ItemSlot s)
		{
			if (!s.IsEmpty() && c.refs.items.currentSelectedSlot.IsSome)
			{
				return c.refs.items.currentSelectedSlot.Value == s.itemSlotID;
			}
			return false;
		}

		[PunRPC]
		public void UpdateNewChasingCharacter(int viewId)
		{
			Character val = default(Character);
			if (Character.GetCharacterWithPhotonID(viewId, ref val) && (Object)(object)m_chasingCharacter != (Object)(object)val)
			{
				m_chasingCharacter = val;
				GreenDemonChallenge.Log.LogInfo((object)$"New target: {val}!");
				IsChasingLocalPlayer = m_chasingCharacter.IsLocal;
				m_chaseTimeout = 0f;
				if (view.IsMine && !object.Equals(val.view.Owner, view.Owner))
				{
					GreenDemonChallenge.Log.LogInfo((object)$"Transferring ownership to {val.view.Owner}...");
					view.TransferOwnership(val.view.Owner);
				}
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private void CheckForCaughtPlayers()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			if (m_inActiveChase && Object.op_Implicit((Object)(object)Character.localCharacter) && TargetIsValid(Character.localCharacter) && Vector3.SqrMagnitude(Character.localCharacter.Center - Center) <= m_catchRadius * m_catchRadius)
			{
				CatchPlayer(Character.localCharacter);
			}
		}

		private static void RemoveFlairFromBackpack(BackpackData backpackData, BackpackVisuals backpackVisuals, ref int flareRemoved, ref int unnamedFlareRemoved)
		{
			Flare val2 = default(Flare);
			for (int i = 0; i < backpackData.itemSlots.Length; i++)
			{
				if (backpackData.itemSlots[i].IsEmpty())
				{
					continue;
				}
				Item val = backpackVisuals.spawnedVisualItems[(byte)i];
				if (UnnamedCompatibilityHandler.Enabled && UnnamedCompatibilityHandler.IsGarbageBag(backpackData.itemSlots[i].prefab))
				{
					UnnamedCompatibilityHandler.RemoveFlairsFormGarbageBags(backpackData.itemSlots[i].prefab, backpackData.itemSlots[i].data, ref flareRemoved, ref unnamedFlareRemoved);
				}
				else if (((Component)val).TryGetComponent<Flare>(ref val2))
				{
					if (UnnamedCompatibilityHandler.Enabled && UnnamedCompatibilityHandler.IsUnnamed(val))
					{
						unnamedFlareRemoved++;
					}
					else
					{
						flareRemoved++;
					}
					PhotonNetwork.Destroy(((Component)val).gameObject);
					backpackData.itemSlots[(byte)i].EmptyOut();
					backpackVisuals.RefreshVisuals();
				}
			}
		}

		private static int CookItemFromBackpack(BackpackData backpackData, BackpackVisuals backpackVisuals)
		{
			int num = 0;
			for (int i = 0; i < backpackData.itemSlots.Length; i++)
			{
				if (!backpackData.itemSlots[i].IsEmpty())
				{
					Item val = backpackVisuals.spawnedVisualItems[(byte)i];
					if (UnnamedCompatibilityHandler.Enabled && UnnamedCompatibilityHandler.IsGarbageBag(backpackData.itemSlots[i].prefab))
					{
						num += UnnamedCompatibilityHandler.CookGarbageBags(backpackData.itemSlots[i].prefab, backpackData.itemSlots[i].data, val);
						continue;
					}
					val.cooking.FinishCooking();
					num++;
				}
			}
			return num;
		}

		private void ApplyEffect(Character character, GreenDemonCaughtEffects effect)
		{
			//IL_09a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c6: Expected O, but got Unknown
			//IL_0596: Unknown result type (might be due to invalid IL or missing references)
			//IL_059b: Unknown result type (might be due to invalid IL or missing references)
			//IL_045c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04da: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0486: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f2: 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_0868: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_050c: Expected O, but got Unknown
			//IL_0518: Unknown result type (might be due to invalid IL or missing references)
			//IL_051d: Unknown result type (might be due to invalid IL or missing references)
			//IL_052e: Expected O, but got Unknown
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: 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_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0701: Unknown result type (might be due to invalid IL or missing references)
			//IL_070b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0710: Unknown result type (might be due to invalid IL or missing references)
			//IL_0715: Unknown result type (might be due to invalid IL or missing references)
			//IL_0746: Unknown result type (might be due to invalid IL or missing references)
			//IL_0752: Unknown result type (might be due to invalid IL or missing references)
			//IL_0757: Unknown result type (might be due to invalid IL or missing references)
			//IL_075c: 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_0769: Unknown result type (might be due to invalid IL or missing references)
			//IL_0773: Unknown result type (might be due to invalid IL or missing references)
			//IL_0778: Unknown result type (might be due to invalid IL or missing references)
			//IL_0781: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e6: Unknown result type (might be due to invalid IL or missing references)
			GreenDemonChallenge.Log.LogInfo((object)$"Applying effect: {effect} to {character}...");
			Vector3 val9;
			switch (effect)
			{
			case GreenDemonCaughtEffects.RANDOM:
			{
				GreenDemonCaughtEffects[] array = (GreenDemonCaughtEffects[])Enum.GetValues(typeof(GreenDemonCaughtEffects));
				GreenDemonCaughtEffects random;
				do
				{
					random = ArrayExtensions.GetRandom<GreenDemonCaughtEffects>(array);
				}
				while (!IsEffectRandoValid(character, random, GreenDemonChallenge.RoomGreenDemonRandomType));
				ApplyEffect(character, random);
				break;
			}
			case GreenDemonCaughtEffects.KILL:
				character.DieInstantly();
				break;
			case GreenDemonCaughtEffects.ZOMBIFY:
				if (!character.TryCheckpoint())
				{
					character.view.RPC("RPCA_Zombify", (RpcTarget)0, new object[1] { character.Center });
				}
				break;
			case GreenDemonCaughtEffects.FULL_INJURY:
				character.refs.afflictions.AddStatus((STATUSTYPE)0, 1f, false, true, true);
				break;
			case GreenDemonCaughtEffects.HALF_INJURY:
				character.refs.afflictions.AddStatus((STATUSTYPE)0, 0.5f, false, true, true);
				break;
			case GreenDemonCaughtEffects.FULL_POISON:
				character.refs.afflictions.AddStatus((STATUSTYPE)3, 1f, false, true, true);
				break;
			case GreenDemonCaughtEffects.HALF_POISON:
				character.refs.afflictions.AddStatus((STATUSTYPE)3, 0.5f, false, true, true);
				break;
			case GreenDemonCaughtEffects.FULL_SPORES:
				character.refs.afflictions.AddStatus((STATUSTYPE)10, 1f, false, true, true);
				break;
			case GreenDemonCaughtEffects.HALF_SPORES:
				character.refs.afflictions.AddStatus((STATUSTYPE)10, 0.5f, false, true, true);
				break;
			case GreenDemonCaughtEffects.CURSE:
				character.refs.afflictions.AddStatus((STATUSTYPE)5, 0.25f, false, true, true);
				break;
			case GreenDemonCaughtEffects.FLING:
			{
				Vector3 back = Vector3.back;
				val9 = Center - character.Center;
				val9 = back + ((Vector3)(ref val9)).normalized;
				character.AddForce(((Vector3)(ref val9)).normalized * 125f / Time.fixedDeltaTime, 1f, 1f);
				break;
			}
			case GreenDemonCaughtEffects.FALL:
				character.Fall(30f, 0f);
				break;
			case GreenDemonCaughtEffects.SCOUTMASTER:
			{
				Scoutmaster val6 = default(Scoutmaster);
				if (Scoutmaster.GetPrimaryScoutmaster(ref val6))
				{
					val6.SetCurrentTarget(character, 60f);
					break;
				}
				GreenDemonChallenge.Log.LogWarning((object)"Can't call the SCOUTMASTER right now. Flinging you instead...");
				ApplyEffect(character, GreenDemonCaughtEffects.FLING);
				break;
			}
			case GreenDemonCaughtEffects.POOR_BOY:
			{
				int itemRemoved = 0;
				RemoveTemporaryItem(character, ref itemRemoved);
				RemoveBackpack(character, ref itemRemoved);
				RemoveWholeInventory(character, ref itemRemoved);
				character.view.RPC("SyncInventoryRPC", (RpcTarget)1, new object[2]
				{
					IBinarySerializable.ToManagedArray<InventorySyncData>(new InventorySyncData(character.player.itemSlots, character.player.backpackSlot, character.player.tempFullSlot)),
					false
				});
				GreenDemonChallenge.Log.LogInfo((object)$"Removed {itemRemoved} item(s).");
				break;
			}
			case GreenDemonCaughtEffects.NO_FLARE:
			{
				int flareRemoved = 0;
				int unnamedFlareRemoved = 0;
				RemoveTemporaryFlares(character, ref unnamedFlareRemoved, ref flareRemoved);
				RemoveFlaresFromBackpack(character, ref flareRemoved, ref unnamedFlareRemoved);
				RemoveFlaresFromInventory(character, ref flareRemoved, ref unnamedFlareRemoved);
				character.view.RPC("SyncInventoryRPC", (RpcTarget)1, new object[2]
				{
					IBinarySerializable.ToManagedArray<InventorySyncData>(new InventorySyncData(character.player.itemSlots, character.player.backpackSlot, character.player.tempFullSlot)),
					false
				});
				int num = flareRemoved + unnamedFlareRemoved;
				GreenDemonChallenge.Log.LogInfo((object)$"Removed {num} flare(s).");
				RespawnFlares(unnamedFlareRemoved, flareRemoved);
				break;
			}
			case GreenDemonCaughtEffects.COOKED:
			{
				int cookedItems = 0;
				CookTemporaryItem(character, ref cookedItems);
				CookBackpackItems(character, ref cookedItems);
				CookInventoryItems(character, ref cookedItems);
				character.view.RPC("SyncInventoryRPC", (RpcTarget)1, new object[2]
				{
					IBinarySerializable.ToManagedArray<InventorySyncData>(new InventorySyncData(character.player.itemSlots, character.player.backpackSlot, character.player.tempFullSlot)),
					false
				});
				GreenDemonChallenge.Log.LogInfo((object)$"Cooked {cookedItems} item(s).");
				break;
			}
			case GreenDemonCaughtEffects.EPPY:
				character.refs.afflictions.AddStatus((STATUSTYPE)6, 1f, false, true, true);
				break;
			case GreenDemonCaughtEffects.POISON_CLOUD:
				((MonoBehaviourPun)GreenDemonHandler.Instance).photonView.RPC("RPC_SpawnPoisonCloud", (RpcTarget)0, new object[1] { character.Center });
				break;
			case GreenDemonCaughtEffects.ICE_CLOUD:
				((MonoBehaviourPun)GreenDemonHandler.Instance).photonView.RPC("RPC_SpawnIceCloud", (RpcTarget)0, new object[1] { character.Center });
				break;
			case GreenDemonCaughtEffects.FIRE_CLOUD:
				((MonoBehaviourPun)GreenDemonHandler.Instance).photonView.RPC("RPC_SpawnFireCloud", (RpcTarget)0, new object[1] { character.Center });
				break;
			case GreenDemonCaughtEffects.SPORE_CLOUD:
				((MonoBehaviourPun)GreenDemonHandler.Instance).photonView.RPC("RPC_SpawnSporeCloud", (RpcTarget)0, new object[1] { character.Center });
				break;
			case GreenDemonCaughtEffects.BLINDS:
				character.refs.afflictions.AddAffliction((Affliction)new Affliction_Blind
				{
					totalTime = 60f
				}, false);
				break;
			case GreenDemonCaughtEffects.NUMBS:
				character.refs.afflictions.AddAffliction((Affliction)new Affliction_Numb
				{
					totalTime = 60f
				}, false);
				break;
			case GreenDemonCaughtEffects.BIOME_CLOUD:
				SpawnBiomeCloud(character);
				break;
			case GreenDemonCaughtEffects.DYNA_BRUH:
				ForceGiveItem(character, 106, GreenDemonCaughtEffects.HALF_INJURY);
				break;
			case GreenDemonCaughtEffects.MANDRAKE:
				ForceGiveItem(character, 155, GreenDemonCaughtEffects.EPPY);
				break;
			case GreenDemonCaughtEffects.SCORPION:
				ForceGiveItem(character, 111, GreenDemonCaughtEffects.HALF_POISON);
				break;
			case GreenDemonCaughtEffects.BAD_SHROOMBERRY:
				character.refs.afflictions.AddStatus((STATUSTYPE)10, 0.05f, false, true, true);
				((MonoBehaviour)character).StartCoroutine(DoRandomShroomberryEffect(character, IEnumerableExtensions.RandomElement<int>((IEnumerable<int>)Action_RandomMushroomEffect.BadEffects)));
				break;
			case GreenDemonCaughtEffects.EXPLODE:
			{
				GameObject val13 = PhotonNetwork.Instantiate("0_Items/Dynamite", character.Center, Quaternion.identity, (byte)0, (object[])null);
				Dynamite val14 = default(Dynamite);
				if (val13.TryGetComponent<Dynamite>(ref val14))
				{
					val14.LightFlare();
					val14.startingFuseTime = 0f;
				}
				else
				{
					GreenDemonChallenge.Log.LogWarning((object)"Can't find dynamite. Deleting spawned object and make you hurt instead");
					PhotonNetwork.Destroy(val13);
					ApplyEffect(character, GreenDemonCaughtEffects.HALF_INJURY);
				}
				break;
			}
			case GreenDemonCaughtEffects.TORNADO:
			{
				GameObject val11 = PhotonNetwork.Instantiate("Tornado", character.Center, Quaternion.identity, (byte)0, (object[])null);
				Tornado val12 = default(Tornado);
				if (val11.TryGetComponent<Tornado>(ref val12))
				{
					val12.tornadoLifetimeMax = 12f;
					val12.tornadoLifetimeMin = 20f;
					val12.force = 75f;
					val12.selectNewTargetInSeconds = 35f;
					val12.targetParent = ((Component)character.refs.hip).transform;
					val12.target = ((Component)character).transform;
					((MonoBehaviour)GreenDemonHandler.Instance).StartCoroutine(GreenDemonHandler.ForceTornadoTarget(val12, ((Component)character).transform, val12.selectNewTargetInSeconds));
				}
				else
				{
					GreenDemonChallenge.Log.LogWarning((object)"Can't find tornado. Deleting spawned object and make you fling instead");
					PhotonNetwork.Destroy(val11);
					ApplyEffect(character, GreenDemonCaughtEffects.FLING);
				}
				break;
			}
			case GreenDemonCaughtEffects.GO_BACK:
				if (!character.TryCheckpoint())
				{
					character.view.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2]
					{
						MapHandler.CurrentBaseCampSpawnPoint.position,
						true
					});
				}
				break;
			case GreenDemonCaughtEffects.SPAWN_LUCKY_BLOCK:
				if (LuckyBlocksCompatibilityHandler.Enabled)
				{
					GameObject val7 = PhotonNetwork.Instantiate("0_Items/legocool.LuckyBlocks:LuckyBlock", ((Component)character.refs.head).transform.position + Vector3.up * 1.85f, Quaternion.identity, (byte)0, (object[])null);
					Item val8 = default(Item);
					if (val7.TryGetComponent<Item>(ref val8))
					{
						val8.lastThrownCharacter = character;
						val9 = ((Component)character.refs.head).transform.position - ((Component)val8).transform.position;
						Vector3 val10 = ((Vector3)(ref val9)).normalized * 25f / Time.deltaTime;
						val8.rig.AddForce(val10, (ForceMode)5);
					}
					else
					{
						GreenDemonChallenge.Log.LogWarning((object)"Can't find item component. Deleting spawned object and give you a RANDOM effect instead.");
						PhotonNetwork.Destroy(val7);
						ApplyEffect(character, GreenDemonCaughtEffects.RANDOM);
					}
				}
				else
				{
					GreenDemonChallenge.Log.LogWarning((object)"Can't find Lucky Blocks... Giving you a RANDOM effect instead.");
					ApplyEffect(character, GreenDemonCaughtEffects.RANDOM);
				}
				break;
			case GreenDemonCaughtEffects.UNNAMIFY:
				if (UnnamedCompatibilityHandler.Enabled)
				{
					UnnamedCompatibilityHandler.UnnamifyInventory(character);
					break;
				}
				GreenDemonChallenge.Log.LogWarning((object)"Can't find Unnamed Products... Giving you a RANDOM effect instead.");
				ApplyEffect(character, GreenDemonCaughtEffects.RANDOM);
				break;
			case GreenDemonCaughtEffects.SET_FIRE:
				if (UnnamedCompatibilityHandler.Enabled)
				{
					UnnamedCompatibilityHandler.SetCharacterOnFire(character);
					break;
				}
				GreenDemonChallenge.Log.LogWarning((object)"Can't find Unnamed Products... Giving you a FIRE CLOUD effect instead.");
				ApplyEffect(character, GreenDemonCaughtEffects.FIRE_CLOUD);
				break;
			case GreenDemonCaughtEffects.FIREBALL:
				if (UnnamedCompatibilityHandler.Enabled)
				{
					((MonoBehaviourPun)GreenDemonHandler.Instance).photonView.RPC("RPC_ThrowFireball", (RpcTarget)2, new object[1] { character.view.ViewID });
				}
				else
				{
					GreenDemonChallenge.Log.LogWarning((object)"Can't find Unnamed Products... Giving you a FIRE CLOUD effect instead.");
					ApplyEffect(character, GreenDemonCaughtEffects.FIRE_CLOUD);
				}
				break;
			case GreenDemonCaughtEffects.BEES:
			{
				GameObject val4 = PhotonNetwork.Instantiate("BeeSwarm", character.Head, Quaternion.identity, (byte)0, (object[])null);
				BeeSwarm val5 = default(BeeSwarm);
				if (val4.TryGetComponent<BeeSwarm>(ref val5))
				{
					((MonoBehaviourPun)val5).photonView.RPC("SetBeesAngryRPC", (RpcTarget)0, new object[1] { true });
				}
				else
				{
					GreenDemonChallenge.Log.LogWarning((object)"Can't find bees. Deleting