Decompiled source of StarLevelSystem v0.11.4

plugins/StarLevelSystem.dll

Decompiled 5 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Versioning;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using JetBrains.Annotations;
using Jotunn;
using Jotunn.Entities;
using Jotunn.Extensions;
using Jotunn.Managers;
using Jotunn.Utils;
using MonoMod.Utils;
using SimpleJson;
using StarLevelSystem.Data;
using StarLevelSystem.common;
using StarLevelSystem.modules;
using UnityEngine;
using UnityEngine.UI;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("StarLevelSystem")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("StarLevelSystem")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("0.11.4")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.11.4.0")]
namespace StarLevelSystem
{
	[PublicAPI]
	public static class API
	{
		private static readonly Type APIReciever;

		private static readonly MethodInfo UpdateCreatureLevel;

		private static readonly MethodInfo UpdateCreatureColorization;

		private static readonly MethodInfo GetBaseAttributeValue;

		private static readonly MethodInfo UpdateCreatureBaseAttributes;

		private static readonly MethodInfo GetAllBaseAttributeValues;

		private static readonly MethodInfo SetAllBaseAttributeValues;

		private static readonly MethodInfo GetPerLevelAttributeValue;

		private static readonly MethodInfo UpdateCreaturePerLevelAttributes;

		private static readonly MethodInfo GetAllPerLevelAttributeValues;

		private static readonly MethodInfo SetAllPerLevelAttributeValues;

		private static readonly MethodInfo GetCreatureDamageRecievedModifier;

		private static readonly MethodInfo UpdateCreatureDamageRecievedModifier;

		private static readonly MethodInfo GetAllDamageRecievedModifiers;

		private static readonly MethodInfo SetAllDamageRecievedModifiers;

		private static readonly MethodInfo GetCreatureDamageBonus;

		private static readonly MethodInfo UpdateCreatureDamageBonus;

		private static readonly MethodInfo GetAllDamageBonus;

		private static readonly MethodInfo SetAllDamageBonus;

		private static readonly MethodInfo ApplyUpdatesToCreature;

		private static readonly MethodInfo GetPossibleModifiersForType;

		private static readonly MethodInfo GetAllModifiersForCreature;

		private static readonly MethodInfo AddModifierToCreature;

		private static readonly MethodInfo AddNewModifierToSLS;

		public static bool IsAvailable => APIReciever != null;

		static API()
		{
			APIReciever = Type.GetType("StarLevelSystem.modules.APIReciever, StarLevelSystem");
			UpdateCreatureLevel = APIReciever.GetMethod("UpdateCreatureLevel", BindingFlags.Static | BindingFlags.Public);
			UpdateCreatureColorization = APIReciever.GetMethod("UpdateCreatureColorization", BindingFlags.Static | BindingFlags.Public);
			GetBaseAttributeValue = APIReciever.GetMethod("GetBaseAttributeValue", BindingFlags.Static | BindingFlags.Public);
			UpdateCreatureBaseAttributes = APIReciever.GetMethod("UpdateCreatureBaseAttributes", BindingFlags.Static | BindingFlags.Public);
			GetAllBaseAttributeValues = APIReciever.GetMethod("GetAllBaseAttributeValues", BindingFlags.Static | BindingFlags.Public);
			SetAllBaseAttributeValues = APIReciever.GetMethod("SetAllBaseAttributeValues", BindingFlags.Static | BindingFlags.Public);
			GetPerLevelAttributeValue = APIReciever.GetMethod("GetPerLevelAttributeValue", BindingFlags.Static | BindingFlags.Public);
			UpdateCreaturePerLevelAttributes = APIReciever.GetMethod("UpdateCreaturePerLevelAttributes", BindingFlags.Static | BindingFlags.Public);
			GetAllPerLevelAttributeValues = APIReciever.GetMethod("GetAllPerLevelAttributeValues", BindingFlags.Static | BindingFlags.Public);
			SetAllPerLevelAttributeValues = APIReciever.GetMethod("SetAllPerLevelAttributeValues", BindingFlags.Static | BindingFlags.Public);
			GetCreatureDamageRecievedModifier = APIReciever.GetMethod("GetCreatureDamageRecievedModifier", BindingFlags.Static | BindingFlags.Public);
			UpdateCreatureDamageRecievedModifier = APIReciever.GetMethod("UpdateCreatureDamageRecievedModifier", BindingFlags.Static | BindingFlags.Public);
			GetAllDamageRecievedModifiers = APIReciever.GetMethod("GetAllDamageRecievedModifiers", BindingFlags.Static | BindingFlags.Public);
			SetAllDamageRecievedModifiers = APIReciever.GetMethod("SetAllDamageRecievedModifiers", BindingFlags.Static | BindingFlags.Public);
			GetCreatureDamageBonus = APIReciever.GetMethod("GetCreatureDamageBonus", BindingFlags.Static | BindingFlags.Public);
			UpdateCreatureDamageBonus = APIReciever.GetMethod("UpdateCreatureDamageBonus", BindingFlags.Static | BindingFlags.Public);
			GetAllDamageBonus = APIReciever.GetMethod("GetAllDamageBonus", BindingFlags.Static | BindingFlags.Public);
			SetAllDamageBonus = APIReciever.GetMethod("SetAllDamageBonus", BindingFlags.Static | BindingFlags.Public);
			ApplyUpdatesToCreature = APIReciever.GetMethod("ApplyUpdatesToCreature", BindingFlags.Static | BindingFlags.Public);
			GetPossibleModifiersForType = APIReciever.GetMethod("GetPossibleModifiersForType", BindingFlags.Static | BindingFlags.Public);
			GetAllModifiersForCreature = APIReciever.GetMethod("GetAllModifiersForCreature", BindingFlags.Static | BindingFlags.Public);
			AddModifierToCreature = APIReciever.GetMethod("AddModifierToCreature", BindingFlags.Static | BindingFlags.Public);
			AddNewModifierToSLS = APIReciever.GetMethod("AddNewModifierToSLS", BindingFlags.Static | BindingFlags.Public);
		}

		public static bool SetCreatureLevel(Character creatureId, int newLevel)
		{
			return (bool)UpdateCreatureLevel.Invoke(null, new object[2] { creatureId, newLevel });
		}

		public static bool SetCreatureColorization(Character creatureId, float value, float hue, float sat, bool emission = false)
		{
			return (bool)UpdateCreatureColorization.Invoke(null, new object[5] { creatureId, value, hue, sat, emission });
		}

		public static float GetCreatureBaseAttribute(Character creatureId, int attribute)
		{
			return (float)GetBaseAttributeValue.Invoke(null, new object[2] { creatureId, attribute });
		}

		public static bool SetCreatureBaseAttribute(Character creatureId, int attribute, float value)
		{
			return (bool)UpdateCreatureBaseAttributes.Invoke(null, new object[3] { creatureId, attribute, value });
		}

		public static Dictionary<int, float> GetAllCreatureBaseAttributes(Character creatureId)
		{
			return (Dictionary<int, float>)GetAllBaseAttributeValues.Invoke(null, new object[1] { creatureId });
		}

		public static bool SetAllCreatureBaseAttributes(Character creatureId, Dictionary<int, float> attributes)
		{
			return (bool)SetAllBaseAttributeValues.Invoke(null, new object[2] { creatureId, attributes });
		}

		public static float GetCreaturePerLevelAttribute(Character creatureId, int attribute)
		{
			return (float)GetPerLevelAttributeValue.Invoke(null, new object[2] { creatureId, attribute });
		}

		public static bool SetCreaturePerLevelAttribute(Character creatureId, int attribute, float value)
		{
			return (bool)UpdateCreaturePerLevelAttributes.Invoke(null, new object[3] { creatureId, attribute, value });
		}

		public static Dictionary<int, float> GetAllCreaturePerLevelAttributes(Character creatureId)
		{
			return (Dictionary<int, float>)GetAllPerLevelAttributeValues.Invoke(null, new object[1] { creatureId });
		}

		public static bool SetAllCreaturePerLevelAttributes(Character creatureId, Dictionary<int, float> attributes)
		{
			return (bool)SetAllPerLevelAttributeValues.Invoke(null, new object[2] { creatureId, attributes });
		}

		public static float GetCreatureDamageReceivedModifier(Character creatureId, int damageType)
		{
			return (float)GetCreatureDamageRecievedModifier.Invoke(null, new object[2] { creatureId, damageType });
		}

		public static bool SetCreatureDamageReceivedModifier(Character creatureId, int damageType, float value)
		{
			return (bool)UpdateCreatureDamageRecievedModifier.Invoke(null, new object[3] { creatureId, damageType, value });
		}

		public static Dictionary<int, float> GetAllCreatureDamageReceivedModifiers(Character creatureId)
		{
			return (Dictionary<int, float>)GetAllDamageRecievedModifiers.Invoke(null, new object[1] { creatureId });
		}

		public static bool SetAllCreatureDamageReceivedModifiers(Character creatureId, Dictionary<int, float> attributes)
		{
			return (bool)SetAllDamageRecievedModifiers.Invoke(null, new object[2] { creatureId, attributes });
		}

		public static float GetCreatureFlatDamageBonus(Character creatureId, int damageType)
		{
			return (float)GetCreatureDamageBonus.Invoke(null, new object[2] { creatureId, damageType });
		}

		public static bool SetCreatureFlatDamageBonus(Character creatureId, int damageType, float value)
		{
			return (bool)UpdateCreatureDamageBonus.Invoke(null, new object[3] { creatureId, damageType, value });
		}

		public static Dictionary<int, float> GetAllCreatureFlatDamageBonuses(Character creatureId)
		{
			return (Dictionary<int, float>)GetAllDamageBonus.Invoke(null, new object[1] { creatureId });
		}

		public static bool SetAllCreatureFlatDamageBonuses(Character creatureId, Dictionary<int, float> attributes)
		{
			return (bool)SetAllDamageBonus.Invoke(null, new object[2] { creatureId, attributes });
		}

		public static bool ApplyCreatureUpdates(Character creatureId)
		{
			return (bool)ApplyUpdatesToCreature.Invoke(null, new object[1] { creatureId });
		}

		public static List<string> GetPossibleModifiers(int modType = 0)
		{
			return (List<string>)GetPossibleModifiersForType.Invoke(null, new object[1] { modType });
		}

		public static Dictionary<string, int> GetCreaturesModifiers(Character creatureId)
		{
			return (Dictionary<string, int>)GetAllModifiersForCreature.Invoke(null, new object[1] { creatureId });
		}

		public static bool AddModifierToTargetCreature(Character creatureId, string modifierName, int modifierType, bool update = true)
		{
			return (bool)AddModifierToCreature.Invoke(null, new object[4] { creatureId, modifierName, modifierType, update });
		}

