Decompiled source of balrond humanoidRandomizer v1.3.6

plugins/BalrondHumanoidRandomizer.dll

Decompiled 4 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BalrondHumanoidRandomizer.Monsters;
using BepInEx;
using HarmonyLib;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ProjectAshlands")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ProjectAshlands")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f405ea1c-ac25-47a3-9aa2-a8f56c14bfd6")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace BalrondHumanoidRandomizer
{
	public class FxReplacment
	{
		private List<GameObject> allPrefabs;

		private string projectName = "[BalrondHumanoidRandomizer]";

		public void setInstance(List<GameObject> gameObjects)
		{
			allPrefabs = gameObjects;
		}

		public void ReplaceOnObject(GameObject gameObject)
		{
			if ((Object)(object)gameObject == (Object)null)
			{
				return;
			}
			SpawnArea component = gameObject.GetComponent<SpawnArea>();
			if ((Object)(object)component != (Object)null)
			{
				EffectList spawnEffects = component.m_spawnEffects;
				if (spawnEffects != null)
				{
					findEffectsAndChange(spawnEffects.m_effectPrefabs);
				}
			}
			Destructible component2 = gameObject.GetComponent<Destructible>();
			if ((Object)(object)component2 != (Object)null)
			{
				EffectList hitEffect = component2.m_hitEffect;
				if (hitEffect != null)
				{
					findEffectsAndChange(hitEffect.m_effectPrefabs);
				}
				EffectList destroyedEffect = component2.m_destroyedEffect;
				if (destroyedEffect != null)
				{
					findEffectsAndChange(destroyedEffect.m_effectPrefabs);
				}
			}
			Projectile component3 = gameObject.GetComponent<Projectile>();
			if ((Object)(object)component3 != (Object)null)
			{
				EffectList hitEffects = component3.m_hitEffects;
				if (hitEffects != null)
				{
					findEffectsAndChange(hitEffects.m_effectPrefabs);
				}
				EffectList hitWaterEffects = component3.m_hitWaterEffects;
				if (hitWaterEffects != null)
				{
					findEffectsAndChange(hitWaterEffects.m_effectPrefabs);
				}
				EffectList spawnOnHitEffects = component3.m_spawnOnHitEffects;
				if (spawnOnHitEffects != null)
				{
					findEffectsAndChange(spawnOnHitEffects.m_effectPrefabs);
				}
			}
		}

		public void ReplaceOnVegetation(GameObject gameObject)
		{
			Pickable component = gameObject.GetComponent<Pickable>();
			if ((Object)(object)component != (Object)null)
			{
				fixPlant(component);
			}
			Destructible component2 = gameObject.GetComponent<Destructible>();
			if ((Object)(object)component2 != (Object)null)
			{
				fixPDestructable(component2);
			}
			MineRock5 component3 = gameObject.GetComponent<MineRock5>();
			if ((Object)(object)component3 != (Object)null)
			{
				fixMineRock5(component3);
			}
			MineRock component4 = gameObject.GetComponent<MineRock>();
			if ((Object)(object)component4 != (Object)null)
			{
				fixMineRock(component4);
			}
		}

		private void fixPlant(Pickable pickable)
		{
			EffectList pickEffector = pickable.m_pickEffector;
			if (pickEffector != null)
			{
				findEffectsAndChange(pickEffector.m_effectPrefabs);
			}
		}

		private void fixPDestructable(Destructible minerock5)
		{
			EffectList hitEffect = minerock5.m_hitEffect;
			if (hitEffect != null)
			{
				findEffectsAndChange(hitEffect.m_effectPrefabs);
			}
			EffectList destroyedEffect = minerock5.m_destroyedEffect;
			if (destroyedEffect != null)
			{
				findEffectsAndChange(destroyedEffect.m_effectPrefabs);
			}
		}

		private void fixMineRock5(MineRock5 minerock5)
		{
			EffectList hitEffect = minerock5.m_hitEffect;
			if (hitEffect != null)
			{
				findEffectsAndChange(hitEffect.m_effectPrefabs);
			}
			EffectList destroyedEffect = minerock5.m_destroyedEffect;
			if (destroyedEffect != null)
			{
				findEffectsAndChange(destroyedEffect.m_effectPrefabs);
			}
		}

		private void fixMineRock(MineRock minerock5)
		{
			EffectList hitEffect = minerock5.m_hitEffect;
			if (hitEffect != null)
			{
				findEffectsAndChange(hitEffect.m_effectPrefabs);
			}
			EffectList destroyedEffect = minerock5.m_destroyedEffect;
			if (destroyedEffect != null)
			{
				findEffectsAndChange(destroyedEffect.m_effectPrefabs);
			}
		}

		public void ReplaceOnMonster(GameObject gameObject)
		{
			if ((Object)(object)gameObject == (Object)null)
			{
				Debug.LogWarning((object)(projectName + ":: GameObject not found"));
				return;
			}
			Humanoid component = gameObject.GetComponent<Humanoid>();
			if ((Object)(object)component == (Object)null)
			{
				Debug.LogWarning((object)(projectName + ":: GameObject not found"));
				return;
			}
			EffectList dropEffects = component.m_dropEffects;
			if (dropEffects != null)
			{
				findEffectsAndChange(dropEffects.m_effectPrefabs);
			}
			EffectList backstabHitEffects = ((Character)component).m_backstabHitEffects;
			if (backstabHitEffects != null)
			{
				findEffectsAndChange(backstabHitEffects.m_effectPrefabs);
			}
			EffectList consumeItemEffects = component.m_consumeItemEffects;
			if (consumeItemEffects != null)
			{
				findEffectsAndChange(consumeItemEffects.m_effectPrefabs);
			}
			EffectList critHitEffects = ((Character)component).m_critHitEffects;
			if (critHitEffects != null)
			{
				findEffectsAndChange(critHitEffects.m_effectPrefabs);
			}
			EffectList deathEffects = ((Character)component).m_deathEffects;
			if (deathEffects != null)
			{
				findEffectsAndChange(deathEffects.m_effectPrefabs);
			}
			EffectList hitEffects = ((Character)component).m_hitEffects;
			if (hitEffects != null)
			{
				findEffectsAndChange(hitEffects.m_effectPrefabs);
			}
			EffectList jumpEffects = ((Character)component).m_jumpEffects;
			if (jumpEffects != null)
			{
				findEffectsAndChange(jumpEffects.m_effectPrefabs);
			}
			EffectList perfectBlockEffect = component.m_perfectBlockEffect;
			if (perfectBlockEffect != null)
			{
				findEffectsAndChange(perfectBlockEffect.m_effectPrefabs);
			}
			EffectList pickupEffects = component.m_pickupEffects;
			if (pickupEffects != null)
			{
				findEffectsAndChange(pickupEffects.m_effectPrefabs);
			}
			EffectList slideEffects = ((Character)component).m_slideEffects;
			if (slideEffects != null)
			{
				findEffectsAndChange(slideEffects.m_effectPrefabs);
			}
			EffectList tarEffects = ((Character)component).m_tarEffects;
			if (tarEffects != null)
			{
				findEffectsAndChange(tarEffects.m_effectPrefabs);
			}
			EffectList waterEffects = ((Character)component).m_waterEffects;
			if (waterEffects != null)
			{
				findEffectsAndChange(waterEffects.m_effectPrefabs);
			}
			FootStep component2 = gameObject.GetComponent<FootStep>();
			if (!((Object)(object)component2 != (Object)null))
			{
				return;
			}
			List<StepEffect> effects = component2.m_effects;
			foreach (StepEffect item in effects)
			{
				GameObject[] effectPrefabs = item.m_effectPrefabs;
				List<GameObject> list = new List<GameObject>();
				list.AddRange(effectPrefabs);
				for (int i = 0; i < list.Count; i++)
				{
					if ((Object)(object)list[i] != (Object)null)
					{
						string name = ((Object)list[i]).name;
						GameObject val = allPrefabs.Find((GameObject x) => ((Object)x).name == name);
						if (!((Object)(object)val == (Object)null))
						{
							list[i] = val;
						}
					}
				}
			}
		}

		public void ReplaceOnItem(GameObject gameObject)
		{
			if ((Object)(object)gameObject == (Object)null)
			{
				return;
			}
			ItemDrop component = gameObject.GetComponent<ItemDrop>();
			if (!((Object)(object)component == (Object)null))
			{
				EffectList hitEffect = component.m_itemData.m_shared.m_hitEffect;
				if (hitEffect != null)
				{
					findEffectsAndChange(hitEffect.m_effectPrefabs);
				}
				EffectList hitTerrainEffect = component.m_itemData.m_shared.m_hitTerrainEffect;
				if (hitTerrainEffect != null)
				{
					findEffectsAndChange(hitTerrainEffect.m_effectPrefabs);
				}
				EffectList holdStartEffect = component.m_itemData.m_shared.m_holdStartEffect;
				if (holdStartEffect != null)
				{
					findEffectsAndChange(holdStartEffect.m_effectPrefabs);
				}
				EffectList trailStartEffect = component.m_itemData.m_shared.m_trailStartEffect;
				if (trailStartEffect != null)
				{
					findEffectsAndChange(trailStartEffect.m_effectPrefabs);
				}
				EffectList blockEffect = component.m_itemData.m_shared.m_blockEffect;
				if (blockEffect != null)
				{
					findEffectsAndChange(blockEffect.m_effectPrefabs);
				}
			}
		}

		public void ReplaceFxOnPiece(GameObject gameObject)
		{
			if ((Object)(object)gameObject == (Object)null)
			{
				return;
			}
			Piece component = gameObject.GetComponent<Piece>();
			if ((Object)(object)component != (Object)null)
			{
				EffectList placeEffect = component.m_placeEffect;
				if (placeEffect != null)
				{
					findEffectsAndChange(placeEffect.m_effectPrefabs);
				}
			}
			WearNTear component2 = gameObject.GetComponent<WearNTear>();
			if ((Object)(object)component2 != (Object)null)
			{
				EffectList hitEffect = component2.m_hitEffect;
				if (hitEffect != null)
				{
					findEffectsAndChange(hitEffect.m_effectPrefabs);
				}
			}
		}

		private void findEffectsAndChange(EffectData[] effects)
		{
			if (effects == null || effects.Length == 0)
			{
				return;
			}
			foreach (EffectData val in effects)
			{
				if ((Object)(object)val.m_prefab != (Object)null)
				{
					string name = ((Object)val.m_prefab).name;
					GameObject val2 = allPrefabs.Find((GameObject x) => ((Object)x).name == name);
					if (!((Object)(object)val2 == (Object)null))
					{
						val.m_prefab = val2;
					}
				}
			}
		}
	}
	public class ShaderReplacment
	{
		public static List<GameObject> prefabsToReplaceShader = new List<GameObject>();

		public static List<Material> materialsInPrefabs = new List<Material>();

		public string[] shaderlist = new string[49]
		{
			"Custom/AlphaParticle", "Custom/Blob", "Custom/Bonemass", "Custom/Clouds", "Custom/Creature", "Custom/Decal", "Custom/Distortion", "Custom/Flow", "Custom/FlowOpaque", "Custom/Grass",
			"Custom/GuiScroll", "Custom/Heightmap", "Custom/icon", "Custom/InteriorSide", "Custom/LitGui", "Custom/LitParticles", "Custom/mapshader", "Custom/ParticleDecal", "Custom/Piece", "Custom/Player",
			"Custom/Rug", "Custom/ShadowBlob", "Custom/SkyboxProcedural", "Custom/SkyObject", "Custom/StaticRock", "Custom/Tar", "Custom/Trilinearmap", "Custom/UI/BGBlur", "Custom/Vegetation", "Custom/Water",
			"Custom/WaterBottom", "Custom/WaterMask", "Custom/Yggdrasil", "Custom/Yggdrasil/root", "Hidden/BlitCopyHDRTonemap", "Hidden/Dof/DepthOfFieldHdr", "Hidden/Dof/DX11Dof", "Hidden/Internal-Loading", "Hidden/Internal-UIRDefaultWorld", "Hidden/SimpleClear",
			"Hidden/SunShaftsComposite", "Lux Lit Particles/ Bumped", "Lux Lit Particles/ Tess Bumped", "Particles/Standard Surface2", "Particles/Standard Unlit2", "Standard TwoSided", "ToonDeferredShading2017", "Unlit/DepthWrite", "Unlit/Lighting"
		};

		public static List<Shader> shaders = new List<Shader>();

		private static readonly HashSet<Shader> CachedShaders = new HashSet<Shader>();

		public static bool debug = true;

		public static Shader findShader(string name)
		{
			Shader[] array = Resources.FindObjectsOfTypeAll<Shader>();
			if (array.Length == 0)
			{
				Debug.LogWarning((object)"SHADER LIST IS EMPTY!");
				return null;
			}
			if (debug)
			{
			}
			return shaders.Find((Shader x) => ((Object)x).name == name);
		}

		public static Shader GetShaderByName(string name)
		{
			return shaders.Find((Shader x) => ((Object)x).name == name.Trim());
		}

		public static void debugShaderList(List<Shader> shadersRes)
		{
			foreach (Shader shadersRe in shadersRes)
			{
				Debug.LogWarning((object)("SHADER NAME IS: " + ((Object)shadersRe).name));
			}
			debug = false;
		}

		public static void Replace(GameObject gameObject)
		{
			prefabsToReplaceShader.Add(gameObject);
			GetMaterialsInPrefab(gameObject);
		}

		public static void GetMaterialsInPrefab(GameObject gameObject)
		{
			Renderer[] componentsInChildren = gameObject.GetComponentsInChildren<Renderer>(true);
			Renderer[] array = componentsInChildren;
			foreach (Renderer val in array)
			{
				Material[] sharedMaterials = val.sharedMaterials;
				if (sharedMaterials == null || sharedMaterials.Length == 0)
				{
					continue;
				}
				Material[] array2 = sharedMaterials;
				foreach (Material val2 in array2)
				{
					if ((Object)(object)val2 != (Object)null)
					{
						materialsInPrefabs.Add(val2);
					}
				}
			}
		}

		public static void getMeShaders()
		{
			AssetBundle[] array = Resources.FindObjectsOfTypeAll<AssetBundle>();
			AssetBundle[] array2 = array;
			foreach (AssetBundle val in array2)
			{
				IEnumerable<Shader> enumerable3;
				try
				{
					IEnumerable<Shader> enumerable2;
					if (!val.isStreamedSceneAssetBundle || !Object.op_Implicit((Object)(object)val))
					{
						IEnumerable<Shader> enumerable = val.LoadAllAssets<Shader>();
						enumerable2 = enumerable;
					}
					else
					{
						enumerable2 = from shader in ((IEnumerable<string>)val.GetAllAssetNames()).Select((Func<string, Shader>)val.LoadAsset<Shader>)
							where (Object)(object)shader != (Object)null
							select shader;
					}
					enumerable3 = enumerable2;
				}
				catch (Exception)
				{
					continue;
				}
				if (enumerable3 == null)
				{
					continue;
				}
				foreach (Shader item in enumerable3)
				{
					CachedShaders.Add(item);
				}
			}
		}

		public static void runMaterialFix()
		{
			getMeShaders();
			shaders.AddRange(CachedShaders);
			foreach (Material materialsInPrefab in materialsInPrefabs)
			{
				Shader shader = materialsInPrefab.shader;
				if (!((Object)(object)shader == (Object)null))
				{
					string name = ((Object)shader).name;
					if (!(name == "Standard") && name.Contains("Balrond"))
					{
						setProperValue(materialsInPrefab, name);
					}
				}
			}
		}

		private static void setProperValue(Material material, string shaderName)
		{
			string name = shaderName.Replace("Balrond", "Custom");
			name = checkNaming(name);
			Shader shaderByName = GetShaderByName(name);
			if ((Object)(object)shaderByName == (Object)null)
			{
				Debug.LogWarning((object)("Shader not found " + name));
			}
			else
			{
				material.shader = shaderByName;
			}
		}

		private static string checkNaming(string name)
		{
			string result = name;
			if (name.Contains("Bumped"))
			{
				result = name.Replace("Custom", "Lux Lit Particles");
			}
			if (name.Contains("Tess Bumped"))
			{
				result = name.Replace("Custom", "Lux Lit Particles");
			}
			if (name.Contains("Standard Surface"))
			{
				result = name.Replace("Custom", "Particles");
				result = result.Replace("Standard Surface2", "Standard Surface");
			}
			if (name.Contains("Standard Unlit"))
			{
				result = name.Replace("Custom", "Particles");
				result = result.Replace("Standard Unlit", "Standard Unlit2");
				result = result.Replace("Standard Unlit22", "Standard Unlit2");
			}
			return result;
		}
	}
	public class BaseLevelEffectSetupValue
	{
		public float scale = 1.1f;

		public float saturation = 0.5f;

		public float hue = -0.1f;

		public float value = -0.1f;

		public LevelSetup setup = null;

		public GameObject enabledObject = null;

		public GameObject enabledObjectLevel2 = null;

		public GameObject enabledObjectLevel3 = null;

		public bool setEmmisive = false;

		public Color emissive = Color.white;

		public float sumValue = 0.05f;

		public void getSetup(LevelEffects levelEffects)
		{
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)levelEffects == (Object)null)
			{
				Debug.LogWarning((object)"I should not be here i am null");
				return;
			}
			int num = 0;
			if (levelEffects.m_levelSetups != null && levelEffects.m_levelSetups.Count > 0)
			{
				num = levelEffects.m_levelSetups.Count;
				setup = levelEffects.m_levelSetups.Last();
			}
			if (num != 0 && setup != null)
			{
				scale = setup.m_scale;
				saturation = setup.m_saturation;
				hue = setup.m_hue;
				value = setup.m_value;
				enabledObject = setup.m_enableObject;
				emissive = setup.m_emissiveColor;
				setEmmisive = setup.m_setEmissiveColor;
				enabledObjectLevel2 = enabledObject;
				enabledObjectLevel3 = enabledObject;
			}
			else
			{
				setValues(num, levelEffects);
			}
			if ((Object)(object)levelEffects.m_character != (Object)null)
			{
				if (((Object)((Component)levelEffects.m_character).gameObject).name == "Deer")
				{
					EditDeer(levelEffects);
				}
				if (((Object)((Component)levelEffects.m_character).gameObject).name == "Boar")
				{
					EditBoar(levelEffects);
				}
			}
		}

		private void EditDeer(LevelEffects levelEffects)
		{
			GameObject enableObject = levelEffects.m_levelSetups[0].m_enableObject;
			GameObject enableObject2 = levelEffects.m_levelSetups[1].m_enableObject;
			enabledObjectLevel2 = enableObject;
			enabledObjectLevel3 = enableObject2;
			Transform parent = enableObject.transform.parent;
			GameObject enableObject3 = (enabledObject = ((Component)parent.Find("Antler1")).gameObject);
			levelEffects.m_levelSetups[0].m_enableObject = enableObject3;
			levelEffects.m_levelSetups[1].m_enableObject = enableObject3;
		}

		private void EditBoar(LevelEffects gameObject)
		{
		}

		private void setValues(int levels, LevelEffects levelEffects)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			float y = ((Component)levelEffects).transform.localScale.y;
			if (levels == 0)
			{
				scale = y;
				saturation = 0f;
				hue = 0f;
				value = 0f;
			}
			if (levels == 1)
			{
				scale = y + 0.05f;
				saturation = 0.5f;
				hue = -0.05f;
				value = -0.05f;
			}
			if (levels == 2)
			{
				scale = y + 0.1f;
				saturation = 0.5f;
				hue = -0.1f;
				value = -0.1f;
			}
		}
	}
	public class HumanoidExtend : MonoBehaviour
	{
		private MonsterAI monster;

		private Humanoid humanoid;

		private ZNetView m_nview;

		private bool itemStolen = false;

		private int growthAmount = 1;

		private int maxLevel = 7;

		private int currentLevel;

		public bool canSteal = false;

		public bool levelingEnabled = true;

		public bool expOnKillEnabled = true;

		public bool bossLeveling = false;

		public int chanceToSteal = 25;

		public int currentGrowth = 0;

		public int growthToLevel = 40000;

		public int expForKill = 500;

		public GameObject levelUpEffect;

		public GameObject stealEffect;

		public ItemData stolenItem = null;

		public bool toggleReset = false;

		private SphereCollider collider;

		private void Awake()
		{
			humanoid = ((Component)this).GetComponent<Humanoid>();
			monster = ((Component)this).GetComponent<MonsterAI>();
			m_nview = ((Component)this).GetComponent<ZNetView>();
			currentLevel = ((Character)humanoid).GetLevel();
			if (!((BaseAI)monster).m_character.IsTamed())
			{
				collider = ((Component)monster).gameObject.AddComponent<SphereCollider>();
				collider.radius = 3f;
				((Collider)collider).isTrigger = true;
			}
			m_nview.Register<string, int>("Steal", (Action<long, string, int>)RPC_StolenItem);
			if (((Character)humanoid).IsBoss() && bossLeveling && !levelingEnabled)
			{
				levelingEnabled = false;
				bossLeveling = false;
			}
			Character character = ((BaseAI)monster).m_character;
			character.m_onDeath = (Action)Delegate.Combine(character.m_onDeath, (Action)delegate
			{
				detectKill(((Component)monster).transform);
			});
			Character character2 = ((BaseAI)monster).m_character;
			character2.m_onDeath = (Action)Delegate.Combine(character2.m_onDeath, (Action)delegate
			{
				DropStolen();
			});
			setMaxExpToLevel();
			((MonoBehaviour)this).InvokeRepeating("CheckLeveling", 1f, 1f);
		}

		private void CheckTamed()
		{
			if (((BaseAI)monster).m_character.IsTamed())
			{
				Object.DestroyImmediate((Object)(object)collider);
			}
		}

		private void CheckLeveling()
		{
			ResetLevel();
			CheckTamed();
			if (((Component)this).gameObject.activeInHierarchy)
			{
				if (levelingEnabled)
				{
					currentGrowth += growthAmount;
				}
				if (currentGrowth >= growthToLevel && currentLevel < maxLevel)
				{
					TransferExpOnLevel();
					setMaxExpToLevel();
					monsterLevelUp();
				}
			}
		}

		private void TransferExpOnLevel()
		{
			if (currentGrowth > growthToLevel)
			{
				int num = currentGrowth - growthToLevel;
				if (num > 0)
				{
					currentGrowth += num;
				}
			}
			else
			{
				currentGrowth = 0;
			}
		}

		private void setMaxExpToLevel()
		{
			growthToLevel *= currentLevel;
		}

		private void monsterLevelUp()
		{
			//IL_0044: 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)
			currentLevel++;
			if ((Object)(object)levelUpEffect != (Object)null && ((Character)humanoid).GetLevel() < currentLevel)
			{
				Object.Instantiate<GameObject>(levelUpEffect, ((Component)this).transform.position, ((Component)this).transform.rotation, (Transform)null);
			}
			if (((Character)humanoid).GetLevel() < currentLevel)
			{
				((Character)humanoid).SetLevel(currentLevel);
				((Character)humanoid).RPC_Heal((long)((Object)humanoid).GetInstanceID(), ((Character)humanoid).GetMaxHealth(), false);
			}
		}

		public void detectKill(Transform transform)
		{
			//IL_0010: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			if (!expOnKillEnabled)
			{
				return;
			}
			Collider[] array = Physics.OverlapSphere(transform.position, 3f, LayerMask.GetMask(new string[1] { "character" }));
			Collider[] array2 = array;
			HumanoidExtend humanoidExtend = default(HumanoidExtend);
			foreach (Collider val in array2)
			{
				if (((Component)val).TryGetComponent<HumanoidExtend>(ref humanoidExtend))
				{
					Humanoid component = ((Component)humanoidExtend).GetComponent<Humanoid>();
					if (((Character)component).m_faction != ((Character)humanoid).m_faction)
					{
						addExpToFound(humanoidExtend);
					}
				}
			}
		}

		private void ResetLevel()
		{
			if (toggleReset)
			{
				((Character)humanoid).SetLevel(1);
				toggleReset = false;
			}
		}

		private void addExpToFound(HumanoidExtend humanoidExtend)
		{
			humanoidExtend.currentGrowth += expForKill;
		}

		private void OnCollisionEnter(Collision collision)
		{
			int num = Random.Range(1, 100);
			Player val = default(Player);
			if (!itemStolen && num <= 33 && canSteal && collision.gameObject.TryGetComponent<Player>(ref val) && ((Character)val).m_nview.IsValid())
			{
				CustomSteal(monster, val);
				itemStolen = true;
			}
		}

		private void CustomSteal(MonsterAI monster, Player player)
		{
			Inventory inventory = ((Humanoid)player).GetInventory();
			FindItemToSteal(inventory, player);
		}

		private void FindItemToSteal(Inventory inventory, Player player)
		{
			List<ItemData> allItems = inventory.GetAllItems();
			List<ItemData> list = allItems.FindAll((ItemData x) => (!x.m_equipped && x.m_quality == 1 && x.m_variant == 0 && !x.IsWeapon()) || ((Object)x.m_dropPrefab).name.Contains("Torch"));
			if (list.Count > 0)
			{
				int index = Random.Range(0, list.Count() - 1);
				GameObject dropPrefab = list[index].m_dropPrefab;
				string name = list[index].m_shared.m_name;
				Debug.Log((object)("STOLEN ITEM: " + ((Object)dropPrefab).name));
				((Character)player).Message((MessageType)2, name + " was stolen!", 0, (Sprite)null);
				stolenItem = list[index];
				inventory.RemoveItem(list[index]);
				m_nview.InvokeRPC("Steal", new object[2]
				{
					((Object)list[index].m_dropPrefab).name,
					list[index].m_stack
				});
			}
			else
			{
				Debug.Log((object)"There was nothing to steal");
			}
		}

		private void RPC_StolenItem(long sender, string name, int amount)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			ItemDrop component = ObjectDB.instance.m_items.Find((GameObject x) => ((Object)x).name == name).GetComponent<ItemDrop>();
			stolenItem = component.m_itemData.Clone();
			stolenItem.m_stack = amount;
			if ((Object)(object)stealEffect != (Object)null)
			{
				Object.Instantiate<GameObject>(stealEffect, ((Component)this).transform.position, ((Component)this).transform.rotation, (Transform)null);
			}
		}

		public void CustomDoorInteract(Transform character, Door door)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((Component)character).transform.position - ((Component)this).transform.position;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			bool flag = Vector3.Dot(((Component)this).transform.forward, normalized) < 0f;
			door.m_nview.InvokeRPC("UseDoor", new object[2]
			{
				((Object)((Component)humanoid).GetComponent<ZNetView>()).GetInstanceID(),
				flag
			});
		}

		private void DropStolen()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			if (canSteal && itemStolen && stolenItem != null)
			{
				Object.Instantiate<GameObject>(stolenItem.m_dropPrefab, ((Component)this).transform.position, ((Component)this).transform.rotation, (Transform)null).GetComponent<ItemDrop>().m_itemData.m_stack = stolenItem.m_stack;
			}
		}
	}
	[Serializable]
	public class HumanoidRandomizer : MonoBehaviour
	{
		private ZNetView m_zview;

		private MonsterAI m_monsterAI;

		private Humanoid m_humanoid;

		private VisEquipment m_visEquipment;

		public string newName;

		public bool isNameSet = false;

		public List<ItemSet> itemSets;

		public string m_itemSetName = "";

		public string m_itemSetSimplified = "";

		public int m_weaponStance = 0;

		private Animator m_animator;

		public RuntimeAnimatorController sourceAnimator;

		public Biome spawnBiome = (Biome)1;

		private void Awake()
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			if (!validatePrefab())
			{
				Debug.LogWarning((object)("I should not  be randomized: " + ((Object)((Component)this).gameObject).name));
				return;
			}
			m_zview = ((Component)this).GetComponent<ZNetView>();
			m_monsterAI = ((Component)this).GetComponent<MonsterAI>();
			m_humanoid = ((Component)this).GetComponent<Humanoid>();
			m_animator = ((Character)m_humanoid).m_animator;
			m_visEquipment = ((Component)this).GetComponent<VisEquipment>();
			newName = ((Character)m_humanoid).m_name;
			spawnBiome = GetBiome();
			if ((Object)(object)m_visEquipment == (Object)null || (Object)(object)m_animator == (Object)null || (Object)(object)m_humanoid == (Object)null || (Object)(object)m_monsterAI == (Object)null || (Object)(object)m_zview == (Object)null)
			{
				Debug.LogWarning((object)("[HUMANOID RANDOMIZER]Incomplete requirments for: " + ((Object)((Component)this).gameObject).name));
				if ((Object)(object)m_visEquipment == (Object)null)
				{
					Debug.LogWarning((object)"missing: VisEquipment  script");
				}
				if ((Object)(object)m_animator == (Object)null)
				{
					Debug.LogWarning((object)"missing: animator");
				}
				if ((Object)(object)m_humanoid == (Object)null)
				{
					Debug.LogWarning((object)"missing: Humanoid script");
				}
				if ((Object)(object)m_monsterAI == (Object)null)
				{
					Debug.LogWarning((object)"missing: MonsterAi script");
				}
				if ((Object)(object)m_zview == (Object)null)
				{
					Debug.LogWarning((object)"missing: ZnetView script");
				}
			}
			else
			{
				if (itemSets == null || itemSets.Count == 0)
				{
					setupItemSets();
				}
				setAnimatorControler();
				bool @bool = m_zview.m_zdo.GetBool("humanoidRandomizerActive", false);
				PickRandomSet(@bool);
				setWeaponState(m_itemSetName);
				m_monsterAI.m_minAttackInterval = 2f;
				clearMissingFiles();
			}
		}

		private void clearMissingFiles()
		{
			List<GameObject> list = new List<GameObject>();
			GameObject[] defaultItems = m_humanoid.m_defaultItems;
			foreach (GameObject val in defaultItems)
			{
				if ((Object)(object)val != (Object)null)
				{
					list.Add(val);
				}
			}
			m_humanoid.m_defaultItems = list.ToArray();
			List<GameObject> list2 = new List<GameObject>();
			GameObject[] randomArmor = m_humanoid.m_randomArmor;
			foreach (GameObject val2 in randomArmor)
			{
				if ((Object)(object)val2 != (Object)null)
				{
					list2.Add(val2);
				}
			}
			m_humanoid.m_defaultItems = list2.ToArray();
			List<GameObject> list3 = new List<GameObject>();
			GameObject[] randomShield = m_humanoid.m_randomShield;
			foreach (GameObject val3 in randomShield)
			{
				if ((Object)(object)val3 != (Object)null)
				{
					list3.Add(val3);
				}
			}
			m_humanoid.m_defaultItems = list3.ToArray();
		}

		private void setupItemSets()
		{
			switch (editZnetName(((Object)this).name))
			{
			case "Skeleton":
				itemSets = VariantTypeCheck.itemSetsSkeleton;
				break;
			case "Skeleton_NoArcher":
				itemSets = VariantTypeCheck.itemSetsSkeletonNoArcher;
				break;
			case "Skeleton_Poison":
				itemSets = VariantTypeCheck.itemSetsSkeletonPoison;
				break;
			case "Draugr":
				itemSets = VariantTypeCheck.itemSetsDraugr;
				break;
			case "Draugr_Elite":
				itemSets = VariantTypeCheck.itemSetsDraugrElite;
				break;
			case "Draugr_Ranged":
				itemSets = VariantTypeCheck.itemSetsDraugrRanged;
				break;
			case "Goblin":
				itemSets = VariantTypeCheck.itemSetsGoblin;
				break;
			case "GoblinArcher":
				itemSets = VariantTypeCheck.itemSetsGoblinArcher;
				break;
			case "GoblinShaman":
				itemSets = VariantTypeCheck.itemSetsGoblinShaman;
				break;
			}
		}

		private bool validatePrefab()
		{
			string[] array = new string[9] { "Skeleton", "Skeleton_NoArcher", "Skeleton_Poison", "Draugr", "Draugr_Elite", "Draugr_Ranged", "Goblin", "GoblinArcher", "GoblinShaman" };
			bool flag = false;
			string[] array2 = array;
			foreach (string value in array2)
			{
				if (((Object)((Component)this).gameObject).name.Contains(value))
				{
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				return false;
			}
			string name = ((Object)((Component)this).gameObject).name;
			name = editZnetName(name);
			return array.Contains(name);
		}

		private string editZnetName(string name)
		{
			name = name.Replace("(Clone)", "");
			int num = name.IndexOf("(");
			if (num >= 0)
			{
				name = name.Substring(0, num);
			}
			return name.Trim();
		}

		private void setAnimatorControler()
		{
			Animator componentInChildren = ((Component)this).gameObject.GetComponentInChildren<Animator>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				componentInChildren.runtimeAnimatorController = sourceAnimator;
			}
			else
			{
				m_animator.runtimeAnimatorController = sourceAnimator;
			}
		}

		private void PickRandomSet(bool chosen = false)
		{
			string setName = "";
			if (chosen)
			{
				setName = m_zview.m_zdo.GetString("humanoidRandomizerSetName", "");
			}
			while (setName == "" || setName == null)
			{
				setName = getWeightedSetName();
			}
			if (setName == "" || setName == null)
			{
				Debug.LogWarning((object)"No item set found");
				return;
			}
			ItemSet val;
			for (val = itemSets.Find((ItemSet x) => x.m_name == setName); val == null; val = itemSets.Find((ItemSet x) => x.m_name == setName))
			{
				setName = getWeightedSetName();
			}
			m_zview.m_zdo.Set("humanoidRandomizerSetName", setName);
			m_itemSetName = setName;
			m_itemSetSimplified = setName;
			List<ItemSet> list = new List<ItemSet>();
			list.Add(val);
			m_humanoid.m_randomSets = list.ToArray();
			m_zview.m_zdo.Set("humanoidRandomizerActive", true);
		}

		private bool CheckBiome(Biome m_biome)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			return (Heightmap.FindBiome(((Component)this).transform.position) & m_biome) > 0;
		}

		private Biome GetBiome()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			return Heightmap.FindBiome(((Component)this).transform.position);
		}

		private string getWeightedSetName()
		{
			int num = Random.Range(1, 100);
			List<string> list = new List<string>();
			while (list.Count == 0)
			{
				list = new List<string>();
				foreach (KeyValuePair<string, int> weight in VariantTypeCheck.weights)
				{
					int id = VariantTypeCheck.biome[weight.Key];
					if (IsCorrectBiome(id, editZnetName(((Object)this).name)) && weight.Value > num)
					{
						list.Add(weight.Key);
					}
				}
				if (list.Count == 0)
				{
					num = Random.Range(1, 100);
				}
			}
			int index = Random.Range(0, list.Count - 1);
			return list[index];
		}

		private bool IsCorrectBiome(int id, string name)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Invalid comparison between Unknown and I4
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Invalid comparison between Unknown and I4
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Invalid comparison between Unknown and I4
			if (name == "Skeleton" || name == "Skeleton_NoArcher" || name == "Skeleton_Poison")
			{
				switch (id)
				{
				case 1:
					return true;
				case 2:
					if ((int)spawnBiome != 1)
					{
						return true;
					}
					break;
				}
				if (id == 3 && (int)spawnBiome != 1 && (int)spawnBiome != 8)
				{
					return true;
				}
				return false;
			}
			return true;
		}

		private int weightedRoll()
		{
			return Random.Range(0, itemSets.Count - 1);
		}

		private void setMonsterName()
		{
			if (((Character)m_humanoid).m_name != prototyepname() + " " + m_itemSetSimplified)
			{
				newName = prototyepname() + " " + m_itemSetSimplified;
				((Character)m_humanoid).m_name = newName;
			}
		}

		private string prototyepname()
		{
			GameObject val = ZNetScene.instance.m_prefabs.Find((GameObject x) => ((Object)x).name == editZnetName(((Object)((Component)this).gameObject).name));
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogWarning((object)"Original not found");
				return ((Character)m_humanoid).m_name;
			}
			string result = ((Character)val.GetComponent<Humanoid>()).m_name;
			if (((Object)((Component)this).gameObject).name == "Skeleton_Poison")
			{
				result = "Rancid";
			}
			return result;
		}

		private string simplifyName(string setName)
		{
			if (m_itemSetName.Contains("Guardian"))
			{
				return "Guardian";
			}
			if (m_itemSetName.Contains("Marauder"))
			{
				return "Marauder";
			}
			if (m_itemSetName.Contains("Warrior"))
			{
				return "Warrior";
			}
			return setName;
		}

		private void setWeaponState(string setName)
		{
			m_animator.SetFloat("weaponStance", 0f);
			switch (setName)
			{
			case "Sailor":
			case "Bonebreaker":
			case "Frozenhammer":
			case "Splasher":
				m_animator.SetFloat("weaponStance", 3f);
				break;
			case "Swordmaster":
			case "Blackblade":
			case "Soulcalibur":
				m_animator.SetFloat("weaponStance", 2f);
				break;
			case "Executioner":
			case "Reaper":
			case "Reaver":
				m_animator.SetFloat("weaponStance", 1f);
				break;
			case "Arbalist":
				m_animator.SetFloat("weaponStance", 4f);
				break;
			case "Stabber":
			case "Thief":
			case "Assassin":
			case "Savage":
			case "Corsair":
			case "Lightbringer":
				m_animator.SetFloat("weaponStance", 5f);
				break;
			default:
				m_animator.SetFloat("weaponStance", 0f);
				break;
			}
		}

		public void AddArmorPieces()
		{
			if (((Character)m_humanoid).m_level == 1 || (((Object)((Component)this).gameObject).name != "Goblin(Clone)" && ((Object)((Component)this).gameObject).name != "GoblinArcher(Clone)") || ((Character)m_humanoid).m_level == 1)
			{
				return;
			}
			List<GameObject> list = new List<GameObject>();
			list.AddRange(m_humanoid.m_randomSets[0].m_items);
			GameObject helmet = ObjectDB.instance.m_items.Find((GameObject x) => ((Object)x).name == "GoblinHelmet");
			GameObject arms = ObjectDB.instance.m_items.Find((GameObject x) => ((Object)x).name == "GoblinArmband");
			GameObject sholders = ObjectDB.instance.m_items.Find((GameObject x) => ((Object)x).name == "GoblinShoulders");
			GameObject boots = ObjectDB.instance.m_items.Find((GameObject x) => ((Object)x).name == "GoblinLegband");
			switch (((Character)m_humanoid).m_level)
			{
			case 2:
				if ((Object)(object)list.Find((GameObject x) => ((Object)x).name == ((Object)arms).name) == (Object)null)
				{
					list.Add(arms);
				}
				break;
			case 3:
				if ((Object)(object)list.Find((GameObject x) => ((Object)x).name == ((Object)arms).name) == (Object)null)
				{
					list.Add(arms);
				}
				if ((Object)(object)list.Find((GameObject x) => ((Object)x).name == ((Object)boots).name) == (Object)null)
				{
					list.Add(boots);
				}
				break;
			case 4:
				if ((Object)(object)list.Find((GameObject x) => ((Object)x).name == ((Object)arms).name) == (Object)null)
				{
					list.Add(arms);
				}
				if ((Object)(object)list.Find((GameObject x) => ((Object)x).name == ((Object)boots).name) == (Object)null)
				{
					list.Add(boots);
				}
				if ((Object)(object)list.Find((GameObject x) => ((Object)x).name == ((Object)helmet).name) == (Object)null)
				{
					list.Add(helmet);
				}
				break;
			case 5:
			case 6:
			case 7:
				if ((Object)(object)list.Find((GameObject x) => ((Object)x).name == ((Object)arms).name) == (Object)null)
				{
					list.Add(arms);
				}
				if ((Object)(object)list.Find((GameObject x) => ((Object)x).name == ((Object)boots).name) == (Object)null)
				{
					list.Add(boots);
				}
				if ((Object)(object)list.Find((GameObject x) => ((Object)x).name == ((Object)helmet).name) == (Object)null)
				{
					list.Add(helmet);
				}
				if ((Object)(object)list.Find((GameObject x) => ((Object)x).name == ((Object)sholders).name) == (Object)null)
				{
					list.Add(sholders);
				}
				break;
			}
			m_humanoid.m_randomSets[0].m_items = list.ToArray();
		}
	}
	public class LevelEffectGenerator
	{
		private BaseLevelEffectSetupValue baseLevelEffectSetupValue = new BaseLevelEffectSetupValue();

		public void CreateVisuals(LevelEffects levelEffects)
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			baseLevelEffectSetupValue.getSetup(levelEffects);
			int num = 0;
			if (levelEffects.m_levelSetups != null)
			{
				num = levelEffects.m_levelSetups.Count;
			}
			int num2 = 6 - num;
			for (int i = 0; i < num2; i++)
			{
				LevelSetup item = createSetup(baseLevelEffectSetupValue.scale, baseLevelEffectSetupValue.saturation, baseLevelEffectSetupValue.hue, baseLevelEffectSetupValue.value, baseLevelEffectSetupValue.setEmmisive, baseLevelEffectSetupValue.emissive, baseLevelEffectSetupValue.sumValue * (float)(i + 1), num2, i + 1);
				levelEffects.m_levelSetups.Add(item);
			}
		}

		public LevelEffects CreateLevelEffectAt(Transform visual, SkinnedMeshRenderer meshRenderer)
		{
			if ((Object)(object)meshRenderer == (Object)null)
			{
				Debug.LogWarning((object)("NO renderer to create Visual Effects:" + ((Object)visual.parent).name));
				return null;
			}
			if ((Object)(object)meshRenderer != (Object)null)
			{
				LevelEffects val = ((Component)visual).gameObject.AddComponent<LevelEffects>();
				val.m_mainRender = (Renderer)(object)meshRenderer;
				val.m_character = (Character)(object)((Component)visual.parent).gameObject.GetComponent<Humanoid>();
				return val;
			}
			return null;
		}

		public LevelEffects CreateLevelEffectComponent(Transform visual)
		{
			SkinnedMeshRenderer[] componentsInChildren = ((Component)visual).GetComponentsInChildren<SkinnedMeshRenderer>();
			if (componentsInChildren.Length > 1)
			{
				Debug.LogWarning((object)("To many renderers to create Visual Effects:" + ((Object)visual.parent).name));
				return null;
			}
			if (componentsInChildren.Length == 1)
			{
				LevelEffects val = ((Component)visual).gameObject.AddComponent<LevelEffects>();
				val.m_mainRender = (Renderer)(object)componentsInChildren[0];
				val.m_character = (Character)(object)((Component)visual.parent).gameObject.GetComponent<Humanoid>();
				return val;
			}
			return null;
		}

		private LevelSetup createSetup(float scale, float saturation, float hue, float value, bool isEmmisive, Color emission, float changeValue, int maxAmount, int lvl)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			LevelSetup val = new LevelSetup();
			val.m_scale = scale;
			val.m_saturation = saturation + changeValue;
			val.m_hue = hue + changeValue;
			val.m_value = value + changeValue;
			val.m_enableObject = pickEnabledObject(maxAmount, lvl);
			val.m_setEmissiveColor = isEmmisive;
			val.m_emissiveColor = new Color(emission.r + changeValue, emission.g + changeValue, emission.b + changeValue, emission.a);
			return val;
		}

		private GameObject pickEnabledObject(int maxAmount, int lvl)
		{
			if (maxAmount == 6)
			{
				if (lvl > 4)
				{
					return baseLevelEffectSetupValue.enabledObjectLevel3;
				}
				if (lvl > 2)
				{
					return baseLevelEffectSetupValue.enabledObjectLevel2;
				}
			}
			if (maxAmount == 3)
			{
				if (lvl > 3)
				{
					return baseLevelEffectSetupValue.enabledObjectLevel3;
				}
				if (lvl > 2)
				{
					return baseLevelEffectSetupValue.enabledObjectLevel2;
				}
			}
			if (maxAmount < 3)
			{
				switch (lvl)
				{
				case 2:
					return baseLevelEffectSetupValue.enabledObjectLevel3;
				case 1:
					return baseLevelEffectSetupValue.enabledObjectLevel2;
				}
			}
			return baseLevelEffectSetupValue.enabledObject;
		}
	}
	[Serializable]
	internal class MonsterHunger : MonoBehaviour
	{
		private MonsterAI monsterAI;

		private ZNetView zNetView;

		private Tameable tameable;

		private Humanoid humanoid;

		public float hungerTime = 600f;

		public bool canEat = true;

		private float currentHunger = 0f;

		public ItemDrop itemToConsume = null;

		private void Awake()
		{
			monsterAI = ((Component)this).GetComponent<MonsterAI>();
			zNetView = ((Component)this).GetComponent<ZNetView>();
			tameable = ((Component)this).GetComponent<Tameable>();
			humanoid = ((Component)this).GetComponent<Humanoid>();
			if ((Object)(object)tameable != (Object)null)
			{
				hungerTime = tameable.m_fedDuration;
			}
			((MonoBehaviour)this).InvokeRepeating("Hunger", 1f, 1f);
		}

		public void MonsterFoodHeal()
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			if (canEat)
			{
				((BaseAI)monsterAI).m_character.Heal(((BaseAI)monsterAI).m_character.GetMaxHealth() / 5f, true);
				monsterAI.m_onConsumedItem(itemToConsume);
				humanoid.m_consumeItemEffects.Create(((Component)this).transform.position, Quaternion.identity, (Transform)null, 1f, -1);
				((BaseAI)monsterAI).m_animator.SetTrigger("consume");
				itemToConsume = null;
				canEat = false;
				currentHunger = 0f;
			}
		}

		private void Hunger()
		{
			currentHunger += 1f;
			if (currentHunger >= hungerTime)
			{
				canEat = true;
			}
		}
	}
	public class BuildPieceTargeting
	{
		private static string[] names = new string[0];

		public void changePieceTargeting(List<GameObject> gameObjects)
		{
			List<GameObject> list = gameObjects.FindAll((GameObject x) => (Object)(object)x.GetComponent<WearNTear>() != (Object)null);
			foreach (GameObject item in list)
			{
				Piece component = item.GetComponent<Piece>();
				if ((Object)(object)component != (Object)null && names.Contains(((Object)item).name))
				{
					((StaticTarget)component).m_primaryTarget = true;
				}
				if ((Object)(object)component != (Object)null && shouldBePrimaryTarget(item))
				{
					((StaticTarget)component).m_primaryTarget = true;
				}
				setResistances(item);
			}
		}

		private bool shouldBePrimaryTarget(GameObject gameObject)
		{
			if ((Object)(object)gameObject.GetComponent<Door>() != (Object)null)
			{
				return true;
			}
			if ((Object)(object)gameObject.GetComponent<CraftingStation>() != (Object)null)
			{
				return true;
			}
			if ((Object)(object)gameObject.GetComponent<StationExtension>() != (Object)null)
			{
				return true;
			}
			if ((Object)(object)gameObject.GetComponent<Container>() != (Object)null)
			{
				return false;
			}
			return false;
		}

		private void setResistances(GameObject gameObject)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			WearNTear component = gameObject.GetComponent<WearNTear>();
			if ((Object)(object)component != (Object)null)
			{
				component.m_damages.m_chop = setChopDamageResistance(component);
				component.m_damages.m_pickaxe = setPickaxeDamageResistance(component);
				component.m_damages.m_fire = setFireDamageResistance(component);
			}
		}

		private DamageModifier setChopDamageResistance(WearNTear wearNTear)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected I4, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			MaterialType materialType = wearNTear.m_materialType;
			MaterialType val = materialType;
			return (DamageModifier)((int)val switch
			{
				0 => 6, 
				3 => 2, 
				2 => 5, 
				1 => 1, 
				_ => 0, 
			});
		}

		private DamageModifier setPickaxeDamageResistance(WearNTear wearNTear)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected I4, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			MaterialType materialType = wearNTear.m_materialType;
			MaterialType val = materialType;
			return (DamageModifier)((int)val switch
			{
				0 => 0, 
				3 => 1, 
				2 => 2, 
				1 => 6, 
				_ => 0, 
			});
		}

		private DamageModifier setFireDamageResistance(WearNTear wearNTear)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected I4, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			MaterialType materialType = wearNTear.m_materialType;
			MaterialType val = materialType;
			return (DamageModifier)((int)val switch
			{
				0 => 6, 
				3 => 2, 
				2 => 0, 
				1 => 5, 
				_ => 0, 
			});
		}
	}
	public class DatabaseAddMethods
	{
		public void AddItems(List<GameObject> items)
		{
			foreach (GameObject item in items)
			{
				AddItem(item);
			}
		}

		public void AddRecipes(List<Recipe> recipes)
		{
			foreach (Recipe recipe in recipes)
			{
				AddRecipe(recipe);
			}
		}

		public void AddStatuseffects(List<StatusEffect> statusEffects)
		{
			foreach (StatusEffect statusEffect in statusEffects)
			{
				AddStatus(statusEffect);
			}
		}

		private bool IsObjectDBValid()
		{
			return (Object)(object)ObjectDB.instance != (Object)null && ObjectDB.instance.m_items.Count != 0 && ObjectDB.instance.m_recipes.Count != 0 && (Object)(object)ObjectDB.instance.GetItemPrefab("Amber") != (Object)null;
		}

		private void AddStatus(StatusEffect status)
		{
			if (!IsObjectDBValid())
			{
				return;
			}
			if ((Object)(object)status != (Object)null)
			{
				if ((Object)(object)ObjectDB.instance.m_StatusEffects.Find((StatusEffect x) => ((Object)x).name == ((Object)status).name) == (Object)null)
				{
					ObjectDB.instance.m_StatusEffects.Add(status);
				}
			}
			else
			{
				Debug.LogError((object)("BalrondHumanoidRandomizer:  " + ((Object)status).name + " - Status not found"));
			}
		}

		private void AddRecipe(Recipe recipe)
		{
			if (!IsObjectDBValid())
			{
				return;
			}
			if ((Object)(object)recipe != (Object)null)
			{
				if ((Object)(object)ObjectDB.instance.GetRecipe(recipe.m_item.m_itemData) == (Object)null)
				{
					ObjectDB.instance.m_recipes.Add(recipe);
				}
			}
			else
			{
				Debug.LogError((object)("BalrondHumanoidRandomizer:  " + ((Object)recipe).name + " - Recipe not found"));
			}
		}

		private void AddItem(GameObject newPrefab)
		{
			if (!IsObjectDBValid())
			{
				return;
			}
			ItemDrop component = newPrefab.GetComponent<ItemDrop>();
			if ((Object)(object)component != (Object)null)
			{
				if ((Object)(object)ObjectDB.instance.GetItemPrefab(((Object)newPrefab).name) == (Object)null)
				{
					ObjectDB.instance.m_items.Add(newPrefab);
					Dictionary<int, GameObject> dictionary = (Dictionary<int, GameObject>)typeof(ObjectDB).GetField("m_itemByHash", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(ObjectDB.instance);
					dictionary[((Object)newPrefab).name.GetHashCode()] = newPrefab;
				}
			}
			else
			{
				Debug.LogError((object)("BalrondHumanoidRandomizer:  " + ((Object)newPrefab).name + " - ItemDrop not found on prefab"));
			}
		}
	}
	[BepInPlugin("balrond.astafaraios.BalrondHumanoidRandomizer", "BalrondHumanoidRandomizer", "1.3.6")]
	public class Launch : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(Game), "Awake")]
		public static class Game_Awake_Path
		{
			public static void Prefix()
			{
				hasSpawned = false;
				SetupNewHudElements();
			}
		}

		[HarmonyPatch(typeof(MonsterAI), "Awake")]
		public static class MonsterAI_Path
		{
			public static void Postfix(MonsterAI __instance)
			{
				if (((Object)((Component)__instance).gameObject).name.Contains("Variant") || (Object)(object)((Component)__instance).gameObject.GetComponent<HumanoidRandomizer>() != (Object)null)
				{
					__instance.m_minAttackInterval = 2.5f;
				}
			}
		}

		[HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")]
		public static class Object_CopyOtherDB_Path
		{
			public static void Postfix()
			{
				if (IsObjectDBValid())
				{
					StatusEffect val = ObjectDB.instance.m_StatusEffects.Find((StatusEffect x) => ((Object)x).name == "Spirit");
					val.m_icon = modResourceLoader.spiritBurnIcon;
					itemEdits.editItems(ObjectDB.instance.m_items);
					databaseAddMethods.AddStatuseffects(modResourceLoader.statusEffects);
					databaseAddMethods.AddRecipes(modResourceLoader.recipes);
					databaseAddMethods.AddItems(modResourceLoader.attackList);
					databaseAddMethods.AddItems(modResourceLoader.visualList);
				}
			}
		}

		[HarmonyPatch(typeof(ObjectDB), "Awake")]
		public static class ObjectDB_Awake_Path
		{
			public static bool hasSpawned;

			public static void Postfix()
			{
				if (IsObjectDBValid())
				{
					StatusEffect val = ObjectDB.instance.m_StatusEffects.Find((StatusEffect x) => ((Object)x).name == "Spirit");
					val.m_icon = modResourceLoader.spiritBurnIcon;
					itemEdits.editItems(ObjectDB.instance.m_items);
					databaseAddMethods.AddStatuseffects(modResourceLoader.statusEffects);
					databaseAddMethods.AddRecipes(modResourceLoader.recipes);
					databaseAddMethods.AddItems(modResourceLoader.attackList);
					databaseAddMethods.AddItems(modResourceLoader.visualList);
				}
			}
		}

		[HarmonyPatch(typeof(Game), "RequestRespawn")]
		public static class Game_RequestRespawn_Path
		{
			public static void Postfix()
			{
				if (!hasSpawned)
				{
					GameObject playerResistance = ZNetScene.instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "Player");
					setPlayerResistance(playerResistance);
				}
			}
		}

		[HarmonyPatch(typeof(CharacterDrop), "GenerateDropList")]
		public static class CharacterDrop_GenerateDropList_Path
		{
			public static void Prefix(CharacterDrop __instance)
			{
				if (__instance.m_character.GetLevel() >= 4)
				{
					__instance.m_character.SetLevel(4);
				}
			}
		}

		[HarmonyPatch(typeof(ZNetScene), "Awake")]
		public static class ZNetScene_Awake_Path
		{
			public static void Prefix(ZNetScene __instance)
			{
				//IL_033d: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)__instance == (Object)null)
				{
					Debug.LogWarning((object)"BalrondHumanoidRandomizer: No ZnetScene found");
					return;
				}
				modResourceLoader.AddPrefabsToZnetScene(__instance);
				if (!hasSpawned)
				{
					pieceTargeting.changePieceTargeting(__instance.m_prefabs);
					itemSetBuilder.setup(__instance.m_prefabs);
					itemSetBuilder.fixAllReferences();
					GameObject monster = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "Skeleton");
					GameObject monster2 = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "Skeleton_NoArcher");
					GameObject monster3 = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "Skeleton_Poison");
					GameObject monster4 = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "Draugr");
					GameObject monster5 = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "Draugr_Ranged");
					GameObject monster6 = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "Draugr_Elite");
					GameObject monster7 = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "Goblin");
					GameObject monster8 = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "GoblinArcher");
					GameObject monster9 = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "GoblinShaman");
					StatusEffect statusEffect = ObjectDB.instance.m_StatusEffects.Find((StatusEffect x) => x.m_name == "Shield_MonsterRandomizer");
					StatusEffectBuilder.setupVisualsForStatus(statusEffect, __instance.m_prefabs);
					itemSetBuilder.CreateItemSets(monster, modResourceLoader.animatorController);
					itemSetBuilder.CreateItemSets(monster2, modResourceLoader.animatorController);
					itemSetBuilder.CreateItemSets(monster3, modResourceLoader.animatorController);
					itemSetBuilder.CreateItemSets(monster4, modResourceLoader.animatorControllerDraugr);
					itemSetBuilder.CreateItemSets(monster5, modResourceLoader.animatorControllerDraugr);
					itemSetBuilder.CreateItemSets(monster6, modResourceLoader.animatorControllerDraugr);
					itemSetBuilder.CreateItemSets(monster7, modResourceLoader.animatorController);
					itemSetBuilder.CreateItemSets(monster8, modResourceLoader.animatorController);
					itemSetBuilder.CreateItemSets(monster9, modResourceLoader.animatorController);
					addPrefabList(itemSetBuilder.prefabs, __instance.m_prefabs);
					monsterManager.setupMonsterList(__instance.m_prefabs);
					monsterManager.changeMonsterResistance();
					monsterManager.setupSpawners(__instance.m_prefabs);
					if (!new ZNet().IsDedicated())
					{
						ShaderReplacment.runMaterialFix();
						hasSpawned = true;
					}
				}
			}
		}

		[HarmonyPatch(typeof(EnemyHud), "UpdateHuds")]
		public static class EnemyHudUpdateHuds_Path
		{
			public static void Prefix(EnemyHud __instance)
			{
				foreach (KeyValuePair<Character, HudData> hud in __instance.m_huds)
				{
					HudData value = hud.Value;
					if (value == null || !Object.op_Implicit((Object)(object)value.m_character) || (!value.m_character.IsPlayer() && !value.m_character.IsBoss() && !value.m_isMount && !((double)value.m_hoverTimer < (double)__instance.m_hoverShowDuration)))
					{
						continue;
					}
					value.m_gui.SetActive(true);
					if (!value.m_character.IsBoss())
					{
						switch (value.m_character.GetLevel())
						{
						case 4:
							setUiStarelements(value, 4);
							break;
						case 5:
							setUiStarelements(value, 5);
							break;
						case 6:
							setUiStarelements(value, 6);
							break;
						case 7:
							setUiStarelements(value, 7);
							break;
						}
					}
					if (value.m_character.IsBoss())
					{
						switch (value.m_character.GetLevel())
						{
						case 2:
							setBossUiStarelements(value, 2);
							break;
						case 3:
							setBossUiStarelements(value, 3);
							break;
						case 4:
							setBossUiStarelements(value, 4);
							break;
						case 5:
							setBossUiStarelements(value, 5);
							break;
						case 6:
							setBossUiStarelements(value, 6);
							break;
						case 7:
							setBossUiStarelements(value, 7);
							break;
						}
					}
				}
			}
		}

		[HarmonyPatch(typeof(Character), "RPC_Damage")]
		public static class RPC_DamagePatch
		{
			public static int chanceForBlunt = 1;

			public static int chanceForPierce = 1;

			public static int chanceForSLash = 1;

			public static void Prefix(Character __instance, HitData hit)
			{
				if (hit != null)
				{
					Character attacker = hit.GetAttacker();
					if ((Object)(object)attacker != (Object)null && !attacker.IsPlayer())
					{
						hit = HumanoidRandomizerDamageModificator.modifyOutput(((Component)attacker).gameObject, hit);
					}
				}
			}
		}

		private readonly Harmony harmony = new Harmony("balrond.astafaraios.BalrondHumanoidRandomizer");

		public const string PluginGUID = "balrond.astafaraios.BalrondHumanoidRandomizer";

		public const string PluginName = "BalrondHumanoidRandomizer";

		public const string PluginVersion = "1.3.6";

		public static ModResourceLoader modResourceLoader = new ModResourceLoader();

		public static ItemEdits itemEdits = new ItemEdits();

		public static DatabaseAddMethods databaseAddMethods = new DatabaseAddMethods();

		public static MonsterManager monsterManager = new MonsterManager();

		public static BuildPieceTargeting pieceTargeting = new BuildPieceTargeting();

		public static MonsterFeeding MonsterFeeding = new MonsterFeeding();

		public static AttachBuilder attachBuilder = new AttachBuilder();

		public static ItemSetBuilder itemSetBuilder = new ItemSetBuilder();

		public static HumanoidRandomizerDamageModificator HumanoidRandomizerDamageModificator = new HumanoidRandomizerDamageModificator();

		public static GameObject gui;

		public static GameObject gui2;

		public static GameObject RootObject;

		public static GameObject PrefabContainer;

		public static GameObject rightHand;

		public static GameObject leftHand;

		public static bool hasSpawned = false;

		public static string[] validNames = new string[10] { "Skeleton_NoArcher", "Skeleton_Poison", "Skeleton", "Draugr", "Draugr_Elite", "Draugr_Ranged", "Goblin", "GoblinArcher", "GoblinShaman", "Surtling" };

		private void Awake()
		{
			createPrefabContainer();
			modResourceLoader.loadAssets();
			rightHand = modResourceLoader.rightHand;
			leftHand = modResourceLoader.leftHand;
			HumanoidRandomizerDamageModificator.setup();
			attachBuilder.createPrefabContainer();
			VariantTypeCheck.weights = VariantTypeCheck.setupChances();
			VariantTypeCheck.setBiomeRestriction();
			harmony.PatchAll();
		}

		private void OnDestroy()
		{
			harmony.UnpatchSelf();
		}

		public void createPrefabContainer()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			RootObject = new GameObject("_ValheimReforgedRoot");
			Object.DontDestroyOnLoad((Object)(object)RootObject);
			PrefabContainer = new GameObject("Prefabs");
			PrefabContainer.transform.parent = RootObject.transform;
			PrefabContainer.SetActive(false);
		}

		public static GameObject cloneMe(GameObject source, string name = "")
		{
			GameObject val = Object.Instantiate<GameObject>(source, PrefabContainer.transform);
			if (name != "")
			{
				((Object)val).name = name;
			}
			else
			{
				((Object)val).name = ((Object)source).name;
			}
			if ((Object)(object)val != (Object)null)
			{
			}
			return val;
		}

		private static bool IsObjectDBValid()
		{
			return (Object)(object)ObjectDB.instance != (Object)null && ObjectDB.instance.m_items.Count != 0 && ObjectDB.instance.m_recipes.Count != 0 && (Object)(object)ObjectDB.instance.GetItemPrefab("Amber") != (Object)null;
		}

		public static void SetupNewHudElements()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			if (!(((Scene)(ref activeScene)).name == "main"))
			{
				return;
			}
			if ((Object)(object)gui == (Object)null)
			{
				gui = GameObject.Find("_GameMain/LoadingGUI/PixelFix/IngameGui/EnemyHud/HudRoot/HudBase");
			}
			if ((Object)(object)gui2 == (Object)null)
			{
				gui2 = GameObject.Find("_GameMain/LoadingGUI/PixelFix/IngameGui/EnemyHud/HudRoot/HudBaseBoss");
			}
			if ((Object)(object)gui != (Object)null)
			{
				if (modResourceLoader == null)
				{
					Debug.LogWarning((object)"Resource loader is empty!");
					return;
				}
				if ((Object)(object)modResourceLoader.lvl4 == (Object)null)
				{
					modResourceLoader.loadNewStars();
				}
				modResourceLoader.lvl4.transform.SetParent(gui.transform);
				modResourceLoader.lvl5.transform.SetParent(gui.transform);
				modResourceLoader.lvl6.transform.SetParent(gui.transform);
				modResourceLoader.lvl7.transform.SetParent(gui.transform);
			}
			else
			{
				Debug.LogWarning((object)"I did not load the UI");
			}
			if ((Object)(object)gui2 != (Object)null)
			{
				if (modResourceLoader == null)
				{
					Debug.LogWarning((object)"Resource loader is empty!");
				}
				if ((Object)(object)modResourceLoader.lvl2boss == (Object)null)
				{
					modResourceLoader.LoadNewBossStars();
				}
				modResourceLoader.lvl2boss.transform.SetParent(gui2.transform);
				modResourceLoader.lvl3boss.transform.SetParent(gui2.transform);
				modResourceLoader.lvl4boss.transform.SetParent(gui2.transform);
				modResourceLoader.lvl5boss.transform.SetParent(gui2.transform);
				modResourceLoader.lvl6boss.transform.SetParent(gui2.transform);
				modResourceLoader.lvl7boss.transform.SetParent(gui2.transform);
			}
			else
			{
				Debug.LogWarning((object)"I did not load the BOSS UI");
			}
		}

		public static void addStatusToAttackField(GameObject gameObject, StatusEffect statusEffect)
		{
			ItemDrop component = gameObject.GetComponent<ItemDrop>();
			component.m_itemData.m_shared.m_equipStatusEffect = statusEffect;
		}

		public static void addPrefabList(List<GameObject> newList, List<GameObject> znetScene)
		{
			foreach (GameObject prefab in newList)
			{
				if ((Object)(object)prefab != (Object)null && znetScene.FindAll((GameObject x) => ((Object)x).name == ((Object)prefab).name).Count == 0)
				{
					znetScene.Add(prefab);
				}
			}
		}

		public List<GameObject> GeneratePrefabs(GameObject gameObject)
		{
			List<GameObject> list = new List<GameObject>();
			List<ItemSet> itemSets = gameObject.GetComponent<HumanoidRandomizer>().itemSets;
			foreach (ItemSet item in itemSets)
			{
				GameObject val = cloneMe(gameObject, ((Object)gameObject).name + "_Variant_" + item.m_name);
				if ((Object)(object)val == (Object)null)
				{
					Debug.LogWarning((object)("Unable to clone: " + ((Object)gameObject).name));
					continue;
				}
				Humanoid component = val.GetComponent<Humanoid>();
				component.m_defaultItems = item.m_items;
				HumanoidRandomizer component2 = val.GetComponent<HumanoidRandomizer>();
				if ((Object)(object)component2 != (Object)null)
				{
					Object.Destroy((Object)(object)component2);
				}
				if (((Object)gameObject).name == "Skeleton_Poison")
				{
					((Character)component).m_name = "Rancid";
				}
				((Character)component).m_name = ((Character)component).m_name + " " + item.m_name;
				switch (item.m_name)
				{
				case "Bonebreaker":
					((Character)component).m_animator.SetFloat("weaponStance", 3f);
					break;
				case "Swordmaster":
					((Character)component).m_animator.SetFloat("weaponStance", 2f);
					break;
				case "Executioner":
					((Character)component).m_animator.SetFloat("weaponStance", 1f);
					break;
				case "Arbalist":
					((Character)component).m_animator.SetFloat("weaponStance", 4f);
					break;
				case "Assassin":
				case "Savage":
					((Character)component).m_animator.SetFloat("weaponStance", 5f);
					break;
				default:
					((Character)component).m_animator.SetFloat("weaponStance", 0f);
					break;
				}
				list.Add(val);
			}
			Debug.LogWarning((object)("Generated variants: " + list.Count));
			return list;
		}

		public static void prepareSurtling(GameObject gameObject)
		{
			VisEquipment val = gameObject.AddComponent<VisEquipment>();
			Transform[] componentsInChildren = gameObject.GetComponentsInChildren<Transform>(true);
			Transform[] array = componentsInChildren;
			foreach (Transform val2 in array)
			{
				if ("mixamorig:RightHand" == ((Object)val2).name)
				{
					rightHand.transform.parent = val2;
				}
				if ("mixamorig:LeftHand" == ((Object)val2).name)
				{
					leftHand.transform.parent = val2;
				}
			}
			val.m_rightHand = rightHand.transform;
			val.m_leftHand = leftHand.transform;
		}

		public static void setPlayerResistance(GameObject player)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			Humanoid component = player.GetComponent<Humanoid>();
			((Character)component).m_damageModifiers.m_spirit = (DamageModifier)0;
		}

		public static void setUiStarelements(HudData hudData, int level)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			Transform val = ((Transform)hudData.m_level2).parent.Find("level_" + level);
			if ((Object)(object)val != (Object)null)
			{
				GameObject gameObject = ((Component)val).gameObject;
				gameObject.SetActive(true);
				gameObject.transform.position = ((Component)hudData.m_level2).transform.position;
				gameObject.transform.localPosition = ((Component)hudData.m_level2).transform.localPosition;
				gameObject.transform.rotation = ((Component)hudData.m_level2).transform.rotation;
			}
			else
			{
				Debug.LogWarning((object)("Cannot find object level_" + level));
			}
		}

		public static void setBossUiStarelements(HudData hudData, int level)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			Transform val = ((Component)hudData.m_healthFast).transform.parent.parent.Find("level_" + level + "_boss");
			if ((Object)(object)val != (Object)null)
			{
				GameObject gameObject = ((Component)val).gameObject;
				gameObject.SetActive(true);
				gameObject.transform.position = ((Component)hudData.m_healthFast).transform.position;
				gameObject.transform.localPosition = ((Component)hudData.m_healthFast).transform.localPosition;
				gameObject.transform.rotation = ((Component)hudData.m_healthFast).transform.rotation;
			}
			else
			{
				Debug.LogWarning((object)("Cannot find object level_boss " + level));
			}
		}
	}
	public class ModResourceLoader
	{
		public AssetBundle assetBundle;

		public List<Recipe> recipes = new List<Recipe>();

		public List<StatusEffect> statusEffects = new List<StatusEffect>();

		public Sprite spiritBurnIcon = null;

		public StatusEffectBuilder statusEffectBuilder = new StatusEffectBuilder();

		public List<GameObject> attackList = new List<GameObject>();

		public List<GameObject> visualList = new List<GameObject>();

		public List<GameObject> otherList = new List<GameObject>();

		public FxReplacment fxReplacment = null;

		public GameObject lvl4;

		public GameObject lvl5;

		public GameObject lvl6;

		public GameObject lvl7;

		public GameObject lvl2boss;

		public GameObject lvl3boss;

		public GameObject lvl4boss;

		public GameObject lvl5boss;

		public GameObject lvl6boss;

		public GameObject lvl7boss;

		public Sprite newLogo = null;

		public RuntimeAnimatorController animatorController = null;

		public RuntimeAnimatorController animatorControllerDraugr = null;

		public GameObject rightHand;

		public GameObject leftHand;

		public void loadAssets()
		{
			assetBundle = GetAssetBundleFromResources("monsterrandomizer");
			string text = "Assets/BalrondNPC/";
			spiritBurnIcon = assetBundle.LoadAsset<Sprite>(text + "spiritburn1.png");
			animatorController = assetBundle.LoadAsset<RuntimeAnimatorController>(text + "humanoid_randomizer.controller");
			animatorControllerDraugr = assetBundle.LoadAsset<RuntimeAnimatorController>(text + "humanoidDraugr_randomizer.controller");
			rightHand = assetBundle.LoadAsset<GameObject>(text + "Visuals/RightHand_Attach_bal.prefab");
			leftHand = assetBundle.LoadAsset<GameObject>(text + "Visuals/LeftHand_Attach_bal.prefab");
			loadNewStars();
			LoadNewBossStars();
			LoadAttacks(text);
			LoadVisuals(text);
			LoadOther(text);
			prepareOtherEffects(text);
		}

		public void loadNewStars()
		{
			string text = "Assets/BalrondNPC/";
			if ((Object)(object)assetBundle == (Object)null)
			{
				Debug.LogWarning((object)"Something unloaded asset bundle");
				assetBundle = GetAssetBundleFromResources("monsterrandomizer");
				return;
			}
			if ((Object)(object)lvl4 != (Object)null)
			{
				Debug.LogWarning((object)"Stars already loaded");
				return;
			}
			GameObject val = assetBundle.LoadAsset<GameObject>(text + "UI/level_4.prefab");
			if ((Object)(object)val != (Object)null)
			{
				val = Launch.cloneMe(val);
			}
			lvl4 = val;
			if ((Object)(object)lvl4 == (Object)null)
			{
				Debug.LogError((object)"NOTHING IS BEING LOADED !!!");
			}
			lvl4.SetActive(false);
			lvl5 = Launch.cloneMe(assetBundle.LoadAsset<GameObject>(text + "UI/level_5.prefab"));
			lvl5.SetActive(false);
			lvl6 = Launch.cloneMe(assetBundle.LoadAsset<GameObject>(text + "UI/level_6.prefab"));
			lvl6.SetActive(false);
			lvl7 = Launch.cloneMe(assetBundle.LoadAsset<GameObject>(text + "UI/level_7.prefab"));
			lvl7.SetActive(false);
		}

		public void LoadNewBossStars()
		{
			string text = "Assets/BalrondNPC/";
			if ((Object)(object)assetBundle == (Object)null)
			{
				Debug.LogWarning((object)"Something unloaded asset bundle");
				return;
			}
			if ((Object)(object)lvl2boss != (Object)null)
			{
				Debug.LogWarning((object)"Boss Stars already loaded");
				return;
			}
			lvl2boss = Launch.cloneMe(assetBundle.LoadAsset<GameObject>(text + "UI/level_2_boss.prefab"));
			if ((Object)(object)lvl2boss == (Object)null)
			{
				Debug.LogError((object)"NOTHING IS BEING LOADED !!!");
			}
			lvl2boss.SetActive(false);
			lvl3boss = Launch.cloneMe(assetBundle.LoadAsset<GameObject>(text + "UI/level_3_boss.prefab"));
			lvl3boss.SetActive(false);
			lvl4boss = Launch.cloneMe(assetBundle.LoadAsset<GameObject>(text + "UI/level_4_boss.prefab"));
			lvl4boss.SetActive(false);
			lvl5boss = Launch.cloneMe(assetBundle.LoadAsset<GameObject>(text + "UI/level_5_boss.prefab"));
			lvl5boss.SetActive(false);
			lvl6boss = Launch.cloneMe(assetBundle.LoadAsset<GameObject>(text + "UI/level_6_boss.prefab"));
			lvl6boss.SetActive(false);
			lvl7boss = Launch.cloneMe(assetBundle.LoadAsset<GameObject>(text + "UI/level_7_boss.prefab"));
			lvl7boss.SetActive(false);
		}

		public void AddPrefabsToZnetScene(ZNetScene zNetScene)
		{
			foreach (GameObject gm in attackList)
			{
				GameObject val = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == ((Object)gm).name);
				if ((Object)(object)val == (Object)null)
				{
					zNetScene.m_prefabs.Add(gm);
				}
				else
				{
					Debug.LogWarning((object)("Object exists: " + ((Object)gm).name));
				}
			}
			foreach (GameObject gm2 in visualList)
			{
				GameObject val2 = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == ((Object)gm2).name);
				if ((Object)(object)val2 == (Object)null)
				{
					zNetScene.m_prefabs.Add(gm2);
				}
				else
				{
					Debug.LogWarning((object)("Object exists: " + ((Object)gm2).name));
				}
			}
			foreach (GameObject gm3 in otherList)
			{
				GameObject val3 = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == ((Object)gm3).name);
				if ((Object)(object)val3 == (Object)null)
				{
					zNetScene.m_prefabs.Add(gm3);
				}
				else
				{
					Debug.LogWarning((object)("Object exists: " + ((Object)gm3).name));
				}
			}
			zNetScene.m_prefabs.RemoveAll((GameObject x) => (Object)(object)x == (Object)null);
		}

		public void LoadAttacks(string mainPath)
		{
			string[] array = new string[43]
			{
				"attack_kick_unarmed_bal", "dual_pierce_bal", "dual_pierce_slash_bal", "dual_slashBLUNT_bal", "dual_slashSLASH_bal", "fireball_bal", "frostbolt_bal", "left_blade_bal", "left_blunt_bal", "left_special_bal",
				"poisonbolt_bal", "right_blade_bal", "right_blunt_bal", "right_special_bal", "spiritbolt_bal", "thunderbolt_bal", "twoHand_Pierce_bal", "twoHand_slam_bal", "twoHand_slash_bal", "twoHand_spin_bal",
				"twoHand_swing_bal", "twoHand_sword_bal", "twoHand_uppercutBlunt_bal", "twoHand_uppercutPierce_bal", "twoHand_uppercutSlash_bal", "left_specialBlunt_bal", "right_specialBlunt_bal", "twoHand_slamBlunt_bal", "twoHand_spinBlunt_bal", "twoHand_swingBlunt_bal",
				"attack_punch_bal", "shield_slam_bal", "arbalest_shoot_bal", "spear_throw_bal", "cast_protect_caster_bal", "cast_protect_guardian_bal", "heal_base_bal", "heal_draugr_bal", "heal_goblin_bal", "poison_spray_bal",
				"fire_spray_bal", "spirit_spray_bal", "firebomb_bal"
			};
			string[] array2 = array;
			foreach (string text in array2)
			{
				GameObject val = assetBundle.LoadAsset<GameObject>(mainPath + "Attacks/" + text + ".prefab");
				if ((Object)(object)val == (Object)null)
				{
					Debug.LogWarning((object)("Could not find file with name: " + text));
					continue;
				}
				ShaderReplacment.Replace(val);
				val.SetActive(true);
				attackList.Add(val);
			}
		}

		public void LoadVisuals(string mainPath)
		{
			string[] array = new string[64]
			{
				"base_arbalest_bal", "base_axe_left_bal", "base_axe_right_bal", "base_bastard_bal", "base_battleaxe_bal", "base_knife_left_bal", "base_knife_right_bal", "base_mace_left_bal", "base_mace_right_bal", "base_sledge_bal",
				"base_spear_bal", "base_sword_left_bal", "base_sword_right_bal", "dual_dagger_base_bal", "spellhand_left_fire_bal", "spellhand_left_ice_bal", "spellhand_left_poison_bal", "spellhand_left_spirit_bal", "spellhand_left_thunder_bal", "spellhand_right_fire_bal",
				"spellhand_right_ice_bal", "spellhand_right_poison_bal", "spellhand_right_spirit_bal", "spellhand_right_thunder_bal", "spellhand_left_mage_bal", "spellhand_right_mage_bal", "dual_dagger_kick_bal", "base_torch_bal", "dual_claws_attack_bal", "dual_claws_kick_bal",
				"dual_claws_pierce_bal", "dual_dagger_slash_bal", "base_saber_left_bal", "base_saber_right_bal", "base_anchor_bal", "base_staff_left_bal", "base_staff_right_bal", "base_sledge_frost_bal", "base_sledge_poison_bal", "base_curse_axe_left_bal",
				"base_curse_axe_right_bal", "base_bastard_poison_bal", "base_bastard_spirit_bal", "base_battleaxe_poison_bal", "base_mace_frost_bal", "base_mace_left_frost_bal", "draugr_bow_base_bal", "draugr_bow_fire_bal", "draugr_bow_frost_bal", "draugr_bow_poison_bal",
				"draugr_bow_spirit_bal", "skeleton_bow_base_bal", "skeleton_bow_fire_bal", "skeleton_bow_frost_bal", "skeleton_bow_poison_bal", "skeleton_bow_spirit_bal", "goblin_bow_base_bal", "goblin_bow_fire_bal", "goblin_bow_frost_bal", "goblin_bow_poison_bal",
				"goblin_bow_spirit_bal", "base_harpoon_bal", "base_torch_right_bal", "base_battleaxe_spirit_bal"
			};
			string[] array2 = array;
			foreach (string text in array2)
			{
				GameObject val = assetBundle.LoadAsset<GameObject>(mainPath + "Visuals/" + text + ".prefab");
				if ((Object)(object)val == (Object)null)
				{
					Debug.LogWarning((object)("Could not find file with name: " + text));
					continue;
				}
				ShaderReplacment.Replace(val);
				visualList.Add(val);
			}
		}

		public void LoadOther(string mainPath)
		{
			string[] array = new string[36]
			{
				"fx_firebomb_hit", "bloodbolt_projectile", "fireball_projectile", "flamewave_ground_projectile 1", "frostbolt_projectile", "poisonbolt_projectile", "shadowbolt_projectile", "spiritbolt_projectile", "summon_projectile_skeleton", "thunderbolt_projectile",
				"vfx_poisonbolt_explosion", "vfx_bloodbolt_explosion", "vfx_fireball_explosion", "vfx_frostbolt_explosion", "vfx_shadowbolt_explosion", "vfx_spiritbolt_explosion", "vfx_thunderbolt_explosion", "Protect_caster", "Protect_guardian", "spear_projectile",
				"projectile_anchorNPC", "projectile_harpoonNPC", "heal_aoe", "spray_aoe_poison", "spray_aoe_fire", "spray_aoe_spirit", "firebomb_aoe", "firebomb_projectile", "vfx_spray_fire", "vfx_spray_poison",
				"vfx_spray_spirit", "enemyArrowFire", "enemyArrowFrost", "enemyArrowNormal", "enemyArrowPoison", "enemyArrowSpirt"
			};
			string[] array2 = array;
			foreach (string text in array2)
			{
				GameObject val = assetBundle.LoadAsset<GameObject>(mainPath + "Projectile/" + text + ".prefab");
				if ((Object)(object)val == (Object)null)
				{
					Debug.LogWarning((object)("Could not find file with name: " + text));
					continue;
				}
				ShaderReplacment.Replace(val);
				otherList.Add(val);
			}
		}

		public void FixAllFx(FxReplacment fxReplacment)
		{
			this.fxReplacment = fxReplacment;
			fixItemFX();
			fixVisualFX();
			fixOtherFX();
		}

		private void fixItemFX()
		{
			foreach (GameObject attack in attackList)
			{
				fxReplacment.ReplaceOnItem(attack);
			}
		}

		private void fixVisualFX()
		{
			foreach (GameObject visual in visualList)
			{
				fxReplacment.ReplaceOnItem(visual);
			}
		}

		private void fixOtherFX()
		{
			foreach (GameObject other in otherList)
			{
				fxReplacment.ReplaceOnObject(other);
			}
		}

		private void prepareOtherEffects(string mainPath)
		{
			SE_bleed statusEffect = ScriptableObject.CreateInstance<SE_bleed>();
			statusEffectBuilder.setBleedingStatus(statusEffect, assetBundle.LoadAsset<Sprite>(mainPath + "bleeding_Status_ico1.png"));
			SE_LevelShield statusEffect2 = ScriptableObject.CreateInstance<SE_LevelShield>();
			statusEffectBuilder.setShieldStatus(statusEffect2, assetBundle.LoadAsset<Sprite>(mainPath + "shieldMonster.png"));
			SE_pierced statusEffect3 = ScriptableObject.CreateInstance<SE_pierced>();
			statusEffectBuilder.setPiercedStatus(statusEffect3, assetBundle.LoadAsset<Sprite>(mainPath + "pierced_Status_ico1.png"));
			SE_crushed statusEffect4 = ScriptableObject.CreateInstance<SE_crushed>();
			statusEffectBuilder.setCrushedStatus(statusEffect4, assetBundle.LoadAsset<Sprite>(mainPath + "crushed_Status_ico1.png"));
			statusEffects.Add(assetBundle.LoadAsset<StatusEffect>(mainPath + "status/heal_base.asset"));
			statusEffects.Add(assetBundle.LoadAsset<StatusEffect>(mainPath + "status/heal_draugr.asset"));
			statusEffects.Add(assetBundle.LoadAsset<StatusEffect>(mainPath + "status/heal_goblin.asset"));
			statusEffects.AddRange(statusEffectBuilder.statusEffects);
		}

		private AssetBundle GetAssetBundleFromResources(string filename)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string name = executingAssembly.GetManifestResourceNames().Single((string str) => str.EndsWith(filename));
			using Stream stream = executingAssembly.GetManifestResourceStream(name);
			return AssetBundle.LoadFromStream(stream);
		}
	}
	public class MonsterFeeding
	{
		private static string[] names = new string[0];

		public void setMonsters(List<GameObject> monsters, List<GameObject> items)
		{
			if (names.Length == 0)
			{
				return;
			}
			foreach (GameObject monster in monsters)
			{
				if (Object.op_Implicit((Object)(object)monster.GetComponent<MonsterAI>()))
				{
					monster.AddComponent<MonsterHunger>();
					setFood(monster, items);
				}
			}
		}

		private void setFood(GameObject monster, List<GameObject> items)
		{
			MonsterAI component = monster.GetComponent<MonsterAI>();
			component.m_consumeRange = 2f;
			component.m_consumeSearchInterval = 5f;
			component.m_consumeSearchRange = 100f;
			if ((((Object)monster).name.Contains("Draugr") || ((Object)monster).name == "AbominationNew") && ((Object)monster).name != "EnemyShip")
			{
				meatList(component, items);
			}
			if (((Object)monster).name.Contains("golem") || ((Object)monster).name.Contains("Golem") || ((Object)monster).name.Contains("IcePanther"))
			{
				golemFeed(component, items);
				return;
			}
			if (isGraydwarfish(((Object)monster).name))
			{
				greyDwarfsFeed(component, items);
				return;
			}
			switch (((Object)monster).name)
			{
			case "Chicken":
			case "Chick":
			case "Goat":
			case "Kid":
			case "Elk":
				chickenFeed(component, items);
				break;
			case "CrabSea":
			case "Neck":
			case "CrabLeaf":
			case "CrabStone":
				chickenFeed(component, items);
				component.m_consumeItems.Add(GetItem(items, "FishRaw"));
				component.m_consumeItems.Add(GetItem(items, "FishingBait"));
				break;
			case "Boar":
			case "Lox":
			case "Bear":
				boarFeed(component, items);
				break;
			case "Wolf":
			case "Ulv":
			case "Fenring":
			case "Troll":
			case "Yotun":
			case "Frostbjorn":
				wolfFeed(component, items);
				break;
			default:
				component.m_consumeItems = new List<ItemDrop>();
				break;
			}
		}

		private ItemDrop GetItem(List<GameObject> items, string name)
		{
			GameObject val = items.Find((GameObject x) => ((Object)x).name == name);
			ItemDrop result = null;
			if ((Object)(object)val != (Object)null)
			{
				result = val.GetComponent<ItemDrop>();
			}
			return result;
		}

		private bool isGraydwarfish(string name)
		{
			return name.Contains("Greyling") || name.Contains("Greyd") || name == "Abomination";
		}

		private void greyDwarfsFeed(MonsterAI monsterAI, List<GameObject> items)
		{
			AddConsumeItem(monsterAI, GetItem(items, "Wood"));
			AddConsumeItem(monsterAI, GetItem(items, "ElderBark"));
			AddConsumeItem(monsterAI, GetItem(items, "Stone"));
			AddConsumeItem(monsterAI, GetItem(items, "RoundLog"));
			AddConsumeItem(monsterAI, GetItem(items, "FineWood"));
		}

		private void golemFeed(MonsterAI monsterAI, List<GameObject> items)
		{
			AddConsumeItem(monsterAI, GetItem(items, "Stone"));
			AddConsumeItem(monsterAI, GetItem(items, "Obsidian"));
			AddConsumeItem(monsterAI, GetItem(items, "CopperOre"));
			AddConsumeItem(monsterAI, GetItem(items, "IronOre"));
			AddConsumeItem(monsterAI, GetItem(items, "TinOre"));
			AddConsumeItem(monsterAI, GetItem(items, "SilverOre"));
			AddConsumeItem(monsterAI, GetItem(items, "Crystal"));
		}

		private void AddConsumeItem(MonsterAI monster, ItemDrop item)
		{
			if ((Object)(object)item != (Object)null)
			{
				monster.m_consumeItems.Add(item);
			}
		}

		private void chickenFeed(MonsterAI monsterAI, List<GameObject> items)
		{
			plantList(monsterAI, items);
		}

		private void boarFeed(MonsterAI monsterAI, List<GameObject> items)
		{
			plantList(monsterAI, items);
			meatList(monsterAI, items);
		}

		private void wolfFeed(MonsterAI monsterAI, List<GameObject> items)
		{
			meatList(monsterAI, items);
			AddConsumeItem(monsterAI, GetItem(items, "SerpentMeat"));
		}

		private void plantList(MonsterAI monsterAI, List<GameObject> items)
		{
			AddConsumeItem(monsterAI, GetItem(items, "Carrot"));
			AddConsumeItem(monsterAI, GetItem(items, "Turnip"));
			AddConsumeItem(monsterAI, GetItem(items, "Potato"));
			AddConsumeItem(monsterAI, GetItem(items, "RedKelp"));
			AddConsumeItem(monsterAI, GetItem(items, "Thistle"));
			AddConsumeItem(monsterAI, GetItem(items, "Dandelion"));
			AddConsumeItem(monsterAI, GetItem(items, "Apple"));
			AddConsumeItem(monsterAI, GetItem(items, "Mushroom"));
			AddConsumeItem(monsterAI, GetItem(items, "MushroomYellow"));
			AddConsumeItem(monsterAI, GetItem(items, "Honey"));
		}

		private void meatList(MonsterAI monsterAI, List<GameObject> items)
		{
			AddConsumeItem(monsterAI, GetItem(items, "BearMeat"));
			AddConsumeItem(monsterAI, GetItem(items, "ChickenMeat"));
			AddConsumeItem(monsterAI, GetItem(items, "LoxMeat"));
			AddConsumeItem(monsterAI, GetItem(items, "RawMeat"));
			AddConsumeItem(monsterAI, GetItem(items, "DeerMeat"));
			AddConsumeItem(monsterAI, GetItem(items, "WolfMeat"));
			AddConsumeItem(monsterAI, GetItem(items, "Entrails"));
			AddConsumeItem(monsterAI, GetItem(items, "FishRaw"));
			AddConsumeItem(monsterAI, GetItem(items, "Honey"));
		}
	}
	public class MonsterManager
	{
		private GameObject levelEffects = null;

		private GameObject stealEffect = null;

		private LevelEffectGenerator levelEffectGenerator = new LevelEffectGenerator();

		private List<GameObject> monsters;

		private List<GameObject> list;

		private string[] names = new string[0];

		private string[] thiefName = new string[14]
		{
			"Greyling", "Greydwarf", "Greydwarf_Elite", "Draugr", "Draugr_Elite", "Draugr_Ranged", "Skeleton", "Skeleton_NoArcher", "Skeleton_Poison", "Forsaken",
			"GoblinBrute", "GoblinArcher", "Goblin", "GoblinShaman"
		};

		public void SetVfx(GameObject levelEffects, GameObject stealEffect)
		{
			this.levelEffects = levelEffects;
			this.stealEffect = stealEffect;
		}

		public void setupMonsterList(List<GameObject> list)
		{
			if (list == null)
			{
				Debug.LogWarning((object)"I DID NOT FOUND PREFAB LIST!");
				return;
			}
			this.list = list;
			monsters = list.FindAll((GameObject x) => (Object)(object)x.GetComponent<MonsterAI>() != (Object)null);
		}

		public void changeMonsterResistance()
		{
			if (monsters == null)
			{
				Debug.LogWarning((object)"I DID NOT FOUND ANY MONSTERS!");
				return;
			}
			foreach (GameObject monster in monsters)
			{
				Humanoid component = monster.GetComponent<Humanoid>();
				SetupLevelVisual(monster);
				if ((Object)(object)component != (Object)null)
				{
					changeResistanceForException(component);
				}
			}
			changeMonsterDrops();
		}

		private void setupHumanoidExtended(GameObject gameObject)
		{
			HumanoidExtend humanoidExtend = gameObject.AddComponent<HumanoidExtend>();
			humanoidExtend.levelingEnabled = true;
			humanoidExtend.levelUpEffect = levelEffects;
			humanoidExtend.stealEffect = stealEffect;
			if (thiefName.Contains(((Object)gameObject).name))
			{
				humanoidExtend.canSteal = true;
			}
		}

		private void SetupLevelVisual(GameObject gameObject)
		{
			Transform visual = gameObject.transform.Find("Visual");
			LevelEffects val = gameObject.GetComponentInChildren<LevelEffects>();
			bool flag = true;
			string[] source = new string[15]
			{
				"Lox", "Wraith", "TentaRoot", "TheHive", "Hatchling", "GoblinKing", "Eikthyr", "Bonemass", "Frog", "Haugbui",
				"Greydwarf_Mystic", "Varsvin", "Varsvin_Brute", "Varsvin_Hunter", "SeekerQueen"
			};
			if (((Object)gameObject).name == "TheHive" || ((Object)gameObject).name == "Haugbui" || ((Object)gameObject).name == "Greydwarf_Mystic")
			{
				return;
			}
			if (source.Contains(((Object)gameObject).name))
			{
				Transform val2 = null;
				switch (((Object)gameObject).name)
				{
				case "Lox":
					val2 = gameObject.transform.Find("Visual/offset/Body");
					break;
				case "Wraith":
					val2 = gameObject.transform.Find("Visual/wraith/wraith");
					break;
				case "TentaRoot":
					val2 = gameObject.transform.Find("Visual/Tentaroots/Cube.001");
					break;
				case "Hatchling":
					val2 = gameObject.transform.Find("Visual/Hatchling_mountain/Hatchling");
					break;
				case "GoblinKing":
					val2 = gameObject.transform.Find("Visual/Yagluth");
					break;
				case "Eikthyr":
					val2 = gameObject.transform.Find("Visual/Deer");
					break;
				case "Bonemass":
					val2 = gameObject.transform.Find("Visual/model/bonemass");
					break;
				case "Varsvin":
				case "Varsvin_Brute":
				case "Varsvin_Hunter":
					val2 = gameObject.transform.Find("Visual/Body");
					break;
				case "Frog":
					val2 = gameObject.transform.Find("Visual/Frog2_mesh");
					break;
				case "Haugbui":
					val2 = gameObject.transform.Find("Visual/Frog2_mesh");
					break;
				case "Greydwarf_Mystic":
					val2 = gameObject.transform.Find("Visual/Frog2_mesh");
					break;
				case "SeekerQueen":
					val2 = gameObject.transform.Find("Visual/Cube");
					break;
				}
				if ((Object)(object)val2 == (Object)null)
				{
					return;
				}
				val = levelEffectGenerator.CreateLevelEffectAt(visual, ((Component)val2).GetComponent<SkinnedMeshRenderer>());
			}
			else if (flag && (Object)(object)val == (Object)null)
			{
				val = levelEffectGenerator.CreateLevelEffectComponent(visual);
			}
			if ((Object)(object)val != (Object)null)
			{
				levelEffectGenerator.CreateVisuals(val);
			}
		}

		private void editMonsterHealth(GameObject gameObject, int health)
		{
			Humanoid component = gameObject.GetComponent<Humanoid>();
			((Character)component).m_health = health;
		}

		private void changeSpiritResistance(Humanoid humanoid)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: 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_002e: Expected I4, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			Faction faction = ((Character)humanoid).m_faction;
			Faction val = faction;
			switch (val - 1)
			{
			case 0:
				((Character)humanoid).m_damageModifiers.m_spirit = (DamageModifier)0;
				break;
			case 1:
				((Character)humanoid).m_damageModifiers.m_spirit = (DamageModifier)1;
				break;
			case 5:
				((Character)humanoid).m_damageModifiers.m_spirit = (DamageModifier)5;
				break;
			case 2:
				((Character)humanoid).m_damageModifiers.m_spirit = (DamageModifier)2;
				break;
			case 3:
				((Character)humanoid).m_damageModifiers.m_spirit = (DamageModifier)2;
				break;
			case 6:
				((Character)humanoid).m_damageModifiers.m_spirit = (DamageModifier)0;
				break;
			case 4:
				((Character)humanoid).m_damageModifiers.m_spirit = (DamageModifier)5;
				break;
			}
		}

		private void changeResistanceForException(Humanoid humanoid)
		{
			changeSpiritResistance(humanoid);
		}

		public void setupSpawners(List<GameObject> list)
		{
			GameObject val = list.Find((GameObject x) => ((Object)x).name == "BonePileSpawner");
			GameObject val2 = list.Find((GameObject x) => ((Object)x).name == "Spawner_DraugrPile");
			GameObject val3 = list.Find((GameObject x) => ((Object)x).name == "Spawner_GreydwarfNest");
			SpawnArea component = val.GetComponent<SpawnArea>();
			if (component.m_farRadius != 1001f)
			{
				AddMonsterToSpawner(component, "Skeleton_Poison", 2, 0.6f);
				AddMonsterToSpawner(component, "Ghost", 2, 0.6f);
			}
			SpawnArea component2 = val2.GetComponent<SpawnArea>();
			if (component2.m_farRadius != 1001f)
			{
				AddMonsterToSpawner(component2, "Wraith", 2, 0.5f);
				AddMonsterToSpawner(component2, "Draugr_Elite", 2, 3f);
				AddMonsterToSpawner(component2, "Ghost", 2, 4f);
			}
			SpawnArea component3 = val3.GetComponent<SpawnArea>();
			if (component3.m_farRadius != 1001f)
			{
				AddMonsterToSpawner(component3, "Greyling", 3, 4f);
			}
			changeSpawners(val);
			changeSpawners(val2);
			changeSpawners(val3, 6);
		}

		private void AddMonsterToSpawner(SpawnArea spawnArea, string prefabName, int maxLevel, float chance)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			SpawnData val = new SpawnData();
			val.m_maxLevel = maxLevel;
			val.m_weight = chance;
			val.m_minLevel = 1;
			val.m_prefab = list.Find((GameObject x) => ((Object)x).name == prefabName);
			spawnArea.m_prefabs.Add(val);
		}

		private DropData prepareDrop(GameObject item, int min, int max, float chance)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			DropData result = default(DropData);
			result.m_item = item;
			result.m_stackMin = min;
			result.m_stackMax = max;
			result.m_weight = chance;
			return result;
		}

		private void CreateSpanwerDropList(GameObject gameObject)
		{
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: 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_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0412: Unknown result type (might be due to invalid IL or missing references)
			//IL_0441: Unknown result type (might be due to invalid IL or missing references)
			//IL_0470: Unknown result type (might be due to invalid IL or missing references)
			//IL_049f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
			DropOnDestroyed val = gameObject.GetComponent<DropOnDestroyed>();
			if ((Object)(object)val == (Object)null)
			{
				val = gameObject.AddComponent<DropOnDestroyed>();
			}
			val.m_dropWhenDestroyed.m_dropMin = 1;
			val.m_dropWhenDestroyed.m_dropMax = 3;
			val.m_spawnYOffset = 0.5f;
			val.m_spawnYStep = 0.3f;
			val.m_dropWhenDestroyed.m_drops.Clear();
			switch (((Object)gameObject).name)
			{
			case "BonePileSpawner":
				val.m_dropWhenDestroyed.m_drops.Add(prepareDrop(FindItem(list, "BoneFragments"), 2, 4, 0.95f));
				val.m_dropWhenDestroyed.m_drops.Add(prepareDrop(FindItem(list, "TrophySkeleton"), 1, 2, 0.55f));
				val.m_dropWhenDestroyed.m_drops.Add(prepareDrop(FindItem(list, "LeatherScraps"), 2, 4, 0.95f));
				val.m_dropWhenDestroyed.m_drops.Add(prepareDrop(FindItem(list, "BronzeScrap"), 1, 2, 0.15f));
				val.m_dropWhenDestroyed.m_drops.Add(prepareDrop(FindItem(list, "CopperScrap"), 1, 2, 0.15f));
				val.m_dropWhenDestroyed.m_drops.Add(prepareDrop(FindItem(list, "SilverNecklace"), 1, 2, 0.35f));
				break;
			case "Spawner_DraugrPile":
				val.m_dropWhenDestroyed.m_drops.Add(prepareDrop(FindItem(list, "BoneFragments"), 2, 4, 0.25f));
				val.m_dropWhenDestroyed.m_drops.Add(prepareDrop(FindItem(list, "Entrails"), 1, 2, 0.25f));
				val.m_dropWhenDestroyed.m_drops.Add(prepareDrop(FindItem(list, "TrophyDraugr"), 1, 2, 0.25f));
				val.m_dropWhenDestroyed.m_drops.Add(prepareDrop(FindItem(list, "TrophySkeleton"), 1, 2, 0.25f));
				val.m_dropWhenDestroyed.m_drops.Add(prepareDrop(FindItem(list, "SilverNecklace"), 1, 2, 0.35f));
				val.m_dropWhenDestroyed.m_drops.Add(prepareDrop(FindItem(list, "IronScrap"), 1, 2, 0.15f));
				val.m_dropWhenDestroyed.m_drops.Add(prepareDrop(FindItem(list, "BronzeScrap"), 1, 2, 0.15f));
				val.m_dropWhenDestroyed.m_drops.Add(prepareDrop(FindItem(list, "CopperScrap"), 1, 2, 0.15f));
				break;
			case "Spawner_GreydwarfNest":
				val.m_dropWhenDestroy