Decompiled source of Environmental Awareness The Trials Of Toil v1.0.4

plugins/EnvironmentalAwareness.dll

Decompiled 5 days ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EnvironmentalAwareness.Data;
using HarmonyLib;
using JetBrains.Annotations;
using LocalizationManager;
using Microsoft.CodeAnalysis;
using ServerSync;
using SkillManager;
using TMPro;
using UnityEngine;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
using YamlDotNet.Core.Tokens;
using YamlDotNet.Helpers;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.Converters;
using YamlDotNet.Serialization.EventEmitters;
using YamlDotNet.Serialization.NamingConventions;
using YamlDotNet.Serialization.NodeDeserializers;
using YamlDotNet.Serialization.NodeTypeResolvers;
using YamlDotNet.Serialization.ObjectFactories;
using YamlDotNet.Serialization.ObjectGraphTraversalStrategies;
using YamlDotNet.Serialization.ObjectGraphVisitors;
using YamlDotNet.Serialization.Schemas;
using YamlDotNet.Serialization.TypeInspectors;
using YamlDotNet.Serialization.TypeResolvers;
using YamlDotNet.Serialization.Utilities;
using YamlDotNet.Serialization.ValueDeserializers;

[assembly: AssemblyProduct("EnvironmentalAwareness")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyCompany("EnvironmentalAwareness")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: AssemblyTitle("EnvironmentalAwareness")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[<1eb0dbde-458d-4199-ad65-d41a5bb1a483>Embedded]
	internal sealed class <1eb0dbde-458d-4199-ad65-d41a5bb1a483>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	[<1eb0dbde-458d-4199-ad65-d41a5bb1a483>Embedded]
	internal sealed class <6a8b7a34-9f83-49d3-8366-65e14226f50e>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <6a8b7a34-9f83-49d3-8366-65e14226f50e>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <6a8b7a34-9f83-49d3-8366-65e14226f50e>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	[<1eb0dbde-458d-4199-ad65-d41a5bb1a483>Embedded]
	internal sealed class <5c9fabdd-05fb-43b2-a213-2116a2b67436>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <5c9fabdd-05fb-43b2-a213-2116a2b67436>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace EnvironmentalAwareness
{
	[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(0)]
	[<5c9fabdd-05fb-43b2-a213-2116a2b67436>NullableContext(1)]
	[BepInPlugin("maxfoxgaming.environmentalawareness", "EnvironmentalAwareness", "1.0.4")]
	public class Main : BaseUnityPlugin
	{
		public const string PluginGUID = "maxfoxgaming.environmentalawareness";

		public const string PluginName = "EnvironmentalAwareness";

		public const string PluginVersion = "1.0.4";

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(2)]
		private static Main instance;

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(2)]
		public AssetBundle Bundle;

		public static Harmony harmony = new Harmony("maxfoxgaming.environmentalawareness");

		public static readonly string ModPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(2)]
		public static ManualLogSource Log;

		public static readonly string VitalitySEName = "AE_Vitality";

		public static readonly string HungrySEName = "AE_Hungry";

		public static readonly string EnergySEName = "AE_Energy";

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(2)]
		public SE_Vitality Vitality;

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(2)]
		public SE_Hungry Hungry;

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(2)]
		public SE_Energy Energy;

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(2)]
		public Skill Resistance;

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(2)]
		public Skill Fitness;

		public TutorialText[] TutorialTexts = (TutorialText[])(object)new TutorialText[4]
		{
			new TutorialText
			{
				m_name = "EnvironmentalAwarenessVitality",
				m_label = "$ea_tutorial_vitality_label",
				m_text = "$ea_tutorial_vitality_text",
				m_topic = "$ea_tutorial_vitality_topic"
			},
			new TutorialText
			{
				m_name = "EnvironmentalAwarenessVitalityLow",
				m_label = "$ea_tutorial_vitality_low_label",
				m_text = "$ea_tutorial_vitality_low_text",
				m_topic = "$ea_tutorial_vitality_low_topic"
			},
			new TutorialText
			{
				m_name = "EnvironmentalAwarenessEnergy",
				m_label = "$ea_tutorial_energy_label",
				m_text = "$ea_tutorial_energy_text",
				m_topic = "$ea_tutorial_energy_topic"
			},
			new TutorialText
			{
				m_name = "EnvironmentalAwarenessEnergyLow",
				m_label = "$ea_tutorial_energy_low_label",
				m_text = "$ea_tutorial_energy_low_text",
				m_topic = "$ea_tutorial_energy_low_topic"
			}
		};

		private readonly string[] credits = new string[6] { "ProbablyKory: Inspiration from the StormExposure mod.", "Azumatt: Help with Valheim asset ripping and referencing.", "OrianaVenture: Encouragement with trying status effect manipulation.", "GsiX & HugoTheDwarf: Help with sprite sizes.", "Blaxxun: ServerSync, SkillManager and LocalizationManager.", "Blacks7ar: Help with SkillManager to get level of custom skill." };

		public void Awake()
		{
			Localizer.Load();
			Log = ((BaseUnityPlugin)this).Logger;
			instance = this;
			ConfigManager.CreateConfigValues((BaseUnityPlugin)(object)this);
			LogMessage("Loading");
			LogMessage("Loading bundles.");
			Bundle = LoadBundle("environmentalsprites");
			LogMessage("Initializing Status Effects.");
			Vitality = ScriptableObject.CreateInstance<SE_Vitality>();
			((Object)Vitality).name = VitalitySEName;
			Hungry = ScriptableObject.CreateInstance<SE_Hungry>();
			((Object)Hungry).name = HungrySEName;
			Energy = ScriptableObject.CreateInstance<SE_Energy>();
			((Object)Energy).name = EnergySEName;
			LogMessage("Adding Skills.");
			Resistance = new Skill("Resistance", Bundle.LoadAsset<Sprite>("vitalityicon1"));
			Resistance.Description.English("You become more resistant to effects that lower your vitality.");
			Resistance.SkillEffectFactor = ConfigManager.ResistanceSkillEffectFactor.Value;
			Resistance.SkillGainFactor = ConfigManager.ResistanceSkillGainFactor.Value;
			Resistance.Configurable = false;
			Fitness = new Skill("Fitness", Bundle.LoadAsset<Sprite>("energyicon1"));
			Fitness.Description.English("Increases your maximum energy and decrease the speed of energy loss.");
			Fitness.SkillEffectFactor = ConfigManager.FitnessSkillEffectFactor.Value;
			Fitness.SkillGainFactor = ConfigManager.FitnessSkillGainFactor.Value;
			Fitness.Configurable = false;
			Harmony val = harmony;
			if (val != null)
			{
				val.PatchAll();
			}
		}

		public void OnDestroy()
		{
			Harmony val = harmony;
			if (val != null)
			{
				val.UnpatchSelf();
			}
			instance = null;
		}

		[<5c9fabdd-05fb-43b2-a213-2116a2b67436>NullableContext(2)]
		public static Main GetInstance()
		{
			return instance;
		}

		public static void LogMessage(string message)
		{
			if (ConfigManager.DebugLogging.Value)
			{
				Log.LogMessage((object)message);
			}
		}

		[return: <6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(2)]
		public static AssetBundle LoadBundle(string name)
		{
			string text = "";
			try
			{
				text = Assembly.GetExecutingAssembly().GetManifestResourceNames().Single((string str) => str.EndsWith(name));
			}
			catch (Exception)
			{
			}
			if (text == "")
			{
				LogMessage("Could not find assembly with name " + name + ".");
				return null;
			}
			AssetBundle result;
			using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(text))
			{
				result = AssetBundle.LoadFromStream(stream);
			}
			LogMessage("Loaded assetbundle successfully.");
			return result;
		}
	}
	[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(0)]
	[<5c9fabdd-05fb-43b2-a213-2116a2b67436>NullableContext(1)]
	public class SE_Energy : SE_Stats
	{
		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(new byte[] { 2, 1 })]
		public Sprite[] icons;

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(2)]
		public Sprite iconNoSkillDrain;

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(2)]
		public Sprite iconNewSpawn;

		public float m_energyLoss = 0f;

		public float m_maxEnergyLoss = 100f;

		public float m_staminaRegenDelay = 0f;

		public float m_energyFromFood = 0f;

		public float m_energyFromFoodTick = 0f;

		public float m_energyRegenSpeed = 0.5f;

		public float m_energyLossPerc = 0f;

		public float m_timeSinceRested = 0f;

		public float fitnessSkillMultiplier = 1f;

		public float energyChange = 0f;

		public float updateTimerState = 0f;

		public float updateTimerStats = 0f;

		public float updateTimerIcon = 0f;

		public float updateTimerLogs = 0f;

		public float countdownTimer = 300f;

		public float seasonMultiplier = 1f;

		public float lossEnergyRestedMult = 1f;

		public float lossEnergyCarryWeightAdd = 0f;

		public float lossEnergyMovementAdd = 0f;

		public float staminaMeadMult = 1f;

		public float noRestMultiplier = 1f;

		public float totalStaminaUseInCycle = 0f;

		public float totalEnergyUseInCycle = 0f;

		public float lastRawLossInCycle;

		public bool warningSpeed;

		public bool warningStaminaRegen;

		public bool warningStaminaDelay;

		public bool warningSkillGain;

		public bool warningSkillLevel;

		public bool warningDamage;

		public bool warningWeight;

		public readonly float baseMaxEnergyLoss = 100f;

		public readonly string[] statuses = new string[5] { "$ea_energy_status_0", "$ea_energy_status_1", "$ea_energy_status_2", "$ea_energy_status_3", "$ea_energy_status_4" };

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(2)]
		private Player player;

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(2)]
		private PlayerEnvironmentStats pes;

		public static readonly int Hash = StringExtensionMethods.GetStableHashCode(Main.EnergySEName);

		public override void Setup(Character character)
		{
			//IL_006b: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			((SE_Stats)this).Setup(character);
			((StatusEffect)this).m_name = "$ea_se_energy";
			LoadIcons();
			((StatusEffect)this).m_icon = icons[0];
			updateTimerState = 0f;
			updateTimerStats = 0f;
			updateTimerIcon = 0f;
			updateTimerLogs = 0f;
			countdownTimer = ConfigManager.NewPlayerCooldown.Value;
			base.m_modifyAttackSkill = (SkillType)999;
			base.m_skillLevel = (SkillType)999;
			base.m_skillLevelModifier = 0f;
			base.m_raiseSkill = (SkillType)999;
			base.m_raiseSkillModifier = 0f;
			ref Player reference = ref player;
			Character character2 = ((StatusEffect)this).m_character;
			reference = (Player)(object)((character2 is Player) ? character2 : null);
			if ((Object)(object)player == (Object)null)
			{
				((StatusEffect)this).m_character.m_seman.RemoveStatusEffect((StatusEffect)(object)this, false);
				return;
			}
			if (player.IsMaterialKnown("$item_stone") || player.IsMaterialKnown("$item_wood"))
			{
				Main.LogMessage("Player knows a material. Cooldown disabled for Energy status.");
				countdownTimer = 0f;
			}
			pes = PlayerEnvironmentStats.Get(player);
			Recalculate();
		}

		public void LoadIcons()
		{
			Sprite[] array = (Sprite[])(object)new Sprite[15];
			for (int i = 0; i < 15; i++)
			{
				string text = "energyicon" + (i + 1);
				array[i] = Main.GetInstance().Bundle.LoadAsset<Sprite>(text);
			}
			icons = array;
			iconNoSkillDrain = Main.GetInstance().Bundle.LoadAsset<Sprite>("energyicondeath");
			iconNewSpawn = Main.GetInstance().Bundle.LoadAsset<Sprite>("energyiconnewplayer");
		}

		public override void Stop()
		{
			((StatusEffect)this).Stop();
			((StatusEffect)this).m_ttl = 1f;
			m_energyLoss = 0f;
			m_maxEnergyLoss = 100f;
			m_staminaRegenDelay = 0f;
			base.m_raiseSkillModifier = 0f;
			base.m_skillLevelModifier = 0f;
			updateTimerState = 0f;
			updateTimerStats = 0f;
			updateTimerIcon = 0f;
			updateTimerLogs = 0f;
		}

		public override bool IsDone()
		{
			return false;
		}

		public override string GetTooltipString()
		{
			StringBuilder stringBuilder = new StringBuilder();
			if (pes.PlayerNoSkillDrain)
			{
				stringBuilder.Append("$ea_player_energy_immune \n");
				return stringBuilder.ToString();
			}
			if (countdownTimer > 0f)
			{
				stringBuilder.AppendFormat("$ea_player_energy_cooldown: {0}s. \n", Mathf.Ceil(countdownTimer));
				return stringBuilder.ToString();
			}
			stringBuilder.Append(GetEnergyStatus());
			if (!pes.PlayerRested)
			{
				stringBuilder.Append("$ea_player_needs_rest \n");
			}
			if (pes.PlayerStaminaMead)
			{
				stringBuilder.Append("$ea_player_stamina_mead \n");
			}
			if (m_energyFromFood > 0f)
			{
				stringBuilder.Append("$ea_player_food_recover_energy \n");
			}
			if (m_timeSinceRested > ConfigManager.ELossNoRestThreshold.Value / 2f)
			{
				stringBuilder.Append("$ea_player_need_rest_energy \n");
			}
			if (m_energyLossPerc > ConfigManager.ERestedLossThreshold.Value)
			{
				stringBuilder.Append("$ea_player_cannot_stay_rested \n");
			}
			if (energyChange > 0f)
			{
				if (pes.PlayerCold || pes.PlayerFreezing)
				{
					stringBuilder.Append("$ea_player_coldfreezing_energy \n");
				}
				if (pes.PlayerWet)
				{
					stringBuilder.Append("$ea_player_wet_energy \n");
				}
				if (pes.PlayerHungry)
				{
					stringBuilder.Append("$ea_player_hungry_energy \n");
				}
			}
			else if (energyChange < 0f && m_energyLoss > 0.5f)
			{
				stringBuilder.Append("$ea_player_recovering_energy \n");
			}
			stringBuilder.Append(((SE_Stats)this).GetTooltipString());
			if (m_staminaRegenDelay > 0f)
			{
				stringBuilder.AppendFormat("$ea_se_staminaregendelay: <color=orange>{0}s</color> \n", (Mathf.Floor(10f * m_staminaRegenDelay) / 10f).ToString("+0;-0"));
			}
			if (staminaMeadMult != 1f)
			{
				stringBuilder.AppendFormat("$ea_se_energylossresist: <color=green>{0}%</color> \n", Mathf.Floor(100f * staminaMeadMult));
			}
			return stringBuilder.ToString();
		}

		public string GetEnergyStatus()
		{
			int num = Mathf.Clamp(Mathf.FloorToInt(m_energyLoss / m_maxEnergyLoss * (float)statuses.Length), 0, statuses.Length - 1);
			return statuses[num] + "\n";
		}

		public override string GetIconText()
		{
			if (pes.PlayerNoSkillDrain)
			{
				return "";
			}
			if (countdownTimer > 0f)
			{
				return StatusEffect.GetTimeString(countdownTimer, false, false);
			}
			if (!ConfigManager.DisplayEnergyPercentage.Value)
			{
				return "";
			}
			int num = 100 - Mathf.FloorToInt(100f * (m_energyLoss / m_maxEnergyLoss));
			return $"{num}%";
		}

		public override void UpdateStatusEffect(float dt)
		{
			if (pes == null)
			{
				((StatusEffect)this).m_character.m_seman.RemoveStatusEffect((StatusEffect)(object)this, false);
			}
			((SE_Stats)this).UpdateStatusEffect(dt);
			if (countdownTimer <= 0f && !pes.PlayerNoSkillDrain)
			{
				UpdateStaminaRegenDelay();
				UpdateEnergyFromFood(dt);
			}
			m_energyLossPerc = 100f * (m_energyLoss / m_maxEnergyLoss);
			if (countdownTimer <= 0f && !pes.PlayerNoSkillDrain)
			{
				updateTimerState += dt;
				updateTimerStats += dt;
			}
			updateTimerIcon += dt;
			updateTimerLogs += dt;
			if (!((Object)(object)player == (Object)null))
			{
				if (updateTimerState >= 1f && countdownTimer <= 0f && !pes.PlayerNoSkillDrain)
				{
					UpdateNonRestedState();
					UpdateMovementState();
					UpdateEnergyValue();
					updateTimerState -= 1f;
				}
				if (updateTimerStats >= 5f && countdownTimer <= 0f && !pes.PlayerNoSkillDrain)
				{
					UpdateEffects();
					UpdateTutorial();
					updateTimerStats -= 5f;
				}
				if (updateTimerLogs >= 10f)
				{
					LogStatistics();
					ResetCycleStats();
					updateTimerLogs -= 10f;
				}
				if (countdownTimer > 0f)
				{
					countdownTimer -= dt;
				}
				else
				{
					countdownTimer = 0f;
				}
				if (updateTimerIcon > 1f)
				{
					UpdateIcon();
					updateTimerIcon -= 1f;
				}
			}
		}

		public void UpdateTutorial()
		{
			if (m_energyLossPerc > 10f)
			{
				player.ShowTutorial("EnvironmentalAwarenessEnergy", false);
			}
			if (m_energyLossPerc > 60f)
			{
				player.ShowTutorial("EnvironmentalAwarenessEnergyLow", false);
			}
		}

		public void UpdateStaminaRegenDelay()
		{
			if (pes != null)
			{
				player.m_staminaRegenDelay = pes.PlayerStaminaRegenDelay + m_staminaRegenDelay;
			}
		}

		public void UpdateEnergyFromFood(float dt)
		{
			if ((double)m_energyFromFood < 0.01)
			{
				m_energyFromFood = 0f;
				m_energyFromFoodTick = 0f;
				return;
			}
			m_energyFromFoodTick = m_maxEnergyLoss / baseMaxEnergyLoss * Mathf.Min(m_energyRegenSpeed, m_energyFromFood) * dt;
			Main.LogMessage("Energy tick: " + m_energyFromFoodTick);
			m_energyLoss -= m_energyFromFoodTick;
			if (m_energyLoss < 0f)
			{
				m_energyLoss = 0f;
			}
			m_energyFromFood -= m_energyFromFoodTick;
		}

		public void UpdateNonRestedState()
		{
			if (pes.PlayerRested)
			{
				m_timeSinceRested = 0f;
				noRestMultiplier = 1f;
			}
			else
			{
				m_timeSinceRested += 1f;
				noRestMultiplier = 1f + Mathf.Min(m_timeSinceRested / ConfigManager.ELossNoRestThreshold.Value, 1f) * (ConfigManager.ELossNoRestMultiplier.Value - 1f);
			}
		}

		public void UpdateMovementState()
		{
			lossEnergyMovementAdd = (pes.PlayerMoving ? (noRestMultiplier * seasonMultiplier * fitnessSkillMultiplier * lossEnergyRestedMult * ConfigManager.ELossMotionAdd.Value) : 0f);
		}

		public void UpdateEnergyValue()
		{
			float num = CalculateThresholdMultiplierForStat(ConfigManager.ELossLowEnergyThreshold.Value);
			float num2 = 1f - num * ConfigManager.ELossLowEnergyResist.Value;
			float num3 = num2 * (energyChange + lossEnergyMovementAdd);
			m_energyLoss = Mathf.Clamp(m_energyLoss + num3, 0f, m_maxEnergyLoss);
		}

		public void Recalculate()
		{
			Main.LogMessage("Recalculating Energy SE");
			m_maxEnergyLoss = baseMaxEnergyLoss + CalculateAdditionalMaxEnergy();
			lossEnergyRestedMult = CalculateRestedMultiplier();
			lossEnergyCarryWeightAdd = CalculateCarryWeightAdd();
			seasonMultiplier = CalculateSeasonMultiplier();
			staminaMeadMult = CalculateStaminaMeadMultiplier();
			fitnessSkillMultiplier = CalculateFitnessSkillMultiplier();
			energyChange = staminaMeadMult * seasonMultiplier * fitnessSkillMultiplier * CalculatePassiveLosses() - (CalculateGainsFromRest() + CalculateGainsFromStaminaMead());
		}

		public float CalculateRestedMultiplier()
		{
			return pes.PlayerRested ? ConfigManager.ELossRestedResist.Value : 1f;
		}

		public float CalculateCarryWeightAdd()
		{
			float value = ConfigManager.ELossHeavyLoadThreshold.Value;
			if (pes.PlayerCarryWeightPerc < value)
			{
				warningWeight = true;
				return 0f;
			}
			if (warningWeight)
			{
				SendPlayerMessage("$ea_energy_warningmessage_weight");
				warningWeight = false;
			}
			float num = CalculateThresholdMultiplierForStat(value);
			return num * ConfigManager.ELossHeavyLoadAdd.Value;
		}

		public float CalculatePassiveLosses()
		{
			float num = 0f;
			if (pes.PlayerCold)
			{
				num += ConfigManager.ELossColdAdd.Value;
			}
			if (pes.PlayerFreezing)
			{
				num += ConfigManager.ELossFreezingAdd.Value;
			}
			if (pes.PlayerWet)
			{
				num += ConfigManager.ELossWetAdd.Value;
			}
			if (pes.PlayerHungry)
			{
				num += ConfigManager.ELossHungryAdd.Value;
			}
			return lossEnergyRestedMult * num;
		}

		public float CalculateGainsFromRest()
		{
			float num = 0f;
			if (pes.PlayerSitting)
			{
				num += ConfigManager.ELossSittingRemove.Value;
			}
			if (pes.PlayerResting)
			{
				num += ConfigManager.ELossRestingRemove.Value;
			}
			if (pes.PlayerRested && !pes.PlayerResting && !pes.PlayerHasBadEnvironmentalStatus)
			{
				num += ConfigManager.ELossRestedRemove.Value;
			}
			if (pes.PlayerSitting && pes.PlayerResting)
			{
				num *= ConfigManager.ELossSittingRestingMultiplier.Value;
			}
			if (pes.PlayerSitting && pes.PlayerResting && pes.PlayerSheltered)
			{
				num *= ConfigManager.ELossSittingRestingShelterMultiplier.Value;
			}
			return m_maxEnergyLoss / baseMaxEnergyLoss * num;
		}

		public float CalculateGainsFromStaminaMead()
		{
			return pes.PlayerStaminaMead ? (ConfigManager.ELossStaminaMeadRemove.Value * m_maxEnergyLoss) : 0f;
		}

		public float CalculateAdditionalMaxEnergy()
		{
			float num = pes.FitnessSkillLevel / 100f;
			float num2 = ConfigManager.FitnessSkillMaxEnergyGain.Value - baseMaxEnergyLoss;
			return num * num2;
		}

		public float CalculateSeasonMultiplier()
		{
			if (pes.PlayerInSeasonExcludedBiome)
			{
				return seasonMultiplier = 1f;
			}
			return pes.EnvironmentSeasonState switch
			{
				EnvironmentSeason.Season.Spring => seasonMultiplier = ConfigManager.ESpringSeasonMultiplier.Value, 
				EnvironmentSeason.Season.Summer => seasonMultiplier = ConfigManager.ESummerSeasonMultiplier.Value, 
				EnvironmentSeason.Season.Fall => seasonMultiplier = ConfigManager.EFallSeasonMultiplier.Value, 
				EnvironmentSeason.Season.Winter => seasonMultiplier = ConfigManager.EWinterSeasonMultiplier.Value, 
				_ => seasonMultiplier = 1f, 
			};
		}

		public float CalculateStaminaMeadMultiplier()
		{
			return staminaMeadMult = (pes.PlayerStaminaMead ? (1f - ConfigManager.ELossStaminaMeadResist.Value) : 1f);
		}

		public float CalculateFitnessSkillMultiplier()
		{
			return 1f - pes.FitnessSkillFactor;
		}

		public void UpdateEffects()
		{
			UpdateRemoveRested();
			UpdateDamageMultOT();
			UpdateMoveSpeedMultOT();
			UpdateSkillGainMultOT();
			UpdateSkillLevelOT();
			UpdateStaminaRegenMultOT();
			UpdateStaminaRegenDelayOT();
		}

		public void UpdateRemoveRested()
		{
			if (!ConfigManager.ERestedLossEnabled.Value)
			{
				return;
			}
			float value = ConfigManager.ERestedLossThreshold.Value;
			if (!(m_energyLossPerc < value) && pes.PlayerRested && !pes.PlayerResting)
			{
				StatusEffect statusEffect = ((Character)player).m_seman.GetStatusEffect(SEMan.s_statusEffectRested);
				SE_Rested val = (SE_Rested)(object)((statusEffect is SE_Rested) ? statusEffect : null);
				if (!((Object)(object)val == (Object)null))
				{
					((Character)player).m_seman.RemoveStatusEffect((StatusEffect)(object)val, false);
				}
			}
		}

		public void UpdateDamageMultOT()
		{
			if (!ConfigManager.EDamageReductionEnabled.Value)
			{
				base.m_damageModifier = 1f;
				return;
			}
			float value = ConfigManager.EDamageReductionThreshold.Value;
			if (m_energyLossPerc < value)
			{
				warningDamage = true;
				base.m_damageModifier = 1f;
				return;
			}
			if (warningDamage)
			{
				SendPlayerMessage("$ea_energy_warningmessage_damage");
				warningDamage = false;
			}
			float num = CalculateThresholdMultiplierForStat(value);
			base.m_damageModifier = 1f - num * ConfigManager.EDamageMaxReduction.Value;
		}

		public void UpdateMoveSpeedMultOT()
		{
			if (!ConfigManager.EMoveSpeedReductionEnabled.Value)
			{
				base.m_speedModifier = 0f;
				return;
			}
			float value = ConfigManager.EMoveSpeedReductionMinThreshold.Value;
			if (m_energyLossPerc < value)
			{
				warningSpeed = true;
				base.m_speedModifier = 0f;
				return;
			}
			if (warningSpeed)
			{
				SendPlayerMessage("$ea_energy_warningmessage_movement");
				warningSpeed = false;
			}
			float num = CalculateThresholdMultiplierForStat(value);
			base.m_speedModifier = -1f * (num * ConfigManager.EMoveSpeedMaxReduction.Value);
		}

		public void UpdateSkillGainMultOT()
		{
			if (!ConfigManager.ESkillGainReductionEnabled.Value)
			{
				base.m_raiseSkillModifier = 0f;
				return;
			}
			float value = ConfigManager.ESkillGainReductionThreshold.Value;
			if (m_energyLossPerc < value)
			{
				warningSkillGain = true;
				base.m_raiseSkillModifier = 0f;
				return;
			}
			if (warningSkillGain)
			{
				SendPlayerMessage("$ea_energy_warningmessage_skillgain");
				warningSkillGain = false;
			}
			float num = CalculateThresholdMultiplierForStat(value);
			base.m_raiseSkillModifier = -1f * (num * ConfigManager.ESkillGainMaxReduction.Value);
		}

		public void UpdateSkillLevelOT()
		{
			if (!ConfigManager.ESkillLevelReductionEnabled.Value)
			{
				base.m_skillLevelModifier = 0f;
				return;
			}
			float value = ConfigManager.ESkillLevelReductionThreshold.Value;
			if (m_energyLossPerc < value)
			{
				warningSkillLevel = true;
				base.m_skillLevelModifier = 0f;
				return;
			}
			if (warningSkillLevel)
			{
				SendPlayerMessage("$ea_energy_warningmessage_skilllevel");
				warningSkillLevel = false;
			}
			float num = CalculateThresholdMultiplierForStat(value);
			base.m_skillLevelModifier = -1f * Mathf.Floor(num * ConfigManager.ESkillLevelMaxReduction.Value);
		}

		public void UpdateStaminaRegenMultOT()
		{
			if (!ConfigManager.EStaminaRegenEnabled.Value)
			{
				base.m_staminaRegenMultiplier = 1f;
				return;
			}
			float value = ConfigManager.EStaminaRegenMinThreshold.Value;
			if (m_energyLossPerc < value)
			{
				warningStaminaRegen = true;
				base.m_staminaRegenMultiplier = 1f;
				return;
			}
			if (warningStaminaRegen)
			{
				SendPlayerMessage("$ea_energy_warningmessage_staminaregen");
				warningStaminaRegen = false;
			}
			float num = CalculateThresholdMultiplierForStat(value);
			base.m_staminaRegenMultiplier = 1f - num * ConfigManager.EStaminaRegenMaxReduction.Value;
		}

		public void UpdateStaminaRegenDelayOT()
		{
			if (!ConfigManager.EStaminaRegenDelayEnabled.Value)
			{
				m_staminaRegenDelay = 0f;
				return;
			}
			float value = ConfigManager.EStaminaRegenDelayMinThreshold.Value;
			if (m_energyLossPerc < value)
			{
				warningStaminaDelay = true;
				m_staminaRegenDelay = 0f;
				return;
			}
			if (warningStaminaDelay)
			{
				SendPlayerMessage("$ea_energy_warningmessage_staminadelay");
				warningStaminaDelay = false;
			}
			float num = CalculateThresholdMultiplierForStat(value);
			m_staminaRegenDelay = num * ConfigManager.EStaminaRegenDelayMaxMultiplier.Value;
		}

		public float CalculateThresholdMultiplierForStat(float threshold)
		{
			return Mathf.Clamp((m_energyLoss - threshold) / (m_maxEnergyLoss - threshold), 0f, 1f);
		}

		public void ApplyEnergyGainFromFood(float stamina)
		{
			if (CheckPlayerData() && !pes.PlayerNoSkillDrain && !(countdownTimer > 0f))
			{
				float num = stamina * ConfigManager.ELossFoodStaminaRemove.Value;
				float num2 = m_maxEnergyLoss / baseMaxEnergyLoss;
				m_energyFromFood += num * num2;
			}
		}

		public void ApplyEnergyGainFromSleeping()
		{
			if (CheckPlayerData() && !pes.PlayerNoSkillDrain && !(countdownTimer > 0f))
			{
				float num = ConfigManager.ELossPercentageSleepRemove.Value / 100f * m_maxEnergyLoss;
				m_energyLoss -= num;
				if (m_energyLoss < 0f)
				{
					m_energyLoss = 0f;
				}
			}
		}

		public void ApplyEnergyLossFromStamina(float stamina)
		{
			if (CheckPlayerData() && stamina != 0f && !pes.PlayerNoSkillDrain && !(countdownTimer > 0f))
			{
				float num = stamina * (ConfigManager.ELossStaminaPointUsedAdd.Value + lossEnergyCarryWeightAdd);
				float num2 = lossEnergyRestedMult * seasonMultiplier * fitnessSkillMultiplier * noRestMultiplier * (1f - pes.FitnessSkillFactor) * num;
				m_energyLoss += num2;
				if (m_energyLoss > m_maxEnergyLoss)
				{
					num = m_energyLoss - m_maxEnergyLoss;
					m_energyLoss = m_maxEnergyLoss;
				}
				RaiseFitnessSkill(num);
				totalStaminaUseInCycle += stamina;
				totalEnergyUseInCycle += num2;
				lastRawLossInCycle = num;
			}
		}

		public void RaiseFitnessSkill(float amount)
		{
			((StatusEffect)this).m_character.RaiseSkill("Fitness", 0.2f * amount * ConfigManager.FitnessSkillGainFactor.Value);
		}

		public void LogStatistics()
		{
			Main.LogMessage("ENERGY SE UPDATE");
			Main.LogMessage("Energy: " + Mathf.Round(100f - m_energyLossPerc) + "( " + (m_maxEnergyLoss - m_energyLoss) + " / " + m_maxEnergyLoss + ")");
			Main.LogMessage("Rested Resist Mult: " + lossEnergyRestedMult);
			Main.LogMessage("No Rested Debuffs: +" + noRestMultiplier + "x (" + m_timeSinceRested + "s since last rested)");
			Main.LogMessage("Stamina Regen Multiplier: " + base.m_staminaRegenMultiplier + "x");
			Main.LogMessage("Stamina Regen Delay: +" + m_staminaRegenDelay + "s");
			Main.LogMessage("Seasonal Multiplier: " + seasonMultiplier + "x");
			Main.LogMessage("Fitness Skill Multiplier " + fitnessSkillMultiplier + "x");
			Main.LogMessage("Stamina Use in Cycle: " + totalStaminaUseInCycle);
			Main.LogMessage("Energy Loss from Stamina in Cycle: " + totalEnergyUseInCycle);
			Main.LogMessage("Last Raw Loss in Cycle: " + lastRawLossInCycle);
		}

		public void ResetCycleStats()
		{
			totalStaminaUseInCycle = 0f;
			totalEnergyUseInCycle = 0f;
			lastRawLossInCycle = 0f;
		}

		public void SendPlayerMessage(string text)
		{
			if (ConfigManager.DisplayEnergyWarningText.Value)
			{
				((StatusEffect)this).m_character.Message((MessageType)2, Localization.instance.Localize(text), 0, (Sprite)null);
			}
		}

		public bool CheckPlayerData()
		{
			if (pes != null)
			{
				return true;
			}
			Main.LogMessage("Player environment stats is null.");
			Character character = ((StatusEffect)this).m_character;
			Player val = (Player)(object)((character is Player) ? character : null);
			if ((Object)(object)val == (Object)null)
			{
				Main.LogMessage("EnergySE not applied to a player.");
				return false;
			}
			player = val;
			pes = PlayerEnvironmentStats.Get(val);
			return true;
		}

		public void UpdateIcon()
		{
			if (pes.PlayerNoSkillDrain)
			{
				((StatusEffect)this).m_icon = iconNoSkillDrain;
				return;
			}
			if (countdownTimer > 0f)
			{
				((StatusEffect)this).m_icon = iconNewSpawn;
				return;
			}
			int num = Mathf.CeilToInt((float)icons.Length * (m_energyLoss / m_maxEnergyLoss));
			if (num > icons.Length - 1)
			{
				num = icons.Length - 1;
			}
			((StatusEffect)this).m_icon = icons[num];
		}
	}
	[<5c9fabdd-05fb-43b2-a213-2116a2b67436>NullableContext(1)]
	[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(0)]
	public class SE_Hungry : SE_Stats
	{
		public static readonly int Hash = StringExtensionMethods.GetStableHashCode(Main.HungrySEName);

		public override void Setup(Character character)
		{
			((SE_Stats)this).Setup(character);
			((StatusEffect)this).m_name = "$ea_se_hungry";
			((StatusEffect)this).m_icon = Main.GetInstance().Bundle.LoadAsset<Sprite>("hungryicon");
		}

		public override void Stop()
		{
			((StatusEffect)this).Stop();
			((StatusEffect)this).m_ttl = 1f;
		}

		public override bool IsDone()
		{
			return false;
		}

		public override string GetTooltipString()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append("$ea_player_hungry_status");
			stringBuilder.Append(((SE_Stats)this).GetTooltipString());
			return stringBuilder.ToString();
		}
	}
	[<5c9fabdd-05fb-43b2-a213-2116a2b67436>NullableContext(1)]
	[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(0)]
	public class SE_Vitality : SE_Stats
	{
		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(new byte[] { 2, 1 })]
		public Sprite[] icons;

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(2)]
		public Sprite iconNoSkillDrain;

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(2)]
		public Sprite iconNewSpawn;

		public float m_vulnerability = 0f;

		public float m_foodBurnMult = 1f;

		public float m_foodStatBurn = 1f;

		public float vulnerabilityChange = 0f;

		public float vulnerabilityFromDamage = 0f;

		public float vulnerabilitySkillResist = 0f;

		public float seasonMultiplier = 1f;

		public float armorReduction = 0f;

		public float updateTimerState = 0f;

		public float updateTimerStats = 0f;

		public float updateTimerIcon = 0f;

		public float updateTimerLogs = 0f;

		public float countdownTimer = 300f;

		public bool warningHealth = true;

		public bool warningStamina = true;

		public bool warningFood = true;

		public bool warningSpeed = true;

		public bool warningPhysical = true;

		public bool warningElemental = true;

		public bool physicalWeaknessActive = false;

		public bool elementalWeaknessActive = false;

		public readonly float vulnerabilityMin = 0f;

		public readonly float vulnerabilityMax = 100f;

		public readonly Dictionary<string, DamageModPair> weaknesses = new Dictionary<string, DamageModPair>
		{
			{
				"blunt",
				new DamageModPair
				{
					m_type = (DamageType)1,
					m_modifier = (DamageModifier)2
				}
			},
			{
				"slash",
				new DamageModPair
				{
					m_type = (DamageType)2,
					m_modifier = (DamageModifier)2
				}
			},
			{
				"pierce",
				new DamageModPair
				{
					m_type = (DamageType)4,
					m_modifier = (DamageModifier)2
				}
			},
			{
				"fire",
				new DamageModPair
				{
					m_type = (DamageType)32,
					m_modifier = (DamageModifier)2
				}
			},
			{
				"frost",
				new DamageModPair
				{
					m_type = (DamageType)64,
					m_modifier = (DamageModifier)2
				}
			},
			{
				"lightning",
				new DamageModPair
				{
					m_type = (DamageType)128,
					m_modifier = (DamageModifier)2
				}
			},
			{
				"poison",
				new DamageModPair
				{
					m_type = (DamageType)256,
					m_modifier = (DamageModifier)2
				}
			}
		};

		public readonly string[] statuses = new string[5] { "$ea_vulnerability_status_0", "$ea_vulnerability_status_1", "$ea_vulnerability_status_2", "$ea_vulnerability_status_3", "$ea_vulnerability_status_4" };

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(2)]
		private Player player;

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(2)]
		private PlayerEnvironmentStats pes;

		public static readonly int Hash = StringExtensionMethods.GetStableHashCode(Main.VitalitySEName);

		public override void Setup(Character character)
		{
			((SE_Stats)this).Setup(character);
			((StatusEffect)this).m_name = "$ea_se_vitality";
			LoadIcons();
			((StatusEffect)this).m_icon = icons[0];
			m_vulnerability = 0f;
			base.m_tickInterval = 5f;
			updateTimerState = 0f;
			updateTimerStats = 0f;
			updateTimerIcon = 0f;
			updateTimerLogs = 0f;
			countdownTimer = ConfigManager.NewPlayerCooldown.Value;
			ref Player reference = ref player;
			Character character2 = ((StatusEffect)this).m_character;
			reference = (Player)(object)((character2 is Player) ? character2 : null);
			if ((Object)(object)player == (Object)null)
			{
				((StatusEffect)this).m_character.m_seman.RemoveStatusEffect((StatusEffect)(object)this, false);
				return;
			}
			if (player.IsMaterialKnown("$item_stone") || player.IsMaterialKnown("$item_wood"))
			{
				Main.LogMessage("Player knows a material. Cooldown disabled for Vitality status.");
				countdownTimer = 0f;
			}
			pes = PlayerEnvironmentStats.Get(player);
			Recalculate();
		}

		public void LoadIcons()
		{
			Sprite[] array = (Sprite[])(object)new Sprite[10];
			for (int i = 0; i < 10; i++)
			{
				string text = "vitalityicon" + (i + 1);
				array[i] = Main.GetInstance().Bundle.LoadAsset<Sprite>(text);
			}
			icons = array;
			iconNoSkillDrain = Main.GetInstance().Bundle.LoadAsset<Sprite>("vitalityicondeath");
			iconNewSpawn = Main.GetInstance().Bundle.LoadAsset<Sprite>("vitalityiconnewplayer");
		}

		public override void Stop()
		{
			((StatusEffect)this).Stop();
			m_vulnerability = 0f;
			base.m_healthPerTick = 0f;
			base.m_healthRegenMultiplier = 1f;
			base.m_staminaRegenMultiplier = 1f;
			m_foodBurnMult = 1f;
			base.m_mods = new List<DamageModPair>();
			((StatusEffect)this).m_ttl = 1f;
			updateTimerState = 0f;
			updateTimerStats = 0f;
			updateTimerIcon = 0f;
			updateTimerLogs = 0f;
			countdownTimer = 60f;
		}

		public override bool IsDone()
		{
			return false;
		}

		public override string GetIconText()
		{
			if (pes.PlayerNoSkillDrain)
			{
				return "";
			}
			if (countdownTimer > 0f)
			{
				return StatusEffect.GetTimeString(countdownTimer, false, false);
			}
			if (!ConfigManager.DisplayVitalityPercentage.Value)
			{
				return "";
			}
			int num = 100 - Mathf.FloorToInt(m_vulnerability);
			return $"{num}%";
		}

		public override string GetTooltipString()
		{
			StringBuilder stringBuilder = new StringBuilder();
			if (pes.PlayerNoSkillDrain)
			{
				stringBuilder.Append("$ea_player_vulnerability_immune \n");
				return stringBuilder.ToString();
			}
			if (countdownTimer > 0f)
			{
				stringBuilder.AppendFormat("$ea_player_vulnerability_cooldown: {0}s. \n", Mathf.Ceil(countdownTimer));
				return stringBuilder.ToString();
			}
			stringBuilder.Append(GetVulnerabilityStatus());
			if (pes.PlayerHealingMead)
			{
				stringBuilder.Append("$ea_player_healing_mead \n");
			}
			if (vulnerabilityChange > 0f)
			{
				if (!pes.PlayerSheltered && (pes.EnvironmentCold || pes.EnvironmentFreezing))
				{
					stringBuilder.Append("$ea_player_coldfreezing_vitality \n");
				}
				if (pes.PlayerHungry)
				{
					stringBuilder.Append("$ea_player_hungry_vitality \n");
				}
				if (pes.PlayerInHarshBiome)
				{
					stringBuilder.Append("$ea_player_harshbiome_vitality \n");
				}
				if (pes.PlayerSheltered && !pes.PlayerNearFire && pes.EnvironmentFreezing)
				{
					stringBuilder.Append("$ea_player_too_cold_shelter_vitality \n");
				}
			}
			else if (vulnerabilityChange < 0f && m_vulnerability > 0.1f)
			{
				stringBuilder.Append("$ea_player_recovering_vitality \n");
			}
			stringBuilder.Append(((SE_Stats)this).GetTooltipString());
			if (base.m_healthPerTick != 0f)
			{
				stringBuilder.AppendFormat("$se_health: <color=orange>{0}</color> \n", Mathf.Floor(base.m_healthPerTick).ToString("+0;-0"));
			}
			if (m_foodBurnMult >= 1.01f)
			{
				stringBuilder.AppendFormat("$ea_se_foodburn: <color=orange>{0}</color> \n", (Mathf.Round(m_foodBurnMult * 100f) / 100f).ToString());
			}
			return stringBuilder.ToString();
		}

		public string GetVulnerabilityStatus()
		{
			int num = Mathf.Clamp(Mathf.FloorToInt(m_vulnerability / (100f / (float)statuses.Length)), 0, statuses.Length - 1);
			return statuses[num] + "\n";
		}

		public override void UpdateStatusEffect(float dt)
		{
			if (pes == null)
			{
				((StatusEffect)this).m_character.m_seman.RemoveStatusEffect((StatusEffect)(object)this, false);
			}
			((SE_Stats)this).UpdateStatusEffect(dt);
			((StatusEffect)this).m_ttl = 1f;
			if (countdownTimer <= 0f && !pes.PlayerNoSkillDrain)
			{
				updateTimerState += dt;
				updateTimerStats += dt;
			}
			updateTimerIcon += dt;
			updateTimerLogs += dt;
			if (!((Object)(object)player == (Object)null))
			{
				if (updateTimerState >= 1f && countdownTimer <= 0f && !pes.PlayerNoSkillDrain)
				{
					UpdateVulnerabilityValue();
					RaiseResistanceSkill();
					updateTimerState -= 1f;
				}
				if (updateTimerStats >= 5f && countdownTimer <= 0f && !pes.PlayerNoSkillDrain)
				{
					UpdateEffects();
					UpdateTutorial();
					updateTimerStats -= 5f;
				}
				if (updateTimerLogs >= 10f)
				{
					LogStatistics();
					updateTimerLogs -= 10f;
				}
				if (countdownTimer > 0f)
				{
					countdownTimer -= dt;
				}
				else
				{
					countdownTimer = 0f;
				}
				if (updateTimerIcon > 1f)
				{
					UpdateIcon();
					updateTimerIcon -= 1f;
				}
			}
		}

		public void UpdateTutorial()
		{
			if (m_vulnerability > 10f)
			{
				player.ShowTutorial("EnvironmentalAwarenessVitality", false);
			}
			if (m_vulnerability > 60f)
			{
				player.ShowTutorial("EnvironmentalAwarenessVitalityLow", false);
			}
		}

		public void Recalculate()
		{
			Main.LogMessage("Recalculating Vitality Change");
			vulnerabilitySkillResist = CalculateResistanceFromSkill();
			seasonMultiplier = CalculateSeasonMultiplier();
			vulnerabilityChange = CalculateVulnerabilityChange();
		}

		public void UpdateVulnerabilityValue()
		{
			m_vulnerability = Mathf.Clamp(m_vulnerability + vulnerabilityChange + vulnerabilityFromDamage, vulnerabilityMin, vulnerabilityMax);
			vulnerabilityFromDamage = 0f;
		}

		public float CalculateVulnerabilityChange()
		{
			float num = CalculateArmorReduction() * CalculateLossFromEnvironment() + CalculateHungerLoss();
			float num2 = CalculateRecoveryFromWarmShelteredRestingPassive() + CalculateRecoveryFromHealthMead();
			return vulnerabilitySkillResist * num - num2;
		}

		public float CalculateLossFromEnvironment()
		{
			float result = 0f;
			if (pes.PlayerInExcludedEnvironment)
			{
				return result;
			}
			float num = 0f;
			float num2 = 0f;
			float num3 = 0f;
			if (pes.EnvironmentCold && !pes.PlayerNearFire)
			{
				num = ConfigManager.VColdAdd.Value;
			}
			if (pes.EnvironmentFreezing && (!pes.PlayerNearFire || !pes.PlayerSheltered))
			{
				num2 = ConfigManager.VFreezingAdd.Value;
			}
			if (pes.PlayerWet)
			{
				num3 = ConfigManager.VWetAdd.Value;
			}
			result = num + num2 + num3;
			if (num > 0f && num3 > 0f)
			{
				result *= ConfigManager.VColdWetMultiplier.Value;
			}
			if (num2 > 0f && num3 > 0f)
			{
				result *= ConfigManager.VFreezingWetMultiplier.Value;
			}
			if (pes.PlayerFrostResistant)
			{
				result *= ConfigManager.VFrostResistantMultiplier.Value;
			}
			if (pes.PlayerFrostVeryResistant)
			{
				result *= ConfigManager.VFrostVeryResistantMultiplier.Value;
			}
			float num4 = 0f;
			num4 += CalculateStatusEffectLoss(pes.PlayerPoisoned, pes.PlayerPoisonVeryResistant, ConfigManager.VPoisonVeryResistantMultiplier.Value, pes.PlayerPoisonResistant, ConfigManager.VPoisonResistantMultiplier.Value, ConfigManager.VPoisonDamageAdd.Value);
			num4 += CalculateStatusEffectLoss(pes.PlayerBurning, pes.PlayerFireVeryResistant, ConfigManager.VFireVeryResistantMultiplier.Value, pes.PlayerFireResistant, ConfigManager.VFireResistantMultiplier.Value, ConfigManager.VBurningDamageAdd.Value);
			num4 += CalculateStatusEffectLoss(pes.PlayerShocked, pes.PlayerLightningVeryResistant, ConfigManager.VLightningVeryResistantMultiplier.Value, pes.PlayerLightningResistant, ConfigManager.VLightningResistantMultiplier.Value, ConfigManager.VShockDamageAdd.Value);
			num4 += CalculateStatusEffectLoss(pes.PlayerFrozen, pes.PlayerFrostVeryResistant, ConfigManager.VFrostVeryResistantMultiplier.Value, pes.PlayerFrostResistant, ConfigManager.VFrostResistantMultiplier.Value, ConfigManager.VFrostDamageAdd.Value);
			return seasonMultiplier * (result + CalculateBiomePassiveLoss()) + num4;
		}

		public float CalculateStatusEffectLoss(bool debuffType, bool vresistant, float vresistantmult, bool resistant, float resistantmult, float damage)
		{
			float result = 0f;
			if (debuffType && damage > 0f)
			{
				float num = 1f;
				if (vresistant)
				{
					num = vresistantmult;
				}
				else if (resistant)
				{
					num = resistantmult;
				}
				result = num * damage;
			}
			return result;
		}

		public float CalculateHungerLoss()
		{
			return pes.PlayerHungry ? ConfigManager.VHungerAdd.Value : 0f;
		}

		public float CalculateBiomePassiveLoss()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: 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_0014: 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)
			//IL_0018: Invalid comparison between Unknown and I4
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Invalid comparison between Unknown and I4
			float num = 1f;
			Biome playerInBiome = pes.PlayerInBiome;
			Biome val = playerInBiome;
			if ((int)val != 32)
			{
				if ((int)val == 64)
				{
					if (pes.PlayerFrostVeryResistant)
					{
						num = ConfigManager.VFrostVeryResistantMultiplier.Value;
					}
					else if (pes.PlayerFrostResistant)
					{
						num = ConfigManager.VFrostResistantMultiplier.Value;
					}
					return num * ConfigManager.VDeepNorthPassiveAdd.Value;
				}
				return 0f;
			}
			if (pes.PlayerFireVeryResistant)
			{
				num = ConfigManager.VFireVeryResistantMultiplier.Value;
			}
			else if (pes.PlayerFireResistant)
			{
				num = ConfigManager.VFireResistantMultiplier.Value;
			}
			return num * ConfigManager.VAshlandsPassiveAdd.Value;
		}

		public float CalculateSeasonMultiplier()
		{
			if (pes.PlayerInSeasonExcludedBiome)
			{
				return seasonMultiplier = 1f;
			}
			return pes.EnvironmentSeasonState switch
			{
				EnvironmentSeason.Season.Spring => seasonMultiplier = ConfigManager.VSpringSeasonalMultiplier.Value, 
				EnvironmentSeason.Season.Summer => seasonMultiplier = ConfigManager.VSummerSeasonalMultiplier.Value, 
				EnvironmentSeason.Season.Fall => seasonMultiplier = ConfigManager.VFallSeasonalMultiplier.Value, 
				EnvironmentSeason.Season.Winter => seasonMultiplier = ConfigManager.VWinterSeasonalMultiplier.Value, 
				_ => seasonMultiplier = 1f, 
			};
		}

		public float CalculateResistanceFromSkill()
		{
			return vulnerabilitySkillResist = 1f - pes.ResistanceSkillFactor;
		}

		public float CalculateRecoveryFromWarmShelteredRestingPassive()
		{
			float num = 0f;
			float num2 = 0f;
			if (pes.PlayerSheltered)
			{
				num = ConfigManager.VShelteredRemove.Value;
				if (pes.PlayerWet)
				{
					num *= 0.1f;
				}
			}
			if (pes.EnvironmentCold || pes.EnvironmentFreezing)
			{
				if (pes.PlayerNearFire && !pes.PlayerWet && !pes.PlayerHasBadElementalStatus && pes.PlayerSheltered)
				{
					num2 = ConfigManager.VHeatRemove.Value;
				}
			}
			else if (pes.PlayerNearFire && !pes.PlayerWet && !pes.PlayerHasBadElementalStatus)
			{
				num2 = ConfigManager.VHeatRemove.Value;
			}
			float num3 = num + num2;
			if (num2 > 0f && num > 0f)
			{
				num3 *= ConfigManager.VHeatShelteredMultiplier.Value;
			}
			if (pes.PlayerResting)
			{
				num3 += ConfigManager.VRestingRemove.Value;
			}
			if (pes.PlayerRested)
			{
				num3 += ConfigManager.VRestedRemove.Value;
			}
			if (!pes.PlayerHungry && !pes.PlayerHasBadEnvironmentalStatus && !pes.PlayerHasBadElementalStatus)
			{
				num3 += ConfigManager.VPassiveRemove.Value;
			}
			float num4 = 1f;
			if (pes.PlayerHungry)
			{
				num4 = 0.1f;
			}
			return num4 * num3;
		}

		public float CalculateRecoveryFromHealthMead()
		{
			return pes.PlayerHealingMead ? ConfigManager.VHealthPotionRemove.Value : 0f;
		}

		public float CalculateArmorReduction()
		{
			float num = Mathf.Max(pes.PlayerBodyArmor - (float)ConfigManager.VResistanceMinArmorThreshold.Value, 0f);
			return armorReduction = Mathf.Pow(ConfigManager.VResistancePerArmorPoint.Value, num);
		}

		public void UpdateIcon()
		{
			if (pes.PlayerNoSkillDrain)
			{
				((StatusEffect)this).m_icon = iconNoSkillDrain;
				return;
			}
			if (countdownTimer > 0f)
			{
				((StatusEffect)this).m_icon = iconNewSpawn;
				return;
			}
			int num = Mathf.CeilToInt((float)icons.Length * (m_vulnerability / 100f));
			if (num > icons.Length - 1)
			{
				num = icons.Length - 1;
			}
			((StatusEffect)this).m_icon = icons[num];
		}

		public void UpdateEffects()
		{
			UpdateHealthDoT();
			UpdateStaminaUseMultOT();
			UpdateMoveSpeedMultOT();
			UpdateFoodBurnMultOT();
			UpdatePhysicalWeakness();
			UpdateElementalWeakness();
			UpdateFoodStats();
		}

		public void UpdateHealthDoT()
		{
			if (!ConfigManager.VHealthDamageEnabled.Value)
			{
				base.m_healthPerTick = 0f;
				base.m_healthRegenMultiplier = 1f;
				return;
			}
			float value = ConfigManager.VHealthDamageMinStartThreshold.Value;
			if (m_vulnerability < value)
			{
				warningHealth = true;
				base.m_healthPerTick = 0f;
				base.m_healthRegenMultiplier = 1f;
				return;
			}
			if (warningHealth)
			{
				SendPlayerMessage("$ea_vitality_warningmessage_health");
				warningHealth = false;
			}
			float num = CalculateThresholdMultiplierForStat(value);
			base.m_healthPerTick = -1f * num * ConfigManager.VHealthMaxDamageOverTime.Value;
			base.m_healthRegenMultiplier = 1f - num * ConfigManager.VHealthMaxRegenReduction.Value;
		}

		public void UpdateStaminaUseMultOT()
		{
			if (!ConfigManager.VStaminaRegenReductionEnabled.Value)
			{
				base.m_staminaRegenMultiplier = 1f;
				return;
			}
			float value = ConfigManager.VStaminaRegenReductionThreshold.Value;
			if (m_vulnerability < value)
			{
				warningStamina = true;
				base.m_staminaRegenMultiplier = 1f;
				return;
			}
			if (warningStamina)
			{
				SendPlayerMessage("$ea_vitality_warningmessage_stamina");
				warningStamina = false;
			}
			float num = CalculateThresholdMultiplierForStat(value);
			base.m_staminaRegenMultiplier = 1f - num * ConfigManager.VStaminaRegenMaxReduction.Value;
		}

		public void UpdateMoveSpeedMultOT()
		{
			if (!ConfigManager.VMoveSpeedReductionEnabled.Value)
			{
				base.m_speedModifier = 0f;
				return;
			}
			float value = ConfigManager.VMoveSpeedMinStartThreshold.Value;
			if (m_vulnerability < value)
			{
				warningSpeed = true;
				base.m_speedModifier = 0f;
				return;
			}
			if (warningSpeed)
			{
				SendPlayerMessage("$ea_vitality_warningmessage_movement");
				warningSpeed = false;
			}
			float num = CalculateThresholdMultiplierForStat(value);
			base.m_speedModifier = -1f * (num * ConfigManager.VMoveSpeedMaxReduction.Value);
		}

		public void UpdateFoodBurnMultOT()
		{
			if (!ConfigManager.VFoodBurnRateEnabled.Value)
			{
				m_foodBurnMult = 1f;
				m_foodStatBurn = 1f;
				return;
			}
			float value = ConfigManager.VFoodBurnMinStartThreshold.Value;
			if (m_vulnerability < value)
			{
				warningFood = true;
				m_foodBurnMult = 1f;
				m_foodStatBurn = 1f;
				return;
			}
			if (warningFood)
			{
				SendPlayerMessage("$ea_vitality_warningmessage_foodburn");
				warningFood = false;
			}
			float num = CalculateThresholdMultiplierForStat(value);
			m_foodBurnMult = 1f + num * (ConfigManager.VFoodBurnMaxOverTime.Value - 1f);
			m_foodStatBurn = Mathf.Sqrt(m_foodBurnMult);
		}

		public void UpdatePhysicalWeakness()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			if (!ConfigManager.VPhysicalWeaknessEnabled.Value)
			{
				return;
			}
			if (m_vulnerability < ConfigManager.VPhysicalWeaknessThreshold.Value)
			{
				warningPhysical = true;
				if (physicalWeaknessActive)
				{
					base.m_mods.Remove(weaknesses["blunt"]);
					base.m_mods.Remove(weaknesses["slash"]);
					base.m_mods.Remove(weaknesses["pierce"]);
					physicalWeaknessActive = false;
				}
				return;
			}
			if (warningPhysical)
			{
				SendPlayerMessage("$ea_vitality_warningmessage_physical");
				warningPhysical = false;
			}
			if (!physicalWeaknessActive)
			{
				base.m_mods.Add(weaknesses["blunt"]);
				base.m_mods.Add(weaknesses["slash"]);
				base.m_mods.Add(weaknesses["pierce"]);
				physicalWeaknessActive = true;
			}
		}

		public void UpdateElementalWeakness()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			if (!ConfigManager.VElementalWeaknessEnabled.Value)
			{
				return;
			}
			if (m_vulnerability < ConfigManager.VElementalWeaknessThreshold.Value)
			{
				warningElemental = true;
				if (elementalWeaknessActive)
				{
					base.m_mods.Remove(weaknesses["fire"]);
					base.m_mods.Remove(weaknesses["frost"]);
					base.m_mods.Remove(weaknesses["lightning"]);
					base.m_mods.Remove(weaknesses["poison"]);
					elementalWeaknessActive = false;
				}
				return;
			}
			if (warningElemental)
			{
				SendPlayerMessage("$ea_vitality_warningmessage_elemental");
				warningElemental = false;
			}
			if (!elementalWeaknessActive)
			{
				base.m_mods.Add(weaknesses["fire"]);
				base.m_mods.Add(weaknesses["frost"]);
				base.m_mods.Add(weaknesses["lightning"]);
				base.m_mods.Add(weaknesses["poison"]);
				elementalWeaknessActive = true;
			}
		}

		public void UpdateFoodStats()
		{
			Dictionary<string, Dictionary<string, float>> foodCacheForPlayer = PlayerFoodCache.GetFoodCacheForPlayer(player);
			foreach (Food food in player.m_foods)
			{
				string name = food.m_item.m_shared.m_name;
				if (!foodCacheForPlayer.TryGetValue(name, out var value))
				{
					Main.LogMessage("Could not find food with name " + name + " in cache. Skipping.");
					continue;
				}
				food.m_item.m_shared.m_foodBurnTime = value[PlayerFoodCache.Time] / m_foodBurnMult;
				if (food.m_time > food.m_item.m_shared.m_foodBurnTime)
				{
					food.m_time = food.m_item.m_shared.m_foodBurnTime;
				}
				Main.LogMessage("Food burn time for " + food.m_item.m_shared.m_name + ": " + value[PlayerFoodCache.Time] + " -> " + food.m_item.m_shared.m_foodBurnTime);
				if (ConfigManager.VFoodBurnStatReduction.Value)
				{
					food.m_health = value[PlayerFoodCache.Health] / m_foodStatBurn;
					food.m_stamina = value[PlayerFoodCache.Stamina] / m_foodStatBurn;
					food.m_eitr = value[PlayerFoodCache.Eitr] / m_foodStatBurn;
					Main.LogMessage("Food stats: HP: " + value[PlayerFoodCache.Health] + " -> " + Mathf.Round(food.m_health) + ", Stamina: " + value[PlayerFoodCache.Stamina] + " -> " + Mathf.Round(food.m_stamina) + ", Eitr: " + value[PlayerFoodCache.Eitr] + " -> " + Mathf.Round(food.m_eitr));
				}
			}
		}

		public float CalculateThresholdMultiplierForStat(float threshold)
		{
			return Mathf.Clamp((m_vulnerability - threshold) / (vulnerabilityMax - threshold), 0f, 1f);
		}

		public void RaiseResistanceSkill()
		{
			if (!((Object)(object)player == (Object)null))
			{
				float value = ConfigManager.ResistanceSkillGainMinThreshold.Value;
				if (!(m_vulnerability <= value))
				{
					float num = CalculateThresholdMultiplierForStat(value);
					((Character)(object)player).RaiseSkill("Resistance", num * ConfigManager.ResistanceSkillGainFactor.Value);
				}
			}
		}

		public void SendPlayerMessage(string text)
		{
			if (ConfigManager.DisplayVitalityWarningTexts.Value)
			{
				((StatusEffect)this).m_character.Message((MessageType)2, Localization.instance.Localize(text), 0, (Sprite)null);
			}
		}

		public void LogStatistics()
		{
			Main.LogMessage("VITALITY SE UPDATE");
			if (countdownTimer > 0f)
			{
				Main.LogMessage("Countdown: " + Mathf.Floor(countdownTimer) + "s");
				return;
			}
			Main.LogMessage("Vitality: " + Mathf.Round(100f * (100f - m_vulnerability)) / 100f + "%");
			Main.LogMessage("HP: " + Mathf.Round(100f * base.m_healthPerTick) / 100f + "HP/t");
			Main.LogMessage("Stamina Regen Multiplier: " + Mathf.Round(100f * base.m_staminaRegenMultiplier) / 100f + "x");
			Main.LogMessage("Move Speed:" + Mathf.Round(100f * base.m_speedModifier) / 100f);
			Main.LogMessage("Food Burn Multiplier: " + Mathf.Round(100f * m_foodBurnMult) / 100f + "x");
			Main.LogMessage("Food Stat Multiplier: " + Mathf.Round(100f * m_foodStatBurn) / 100f + "x");
		}

		public void ApplyVulnerabilityFromDamage(float damage)
		{
			if (!pes.PlayerNoSkillDrain && !(countdownTimer > 0f))
			{
				vulnerabilityFromDamage += vulnerabilitySkillResist * armorReduction * ConfigManager.VHPDamageAdd.Value * damage;
			}
		}
	}
}
namespace EnvironmentalAwareness.Patch
{
	internal class ObjectDB_Awake
	{
		[HarmonyPatch(typeof(ObjectDB), "Awake")]
		public static class ObjectDB_Awake_Patches
		{
			[<5c9fabdd-05fb-43b2-a213-2116a2b67436>NullableContext(1)]
			[HarmonyPriority(700)]
			public static void Postfix(ObjectDB __instance)
			{
				SE_Vitality vitality = Main.GetInstance().Vitality;
				if (!__instance.m_StatusEffects.Contains((StatusEffect)(object)vitality))
				{
					Main.LogMessage("Adding Vitality status effect to ObjectDB.");
					__instance.m_StatusEffects.Add((StatusEffect)(object)vitality);
				}
				SE_Energy energy = Main.GetInstance().Energy;
				if (!__instance.m_StatusEffects.Contains((StatusEffect)(object)energy))
				{
					Main.LogMessage("Adding Energy status effect to ObjectDB.");
					__instance.m_StatusEffects.Add((StatusEffect)(object)energy);
				}
				SE_Hungry hungry = Main.GetInstance().Hungry;
				if (!__instance.m_StatusEffects.Contains((StatusEffect)(object)hungry))
				{
					Main.LogMessage("Adding Hungry status effect to ObjectDB.");
					__instance.m_StatusEffects.Add((StatusEffect)(object)hungry);
				}
			}
		}
	}
	internal class Player_EatFood
	{
		[HarmonyPatch(typeof(Player), "EatFood")]
		public static class Player_EatFood_Patches
		{
			[<5c9fabdd-05fb-43b2-a213-2116a2b67436>NullableContext(1)]
			[HarmonyPriority(700)]
			public static void Postfix(Player __instance, ItemData item, bool __result)
			{
				if (__result && ConfigManager.EnergyEnabled.Value && ((Character)__instance).m_seman.HaveStatusEffect(SE_Energy.Hash))
				{
					SE_Energy sE_Energy = ((Character)__instance).m_seman.GetStatusEffect(SE_Energy.Hash) as SE_Energy;
					if (!((Object)(object)sE_Energy == (Object)null) && item.m_shared.m_foodStamina != 0f)
					{
						sE_Energy.ApplyEnergyGainFromFood(item.m_shared.m_foodStamina);
					}
				}
			}
		}
	}
	internal class Player_OnDamaged
	{
		[HarmonyPatch(typeof(Player), "OnDamaged")]
		public static class Player_OnDamaged_Patches
		{
			[<5c9fabdd-05fb-43b2-a213-2116a2b67436>NullableContext(1)]
			[HarmonyPriority(700)]
			public static void Postfix(Player __instance, HitData hit)
			{
				if (!ConfigManager.VitalityEnabled.Value || ((Character)__instance).m_seman.HaveStatusEffect(SE_Vitality.Hash))
				{
					return;
				}
				SE_Vitality sE_Vitality = ((Character)__instance).m_seman.GetStatusEffect(SE_Vitality.Hash) as SE_Vitality;
				if (!((Object)(object)sE_Vitality == (Object)null))
				{
					float totalDamage = hit.GetTotalDamage();
					if (!(totalDamage < 1f))
					{
						sE_Vitality.ApplyVulnerabilityFromDamage(totalDamage);
					}
				}
			}
		}
	}
	internal class Player_OnSpawned
	{
		[HarmonyPatch(typeof(Player), "OnSpawned")]
		public static class Player_OnSpawned_Patches
		{
			[HarmonyPriority(700)]
			[<5c9fabdd-05fb-43b2-a213-2116a2b67436>NullableContext(1)]
			public static void Postfix(Player __instance)
			{
				Main.LogMessage("Player with ID " + __instance.GetPlayerID() + " spawned.");
				PlayerFoodCache.AddOrRefreshCacheForPlayer(__instance);
				PlayerEnvironmentStats.Get(__instance);
			}
		}
	}
	internal class Player_RPC_UseStamina
	{
		[HarmonyPatch(typeof(Player), "RPC_UseStamina")]
		public static class Player_RPC_UseStamina_Patches
		{
			[HarmonyPriority(700)]
			[<5c9fabdd-05fb-43b2-a213-2116a2b67436>NullableContext(1)]
			public static void Postfix(Player __instance, float v)
			{
				if (ConfigManager.EnergyEnabled.Value && !((Character)__instance).InIntro() && ((Character)__instance).m_seman.HaveStatusEffect(SE_Energy.Hash))
				{
					SE_Energy sE_Energy = ((Character)__instance).m_seman.GetStatusEffect(SE_Energy.Hash) as SE_Energy;
					if (!((Object)(object)sE_Energy == (Object)null))
					{
						sE_Energy.ApplyEnergyLossFromStamina(v);
					}
				}
			}
		}
	}
	internal class Player_SetSleeping
	{
		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(0)]
		[<5c9fabdd-05fb-43b2-a213-2116a2b67436>NullableContext(1)]
		[HarmonyPatch(typeof(Player), "SetSleeping")]
		public static class Player_SetSleeping_Patches
		{
			[HarmonyPriority(700)]
			public static void Prefix(Player __instance, bool sleep, out bool __state)
			{
				__state = __instance.m_sleeping != sleep;
			}