		public static bool AddNewModifier(int modifierID, string modifier_name, string setupMethod = null, float selectionWeight = 10f, float basepower = 0f, float perlevelpower = 0f, Dictionary<Biome, List<string>> biomeConfig = null, int namingStyle = 2, List<string> name_suffixes = null, List<string> name_prefixes = null, int visualStyle = 0, Sprite starIcon = null, GameObject visualEffect = null, List<string> allowed_creatures = null, List<string> unallowed_creatures = null, List<Biome> allowed_biomes = null)
		{
			return (bool)AddNewModifierToSLS.Invoke(null, new object[16]
			{
				modifierID, modifier_name, setupMethod, selectionWeight, basepower, perlevelpower, biomeConfig, namingStyle, name_suffixes, name_prefixes,
				visualStyle, starIcon, visualEffect, allowed_creatures, unallowed_creatures, allowed_biomes
			});
		}
	}
	internal class ValConfig
	{
		[CompilerGenerated]
		private sealed class <OnClientReceiveColorConfigs>d__71 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public ZPackage package;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <OnClientReceiveColorConfigs>d__71(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					Colorization.UpdateYamlConfig(package.ReadString());
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <OnClientReceiveCreatureLootConfigs>d__72 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public ZPackage package;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <OnClientReceiveCreatureLootConfigs>d__72(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					LootSystemData.UpdateYamlConfig(package.ReadString());
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <OnClientReceiveLevelConfigs>d__70 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public ZPackage package;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <OnClientReceiveLevelConfigs>d__70(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					LevelSystemData.UpdateYamlConfig(package.ReadString());
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <OnClientReceiveModifiersConfigs>d__73 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public ZPackage package;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <OnClientReceiveModifiersConfigs>d__73(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					CreatureModifiersData.UpdateModifierConfig(package.ReadString());
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <OnServerRecieveConfigs>d__69 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <OnServerRecieveConfigs>d__69(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					Logger.LogDebug("Server recieved config from client, rejecting due to being the server.");
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public static ConfigFile cfg;

		internal static string levelsFilePath = Path.Combine(Paths.ConfigPath, "StarLevelSystem", "LevelSettings.yaml");

		internal static string colorsFilePath = Path.Combine(Paths.ConfigPath, "StarLevelSystem", "ColorSettings.yaml");

		internal static string creatureLootFilePath = Path.Combine(Paths.ConfigPath, "StarLevelSystem", "CreatureLootSettings.yaml");

		internal static string creatureModifierFilePath = Path.Combine(Paths.ConfigPath, "StarLevelSystem", "Modifiers.yaml");

		private static CustomRPC LevelSettingsRPC;

		private static CustomRPC ColorSettingsRPC;

		private static CustomRPC CreatureLootSettingsRPC;

		private static CustomRPC ModifiersRPC;

		public static ConfigEntry<bool> EnableDebugMode;

		public static ConfigEntry<int> MaxLevel;

		public static ConfigEntry<bool> EnableMapRingsForDistanceBonus;

		public static ConfigEntry<bool> DistanceBonusIsFromStarterTemple;

		public static ConfigEntry<int> MiniMapRingGeneratorUpdatesPerFrame;

		public static ConfigEntry<string> DistanceRingColorOptions;

		public static ConfigEntry<bool> ControlSpawnerLevels;

		public static ConfigEntry<bool> ForceControlAllSpawns;

		public static ConfigEntry<string> SpawnsAlwaysControlled;

		public static ConfigEntry<bool> ControlBossSpawns;

		public static ConfigEntry<bool> ControlAbilitySpawnedCreatures;

		public static ConfigEntry<bool> EnableCreatureScalingPerLevel;

		public static ConfigEntry<bool> EnableScalingInDungeons;

		public static ConfigEntry<float> PerLevelScaleBonus;

		public static ConfigEntry<float> PerLevelLootScale;

		public static ConfigEntry<int> LootDropsPerTick;

		public static ConfigEntry<string> LootDropCalculationType;

		public static ConfigEntry<float> EnemyHealthMultiplier;

		public static ConfigEntry<float> BossEnemyHealthMultiplier;

		public static ConfigEntry<float> EnemyHealthPerWorldLevel;

		public static ConfigEntry<float> EnemyDamageLevelMultiplier;

		public static ConfigEntry<float> BossEnemyDamageMultiplier;

		public static ConfigEntry<bool> EnableScalingBirds;

		public static ConfigEntry<float> BirdSizeScalePerLevel;

		public static ConfigEntry<bool> EnableScalingFish;

		public static ConfigEntry<float> FishSizeScalePerLevel;

		public static ConfigEntry<bool> EnableTreeScaling;

		public static ConfigEntry<float> TreeSizeScalePerLevel;

		public static ConfigEntry<bool> RandomizeTameChildrenLevels;

		public static ConfigEntry<bool> SpawnMultiplicationAppliesToTames;

		public static ConfigEntry<bool> BossCreaturesNeverSpawnMultiply;

		public static ConfigEntry<bool> EnableColorization;

		public static ConfigEntry<int> MaxMajorModifiersPerCreature;

		public static ConfigEntry<int> MaxMinorModifiersPerCreature;

		public static ConfigEntry<bool> LimitCreatureModifiersToCreatureStarLevel;

		public static ConfigEntry<float> ChanceMajorModifier;

		public static ConfigEntry<float> ChanceMinorModifier;

		public static ConfigEntry<bool> EnableBossModifiers;

		public static ConfigEntry<float> ChanceOfBossModifier;

		public static ConfigEntry<int> MaxBossModifiersPerBoss;

		public static ConfigEntry<bool> SplittersInheritLevel;

		public static ConfigEntry<bool> EnableDistanceLevelScalingBonus;

		public static ConfigEntry<bool> EnableMultiplayerEnemyHealthScaling;

		public static ConfigEntry<bool> EnableMultiplayerEnemyDamageScaling;

		public static ConfigEntry<int> MultiplayerScalingRequiredPlayersNearby;

		public static ConfigEntry<float> MultiplayerEnemyDamageModifier;

		public static ConfigEntry<float> MultiplayerEnemyHealthModifier;

		public static ConfigEntry<int> NumberOfCacheUpdatesPerFrame;

		public static ConfigEntry<bool> OutputColorizationGeneratorsData;

		public ValConfig(ConfigFile cf)
		{
			cfg = cf;
			cfg.SaveOnConfigSet = true;
			CreateConfigValues(cf);
		}

		public void SetupConfigRPCs()
		{
			//IL_0011: 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_0027: Expected O, but got Unknown
			//IL_0027: Expected O, but got Unknown
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_0053: Expected O, but got Unknown
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_007f: Expected O, but got Unknown
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			//IL_00ab: Expected O, but got Unknown
			LevelSettingsRPC = NetworkManager.Instance.AddRPC("LSE_LevelsRPC", new CoroutineHandler(OnServerRecieveConfigs), new CoroutineHandler(OnClientReceiveLevelConfigs));
			ColorSettingsRPC = NetworkManager.Instance.AddRPC("LSE_ColorsRPC", new CoroutineHandler(OnServerRecieveConfigs), new CoroutineHandler(OnClientReceiveColorConfigs));
			CreatureLootSettingsRPC = NetworkManager.Instance.AddRPC("LSE_CreatureLootRPC", new CoroutineHandler(OnServerRecieveConfigs), new CoroutineHandler(OnClientReceiveCreatureLootConfigs));
			ModifiersRPC = NetworkManager.Instance.AddRPC("LSE_ModifiersRPC", new CoroutineHandler(OnServerRecieveConfigs), new CoroutineHandler(OnClientReceiveModifiersConfigs));
			SynchronizationManager.Instance.AddInitialSynchronization(LevelSettingsRPC, (Func<ZPackage>)SendLevelsConfigs);
			SynchronizationManager.Instance.AddInitialSynchronization(ColorSettingsRPC, (Func<ZPackage>)SendColorsConfigs);
			SynchronizationManager.Instance.AddInitialSynchronization(CreatureLootSettingsRPC, (Func<ZPackage>)SendCreatureLootConfigs);
			SynchronizationManager.Instance.AddInitialSynchronization(ModifiersRPC, (Func<ZPackage>)SendModifierConfigs);
		}

		private void CreateConfigValues(ConfigFile Config)
		{
			//IL_001a: 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_002c: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			EnableDebugMode = Config.Bind<bool>("Client config", "EnableDebugMode", false, new ConfigDescription("Enables Debug logging.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdvanced = true
			} }));
			EnableDebugMode.SettingChanged += Logger.enableDebugLogging;
			Logger.CheckEnableDebugLogging();
			MaxLevel = BindServerConfig("LevelSystem", "MaxLevel", 20, "The Maximum number of stars that a creature can have", advanced: false, 1, 100);
			EnableCreatureScalingPerLevel = BindServerConfig("LevelSystem", "EnableCreatureScalingPerLevel", value: true, "Enables started creatures to get larger for each star");
			EnableDistanceLevelScalingBonus = BindServerConfig("LevelSystem", "EnableDistanceLevelScalingBonus", value: true, "Creatures further away from the center of the world have a higher chance to levelup, this is a bonus applied to existing creature/biome configuration.");
			EnableMapRingsForDistanceBonus = BindServerConfig("LevelSystem", "EnableMapRingsForDistanceBonus", value: true, "Enables map rings to show distance levels, this is a visual aid to help you see how far away from the center of the world you are.");
			DistanceBonusIsFromStarterTemple = BindServerConfig("LevelSystem", "DistanceBonusIsFromStarterTemple", value: false, "When enabled the distance bonus is calculated from the starter temple instead of world center, typically this makes little difference. But can help ensure your starting area is more correctly calculated.");
			DistanceBonusIsFromStarterTemple.SettingChanged += LevelSystem.OnRingCenterChanged;
			DistanceRingColorOptions = BindServerConfig("LevelSystem", "DistanceRingColorOptions", "White,Blue,Teal,Green,Yellow,Purple,Orange,Pink,Purple,Red,Grey", "The colors that distance rings will use, if there are more rings than colors, the color pattern will be repeated. (Optional, use an HTML hex color starting with # to have a custom color.) Available options: Red, Orange, Yellow, Green, Teal, Blue, Purple, Pink, Gray, Brown, Black");
			DistanceRingColorOptions.SettingChanged += LevelSystem.UpdateMapColorSettingsOnChange;
			MiniMapRingGeneratorUpdatesPerFrame = BindServerConfig("LevelSystem", "MiniMapRingGeneratorUpdatesPerFrame", 1000, "The number of ring points to calculate per frame when generating the minimap rings. Higher values make this go faster, but can get it killed or cause instability.", advanced: true);
			PerLevelScaleBonus = BindServerConfig("LevelSystem", "PerLevelScaleBonus", 0.1f, "The additional size that a creature grows each star level.", advanced: true, 0f, 2f);
			PerLevelScaleBonus.SettingChanged += Colorization.StarLevelScaleChanged;
			EnableScalingInDungeons = BindServerConfig("LevelSystem", "EnableScalingInDungeons", value: false, "Enables scaling in dungeons, this can cause creatures to become stuck.");
			EnableColorization = BindServerConfig("LevelSystem", "EnableColorization", value: true, "Enables this mods colorization of creatures based on their star level.");
			EnemyHealthMultiplier = BindServerConfig("LevelSystem", "EnemyHealthMultiplier", 1f, "The amount of health that each level gives a creature, vanilla is 1x.", advanced: false, 0f, 5f);
			EnemyHealthPerWorldLevel = BindServerConfig("LevelSystem", "EnemyHealthPerWorldLevel", 0.2f, "The percent amount of health that each world level gives a creature, vanilla is 2x (eg 200% more health each world level).", advanced: false, 0f, 2f);
			EnemyDamageLevelMultiplier = BindServerConfig("LevelSystem", "EnemyDamageLevelMultiplier", 0.1f, "The amount of damage that each level gives a creatures, vanilla is 0.5x (eg 50% more damage each level).", advanced: false, 0f, 2f);
			BossEnemyHealthMultiplier = BindServerConfig("LevelSystem", "BossEnemyHealthMultiplier", 0.3f, "The amount of health that each level gives a boss. 1 is 100% more health per level.", advanced: false, 0f, 5f);
			BossEnemyDamageMultiplier = BindServerConfig("LevelSystem", "BossEnemyDamageMultiplier", 0.02f, "The amount of damage that each level gives a boss. 1 is 100% more damage per level.", advanced: false, 0f, 5f);
			RandomizeTameChildrenLevels = BindServerConfig("LevelSystem", "RandomizeTameLevels", value: false, "Randomly rolls bred creature levels, instead of inheriting from parent.");
			SpawnMultiplicationAppliesToTames = BindServerConfig("LevelSystem", "SpawnMultiplicationAppliesToTames", value: false, "Spawn multipliers set on creature or biome will apply to produced tames when enabled.");
			BossCreaturesNeverSpawnMultiply = BindServerConfig("LevelSystem", "BossCreaturesNeverSpawnMultiply", value: true, "Boss creatures never have spawn multipliers applied to them.");
			EnableScalingBirds = BindServerConfig("LevelSystem", "EnableScalingBirds", value: true, "Enables birds to scale with the level system. This will cause them to become larger and give more drops.");
			BirdSizeScalePerLevel = BindServerConfig("LevelSystem", "BirdSizeScalePerLevel", 0.1f, "The amount of size that birds gain per level. 0.1 = 10% larger per level.", advanced: true, 0f, 2f);
			EnableScalingFish = BindServerConfig("LevelSystem", "EnableScalingFish", value: true, "Enables star scaling for fish. This does potentially allow huge fish.");
			FishSizeScalePerLevel = BindServerConfig("LevelSystem", "FishSizeScalePerLevel", 0.1f, "The amount of size that fish gain per level 0.1 = 10% larger per level.");
			EnableTreeScaling = BindServerConfig("LevelSystem", "EnableTreeScaling", value: true, "Enables level scaling of trees. Make the trees bigger than reasonable? sure why not.");
			TreeSizeScalePerLevel = BindServerConfig("LevelSystem", "TreeSizeScalePerLevel", 0.1f, "The amount of size that trees gain per level 0.1 = 10% larger per level.");
			MultiplayerEnemyDamageModifier = BindServerConfig("Multiplayer", "MultiplayerEnemyDamageModifier", 0.05f, "The additional amount of damage enemies will do to players, when there is a group of players together, per player. .2 = 20%. Vanilla gives creatures 4% more damage per player nearby.", advanced: true, 0f, 2f);
			MultiplayerEnemyHealthModifier = BindServerConfig("Multiplayer", "MultiplayerEnemyHealthModifier", 0.2f, "Enemies take reduced damage when there is a group of players, vanilla gives creatures 30% damage resistance per player nearby.", advanced: true, 0f, 0.99f);
			MultiplayerScalingRequiredPlayersNearby = BindServerConfig("Multiplayer", "MultiplayerScalingRequiredPlayersNearby", 3, "The number of players in a local area required to cause monsters to gain bonus health and/or damage.", advanced: true, 1, 20);
			EnableMultiplayerEnemyHealthScaling = BindServerConfig("Multiplayer", "EnableMultiplayerEnemyHealthScaling", value: true, "Wether or not creatures gain more health when players are grouped up.");
			EnableMultiplayerEnemyDamageScaling = BindServerConfig("Multiplayer", "EnableMultiplayerEnemyDamageScaling", value: false, "Wether or not creatures gain more damage when players are grouped up.");
			ControlSpawnerLevels = BindServerConfig("LevelSystem", "ControlSpawnerLevels", value: true, "Overrides spawner levels to be controlled by SLS (this impacts all naturally spawning creatures)");
			ControlAbilitySpawnedCreatures = BindServerConfig("LevelSystem", "ControlAbilitySpawnedCreatures", value: true, "Forces creatures spawned from abilities to be controlled by SLS. This primarily impacts things such as the roots from Elder.");
			ControlBossSpawns = BindServerConfig("LevelSystem", "ControlBossSpawns", value: true, "Forces boss creatures to be controlled by SLS. Bosses will not get star levels if this is disabled.");
			ForceControlAllSpawns = BindServerConfig("LevelSystem", "ForceControlAllSpawns", value: false, "Forces all creatures to be controlled by SLS, this includes creatures spawned from player abilities and items. This will override creature levels, other mods must use the API to ensure their spawned creature levels are set.");
			SpawnsAlwaysControlled = BindServerConfig("LevelSystem", "SpawnsAlwaysControlled", "piece_TrainingDummy", "A list of creatures which always get their level set");
			SpawnsAlwaysControlled.SettingChanged += ModificationExtensionSystem.LeveledCreatureListChanged;
			ModificationExtensionSystem.SetupForceLeveledCreatureList();
			PerLevelLootScale = BindServerConfig("LootSystem", "PerLevelLootScale", 1f, "The amount of additional loot that a creature provides per each star level", advanced: false, 0f, 4f);
			LootDropCalculationType = BindServerConfig("LootSystem", "LootDropCaluationType", "PerLevel", "The type of loot calculation to use. Per Level ", LootLevelsExpanded.AllowedLootFactors);
			LootDropCalculationType.SettingChanged += LootLevelsExpanded.LootFactorChanged;
			LootDropsPerTick = BindServerConfig("LootSystem", "LootDropsPerTick", 20, "The number of loot drops that are generated per tick, reducing this will reduce lag when massive amounts of loot is generated at once.", advanced: true, 1, 100);
			MaxMajorModifiersPerCreature = BindServerConfig("Modifiers", "DefaultMajorModifiersPerCreature", 1, "The default number of major modifiers that a creature can have.");
			MaxMinorModifiersPerCreature = BindServerConfig("Modifiers", "MaxMinorModifiersPerCreature", 1, "The default number of minor modifiers that a creature can have.");
			LimitCreatureModifiersToCreatureStarLevel = BindServerConfig("Modifiers", "LimitCreatureModifiersToCreatureStarLevel", value: true, "Limits the number of modifiers that a creature can have based on its level.");
			ChanceMajorModifier = BindServerConfig("Modifiers", "ChanceMajorModifier", 0.15f, "The chance that a creature will have a major modifier (creatures can have BOTH major and minor modifiers).", advanced: false, 0f, 1f);
			ChanceMajorModifier.SettingChanged += CreatureModifiersData.ClearProbabilityCaches;
			ChanceMinorModifier = BindServerConfig("Modifiers", "ChanceMinorModifier", 0.25f, "The chance that a creature will have a minor modifier (creatures can have BOTH major and minor modifiers).", advanced: false, 0f, 1f);
			ChanceMinorModifier.SettingChanged += CreatureModifiersData.ClearProbabilityCaches;
			EnableBossModifiers = BindServerConfig("Modifiers", "EnableBossModifiers", value: true, "Wether or not bosses can spawn with modifiers.");
			ChanceOfBossModifier = BindServerConfig("Modifiers", "ChanceOfBossModifier", 0.75f, "The chance that a boss will have a modifier.", advanced: false, 0f, 1f);
			ChanceOfBossModifier.SettingChanged += CreatureModifiersData.ClearProbabilityCaches;
			MaxBossModifiersPerBoss = BindServerConfig("Modifiers", "MaxBossModifiersPerBoss", 2, "The maximum number of modifiers that a boss can have.");
			SplittersInheritLevel = BindServerConfig("Modifiers", "SplittersInheritLevel", value: true, "Wether or not creatures spawned from the Splitter modifier inherit the level of the parent creature.");
			NumberOfCacheUpdatesPerFrame = BindServerConfig("Misc", "NumberOfCacheUpdatesPerFrame", 10, "Number of cache updates to process when performing live updates", advanced: true, 1);
			OutputColorizationGeneratorsData = BindServerConfig("Misc", "OutputColorizationGeneratorsData", value: false, "Writes out color generators to a debug file. This can be useful if you want to hand pick color settings from generated values.");
		}

		internal void LoadYamlConfigs()
		{
			string[] files = Directory.GetFiles(GetSecondaryConfigDirectoryPath());
			bool flag = false;
			bool flag2 = false;
			bool flag3 = false;
			bool flag4 = false;
			string[] array = files;
			foreach (string text in array)
			{
				if (text.Contains("LevelSettings.yaml"))
				{
					Logger.LogDebug("Found level configuration: " + text);
					levelsFilePath = text;
					flag = true;
				}
				if (text.Contains("ColorSettings.yaml"))
				{
					Logger.LogDebug("Found color configuration: " + text);
					colorsFilePath = text;
					flag2 = true;
				}
				if (text.Contains("LootSettings.yaml"))
				{
					Logger.LogDebug("Found loot configuration: " + text);
					creatureLootFilePath = text;
					flag3 = true;
				}
				if (text.Contains("Modifiers.yaml"))
				{
					Logger.LogDebug("Found modifier configuration: " + text);
					creatureModifierFilePath = text;
					flag4 = true;
				}
			}
			if (!flag4)
			{
				Logger.LogDebug("Loot config missing, recreating.");
				using StreamWriter streamWriter = new StreamWriter(creatureModifierFilePath);
				string value = "#################################################\n# Star Level System Expanded - Creature Modifier Configuration\n#################################################\n";
				streamWriter.WriteLine(value);
				streamWriter.WriteLine(CreatureModifiersData.GetModifierDefaultConfig());
			}
			if (!flag3)
			{
				Logger.LogDebug("Loot config missing, recreating.");
				using StreamWriter streamWriter2 = new StreamWriter(creatureLootFilePath);
				string value2 = "#################################################\n# Star Level System Expanded - Creature loot configuration\n#################################################\n";
				streamWriter2.WriteLine(value2);
				streamWriter2.WriteLine(LootSystemData.YamlDefaultConfig());
			}
			if (!flag)
			{
				Logger.LogDebug("Level config file missing, recreating.");
				using StreamWriter streamWriter3 = new StreamWriter(levelsFilePath);
				string value3 = "#################################################\n# Star Level System Expanded - Level Settings\n#################################################\n";
				streamWriter3.WriteLine(value3);
				streamWriter3.WriteLine(LevelSystemData.YamlDefaultConfig());
			}
			if (!flag2)
			{
				Logger.LogDebug("Color config file missing, recreating.");
				using StreamWriter streamWriter4 = new StreamWriter(colorsFilePath);
				string value4 = "#################################################\n# Star Level System Expanded - Creature Level Color Settings\n#################################################\n";
				streamWriter4.WriteLine(value4);
				streamWriter4.WriteLine(Colorization.YamlDefaultConfig());
			}
			SetupFileWatcher("ColorSettings.yaml");
			SetupFileWatcher("LevelSettings.yaml");
			SetupFileWatcher("Modifiers.yaml");
			SetupFileWatcher("CreatureLootSettings.yaml");
		}

		private void SetupFileWatcher(string filtername)
		{
			FileSystemWatcher fileSystemWatcher = new FileSystemWatcher();
			fileSystemWatcher.Path = GetSecondaryConfigDirectoryPath();
			fileSystemWatcher.NotifyFilter = NotifyFilters.LastWrite;
			fileSystemWatcher.Filter = filtername;
			fileSystemWatcher.Changed += UpdateConfigFileOnChange;
			fileSystemWatcher.Created += UpdateConfigFileOnChange;
			fileSystemWatcher.Renamed += UpdateConfigFileOnChange;
			fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject;
			fileSystemWatcher.EnableRaisingEvents = true;
		}

		private static void UpdateConfigFileOnChange(object sender, FileSystemEventArgs e)
		{
			if (!SynchronizationManager.Instance.PlayerIsAdmin)
			{
				Logger.LogInfo("Player is not an admin, and not allowed to change local configuration. Ignoring.");
			}
			else if (File.Exists(e.FullPath))
			{
				string yaml = File.ReadAllText(e.FullPath);
				FileInfo fileInfo = new FileInfo(e.FullPath);
				Logger.LogDebug("Filewatch changes from: (" + fileInfo.Name + ") " + fileInfo.FullName);
				switch (fileInfo.Name)
				{
				case "ColorSettings.yaml":
					Logger.LogDebug("Triggering Color Settings update.");
					Colorization.UpdateYamlConfig(yaml);
					ColorSettingsRPC.SendPackage(ZNet.instance.m_peers, SendFileAsZPackage(e.FullPath));
					break;
				case "LevelSettings.yaml":
					Logger.LogDebug("Triggering Level Settings update.");
					LevelSystemData.UpdateYamlConfig(yaml);
					LevelSettingsRPC.SendPackage(ZNet.instance.m_peers, SendFileAsZPackage(e.FullPath));
					break;
				case "CreatureLootSettings.yaml":
					Logger.LogDebug("Triggering Loot Settings update.");
					LootSystemData.UpdateYamlConfig(yaml);
					CreatureLootSettingsRPC.SendPackage(ZNet.instance.m_peers, SendFileAsZPackage(e.FullPath));
					break;
				case "Modifiers.yaml":
					Logger.LogDebug("Triggering Modifiers Settings update.");
					CreatureModifiersData.UpdateModifierConfig(yaml);
					ModifiersRPC.SendPackage(ZNet.instance.m_peers, SendFileAsZPackage(e.FullPath));
					break;
				}
			}
		}

		private static ZPackage SendFileAsZPackage(string filepath)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			string text = File.ReadAllText(filepath);
			ZPackage val = new ZPackage();
			val.Write(text);
			return val;
		}

