Decompiled source of Venture World Scaling v0.3.0

Plugins/VentureValheim.Scaling.dll

Decompiled 7 months 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.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.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;
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: Guid("DA7A94D9-DD8B-4C13-A7BF-44178396D6DF")]
[assembly: ComVisible(false)]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCopyright("Copyright ©  2022")]
[assembly: AssemblyProduct("VentureValheim.Scaling")]
[assembly: AssemblyCompany("")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyTitle("VentureValheim.Scaling")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: AssemblyFileVersion("0.3.0")]
[assembly: AssemblyConfiguration("")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.3.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[<4fbbcef8-8d74-42eb-9a62-1e2a55be03f6>Embedded]
	internal sealed class <4fbbcef8-8d74-42eb-9a62-1e2a55be03f6>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)]
	[<4fbbcef8-8d74-42eb-9a62-1e2a55be03f6>Embedded]
	internal sealed class <9eed9c0a-9fd3-449f-9769-233bc050d602>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <9eed9c0a-9fd3-449f-9769-233bc050d602>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <9eed9c0a-9fd3-449f-9769-233bc050d602>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	[<4fbbcef8-8d74-42eb-9a62-1e2a55be03f6>Embedded]
	[CompilerGenerated]
	internal sealed class <b9fea6d5-68cd-496d-aaa1-f4835254cf4a>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <b9fea6d5-68cd-496d-aaa1-f4835254cf4a>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace VentureValheim.Scaling
{
	[BepInPlugin("com.orianaventure.mod.WorldScaling", "WorldScaling", "0.3.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[<9eed9c0a-9fd3-449f-9769-233bc050d602>Nullable(0)]
	[<b9fea6d5-68cd-496d-aaa1-f4835254cf4a>NullableContext(1)]
	public class ScalingPlugin : BaseUnityPlugin
	{
		private static readonly ScalingPlugin _instance;

		private const string ModName = "WorldScaling";

		private const string ModVersion = "0.3.0";

		private const string Author = "com.orianaventure.mod";

		private const string ModGUID = "com.orianaventure.mod.WorldScaling";

		private static string ConfigFileName;

		private static string ConfigFileFullPath;

		private readonly Harmony HarmonyInstance = new Harmony("com.orianaventure.mod.WorldScaling");

		public static readonly ManualLogSource VentureScalingLogger;

		public static ConfigEntry<bool> CE_GenerateGameData;

		public static ConfigEntry<string> CE_AutoScaleType;

		public static ConfigEntry<float> CE_AutoScaleFactor;

		public static ConfigEntry<bool> CE_AutoScaleIgnoreOverrides;

		public static ConfigEntry<bool> CE_AutoScaleCreatures;

		public static ConfigEntry<string> CE_AutoScaleCreatureHealth;

		public static ConfigEntry<string> CE_AutoScaleCreatureDamage;

		public static ConfigEntry<bool> CE_AutoScaleItems;

		private readonly ConfigurationManagerAttributes AdminConfig = new ConfigurationManagerAttributes
		{
			IsAdminOnly = true
		};

		private readonly ConfigurationManagerAttributes ClientConfig = new ConfigurationManagerAttributes
		{
			IsAdminOnly = false
		};

		private DateTime _lastReloadTime;

		private const long RELOAD_DELAY = 10000000L;

		public static ScalingPlugin Instance => _instance;

		static ScalingPlugin()
		{
			_instance = new ScalingPlugin();
			ConfigFileName = "com.orianaventure.mod.WorldScaling.cfg";
			string configPath = Paths.ConfigPath;
			char directorySeparatorChar = Path.DirectorySeparatorChar;
			ConfigFileFullPath = configPath + directorySeparatorChar + ConfigFileName;
			VentureScalingLogger = Logger.CreateLogSource("WorldScaling");
			CE_GenerateGameData = null;
			CE_AutoScaleType = null;
			CE_AutoScaleFactor = null;
			CE_AutoScaleIgnoreOverrides = null;
			CE_AutoScaleCreatures = null;
			CE_AutoScaleCreatureHealth = null;
			CE_AutoScaleCreatureDamage = null;
			CE_AutoScaleItems = null;
		}

		private ScalingPlugin()
		{
		}//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Expected O, but got Unknown
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Expected O, but got Unknown
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Expected O, but got Unknown


		private void AddConfig<[<9eed9c0a-9fd3-449f-9769-233bc050d602>Nullable(2)] T>(string key, string section, string description, bool synced, T value, ref ConfigEntry<T> configEntry)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			string extendedDescription = GetExtendedDescription(description, synced);
			configEntry = ((BaseUnityPlugin)this).Config.Bind<T>(section, key, value, new ConfigDescription(extendedDescription, (AcceptableValueBase)null, new object[1] { synced ? AdminConfig : ClientConfig }));
		}

		public string GetExtendedDescription(string description, bool synchronizedSetting)
		{
			return description + (synchronizedSetting ? " [Synced with Server]" : " [Not Synced with Server]");
		}

		public void Awake()
		{
			AddConfig("GenerateGameDataFiles", "General", "Finds all items and creatures and creates data files in your config path for viewing only (boolean).", synced: false, value: false, ref CE_GenerateGameData);
			AddConfig("AutoScaleType", "General", "Auto-scaling type: Vanilla, Linear, Exponential, or Custom (string).", synced: true, "Linear", ref CE_AutoScaleType);
			AddConfig("AutoScaleFactor", "General", "Auto-scaling factor used for the Auto-scaling type algorithm (float).", synced: true, 0.75f, ref CE_AutoScaleFactor);
			AddConfig("AutoScaleIgnoreOverrides", "General", "When true ignores the overrides specified in the yaml files (boolean).", synced: true, value: false, ref CE_AutoScaleIgnoreOverrides);
			AddConfig("ScaleCreatures", "Creatures", "Enable the scaling of creatures (boolean).", synced: true, value: true, ref CE_AutoScaleCreatures);
			AddConfig("CreaturesHealth", "Creatures", "Override the Base Health distribution for Creatures (comma-separated list of 6 integers) (string).", synced: true, "", ref CE_AutoScaleCreatureHealth);
			AddConfig("CreaturesDamage", "Creatures", "Override the Base Damage distribution for Creatures (comma-separated list of 6 integers) (string).", synced: true, "", ref CE_AutoScaleCreatureDamage);
			AddConfig("AutoScaleItems", "Items", "Enable the scaling of Items (boolean).", synced: true, value: true, ref CE_AutoScaleItems);
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			HarmonyInstance.PatchAll(executingAssembly);
			SetupWatcher();
		}

		private void OnDestroy()
		{
			((BaseUnityPlugin)this).Config.Save();
		}

		private void SetupWatcher()
		{
			_lastReloadTime = DateTime.Now;
			FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, ConfigFileName);
			fileSystemWatcher.Changed += ReadConfigValues;
			fileSystemWatcher.Created += ReadConfigValues;
			fileSystemWatcher.Renamed += ReadConfigValues;
			fileSystemWatcher.IncludeSubdirectories = true;
			fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject;
			fileSystemWatcher.EnableRaisingEvents = true;
		}

		private void ReadConfigValues(object sender, FileSystemEventArgs e)
		{
			DateTime now = DateTime.Now;
			long num = now.Ticks - _lastReloadTime.Ticks;
			if (File.Exists(ConfigFileFullPath) && num >= 10000000)
			{
				try
				{
					VentureScalingLogger.LogInfo((object)"Attempting to reload configuration...");
					((BaseUnityPlugin)this).Config.Reload();
				}
				catch
				{
					VentureScalingLogger.LogError((object)("There was an issue loading " + ConfigFileName));
					return;
				}
				_lastReloadTime = now;
				WorldConfiguration.Instance.SetupScaling();
			}
		}
	}
	[<b9fea6d5-68cd-496d-aaa1-f4835254cf4a>NullableContext(1)]
	public interface IScalingConfiguration
	{
		bool GetGenerateGameData();

		string GetAutoScaleType();

		float GetAutoScaleFactor();

		bool GetAutoScaleIgnoreOverrides();

		bool GetAutoScaleCreatures();

		string GetAutoScaleCreatureHealth();

		string GetAutoScaleCreatureDamage();

		bool GetAutoScaleItems();
	}
	[<b9fea6d5-68cd-496d-aaa1-f4835254cf4a>NullableContext(1)]
	[<9eed9c0a-9fd3-449f-9769-233bc050d602>Nullable(0)]
	public class ScalingConfiguration : IScalingConfiguration
	{
		private static IScalingConfiguration _instance;

		public static IScalingConfiguration Instance => _instance;

		static ScalingConfiguration()
		{
			_instance = new ScalingConfiguration();
		}

		public ScalingConfiguration()
		{
		}

		public ScalingConfiguration(IScalingConfiguration ScalingConfiguration)
		{
			_instance = ScalingConfiguration;
		}

		public bool GetGenerateGameData()
		{
			return ScalingPlugin.CE_GenerateGameData.Value;
		}

		public string GetAutoScaleType()
		{
			return ScalingPlugin.CE_AutoScaleType.Value;
		}

		public float GetAutoScaleFactor()
		{
			return ScalingPlugin.CE_AutoScaleFactor.Value;
		}

		public bool GetAutoScaleIgnoreOverrides()
		{
			return ScalingPlugin.CE_AutoScaleIgnoreOverrides.Value;
		}

		public bool GetAutoScaleCreatures()
		{
			return ScalingPlugin.CE_AutoScaleCreatures.Value;
		}

		public string GetAutoScaleCreatureHealth()
		{
			return ScalingPlugin.CE_AutoScaleCreatureHealth.Value;
		}

		public string GetAutoScaleCreatureDamage()
		{
			return ScalingPlugin.CE_AutoScaleCreatureDamage.Value;
		}

		public bool GetAutoScaleItems()
		{
			return ScalingPlugin.CE_AutoScaleItems.Value;
		}
	}
	[<b9fea6d5-68cd-496d-aaa1-f4835254cf4a>NullableContext(1)]
	[<9eed9c0a-9fd3-449f-9769-233bc050d602>Nullable(0)]
	public class CreatureClassification
	{
		public string Name { get; private set; }

		public WorldConfiguration.Biome BiomeType { get; private set; }

		public WorldConfiguration.Difficulty CreatureDifficulty { get; private set; }

		public Dictionary<string, DamageTypes> VanillaAttacks { get; private set; }

		public float? VanillaHealth { get; private set; }

		public bool Overridden { get; private set; }

		public Dictionary<string, CreatureOverrides.AttackOverride> OverrideAttacks { get; private set; }

		public float? OverrideHealth { get; private set; }

		public CreatureClassification(string name, WorldConfiguration.Biome? biomeType, WorldConfiguration.Difficulty? creatureDifficulty)
		{
			Reset();
			Name = name;
			if (biomeType.HasValue)
			{
				BiomeType = biomeType.Value;
			}
			if (creatureDifficulty.HasValue)
			{
				CreatureDifficulty = creatureDifficulty.Value;
			}
			VanillaHealth = null;
			VanillaAttacks = null;
		}

		public void Reset()
		{
			BiomeType = WorldConfiguration.Biome.Undefined;
			CreatureDifficulty = WorldConfiguration.Difficulty.Undefined;
			Overridden = false;
			OverrideHealth = null;
			OverrideAttacks = new Dictionary<string, CreatureOverrides.AttackOverride>();
		}

		public virtual bool IgnoreScaling()
		{
			if (WorldConfiguration.Instance.WorldScale == WorldConfiguration.Scaling.Vanilla || (WorldConfiguration.Instance.WorldScale == WorldConfiguration.Scaling.Custom && !Overridden) || CreatureDifficulty == WorldConfiguration.Difficulty.Vanilla)
			{
				return true;
			}
			return false;
		}

		public void UpdateCreature(WorldConfiguration.Biome? biomeType, WorldConfiguration.Difficulty? creatureDifficulty)
		{
			if (biomeType.HasValue)
			{
				BiomeType = biomeType.Value;
			}
			if (creatureDifficulty.HasValue)
			{
				CreatureDifficulty = creatureDifficulty.Value;
			}
		}

		public void OverrideCreature(CreatureOverrides.CreatureOverride creatureOverride)
		{
			Overridden = true;
			WorldConfiguration.Biome? biomeType = null;
			if (creatureOverride.biome.HasValue)
			{
				biomeType = (WorldConfiguration.Biome)creatureOverride.biome.Value;
			}
			WorldConfiguration.Difficulty? creatureDifficulty = null;
			if (creatureOverride.difficulty.HasValue)
			{
				creatureDifficulty = (WorldConfiguration.Difficulty)creatureOverride.difficulty.Value;
			}
			UpdateCreature(biomeType, creatureDifficulty);
			OverrideHealth = creatureOverride.health;
			OverrideAttacks = new Dictionary<string, CreatureOverrides.AttackOverride>();
			if (creatureOverride.attacks == null)
			{
				return;
			}
			foreach (CreatureOverrides.AttackOverride attack in creatureOverride.attacks)
			{
				if (!Utility.IsNullOrWhiteSpace(attack.name))
				{
					SetOverrideAttack(attack);
				}
			}
		}

		public void SetVanillaData(float health, List<GameObject> attacks)
		{
			SetVanillaHealth(health);
			SetVanillaAttacks(attacks);
		}