			[HarmonyPriority(700)]
			public static void Postfix(Player __instance, bool __state)
			{
				if (__state)
				{
					SE_Energy sE_Energy = ((Character)__instance).m_seman.GetStatusEffect(SE_Energy.Hash) as SE_Energy;
					if (!((Object)(object)sE_Energy == (Object)null))
					{
						sE_Energy.ApplyEnergyGainFromSleeping();
					}
				}
			}
		}
	}
	internal class Player_UpdateEnvStatusEffects
	{
		[HarmonyPatch(typeof(Player), "UpdateEnvStatusEffects")]
		[<5c9fabdd-05fb-43b2-a213-2116a2b67436>NullableContext(1)]
		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(0)]
		public static class Player_UpdateEnvStatusEffects_Patches
		{
			[HarmonyPriority(700)]
			public static void Postfix(Player __instance, float dt)
			{
				if (!((Character)__instance).InIntro() && __instance.GetPlayerID() != 0)
				{
					PlayerEnvironmentStats playerEnvironmentStats = PlayerEnvironmentStats.Get(__instance);
					playerEnvironmentStats.Update(dt);
					HandleVitality(__instance, playerEnvironmentStats);
					HandleEnergy(__instance, playerEnvironmentStats);
					playerEnvironmentStats.AfterRecalculate();
				}
			}

			public static void HandleVitality(Player player, PlayerEnvironmentStats pes)
			{
				if (ConfigManager.VitalityEnabled.Value)
				{
					if (!((Character)player).m_seman.HaveStatusEffect(SE_Vitality.Hash))
					{
						((Character)player).m_seman.AddStatusEffect(SE_Vitality.Hash, false, 0, 0f);
						Main.LogMessage("Vitality status effect initialized");
					}
					SE_Vitality sE_Vitality = ((Character)player).m_seman.GetStatusEffect(SE_Vitality.Hash) as SE_Vitality;
					if ((Object)(object)sE_Vitality != (Object)null && pes.ShouldRecalculate())
					{
						sE_Vitality.Recalculate();
					}
				}
			}

			public static void HandleEnergy(Player player, PlayerEnvironmentStats pes)
			{
				if (ConfigManager.EnergyEnabled.Value)
				{
					if (!((Character)player).m_seman.HaveStatusEffect(SE_Energy.Hash))
					{
						((Character)player).m_seman.AddStatusEffect(SE_Energy.Hash, false, 0, 0f);
						Main.LogMessage("Energy status effect initialized");
					}
					SEMan seman = ((Character)player).m_seman;
					SE_Energy sE_Energy = ((seman != null) ? seman.GetStatusEffect(SE_Energy.Hash) : null) as SE_Energy;
					if ((Object)(object)sE_Energy != (Object)null && pes.ShouldRecalculate())
					{
						sE_Energy.Recalculate();
					}
				}
			}
		}
	}
	internal class Player_UpdateFood
	{
		[HarmonyPatch(typeof(Player), "UpdateFood")]
		public static class Player_UpdateFood_Patches
		{
			[<5c9fabdd-05fb-43b2-a213-2116a2b67436>NullableContext(1)]
			[HarmonyPriority(700)]
			public static void Postfix(Player __instance)
			{
				if (!((Character)__instance).InIntro() && __instance.GetPlayerID() != 0 && ConfigManager.HungerEnabled.Value)
				{
					if (__instance.m_foods.Count == 0 && !((Character)__instance).m_seman.HaveStatusEffect(SE_Hungry.Hash))
					{
						((Character)__instance).m_seman.AddStatusEffect(SE_Hungry.Hash, false, 0, 0f);
					}
					if (__instance.m_foods.Count > 0 && ((Character)__instance).m_seman.HaveStatusEffect(SE_Hungry.Hash))
					{
						((Character)__instance).m_seman.RemoveStatusEffect(SE_Hungry.Hash, false);
					}
				}
			}
		}
	}
	internal class Tutorial_Awake
	{
		[HarmonyPatch(typeof(Tutorial), "Awake")]
		public static class Tutorial_Awake_Patches
		{
			[HarmonyPriority(700)]
			[<5c9fabdd-05fb-43b2-a213-2116a2b67436>NullableContext(1)]
			public static void Postfix(Tutorial __instance)
			{
				TutorialText[] tutorialTexts = Main.GetInstance().TutorialTexts;
				foreach (TutorialText val in tutorialTexts)
				{
					if (!__instance.m_texts.Contains(val))
					{
						Main.LogMessage("Adding tutorial " + val.m_name);
						__instance.m_texts.Add(val);
					}
				}
			}
		}
	}
}
namespace EnvironmentalAwareness.Data
{
	[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(0)]
	[<5c9fabdd-05fb-43b2-a213-2116a2b67436>NullableContext(2)]
	public class ConfigManager
	{
		public static ConfigSync configSync;