		private static ZPackage SendLevelsConfigs()
		{
			return SendFileAsZPackage(levelsFilePath);
		}

		private static ZPackage SendCreatureLootConfigs()
		{
			return SendFileAsZPackage(creatureLootFilePath);
		}

		private static ZPackage SendColorsConfigs()
		{
			return SendFileAsZPackage(colorsFilePath);
		}

		private static ZPackage SendModifierConfigs()
		{
			return SendFileAsZPackage(creatureModifierFilePath);
		}

		[IteratorStateMachine(typeof(<OnServerRecieveConfigs>d__69))]
		public static IEnumerator OnServerRecieveConfigs(long sender, ZPackage package)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <OnServerRecieveConfigs>d__69(0);
		}

		[IteratorStateMachine(typeof(<OnClientReceiveLevelConfigs>d__70))]
		private static IEnumerator OnClientReceiveLevelConfigs(long sender, ZPackage package)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <OnClientReceiveLevelConfigs>d__70(0)
			{
				package = package
			};
		}

		[IteratorStateMachine(typeof(<OnClientReceiveColorConfigs>d__71))]
		private static IEnumerator OnClientReceiveColorConfigs(long sender, ZPackage package)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <OnClientReceiveColorConfigs>d__71(0)
			{
				package = package
			};
		}

		[IteratorStateMachine(typeof(<OnClientReceiveCreatureLootConfigs>d__72))]
		private static IEnumerator OnClientReceiveCreatureLootConfigs(long sender, ZPackage package)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <OnClientReceiveCreatureLootConfigs>d__72(0)
			{
				package = package
			};
		}

		[IteratorStateMachine(typeof(<OnClientReceiveModifiersConfigs>d__73))]
		private static IEnumerator OnClientReceiveModifiersConfigs(long sender, ZPackage package)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <OnClientReceiveModifiersConfigs>d__73(0)
			{
				package = package
			};
		}

		public static string GetSecondaryConfigDirectoryPath()
		{
			return Directory.CreateDirectory(Path.Combine(Paths.ConfigPath, "StarLevelSystem")).FullName;
		}

		public static ConfigEntry<bool> BindServerConfig(string catagory, string key, bool value, string description, AcceptableValueBase acceptableValues = null, bool advanced = false)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			return cfg.Bind<bool>(catagory, key, value, new ConfigDescription(description, acceptableValues, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true,
				IsAdvanced = advanced
			} }));
		}

		public static ConfigEntry<int> BindServerConfig(string catagory, string key, int value, string description, bool advanced = false, int valmin = 0, int valmax = 150)
		{
			//IL_001a: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			return cfg.Bind<int>(catagory, key, value, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<int>(valmin, valmax), new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true,
				IsAdvanced = advanced
			} }));
		}

		public static ConfigEntry<float> BindServerConfig(string catagory, string key, float value, string description, bool advanced = false, float valmin = 0f, float valmax = 150f)
		{
			//IL_001a: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			return cfg.Bind<float>(catagory, key, value, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<float>(valmin, valmax), new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true,
				IsAdvanced = advanced
			} }));
		}

		public static ConfigEntry<string> BindServerConfig(string catagory, string key, string value, string description, AcceptableValueList<string> acceptableValues = null, bool advanced = false)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			return cfg.Bind<string>(catagory, key, value, new ConfigDescription(description, (AcceptableValueBase)(object)acceptableValues, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true,
				IsAdvanced = advanced
			} }));
		}
	}
	internal class Logger
	{
		public static LogLevel Level = (LogLevel)16;

		public static void enableDebugLogging(object sender, EventArgs e)
		{
			//IL_0016: 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)
			if (ValConfig.EnableDebugMode.Value)
			{
				Level = (LogLevel)32;
			}
			else
			{
				Level = (LogLevel)16;
			}
		}

		public static void CheckEnableDebugLogging()
		{
			//IL_0016: 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)
			if (ValConfig.EnableDebugMode.Value)
			{
				Level = (LogLevel)32;
			}
			else
			{
				Level = (LogLevel)16;
			}
		}

		public static void LogDebug(string message)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			if ((int)Level >= 32)
			{
				StarLevelSystem.Log.LogInfo((object)message);
			}
		}

		public static void LogInfo(string message)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			if ((int)Level >= 16)
			{
				StarLevelSystem.Log.LogInfo((object)message);
			}
		}

		public static void LogWarning(string message)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			if ((int)Level >= 4)
			{
				StarLevelSystem.Log.LogWarning((object)message);
			}
		}

		public static void LogError(string message)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			if ((int)Level >= 2)
			{
				StarLevelSystem.Log.LogError((object)message);
			}
		}
	}
	[BepInPlugin("MidnightsFX.StarLevelSystem", "StarLevelSystem", "0.11.4")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	[BepInIncompatibility("org.bepinex.plugins.creaturelevelcontrol")]
	internal class StarLevelSystem : BaseUnityPlugin
	{
		public const string PluginGUID = "MidnightsFX.StarLevelSystem";

		public const string PluginName = "StarLevelSystem";

		public const string PluginVersion = "0.11.4";

		public ValConfig cfg;

		public static CustomLocalization Localization = LocalizationManager.Instance.GetLocalization();

		public static AssetBundle EmbeddedResourceBundle;

		public static ManualLogSource Log;

		public static Harmony HarmonyInstance { get; private set; }

		public void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			cfg = new ValConfig(((BaseUnityPlugin)this).Config);
			cfg.SetupConfigRPCs();
			cfg.LoadYamlConfigs();
			EmbeddedResourceBundle = AssetUtils.LoadAssetBundleFromResources("StarLevelSystem.assets.starlevelsystems", typeof(StarLevelSystem).Assembly);
			HarmonyInstance = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "MidnightsFX.StarLevelSystem");
			Colorization.Init();
			LevelSystemData.Init();
			LootSystemData.Init();
			CreatureModifiersData.Init();
			LocalizationLoader.AddLocalizations();
			PrefabManager.OnVanillaPrefabsAvailable += CreatureModifiersData.LoadPrefabs;
			PrefabManager.OnVanillaPrefabsAvailable += LevelSystem.UpdateMaxLevel;
			PrefabManager.OnPrefabsRegistered += LootSystemData.AttachPrefabsWhenReady;
			MinimapManager.OnVanillaMapAvailable += LevelSystem.CreateLevelBonusRingMapOverlays;
			ZoneManager.OnVanillaLocationsAvailable += LevelSystem.SetRingCenter;
			TerminalCommands.AddCommands();
		}
	}
}
namespace StarLevelSystem.modules
{
	public static class APIReciever
	{
		public static bool UpdateCreatureLevel(Character chara, int level)
		{
			DataObjects.CreatureDetailCache andSetDetailCache = CompositeLazyCache.GetAndSetDetailCache(chara);
			if (andSetDetailCache == null)
			{
				return false;
			}
			andSetDetailCache.Level = level;
			CompositeLazyCache.UpdateCacheEntry(chara, andSetDetailCache);
			LevelSystem.SetAndUpdateCharacterLevel(chara, andSetDetailCache.Level);
			return true;
		}