		private void SetVanillaAttacks(List<GameObject> attacks)
		{
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
			if (VanillaAttacks != null)
			{
				return;
			}
			VanillaAttacks = new Dictionary<string, DamageTypes>();
			if (attacks == null)
			{
				return;
			}
			for (int i = 0; i < attacks.Count; i++)
			{
				ItemDrop component = attacks[i].GetComponent<ItemDrop>();
				if ((Object)(object)component == (Object)null)
				{
					ScalingPlugin.VentureScalingLogger.LogWarning((object)("Attack " + ((Object)attacks[i]).name + " not added to creature " + Name + ". ItemDrop not found. Will not override."));
				}
				else if (!VanillaAttacks.ContainsKey(((Object)component).name))
				{
					DamageTypes damages = component.m_itemData.m_shared.m_damages;
					if (ItemConfiguration.Instance.GetTotalDamage(damages) > 0f)
					{
						VanillaAttacks.Add(((Object)component).name, damages);
						continue;
					}
					ScalingPlugin.VentureScalingLogger.LogDebug((object)("Attack for " + ((Object)attacks[i]).name + " not added to creature " + Name + ". Does 0 damage. Will not override."));
				}
			}
		}

		private void SetVanillaHealth(float health)
		{
			float? vanillaHealth = VanillaHealth;
			float valueOrDefault = vanillaHealth.GetValueOrDefault();
			if (!vanillaHealth.HasValue)
			{
				valueOrDefault = health;
				float? vanillaHealth2 = valueOrDefault;
				VanillaHealth = vanillaHealth2;
			}
		}

		public bool HealthOverridden()
		{
			return OverrideHealth.HasValue;
		}

		public float? GetHealth()
		{
			if (IgnoreScaling())
			{
				return VanillaHealth;
			}
			if (HealthOverridden())
			{
				return OverrideHealth;
			}
			float biomeScaling = WorldConfiguration.Instance.GetBiomeScaling(BiomeType);
			int baseHealth = CreatureConfiguration.Instance.GetBaseHealth(CreatureDifficulty);
			return ScalingAPI.PrettifyNumber(CreatureConfiguration.Instance.CalculateHealth(biomeScaling, baseHealth));
		}

		public DamageTypes? GetAttack(string name, float maxTotalDamage)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			if (Utility.IsNullOrWhiteSpace(name) || !VanillaAttacks.ContainsKey(name))
			{
				return null;
			}
			DamageTypes val = VanillaAttacks[name];
			if (IgnoreScaling())
			{
				return val;
			}
			if (AttackOverridden(name))
			{
				CreatureOverrides.AttackOverride attackOverride = OverrideAttacks[name];
				if (attackOverride.totalDamage.HasValue)
				{
					return ItemConfiguration.Instance.CalculateDamageTypesFinal(val, attackOverride.totalDamage.Value, 1f);
				}
				DamageTypes damageTypes = CreatureOverrides.GetDamageTypes(attackOverride);
				if (!attackOverride.pickaxe.HasValue)
				{
					damageTypes.m_pickaxe = val.m_pickaxe;
				}
				if (!attackOverride.chop.HasValue)
				{
					damageTypes.m_chop = val.m_chop;
				}
				return damageTypes;
			}
			int baseTotalDamage = CreatureConfiguration.Instance.GetBaseTotalDamage(CreatureDifficulty);
			WorldConfiguration.BiomeData biome = WorldConfiguration.Instance.GetBiome(BiomeType);
			if (biome != null)
			{
				return ItemConfiguration.Instance.CalculateCreatureDamageTypes(biome.ScaleValue, val, baseTotalDamage, maxTotalDamage);
			}
			return val;
		}

		public bool AttackOverridden(string name)
		{
			if (OverrideAttacks == null)
			{
				return false;
			}
			return OverrideAttacks.ContainsKey(name);
		}