		public static ConfigEntry<bool> DebugLogging;

		public static ConfigEntry<bool> VitalityEnabled;

		public static ConfigEntry<bool> EnergyEnabled;

		public static ConfigEntry<bool> HungerEnabled;

		public static ConfigEntry<float> NewPlayerCooldown;

		public static ConfigEntry<bool> DeathGrantsImmunity;

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(new byte[] { 2, 1 })]
		public static ConfigEntry<string> GlobalKeySpring;

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(new byte[] { 2, 1 })]
		public static ConfigEntry<string> GlobalKeySummer;

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(new byte[] { 2, 1 })]
		public static ConfigEntry<string> GlobalKeyFall;

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(new byte[] { 2, 1 })]
		public static ConfigEntry<string> GlobalKeyWinter;

		public static ConfigEntry<float> VColdAdd;

		public static ConfigEntry<float> VFreezingAdd;

		public static ConfigEntry<float> VWetAdd;

		public static ConfigEntry<float> VColdWetMultiplier;

		public static ConfigEntry<float> VFreezingWetMultiplier;

		public static ConfigEntry<float> VHungerAdd;

		public static ConfigEntry<float> VHPDamageAdd;

		public static ConfigEntry<float> VPoisonDamageAdd;

		public static ConfigEntry<float> VBurningDamageAdd;

		public static ConfigEntry<float> VShockDamageAdd;

		public static ConfigEntry<float> VFrostDamageAdd;

		public static ConfigEntry<float> VAshlandsPassiveAdd;

		public static ConfigEntry<float> VDeepNorthPassiveAdd;

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(new byte[] { 2, 1 })]
		public static ConfigEntry<string> VEnvironmentsToIgnore;

		public static ConfigEntry<float> VSpringSeasonalMultiplier;

		public static ConfigEntry<float> VSummerSeasonalMultiplier;

		public static ConfigEntry<float> VFallSeasonalMultiplier;

		public static ConfigEntry<float> VWinterSeasonalMultiplier;

		public static ConfigEntry<float> VHeatRemove;

		public static ConfigEntry<float> VShelteredRemove;

		public static ConfigEntry<float> VHeatShelteredMultiplier;

		public static ConfigEntry<float> VRestingRemove;

		public static ConfigEntry<float> VRestedRemove;

		public static ConfigEntry<float> VPassiveRemove;

		public static ConfigEntry<float> VHealthPotionRemove;

		public static ConfigEntry<float> VResistancePerArmorPoint;

		public static ConfigEntry<int> VResistanceMinArmorThreshold;

		public static ConfigEntry<float> VPoisonResistantMultiplier;

		public static ConfigEntry<float> VPoisonVeryResistantMultiplier;

		public static ConfigEntry<float> VFireResistantMultiplier;

		public static ConfigEntry<float> VFireVeryResistantMultiplier;

		public static ConfigEntry<float> VLightningResistantMultiplier;

		public static ConfigEntry<float> VLightningVeryResistantMultiplier;

		public static ConfigEntry<float> VFrostResistantMultiplier;

		public static ConfigEntry<float> VFrostVeryResistantMultiplier;

		public static ConfigEntry<float> VMultiplierPer10FoodValue;

		public static ConfigEntry<bool> VHealthDamageEnabled;

		public static ConfigEntry<float> VHealthMaxDamageOverTime;

		public static ConfigEntry<float> VHealthMaxRegenReduction;

		public static ConfigEntry<float> VHealthDamageMinStartThreshold;

		public static ConfigEntry<bool> VMoveSpeedReductionEnabled;

		public static ConfigEntry<float> VMoveSpeedMaxReduction;

		public static ConfigEntry<float> VMoveSpeedMinStartThreshold;

		public static ConfigEntry<bool> VStaminaRegenReductionEnabled;

		public static ConfigEntry<float> VStaminaRegenMaxReduction;

		public static ConfigEntry<float> VStaminaRegenReductionThreshold;

		public static ConfigEntry<bool> VFoodBurnRateEnabled;

		public static ConfigEntry<float> VFoodBurnMaxOverTime;

		public static ConfigEntry<float> VFoodBurnMinStartThreshold;

		public static ConfigEntry<bool> VFoodBurnStatReduction;

		public static ConfigEntry<bool> VPhysicalWeaknessEnabled;

		public static ConfigEntry<float> VPhysicalWeaknessThreshold;

		public static ConfigEntry<bool> VElementalWeaknessEnabled;

		public static ConfigEntry<float> VElementalWeaknessThreshold;

		public static ConfigEntry<float> ELossStaminaPointUsedAdd;

		public static ConfigEntry<float> ELossMotionAdd;

		public static ConfigEntry<float> ELossHungryAdd;

		public static ConfigEntry<float> ELossColdAdd;

		public static ConfigEntry<float> ELossFreezingAdd;

		public static ConfigEntry<float> ELossWetAdd;

		public static ConfigEntry<float> ELossHeavyLoadAdd;

		public static ConfigEntry<float> ELossHeavyLoadThreshold;

		public static ConfigEntry<float> ELossNoRestMultiplier;

		public static ConfigEntry<float> ELossNoRestThreshold;

		public static ConfigEntry<float> ESpringSeasonMultiplier;

		public static ConfigEntry<float> ESummerSeasonMultiplier;

		public static ConfigEntry<float> EFallSeasonMultiplier;

		public static ConfigEntry<float> EWinterSeasonMultiplier;

		public static ConfigEntry<float> ELossSittingRemove;

		public static ConfigEntry<float> ELossRestingRemove;

		public static ConfigEntry<float> ELossSittingRestingMultiplier;

		public static ConfigEntry<float> ELossSittingRestingShelterMultiplier;

		public static ConfigEntry<float> ELossRestedRemove;

		public static ConfigEntry<float> ELossPercentageSleepRemove;

		public static ConfigEntry<float> ELossFoodStaminaRemove;

		public static ConfigEntry<float> ELossStaminaMeadRemove;

		public static ConfigEntry<float> ELossRestedResist;

		public static ConfigEntry<float> ELossStaminaMeadResist;

		public static ConfigEntry<float> ELossLowEnergyResist;

		public static ConfigEntry<float> ELossLowEnergyThreshold;

		public static ConfigEntry<bool> EDamageReductionEnabled;

		public static ConfigEntry<float> EDamageMaxReduction;

		public static ConfigEntry<float> EDamageReductionThreshold;

		public static ConfigEntry<bool> ESkillGainReductionEnabled;

		public static ConfigEntry<float> ESkillGainMaxReduction;

		public static ConfigEntry<float> ESkillGainReductionThreshold;

		public static ConfigEntry<bool> ESkillLevelReductionEnabled;

		public static ConfigEntry<float> ESkillLevelMaxReduction;

		public static ConfigEntry<float> ESkillLevelReductionThreshold;

		public static ConfigEntry<bool> EStaminaRegenEnabled;

		public static ConfigEntry<float> EStaminaRegenMaxReduction;

		public static ConfigEntry<float> EStaminaRegenMinThreshold;

		public static ConfigEntry<bool> EStaminaRegenDelayEnabled;

		public static ConfigEntry<float> EStaminaRegenDelayMaxMultiplier;

		public static ConfigEntry<float> EStaminaRegenDelayMinThreshold;

		public static ConfigEntry<bool> EMoveSpeedReductionEnabled;

		public static ConfigEntry<float> EMoveSpeedMaxReduction;

		public static ConfigEntry<float> EMoveSpeedReductionMinThreshold;

		public static ConfigEntry<bool> ERestedLossEnabled;

		public static ConfigEntry<float> ERestedLossThreshold;

		public static ConfigEntry<float> ResistanceSkillEffectFactor;

		public static ConfigEntry<float> ResistanceSkillGainMinThreshold;

		public static ConfigEntry<float> ResistanceSkillGainFactor;

		public static ConfigEntry<float> FitnessSkillEffectFactor;

		public static ConfigEntry<float> FitnessSkillGainFactor;

		public static ConfigEntry<float> FitnessSkillMaxEnergyGain;

		public static ConfigEntry<bool> DisplayVitalityPercentage;

		public static ConfigEntry<bool> DisplayVitalityWarningTexts;

		public static ConfigEntry<bool> DisplayEnergyPercentage;

		public static ConfigEntry<bool> DisplayEnergyWarningText;

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(new byte[] { 2, 1 })]
		public static List<string> VIgnoredEnvironments;

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(1)]
		public static readonly string ZerA = "0a. General";

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(1)]
		public static readonly string ZerB = "0b. Season Mod Integration";

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(1)]
		public static readonly string OneA = "1a. Vitality Loss";

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(1)]
		public static readonly string OneB = "1b. Vitality Recovery";

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(1)]
		public static readonly string OneC = "1c. Resistances to Vitality Loss";

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(1)]
		public static readonly string OneD = "1d. Vitality Effects";

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(1)]
		public static readonly string TwoA = "2a. Energy Loss";

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(1)]
		public static readonly string TwoB = "2b. Energy Recovery";

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(1)]
		public static readonly string TwoC = "2c. Resistance to Energy Loss";

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(1)]
		public static readonly string TwoD = "2d. Energy Effects";

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(1)]
		public static readonly string ThrA = "3a. Skill: Resistance";

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(1)]
		public static readonly string ThrB = "3b. Skill: Fitness";

		[<6a8b7a34-9f83-49d3-8366-65e14226f50e>Nullable(1)]
		public static readonly string Four = "4. UI and Display";

		[<5c9fabdd-05fb-43b2-a213-2116a2b67436>NullableContext(1)]
		public static void CreateConfigValues(BaseUnityPlugin plugin)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Expected O, but got Unknown
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Expected O, but got Unknown
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Expected O, but got Unknown
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Expected O, but got Unknown
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Expected O, but got Unknown
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Expected O, but got Unknown
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Expected O, but got Unknown
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Expected O, but got Unknown
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Expected O, but got Unknown
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Expected O, but got Unknown
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Expected O, but got Unknown
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Expected O, but got Unknown
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0387: Expected O, but got Unknown
			//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c5: Expected O, but got Unknown
			//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0403: Expected O, but got Unknown
			//IL_0436: Unknown result type (might be due to invalid IL or missing references)
			//IL_0441: Expected O, but got Unknown
			//IL_0474: Unknown result type (might be due to invalid IL or missing references)
			//IL_047f: Expected O, but got Unknown
			//IL_04b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bd: Expected O, but got Unknown
			//IL_04f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fb: Expected O, but got Unknown
			//IL_052e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0539: Expected O, but got Unknown
			//IL_055e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0569: Expected O, but got Unknown
			//IL_05c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cb: Expected O, but got Unknown
			//IL_05fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0609: Expected O, but got Unknown
			//IL_063c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0647: Expected O, but got Unknown
			//IL_067a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0685: Expected O, but got Unknown
			//IL_06b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c3: Expected O, but got Unknown
			//IL_06f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0701: Expected O, but got Unknown
			//IL_0734: Unknown result type (might be due to invalid IL or missing references)
			//IL_073f: Expected O, but got Unknown
			//IL_0772: Unknown result type (might be due to invalid IL or missing references)
			//IL_077d: Expected O, but got Unknown
			//IL_07b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_07bb: Expected O, but got Unknown
			//IL_07ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f9: Expected O, but got Unknown
			//IL_082c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0837: Expected O, but got Unknown
			//IL_086a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0875: Expected O, but got Unknown
			//IL_08a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ac: Expected O, but got Unknown
			//IL_08df: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ea: Expected O, but got Unknown
			//IL_091d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0928: Expected O, but got Unknown
			//IL_095b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0966: Expected O, but got Unknown
			//IL_0999: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a4: Expected O, but got Unknown
			//IL_09d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e2: Expected O, but got Unknown
			//IL_0a15: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a20: Expected O, but got Unknown
			//IL_0a53: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a5e: Expected O, but got Unknown
			//IL_0a91: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a9c: Expected O, but got Unknown
			//IL_0acf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ada: Expected O, but got Unknown
			//IL_0afb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b06: Expected O, but got Unknown
			//IL_0b39: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b44: Expected O, but got Unknown
			//IL_0b77: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b82: Expected O, but got Unknown
			//IL_0bb5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bc0: Expected O, but got Unknown
			//IL_0be1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bec: Expected O, but got Unknown
			//IL_0c1f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c2a: Expected O, but got Unknown
			//IL_0c5d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c68: Expected O, but got Unknown
			//IL_0c89: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c94: Expected O, but got Unknown
			//IL_0cc7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cd2: Expected O, but got Unknown
			//IL_0d05: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d10: Expected O, but got Unknown
			//IL_0d31: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d3c: Expected O, but got Unknown
			//IL_0d6f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d7a: Expected O, but got Unknown
			//IL_0dad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0db8: Expected O, but got Unknown
			//IL_0dd9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0de4: Expected O, but got Unknown
			//IL_0e05: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e10: Expected O, but got Unknown
			//IL_0e43: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e4e: Expected O, but got Unknown
			//IL_0e6f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e7a: Expected O, but got Unknown
			//IL_0ead: Unknown result type (might be due to invalid IL or missing references)
			//IL_0eb8: Expected O, but got Unknown
			//IL_0eeb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ef6: Expected O, but got Unknown
			//IL_0f29: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f34: Expected O, but got Unknown
			//IL_0f67: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f72: Expected O, but got Unknown
			//IL_0fa5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fb0: Expected O, but got Unknown
			//IL_0fe3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fee: Expected O, but got Unknown
			//IL_1021: Unknown result type (might be due to invalid IL or missing references)
			//IL_102c: Expected O, but got Unknown
			//IL_105f: Unknown result type (might be due to invalid IL or missing references)
			//IL_106a: Expected O, but got Unknown
			//IL_109d: Unknown result type (might be due to invalid IL or missing references)
			//IL_10a8: Expected O, but got Unknown
			//IL_10db: Unknown result type (might be due to invalid IL or missing references)
			//IL_10e6: Expected O, but got Unknown
			//IL_1119: Unknown result type (might be due to invalid IL or missing references)
			//IL_1124: Expected O, but got Unknown
			//IL_1157: Unknown result type (might be due to invalid IL or missing references)
			//IL_1162: Expected O, but got Unknown
			//IL_1195: Unknown result type (might be due to invalid IL or missing references)
			//IL_11a0: Expected O, but got Unknown
			//IL_11d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_11de: Expected O, but got Unknown
			//IL_1211: Unknown result type (might be due to invalid IL or missing references)
			//IL_121c: Expected O, but got Unknown
			//IL_124f: Unknown result type (might be due to invalid IL or missing references)
			//IL_125a: Expected O, but got Unknown
			//IL_128d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1298: Expected O, but got Unknown
			//IL_12cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_12d6: Expected O, but got Unknown
			//IL_1309: Unknown result type (might be due to invalid IL or missing references)
			//IL_1314: Expected O, but got Unknown
			//IL_1347: Unknown result type (might be due to invalid IL or missing references)
			//IL_1352: Expected O, but got Unknown
			//IL_1385: Unknown result type (might be due to invalid IL or missing references)
			//IL_1390: Expected O, but got Unknown
			//IL_13c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_13ce: Expected O, but got Unknown
			//IL_1401: Unknown result type (might be due to invalid IL or missing references)
			//IL_140c: Expected O, but got Unknown
			//IL_143f: Unknown result type (might be due to invalid IL or missing references)
			//IL_144a: Expected O, but got Unknown
			//IL_147d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1488: Expected O, but got Unknown
			//IL_14bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_14c6: Expected O, but got Unknown
			//IL_14f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_1504: Expected O, but got Unknown
			//IL_1525: Unknown result type (might be due to invalid IL or missing references)
			//IL_1530: Expected O, but got Unknown
			//IL_1563: Unknown result type (might be due to invalid IL or missing references)
			//IL_156e: Expected O, but got Unknown
			//IL_15a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_15ac: Expected O, but got Unknown
			//IL_15cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_15d8: Expected O, but got Unknown
			//IL_160b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1616: Expected O, but got Unknown
			//IL_1649: Unknown result type (might be due to invalid IL or missing references)
			//IL_1654: Expected O, but got Unknown
			//IL_1675: Unknown result type (might be due to invalid IL or missing references)
			//IL_1680: Expected O, but got Unknown
			//IL_16b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_16be: Expected O, but got Unknown
			//IL_16f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_16fc: Expected O, but got Unknown
			//IL_171d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1728: Expected O, but got Unknown
			//IL_175b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1766: Expected O, but got Unknown
			//IL_1799: Unknown result type (might be due to invalid IL or missing references)
			//IL_17a4: Expected O, but got Unknown
			//IL_17c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_17d0: Expected O, but got Unknown
			//IL_1803: Unknown result type (might be due to invalid IL or missing references)
			//IL_180e: Expected O, but got Unknown
			//IL_1841: Unknown result type (might be due to invalid IL or missing references)
			//IL_184c: Expected O, but got Unknown
			//IL_186d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1878: Expected O, but got Unknown
			//IL_18ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_18b6: Expected O, but got Unknown
			//IL_18e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_18f4: Expected O, but got Unknown
			//IL_1915: Unknown result type (might be due to invalid IL or missing references)
			//IL_1920: Expected O, but got Unknown
			//IL_1953: Unknown result type (might be due to invalid IL or missing references)
			//IL_195e: Expected O, but got Unknown
			//IL_1991: Unknown result type (might be due to invalid IL or missing references)
			//IL_199c: Expected O, but got Unknown
			//IL_19cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_19da: Expected O, but got Unknown
			//IL_1a0d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a18: Expected O, but got Unknown
			//IL_1a4b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a56: Expected O, but got Unknown
			//IL_1a89: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a94: Expected O, but got Unknown
			//IL_1ac7: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ad2: Expected O, but got Unknown
			//IL_1af3: Unknown result type (might be due to invalid IL or missing references)
			//IL_1afe: Expected O, but got Unknown
			//IL_1b1f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b2a: Expected O, but got Unknown
			//IL_1b4b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b56: Expected O, but got Unknown
			//IL_1b77: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b82: Expected O, but got Unknown
			configSync = new ConfigSync("maxfoxgaming.environmentalawareness")
			{
				DisplayName = "EnvironmentalAwareness",
				CurrentVersion = "1.0.4",
				MinimumRequiredVersion = "1.0.4"
			};
			plugin.Config.SaveOnConfigSet = true;
			DebugLogging = plugin.Config.BindServer(ZerA, "Logs Enabled", value: false, new ConfigDescription("Whether the mod should print outputs and data to the console. Only needed for debugging.", (AcceptableValueBase)null, Array.Empty<object>()));
			VitalityEnabled = plugin.Config.BindServer(ZerA, "Vitality & Resistance Enabled", value: true, new ConfigDescription("If enabled, the player will have the Vitality status effect which reacts to their environment, and a Resistance skill that allows them to whithstand drops in vitality as it levels up.", (AcceptableValueBase)null, Array.Empty<object>()));
			EnergyEnabled = plugin.Config.BindServer(ZerA, "Energy & Fitness Enabled", value: true, new ConfigDescription("If enabled, the player will have the Energy status effect which reacts to their physical activities, and a Fitness skill that allows them to whithstand drops in energy as it levels up.", (AcceptableValueBase)null, Array.Empty<object>()));
			HungerEnabled = plugin.Config.BindServer(ZerA, "Hunger Enabled", value: true, new ConfigDescription("If enabled, the player will get a Hungry status effect when they have no food. This status effect is purely for display purposes, to help alert the player to eat when needed.", (AcceptableValueBase)null, Array.Empty<object>()));
			NewPlayerCooldown = plugin.Config.BindServer(ZerA, "New Player Immunity", 300f, new ConfigDescription("New characters who have not picked up items will spawn in with an immunity to energy and vitality loss. The immunity will wear off after this amount of time.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1200f), Array.Empty<object>()));
			DeathGrantsImmunity = plugin.Config.BindServer(ZerA, "Death Grants Immunity", value: true, new ConfigDescription("If the player has died, effects of vitality and energy loss will not start until the player's No Skill Drain buff ends.", (AcceptableValueBase)null, Array.Empty<object>()));
			GlobalKeySpring = plugin.Config.BindServer(ZerB, "Global Key for Spring", "season_spring", new ConfigDescription("If a seasons mod is installed such as Seasonality or Seasons, what global key is used to represent Spring. Note that for Shudnal's Seasons mod, you must turn on seasonal global keys. It is on by default in Seasonality.", (AcceptableValueBase)null, Array.Empty<object>()));
			GlobalKeySummer = plugin.Config.BindServer(ZerB, "Global Key for Summer", "season_summer", new ConfigDescription("If a seasons mod is installed such as Seasonality or Seasons, what global key is used to represent Summer. Note that for Shudnal's Seasons mod, you must turn on seasonal global keys. It is on by default in Seasonality.", (AcceptableValueBase)null, Array.Empty<object>()));
			GlobalKeyFall = plugin.Config.BindServer(ZerB, "Global Key for Fall", "season_fall", new ConfigDescription("If a seasons mod is installed such as Seasonality or Seasons, what global key is used to represent Fall. Note that for Shudnal's Seasons mod, you must turn on seasonal global keys. It is on by default in Seasonality.", (AcceptableValueBase)null, Array.Empty<object>()));
			GlobalKeyWinter = plugin.Config.BindServer(ZerB, "Global Key for Winter", "season_winter", new ConfigDescription("If a seasons mod is installed such as Seasonality or Seasons, what global key is used to represent Winter. Note that for Shudnal's Seasons mod, you must turn on seasonal global keys. It is on by default in Seasonality.", (AcceptableValueBase)null, Array.Empty<object>()));
			VColdAdd = plugin.Config.BindServer(OneA, "Vitality Loss when Cold", 0.045f, new ConfigDescription("How much vitality is lost when the environment is cold.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			VFreezingAdd = plugin.Config.BindServer(OneA, "Vitality Loss when Freezing", 0.155f, new ConfigDescription("How much vitality is lost when the environment is freezing.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			VWetAdd = plugin.Config.BindServer(OneA, "Vitality Loss when Wet", 0.035f, new ConfigDescription("How much vitality is lost when the player is wet.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			VColdWetMultiplier = plugin.Config.BindServer(OneA, "Wet and Cold Multiplier", 1.25f, new ConfigDescription("If the player is both wet and the environment is cold, vitality loss gets multiplied by this amount after resistances. A value of 1 does nothing.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), Array.Empty<object>()));
			VFreezingWetMultiplier = plugin.Config.BindServer(OneA, "Wet and Freezing Multiplier", 1.55f, new ConfigDescription("If the player is both wet and the environment is freezing, vitality loss gets multiplied by this amount after resistances. A value of 1 does nothing.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), Array.Empty<object>()));
			VHungerAdd = plugin.Config.BindServer(OneA, "Vitality Loss when Hungry", 0.25f, new ConfigDescription("If the player has not eaten and has no food slots filled, this value will be added to the vitality loss, bypassing all resistances. A value of 0 disables this feature.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			VHPDamageAdd = plugin.Config.BindServer(OneA, "Vitality Loss per HP of Damage", 0.005f, new ConfigDescription("How much vitality is lost per health point of damage sustained by the player. This number is VERY sensitive. A value of 0 disables this feature.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 0.1f), Array.Empty<object>()));
			VPoisonDamageAdd = plugin.Config.BindServer(OneA, "Vitality Loss from Poison", 0.24f, new ConfigDescription("How much vitality is lost when the player is poisoned. Affected by poison resistance. A value of 0 disables this feature.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			VBurningDamageAdd = plugin.Config.BindServer(OneA, "Vitality Loss from Burning", 0.2f, new ConfigDescription("How much vitality is lost when the player is on fire. Affected by fire resistance. A value of 0 disables this feature.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			VFrostDamageAdd = plugin.Config.BindServer(OneA, "Vitality Loss from Frozen", 0.15f, new ConfigDescription("How much vitality is lost when the player is frozen. Affected by frost resistance. A value of 0 disables this feature.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			VShockDamageAdd = plugin.Config.BindServer(OneA, "Vitality loss from Shocked", 0.3f, new ConfigDescription("How much vitality is lost when the player is shocked. Affected by lightning resistance. A value of 0 disables this feature.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			VAshlandsPassiveAdd = plugin.Config.BindServer(OneA, "Vitality Loss from being in Ashlands", 0.2f, new ConfigDescription("How much vitality is lost when the player is in the Ashlands. A value of 0 disables this effect..", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			VDeepNorthPassiveAdd = plugin.Config.BindServer(OneA, "Vitality Loss from being in Deep North", 0.2f, new ConfigDescription("How much vitality is lost when the player is in the Deep North. A value of 0 disables this effect.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			VEnvironmentsToIgnore = plugin.Config.BindServer(OneA, "Environments that Bypass Vitality Loss", "Eikthyr,GDKing,Bonemass,Moder,GoblinKing", new ConfigDescription("A comma separated list of environments that will not affect the player's vitality negatively.", (AcceptableValueBase)null, Array.Empty<object>()));
			VIgnoredEnvironments = new List<string>(VEnvironmentsToIgnore.Value.Split(new char[1] { ',' }));
			VSpringSeasonalMultiplier = plugin.Config.BindServer(OneA, "Multiplier to Vitality Loss during Spring", 0.95f, new ConfigDescription("If a seasons mod is installed, this number is multiplied by the final vitality loss during Spring. A value of 0 means no vitality will be lost in spring. A value of 1 disables this feature.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>()));
			VSummerSeasonalMultiplier = plugin.Config.BindServer(OneA, "Multiplier to Vitality Loss during Summer", 0.75f, new ConfigDescription("If a seasons mod is installed, this number is multiplied by the final vitality loss during Summer. A value of 0 means no vitality will be lost in summer. A value of 1 disables this feature.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>()));
			VFallSeasonalMultiplier = plugin.Config.BindServer(OneA, "Multiplier to Vitality Loss during Fall", 1.15f, new ConfigDescription("If a seasons mod is installed, this number is multiplied by the final vitality loss during Fall. A value of 0 means no vitality will be lost in fall. A value of 1 disables this feature.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>()));
			VWinterSeasonalMultiplier = plugin.Config.BindServer(OneA, "Multiplier to Vitality Loss during Winter", 1.45f, new ConfigDescription("If a seasons mod is installed, this number is multiplied by the final vitality loss during Winter. A value of 0 means no vitality will be lost in winter. A value of 1 disables this feature.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>()));
			VHeatRemove = plugin.Config.BindServer(OneB, "Vitality Recovered when Warm", 0.25f, new ConfigDescription("How much vitality is recovered when the player is by a fire or warm.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			VShelteredRemove = plugin.Config.BindServer(OneB, "Vitality Recovered when Sheltered", 0.25f, new ConfigDescription("How much vitality is recovered when the player is sheltered.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			VHeatShelteredMultiplier = plugin.Config.BindServer(OneB, "Warm and Sheltered Multiplier", 1.25f, new ConfigDescription("If the player is both warm and sheltered, multiplies how much vitality is recovered from heat and shelter. A value of 1 does nothing.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), Array.Empty<object>()));
			VRestingRemove = plugin.Config.BindServer(OneB, "Vitality Recovered when Resting", 0.1f, new ConfigDescription("How much vitality is recovered when the player is resting.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			VRestedRemove = plugin.Config.BindServer(OneB, "Vitality Recovered when Rested", 0.005f, new ConfigDescription("How much vitality is recovered while the player has Rested.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			VPassiveRemove = plugin.Config.BindServer(OneB, "Passive Vitality Recovery", 0.005f, new ConfigDescription("How much vitality is recovered passively when the player is not in unfavourable conditions.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			VHealthPotionRemove = plugin.Config.BindServer(OneB, "Vitality Recovered from Health Meads", 0.1f, new ConfigDescription("How much vitality is recovered per second while a health potion is active. A value of 0 disables this feature.", (AcceptableValueBase)(object)new Accept