		public static bool UpdateCreatureColorization(Character chara, float value, float hue, float sat, bool emission = false)
		{
			DataObjects.CreatureDetailCache andSetDetailCache = CompositeLazyCache.GetAndSetDetailCache(chara);
			if (andSetDetailCache == null)
			{
				return false;
			}
			andSetDetailCache.Colorization = new DataObjects.ColorDef(hue, sat, value, emission);
			CompositeLazyCache.UpdateCacheEntry(chara, andSetDetailCache);
			Colorization.ApplyColorizationWithoutLevelEffects(((Component)chara).gameObject, andSetDetailCache.Colorization);
			return true;
		}

		public static float GetBaseAttributeValue(Character chara, int attribute)
		{
			return CompositeLazyCache.GetAndSetDetailCache(chara)?.CreatureBaseValueModifiers[(DataObjects.CreatureBaseAttribute)attribute] ?? (-1f);
		}

		public static bool UpdateCreatureBaseAttributes(Character chara, int attribute, float value)
		{
			DataObjects.CreatureDetailCache andSetDetailCache = CompositeLazyCache.GetAndSetDetailCache(chara);
			if (andSetDetailCache == null)
			{
				return false;
			}
			andSetDetailCache.CreatureBaseValueModifiers[(DataObjects.CreatureBaseAttribute)attribute] = value;
			return true;
		}

		public static Dictionary<int, float> GetAllBaseAttributes(Character chara)
		{
			DataObjects.CreatureDetailCache andSetDetailCache = CompositeLazyCache.GetAndSetDetailCache(chara);
			if (andSetDetailCache == null)
			{
				return null;
			}
			Dictionary<int, float> dictionary = new Dictionary<int, float>();
			foreach (KeyValuePair<DataObjects.CreatureBaseAttribute, float> creatureBaseValueModifier in andSetDetailCache.CreatureBaseValueModifiers)
			{
				dictionary[(int)creatureBaseValueModifier.Key] = creatureBaseValueModifier.Value;
			}
			return dictionary;
		}

		public static bool SetAllBaseAttributes(Character chara, Dictionary<int, float> attributes)
		{
			DataObjects.CreatureDetailCache andSetDetailCache = CompositeLazyCache.GetAndSetDetailCache(chara);
			if (andSetDetailCache == null)
			{
				return false;
			}
			foreach (KeyValuePair<int, float> attribute in attributes)
			{
				andSetDetailCache.CreatureBaseValueModifiers[(DataObjects.CreatureBaseAttribute)attribute.Key] = attribute.Value;
			}
			CompositeLazyCache.UpdateCacheEntry(chara, andSetDetailCache);
			ModificationExtensionSystem.ApplySpeedModifications(chara, andSetDetailCache);
			ModificationExtensionSystem.ApplyDamageModification(chara, andSetDetailCache);
			ModificationExtensionSystem.LoadApplySizeModifications(((Component)chara).gameObject, chara.m_nview, andSetDetailCache, force_update: true);
			ModificationExtensionSystem.ApplyHealthModifications(chara, andSetDetailCache);
			return true;
		}

		public static float GetPerLevelAttributeValue(Character chara, int attribute)
		{
			return CompositeLazyCache.GetAndSetDetailCache(chara)?.CreaturePerLevelValueModifiers[(DataObjects.CreaturePerLevelAttribute)attribute] ?? (-1f);
		}

		public static bool UpdateCreaturePerLevelAttributes(Character chara, int attribute, float value)
		{
			DataObjects.CreatureDetailCache andSetDetailCache = CompositeLazyCache.GetAndSetDetailCache(chara);
			if (andSetDetailCache == null)
			{
				return false;
			}
			andSetDetailCache.CreaturePerLevelValueModifiers[(DataObjects.CreaturePerLevelAttribute)attribute] = value;
			return true;
		}

