Decompiled source of VanillaPlusAscent v0.2.1

AdditionalAscents.dll

Decompiled 3 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Peak.Afflictions;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
using UnityEngine.UI;
using Zorro.Core;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("AdditionalAscents")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AdditionalAscents")]
[assembly: AssemblyTitle("AdditionalAscents")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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;
		}
	}
}
namespace AdditionalAscents
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "AdditionalAscents";

		public const string PLUGIN_NAME = "AdditionalAscents";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace VanillaPlusAscents
{
	public static class ModConfig
	{
		public static int Level_ForagersTax = 9;

		public static int Level_WornEquipment = 10;

		public static int Level_HarshClimates = 11;

		public static int Level_UniqueStatuses = 12;

		public static int Level_SurgingMist = 13;

		public static int Level_NoCampfirePetrify = 14;

		public static string Title_Ascent9 = "Ascent 9";

		public static string Desc_Ascent9 = "FORAGED FOODS ARE LESS NOURISHING.";

		public static string Title_Ascent10 = "Ascent 10";

		public static string Desc_Ascent10 = "SUPPLIES ARE WORN.";

		public static string Title_Ascent11 = "Ascent 11";

		public static string Desc_Ascent11 = "CLIMATES ARE HARSHER IN CALDERA AND GLOOM.";

		public static string Title_Ascent12 = "Ascent 12";

		public static string Desc_Ascent12 = "STATUS AILMENTS HAS SPECIAL EFFECTS.";

		public static string Title_Ascent13 = "Ascent 13";

		public static string Desc_Ascent13 = "THE FOG IS FASTER.";

		public static string Title_Ascent14 = "Ascent 14";

		public static string Desc_Ascent14 = "CAMPFIRES NO LONGER HEAL PETRIFICATION.";

		public static float RawFoodHungerMultiplier = 0.5f;

		public static float CalderaSunHeatRate = 0.005f;

		public static float GloomNightColdRate = 0.005f;

		public static float CalderaLockedTimeOfDay = 10.65f;

		public static float WeightMaxFallDamageMult = 2f;

		public static float PoisonBurstThreshold = 0.25f;

		public static float PoisonBurstTimeWindow = 13f;

		public static float PukeHungerInflicted = 0.2f;

		public static float PukeStumbleDuration = 0.6f;

		public static float SporeMinNumbDuration = 5f;

		public static float SporeMaxNumbDuration = 45f;

		public static float SporeCheckInterval = 5f;

		public static float SporeTriggerChanceMult = 0.85f;

		public static float SporeCooldownExtra = 15f;

		public static float ColdMaxRunSlowPercent = 0.5f;

		public static float HeatClimbStaminaPenalty = 0.5f;

		public static float InjuryBaseWorsenRate = 0.0011f;

		public static float InjuryScalingExponent = 1.5f;

		public static float FogSpeedMultiplier = 3f;

		public static float FogWaitTimeDivisor = 3f;

		public static bool AffectLavaAndGloomRising = true;

		public static float LavaRiseSpeedMultiplier = 2.5f;

		public static float LavaWaitTimeDivisor = 2.5f;

		public static bool IsActive(int requiredAscentLevel)
		{
			return Ascents.currentAscent >= requiredAscentLevel;
		}
	}
	public static class AreaDetector
	{
		private static bool reflectionInitialized;

		private static bool tfaModPresent;

		private static PropertyInfo? tfaActiveProp;

		private static FieldInfo? tfaVoidActiveField;

		private static PropertyInfo? tfaCurrentStageProp;

		private static FieldInfo? tfaSegIndexField;

		private static FieldInfo? tfaChainIndexField;

		private static FieldInfo? tfaTitleField;

		public static void InitReflection()
		{
			if (reflectionInitialized)
			{
				return;
			}
			reflectionInitialized = true;
			try
			{
				Type type = AccessTools.TypeByName("TrueFinalAscent.FinalAscent");
				if (type != null)
				{
					tfaModPresent = true;
					tfaActiveProp = AccessTools.Property(type, "Active");
				}
				Type type2 = AccessTools.TypeByName("VoidBiome");
				if (type2 != null)
				{
					tfaVoidActiveField = AccessTools.Field(type2, "VoidBiomeActive");
				}
				Type type3 = AccessTools.TypeByName("TrueFinalAscent.FinalAscentSegments");
				if (type3 != null)
				{
					tfaCurrentStageProp = AccessTools.Property(type3, "CurrentStage");
				}
				Type type4 = AccessTools.TypeByName("TrueFinalAscent.FinalAscentStage");
				if (type4 != null)
				{
					tfaSegIndexField = AccessTools.Field(type4, "SegmentIndex");
					tfaChainIndexField = AccessTools.Field(type4, "ChainIndex");
					tfaTitleField = AccessTools.Field(type4, "Title");
				}
			}
			catch
			{
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static bool IsFinalAscentActive()
		{
			if (tfaModPresent && tfaActiveProp != null)
			{
				try
				{
					object value = tfaActiveProp.GetValue(null);
					bool flag = default(bool);
					int num;
					if (value is bool)
					{
						flag = (bool)value;
						num = 1;
					}
					else
					{
						num = 0;
					}
					if (((uint)num & (flag ? 1u : 0u)) != 0)
					{
						return true;
					}
				}
				catch
				{
				}
			}
			if (PhotonNetwork.InRoom)
			{
				Room currentRoom = PhotonNetwork.CurrentRoom;
				if (((currentRoom != null) ? ((RoomInfo)currentRoom).CustomProperties : null) != null)
				{
					bool flag2 = default(bool);
					int num2;
					if (((Dictionary<object, object>)(object)((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties).TryGetValue((object)"FA", out object value2))
					{
						if (value2 is bool)
						{
							flag2 = (bool)value2;
							num2 = 1;
						}
						else
						{
							num2 = 0;
						}
					}
					else
					{
						num2 = 0;
					}
					if (((uint)num2 & (flag2 ? 1u : 0u)) != 0)
					{
						return true;
					}
				}
			}
			return false;
		}

		public static string DetectCurrentArea()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)Singleton<MountainProgressHandler>.Instance != (Object)null && (Object)(object)Character.localCharacter != (Object)null && Singleton<MountainProgressHandler>.Instance.IsAtPeak(Character.localCharacter.Center))
				{
					return "Peak";
				}
			}
			catch
			{
			}
			if (IsFinalAscentActive())
			{
				try
				{
					if (tfaVoidActiveField != null && (bool)(tfaVoidActiveField.GetValue(null) ?? ((object)false)))
					{
						return "Void";
					}
					if (tfaCurrentStageProp != null)
					{
						object value = tfaCurrentStageProp.GetValue(null);
						if (value != null)
						{
							int num = ((tfaSegIndexField != null) ? ((int)(tfaSegIndexField.GetValue(value) ?? ((object)0))) : 0);
							int num2 = ((tfaChainIndexField != null) ? ((int)(tfaChainIndexField.GetValue(value) ?? ((object)0))) : 0);
							string text = ((tfaTitleField != null) ? ((tfaTitleField.GetValue(value) as string) ?? "") : "");
							switch (num)
							{
							case 0:
								return "Shore";
							case 1:
								return (num2 == 0) ? "Tropics" : "Roots";
							case 2:
								return (num2 == 0) ? "Alpine" : "Mesa";
							case 3:
								return "Caldera";
							case 4:
								if (num2 == 0)
								{
									return "TheKiln";
								}
								if (num2 == 1)
								{
									return "Gloom";
								}
								if (num2 >= 2)
								{
									return "TheCitadel";
								}
								break;
							}
							if (text.Contains("SHORE"))
							{
								return "Shore";
							}
							if (text.Contains("TROPICS"))
							{
								return "Tropics";
							}
							if (text.Contains("ROOTS"))
							{
								return "Roots";
							}
							if (text.Contains("ALPINE"))
							{
								return "Alpine";
							}
							if (text.Contains("MESA"))
							{
								return "Mesa";
							}
							if (text.Contains("CALDERA"))
							{
								return "Caldera";
							}
							if (text.Contains("KILN"))
							{
								return "TheKiln";
							}
							if (text.Contains("GLOOM"))
							{
								return "Gloom";
							}
							if (text.Contains("CITADEL"))
							{
								return "TheCitadel";
							}
						}
					}
				}
				catch
				{
				}
			}
			MapHandler instance = Singleton<MapHandler>.Instance;
			string text2 = ((instance != null) ? ((object)instance.GetCurrentSegment()/*cast due to .constrained prefix*/).ToString() : null) ?? "";
			MapHandler instance2 = Singleton<MapHandler>.Instance;
			string text3 = ((instance2 != null) ? ((object)instance2.GetCurrentBiome()/*cast due to .constrained prefix*/).ToString() : null) ?? "";
			if (text2.Equals("Void", StringComparison.OrdinalIgnoreCase) || text3.Equals("Void", StringComparison.OrdinalIgnoreCase))
			{
				return "Void";
			}
			if (text2.Equals("Beach", StringComparison.OrdinalIgnoreCase) || text3.Equals("Shore", StringComparison.OrdinalIgnoreCase))
			{
				return "Shore";
			}
			if (text2.Equals("Tropics", StringComparison.OrdinalIgnoreCase))
			{
				return text3.Equals("Roots", StringComparison.OrdinalIgnoreCase) ? "Roots" : "Tropics";
			}
			if (text2.Equals("Alpine", StringComparison.OrdinalIgnoreCase))
			{
				return text3.Equals("Mesa", StringComparison.OrdinalIgnoreCase) ? "Mesa" : "Alpine";
			}
			if (text2.Equals("Caldera", StringComparison.OrdinalIgnoreCase))
			{
				return text3.Equals("Volcano", StringComparison.OrdinalIgnoreCase) ? "Caldera" : "Gloom";
			}
			if (text2.Equals("TheKiln", StringComparison.OrdinalIgnoreCase))
			{
				return text3.Equals("Volcano", StringComparison.OrdinalIgnoreCase) ? "TheKiln" : "TheCitadel";
			}
			return text2;
		}
	}
	public abstract class AscentGimmick
	{
		public AscentInstanceData? _ascentData;

		public bool active;

		public abstract string GetTitle();

		public abstract string GetDescription();

		public virtual Color GetColor()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			return new Color(0.85f, 0.4f, 0.2f);
		}

		public virtual string GetTitleReward()
		{
			return GetTitle() + " Conqueror";
		}

		public virtual void OnUpdateNormalStatuses(Character character)
		{
		}

		public virtual void OnFogInitNewSphere(OrbFogHandler fog)
		{
		}

		public virtual void Update()
		{
		}
	}
	public static class AscentGimmickHandler
	{
		internal static readonly List<AscentGimmick> gimmicks = new List<AscentGimmick>();

		private static readonly List<AscentInstanceData> pendingDatas = new List<AscentInstanceData>();

		private static bool HasInitialized = false;

		internal static int BaseAscents { get; private set; } = -1;

		internal static void MarkGimmicksAsActive(int ascentIndex)
		{
			int num = 0;
			foreach (AscentInstanceData ascent in SingletonAsset<AscentData>.Instance.ascents)
			{
				foreach (AscentGimmick gimmick in gimmicks)
				{
					if (gimmick._ascentData == ascent && num <= ascentIndex)
					{
						gimmick.active = true;
					}
				}
				num++;
			}
		}

		internal static void DisableGimmicks()
		{
			foreach (AscentGimmick gimmick in gimmicks)
			{
				gimmick.active = false;
			}
		}

		internal static int GetBaseAscentCount()
		{
			if (BaseAscents == -1)
			{
				BaseAscents = SingletonAsset<AscentData>.Instance.ascents.Count;
			}
			return BaseAscents;
		}

		internal static void Initialize()
		{
			if (HasInitialized)
			{
				return;
			}
			HasInitialized = true;
			AscentData instance = SingletonAsset<AscentData>.Instance;
			List<AscentInstanceData> list = new List<AscentInstanceData>();
			foreach (AscentInstanceData ascent in instance.ascents)
			{
				list.Add(ascent);
			}
			foreach (AscentInstanceData pendingData in pendingDatas)
			{
				list.Add(pendingData);
			}
			instance.ascents = list;
		}

		public static void RegisterAscent<T>() where T : AscentGimmick, new()
		{
			//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_001d: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			T val = new T();
			AscentInstanceData item = (val._ascentData = new AscentInstanceData
			{
				title = val.GetTitle(),
				description = val.GetDescription(),
				titleReward = val.GetTitleReward(),
				color = val.GetColor(),
				sashSprite = SingletonAsset<AscentData>.Instance.ascents[0].sashSprite
			});
			gimmicks.Add(val);
			if (HasInitialized)
			{
				SingletonAsset<AscentData>.Instance.ascents.Add(item);
			}
			else
			{
				pendingDatas.Add(item);
			}
			string text = val.GetTitle().ToUpperInvariant();
			string key = "DESC_" + text;
			if (!LocalizedText.mainTable.ContainsKey(text))
			{
				LocalizedText.mainTable.Add(text, Enumerable.Repeat(val.GetTitle(), 14).ToList());
			}
			if (!LocalizedText.mainTable.ContainsKey(key))
			{
				LocalizedText.mainTable.Add(key, Enumerable.Repeat(val.GetDescription(), 14).ToList());
			}
		}
	}
	public class Gimmick_ForagersTax : AscentGimmick
	{
		public override string GetTitle()
		{
			return ModConfig.Title_Ascent9;
		}

		public override string GetDescription()
		{
			return ModConfig.Desc_Ascent9;
		}

		public override Color GetColor()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			return new Color(0.3f, 0.7f, 0.3f);
		}
	}
	public class Gimmick_WornEquipment : AscentGimmick
	{
		public override string GetTitle()
		{
			return ModConfig.Title_Ascent10;
		}

		public override string GetDescription()
		{
			return ModConfig.Desc_Ascent10;
		}

		public override Color GetColor()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			return new Color(0.8f, 0.6f, 0.2f);
		}
	}
	public class Gimmick_HarshClimates : AscentGimmick
	{
		private float _sunCheckTimer = 0f;

		private bool _isInSunlight = false;

		public override string GetTitle()
		{
			return ModConfig.Title_Ascent11;
		}

		public override string GetDescription()
		{
			return ModConfig.Desc_Ascent11;
		}

		public override Color GetColor()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			return new Color(0.85f, 0.3f, 0.2f);
		}

		public override void OnUpdateNormalStatuses(Character character)
		{
			//IL_009a: 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_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)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			if (!ModConfig.IsActive(ModConfig.Level_HarshClimates) || !character.IsLocal || (Object)(object)DayNightManager.instance == (Object)null)
			{
				return;
			}
			string text = AreaDetector.DetectCurrentArea();
			if (text == "Caldera")
			{
				_sunCheckTimer += Time.deltaTime;
				if (_sunCheckTimer >= 0.1f)
				{
					_sunCheckTimer = 0f;
					Transform transform = ((Component)DayNightManager.instance.sun).transform;
					RaycastHit val = HelperFunctions.LineCheck(character.Center - transform.forward * 500f, character.Center, (LayerType)1, 0f, (QueryTriggerInteraction)1);
					_isInSunlight = (Object)(object)((RaycastHit)(ref val)).transform == (Object)null || (Object)(object)((RaycastHit)(ref val)).transform.root == (Object)(object)((Component)character).transform.root;
				}
				if (_isInSunlight)
				{
					character.refs.afflictions.AddSunHeat(ModConfig.CalderaSunHeatRate * Time.deltaTime);
				}
			}
			bool flag = DayNightManager.instance.isDay >= 0.5f;
			if (text == "Gloom" && !flag)
			{
				float num = ((Ascents.nightColdRate > 0f) ? Ascents.nightColdRate : ModConfig.GloomNightColdRate);
				character.refs.afflictions.AddStatus((STATUSTYPE)2, num * Time.deltaTime, false, true, true, false, false);
			}
		}
	}
	public class Gimmick_UniqueStatuses : AscentGimmick
	{
		private struct PoisonRecord
		{
			public float time;

			public float amount;
		}

		private float _previousPoison = 0f;

		private readonly List<PoisonRecord> _poisonHistory = new List<PoisonRecord>();

		private float _sporeCheckTimer = 0f;

		private float _sporeNextAvailableTime = 0f;

		public override string GetTitle()
		{
			return ModConfig.Title_Ascent12;
		}

		public override string GetDescription()
		{
			return ModConfig.Desc_Ascent12;
		}

		public override Color GetColor()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			return new Color(0.6f, 0.2f, 0.7f);
		}

		private static void TriggerFall(Character character, float seconds)
		{
			if (!((Object)(object)character == (Object)null) && !((Object)(object)character.refs?.view == (Object)null))
			{
				character.refs.view.RPC("RPCA_Fall", (RpcTarget)0, new object[2] { seconds, 0f });
			}
		}

		public override void OnUpdateNormalStatuses(Character character)
		{
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Expected O, but got Unknown
			if (!ModConfig.IsActive(ModConfig.Level_UniqueStatuses) || !character.IsLocal)
			{
				return;
			}
			CharacterAfflictions afflictions = character.refs.afflictions;
			float currentStatus = afflictions.GetCurrentStatus((STATUSTYPE)3);
			if (currentStatus > _previousPoison)
			{
				float amount = currentStatus - _previousPoison;
				_poisonHistory.Add(new PoisonRecord
				{
					time = Time.time,
					amount = amount
				});
			}
			_previousPoison = currentStatus;
			_poisonHistory.RemoveAll((PoisonRecord p) => Time.time - p.time > ModConfig.PoisonBurstTimeWindow);
			float num = 0f;
			for (int num2 = 0; num2 < _poisonHistory.Count; num2++)
			{
				num += _poisonHistory[num2].amount;
			}
			if (num >= ModConfig.PoisonBurstThreshold)
			{
				_poisonHistory.Clear();
				afflictions.AddStatus((STATUSTYPE)1, ModConfig.PukeHungerInflicted, false, true, true, false, false);
				TriggerFall(character, ModConfig.PukeStumbleDuration);
				GamefeelHandler.instance.AddPerlinShake(7f, 0.4f, 15f);
			}
			if ((Object)(object)DayNightManager.instance != (Object)null && DayNightManager.instance.isDay < 0.5f)
			{
				afflictions.drowsyReductionPerSecond = 0f;
			}
			else
			{
				afflictions.drowsyReductionPerSecond = 0.015f;
			}
			float currentStatus2 = afflictions.GetCurrentStatus((STATUSTYPE)2);
			if (currentStatus2 > 0.02f)
			{
				float movementModifier = Mathf.Clamp(1f - currentStatus2 * ModConfig.ColdMaxRunSlowPercent, 0.4f, 1f);
				character.refs.movement.movementModifier = movementModifier;
			}
			else
			{
				character.refs.movement.movementModifier = 1f;
			}
			character.refs.climbing.climbSpeedMod = 1f;
			float currentStatus3 = afflictions.GetCurrentStatus((STATUSTYPE)0);
			if (currentStatus3 > 0.05f)
			{
				float num3 = ModConfig.InjuryBaseWorsenRate * Mathf.Pow(currentStatus3, ModConfig.InjuryScalingExponent);
				afflictions.AddStatus((STATUSTYPE)0, num3 * Time.deltaTime, false, false, false, false, false);
			}
			float currentStatus4 = afflictions.GetCurrentStatus((STATUSTYPE)10);
			if (currentStatus4 > 0.05f && Time.time >= _sporeNextAvailableTime)
			{
				_sporeCheckTimer += Time.deltaTime;
				if (_sporeCheckTimer >= ModConfig.SporeCheckInterval)
				{
					_sporeCheckTimer = 0f;
					float value = Random.value;
					float num4 = Mathf.Clamp01(currentStatus4 * ModConfig.SporeTriggerChanceMult);
					if (value <= num4)
					{
						float num5 = Mathf.Lerp(ModConfig.SporeMinNumbDuration, ModConfig.SporeMaxNumbDuration, currentStatus4);
						float num6 = num5 + ModConfig.SporeCooldownExtra;
						_sporeNextAvailableTime = Time.time + num6;
						Affliction_Numb val = new Affliction_Numb
						{
							totalTime = num5
						};
						afflictions.AddAffliction((Affliction)(object)val, false);
					}
				}
			}
			else if (currentStatus4 <= 0.05f)
			{
				_sporeCheckTimer = 0f;
			}
		}
	}
	public class Gimmick_SurgingMist : AscentGimmick
	{
		private const float VanillaBaseFogSpeed = 0.3f;

		private const float VanillaBaseMaxWaitTime = 500f;

		public override string GetTitle()
		{
			return ModConfig.Title_Ascent13;
		}

		public override string GetDescription()
		{
			return ModConfig.Desc_Ascent13;
		}

		public override Color GetColor()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			return new Color(0.4f, 0.1f, 0.5f);
		}

		public override void OnFogInitNewSphere(OrbFogHandler fog)
		{
			if (ModConfig.IsActive(ModConfig.Level_SurgingMist))
			{
				fog.speed = 0.3f * ModConfig.FogSpeedMultiplier;
				fog.maxWaitTime = 500f / ModConfig.FogWaitTimeDivisor;
			}
		}
	}
	public class Gimmick_NoCampfirePetrify : AscentGimmick
	{
		public override string GetTitle()
		{
			return ModConfig.Title_Ascent14;
		}

		public override string GetDescription()
		{
			return ModConfig.Desc_Ascent14;
		}

		public override Color GetColor()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			return new Color(0.2f, 0.2f, 0.2f);
		}
	}
	[BepInPlugin("com.vanillaplus.ascents", "Vanilla+ Ascents (9-14)", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		internal static ConfigEntry<int> AscentsUnlocked;

		internal static ConfigEntry<bool> UnlockAllAscents;

		private void Awake()
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			AscentsUnlocked = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MaxAscent", 14, "Highest unlocked ascent index.");
			UnlockAllAscents = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "UnlockAllCustomAscents", true, "If true, all custom ascents will be unlocked for immediate play.");
			AreaDetector.InitReflection();
			AscentGimmickHandler.GetBaseAscentCount();
			AscentGimmickHandler.RegisterAscent<Gimmick_ForagersTax>();
			AscentGimmickHandler.RegisterAscent<Gimmick_WornEquipment>();
			AscentGimmickHandler.RegisterAscent<Gimmick_HarshClimates>();
			AscentGimmickHandler.RegisterAscent<Gimmick_UniqueStatuses>();
			AscentGimmickHandler.RegisterAscent<Gimmick_SurgingMist>();
			AscentGimmickHandler.RegisterAscent<Gimmick_NoCampfirePetrify>();
			AscentGimmickHandler.Initialize();
			Harmony val = new Harmony("com.vanillaplus.ascents");
			val.PatchAll();
			Log.LogInfo((object)"Vanilla+ Ascents (9-14) loaded successfully!");
		}
	}
	[HarmonyPatch(typeof(CharacterMovement), "CheckFallDamage")]
	internal static class Patch_FallDamageMovement
	{
		private static void Prefix()
		{
			Patch_FallDamageMultiplier.InFallDamage = true;
		}

		private static void Postfix()
		{
			Patch_FallDamageMultiplier.InFallDamage = false;
		}
	}
	[HarmonyPatch(typeof(CharacterClimbing), "CheckFallDamage")]
	internal static class Patch_FallDamageClimbing
	{
		private static void Prefix()
		{
			Patch_FallDamageMultiplier.InFallDamage = true;
		}

		private static void Postfix()
		{
			Patch_FallDamageMultiplier.InFallDamage = false;
		}
	}
	[HarmonyPatch(typeof(CharacterAfflictions), "AddStatus")]
	internal static class Patch_FallDamageMultiplier
	{
		internal static bool InFallDamage;

		private static void Prefix(CharacterAfflictions __instance, ref float amount, STATUSTYPE statusType)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			if (InFallDamage && (int)statusType == 0 && ModConfig.IsActive(ModConfig.Level_UniqueStatuses))
			{
				float currentStatus = __instance.GetCurrentStatus((STATUSTYPE)7);
				if (currentStatus > 0.05f)
				{
					float num = 1f + Mathf.Clamp01(currentStatus) * (ModConfig.WeightMaxFallDamageMult - 1f);
					amount *= num;
				}
			}
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal static class Patch_ClimbStaminaMultiplierGetter
	{
		private static void Postfix(ref float __result)
		{
			if (ModConfig.IsActive(ModConfig.Level_UniqueStatuses) && (Object)(object)Character.localCharacter != (Object)null && Character.localCharacter.data.isClimbing)
			{
				float currentStatus = Character.localCharacter.refs.afflictions.GetCurrentStatus((STATUSTYPE)8);
				if (currentStatus > 0.02f)
				{
					__result *= 1f + currentStatus * ModConfig.HeatClimbStaminaPenalty;
				}
			}
		}
	}
	[HarmonyPatch(typeof(DayNightManager), "Update")]
	internal static class Patch_CalderaLockSun
	{
		private static bool _wasInCaldera;

		private static void Prefix(DayNightManager __instance)
		{
			if (ModConfig.IsActive(ModConfig.Level_HarshClimates))
			{
				if (AreaDetector.DetectCurrentArea() == "Caldera")
				{
					__instance.timeOfDay = ModConfig.CalderaLockedTimeOfDay;
					_wasInCaldera = true;
				}
				else if (_wasInCaldera)
				{
					_wasInCaldera = false;
				}
			}
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal static class Patch_CurrentAscentSetter
	{
		private static void Prefix(int value)
		{
			AscentGimmickHandler.DisableGimmicks();
			AscentGimmickHandler.MarkGimmicksAsActive(value + 2);
		}
	}
	[HarmonyPatch(typeof(Action_RestoreHunger), "RunAction")]
	internal static class Patch_ActionRestoreHunger
	{
		private static float _orig;

		private static bool _mod;

		private static void Prefix(Action_RestoreHunger __instance)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			_mod = false;
			if (!ModConfig.IsActive(ModConfig.Level_ForagersTax))
			{
				return;
			}
			Item componentInParent = ((Component)__instance).GetComponentInParent<Item>();
			if (!((Object)(object)componentInParent == (Object)null) && !((Enum)componentInParent.itemTags).HasFlag((Enum)(object)(ItemTags)2))
			{
				int value = componentInParent.GetData<IntItemData>((DataEntryKey)1).Value;
				if (value < 1)
				{
					_orig = __instance.restorationAmount;
					__instance.restorationAmount *= ModConfig.RawFoodHungerMultiplier;
					_mod = true;
				}
			}
		}

		private static void Postfix(Action_RestoreHunger __instance)
		{
			if (_mod)
			{
				__instance.restorationAmount = _orig;
			}
		}
	}
	[HarmonyPatch(typeof(Item), "Start")]
	internal static class Patch_ItemStart
	{
		private static void Prefix(Item __instance)
		{
			if (ModConfig.IsActive(ModConfig.Level_WornEquipment) && !__instance.HasData((DataEntryKey)2) && __instance.totalUses >= 3)
			{
				__instance.totalUses--;
			}
		}
	}
	[HarmonyPatch(typeof(CharacterAfflictions), "UpdateNormalStatuses")]
	internal static class Patch_UpdateNormalStatuses
	{
		private static void Postfix(CharacterAfflictions __instance)
		{
			foreach (AscentGimmick gimmick in AscentGimmickHandler.gimmicks)
			{
				if (gimmick.active)
				{
					gimmick.OnUpdateNormalStatuses(__instance.character);
				}
			}
		}
	}
	[HarmonyPatch(typeof(OrbFogHandler), "InitNewSphere")]
	internal static class Patch_OrbFogInitNewSphere
	{
		private static void Postfix(OrbFogHandler __instance)
		{
			foreach (AscentGimmick gimmick in AscentGimmickHandler.gimmicks)
			{
				if (gimmick.active)
				{
					gimmick.OnFogInitNewSphere(__instance);
				}
			}
		}
	}
	[HarmonyPatch(typeof(LavaRising), "Start")]
	internal static class Patch_LavaRisingSpeed
	{
		private static void Postfix(LavaRising __instance)
		{
			if (ModConfig.IsActive(ModConfig.Level_SurgingMist) && ModConfig.AffectLavaAndGloomRising)
			{
				__instance.travelTime /= ModConfig.LavaRiseSpeedMultiplier;
				__instance.initialWaitTime /= ModConfig.LavaWaitTimeDivisor;
				Plugin.Log.LogInfo((object)$"[VanillaPlusAscents] LavaRising sped up: TravelTime={__instance.travelTime:F1}s, WaitTime={__instance.initialWaitTime:F1}s");
			}
		}
	}
	[HarmonyPatch(typeof(CharacterAfflictions), "AdjustStatus")]
	internal static class Patch_BlockCampfirePetrifyHeal
	{
		private static bool Prefix(STATUSTYPE statusType, ref float amount)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Invalid comparison between Unknown and I4
			if ((int)statusType == 13 && amount < 0f && ModConfig.IsActive(ModConfig.Level_NoCampfirePetrify))
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(BoardingPass), "UpdateAscent")]
	internal static class Patch_BoardingPass
	{
		private static void Postfix(BoardingPass __instance, ref int ___maxAscent, ref int ___maxUnlockedAscent, Button ___incrementAscentButton, Button ___decrementAscentButton, int ____ascentIndex)
		{
			int num = (___maxAscent = 14);
			___maxUnlockedAscent = (Plugin.UnlockAllAscents.Value ? num : Mathf.Max(___maxUnlockedAscent, Plugin.AscentsUnlocked.Value));
			int num2 = Mathf.Min(___maxAscent, ___maxUnlockedAscent);
			if (!RunSettings.IsCustomRun)
			{
				((Selectable)___incrementAscentButton).interactable = ____ascentIndex < num2;
				((Selectable)___decrementAscentButton).interactable = ____ascentIndex > -1;
			}
		}
	}
	[HarmonyPatch(typeof(AchievementManager), "GetMaxAscent")]
	internal static class Patch_AchievementManager_GetMaxAscent
	{
		private static void Postfix(ref int __result)
		{
			__result = (Plugin.UnlockAllAscents.Value ? 14 : Mathf.Max(__result, Plugin.AscentsUnlocked.Value));
		}
	}
	[HarmonyPatch(typeof(AchievementManager), "SetSteamStat", new Type[]
	{
		typeof(STEAMSTATTYPE),
		typeof(int)
	})]
	internal static class Patch_AchievementManager_SetSteamStat
	{
		private static void Prefix(STEAMSTATTYPE steamStatType, ref int value)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Invalid comparison between Unknown and I4
			if ((int)steamStatType == 13)
			{
				Plugin.AscentsUnlocked.Value = Mathf.Max(Plugin.AscentsUnlocked.Value, value);
			}
		}
	}
}