		public DamageTypes? GetAttackOverride(string name)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			if (OverrideAttacks.ContainsKey(name))
			{
				return CreatureOverrides.GetDamageTypes(OverrideAttacks[name]);
			}
			return null;
		}

		public float? GetAttackOverrideTotal(string name)
		{
			if (OverrideAttacks.ContainsKey(name))
			{
				return OverrideAttacks[name].totalDamage;
			}
			return null;
		}

		private void SetOverrideAttack(CreatureOverrides.AttackOverride attack)
		{
			if (OverrideAttacks.ContainsKey(attack.name))
			{
				OverrideAttacks[attack.name] = attack;
			}
			else
			{
				OverrideAttacks.Add(attack.name, attack);
			}
		}
	}
	[<b9fea6d5-68cd-496d-aaa1-f4835254cf4a>NullableContext(1)]
	public interface ICreatureConfiguration
	{
		bool ContainsCreature(string key);

		void SetBaseHealth(int[] values);

		int GetBaseHealth(WorldConfiguration.Difficulty difficulty);

		void SetBaseDamage(int[] values);

		int GetBaseTotalDamage(WorldConfiguration.Difficulty difficulty);

		void AddCreatureConfiguration(string name, WorldConfiguration.Biome? biome, WorldConfiguration.Difficulty? difficulty);

		void UpdateCreatures();

		void VanillaReset();
	}
	[<b9fea6d5-68cd-496d-aaa1-f4835254cf4a>NullableContext(1)]
	[<9eed9c0a-9fd3-449f-9769-233bc050d602>Nullable(0)]
	public class CreatureConfiguration : ICreatureConfiguration
	{
		private static readonly CreatureConfiguration _instance;

		protected Dictionary<string, CreatureClassification> _creatureData = new Dictionary<string, CreatureClassification>();

		private int[] _baseHealth = new int[6] { 5, 10, 30, 50, 200, 500 };

		private int[] _baseDamage = new int[6] { 5, 15, 20, 25, 30, 30 };

		public static CreatureConfiguration Instance => _instance;

		static CreatureConfiguration()
		{
			_instance = new CreatureConfiguration();
		}

		protected CreatureConfiguration()
		{
		}

		public bool ContainsCreature(string key)
		{
			return _creatureData.ContainsKey(key);
		}

		public void SetBaseHealth(int[] values)
		{
			if (values != null && values.Length == 6)
			{
				_baseHealth = values;
			}
		}

		public int GetBaseHealth(WorldConfiguration.Difficulty difficulty)
		{
			return difficulty switch
			{
				WorldConfiguration.Difficulty.Harmless => _baseHealth[0], 
				WorldConfiguration.Difficulty.Novice => _baseHealth[1], 
				WorldConfiguration.Difficulty.Average => _baseHealth[2], 
				WorldConfiguration.Difficulty.Intermediate => _baseHealth[3], 
				WorldConfiguration.Difficulty.Expert => _baseHealth[4], 
				WorldConfiguration.Difficulty.Boss => _baseHealth[5], 
				_ => _baseHealth[2], 
			};
		}

		public int CalculateHealth(float scale, int baseHealth)
		{
			return (int)(scale * (float)baseHealth);
		}

		public void SetBaseDamage(int[] values)
		{
			if (values != null && values.Length == 6)
			{
				_baseDamage = values;
			}
		}

		public int GetBaseTotalDamage(WorldConfiguration.Difficulty difficulty)
		{
			return difficulty switch
			{
				WorldConfiguration.Difficulty.Harmless => _baseDamage[0], 
				WorldConfiguration.Difficulty.Novice => _baseDamage[1], 
				WorldConfiguration.Difficulty.Average => _baseDamage[2], 
				WorldConfiguration.Difficulty.Intermediate => _baseDamage[3], 
				WorldConfiguration.Difficulty.Expert => _baseDamage[4], 
				WorldConfiguration.Difficulty.Boss => _baseDamage[5], 
				_ => _baseDamage[2], 
			};
		}

		private void ConfigureAttacks(CreatureClassification cc)
		{
			if (cc.VanillaAttacks == null || cc.VanillaAttacks.Count < 1)
			{
				return;
			}
			try
			{
				float maxCreatureDamage = GetMaxCreatureDamage(cc.VanillaAttacks);
				if (maxCreatureDamage <= 0f)
				{
					return;
				}
				foreach (KeyValuePair<string, DamageTypes> vanillaAttack in cc.VanillaAttacks)
				{
					ScalingAPI.GetItemDrop(vanillaAttack.Key, out var item);
					if ((Object)(object)item != (Object)null)
					{
						DamageTypes? attack = cc.GetAttack(vanillaAttack.Key, maxCreatureDamage);
						ConfigureAttack(ref item, attack);
						continue;
					}
					ScalingPlugin.VentureScalingLogger.LogWarning((object)("Failed to configure \"" + vanillaAttack.Key + "\" for " + cc.Name + ". ItemDrop data does not exist!"));
				}
			}
			catch (Exception ex)
			{
				ScalingPlugin.VentureScalingLogger.LogDebug((object)("Error configuring attacks for " + cc.Name + ". Skipping."));
				ScalingPlugin.VentureScalingLogger.LogDebug((object)ex);
			}
		}

		private void ConfigureAttack(ref ItemDrop item, DamageTypes? value)
		{
			ItemConfiguration.Instance.UpdateWeapon(ref item, value, 1, null, playerItem: false);
		}

		protected float GetMaxCreatureDamage(Dictionary<string, DamageTypes> attacks)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			float num = 0f;
			if (attacks != null)
			{
				foreach (DamageTypes value in attacks.Values)
				{
					float totalDamage = ItemConfiguration.Instance.GetTotalDamage(value);
					if (totalDamage > num)
					{
						num = totalDamage;
					}
				}
			}
			return num;
		}

		public void Initialize()
		{
			foreach (CreatureClassification value2 in _creatureData.Values)
			{
				value2.Reset();
			}
			WorldConfiguration.Biome value = WorldConfiguration.Biome.Meadow;
			AddCreatureConfiguration("Eikthyr", value, WorldConfiguration.Difficulty.Boss);
			AddCreatureConfiguration("Boar_piggy", value, WorldConfiguration.Difficulty.Harmless);
			AddCreatureConfiguration("Boar", value, WorldConfiguration.Difficulty.Novice);
			AddCreatureConfiguration("Deer", value, WorldConfiguration.Difficulty.Novice);
			AddCreatureConfiguration("Greyling", value, WorldConfiguration.Difficulty.Novice);
			AddCreatureConfiguration("Neck", value, WorldConfiguration.Difficulty.Harmless);
			value = WorldConfiguration.Biome.BlackForest;
			AddCreatureConfiguration("gd_king", value, WorldConfiguration.Difficulty.Boss);
			AddCreatureConfiguration("Skeleton_Hildir", value, WorldConfiguration.Difficulty.Boss);
			AddCreatureConfiguration("Ghost", value, WorldConfiguration.Difficulty.Intermediate);
			AddCreatureConfiguration("Greydwarf", value, WorldConfiguration.Difficulty.Novice);
			AddCreatureConfiguration("Greydwarf_Elite", value, WorldConfiguration.Difficulty.Intermediate);
			AddCreatureConfiguration("Greydwarf_Shaman", value, WorldConfiguration.Difficulty.Average);
			AddCreatureConfiguration("Skeleton", value, WorldConfiguration.Difficulty.Average);
			AddCreatureConfiguration("Skeleton_NoArcher", value, WorldConfiguration.Difficulty.Average);
			AddCreatureConfiguration("Skeleton_Poison", value, WorldConfiguration.Difficulty.Intermediate);
			AddCreatureConfiguration("TentaRoot", value, WorldConfiguration.Difficulty.Novice);
			AddCreatureConfiguration("Troll", value, WorldConfiguration.Difficulty.Expert);
			value = WorldConfiguration.Biome.Swamp;
			AddCreatureConfiguration("Bonemass", value, WorldConfiguration.Difficulty.Boss);
			AddCreatureConfiguration("Abomination", value, WorldConfiguration.Difficulty.Expert);
			AddCreatureConfiguration("Blob", value, WorldConfiguration.Difficulty.Novice);
			AddCreatureConfiguration("BlobElite", value, WorldConfiguration.Difficulty.Intermediate);
			AddCreatureConfiguration("Draugr_Elite", value, WorldConfiguration.Difficulty.Intermediate);
			AddCreatureConfiguration("Draugr", value, WorldConfiguration.Difficulty.Average);
			AddCreatureConfiguration("Draugr_Ranged", value, WorldConfiguration.Difficulty.Average);
			AddCreatureConfiguration("Leech", value, WorldConfiguration.Difficulty.Novice);
			AddCreatureConfiguration("Surtling", value, WorldConfiguration.Difficulty.Novice);
			AddCreatureConfiguration("Wraith", value, WorldConfiguration.Difficulty.Intermediate);
			value = WorldConfiguration.Biome.Mountain;
			AddCreatureConfiguration("Dragon", value, WorldConfiguration.Difficulty.Boss);
			AddCreatureConfiguration("Skeleton_Hildir", value, WorldConfiguration.Difficulty.Boss);
			AddCreatureConfiguration("Bat", value, WorldConfiguration.Difficulty.Harmless);
			AddCreatureConfiguration("Fenring_Cultist", value, WorldConfiguration.Difficulty.Intermediate);
			AddCreatureConfiguration("Fenring", value, WorldConfiguration.Difficulty.Average);
			AddCreatureConfiguration("Hatchling", value, WorldConfiguration.Difficulty.Average);
			AddCreatureConfiguration("StoneGolem", value, WorldConfiguration.Difficulty.Expert);
			AddCreatureConfiguration("Ulv", value, WorldConfiguration.Difficulty.Average);
			AddCreatureConfiguration("Wolf_cub", value, WorldConfiguration.Difficulty.Harmless);
			AddCreatureConfiguration("Wolf", value, WorldConfiguration.Difficulty.Novice);
			value = WorldConfiguration.Biome.Plain;
			AddCreatureConfiguration("GoblinKing", value, WorldConfiguration.Difficulty.Boss);
			AddCreatureConfiguration("BlobTar", value, WorldConfiguration.Difficulty.Novice);
			AddCreatureConfiguration("Deathsquito", value, WorldConfiguration.Difficulty.Harmless);
			AddCreatureConfiguration("Goblin", value, WorldConfiguration.Difficulty.Average);
			AddCreatureConfiguration("GoblinArcher", value, WorldConfiguration.Difficulty.Average);
			AddCreatureConfiguration("GoblinShaman", value, WorldConfiguration.Difficulty.Novice);
			AddCreatureConfiguration("GoblinBrute", value, WorldConfiguration.Difficulty.Intermediate);
			AddCreatureConfiguration("Lox_Calf", value, WorldConfiguration.Difficulty.Harmless);
			AddCreatureConfiguration("Lox", value, WorldConfiguration.Difficulty.Intermediate);
			value = WorldConfiguration.Biome.Ocean;
			AddCreatureConfiguration("Serpent", value, WorldConfiguration.Difficulty.Expert);
			value = WorldConfiguration.Biome.Mistland;
			AddCreatureConfiguration("SeekerQueen", value, WorldConfiguration.Difficulty.Boss);
			AddCreatureConfiguration("Dverger", value, WorldConfiguration.Difficulty.Intermediate);
			AddCreatureConfiguration("DvergerMage", value, WorldConfiguration.Difficulty.Intermediate);
			AddCreatureConfiguration("DvergerMageFire", value, WorldConfiguration.Difficulty.Intermediate);
			AddCreatureConfiguration("DvergerMageIce", value, WorldConfiguration.Difficulty.Intermediate);
			AddCreatureConfiguration("DvergerMageSupport", value, WorldConfiguration.Difficulty.Intermediate);
			AddCreatureConfiguration("Gjall", value, WorldConfiguration.Difficulty.Expert);
			AddCreatureConfiguration("Hare", value, WorldConfiguration.Difficulty.Harmless);
			AddCreatureConfiguration("Seeker", value, WorldConfiguration.Difficulty.Average);
			AddCreatureConfiguration("SeekerBrood", value, WorldConfiguration.Difficulty.Harmless);
			AddCreatureConfiguration("SeekerBrute", value, WorldConfiguration.Difficulty.Expert);
			AddCreatureConfiguration("Tick", value, WorldConfiguration.Difficulty.Novice);
			value = WorldConfiguration.Biome.AshLand;
			AddCreatureConfiguration("Fader", value, WorldConfiguration.Difficulty.Boss);
			AddCreatureConfiguration("Asksvin", value, WorldConfiguration.Difficulty.Intermediate);
			AddCreatureConfiguration("Asksvin_hatchling", value, WorldConfiguration.Difficulty.Harmless);
			AddCreatureConfiguration("BlobLava", value, WorldConfiguration.Difficulty.Average);
			AddCreatureConfiguration("BonemawSerpent", value, WorldConfiguration.Difficulty.Intermediate);
			AddCreatureConfiguration("Charred_Archer", value, WorldConfiguration.Difficulty.Average);
			AddCreatureConfiguration("Charred_Archer_Fader", value, WorldConfiguration.Difficulty.Novice);
			AddCreatureConfiguration("Charred_Mage", value, WorldConfiguration.Difficulty.Intermediate);
			AddCreatureConfiguration("Charred_Melee", value, WorldConfiguration.Difficulty.Intermediate);
			AddCreatureConfiguration("Charred_Melee_Dyrnwyn", value, WorldConfiguration.Difficulty.Expert);
			AddCreatureConfiguration("Charred_Melee_Fader", value, WorldConfiguration.Difficulty.Novice);
			AddCreatureConfiguration("Charred_Twitcher", value, WorldConfiguration.Difficulty.Average);
			AddCreatureConfiguration("Charred_Twitcher_Summoned", value, WorldConfiguration.Difficulty.Novice);
			AddCreatureConfiguration("FallenValkyrie", value, WorldConfiguration.Difficulty.Expert);
			AddCreatureConfiguration("Morgen", value, WorldConfiguration.Difficulty.Expert);
			AddCreatureConfiguration("Morgen_NonSleeping", value, WorldConfiguration.Difficulty.Expert);
			AddCreatureConfiguration("Volture", value, WorldConfiguration.Difficulty.Average);
			AddCreatureConfiguration("staff_greenroots_tentaroot", WorldConfiguration.Biome.AshLand, WorldConfiguration.Difficulty.Average);
			AddCreatureConfiguration("Skeleton_Friendly", WorldConfiguration.Biome.Mistland, WorldConfiguration.Difficulty.Average);
			AddCreatureConfiguration("Troll_Summoned", WorldConfiguration.Biome.AshLand, WorldConfiguration.Difficulty.Expert);
			if (WorldConfiguration.Instance.WorldScale != 0 && !ScalingConfiguration.Instance.GetAutoScaleIgnoreOverrides())
			{
				ReadCustomValues();
			}
			CreateVanillaBackup();
		}

		public void AddCreatureConfiguration(string name, WorldConfiguration.Biome? biome, WorldConfiguration.Difficulty? difficulty)
		{
			if (!Utility.IsNullOrWhiteSpace(name))
			{
				if (_creatureData.ContainsKey(name))
				{
					_creatureData[name].UpdateCreature(biome, difficulty);
				}
				else
				{
					_creatureData.Add(name, new CreatureClassification(name, biome, difficulty));
				}
			}
		}

		public void AddCreatureConfiguration(CreatureOverrides.CreatureOverride creatureOverride)
		{
			if (creatureOverride != null && !Utility.IsNullOrWhiteSpace(creatureOverride.name))
			{
				AddCreatureConfiguration(creatureOverride.name, null, null);
				_creatureData[creatureOverride.name].OverrideCreature(creatureOverride);
			}
		}

		public void UpdateCreatures()
		{
			foreach (CreatureClassification value in _creatureData.Values)
			{
				Humanoid creature = ScalingAPI.GetHumanoid(value.Name);
				if ((Object)(object)creature != (Object)null)
				{
					float? health = value.GetHealth();
					if (health.HasValue)
					{
						UpdateCreature(health.Value, ref creature);
					}
					ConfigureAttacks(value);
				}
			}
		}

		private void UpdateCreature(float health, ref Humanoid creature)
		{
			float health2 = ((Character)creature).m_health;
			((Character)creature).m_health = health;
			ScalingPlugin.VentureScalingLogger.LogDebug((object)$"{((Object)creature).name}: Health updated from {health2} to {((Character)creature).m_health}.");
		}

		protected virtual void CreateVanillaBackup()
		{
			ScalingPlugin.VentureScalingLogger.LogInfo((object)"Configuring vanilla backup for Creature data...");
			foreach (CreatureClassification value in _creatureData.Values)
			{
				Humanoid humanoid = ScalingAPI.GetHumanoid(value.Name);
				if (!((Object)(object)humanoid != (Object)null))
				{
					continue;
				}
				List<GameObject> list = new List<GameObject>();
				if (humanoid.m_defaultItems != null)
				{
					list.AddRange(humanoid.m_defaultItems);
				}
				if (humanoid.m_randomWeapon != null)
				{
					list.AddRange(humanoid.m_randomWeapon);
				}
				if (humanoid.m_randomSets != null)
				{
					for (int i = 0; i < humanoid.m_randomSets.Length; i++)
					{
						if (humanoid.m_randomSets[i].m_items != null)
						{
							list.AddRange(humanoid.m_randomSets[i].m_items);
						}
					}
				}
				value.SetVanillaData(((Character)humanoid).m_health, list);
			}
		}

		public void VanillaReset()
		{
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			foreach (CreatureClassification value in _creatureData.Values)
			{
				Humanoid humanoid = ScalingAPI.GetHumanoid(value.Name);
				if (!((Object)(object)humanoid != (Object)null))
				{
					continue;
				}
				if (value.VanillaHealth.HasValue)
				{
					((Character)humanoid).m_health = value.VanillaHealth.Value;
				}
				if (value.VanillaAttacks == null)
				{
					continue;
				}
				foreach (KeyValuePair<string, DamageTypes> vanillaAttack in value.VanillaAttacks)
				{
					ScalingAPI.GetItemDrop(vanillaAttack.Key, out var item);
					if ((Object)(object)item != (Object)null)
					{
						ConfigureAttack(ref item, vanillaAttack.Value);
					}
				}
			}
		}

		protected virtual void ReadCustomValues()
		{
			try
			{
				CreatureOverrides.CreatureOverridesList creatureOverridesList = CreatureOverrides.ReadYaml();
				if (creatureOverridesList == null)
				{
					return;
				}
				ScalingPlugin.VentureScalingLogger.LogDebug((object)"Deserializer successfully parsed yaml data.");
				ScalingPlugin.VentureScalingLogger.LogDebug((object)creatureOverridesList.ToString());
				foreach (CreatureOverrides.CreatureOverride creature in creatureOverridesList.creatures)
				{
					AddCreatureConfiguration(creature);
				}
			}
			catch (Exception ex)
			{
				ScalingPlugin.VentureScalingLogger.LogWarning((object)"Error loading VWS.CreatureOverrides.yaml file.");
				ScalingPlugin.VentureScalingLogger.LogWarning((object)ex);
				ScalingPlugin.VentureScalingLogger.LogWarning((object)"Continuing without custom values...");
			}
		}
	}
	[<b9fea6d5-68cd-496d-aaa1-f4835254cf4a>NullableContext(1)]
	[<9eed9c0a-9fd3-449f-9769-233bc050d602>Nullable(0)]
	public class CreatureOverrides
	{
		[Serializable]
		[<9eed9c0a-9fd3-449f-9769-233bc050d602>Nullable(0)]
		public class CreatureOverridesList
		{
			public IEnumerable<CreatureOverride> creatures { get; set; }

			public override string ToString()
			{
				if (creatures == null)
				{
					return "No Data.";
				}
				string text = $"Creatures in list {creatures.Count()}:\n";
				foreach (CreatureOverride creature in creatures)
				{
					text += creature.ToString();
				}
				return text;
			}
		}

		[Serializable]
		[<9eed9c0a-9fd3-449f-9769-233bc050d602>Nullable(0)]
		public class CreatureOverride
		{
			public string name { get; set; }

			public int? biome { get; set; }

			public int? difficulty { get; set; }

			public float? health { get; set; }

			public IEnumerable<AttackOverride> attacks { get; set; }

			public override string ToString()
			{
				string text = $"{name}: Biome {biome}, Difficulty {difficulty}, Health {health}, Attacks:\n";
				if (attacks != null)
				{
					foreach (AttackOverride attack in attacks)
					{
						text += attack.ToString();
					}
				}
				return text;
			}
		}

		[Serializable]
		[<9eed9c0a-9fd3-449f-9769-233bc050d602>Nullable(0)]
		public class AttackOverride
		{
			public string name { get; set; }

			public float? totalDamage { get; set; }

			public float? damage { get; set; }

			public float? blunt { get; set; }

			public float? slash { get; set; }

			public float? pierce { get; set; }

			public float? fire { get; set; }

			public float? frost { get; set; }

			public float? lightning { get; set; }

			public float? poison { get; set; }

			public float? spirit { get; set; }

			public float? chop { get; set; }

			public float? pickaxe { get; set; }

			public override string ToString()
			{
				string text = "";
				if (!Utility.IsNullOrWhiteSpace(name))
				{
					text = text + "+" + name + ": ";
				}
				if (totalDamage.HasValue)
				{
					return text + $"total damage {totalDamage}\n";
				}
				return text + $"damage {damage}, blunt {blunt}, slash {slash}, pierce {pierce}, fire {fire}, frost {frost}, " + $"lightning {lightning}, poison {poison}, spirit {spirit}, chop {chop}, pickaxe {pickaxe}\n";
			}
		}

		private static string filePath;

		public static CreatureOverridesList ReadYaml()
		{
			if (File.Exists(filePath))
			{
				using (new StreamReader(filePath))
				{
					string input = File.ReadAllText(filePath);
					return new DeserializerBuilder().WithNamingConvention(CamelCaseNamingConvention.Instance).Build().Deserialize<CreatureOverridesList>(input);
				}
			}
			ScalingPlugin.VentureScalingLogger.LogWarning((object)"No yaml file found, to use overrides the VWS.CreatureOverrides.yaml file must be in your bepinex config folder.");
			return null;
		}

		public static DamageTypes GetDamageTypes(AttackOverride attack)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			DamageTypes result = default(DamageTypes);
			result.m_damage = ((!attack.damage.HasValue) ? 0f : attack.damage.Value);
			result.m_blunt = ((!attack.blunt.HasValue) ? 0f : attack.blunt.Value);
			result.m_slash = ((!attack.slash.HasValue) ? 0f : attack.slash.Value);
			result.m_pierce = ((!attack.pierce.HasValue) ? 0f : attack.pierce.Value);
			result.m_fire = ((!attack.fire.HasValue) ? 0f : attack.fire.Value);
			result.m_frost = ((!attack.frost.HasValue) ? 0f : attack.frost.Value);
			result.m_lightning = ((!attack.lightning.HasValue) ? 0f : attack.lightning.Value);
			result.m_poison = ((!attack.poison.HasValue) ? 0f : attack.poison.Value);
			result.m_spirit = ((!attack.spirit.HasValue) ? 0f : attack.spirit.Value);
			result.m_chop = ((!attack.chop.HasValue) ? 0f : attack.chop.Value);
			result.m_pickaxe = ((!attack.pickaxe.HasValue) ? 0f : attack.pickaxe.Value);
			return result;
		}

		static CreatureOverrides()
		{
			string configPath = Paths.ConfigPath;
			char directorySeparatorChar = Path.DirectorySeparatorChar;
			filePath = configPath + directorySeparatorChar + "VWS.CreatureOverrides.yaml";
		}
	}
	public enum ItemCategory
	{
		Undefined = -1,
		Weapon,
		Armor,
		Shield
	}
	public enum ItemType
	{
		Undefined = -1,
		None = 0,
		Shield = 1,
		Helmet = 2,
		Chest = 3,
		Legs = 4,
		Shoulder = 5,
		Utility = 6,
		Tool = 7,
		PickAxe = 8,
		Axe = 9,
		Bow = 10,
		Ammo = 11,
		Sword = 20,
		Knife = 21,
		Mace = 22,
		Sledge = 23,
		Atgeir = 25,
		Battleaxe = 26,
		Primative = 27,
		Spear = 28,
		TowerShield = 29,
		BucklerShield = 30,
		PrimativeArmor = 31,
		Bolt = 32,
		Crossbow = 33,
		HelmetRobe = 34,
		ChestRobe = 35,
		LegsRobe = 36,
		Fist = 37,
		TurretBolt = 38,
		GemAxe = 39,
		GemBow = 40,
		GemSword = 41,
		GemKnife = 42,
		GemMace = 43,
		GemSledge = 44,
		GemAtgeir = 45,
		GemBattleaxe = 46,
		GemSpear = 47,
		GemCrossbow = 48,
		HelmetMedium = 49,
		ChestMedium = 50,
		LegsMedium = 51,
		StaffRapid = 52,
		StaffSlow = 53,
		MagicShield = 54
	}
	[<9eed9c0a-9fd3-449f-9769-233bc050d602>Nullable(0)]
	[<b9fea6d5-68cd-496d-aaa1-f4835254cf4a>NullableContext(1)]
	public class ItemClassification
	{
		public string Name { get; private set; }

		public WorldConfiguration.Biome BiomeType { get; private set; }

		public ItemType ItemType { get; private set; }

		public ItemCategory ItemCategory { get; private set; }

		public int? VanillaUpgradeLevels { get; private set; }

		public float? VanillaValue { get; private set; }

		public float? VanillaUpgradeValue { get; private set; }

		public DamageTypes? VanillaDamageValue { get; private set; }

		public DamageTypes? VanillaUpgradeDamageValue { get; private set; }

		public bool Overridden { get; private set; }

		public float? OverrideValue { get; private set; }

		protected CreatureOverrides.AttackOverride OverrideDamageValue { get; private set; }

		protected CreatureOverrides.AttackOverride OverrideUpgradeDamageValue { get; private set; }

		protected float? OverrideUpgradeValue { get; private set; }

		protected int? OverrideUpgradeLevels { get; private set; }

		public ItemClassification(string name, WorldConfiguration.Biome? biomeType, ItemType? itemType)
		{
			Reset();
			Name = name;
			if (biomeType.HasValue)
			{
				BiomeType = biomeType.Value;
			}
			if (itemType.HasValue)
			{
				ItemType = itemType.Value;
			}
			ItemCategory = GetItemCategory(itemType);
			VanillaUpgradeLevels = null;
			VanillaValue = null;
			VanillaDamageValue = null;
			VanillaUpgradeValue = null;
			VanillaUpgradeDamageValue = null;
		}

		public void Reset()
		{
			BiomeType = WorldConfiguration.Biome.Undefined;
			ItemType = ItemType.Undefined;
			ItemCategory = ItemCategory.Undefined;
			Overridden = false;
			OverrideUpgradeLevels = null;
			OverrideValue = null;
			OverrideDamageValue = null;
			OverrideUpgradeValue = null;
			OverrideUpgradeDamageValue = null;
		}

		public virtual bool IgnoreScaling()
		{
			if (WorldConfiguration.Instance.WorldScale == WorldConfiguration.Scaling.Vanilla || (WorldConfiguration.Instance.WorldScale == WorldConfiguration.Scaling.Custom && !Overridden))
			{
				return true;
			}
			return false;
		}

		public void UpdateItem(WorldConfiguration.Biome? biomeType, ItemType? itemType)
		{
			if (biomeType.HasValue)
			{
				BiomeType = biomeType.Value;
			}
			if (itemType.HasValue)
			{
				ItemType = itemType.Value;
				ItemCategory = GetItemCategory(itemType);
			}
		}

		public void OverrideItem(ItemOverrides.ItemOverride item)
		{
			Overridden = true;
			WorldConfiguration.Biome? biomeType = null;
			if (item.biome.HasValue)
			{
				biomeType = (WorldConfiguration.Biome)item.biome.Value;
			}
			ItemType? itemType = null;
			if (item.itemType.HasValue)
			{
				itemType = (ItemType)item.itemType.Value;
			}
			UpdateItem(biomeType, itemType);
			OverrideUpgradeLevels = item.quality;
			OverrideValue = item.value;
			OverrideDamageValue = item.damageValue;
			OverrideUpgradeValue = item.upgradeValue;
			OverrideUpgradeDamageValue = item.upgradeDamageValue;
		}

		public static ItemCategory GetItemCategory(ItemType? itemType)
		{
			if (!itemType.HasValue)
			{
				return ItemCategory.Undefined;
			}
			switch (itemType)
			{
			case ItemType.Shield:
			case ItemType.TowerShield:
			case ItemType.BucklerShield:
			case ItemType.MagicShield:
				return ItemCategory.Shield;
			case ItemType.Helmet:
			case ItemType.Chest:
			case ItemType.Legs:
			case ItemType.Shoulder:
			case ItemType.Utility:
			case ItemType.PrimativeArmor:
			case ItemType.HelmetRobe:
			case ItemType.ChestRobe:
			case ItemType.LegsRobe:
			case ItemType.HelmetMedium:
			case ItemType.ChestMedium:
			case ItemType.LegsMedium:
				return ItemCategory.Armor;
			case ItemType.Tool:
			case ItemType.PickAxe:
			case ItemType.Axe:
			case ItemType.Bow:
			case ItemType.Ammo:
			case ItemType.Sword:
			case ItemType.Knife:
			case ItemType.Mace:
			case ItemType.Sledge:
			case ItemType.Atgeir:
			case ItemType.Battleaxe:
			case ItemType.Primative:
			case ItemType.Spear:
			case ItemType.Bolt:
			case ItemType.Crossbow:
			case ItemType.Fist:
			case ItemType.TurretBolt:
			case ItemType.GemAxe:
			case ItemType.GemBow:
			case ItemType.GemSword:
			case ItemType.GemKnife:
			case ItemType.GemMace:
			case ItemType.GemSledge:
			case ItemType.GemAtgeir:
			case ItemType.GemBattleaxe:
			case ItemType.GemSpear:
			case ItemType.GemCrossbow:
			case ItemType.StaffRapid:
			case ItemType.StaffSlow:
				return ItemCategory.Weapon;
			default:
				return ItemCategory.Undefined;
			}
		}

		private bool ItemTypeDefined()
		{
			if (ItemType != ItemType.Undefined)
			{
				return ItemType != ItemType.None;
			}
			return false;
		}

		public float? GetValue()
		{
			if (IgnoreScaling())
			{
				return VanillaValue;
			}
			if (OverrideValue.HasValue)
			{
				return OverrideValue;
			}
			if (BiomeType != WorldConfiguration.Biome.Undefined && ItemTypeDefined())
			{
				float biomeScaling = WorldConfiguration.Instance.GetBiomeScaling(BiomeType);
				return (int)(GetBaseValue() * biomeScaling);
			}
			return VanillaValue;
		}

		private float GetBaseValue()
		{
			return ItemConfiguration.Instance.GetBaseItemValue(ItemType);
		}

		public float? GetUpgradeValue()
		{
			if (IgnoreScaling())
			{
				return VanillaUpgradeValue;
			}
			if (OverrideUpgradeValue.HasValue)
			{
				return OverrideUpgradeValue;
			}
			if (BiomeType != WorldConfiguration.Biome.Undefined && ItemTypeDefined())
			{
				int? upgradeLevels = GetUpgradeLevels();
				if (upgradeLevels.HasValue)
				{
					return ItemConfiguration.Instance.CalculateUpgradeValue(BiomeType, GetBaseValue(), upgradeLevels.Value);
				}
			}
			return VanillaUpgradeValue;
		}

		public int? GetUpgradeLevels()
		{
			if (OverrideUpgradeLevels.HasValue)
			{
				return OverrideUpgradeLevels;
			}
			return VanillaUpgradeLevels;
		}

		public DamageTypes? GetDamageValue()
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			if (IgnoreScaling())
			{
				return VanillaDamageValue;
			}
			if (OverrideDamageValue != null)
			{
				if (OverrideDamageValue.totalDamage.HasValue && VanillaDamageValue.HasValue)
				{
					return ItemConfiguration.Instance.CalculateDamageTypesFinal(VanillaDamageValue.Value, OverrideDamageValue.totalDamage.Value, 1f);
				}
				DamageTypes damageTypes = CreatureOverrides.GetDamageTypes(OverrideDamageValue);
				if (VanillaDamageValue.HasValue)
				{
					if (!OverrideDamageValue.pickaxe.HasValue)
					{
						damageTypes.m_pickaxe = VanillaDamageValue.Value.m_pickaxe;
					}
					if (!OverrideDamageValue.chop.HasValue)
					{
						damageTypes.m_chop = VanillaDamageValue.Value.m_chop;
					}
				}
				return damageTypes;
			}
			if (BiomeType != WorldConfiguration.Biome.Undefined && VanillaDamageValue.HasValue && ItemTypeDefined())
			{
				WorldConfiguration.BiomeData biome = WorldConfiguration.Instance.GetBiome(BiomeType);
				return ItemConfiguration.Instance.CalculateItemDamageTypes(biome.ScaleValue, VanillaDamageValue.Value, GetBaseValue());
			}
			return VanillaDamageValue;
		}

		public DamageTypes? GetUpgradeDamageValue()
		{
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			if (IgnoreScaling())
			{
				return VanillaUpgradeDamageValue;
			}
			if (OverrideUpgradeDamageValue != null)
			{
				if (OverrideUpgradeDamageValue.totalDamage.HasValue && VanillaDamageValue.HasValue)
				{
					return ItemConfiguration.Instance.CalculateDamageTypesFinal(VanillaUpgradeDamageValue.Value, OverrideUpgradeDamageValue.totalDamage.Value, 1f);
				}
				return CreatureOverrides.GetDamageTypes(OverrideUpgradeDamageValue);
			}
			if (BiomeType != WorldConfiguration.Biome.Undefined && VanillaDamageValue.HasValue && ItemTypeDefined())
			{
				return ItemConfiguration.Instance.CalculateUpgradeValue(BiomeType, VanillaUpgradeDamageValue.Value, GetBaseValue(), GetUpgradeLevels().Value);
			}
			return VanillaUpgradeDamageValue;
		}

		public void SetVanillaData(float value, int upgrades, float upgradeValue)
		{
			float? vanillaValue = VanillaValue;
			float valueOrDefault = vanillaValue.GetValueOrDefault();
			if (!vanillaValue.HasValue)
			{
				valueOrDefault = value;
				float? vanillaValue2 = valueOrDefault;
				VanillaValue = vanillaValue2;
			}
			int? vanillaUpgradeLevels = VanillaUpgradeLevels;
			int valueOrDefault2 = vanillaUpgradeLevels.GetValueOrDefault();
			if (!vanillaUpgradeLevels.HasValue)
			{
				valueOrDefault2 = upgrades;
				int? vanillaUpgradeLevels2 = valueOrDefault2;
				VanillaUpgradeLevels = vanillaUpgradeLevels2;
			}
			vanillaValue = VanillaUpgradeValue;
			valueOrDefault = vanillaValue.GetValueOrDefault();
			if (!vanillaValue.HasValue)
			{
				valueOrDefault = upgradeValue;
				float? vanillaValue2 = valueOrDefault;
				VanillaUpgradeValue = vanillaValue2;
			}
		}

		public void SetVanillaData(DamageTypes damage, int upgrades, DamageTypes upgradeDamage)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			DamageTypes? vanillaDamageValue = VanillaDamageValue;
			DamageTypes valueOrDefault = vanillaDamageValue.GetValueOrDefault();
			if (!vanillaDamageValue.HasValue)
			{
				valueOrDefault = damage;
				DamageTypes? vanillaDamageValue2 = valueOrDefault;
				VanillaDamageValue = vanillaDamageValue2;
			}
			int? vanillaUpgradeLevels = VanillaUpgradeLevels;
			int valueOrDefault2 = vanillaUpgradeLevels.GetValueOrDefault();
			if (!vanillaUpgradeLevels.HasValue)
			{
				valueOrDefault2 = upgrades;
				int? vanillaUpgradeLevels2 = valueOrDefault2;
				VanillaUpgradeLevels = vanillaUpgradeLevels2;
			}
			vanillaDamageValue = VanillaUpgradeDamageValue;
			valueOrDefault = vanillaDamageValue.GetValueOrDefault();
			if (!vanillaDamageValue.HasValue)
			{
				valueOrDefault = upgradeDamage;
				DamageTypes? vanillaDamageValue2 = valueOrDefault;
				VanillaUpgradeDamageValue = vanillaDamageValue2;
			}
		}
	}
	[<b9fea6d5-68cd-496d-aaa1-f4835254cf4a>NullableContext(1)]
	public interface IItemConfiguration
	{
		float GetTotalDamage(DamageTypes OriginalDamage);

		DamageTypes CalculateCreatureDamageTypes(float biomeScale, DamageTypes OriginalDamage, float baseTotalDamage, float maxTotalDamage);

		DamageTypes CalculateItemDamageTypes(float biomeScale, DamageTypes originalDamage, float baseTotalDamage);

		void UpdateWeapon(ref ItemDrop item, DamageTypes? value, int? upgrades, DamageTypes? upgradeValue, bool playerItem = true);

		void UpdateArmor(ref ItemDrop item, float? value, int? upgrades, float? upgradeValue);

		void UpdateShield(ref ItemDrop item, float? value, int? upgrades, float? upgradeValue);

		void UpdateItems();

		void VanillaReset();
	}
	[<b9fea6d5-68cd-496d-aaa1-f4835254cf4a>NullableContext(1)]
	[<9eed9c0a-9fd3-449f-9769-233bc050d602>Nullable(0)]
	public class ItemConfiguration : IItemConfiguration
	{
		private static readonly IItemConfiguration _instance;

		protected Dictionary<ItemType, float> _itemBaseValues = new Dictionary<ItemType, float>();

		protected Dictionary<string, ItemClassification> _itemData = new Dictionary<string, ItemClassification>();

		public static ItemConfiguration Instance => _instance as ItemConfiguration;

		static ItemConfiguration()
		{
			_instance = new ItemConfiguration();
		}

		protected ItemConfiguration()
		{
		}

		public float GetBaseItemValue(ItemType itemType)
		{
			if (_itemBaseValues.ContainsKey(itemType))
			{
				return _itemBaseValues[itemType];
			}
			return 0f;
		}

		public void AddBaseItemValue(ItemType type, float value)
		{
			if (_itemBaseValues.ContainsKey(type))
			{
				_itemBaseValues[type] = value;
			}
			else
			{
				_itemBaseValues.Add(type, value);
			}
		}

		public void AddBaseItemValue(ItemOverrides.BaseItemValueOverride item)
		{
			if (item.itemType.HasValue && item.value.HasValue)
			{
				ItemType value = (ItemType)item.itemType.Value;
				AddBaseItemValue(value, item.value.Value);
			}
		}

		public void Initialize()
		{
			foreach (ItemClassification value in _itemData.Values)
			{
				value.Reset();
			}
			InitializeBaseArmorValues();
			InitializeBaseDamageValues();
			InitializeWeapons();
			InitializeArmor();
			InitializeShields();
			if (WorldConfiguration.Instance.WorldScale != 0 && !ScalingConfiguration.Instance.GetAutoScaleIgnoreOverrides())
			{
				ReadCustomValues();
			}
			CreateVanillaBackup();
		}

		public void AddItemConfiguration(string name, WorldConfiguration.Biome? biome, ItemType? itemType)
		{
			if (!Utility.IsNullOrWhiteSpace(name))
			{
				if (_itemData.ContainsKey(name))
				{
					_itemData[name].UpdateItem(biome, itemType);
				}
				else
				{
					_itemData.Add(name, new ItemClassification(name, biome, itemType));
				}
			}
		}

		public void AddItemConfiguration(ItemOverrides.ItemOverride itemOverride)
		{
			if (itemOverride != null && !Utility.IsNullOrWhiteSpace(itemOverride.name))
			{
				AddItemConfiguration(itemOverride.name, null, null);
				_itemData[itemOverride.name].OverrideItem(itemOverride);
			}
		}

		public void UpdateItems()
		{
			foreach (ItemClassification value in _itemData.Values)
			{
				ScalingAPI.GetItemDrop(value.Name, out var item);
				if ((Object)(object)item == (Object)null)
				{
					ScalingPlugin.VentureScalingLogger.LogWarning((object)("Failed to configure Item: " + value.Name + "."));
				}
				else if (value.ItemCategory == ItemCategory.Weapon)
				{
					UpdateWeapon(ref item, value.GetDamageValue(), value.GetUpgradeLevels(), value.GetUpgradeDamageValue());
				}
				else if (value.ItemCategory == ItemCategory.Armor)
				{
					UpdateArmor(ref item, value.GetValue(), value.GetUpgradeLevels(), value.GetUpgradeValue());
				}
				else if (value.ItemCategory == ItemCategory.Shield)
				{
					UpdateShield(ref item, value.GetValue(), value.GetUpgradeLevels(), value.GetUpgradeValue());
				}
			}
		}

		protected virtual void CreateVanillaBackup()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			ScalingPlugin.VentureScalingLogger.LogInfo((object)"Configuring vanilla backup for Item data...");
			foreach (ItemClassification value in _itemData.Values)
			{
				ScalingAPI.GetItemDrop(value.Name, out var item);
				if ((Object)(object)item != (Object)null)
				{
					if (value.ItemCategory == ItemCategory.Weapon)
					{
						DamageTypes damages = item.m_itemData.m_shared.m_damages;
						int maxQuality = item.m_itemData.m_shared.m_maxQuality;
						DamageTypes damagesPerLevel = item.m_itemData.m_shared.m_damagesPerLevel;
						value.SetVanillaData(damages, maxQuality, damagesPerLevel);
					}
					else if (value.ItemCategory == ItemCategory.Armor)
					{
						float armor = item.m_itemData.m_shared.m_armor;
						int maxQuality2 = item.m_itemData.m_shared.m_maxQuality;
						float armorPerLevel = item.m_itemData.m_shared.m_armorPerLevel;
						value.SetVanillaData(armor, maxQuality2, armorPerLevel);
					}
					else if (value.ItemCategory == ItemCategory.Shield)
					{
						float blockPower = item.m_itemData.m_shared.m_blockPower;
						int maxQuality3 = item.m_itemData.m_shared.m_maxQuality;
						float blockPowerPerLevel = item.m_itemData.m_shared.m_blockPowerPerLevel;
						value.SetVanillaData(blockPower, maxQuality3, blockPowerPerLevel);
					}
				}
				else
				{
					ScalingPlugin.VentureScalingLogger.LogDebug((object)("Vanilla backup for " + value.Name + " not created, ItemDrop not found."));
				}
			}
		}

		public void VanillaReset()
		{
			foreach (ItemClassification value in _itemData.Values)
			{
				ScalingAPI.GetItemDrop(value.Name, out var item);
				if ((Object)(object)item != (Object)null)
				{
					if (value.ItemCategory == ItemCategory.Weapon)
					{
						UpdateWeapon(ref item, value.VanillaDamageValue, value.VanillaUpgradeLevels, value.VanillaUpgradeDamageValue);
					}
					else if (value.ItemCategory == ItemCategory.Armor)
					{
						UpdateArmor(ref item, value.VanillaValue, value.VanillaUpgradeLevels, value.VanillaUpgradeValue);
					}
					else if (value.ItemCategory == ItemCategory.Shield)
					{
						UpdateShield(ref item, value.VanillaValue, value.VanillaUpgradeLevels, value.VanillaUpgradeValue);
					}
				}
			}
		}

		protected virtual void ReadCustomValues()
		{
			try
			{
				ItemOverrides.ItemOverridesList itemOverridesList = ItemOverrides.ReadYaml();
				if (itemOverridesList == null)
				{
					return;
				}
				ScalingPlugin.VentureScalingLogger.LogDebug((object)"Deserializer successfully parsed yaml data.");
				ScalingPlugin.VentureScalingLogger.LogDebug((object)itemOverridesList.ToString());
				foreach (ItemOverrides.ItemOverride item in itemOverridesList.items)
				{
					AddItemConfiguration(item);
				}
				foreach (ItemOverrides.BaseItemValueOverride baseItemValue in itemOverridesList.baseItemValues)
				{
					AddBaseItemValue(baseItemValue);
				}
			}
			catch (Exception ex)
			{
				ScalingPlugin.VentureScalingLogger.LogWarning((object)"Error loading VWS.ItemOverrides.yaml file.");
				ScalingPlugin.VentureScalingLogger.LogWarning((object)ex);
				ScalingPlugin.VentureScalingLogger.LogWarning((object)"Continuing without custom values...");
			}
		}

		private void InitializeBaseArmorValues()
		{
			AddBaseItemValue(ItemType.Shoulder, 1f);
			AddBaseItemValue(ItemType.PrimativeArmor, 2f);
			AddBaseItemValue(ItemType.Helmet, 4f);
			AddBaseItemValue(ItemType.Chest, 4f);
			AddBaseItemValue(ItemType.Legs, 4f);
			AddBaseItemValue(ItemType.HelmetMedium, 3f);
			AddBaseItemValue(ItemType.ChestMedium, 3f);
			AddBaseItemValue(ItemType.LegsMedium, 3f);
			AddBaseItemValue(ItemType.HelmetRobe, 2f);
			AddBaseItemValue(ItemType.ChestRobe, 2f);
			AddBaseItemValue(ItemType.LegsRobe, 2f);
			AddBaseItemValue(ItemType.BucklerShield, 8f);
			AddBaseItemValue(ItemType.Shield, 10f);
			AddBaseItemValue(ItemType.TowerShield, 15f);
			AddBaseItemValue(ItemType.MagicShield, 10f);
		}

		private void InitializeArmor()
		{
			AddItemConfiguration("ArmorRagsChest", WorldConfiguration.Biome.Meadow, ItemType.PrimativeArmor);
			AddItemConfiguration("ArmorRagsLegs", WorldConfiguration.Biome.Meadow, ItemType.PrimativeArmor);
			AddItemConfiguration("HelmetLeather", WorldConfiguration.Biome.Meadow, ItemType.Helmet);
			AddItemConfiguration("ArmorLeatherChest", WorldConfiguration.Biome.Meadow, ItemType.Chest);
			AddItemConfiguration("ArmorLeatherLegs", WorldConfiguration.Biome.Meadow, ItemType.Legs);
			AddItemConfiguration("HelmetBronze", WorldConfiguration.Biome.BlackForest, ItemType.Helmet);
			AddItemConfiguration("ArmorBronzeChest", WorldConfiguration.Biome.BlackForest, ItemType.Chest);
			AddItemConfiguration("ArmorBronzeLegs", WorldConfiguration.Biome.BlackForest, ItemType.Legs);
			AddItemConfiguration("HelmetTrollLeather", WorldConfiguration.Biome.BlackForest, ItemType.HelmetRobe);
			AddItemConfiguration("ArmorTrollLeatherChest", WorldConfiguration.Biome.BlackForest, ItemType.ChestRobe);
			AddItemConfiguration("ArmorTrollLeatherLegs", WorldConfiguration.Biome.BlackForest, ItemType.LegsRobe);
			AddItemConfiguration("HelmetIron", WorldConfiguration.Biome.Swamp, ItemType.Helmet);
			AddItemConfiguration("ArmorIronChest", WorldConfiguration.Biome.Swamp, ItemType.Chest);
			AddItemConfiguration("ArmorIronLegs", WorldConfiguration.Biome.Swamp, ItemType.Legs);
			AddItemConfiguration("HelmetRoot", WorldConfiguration.Biome.Swamp, ItemType.HelmetRobe);
			AddItemConfiguration("ArmorRootChest", WorldConfiguration.Biome.Swamp, ItemType.ChestRobe);
			AddItemConfiguration("ArmorRootLegs", WorldConfiguration.Biome.Swamp, ItemType.LegsRobe);
			AddItemConfiguration("HelmetFenring", WorldConfiguration.Biome.Mountain, ItemType.HelmetRobe);
			AddItemConfiguration("ArmorFenringChest", WorldConfiguration.Biome.Mountain, ItemType.ChestRobe);
			AddItemConfiguration("ArmorFenringLegs", WorldConfiguration.Biome.Mountain, ItemType.LegsRobe);
			AddItemConfiguration("HelmetDrake", WorldConfiguration.Biome.Mountain, ItemType.Helmet);
			AddItemConfiguration("ArmorWolfChest", WorldConfiguration.Biome.Mountain, ItemType.Chest);
			AddItemConfiguration("ArmorWolfLegs", WorldConfiguration.Biome.Mountain, ItemType.Legs);
			AddItemConfiguration("HelmetPadded", WorldConfiguration.Biome.Plain, ItemType.Helmet);
			AddItemConfiguration("ArmorPaddedCuirass", WorldConfiguration.Biome.Plain, ItemType.Chest);
			AddItemConfiguration("ArmorPaddedGreaves", WorldConfiguration.Biome.Plain, ItemType.Legs);
			AddItemConfiguration("HelmetMage", WorldConfiguration.Biome.Mistland, ItemType.HelmetRobe);
			AddItemConfiguration("ArmorMageChest", WorldConfiguration.Biome.Mistland, ItemType.ChestRobe);
			AddItemConfiguration("ArmorMageLegs", WorldConfiguration.Biome.Mistland, ItemType.LegsRobe);
			AddItemConfiguration("HelmetCarapace", WorldConfiguration.Biome.Mistland, ItemType.Helmet);
			AddItemConfiguration("ArmorCarapaceChest", WorldConfiguration.Biome.Mistland, ItemType.Chest);
			AddItemConfiguration("ArmorCarapaceLegs", WorldConfiguration.Biome.Mistland, ItemType.Legs);
			AddItemConfiguration("HelmetFlametal", WorldConfiguration.Biome.AshLand, ItemType.Helmet);
			AddItemConfiguration("ArmorFlametalChest", WorldConfiguration.Biome.AshLand, ItemType.Chest);
			AddItemConfiguration("ArmorFlametalLegs", WorldConfiguration.Biome.AshLand, ItemType.Legs);
			AddItemConfiguration("HelmetAshlandsMediumHood", WorldConfiguration.Biome.AshLand, ItemType.HelmetMedium);
			AddItemConfiguration("ArmorAshlandsMediumChest", WorldConfiguration.Biome.AshLand, ItemType.ChestMedium);
			AddItemConfiguration("ArmorAshlandsMediumlegs", WorldConfiguration.Biome.AshLand, ItemType.LegsMedium);
			AddItemConfiguration("HelmetMage_Ashlands", WorldConfiguration.Biome.AshLand, ItemType.HelmetRobe);
			AddItemConfiguration("ArmorMageChest_Ashlands", WorldConfiguration.Biome.AshLand, ItemType.ChestRobe);
			AddItemConfiguration("ArmorMageLegs_Ashlands", WorldConfiguration.Biome.AshLand, ItemType.LegsRobe);
		}

		private void InitializeShields()
		{
			AddItemConfiguration("ShieldBronzeBuckler", WorldConfiguration.Biome.BlackForest, ItemType.BucklerShield);
			AddItemConfiguration("ShieldIronBuckler", WorldConfiguration.Biome.Swamp, ItemType.BucklerShield);
			AddItemConfiguration("ShieldCarapaceBuckler", WorldConfiguration.Biome.Mistland, ItemType.BucklerShield);
			AddItemConfiguration("ShieldWood", WorldConfiguration.Biome.Meadow, ItemType.Shield);
			AddItemConfiguration("ShieldBanded", WorldConfiguration.Biome.Swamp, ItemType.Shield);
			AddItemConfiguration("ShieldSilver", WorldConfiguration.Biome.Swamp, ItemType.Shield);
			AddItemConfiguration("ShieldBlackmetal", WorldConfiguration.Biome.Plain, ItemType.Shield);
			AddItemConfiguration("ShieldCarapace", WorldConfiguration.Biome.Mistland, ItemType.Shield);
			AddItemConfiguration("ShieldFlametal", WorldConfiguration.Biome.AshLand, ItemType.Shield);
			AddItemConfiguration("ShieldSerpentscale", WorldConfiguration.Biome.Ocean, ItemType.TowerShield);
			AddItemConfiguration("ShieldWoodTower", WorldConfiguration.Biome.Meadow, ItemType.TowerShield);
			AddItemConfiguration("ShieldBoneTower", WorldConfiguration.Biome.BlackForest, ItemType.TowerShield);
			AddItemConfiguration("ShieldIronTower", WorldConfiguration.Biome.Swamp, ItemType.TowerShield);
			AddItemConfiguration("ShieldBlackmetalTower", WorldConfiguration.Biome.Plain, ItemType.TowerShield);
			AddItemConfiguration("ShieldFlametalTower", WorldConfiguration.Biome.AshLand, ItemType.TowerShield);
			AddItemConfiguration("StaffShield", WorldConfiguration.Biome.Mistland, ItemType.MagicShield);
		}

		public float CalculateUpgradeValue(WorldConfiguration.Biome biome, float baseValue, int quality)
		{
			float biomeScaling = WorldConfiguration.Instance.GetBiomeScaling(biome);
			float nextBiomeScale = WorldConfiguration.Instance.GetNextBiomeScale(biome);
			return CalculateUpgradeValue(biomeScaling, nextBiomeScale, baseValue, quality);
		}

		protected float CalculateUpgradeValue(float scale, float nextScale, float baseValue, int quality)
		{
			if (quality <= 1)
			{
				return 0f;
			}
			float num = baseValue * scale;
			float num2 = baseValue * nextScale - num;
			if (num2 > 0f)
			{
				return (float)Math.Round(num2 / (float)quality, 1);
			}
			return 0f;
		}

		public void UpdateArmor(ref ItemDrop item, float? value, int? upgrades, float? upgradeValue)
		{
			if (!value.HasValue)
			{
				ScalingPlugin.VentureScalingLogger.LogWarning((object)(((Object)item).name + " NOT updated with new armor value. Value undefined."));
				return;
			}
			float armor = item.m_itemData.m_shared.m_armor;
			item.m_itemData.m_shared.m_armor = value.Value;
			ScalingPlugin.VentureScalingLogger.LogDebug((object)$"{((Object)item).name}: Total armor changed from {armor} to {value}.");
			if (!upgrades.HasValue)
			{
				ScalingPlugin.VentureScalingLogger.LogWarning((object)(((Object)item).name + " NOT updated with new upgrade value. Total upgrades undefined."));
				return;
			}
			if (!upgradeValue.HasValue)
			{
				ScalingPlugin.VentureScalingLogger.LogWarning((object)(((Object)item).name + " NOT updated with new upgrade value. Value for item upgrade undefined."));
				return;
			}
			int maxQuality = item.m_itemData.m_shared.m_maxQuality;
			float armorPerLevel = item.m_itemData.m_shared.m_armorPerLevel;
			item.m_itemData.m_shared.m_maxQuality = upgrades.Value;
			item.m_itemData.m_shared.m_armorPerLevel = upgradeValue.Value;
			ScalingPlugin.VentureScalingLogger.LogDebug((object)($"{((Object)item).name}: Total item upgrades changed from {maxQuality} to {upgrades}. " + $"Total upgrade armor changed from {armorPerLevel} to {upgradeValue}."));
		}

		public void UpdateShield(ref ItemDrop item, float? value, int? upgrades, float? upgradeValue)
		{
			if (!value.HasValue)
			{
				ScalingPlugin.VentureScalingLogger.LogWarning((object)(((Object)item).name + " NOT updated with new block value. Value undefined."));
				return;
			}
			float blockPower = item.m_itemData.m_shared.m_blockPower;
			item.m_itemData.m_shared.m_blockPower = value.Value;
			ScalingPlugin.VentureScalingLogger.LogDebug((object)$"{((Object)item).name}: Total block changed from {blockPower} to {value}.");
			if (!upgrades.HasValue)
			{
				ScalingPlugin.VentureScalingLogger.LogWarning((object)(((Object)item).name + " NOT updated with new upgrade value. Total upgrades undefined."));
				return;
			}
			if (!upgradeValue.HasValue)
			{
				ScalingPlugin.VentureScalingLogger.LogWarning((object)(((Object)item).name + " NOT updated with new upgrade value. Value for item upgrade undefined."));
				return;
			}
			int maxQuality = item.m_itemData.m_shared.m_maxQuality;
			float blockPowerPerLevel = item.m_itemData.m_shared.m_blockPowerPerLevel;
			item.m_itemData.m_shared.m_maxQuality = upgrades.Value;
			item.m_itemData.m_shared.m_blockPowerPerLevel = upgradeValue.Value;
			ScalingPlugin.VentureScalingLogger.LogDebug((object)($"{((Object)item).name}: Total item upgrades changed from {maxQuality} to {upgrades}. " + $"Total upgrade block changed from {blockPowerPerLevel} to {upgradeValue}."));
		}

		private void InitializeBaseDamageValues()
		{
			AddBaseItemValue(ItemType.Primative, 8f);
			AddBaseItemValue(ItemType.Knife, 8f);
			AddBaseItemValue(ItemType.GemKnife, 9f);
			AddBaseItemValue(ItemType.Fist, 8f);
			AddBaseItemValue(ItemType.Ammo, 12f);
			AddBaseItemValue(ItemType.Bolt, 12f);
			AddBaseItemValue(ItemType.TurretBolt, 25f);
			AddBaseItemValue(ItemType.PickAxe, 10f);
			AddBaseItemValue(ItemType.Sword, 12f);
			AddBaseItemValue(ItemType.GemSword, 13f);
			AddBaseItemValue(ItemType.Mace, 12f);
			AddBaseItemValue(ItemType.GemMace, 13f);
			AddBaseItemValue(ItemType.Spear, 12f);
			AddBaseItemValue(ItemType.GemSpear, 13f);
			AddBaseItemValue(ItemType.Axe, 12f);
			AddBaseItemValue(ItemType.GemAxe, 13f);
			AddBaseItemValue(ItemType.Sledge, 15f);
			AddBaseItemValue(ItemType.GemSledge, 16f);
			AddBaseItemValue(ItemType.Atgeir, 15f);
			AddBaseItemValue(ItemType.GemAtgeir, 16f);
			AddBaseItemValue(ItemType.Battleaxe, 15f);
			AddBaseItemValue(ItemType.GemBattleaxe, 16f);
			AddBaseItemValue(ItemType.Bow, 18f);
			AddBaseItemValue(ItemType.GemBow, 19f);
			AddBaseItemValue(ItemType.Crossbow, 40f);
			AddBaseItemValue(ItemType.GemCrossbow, 42f);
			AddBaseItemValue(ItemType.StaffRapid, 5f);
			AddBaseItemValue(ItemType.StaffSlow, 24f);
			AddBaseItemValue(ItemType.Tool, 0f);
			AddBaseItemValue(ItemType.Utility, 0f);
			AddBaseItemValue(ItemType.None, 0f);
			AddBaseItemValue(ItemType.Undefined, 0f);
		}

		private void InitializeWeapons()
		{
			AddItemConfiguration("PlayerUnarmed", WorldConfiguration.Biome.Meadow, ItemType.Fist);
			AddItemConfiguration("Club", WorldConfiguration.Biome.Meadow, ItemType.Primative);
			AddItemConfiguration("AxeStone", WorldConfiguration.Biome.Meadow, ItemType.Primative);
			AddItemConfiguration("PickaxeStone", WorldConfiguration.Biome.Meadow, ItemType.Primative);
			AddItemConfiguration("Torch", WorldConfiguration.Biome.Meadow, ItemType.Primative);
			AddItemConfiguration("AxeFlint", WorldConfiguration.Biome.Meadow, ItemType.Axe);
			AddItemConfiguration("AxeBronze", WorldConfiguration.Biome.BlackForest, ItemType.Axe);
			AddItemConfiguration("AxeIron", WorldConfiguration.Biome.Swamp, ItemType.Axe);
			AddItemConfiguration("AxeBlackMetal", WorldConfiguration.Biome.Plain, ItemType.Axe);
			AddItemConfiguration("AxeJotunBane", WorldConfiguration.Biome.Mistland, ItemType.Axe);
			AddItemConfiguration("AxeBerzerkr", WorldConfiguration.Biome.AshLand, ItemType.Axe);
			AddItemConfiguration("AxeBerzerkrBlood", WorldConfiguration.Biome.AshLand, ItemType.Axe);
			AddItemConfiguration("AxeBerzerkrLightning", WorldConfiguration.Biome.AshLand, ItemType.GemAxe);
			AddItemConfiguration("AxeBerzerkrNature", WorldConfiguration.Biome.AshLand, ItemType.GemAxe);
			AddItemConfiguration("PickaxeAntler", WorldConfiguration.Biome.Meadow, ItemType.PickAxe);
			AddItemConfiguration("PickaxeBronze", WorldConfiguration.Biome.BlackForest, ItemType.PickAxe);
			AddItemConfiguration("PickaxeIron", WorldConfiguration.Biome.Swamp, ItemType.PickAxe);
			AddItemConfiguration("PickaxeBlackMetal", WorldConfiguration.Biome.Plain, ItemType.PickAxe);
			AddItemConfiguration("KnifeChitin", WorldConfiguration.Biome.Ocean, ItemType.Knife);
			AddItemConfiguration("KnifeFlint", WorldConfiguration.Biome.Meadow, ItemType.Knife);
			AddItemConfiguration("KnifeCopper", WorldConfiguration.Biome.BlackForest, ItemType.Knife);
			AddItemConfiguration("KnifeSilver", WorldConfiguration.Biome.Mountain, ItemType.Knife);
			AddItemConfiguration("KnifeBlackMetal", WorldConfiguration.Biome.Plain, ItemType.Knife);
			AddItemConfiguration("KnifeSkollAndHati", WorldConfiguration.Biome.Mistland, ItemType.Knife);
			AddItemConfiguration("MaceBronze", WorldConfiguration.Biome.BlackForest, ItemType.Mace);
			AddItemConfiguration("MaceIron", WorldConfiguration.Biome.Swamp, ItemType.Mace);
			AddItemConfiguration("MaceSilver", WorldConfiguration.Biome.Mountain, ItemType.Mace);
			AddItemConfiguration("MaceNeedle", WorldConfiguration.Biome.Plain, ItemType.Mace);
			AddItemConfiguration("MaceEldner", WorldConfiguration.Biome.AshLand, ItemType.Mace);
			AddItemConfiguration("MaceEldnerBlood", WorldConfiguration.Biome.AshLand, ItemType.Mace);
			AddItemConfiguration("MaceEldnerLightning", WorldConfiguration.Biome.AshLand, ItemType.GemMace);
			AddItemConfiguration("MaceEldnerNature", WorldConfiguration.Biome.AshLand, ItemType.GemMace);
			AddItemConfiguration("SwordBronze", WorldConfiguration.Biome.BlackForest, ItemType.Sword);
			AddItemConfiguration("SwordIron", WorldConfiguration.Biome.Swamp, ItemType.Sword);
			AddItemConfiguration("SwordIronFire", WorldConfiguration.Biome.Swamp, ItemType.Sword);
			AddItemConfiguration("SwordSilver", WorldConfiguration.Biome.Mountain, ItemType.Sword);
			AddItemConfiguration("SwordBlackmetal", WorldConfiguration.Biome.Plain, ItemType.Sword);
			AddItemConfiguration("SwordMistwalker", WorldConfiguration.Biome.Mistland, ItemType.Sword);
			AddItemConfiguration("SwordDyrnwyn", WorldConfiguration.Biome.AshLand, ItemType.GemSword);
			AddItemConfiguration("SwordNiedhogg", WorldConfiguration.Biome.AshLand, ItemType.Sword);
			AddItemConfiguration("SwordNiedhoggBlood", WorldConfiguration.Biome.AshLand, ItemType.Sword);
			AddItemConfiguration("SwordNiedhoggLightning", WorldConfiguration.Biome.AshLand, ItemType.GemSword);
			AddItemConfiguration("SwordNiedhoggNature", WorldConfiguration.Biome.AshLand, ItemType.GemSword);
			AddItemConfiguration("AtgeirBronze", WorldConfiguration.Biome.BlackForest, ItemType.Atgeir);
			AddItemConfiguration("AtgeirIron", WorldConfiguration.Biome.Swamp, ItemType.Atgeir);
			AddItemConfiguration("AtgeirBlackmetal", WorldConfiguration.Biome.Plain, ItemType.Atgeir);
			AddItemConfiguration("AtgeirHimminAfl", WorldConfiguration.Biome.Mistland, ItemType.Atgeir);
			AddItemConfiguration("Battleaxe", WorldConfiguration.Biome.Swamp, ItemType.Battleaxe);
			AddItemConfiguration("BattleaxeCrystal", WorldConfiguration.Biome.Mountain, ItemType.Battleaxe);
			AddItemConfiguration("THSwordKrom", WorldConfiguration.Biome.Mistland, ItemType.Battleaxe);
			AddItemConfiguration("THSwordSlayer", WorldConfiguration.Biome.AshLand, ItemType.Battleaxe);
			AddItemConfiguration("THSwordSlayerBlood", WorldConfiguration.Biome.AshLand, ItemType.Battleaxe);
			AddItemConfiguration("THSwordSlayerLightning", WorldConfiguration.Biome.AshLand, ItemType.GemBattleaxe);
			AddItemConfiguration("THSwordSlayerNature", WorldConfiguration.Biome.AshLand, ItemType.GemBattleaxe);
			AddItemConfiguration("SledgeStagbreaker", WorldConfiguration.Biome.Meadow, ItemType.Sledge);
			AddItemConfiguration("SledgeIron", WorldConfiguration.Biome.Swamp, ItemType.Sledge);
			AddItemConfiguration("SledgeDemolisher", WorldConfiguration.Biome.Mistland, ItemType.Sledge);
			AddItemConfiguration("SpearChitin", WorldConfiguration.Biome.Ocean, ItemType.Spear);
			AddItemConfiguration("SpearFlint", WorldConfiguration.Biome.Meadow, ItemType.Spear);
			AddItemConfiguration("SpearBronze", WorldConfiguration.Biome.BlackForest, ItemType.Spear);
			AddItemConfiguration("SpearElderbark", WorldConfiguration.Biome.Swamp, ItemType.Spear);
			AddItemConfiguration("SpearWolfFang", WorldConfiguration.Biome.Mountain, ItemType.Spear);
			AddItemConfiguration("SpearCarapace", WorldConfiguration.Biome.Mistland, ItemType.Spear);
			AddItemConfiguration("SpearSplitner", WorldConfiguration.Biome.AshLand, ItemType.Spear);
			AddItemConfiguration("SpearSplitner_Blood", WorldConfiguration.Biome.AshLand, ItemType.Spear);
			AddItemConfiguration("SpearSplitner_Lightning", WorldConfiguration.Biome.AshLand, ItemType.GemSpear);
			AddItemConfiguration("SpearSplitner_Nature", WorldConfiguration.Biome.AshLand, ItemType.GemSpear);
			AddItemConfiguration("FistFenrirClaw", WorldConfiguration.Biome.Mountain, ItemType.Fist);
			AddItemConfiguration("Bow", WorldConfiguration.Biome.Meadow, ItemType.Bow);
			AddItemConfiguration("BowFineWood", WorldConfiguration.Biome.BlackForest, ItemType.Bow);
			AddItemConfiguration("BowHuntsman", WorldConfiguration.Biome.Swamp, ItemType.Bow);
			AddItemConfiguration("BowDraugrFang", WorldConfiguration.Biome.Mountain, ItemType.Bow);
			AddItemConfiguration("BowSpineSnap", WorldConfiguration.Biome.Mistland, ItemType.Bow);
			AddItemConfiguration("BowAshlands", WorldConfiguration.Biome.AshLand, ItemType.Bow);
			AddItemConfiguration("BowAshlandsBlood", WorldConfiguration.Biome.AshLand, ItemType.Bow);
			AddItemConfiguration("BowAshlandsRoot", WorldConfiguration.Biome.AshLand, ItemType.GemBow);
			AddItemConfiguration("BowAshlandsStorm", WorldConfiguration.Biome.AshLand, ItemType.GemBow);
			AddItemConfiguration("ArrowWood", WorldConfiguration.Biome.Meadow, ItemType.Ammo);
			AddItemConfiguration("ArrowFlint", WorldConfiguration.Biome.Meadow, ItemType.Ammo);
			AddItemConfiguration("ArrowFire", WorldConfiguration.Biome.Meadow, ItemType.Ammo);
			AddItemConfiguration("ArrowBronze", WorldConfiguration.Biome.BlackForest, ItemType.Ammo);
			AddItemConfiguration("ArrowIron", WorldConfiguration.Biome.Plain, ItemType.Ammo);
			AddItemConfiguration("ArrowSilver", WorldConfiguration.Biome.Mountain, ItemType.Ammo);
			AddItemConfiguration("ArrowPoison", WorldConfiguration.Biome.Mountain, ItemType.Ammo);
			AddItemConfiguration("ArrowObsidian", WorldConfiguration.Biome.Mountain, ItemType.Ammo);
			AddItemConfiguration("ArrowFrost", WorldConfiguration.Biome.Mountain, ItemType.Ammo);
			AddItemConfiguration("ArrowNeedle", WorldConfiguration.Biome.Plain, ItemType.Ammo);
			AddItemConfiguration("ArrowCarapace", WorldConfiguration.Biome.Mistland, ItemType.Ammo);
			AddItemConfiguration("ArrowCharred", WorldConfiguration.Biome.AshLand, ItemType.Ammo);
			AddItemConfiguration("CrossbowArbalest", WorldConfiguration.Biome.Mistland, ItemType.Crossbow);
			AddItemConfiguration("CrossbowRipper", WorldConfiguration.Biome.AshLand, ItemType.Crossbow);
			AddItemConfiguration("CrossbowRipperBlood", WorldConfiguration.Biome.AshLand, ItemType.Crossbow);
			AddItemConfiguration("CrossbowRipperLightning", WorldConfiguration.Biome.AshLand, ItemType.GemCrossbow);
			AddItemConfiguration("CrossbowRipperNature", WorldConfiguration.Biome.AshLand, ItemType.GemCrossbow);
			AddItemConfiguration("BoltBone", WorldConfiguration.Biome.BlackForest, ItemType.Bolt);
			AddItemConfiguration("BoltIron", WorldConfiguration.Biome.Swamp, ItemType.Bolt);
			AddItemConfiguration("BoltBlackmetal", WorldConfiguration.Biome.Plain, ItemType.Bolt);
			AddItemConfiguration("BoltCarapace", WorldConfiguration.Biome.Mistland, ItemType.Bolt);
			AddItemConfiguration("BoltCharred", WorldConfiguration.Biome.AshLand, ItemType.Bolt);
			AddItemConfiguration("TurretBoltWood", WorldConfiguration.Biome.BlackForest, ItemType.TurretBolt);
			AddItemConfiguration("TurretBolt", WorldConfiguration.Biome.Plain, ItemType.TurretBolt);
			AddItemConfiguration("TurretBoltFlametal", WorldConfiguration.Biome.AshLand, ItemType.TurretBolt);
			AddItemConfiguration("StaffIceShards", WorldConfiguration.Biome.Mistland, ItemType.StaffRapid);
			AddItemConfiguration("StaffFireball", WorldConfiguration.Biome.Mistland, ItemType.StaffSlow);
			AddItemConfiguration("StaffClusterbomb", WorldConfiguration.Biome.AshLand, ItemType.StaffRapid);
			AddItemConfiguration("StaffLightning", WorldConfiguration.Biome.AshLand, ItemType.StaffRapid);
		}

		public float GetTotalDamage(DamageTypes originalDamage)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			return originalDamage.m_damage + originalDamage.m_blunt + originalDamage.m_slash + originalDamage.m_pierce + originalDamage.m_fire + originalDamage.m_frost + originalDamage.m_lightning + originalDamage.m_poison + originalDamage.m_spirit;
		}

		public DamageTypes CalculateCreatureDamageTypes(float biomeScale, DamageTypes originalDamage, float baseTotalDamage, float maxTotalDamage)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			Normalize(ref originalDamage);
			float multiplier = DamageRatio(GetTotalDamage(originalDamage), maxTotalDamage) * biomeScale;
			return CalculateDamageTypesFinal(originalDamage, baseTotalDamage, multiplier);
		}

		public DamageTypes CalculateItemDamageTypes(float biomeScale, DamageTypes originalDamage, float baseTotalDamage)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			Normalize(ref originalDamage);
			return CalculateDamageTypesFinal(originalDamage, baseTotalDamage, biomeScale);
		}

		public DamageTypes CalculateDamageTypesFinal(DamageTypes OriginalDamage, float baseTotalDamage, float multiplier)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			DamageTypes result = default(DamageTypes);
			float totalDamage = GetTotalDamage(OriginalDamage);
			result.m_chop = OriginalDamage.m_chop;
			result.m_pickaxe = OriginalDamage.m_pickaxe;
			result.m_damage = ScaleDamage(totalDamage, OriginalDamage.m_damage, baseTotalDamage, multiplier);
			result.m_blunt = ScaleDamage(totalDamage, OriginalDamage.m_blunt, baseTotalDamage, multiplier);
			result.m_slash = ScaleDamage(totalDamage, OriginalDamage.m_slash, baseTotalDamage, multiplier);
			result.m_pierce = ScaleDamage(totalDamage, OriginalDamage.m_pierce, baseTotalDamage, multiplier);
			result.m_fire = ScaleDamage(totalDamage, OriginalDamage.m_fire, baseTotalDamage, multiplier);
			result.m_frost = ScaleDamage(totalDamage, OriginalDamage.m_frost, baseTotalDamage, multiplier);
			result.m_lightning = ScaleDamage(totalDamage, OriginalDamage.m_lightning, baseTotalDamage, multiplier);
			result.m_poison = ScaleDamage(totalDamage, OriginalDamage.m_poison, baseTotalDamage, multiplier);
			result.m_spirit = ScaleDamage(totalDamage, OriginalDamage.m_spirit, baseTotalDamage, multiplier);
			return result;
		}

		protected float DamageRatio(float totalDamage, float maxDamageOfAnyAttackType)
		{
			if (totalDamage == 0f || maxDamageOfAnyAttackType == 0f)
			{
				return 0f;
			}
			return totalDamage / maxDamageOfAnyAttackType;
		}

		protected float ScaleDamage(float originalSum, float original, float baseTotalDamage, float multiplier)
		{
			if (original <= 0f || baseTotalDamage <= 0f)
			{
				return 0f;
			}
			return (float)Math.Round(baseTotalDamage * multiplier * (original / originalSum), 1);
		}

		private void Normalize(ref DamageTypes OriginalDamage)
		{
			OriginalDamage.m_damage = Normalize(OriginalDamage.m_damage);
			OriginalDamage.m_blunt = Normalize(OriginalDamage.m_blunt);
			OriginalDamage.m_slash = Normalize(OriginalDamage.m_slash);
			OriginalDamage.m_pierce = Normalize(OriginalDamage.m_pierce);
			OriginalDamage.m_chop = Normalize(OriginalDamage.m_chop);
			OriginalDamage.m_pickaxe = Normalize(OriginalDamage.m_pickaxe);
			OriginalDamage.m_fire = Normalize(OriginalDamage.m_fire);
			OriginalDamage.m_frost = Normalize(OriginalDamage.m_frost);
			OriginalDamage.m_lightning = Normalize(OriginalDamage.m_lightning);
			OriginalDamage.m_poison = Normalize(OriginalDamage.m_poison);
			OriginalDamage.m_spirit = Normalize(OriginalDamage.m_spirit);
		}

		private float Normalize(float num)
		{
			if (num < 0f)
			{
				return 0f;
			}
			return num;
		}

		public DamageTypes CalculateUpgradeValue(WorldConfiguration.Biome biome, DamageTypes original, float baseTotalDamage, int quality)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			float biomeScaling = WorldConfiguration.Instance.GetBiomeScaling(biome);
			float nextBiomeScale = WorldConfiguration.Instance.GetNextBiomeScale(biome);
			return CalculateUpgradeValue(biomeScaling, nextBiomeScale, original, baseTotalDamage, quality);
		}

		protected DamageTypes CalculateUpgradeValue(float scale, float nextScale, DamageTypes original, float baseTotalDamage, int quality)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			if (quality <= 1)
			{
				return original;
			}
			float num = baseTotalDamage * scale;
			float num2 = baseTotalDamage * nextScale - num;
			if (num2 > 0f)
			{
				float baseTotalDamage2 = num2 / (float)quality;
				return CalculateDamageTypesFinal(original, baseTotalDamage2, 1f);
			}
			return original;
		}

		public void UpdateWeapon(ref ItemDrop item, DamageTypes? value, int? upgrades, DamageTypes? upgradeValue, bool playerItem = true)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			if (!value.HasValue)
			{
				ScalingPlugin.VentureScalingLogger.LogWarning((object)(((Object)item).name + " NOT updated with new scaled damage values. DamageTypes undefined."));
				return;
			}
			DamageTypes damages = item.m_itemData.m_shared.m_damages;
			float totalDamage = GetTotalDamage(damages);
			float totalDamage2 = GetTotalDamage(value.Value);
			item.m_itemData.m_shared.m_damages = value.Value;
			ScalingPlugin.VentureScalingLogger.LogDebug((object)$"{((Object)item).name}: Total damage changed from {totalDamage} to {totalDamage2}.");
			if (playerItem)
			{
				if (!upgrades.HasValue)
				{
					ScalingPlugin.VentureScalingLogger.LogWarning((object)(((Object)item).name + " NOT updated with new scaled upgrade damage values. Total upgrades undefined."));
					return;
				}
				if (!upgradeValue.HasValue)
				{
					ScalingPlugin.VentureScalingLogger.LogWarning((object)(((Object)item).name + " NOT updated with new scaled upgrade damage values. DamageTypes for item upgrades undefined."));
					return;
				}
				int maxQuality = item.m_itemData.m_shared.m_maxQuality;
				DamageTypes damagesPerLevel = item.m_itemData.m_shared.m_damagesPerLevel;
				float totalDamage3 = GetTotalDamage(damagesPerLevel);
				float totalDamage4 = GetTotalDamage(upgradeValue.Value);
				item.m_itemData.m_shared.m_maxQuality = upgrades.Value;
				item.m_itemData.m_shared.m_damagesPerLevel = upgradeValue.Value;
				ScalingPlugin.VentureScalingLogger.LogDebug((object)($"{((Object)item).name}: Total item upgrades changed from {maxQuality} to {upgrades}." + $"Total upgrade damage changed from {totalDamage3} to {totalDamage4}"));
			}
		}
	}
	[<b9fea6d5-68cd-496d-aaa1-f4835254cf4a>NullableContext(1)]
	[<9eed9c0a-9fd3-449f-9769-233bc050d602>Nullable(0)]
	public class ItemOverrides
	{
		[Serializable]
		[<9eed9c0a-9fd3-449f-9769-233bc050d602>Nullable(0)]
		public class ItemOverridesList
		{
			public IEnumerable<ItemOverride> items { get; set; }

			public IEnumerable<BaseItemValueOverride> baseItemValues { get; set; }

			public override string ToString()
			{
				if (items == null)
				{
					return "No Data.";
				}
				string text = $"Items in list {items.Count()}:\n";
				foreach (ItemOverride item in items)
				{
					text += item.ToString();
				}
				return text;
			}
		}

		[Serializable]
		[<9eed9c0a-9fd3-449f-9769-233bc050d602>Nullable(0)]
		public class ItemOverride
		{
			public string name { get; set; }

			public int? biome { get; set; }

			public int? itemType { get; set; }

			public float? value { get; set; }

			public int? quality { get; set; }

			public float? upgradeValue { get; set; }

			public CreatureOverrides.AttackOverride damageValue { get; set; }

			public CreatureOverrides.AttackOverride upgradeDamageValue { get; set; }

			public override string ToString()
			{
				string text = $"{name}: Biome {biome}, Item Type {itemType}, Value {value}, Quality {quality}, Upgrade Value {upgradeValue}\n";
				if (damageValue != null)
				{
					text = text + "+Damage Value: " + damageValue.ToString();
				}
				if (upgradeDamageValue != null)
				{
					text = text + "+Upgrade Damage Value: " + upgradeDamageValue.ToString();
				}
				return text;
			}
		}

		[<b9fea6d5-68cd-496d-aaa1-f4835254cf4a>NullableContext(0)]
		public class BaseItemValueOverride
		{
			public int? itemType { get; set; }

			public float? value { get; set; }
		}

		private static string filePath;

		public static ItemOverridesList ReadYaml()
		{
			if (File.Exists(filePath))
			{
				using (new StreamReader(filePath))
				{
					string input = File.ReadAllText(filePath);
					return new DeserializerBuilder().WithNamingConvention(CamelCaseNamingConvention.Instance).Build().Deserialize<ItemOverridesList>(input);
				}
			}
			ScalingPlugin.VentureScalingLogger.LogWarning((object)"No yaml file found, to use overrides the VWS.ItemOverrides.yaml file must be in your bepinex config folder.");
			return null;
		}

		static ItemOverrides()
		{
			string configPath = Paths.ConfigPath;
			char directorySeparatorChar = Path.DirectorySeparatorChar;
			filePath = configPath + directorySeparatorChar + "VWS.ItemOverrides.yaml";
		}
	}
	public interface IScalingAPI
	{
	}
	[<9eed9c0a-9fd3-449f-9769-233bc050d602>Nullable(0)]
	[PublicAPI]
	[<b9fea6d5-68cd-496d-aaa1-f4835254cf4a>NullableContext(1)]
	public class ScalingAPI : IScalingAPI
	{
		private static readonly ScalingAPI _instance;

		public static ScalingAPI Instance => _instance;

		static ScalingAPI()
		{
			_instance = new ScalingAPI();
		}

		protected ScalingAPI()
		{
		}

		public static void AddCustomBiome(Biome biome, int order, bool overrideBiome = false)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			WorldConfiguration.Biome progressionBiome = GetProgressionBiome(biome);
			WorldConfiguration.Instance.AddBiome(progressionBiome, order, overrideBiome);
		}

		public static void AddCustomBiome(Biome biome, int order, float scale, bool overrideBiome = false)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			WorldConfiguration.Biome progressionBiome = GetProgressionBiome(biome);
			WorldConfiguration.Instance.AddCustomBiome(progressionBiome, scale, order, overrideBiome);
		}

		public static WorldConfiguration.Biome GetProgressionBiome(Biome biome)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Invalid comparison between Unknown and I4
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected I4, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Invalid comparison between Unknown and I4
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Invalid comparison between Unknown and I4
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Invalid comparison between Unknown and I4
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Invalid comparison between Unknown and I4
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Invalid comparison between Unknown and I4
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Invalid comparison between Unknown and I4
			if ((int)biome <= 16)
			{
				switch (biome - 1)
				{
				default:
					if ((int)biome != 8)
					{
						if ((int)biome != 16)
						{
							break;
						}
						return WorldConfiguration.Biome.Plain;
					}
					return WorldConfiguration.Biome.BlackForest;
				case 0:
					return WorldConfiguration.Biome.Meadow;
				case 1:
					return WorldConfiguration.Biome.Swamp;
				case 3:
					return WorldConfiguration.Biome.Mountain;
				case 2:
					break;
				}
			}
			else if ((int)biome <= 64)
			{
				if ((int)biome == 32)
				{
					return WorldConfiguration.Biome.AshLand;
				}
				if ((int)biome == 64)
				{
					return WorldConfiguration.Biome.DeepNorth;
				}
			}
			else
			{
				if ((int)biome == 256)
				{
					return WorldConfiguration.Biome.Ocean;
				}
				if ((int)biome == 512)
				{
					return WorldConfiguration.Biome.Mistland;
				}
			}
			return WorldConfiguration.Biome.Undefined;
		}

		public static bool GetItemDrop(string name, out ItemDrop item)
		{
			item = null;
			if (!Utility.IsNullOrWhiteSpace(name))
			{
				GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(StringExtensionMethods.GetStableHashCode(name));
				if ((Object)(object)itemPrefab == (Object)null)
				{
					itemPrefab = ObjectDB.instance.GetItemPrefab(name);
				}
				if ((Object)(object)itemPrefab != (Object)null)
				{
					item = itemPrefab.GetComponent<ItemDrop>();
					if ((Object)(object)item != (Object)null)
					{
						return true;
					}
				}
			}
			return false;
		}

		public static Humanoid GetHumanoid(string name)
		{
			if (!Utility.IsNullOrWhiteSpace(name) && (Object)(object)ZNetScene.instance != (Object)null)
			{
				int stableHashCode = StringExtensionMethods.GetStableHashCode(name);
				if (ZNetScene.instance.m_namedPrefabs != null && ZNetScene.instance.m_namedPrefabs.ContainsKey(stableHashCode))
				{
					return ZNetScene.instance.m_namedPrefabs[stableHashCode].GetComponent<Humanoid>();
				}
				if (ZNetScene.instance.m_prefabs != null)
				{
					List<GameObject> prefabs = ZNetScene.instance.m_prefabs;
					for (int i = 0; i < prefabs.Count; i++)
					{
						if (((Object)prefabs[i]).name.Equals(name, StringComparison.OrdinalIgnoreCase))
						{
							return prefabs[i].GetComponent<Humanoid>();
						}
					}
				}
			}
			return null;
		}

		public static void GenerateData(bool overwrite = false)
		{
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			string text = string.Format("{0}{1}{2}", Paths.ConfigPath, Path.DirectorySeparatorChar, "ItemDropData");
			if (!Directory.Exists(text) || overwrite)
			{
				Directory.CreateDirectory(text);
				foreach (GameObject item in ObjectDB.instance.m_items)
				{
					try
					{
						ItemDrop component = item.GetComponent<ItemDrop>();
						File.WriteAllText($"{text}{Path.DirectorySeparatorChar}{((Object)component).name}.json", JsonUtility.ToJson((object)component, true));
					}
					catch
					{
						ScalingPlugin.VentureScalingLogger.LogDebug((object)("Failed to write to file for GameObject: " + ((Object)item).name + "."));
					}
				}
			}
			text = string.Format("{0}{1}{2}", Paths.ConfigPath, Path.DirectorySeparatorChar, "CreatureData");
			if (Directory.Exists(text) && !overwrite)
			{
				return;
			}
			Directory.CreateDirectory(text);
			foreach (GameObject prefab in ZNetScene.instance.m_prefabs)
			{
				try
				{
					Humanoid component2 = prefab.GetComponent<Humanoid>();
					if (!((Object)(object)component2 != (Object)null))
					{
						continue;
					}
					File.WriteAllText($"{text}{Path.DirectorySeparatorChar}{((Object)component2).name}.json", JsonUtility.ToJson((object)component2, true));
					Dictionary<string, GameObject> dictionary = new Dictionary<string, GameObject>();
					if (component2.m_defaultItems != null)
					{
						GameObject[] defaultItems = component2.m_defaultItems;
						foreach (GameObject val in defaultItems)
						{
							if (!dictionary.ContainsKey(((Object)val).name))
							{
								dictionary.Add(((Object)val).name, val);
							}
						}
					}
					if (component2.m_randomWeapon != null)
					{
						GameObject[] defaultItems = component2.m_randomWeapon;
						foreach (GameObject val2 in defaultItems)
						{
							if (!dictionary.ContainsKey(((Object)val2).name))
							{
								dictionary.Add(((Object)val2).name, val2);
							}
						}
					}
					if (