		public static Dictionary<int, float> GetAllPerLevelAttributes(Character chara)
		{
			DataObjects.CreatureDetailCache andSetDetailCache = CompositeLazyCache.GetAndSetDetailCache(chara);
			if (andSetDetailCache == null)
			{
				return null;
			}
			Dictionary<int, float> dictionary = new Dictionary<int, float>();
			foreach (KeyValuePair<DataObjects.CreaturePerLevelAttribute, float> creaturePerLevelValueModifier in andSetDetailCache.CreaturePerLevelValueModifiers)
			{
				dictionary[(int)creaturePerLevelValueModifier.Key] = creaturePerLevelValueModifier.Value;
			}
			return dictionary;
		}

		public static bool SetAllPerLevelAttributes(Character chara, Dictionary<int, float> attributes)
		{
			DataObjects.CreatureDetailCache andSetDetailCache = CompositeLazyCache.GetAndSetDetailCache(chara);
			if (andSetDetailCache == null)
			{
				return false;
			}
			foreach (KeyValuePair<int, float> attribute in attributes)
			{
				andSetDetailCache.CreaturePerLevelValueModifiers[(DataObjects.CreaturePerLevelAttribute)attribute.Key] = attribute.Value;
			}
			CompositeLazyCache.UpdateCacheEntry(chara, andSetDetailCache);
			ModificationExtensionSystem.ApplySpeedModifications(chara, andSetDetailCache);
			ModificationExtensionSystem.ApplyDamageModification(chara, andSetDetailCache);
			ModificationExtensionSystem.LoadApplySizeModifications(((Component)chara).gameObject, chara.m_nview, andSetDetailCache, force_update: true);
			ModificationExtensionSystem.ApplyHealthModifications(chara, andSetDetailCache);
			return true;
		}

		public static float GetCreatureDamageRecievedModifier(Character chara, int attribute)
		{
			return CompositeLazyCache.GetAndSetDetailCache(chara)?.DamageRecievedModifiers[(DataObjects.DamageType)attribute] ?? (-1f);
		}

		public static bool UpdateCreatureDamageRecievedModifier(Character chara, int attribute, float value)
		{
			DataObjects.CreatureDetailCache andSetDetailCache = CompositeLazyCache.GetAndSetDetailCache(chara);
			if (andSetDetailCache == null)
			{
				return false;
			}
			andSetDetailCache.DamageRecievedModifiers[(DataObjects.DamageType)attribute] = value;
			return true;
		}

		public static Dictionary<int, float> GetAllDamageRecievedModifiers(Character chara)
		{
			DataObjects.CreatureDetailCache andSetDetailCache = CompositeLazyCache.GetAndSetDetailCache(chara);
			if (andSetDetailCache == null)
			{
				return null;
			}
			Dictionary<int, float> dictionary = new Dictionary<int, float>();
			foreach (KeyValuePair<DataObjects.DamageType, float> damageRecievedModifier in andSetDetailCache.DamageRecievedModifiers)
			{
				dictionary[(int)damageRecievedModifier.Key] = damageRecievedModifier.Value;
			}
			return dictionary;
		}

		public static bool SetAllDamageRecievedModifiers(Character chara, Dictionary<int, float> attributes)
		{
			DataObjects.CreatureDetailCache andSetDetailCache = CompositeLazyCache.GetAndSetDetailCache(chara);
			if (andSetDetailCache == null)
			{
				return false;
			}
			foreach (KeyValuePair<int, float> attribute in attributes)
			{
				andSetDetailCache.DamageRecievedModifiers[(DataObjects.DamageType)attribute.Key] = attribute.Value;
			}
			CompositeLazyCache.UpdateCacheEntry(chara, andSetDetailCache);
			ModificationExtensionSystem.ApplyDamageModification(chara, andSetDetailCache);
			return true;
		}

		public static float GetCreatureDamageBonus(Character chara, int attribute)
		{
			DataObjects.CreatureDetailCache andSetDetailCache = CompositeLazyCache.GetAndSetDetailCache(chara);
			if (andSetDetailCache == null)
			{
				return -1f;
			}
			if (andSetDetailCache.CreatureDamageBonus.ContainsKey((DataObjects.DamageType)attribute))
			{
				return andSetDetailCache.CreatureDamageBonus[(DataObjects.DamageType)attribute];
			}
			return 0f;
		}

		public static bool UpdateCreatureDamageBonus(Character chara, int attribute, float value)
		{
			DataObjects.CreatureDetailCache andSetDetailCache = CompositeLazyCache.GetAndSetDetailCache(chara);
			if (andSetDetailCache == null)
			{
				return false;
			}
			if (!andSetDetailCache.CreatureDamageBonus.ContainsKey((DataObjects.DamageType)attribute))
			{
				andSetDetailCache.CreatureDamageBonus[(DataObjects.DamageType)attribute] = value;
			}
			else
			{
				andSetDetailCache.CreatureDamageBonus.Add((DataObjects.DamageType)attribute, value);
			}
			return true;
		}

		public static Dictionary<int, float> GetAllDamageBonus(Character chara)
		{
			DataObjects.CreatureDetailCache andSetDetailCache = CompositeLazyCache.GetAndSetDetailCache(chara);
			if (andSetDetailCache == null)
			{
				return null;
			}
			Dictionary<int, float> dictionary = new Dictionary<int, float>();
			foreach (KeyValuePair<DataObjects.DamageType, float> creatureDamageBonu in andSetDetailCache.CreatureDamageBonus)
			{
				dictionary[(int)creatureDamageBonu.Key] = creatureDamageBonu.Value;
			}
			return dictionary;
		}

		public static bool SetAllDamageBonus(Character chara, Dictionary<int, float> attributes)
		{
			DataObjects.CreatureDetailCache andSetDetailCache = CompositeLazyCache.GetAndSetDetailCache(chara);
			if (andSetDetailCache == null)
			{
				return false;
			}
			foreach (KeyValuePair<int, float> attribute in attributes)
			{
				if (!andSetDetailCache.CreatureDamageBonus.ContainsKey((DataObjects.DamageType)attribute.Key))
				{
					andSetDetailCache.CreatureDamageBonus[(DataObjects.DamageType)attribute.Key] = attribute.Value;
				}
				else
				{
					andSetDetailCache.CreatureDamageBonus.Add((DataObjects.DamageType)attribute.Key, attribute.Value);
				}
			}
			CompositeLazyCache.UpdateCacheEntry(chara, andSetDetailCache);
			ModificationExtensionSystem.ApplyDamageModification(chara, andSetDetailCache);
			return true;
		}

		public static bool ApplyUpdatesToCreature(Character chara)
		{
			DataObjects.CreatureDetailCache andSetDetailCache = CompositeLazyCache.GetAndSetDetailCache(chara);
			if (andSetDetailCache == null)
			{
				return false;
			}
			ModificationExtensionSystem.ApplySpeedModifications(chara, andSetDetailCache);
			ModificationExtensionSystem.ApplyDamageModification(chara, andSetDetailCache);
			ModificationExtensionSystem.LoadApplySizeModifications(((Component)chara).gameObject, chara.m_nview, andSetDetailCache, force_update: true);
			ModificationExtensionSystem.ApplyHealthModifications(chara, andSetDetailCache);
			return true;
		}

		public static List<string> GetPossibleModifiersForType(int modifierType)
		{
			List<string> list = new List<string>();
			switch (modifierType)
			{
			case 0:
				foreach (string key in CreatureModifiersData.ActiveCreatureModifiers.MajorModifiers.Keys)
				{
					list.Add(key);
				}
				break;
			case 1:
				foreach (string key2 in CreatureModifiersData.ActiveCreatureModifiers.MinorModifiers.Keys)
				{
					list.Add(key2);
				}
				break;
			case 2:
				foreach (string key3 in CreatureModifiersData.ActiveCreatureModifiers.BossModifiers.Keys)
				{
					list.Add(key3);
				}
				break;
			default:
				Logger.LogWarning($"Invalid modifier type {modifierType} passed to GetAllPossibleModifiers. Valid types are 0 (Major), 1 (Minor), 2 (Boss).");
				break;
			}
			return list;
		}

		public static Dictionary<string, int> GetAllModifiersForCreature(Character chara)
		{
			DataObjects.CreatureDetailCache andSetDetailCache = CompositeLazyCache.GetAndSetDetailCache(chara);
			if (andSetDetailCache == null)
			{
				return null;
			}
			Dictionary<string, int> dictionary = new Dictionary<string, int>();
			foreach (KeyValuePair<string, DataObjects.ModifierType> modifier in andSetDetailCache.Modifiers)
			{
				dictionary.Add(modifier.Key.ToString(), (int)modifier.Value);
			}
			return dictionary;
		}

		public static bool AddModifierToCreature(Character chara, string modifierName, int modifierType, bool update = true)
		{
			if (CompositeLazyCache.GetAndSetDetailCache(chara) == null)
			{
				return false;
			}
			return CreatureModifiers.AddCreatureModifier(chara, (DataObjects.ModifierType)modifierType, modifierName, update);
		}

		public static bool AddNewModifierToSLS(int modifierID, string modifier_name, string setupMethod = null, float selectionWeight = 10f, float basepower = 0f, float perlevelpower = 0f, Dictionary<Biome, List<string>> biomeConfig = null, int namingStyle = 2, List<string> name_suffixes = null, List<string> name_prefixes = null, int visualStyle = 0, Sprite starIcon = null, GameObject visualEffect = null, List<string> allowed_creatures = null, List<string> unallowed_creatures = null, List<Biome> allowed_biomes = null)
		{
			if (CreatureModifiersData.ModifierNamesLookupTable.ContainsID(modifierID))
			{
				Logger.LogWarning($"Modifier ID {modifierID} already exists as {CreatureModifiersData.ModifierNamesLookupTable.GetValue(modifierID)}, please choose a different ID");
				return false;
			}
			CreatureModifiersData.ModifierNamesLookupTable.AddValue(modifier_name, modifierID);
			DataObjects.CreatureModifier creatureModifier = new DataObjects.CreatureModifier();
			creatureModifier.SelectionWeight = selectionWeight;
			if ((Object)(object)starIcon != (Object)null)
			{
				creatureModifier.StarVisualAPI = starIcon;
				creatureModifier.StarVisual = ((Object)starIcon).name;
			}
			if ((Object)(object)visualEffect != (Object)null)
			{
				creatureModifier.VisualEffectAPI = visualEffect;
				creatureModifier.VisualEffect = ((Object)visualEffect).name;
			}
			if (setupMethod != null)
			{
				creatureModifier.SetupMethodClass = setupMethod;
			}
			creatureModifier.Config = new DataObjects.CreatureModConfig
			{
				BasePower = basepower,
				PerlevelPower = perlevelpower,
				BiomeObjects = biomeConfig
			};
			if (namingStyle > 2 || namingStyle < 0)
			{
				namingStyle = 2;
			}
			creatureModifier.namingConvention = (DataObjects.NameSelectionStyle)namingStyle;
			if (name_suffixes != null)
			{
				creatureModifier.NameSuffixes = name_suffixes;
			}
			if (name_prefixes != null)
			{
				creatureModifier.NamePrefixes = name_prefixes;
			}
			if (visualStyle > 3 || visualStyle < 0)
			{
				visualStyle = 0;
			}
			creatureModifier.VisualEffectStyle = (DataObjects.VisualEffectStyle)visualStyle;
			if (allowed_creatures != null)
			{
				creatureModifier.AllowedCreatures = allowed_creatures;
			}
			if (unallowed_creatures != null)
			{
				creatureModifier.UnallowedCreatures = unallowed_creatures;
			}
			if (allowed_biomes != null)
			{
				creatureModifier.AllowedBiomes = allowed_biomes;
			}
			CreatureModifiersData.ClearProbabilityCaches();
			return true;
		}
	}
	public static class Colorization
	{
		[HarmonyPatch(typeof(LevelEffects), "SetupLevelVisualization")]
		public static class PreventDefaultLevelSetup
		{
			public static bool Prefix()
			{
				return false;
			}
		}

		public static DataObjects.CreatureColorizationSettings creatureColorizationSettings = defaultColorizationSettings;

		private static DataObjects.CreatureColorizationSettings defaultColorizationSettings = new DataObjects.CreatureColorizationSettings
		{
			characterSpecificColorization = ColorizationData.characterColorizationData,
			defaultLevelColorization = ColorizationData.defaultColorizationData,
			characterColorGenerators = ColorizationData.defaultColorGenerators
		};

		public static List<Color> mapRingColors = new List<Color>();

		public static readonly Dictionary<string, string> defaultColors = new Dictionary<string, string>
		{
			{ "Red", "#ff1a1a" },
			{ "Orange", "#ff9933" },
			{ "Yellow", "#ffff1a" },
			{ "Green", "#50f83a" },
			{ "Teal", "#18e7a9" },
			{ "Blue", "#00abff" },
			{ "Purple", "#c966ff" },
			{ "Pink", "#ff4dcf" },
			{ "Gray", "#999999" },
			{ "Brown", "#b37700" },
			{ "Black", "#333333" },
			{ "White", "#f2f2f2" }
		};

		public static DataObjects.ColorDef defaultColorization = new DataObjects.ColorDef
		{
			hue = 0f,
			saturation = 0f,
			value = 0f,
			IsEmissive = false
		};

		public static void Init()
		{
			creatureColorizationSettings = defaultColorizationSettings;
			try
			{
				UpdateYamlConfig(File.ReadAllText(ValConfig.colorsFilePath));
			}
			catch (Exception arg)
			{
				Logger.LogWarning((object)$"There was an error updating the Color Level values, defaults will be used. Exception: {arg}");
			}
		}

		public static string YamlDefaultConfig()
		{
			return DataObjects.yamlserializer.Serialize((object)defaultColorizationSettings);
		}

		public static bool UpdateYamlConfig(string yaml)
		{
			try
			{
				creatureColorizationSettings = DataObjects.yamldeserializer.Deserialize<DataObjects.CreatureColorizationSettings>(yaml);
				foreach (KeyValuePair<int, DataObjects.ColorDef> item in defaultColorizationSettings.defaultLevelColorization)
				{
					if (!creatureColorizationSettings.defaultLevelColorization.Keys.Contains(item.Key))
					{
						creatureColorizationSettings.defaultLevelColorization.Add(item.Key, item.Value);
					}
				}
				if (creatureColorizationSettings.characterColorGenerators != null)
				{
					Logger.LogInfo("Running color generators");
					foreach (KeyValuePair<string, List<DataObjects.ColorRangeDef>> characterColorGenerator in creatureColorizationSettings.characterColorGenerators)
					{
						Logger.LogInfo("Building color range for " + characterColorGenerator.Key);
						foreach (DataObjects.ColorRangeDef item2 in characterColorGenerator.Value)
						{
							BuildAddColorRange(characterColorGenerator.Key, item2);
						}
					}
					if (ValConfig.OutputColorizationGeneratorsData.Value)
					{
						File.WriteAllText(Path.Combine(Paths.ConfigPath, "StarLevelSystem", "DebugGeneratedColorValues.yaml"), DataObjects.yamlserializer.Serialize((object)creatureColorizationSettings));
					}
				}
				Logger.LogInfo("Updated ColorizationSettings.");
				Character[] array = Resources.FindObjectsOfTypeAll<Character>();
				foreach (Character val in array)
				{
					if (val.m_level > 1)
					{
						DataObjects.CreatureDetailCache andSetDetailCache = CompositeLazyCache.GetAndSetDetailCache(val, update: true);
						ApplyColorizationWithoutLevelEffects(((Component)val).gameObject, andSetDetailCache.Colorization);
					}
				}
			}
			catch (Exception ex)
			{
				StarLevelSystem.Log.LogError((object)("Failed to parse ColorizationSettings YAML: " + ex.Message));
				return false;
			}
			return true;
		}

		public static void ApplyLevelVisual(Character charc)
		{
			LevelEffects componentInChildren = ((Component)charc).gameObject.GetComponentInChildren<LevelEffects>();
			if (!((Object)(object)componentInChildren == (Object)null) && componentInChildren.m_levelSetups != null && componentInChildren.m_levelSetups.Count > 0)
			{
				LevelSetup val = componentInChildren.m_levelSetups[Random.Range(0, componentInChildren.m_levelSetups.Count - 1)];
				if ((Object)(object)val.m_enableObject != (Object)null)
				{
					val.m_enableObject.SetActive(true);
				}
			}
		}

		internal static DataObjects.ColorDef DetermineCharacterColorization(Character cgo, int level)
		{
			if ((Object)(object)cgo == (Object)null)
			{
				return null;
			}
			string prefabName = Utils.GetPrefabName(((Component)cgo).gameObject);
			if (creatureColorizationSettings.characterSpecificColorization.ContainsKey(prefabName) && creatureColorizationSettings.characterSpecificColorization[prefabName].ContainsKey(level - 1) && creatureColorizationSettings.characterSpecificColorization[prefabName].TryGetValue(level - 1, out var value))
			{
				return value;
			}
			return GetDefaultColorization(level - 1);
		}

		internal static void ApplyColorizationWithoutLevelEffects(GameObject cgo, DataObjects.ColorDef colorization)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			if (!ValConfig.EnableColorization.Value)
			{
				return;
			}
			LevelSetup val = colorization.toLevelEffect();
			try
			{
				SkinnedMeshRenderer[] componentsInChildren = cgo.gameObject.GetComponentsInChildren<SkinnedMeshRenderer>();
				foreach (SkinnedMeshRenderer val2 in componentsInChildren)
				{
					Material[] sharedMaterials = ((Renderer)val2).sharedMaterials;
					if (sharedMaterials.Length != 0)
					{
						sharedMaterials[0] = new Material(sharedMaterials[0]);
						sharedMaterials[0].SetFloat("_Hue", val.m_hue);
						sharedMaterials[0].SetFloat("_Saturation", val.m_saturation);
						sharedMaterials[0].SetFloat("_Value", val.m_value);
						if (val.m_setEmissiveColor)
						{
							sharedMaterials[0].SetColor("_EmissionColor", val.m_emissiveColor);
						}
						((Renderer)val2).sharedMaterials = sharedMaterials;
					}
				}
			}
			catch (Exception arg)
			{
				Logger.LogError($"Exception while colorizing {arg}");
			}
		}

		internal static void BuildAddColorRange(string creatureKey, DataObjects.ColorRangeDef colorGen)
		{
			float num = Mathf.Abs(colorGen.EndColorDef.hue) + Mathf.Abs(colorGen.StartColorDef.hue);
			Mathf.Clamp(num, 0f, 2f);
			float num2 = Mathf.Abs(colorGen.EndColorDef.saturation) + Mathf.Abs(colorGen.StartColorDef.saturation);
			Mathf.Clamp(num2, 0f, 2f);
			float num3 = Mathf.Abs(colorGen.EndColorDef.value) + Mathf.Abs(colorGen.StartColorDef.value);
			Mathf.Clamp(num3, 0f, 2f);
			int num4 = colorGen.RangeEnd - colorGen.RangeStart;
			float num5 = num / (float)num4;
			float num6 = num2 / (float)num4;
			float num7 = num3 / (float)num4;
			int num8 = ((!(colorGen.StartColorDef.hue > colorGen.EndColorDef.hue)) ? 1 : (-1));
			int num9 = ((!(colorGen.StartColorDef.saturation > colorGen.EndColorDef.saturation)) ? 1 : (-1));
			int num10 = ((!(colorGen.StartColorDef.value > colorGen.EndColorDef.value)) ? 1 : (-1));
			if (colorGen.CharacterSpecific && !creatureColorizationSettings.characterSpecificColorization.ContainsKey(creatureKey))
			{
				creatureColorizationSettings.characterSpecificColorization.Add(creatureKey, new Dictionary<int, DataObjects.ColorDef>());
			}
			int num11 = colorGen.RangeStart;
			int num12 = 0;
			while (num11 < colorGen.RangeEnd + 1)
			{
				DataObjects.ColorDef value = new DataObjects.ColorDef
				{
					hue = colorGen.StartColorDef.hue + num5 * (float)num12 * (float)num8,
					saturation = colorGen.StartColorDef.saturation + num6 * (float)num12 * (float)num9,
					value = colorGen.StartColorDef.value + num7 * (float)num12 * (float)num10,
					IsEmissive = false
				};
				if (colorGen.CharacterSpecific)
				{
					if (!creatureColorizationSettings.characterSpecificColorization.ContainsKey(creatureKey))
					{
						creatureColorizationSettings.characterSpecificColorization.Add(creatureKey, new Dictionary<int, DataObjects.ColorDef>());
					}
					if (creatureColorizationSettings.characterSpecificColorization[creatureKey].ContainsKey(num11))
					{
						if (colorGen.OverwriteExisting)
						{
							creatureColorizationSettings.characterSpecificColorization[creatureKey][num11] = value;
						}
					}
					else
					{
						creatureColorizationSettings.characterSpecificColorization[creatureKey].Add(num11, value);
					}
				}
				else if (creatureColorizationSettings.defaultLevelColorization.ContainsKey(num11))
				{
					if (colorGen.OverwriteExisting)
					{
						creatureColorizationSettings.defaultLevelColorization[num11] = value;
					}
				}
				else
				{
					creatureColorizationSettings.defaultLevelColorization.Add(num11, value);
				}
				num11++;
				num12++;
			}
		}

		internal static void StarLevelScaleChanged(object s, EventArgs e)
		{
			//IL_0014: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			Character[] array = Resources.FindObjectsOfTypeAll<Character>();
			foreach (Character val in array)
			{
				((Component)val).transform.localScale = Vector3.one;
				float num = 1f + ValConfig.PerLevelScaleBonus.Value * (float)(val.m_level - 1);
				Logger.LogDebug($"Setting {((Object)val).name} size {num}.");
				Transform transform = ((Component)val).transform;
				transform.localScale *= num;
			}
			Physics.SyncTransforms();
		}

		internal static DataObjects.ColorDef GetDefaultColorization(int level)
		{
			if (creatureColorizationSettings.defaultLevelColorization.ContainsKey(level))
			{
				return creatureColorizationSettings.defaultLevelColorization[level];
			}
			return defaultColorization;
		}

		public static void UpdateMapColorSelection()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			mapRingColors.Clear();
			Color item = default(Color);
			Color item2 = default(Color);
			foreach (string item3 in ValConfig.DistanceRingColorOptions.Value.Split(new char[1] { ',' }).ToList())
			{
				if (item3.StartsWith("#"))
				{
					if (ColorUtility.TryParseHtmlString(item3.Trim(), ref item))
					{
						mapRingColors.Add(item);
					}
					else
					{
						Logger.LogWarning("Unable to parse color string " + item3 + " for distance ring colors. It will be skipped");
					}
					continue;
				}
				string key = StringExtensions.CapitalizeFirstLetter(item3.Trim());
				if (defaultColors.TryGetValue(key, out var value) && ColorUtility.TryParseHtmlString(value, ref item2))
				{
					mapRingColors.Add(item2);
				}
			}
		}
	}
	internal static class Compatibility
	{
	}
	public static class CreatureModifiers
	{
		internal static readonly string NoMods = "None";

		private static readonly List<DataObjects.NameSelectionStyle> prefixSelectors = new List<DataObjects.NameSelectionStyle>
		{
			DataObjects.NameSelectionStyle.RandomFirst,
			DataObjects.NameSelectionStyle.RandomBoth
		};

		private static readonly List<DataObjects.NameSelectionStyle> suffixSelectors = new List<DataObjects.NameSelectionStyle>
		{
			DataObjects.NameSelectionStyle.RandomLast,
			DataObjects.NameSelectionStyle.RandomBoth
		};

		public static void SetupModifiers(Character character, DataObjects.CreatureDetailCache cacheEntry)
		{
			Dictionary<string, DataObjects.ModifierType> dictionary = new Dictionary<string, DataObjects.ModifierType>();
			int num = 0;
			cacheEntry.ModifierSuffixNames.Clear();
			cacheEntry.ModifierPrefixNames.Clear();
			foreach (KeyValuePair<string, DataObjects.ModifierType> modifier in cacheEntry.Modifiers)
			{
				if (ValConfig.LimitCreatureModifiersToCreatureStarLevel.Value && num >= character.m_level)
				{
					break;
				}
				if (!dictionary.ContainsKey(modifier.Key))
				{
					dictionary.Add(modifier.Key, modifier.Value);
				}
				switch (modifier.Value)
				{
				case DataObjects.ModifierType.Boss:
					StartupModifier(modifier.Key, character, cacheEntry, CreatureModifiersData.ActiveCreatureModifiers.BossModifiers);
					break;
				case DataObjects.ModifierType.Major:
					StartupModifier(modifier.Key, character, cacheEntry, CreatureModifiersData.ActiveCreatureModifiers.MajorModifiers);
					break;
				case DataObjects.ModifierType.Minor:
					StartupModifier(modifier.Key, character, cacheEntry, CreatureModifiersData.ActiveCreatureModifiers.MinorModifiers);
					break;
				}
				num++;
			}
			cacheEntry.Modifiers = dictionary;
		}

		private static void StartupModifier(string mod, Character character, DataObjects.CreatureDetailCache cacheEntry, Dictionary<string, DataObjects.CreatureModifier> availableMods)
		{
			if (!availableMods.ContainsKey(mod))
			{
				if (!(mod == NoMods))
				{
					Logger.LogWarning("Modifier " + mod + " not found in CreatureModifiersData, skipping setup for " + ((Object)character).name);
				}
				return;
			}
			DataObjects.CreatureModifier creatureModifier = availableMods[mod];
			creatureModifier.SetupMethodCall(character, creatureModifier.Config, cacheEntry);
			SetupCreatureVFX(character, creatureModifier);
			if (creatureModifier.NamePrefixes != null && prefixSelectors.Contains(creatureModifier.namingConvention))
			{
				cacheEntry.ModifierPrefixNames.Add(mod, creatureModifier.NamePrefixes);
			}
			if (creatureModifier.NameSuffixes != null && suffixSelectors.Contains(creatureModifier.namingConvention))
			{
				cacheEntry.ModifierSuffixNames.Add(mod, creatureModifier.NameSuffixes);
			}
		}

		internal static void SetupCreatureVFX(Character character, DataObjects.CreatureModifier cmodifier)
		{
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			if (cmodifier.VisualEffect == null)
			{
				return;
			}
			GameObject val = CreatureModifiersData.LoadedModifierEffects[cmodifier.VisualEffect];
			if (!Object.op_Implicit((Object)(object)((Component)character).transform.Find(((Object)val).name + "(Clone)")))
			{
				GameObject val2 = Object.Instantiate<GameObject>(val, ((Component)character).transform);
				float height = character.GetHeight();
				float num = height / 5f;
				float num2 = character.GetRadius() / 2f;
				switch (cmodifier.VisualEffectStyle)
				{
				case DataObjects.VisualEffectStyle.top:
					val2.transform.localPosition = new Vector3(0f, height, 0f);
					break;
				case DataObjects.VisualEffectStyle.bottom:
					val2.transform.localPosition = new Vector3(0f, 0f, 0f);
					break;
				case DataObjects.VisualEffectStyle.objectCenter:
					val2.transform.localPosition = new Vector3(0f, height / 2f, 0f);
					break;
				}
				val2.transform.localScale = new Vector3(val2.transform.localScale.x * num, val2.transform.localScale.y * num2, val2.transform.localScale.z * num);
			}
		}

		internal static string CheckOrBuildCreatureName(Character chara, DataObjects.CreatureDetailCache cacheEntry, bool useChache = true)
		{
			if (cacheEntry.CreatureDisabledInBiome || cacheEntry == null)
			{
				return Localization.instance.Localize(chara.m_name);
			}
			string @string = chara.m_nview.GetZDO().GetString("SLE_Name", "");
			if (@string == "" || !useChache)
			{
				List<string> list = new List<string>();
				List<string> list2 = new List<string>();
				int i = 0;
				List<string> list3 = cacheEntry.Modifiers.Keys.ToList();
				for (; i < cacheEntry.Modifiers.Count; i++)
				{
					if (list3.Count == 0)
					{
						break;
					}
					if (cacheEntry.ModifierPrefixNames != null && cacheEntry.ModifierPrefixNames.Count > 0)
					{
						KeyValuePair<string, List<string>> keyValuePair = Extensions.RandomEntry(cacheEntry.ModifierPrefixNames);
						list3.Remove(keyValuePair.Key);
						cacheEntry.ModifierPrefixNames.Remove(keyValuePair.Key);
						cacheEntry.ModifierSuffixNames.Remove(keyValuePair.Key);
						list.Add(keyValuePair.Value[Random.Range(0, keyValuePair.Value.Count - 1)]);
					}
					if (cacheEntry.ModifierSuffixNames != null && cacheEntry.ModifierSuffixNames.Count > 0)
					{
						KeyValuePair<string, List<string>> keyValuePair2 = Extensions.RandomEntry(cacheEntry.ModifierSuffixNames);
						list3.Remove(keyValuePair2.Key);
						cacheEntry.ModifierPrefixNames.Remove(keyValuePair2.Key);
						cacheEntry.ModifierSuffixNames.Remove(keyValuePair2.Key);
						list2.Add(keyValuePair2.Value[Random.Range(0, keyValuePair2.Value.Count - 1)]);
					}
				}
				Tameable component = ((Component)chara).GetComponent<Tameable>();
				string text = chara.m_name;
				if (Object.op_Implicit((Object)(object)component))
				{
					text = component.GetHoverName();
				}
				@string = string.Join(" ", list) + " " + text;
				if (list2.Count > 0)
				{
					@string = @string + " $suffix_moniker " + string.Join(" ", list2);
				}
				chara.m_nview.GetZDO().Set("SLE_Name", @string);
				return Localization.instance.Localize(@string.Trim());
			}
			return Localization.instance.Localize(@string);
		}

		public static Dictionary<string, DataObjects.ModifierType> SelectOrLoadModifiers(Character character, DataObjects.CreatureDetailCache cdc, int maxMajorMods = 0, float chanceMajorMods = 1f, int maxMinorMods = 0, float chanceMinorMods = 1f, bool isBoss = false, int maxBossMods = 0, float chanceBossMods = 1f, bool rebuildCache = false)
		{
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			DataObjects.CreatureModifiersZNetProperty creatureModifiersZNetProperty = new DataObjects.CreatureModifiersZNetProperty("SLS_MODS", character.m_nview, new Dictionary<string, DataObjects.ModifierType>());
			Dictionary<string, DataObjects.ModifierType> dictionary = creatureModifiersZNetProperty.Get();
			if (dictionary.Count > 0 && !rebuildCache)
			{
				return dictionary;
			}
			if (rebuildCache)
			{
				Logger.LogDebug("Rebuilding creature modifiers for " + cdc.CreatureName);
				dictionary.Clear();
				cdc.ModifierPrefixNames.Clear();
				cdc.ModifierSuffixNames.Clear();
			}
			if (cdc.CreatureName != null && CreatureModifiersData.ActiveCreatureModifiers.ModifierGlobalSettings != null && CreatureModifiersData.ActiveCreatureModifiers.ModifierGlobalSettings.GlobalIgnorePrefabList != null && CreatureModifiersData.ActiveCreatureModifiers.ModifierGlobalSettings.GlobalIgnorePrefabList.Contains(cdc.CreatureName))
			{
				Logger.LogDebug("Creature " + cdc.CreatureName + " is in the global ignore prefab list, skipping modifier assignment.");
				if (!dictionary.ContainsKey(NoMods))
				{
					dictionary.Add(NoMods, DataObjects.ModifierType.Minor);
				}
				creatureModifiersZNetProperty.Set(dictionary);
				return dictionary;
			}
			if (isBoss)
			{
				foreach (string item in SelectCreatureModifiers(Utils.GetPrefabName(((Component)character).gameObject), cdc.Biome, chanceBossMods, maxBossMods, cdc.Level, 0, DataObjects.ModifierType.Boss))
				{
					if (!dictionary.ContainsKey(item))
					{
						dictionary.Add(item.ToString(), DataObjects.ModifierType.Boss);
					}
				}
				creatureModifiersZNetProperty.Set(dictionary);
				return dictionary;
			}
			List<string> list = SelectCreatureModifiers(Utils.GetPrefabName(((Component)character).gameObject), cdc.Biome, chanceMajorMods, maxMajorMods, cdc.Level);
			foreach (string item2 in list)
			{
				if (!dictionary.ContainsKey(item2))
				{
					dictionary.Add(item2.ToString(), DataObjects.ModifierType.Major);
				}
			}
			foreach (string item3 in SelectCreatureModifiers(Utils.GetPrefabName(((Component)character).gameObject), cdc.Biome, chanceMinorMods, maxMinorMods, cdc.Level, list.Count, DataObjects.ModifierType.Minor))
			{
				if (!dictionary.ContainsKey(item3))
				{
					dictionary.Add(item3.ToString(), DataObjects.ModifierType.Minor);
				}
			}
			creatureModifiersZNetProperty.Set(dictionary);
			return dictionary;
		}

		public static List<string> SelectCreatureModifiers(string creature, Biome biome, float chance, int num_mods, int level, int existingMods = 0, DataObjects.ModifierType type = DataObjects.ModifierType.Major)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			List<string> list = new List<string>();
			List<DataObjects.ProbabilityEntry> list2 = CreatureModifiersData.LazyCacheCreatureModifierSelect(creature, biome, type);
			if (list2.Count == 0)
			{
				return list;
			}
			for (int i = 0; num_mods > i && (!ValConfig.LimitCreatureModifiersToCreatureStarLevel.Value || i + 1 + existingMods < level); i++)
			{
				if (chance < 1f)
				{
					if (Random.value < chance)
					{
						list.Add(RandomSelect.RandomSelectFromWeightedListWithExclusions(list2, list));
					}
				}
				else
				{
					list.Add(RandomSelect.RandomSelectFromWeightedListWithExclusions(list2, list));
				}
			}
			if (list.Count == 0)
			{
				list.Add(NoMods);
			}
			return list;
		}

		public static void RemoveCreatureModifier(Character character, string modifier)
		{
			DataObjects.CreatureDetailCache andSetDetailCache = CompositeLazyCache.GetAndSetDetailCache(character);
			if (andSetDetailCache.Modifiers.Keys.Contains(modifier))
			{
				andSetDetailCache.Modifiers.Remove(modifier);
				if (andSetDetailCache.ModifierPrefixNames.ContainsKey(modifier))
				{
					andSetDetailCache.ModifierPrefixNames.Remove(modifier);
				}
				if (andSetDetailCache.ModifierSuffixNames.ContainsKey(modifier))
				{
					andSetDetailCache.ModifierSuffixNames.Remove(modifier);
				}
				CompositeLazyCache.UpdateCacheEntry(character, andSetDetailCache);
				ModificationExtensionSystem.CreatureSetup(character, refresh_cache: false, 0, 0f);
			}
		}

		public static bool AddCreatureModifier(Character character, DataObjects.ModifierType modType, string newModifier, bool applyChanges = true)
		{
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			DataObjects.CreatureModifiersZNetProperty creatureModifiersZNetProperty = new DataObjects.CreatureModifiersZNetProperty("SLS_MODS", character.m_nview, new Dictionary<string, DataObjects.ModifierType>());
			Dictionary<string, DataObjects.ModifierType> dictionary = creatureModifiersZNetProperty.Get();
			if (dictionary.Count > 0 && dictionary.ContainsKey(newModifier))
			{
				Logger.LogDebug(((Object)character).name + " already has " + newModifier + ", skipping.");
				return false;
			}
			dictionary.Add(newModifier, modType);
			creatureModifiersZNetProperty.Set(dictionary);
			DataObjects.CreatureDetailCache andSetDetailCache = CompositeLazyCache.GetAndSetDetailCache(character);
			DataObjects.CreatureModifier modifierDef = CreatureModifiersData.GetModifierDef(newModifier, modType);
			modifierDef.SetupMethodCall(character, modifierDef.Config, andSetDetailCache);
			SetupCreatureVFX(character, modifierDef);
			if (modifierDef.NamePrefixes != null && prefixSelectors.Contains(modifierDef.namingConvention) && !andSetDetailCache.ModifierPrefixNames.ContainsKey(newModifier))
			{
				andSetDetailCache.ModifierPrefixNames.Add(newModifier, modifierDef.NamePrefixes);
			}
			if (modifierDef.NameSuffixes != null && suffixSelectors.Contains(modifierDef.namingConvention) && !andSetDetailCache.ModifierSuffixNames.ContainsKey(newModifier))
			{
				andSetDetailCache.ModifierSuffixNames.Add(newModifier, modifierDef.NameSuffixes);
			}
			andSetDetailCache.Modifiers.Add(newModifier, modType);
			CompositeLazyCache.UpdateCacheEntry(character, andSetDetailCache);
			CheckOrBuildCreatureName(character, andSetDetailCache, useChache: false);
			LevelUI.InvalidateCacheEntry(character.GetZDOID());
			if (!applyChanges)
			{
				ModificationExtensionSystem.ApplySpeedModifications(character, andSetDetailCache);
				ModificationExtensionSystem.ApplyDamageModification(character, andSetDetailCache);
				ModificationExtensionSystem.LoadApplySizeModifications(((Component)character).gameObject, character.m_nview, andSetDetailCache, force_update: true);
				ModificationExtensionSystem.ApplyHealthModifications(character, andSetDetailCache);
				return true;
			}
			return true;
		}
	}
	public static class LevelSystem
	{
		[HarmonyPatch(typeof(Fish), "Awake")]
		public static class RandomFishLevelExtension
		{
			public static void Postfix(Fish __instance)
			{
				//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
				if (ValConfig.EnableScalingFish.Value && !((Object)(object)__instance.m_nview == (Object)null) && __instance.m_nview.GetZDO() != null)
				{
					int num = __instance.m_nview.GetZDO().GetInt("SLE_Fish", 0);
					if (num == 0)
					{
						SelectCreatureBiomeSettings(((Component)__instance).gameObject, out var creature_name, out var creature_settings, out var biome_settings, out var _);
						num = DetermineLevel(((Component)__instance).gameObject, creature_name, creature_settings, biome_settings);
						__instance.m_nview.GetZDO().Set("SLE_Fish", num);
						((Component)__instance).GetComponent<ItemDrop>().SetQuality(num);
						((Component)__instance).GetComponent<ItemDrop>().m_itemData.m_shared.m_maxQuality = num + 1;
					}
					if (num > 1)
					{
						float num2 = 1f + ValConfig.FishSizeScalePerLevel.Value * (float)num;
						((Component)__instance).GetComponent<ItemDrop>().SetQuality(num);
						((Component)__instance).GetComponent<ItemDrop>().m_itemData.m_shared.m_maxQuality = num + 1;
						Transform transform = ((Component)__instance).transform;
						transform.localScale *= num2;
						Physics.SyncTransforms();
					}
				}
			}
		}

		[HarmonyPatch(typeof(TreeBase), "Awake")]
		public static class RandomTreeLevelExtension
		{
			public static void Postfix(TreeBase __instance)
			{
				//IL_009e: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
				//IL_0121: Unknown result type (might be due to invalid IL or missing references)
				//IL_012f: Unknown result type (might be due to invalid IL or missing references)
				if (!ValConfig.EnableTreeScaling.Value)
				{
					return;
				}
				int num = __instance.m_nview.GetZDO().GetInt("SLE_Tree", 0);
				if (num == 0)
				{
					SelectCreatureBiomeSettings(((Component)__instance).gameObject, out var creature_name, out var creature_settings, out var biome_settings, out var _);
					num = DetermineLevel(((Component)__instance).gameObject, creature_name, creature_settings, biome_settings);
					__instance.m_nview.GetZDO().Set("SLE_Tree", num);
				}
				if (num <= 1)
				{
					return;
				}
				float num2 = 1f + ValConfig.TreeSizeScalePerLevel.Value * (float)num;
				__instance.m_health += __instance.m_health * 0.1f * (float)num;
				Transform transform = ((Component)__instance).transform;
				transform.localScale *= num2;
				List<DropData> list = new List<DropData>();
				foreach (DropData drop in __instance.m_dropWhenDestroyed.m_drops)
				{
					DropData item = default(DropData);
					item.m_stackMin = Mathf.RoundToInt((float)drop.m_stackMin * (ValConfig.PerLevelLootScale.Value * (float)num));
					item.m_stackMax = Mathf.RoundToInt((float)drop.m_stackMax * (ValConfig.PerLevelLootScale.Value * (float)num));
					item.m_item = drop.m_item;
					list.Add(item);
				}
				Physics.SyncTransforms();
			}
		}

		[HarmonyPatch(typeof(TreeLog))]
		public static class SetTreeLogPassLevel
		{
			[HarmonyTranspiler]
			[HarmonyPatch("Destroy")]
			private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Expected O, but got Unknown
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Expected O, but got Unknown
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Expected O, but got Unknown
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: Expected O, but got Unknown
				//IL_006e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0074: Expected O, but got Unknown
				//IL_0093: Unknown result type (might be due to invalid IL or missing references)
				//IL_0099: Expected O, but got Unknown
				//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c0: Expected O, but got Unknown
				//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d4: Expected O, but got Unknown
				//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e8: Expected O, but got Unknown
				//IL_010e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0114: Expected O, but got Unknown
				//IL_0122: Unknown result type (might be due to invalid IL or missing references)
				//IL_0128: Expected O, but got Unknown
				CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
				val.MatchStartForward((CodeMatch[])(object)new CodeMatch[4]
				{
					new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(ZNetScene), "Destroy", (Type[])null, (Type[])null), (string)null)
				}).RemoveInstructions(4).MatchStartForward((CodeMatch[])(object)new CodeMatch[4]
				{
					new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(TreeLog), "m_subLogPrefab"), (string)null),
					new CodeMatch((OpCode?)OpCodes.Ldloc_S, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Callvirt, (object)null, (string)null)
				})
					.Advance(1)
					.RemoveInstructions(10)
					.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[3]
					{
						new CodeInstruction(OpCodes.Ldloc_S, (object)(byte)10),
						new CodeInstruction(OpCodes.Ldloc_S, (object)(byte)11),
						Transpilers.EmitDelegate<Action<TreeLog, Transform, Quaternion>>((Action<TreeLog, Transform, Quaternion>)SetupTreeLog)
					})
					.ThrowIfNotMatch("Unable to patch Tree Log Child Spawn Set Level.", Array.Empty<CodeMatch>());
				return val.Instructions();
			}

			[HarmonyPatch("Awake")]
			[HarmonyPostfix]
			private static void SetupAwakeLog(TreeLog __instance)
			{
				int @int = __instance.m_nview.GetZDO().GetInt("SLE_Tree", 1);
				UpdateDrops(__instance, @int);
				__instance.m_health += __instance.m_health * 0.1f * (float)@int;
				ImpactEffect component = ((Component)__instance).GetComponent<ImpactEffect>();
				if (component != null)
				{
					((DamageTypes)(ref component.m_damages)).Modify(1f + 0.1f * (float)@int);
				}
			}

			[HarmonyPatch("Destroy")]
			[HarmonyPostfix]
			internal static void RemoveTreeLogInst(TreeLog __instance)
			{
				ZNetScene.instance.Destroy(((Component)__instance).gameObject);
			}

			internal static void SetupTreeLog(TreeLog instance, Transform tform, Quaternion qt)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				GameObject obj = Object.Instantiate<GameObject>(instance.m_subLogPrefab, tform.position, qt);
				ZNetView component = obj.GetComponent<ZNetView>();
				TreeLog component2 = obj.GetComponent<TreeLog>();
				component.SetLocalScale(((Component)instance).transform.localScale);
				int num = 1;
				if (instance.m_nview.GetZDO() != null)
				{
					num = instance.m_nview.GetZDO().GetInt("SLE_Tree", 1);
				}
				UpdateDrops(component2, num);
				component2.m_health += component2.m_health * 0.1f * (float)num;
				ImpactEffect component3 = obj.GetComponent<ImpactEffect>();
				if (component3 != null)
				{
					((DamageTypes)(ref component3.m_damages)).Modify(1f + 0.1f * (float)num);
				}
				component.GetZDO().Set("SLE_Tree", num);
				ZNetScene.instance.Destroy(((Component)instance).gameObject);
			}

			internal static void UpdateDrops(TreeLog log, int level)
			{
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0052: 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_007b: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
				if (log.m_dropWhenDestroyed == null || log.m_dropWhenDestroyed.m_drops == null || level == 1)
				{
					return;
				}
				List<DropData> list = new List<DropData>();
				Logger.LogDebug($"Updating Drops for tree to: {level}");
				foreach (DropData drop in log.m_dropWhenDestroyed.m_drops)
				{
					DropData item = default(DropData);
					item.m_stackMin = Mathf.RoundToInt((float)drop.m_stackMin * (ValConfig.PerLevelLootScale.Value * (float)level));
					item.m_stackMax = Mathf.RoundToInt((float)drop.m_stackMax * (ValConfig.PerLevelLootScale.Value * (float)level));
					item.m_item = drop.m_item;
					list.Add(item);
				}
				log.m_dropWhenDestroyed.m_drops = list;
			}
		}

		[HarmonyPatch(typeof(RandomFlyingBird), "Awake")]
		public static class RandomFlyingBirdExtension
		{
			public static void Postfix(RandomFlyingBird __instance)
			{
				//IL_0082: Unknown result type (might be due to invalid IL or missing references)
				//IL_0089: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c3: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
				//IL_0118: Unknown result type (might be due to invalid IL or missing references)
				//IL_0126: Unknown result type (might be due to invalid IL or missing references)
				if (!ValConfig.EnableScalingBirds.Value)
				{
					return;
				}
				int num = __instance.m_nview.GetZDO().GetInt("SLE_Bird", 0);
				if (num == 0)
				{
					SelectCreatureBiomeSettings(((Component)__instance).gameObject, out var creature_name, out var creature_settings, out var biome_settings, out var _);
					num = DetermineLevel(((Component)__instance).gameObject, creature_name, creature_settings, biome_settings);
					__instance.m_nview.GetZDO().Set("SLE_Bird", num);
				}
				if (num <= 1)
				{
					return;
				}
				float num2 = 1f + ValConfig.BirdSizeScalePerLevel.Value * (float)num;
				Transform transform = ((Component)__instance).transform;
				transform.localScale *= num2;
				Physics.SyncTransforms();
				DropOnDestroyed component = ((Component)__instance).gameObject.GetComponent<DropOnDestroyed>();
				List<DropData> list = new List<DropData>();
				foreach (DropData drop in component.m_dropWhenDestroyed.m_drops)
				{
					DropData item = default(DropData);
					item.m_stackMin = Mathf.RoundToInt((float)drop.m_stackMin * (ValConfig.PerLevelLootScale.Value * (float)num));
					item.m_stackMax = Mathf.RoundToInt((float)drop.m_stackMax * (ValConfig.PerLevelLootScale.Value * (float)num));
					item.m_item = drop.m_item;
					list.Add(item);
				}
				component.m_dropWhenDestroyed.m_dr