Decompiled source of ReidrheimrFactionWeaponPack v2.0.1

ReidrheimrFactionWeaponPack/BjornheimArtifacts.dll

Decompiled 6 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 BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ValheimReforgedWeapons")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ValheimReforgedWeapons")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("108df065-3a24-4888-8a60-cf793a69379c")]
[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]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BjornheimArtifacts
{
	public class BuildPieceChanges
	{
		private List<GameObject> buildPieces = new List<GameObject>();

		private List<GameObject> items = new List<GameObject>();

		private List<ItemConversion> allConversions = new List<ItemConversion>();

		public void editBuidlPieces(List<GameObject> buildpieces, List<GameObject> newPieces, List<GameObject> items)
		{
			buildPieces = buildpieces;
			this.items = items;
			createBuildPiecesRecipes(newPieces);
			editFermenter();
			editSmelter();
			editFurnace();
			editKiln();
			editWHeel();
			editRefinery();
			editWIndMIll();
			editSap();
		}

		public void editStations(List<GameObject> buildpieces)
		{
			buildPieces = buildpieces;
			items = buildpieces;
			editFermenter();
			editSmelter();
			editFurnace();
			editKiln();
			editWHeel();
			editRefinery();
			editWIndMIll();
			editSap();
		}

		private void createBuildPiecesRecipes(List<GameObject> newPieces)
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			GameObject val = items.Find((GameObject x) => ((Object)x).name == "Hammer");
			List<GameObject> pieces = val.GetComponent<ItemDrop>().m_itemData.m_shared.m_buildPieces.m_pieces;
			foreach (GameObject piece in newPieces)
			{
				Piece component = piece.GetComponent<Piece>();
				if (!((Object)component == (Object)null))
				{
					CheckForOtherNames(component, component.m_name);
					List<Requirement> list = new List<Requirement>();
					component.m_resources = createResources(piece);
					if ((Object)pieces.Find((GameObject x) => ((Object)x).name == ((Object)piece).name) == (Object)null)
					{
						pieces.Add(piece);
					}
				}
			}
		}

		private CraftingStation FindStation(List<GameObject> list, string name)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			GameObject val = list.Find((GameObject x) => ((Object)x).name == name);
			if ((Object)val != (Object)null)
			{
				return val.GetComponent<CraftingStation>();
			}
			return null;
		}

		private GameObject FindItem(string name)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			GameObject val = items.Find((GameObject x) => ((Object)x).name == name);
			if ((Object)val == (Object)null)
			{
				val = items.Find((GameObject x) => ((Object)x).name == name);
				if ((Object)val != (Object)null)
				{
					return val;
				}
				Debug.LogWarning((object)("Item Not Found - " + name + ", Replaced With Wood"));
				return items.Find((GameObject x) => ((Object)x).name == "Wood");
			}
			if ((Object)val != (Object)null)
			{
				return val;
			}
			Debug.LogWarning((object)("Item Not Found - " + name + ", Replaced With Wood"));
			return items.Find((GameObject x) => ((Object)x).name == "Wood");
		}

		private Requirement[] createResources(GameObject item)
		{
			List<Requirement> list = new List<Requirement>();
			switch (((Object)item).name)
			{
			case "sacredforge_ext3":
			case "sacredforge_ext2":
			case "sacredforge_ext1":
			case "SacredForge":
			case "GrandForgeV2":
				list.Add(createReq("SwordCheat", 1, 0));
				break;
			}
			return list.ToArray();
		}

		private Requirement createReq(string name, int amount, int amountPerLevel)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			Requirement val = new Requirement();
			val.m_recover = true;
			ItemDrop val2 = (val.m_resItem = items.Find((GameObject x) => ((Object)x).name == name).GetComponent<ItemDrop>());
			val.m_amount = amount;
			val.m_amountPerLevel = amountPerLevel;
			return val;
		}

		private void CheckForOtherNames(Piece piece, string name)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Expected O, but got Unknown
			Chair component = ((Component)piece).GetComponent<Chair>();
			if ((Object)component != (Object)null)
			{
				component.m_name = name;
			}
			Fermenter component2 = ((Component)piece).GetComponent<Fermenter>();
			if ((Object)component2 != (Object)null)
			{
				component2.m_name = name;
			}
			Door component3 = ((Component)piece).GetComponent<Door>();
			if ((Object)component3 != (Object)null)
			{
				component3.m_name = name;
			}
			ItemStand component4 = ((Component)piece).GetComponent<ItemStand>();
			if ((Object)component4 != (Object)null)
			{
				component4.m_name = name;
			}
			Container component5 = ((Component)piece).GetComponent<Container>();
			if ((Object)component5 != (Object)null)
			{
				component5.m_name = name;
			}
		}

		private void editFermenter()
		{
			GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "fermenter");
			Fermenter component = val.GetComponent<Fermenter>();
			component.m_conversion.Add(addFermenterCoversion(FindItem("MeadBaseLightingResistMedium_bal"), FindItem("MediumThunderPotion_bal")));
			component.m_conversion.Add(addFermenterCoversion(FindItem("MeadBaseSpiritResistMedium_bal"), FindItem("MediumSpiritPotion_bal")));
		}

		private ItemConversion addFermenterCoversion(GameObject from, GameObject to)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ItemConversion val = new ItemConversion();
			val.m_from = from.GetComponent<ItemDrop>();
			val.m_to = to.GetComponent<ItemDrop>();
			val.m_producedItems = 6;
			return val;
		}

		private void editSmelter()
		{
			GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "smelter");
			Smelter component = val.GetComponent<Smelter>();
			component.m_secPerProduct = 6f;
			component.m_fuelPerProduct = 3;
			allConversions.AddRange(component.m_conversion);
		}

		private void editFurnace()
		{
			GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "blastfurnace");
			Smelter component = val.GetComponent<Smelter>();
			component.m_secPerProduct = 3f;
			component.m_fuelPerProduct = 2;
			foreach (ItemConversion itemConversion in component.m_conversion)
			{
				ItemConversion val2 = allConversions.Find((ItemConversion x) => ((Object)x.m_from).name == ((Object)itemConversion.m_from).name);
				if (val2 == null)
				{
					allConversions.Add(itemConversion);
				}
			}
			component.m_conversion.Clear();
			component.m_conversion.AddRange(allConversions);
		}

		private void editWHeel()
		{
			GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "piece_spinningwheel");
			Smelter component = val.GetComponent<Smelter>();
			component.m_secPerProduct = 10f;
		}

		private void editRefinery()
		{
			GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "eitrrefinery");
			Smelter component = val.GetComponent<Smelter>();
			component.m_secPerProduct = 10f;
		}

		private void editWIndMIll()
		{
			GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "piece_sapcollector");
			SapCollector component = val.GetComponent<SapCollector>();
			component.m_secPerUnit = 15f;
			component.m_maxLevel = 60;
		}

		private void editSap()
		{
			GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "windmill");
			Smelter component = val.GetComponent<Smelter>();
			component.m_secPerProduct = 8f;
		}

		private void editKiln()
		{
			GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "charcoal_kiln");
			Smelter component = val.GetComponent<Smelter>();
			component.m_secPerProduct = 10f;
		}
	}
	[BepInPlugin("balrond.astafaraios.BjornheimArtifacts", "BjornheimArtifacts", "1.0.1")]
	public class Launch : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(ZNetScene), "Awake")]
		public static class ZNetScene_Awake_Path
		{
			public static void Prefix(ZNetScene __instance)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Expected O, but got Unknown
				if ((Object)__instance == (Object)null)
				{
					return;
				}
				foreach (GameObject newPrefab3 in vfxList)
				{
					if (!Object.op_Implicit((Object)(object)__instance.m_prefabs.Find((GameObject x) => ((Object)x).name == ((Object)newPrefab3).name)))
					{
						__instance.m_prefabs.Add(newPrefab3);
					}
				}
				foreach (GameObject newPrefab2 in prefabs)
				{
					if (!Object.op_Implicit((Object)(object)__instance.m_prefabs.Find((GameObject x) => ((Object)x).name == ((Object)newPrefab2).name)))
					{
						__instance.m_prefabs.Add(newPrefab2);
					}
				}
				foreach (GameObject newPrefab in buildPieces)
				{
					if (!Object.op_Implicit((Object)(object)__instance.m_prefabs.Find((GameObject x) => ((Object)x).name == ((Object)newPrefab).name)))
					{
						__instance.m_prefabs.Add(newPrefab);
					}
				}
				buildPieceChanges.editBuidlPieces(__instance.m_prefabs, buildPieces, __instance.m_prefabs);
				monsterManager.setupMonsters(__instance.m_prefabs, __instance.m_prefabs);
				editPortal(__instance.m_prefabs, "portal_wood");
				editPortal(__instance.m_prefabs, "portal_stone");
				GameObject playerResistance = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "Player");
				monsterManager.setPlayerResistance(playerResistance);
				buildPieceChanges.editStations(__instance.m_prefabs);
				recipeBuilder.fixWaveGround(__instance.m_prefabs);
			}
		}

		[HarmonyAfter(new string[] { "FactionPowers" })]
		[HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")]
		public static class Object_CopyOtherDB_Path
		{
			public static void Postfix()
			{
				//IL_0095: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a0: Expected O, but got Unknown
				if (!IsObjectDBValid())
				{
					return;
				}
				GameObject val = ObjectDB.instance.m_items.Find((GameObject x) => ((Object)x).name == "Hammer");
				List<GameObject> pieces = val.GetComponent<ItemDrop>().m_itemData.m_shared.m_buildPieces.m_pieces;
				foreach (GameObject piece in buildPieces)
				{
					if ((Object)pieces.Find((GameObject x) => ((Object)x).name == ((Object)piece).name) == (Object)null)
					{
						pieces.Add(piece);
					}
				}
				foreach (StatusEffect statusEffect in statusEffects)
				{
					AddStatus(statusEffect);
				}
				StatusEffect val2 = ObjectDB.instance.m_StatusEffects.Find((StatusEffect x) => ((Object)x).name == "Spirit");
				val2.m_icon = iconSpirit;
				foreach (GameObject prefab in prefabs)
				{
					AddNewPrefab(prefab);
				}
			}
		}

		[HarmonyAfter(new string[] { "FactionPowers" })]
		[HarmonyPatch(typeof(ObjectDB), "Awake")]
		public static class Object_Awake_Path
		{
			public static void Postfix()
			{
				//IL_0095: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a0: Expected O, but got Unknown
				if (!IsObjectDBValid())
				{
					return;
				}
				GameObject val = ObjectDB.instance.m_items.Find((GameObject x) => ((Object)x).name == "Hammer");
				List<GameObject> pieces = val.GetComponent<ItemDrop>().m_itemData.m_shared.m_buildPieces.m_pieces;
				foreach (GameObject piece in buildPieces)
				{
					if ((Object)pieces.Find((GameObject x) => ((Object)x).name == ((Object)piece).name) == (Object)null)
					{
						pieces.Add(piece);
					}
				}
				foreach (StatusEffect statusEffect in statusEffects)
				{
					AddStatus(statusEffect);
				}
				StatusEffect val2 = ObjectDB.instance.m_StatusEffects.Find((StatusEffect x) => ((Object)x).name == "Spirit");
				val2.m_icon = iconSpirit;
				foreach (GameObject prefab in prefabs)
				{
					AddNewPrefab(prefab);
				}
				recipes.AddRange(recipeBuilder.createRecipes(ObjectDB.instance.m_items, prefabs));
				foreach (Recipe recipe in recipes)
				{
					AddRecipe(recipe);
				}
			}
		}

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

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

		public const string PluginName = "BjornheimArtifacts";

		public const string PluginVersion = "1.0.1";

		private static AssetBundle assetBundle;

		private static readonly string bundleName = "factionweapons";

		private static List<GameObject> prefabs = new List<GameObject>();

		private static List<GameObject> buildPieces = new List<GameObject>();

		private static List<GameObject> vfxList = new List<GameObject>();

		private static List<StatusEffect> statusEffects = new List<StatusEffect>();

		public static RecipeBuilder recipeBuilder = new RecipeBuilder();

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

		public static MonsterManager monsterManager = new MonsterManager();

		public static BuildPieceChanges buildPieceChanges = new BuildPieceChanges();

		private static readonly string[] prefabNames = new string[9] { "Blidhr_bal", "Blidhr_base_bal", "BowRazorStrikes", "FenrirSword_bal", "FenrirSword_base_bal", "Gugnir_bal", "Gugnir_base_bal", "HoundsSycle", "HoundsScythe" };

		private static readonly string[] resourceNames = new string[19]
		{
			"AcidSludge_bal", "Amethyst_bal", "AmethystSteel", "BlackTissue", "Bloodsteel", "DarkSteel", "DvergrHeart", "Electrum", "Frosteel", "GjallCore_bal",
			"GoldBar", "SeedFrost_bal", "SeekerBruteBlood", "MeadBaseLightingResistMedium_bal", "MeadBaseSpiritResistMedium_bal", "MediumSpiritPotion_bal", "MediumThunderPotion_bal", "DraugrInsygnia", "QueenCore"
		};

		private static readonly string[] pieceNames = new string[5] { "SacredForge", "sacredforge_ext1", "sacredforge_ext2", "sacredforge_ext3", "GrandForgeV2" };

		private static readonly string[] vfxNames = new string[12]
		{
			"SacredForgeAltar", "GrandForge", "Wave_Ground", "projectile_runeAxe", "fx_eikthyr_forwardshockwave1", "fx_Lightning1", "vfx_iceblocker_destroyed1", "vfx_scythExplosion", "vfx_scythe_ground", "vfx_scytheSpikeAoe",
			"fx_eikthyr_forwardshockwave2", "vfx_spiritbolt_explosion"
		};

		public static Sprite iconSpirit = null;

		private void Awake()
		{
			Debug.Log((object)"ReidrheimrFactionWeapons loading");
			init();
			Debug.Log((object)"ReidrheimrFactionWeapons done loading");
		}

		private void init()
		{
			LoadAllAssetBundles();
			harmony.PatchAll();
		}

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

		public static void LoadAllAssetBundles()
		{
			assetBundle = GetAssetBundleFromResources(bundleName);
			LoadPrefabs(assetBundle);
			loadStatusFromPotion();
		}

		public static 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);
		}

		private static void LoadPrefabs(AssetBundle assetBundle)
		{
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			iconSpirit = assetBundle.LoadAsset<Sprite>("Assets/Custom/Comission/FactionWeapons/ico/spiritburn1.png");
			string[] array = vfxNames;
			string[] array2 = array;
			foreach (string text in array2)
			{
				GameObject val = assetBundle.LoadAsset<GameObject>("Assets/Custom/Comission/FactionWeapons/Objects/" + text + ".prefab");
				val.SetActive(true);
				vfxList.Add(val);
			}
			string[] array3 = resourceNames;
			string[] array4 = array3;
			foreach (string text2 in array4)
			{
				GameObject val2 = assetBundle.LoadAsset<GameObject>("Assets/Custom/Comission/FactionWeapons/Resources/" + text2 + ".prefab");
				val2.SetActive(true);
				prefabs.Add(val2);
			}
			string[] array5 = prefabNames;
			string[] array6 = array5;
			foreach (string text3 in array6)
			{
				GameObject val3 = assetBundle.LoadAsset<GameObject>("Assets/Custom/Comission/FactionWeapons/Weapons/" + text3 + ".prefab");
				val3.SetActive(true);
				if (text3 == "Blidhr_bal" || text3 == "Blidhr_base_bal")
				{
					recolorParticleEmitterColorsRecursively(val3, new Color(0f, 0.64f, 1f));
				}
				prefabs.Add(val3);
			}
			string[] array7 = pieceNames;
			string[] array8 = array7;
			foreach (string text4 in array8)
			{
				GameObject val4 = assetBundle.LoadAsset<GameObject>("Assets/Custom/Comission/FactionWeapons/Pieces/" + text4 + ".prefab");
				val4.SetActive(true);
				buildPieces.Add(val4);
			}
		}

		private static void recolorParticleEmitterColorsRecursively(GameObject g, Color c)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			ParticleSystem component = g.GetComponent<ParticleSystem>();
			if ((Object)(object)component != (Object)null)
			{
				MainModule main = component.main;
				MinMaxGradient startColor = ((MainModule)(ref main)).startColor;
				c.a = ((MinMaxGradient)(ref startColor)).color.a;
				((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(c);
			}
			for (int i = 0; i < g.transform.childCount; i++)
			{
				recolorParticleEmitterColorsRecursively(((Component)g.transform.GetChild(i)).gameObject, c);
			}
		}

		private static void loadStatusFromPotion()
		{
			string[] source = new string[2] { "MediumSpiritPotion_bal", "MediumThunderPotion_bal" };
			foreach (GameObject prefab in prefabs)
			{
				if (source.Contains(((Object)prefab).name))
				{
					ItemDrop component = prefab.GetComponent<ItemDrop>();
					statusEffects.Add(component.m_itemData.m_shared.m_consumeStatusEffect);
				}
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Fireplace), "UpdateFireplace")]
		public static void Fireplace_UpdateFireplace(Fireplace __instance, ref ZNetView ___m_nview)
		{
			___m_nview.GetZDO().Set("fuel", __instance.m_maxFuel);
		}

		public static void editPortal(List<GameObject> prefbaList, string name)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Expected O, but got Unknown
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Expected O, but got Unknown
			GameObject val = prefbaList.Find((GameObject x) => ((Object)x).name == name);
			if ((Object)val == (Object)null)
			{
				Debug.LogWarning((object)"NO PORTAL FOUND");
				return;
			}
			Piece component = val.GetComponent<Piece>();
			if ((Object)component == (Object)null)
			{
				Debug.LogWarning((object)"NO PIECE FOUND");
				return;
			}
			Requirement[] resources = component.m_resources;
			List<Requirement> list = new List<Requirement>(resources.Length);
			Requirement[] array = resources;
			foreach (Requirement item in array)
			{
				list.Add(item);
			}
			List<Requirement> list2 = list;
			if (!list2.Any((Requirement w) => ((Object)w.m_resItem).name.ToLower().Contains("queen")))
			{
				Requirement val2 = new Requirement();
				val2.m_amount = 1;
				GameObject val3 = prefbaList.Find((GameObject x) => ((Object)x).name == "QueenCore");
				if ((Object)val3 == (Object)null)
				{
					Debug.LogWarning((object)"NO QUEEN CORE FOUND");
					return;
				}
				val2.m_resItem = val3.GetComponent<ItemDrop>();
				val2.m_recover = true;
				list2.Add(val2);
			}
			component.m_resources = list2.ToArray();
		}

		private static bool IsObjectDBValid()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			return (Object)ObjectDB.instance != (Object)null && ObjectDB.instance.m_items.Count != 0 && ObjectDB.instance.m_recipes.Count != 0 && (Object)ObjectDB.instance.GetItemPrefab("Amber") != (Object)null;
		}

		private static void AddRecipe(Recipe recipe)
		{
			int num = ObjectDB.instance.m_recipes.RemoveAll((Recipe x) => ((Object)x).name == ((Object)recipe).name);
			if (num > 0)
			{
				Debug.Log((object)$"Recipe ({((Object)recipe).name}): {num} instances removed.");
			}
			ObjectDB.instance.m_recipes.Add(recipe);
			Debug.Log((object)("Recipe (" + ((Object)recipe).name + ")  added."));
		}

		private static void AddNewPrefab(GameObject newPrefab)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			ItemDrop component = newPrefab.GetComponent<ItemDrop>();
			if ((Object)component != (Object)null)
			{
				if ((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[StringExtensionMethods.GetStableHashCode(((Object)newPrefab).name)] = newPrefab;
					Debug.Log((object)(((Object)newPrefab).name + " - Added to the Game"));
				}
				else
				{
					Debug.LogWarning((object)(((Object)newPrefab).name + " - ItemDrop already exists"));
				}
			}
			else
			{
				Debug.LogError((object)(((Object)newPrefab).name + " - ItemDrop not found on prefab"));
			}
		}

		private static void AddStatus(StatusEffect status)
		{
			if (!IsObjectDBValid())
			{
				return;
			}
			if ((Object)(object)status != (Object)null)
			{
				if ((Object)(object)ObjectDB.instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode(((Object)status).name)) == (Object)null)
				{
					ObjectDB.instance.m_StatusEffects.Add(status);
					Debug.Log((object)(((Object)status).name + " - Status Added to the Game"));
				}
			}
			else
			{
				Debug.LogError((object)(((Object)status).name + " - Status not found"));
			}
		}
	}
	public class MonsterManager
	{
		private List<GameObject> monsters;

		private List<GameObject> list;

		private List<GameObject> list2;

		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 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 void setupMonsters(List<GameObject> list, List<GameObject> newItemList)
		{
			if (list == null)
			{
				Debug.LogWarning((object)"I DID NOT FOUND PREFAB LIST!");
				return;
			}
			this.list = list;
			list2 = newItemList;
			monsters = list.FindAll((GameObject x) => (Object)x.GetComponent<MonsterAI>() != (Object)null);
			if (monsters == null)
			{
				Debug.LogWarning((object)"I DID NOT FOUND ANY MONSTERS!");
				return;
			}
			changeMonsterResistance();
			changeMonsterDrops();
		}

		private void changeMonsterDrops()
		{
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Expected O, but got Unknown
			string[] array = new string[13]
			{
				"Tick", "Seeker", "SeekerBrute", "Gjall", "DvergerMageIce", "DvergerMageSupport", "DvergerMage", "DvergerMageFire", "Dverger", "Draugr",
				"Draugr_Elite", "Draugr_Ranged", "SeekerQueen"
			};
			string[] array2 = array;
			string[] array3 = array2;
			foreach (string name in array3)
			{
				GameObject val = monsters.Find((GameObject x) => ((Object)x).name == name);
				if ((Object)val != (Object)null)
				{
					monsterLootChange(val);
				}
			}
		}

		private void monsterLootChange(GameObject monster)
		{
			string name = ((Object)monster).name;
			string text = name;
			if (text == null)
			{
				return;
			}
			switch (text.Length)
			{
			case 11:
				switch (text[6])
				{
				case 'r':
					if (text == "DvergerMage")
					{
						addItemToLootTable(monster, "DvergrHeart", 1, 1, 0.25f);
					}
					break;
				case 'B':
					if (text == "SeekerBrute")
					{
						addItemToLootTable(monster, "SeekerBruteBlood", 1, 1, 0.5f);
					}
					break;
				case 'Q':
					if (text == "SeekerQueen")
					{
						addItemToLootTable(monster, "QueenCore", 1, 1, 0.15f);
					}
					break;
				}
				break;
			case 6:
				switch (text[0])
				{
				default:
					return;
				case 'S':
					if (text == "Seeker")
					{
						addItemToLootTable(monster, "AcidSludge_bal", 1, 1, 0.5f);
					}
					return;
				case 'D':
					break;
				}
				if (!(text == "Draugr"))
				{
					break;
				}
				goto IL_02ca;
			case 4:
				if (text == "Tick")
				{
					addItemToLootTable(monster, "BlackTissue", 1, 1, 0.25f);
				}
				break;
			case 14:
				if (text == "DvergerMageIce")
				{
					addItemToLootTable(monster, "DvergrHeart", 1, 1, 0.25f);
					addItemToLootTable(monster, "SeedFrost_bal", 1, 1, 0.75f);
				}
				break;
			case 18:
				if (text == "DvergerMageSupport")
				{
					addItemToLootTable(monster, "DvergrHeart", 1, 1, 0.25f);
					addItemToLootTable(monster, "Amethyst_bal", 1, 1, 0.5f);
				}
				break;
			case 15:
				if (text == "DvergerMageFire")
				{
					addItemToLootTable(monster, "DvergrHeart", 1, 1, 0.25f);
					addItemToLootTable(monster, "Amethyst_bal", 1, 1, 0.25f);
				}
				break;
			case 7:
				if (text == "Dverger")
				{
					addItemToLootTable(monster, "GoldBar", 1, 1, 0.25f);
				}
				break;
			case 5:
				if (text == "Gjall")
				{
					addItemToLootTable(monster, "GjallCore_bal", 1, 1, 1f);
				}
				break;
			case 13:
				if (!(text == "Draugr_Ranged"))
				{
					break;
				}
				goto IL_02ca;
			case 12:
				if (text == "Draugr_Elite")
				{
					addItemToLootTable(monster, "DraugrInsygnia", 1, 1, 0.5f);
				}
				break;
			case 8:
			case 9:
			case 10:
			case 16:
			case 17:
				break;
				IL_02ca:
				addItemToLootTable(monster, "DraugrInsygnia", 1, 1, 0.2f);
				break;
			}
		}

		private void addItemToLootTable(GameObject monster, string itemName, int amountMin, int amountMax, float chance)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			CharacterDrop component = monster.GetComponent<CharacterDrop>();
			Drop val = new Drop();
			val.m_amountMin = amountMin;
			val.m_amountMax = amountMax;
			val.m_chance = chance;
			val.m_levelMultiplier = false;
			GameObject val2 = (val.m_prefab = FindItem(itemName));
			component.m_drops.Add(val);
		}

		private void changeMonsterResistance()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			foreach (GameObject monster in monsters)
			{
				Humanoid component = monster.GetComponent<Humanoid>();
				if ((Object)component != (Object)null)
				{
					changeResistanceForException(component);
				}
			}
		}

		private GameObject FindItem(string name)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			GameObject val = list.Find((GameObject x) => ((Object)x).name == name);
			if ((Object)val == (Object)null)
			{
				val = list2.Find((GameObject x) => ((Object)x).name == name);
				if ((Object)val != (Object)null)
				{
					return val;
				}
				Debug.LogWarning((object)("Item Not Found - " + name + ", Replaced With Wood"));
				return list.Find((GameObject x) => ((Object)x).name == "Wood");
			}
			if ((Object)val != (Object)null)
			{
				return val;
			}
			Debug.LogWarning((object)("Item Not Found - " + name + ", Replaced With Wood"));
			return list.Find((GameObject x) => ((Object)x).name == "Wood");
		}

		private CraftingStation FindStation(string name)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			GameObject val = FindItem(name);
			if ((Object)val != (Object)null)
			{
				return val.GetComponent<CraftingStation>();
			}
			return null;
		}

		private void changeSpiritResistance(Humanoid humanoid)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected I4, but got Unknown
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			switch ((int)((Character)humanoid).m_faction)
			{
			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)1;
				break;
			case 4:
				((Character)humanoid).m_damageModifiers.m_spirit = (DamageModifier)5;
				break;
			case 8:
				((Character)humanoid).m_damageModifiers.m_spirit = (DamageModifier)5;
				break;
			case 7:
				break;
			}
		}

		private void changeResistanceForException(Humanoid humanoid)
		{
			changeSpiritResistance(humanoid);
		}
	}
	public class RecipeBuilder
	{
		private List<GameObject> pieces;

		private List<GameObject> items;

		private List<GameObject> newItems;

		public List<Recipe> recipes;

		private string[] toRecipe = new string[17]
		{
			"Blidhr_bal", "Blidhr_base_bal", "BowRazorStrikes", "FenrirSword_bal", "FenrirSword_base_bal", "Gugnir_bal", "Gugnir_base_bal", "HoundsSycle", "Electrum", "Frosteel",
			"GoldBar", "Bloodsteel", "HoundsScythe", "DarkSteel", "AmethystSteel", "MeadBaseLightingResistMedium_bal", "MeadBaseSpiritResistMedium_bal"
		};

		private string[] itemEditNames = new string[19]
		{
			"SeekerAspic", "YggdrasilPorridge", "MagicallyStuffedShroom", "MushroomOmelette", "draugr_sword", "draugr_bow", "draugr_axe", "skeleton_bow", "skeleton_mace", "skeleton_sword2",
			"skeleton_bow2", "skeleton_sword2", "imp_fireball_attack", "Ghost_attack", "gd_king_shoot", "Greydwarf_shaman_attack", "GoblinKing_Beam", "GoblinShaman_attack_fireball", "BowRazorStrikes"
		};

		private void editItems()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			string[] array = itemEditNames;
			string[] array2 = array;
			foreach (string text in array2)
			{
				GameObject val = FindItem(text);
				if ((Object)val == (Object)null)
				{
					Debug.LogWarning((object)("Could not find: " + text));
				}
				else
				{
					CheckStats(val);
				}
			}
		}

		private void CheckStats(GameObject gameObject)
		{
			string name = ((Object)gameObject).name;
			string text = name;
			if (text == null)
			{
				return;
			}
			switch (text.Length)
			{
			case 12:
				switch (text[0])
				{
				default:
					return;
				case 'd':
					if (text == "draugr_sword")
					{
						editSpiritDamageStat(gameObject, 25);
					}
					return;
				case 's':
					if (!(text == "skeleton_bow"))
					{
						return;
					}
					break;
				case 'G':
					if (!(text == "Ghost_attack"))
					{
						return;
					}
					break;
				}
				goto IL_0243;
			case 10:
				switch (text[7])
				{
				case 'b':
					if (text == "draugr_bow")
					{
						editSpiritDamageStat(gameObject, 15);
					}
					break;
				case 'a':
					if (text == "draugr_axe")
					{
						editSpiritDamageStat(gameObject, 15);
					}
					break;
				}
				break;
			case 13:
				switch (text[9])
				{
				default:
					return;
				case 'b':
					if (!(text == "skeleton_bow2"))
					{
						return;
					}
					break;
				case 'm':
					if (!(text == "skeleton_mace"))
					{
						return;
					}
					break;
				case 'h':
					if (!(text == "gd_king_shoot"))
					{
						return;
					}
					break;
				}
				goto IL_024f;
			case 15:
				switch (text[0])
				{
				default:
					return;
				case 's':
					if (!(text == "skeleton_sword2"))
					{
						return;
					}
					break;
				case 'G':
					if (!(text == "GoblinKing_Beam"))
					{
						return;
					}
					break;
				case 'B':
					if (text == "BowRazorStrikes")
					{
						editStatsRazorStrike(gameObject, 94, 0, 10, 10, 0, 10);
					}
					return;
				}
				goto IL_024f;
			case 14:
				if (!(text == "skeleton_sword"))
				{
					break;
				}
				goto IL_0243;
			case 23:
				if (!(text == "Greydwarf_shaman_attack"))
				{
					break;
				}
				goto IL_024f;
			case 28:
				if (!(text == "GoblinShaman_attack_fireball"))
				{
					break;
				}
				goto IL_024f;
			case 19:
				{
					if (text == "imp_fireball_attack")
					{
						editSpiritDamageStat(gameObject, 10);
					}
					break;
				}
				IL_0243:
				editSpiritDamageStat(gameObject, 10);
				break;
				IL_024f:
				editSpiritDamageStat(gameObject, 20);
				break;
			}
		}

		private void editStatsRazorStrike(GameObject gameObject, int pierce, int fire, int frost, int lightning, int poison, int spirit)
		{
			ItemDrop component = gameObject.GetComponent<ItemDrop>();
			component.m_itemData.m_shared.m_damages.m_pierce = pierce;
			component.m_itemData.m_shared.m_damages.m_fire = fire;
			component.m_itemData.m_shared.m_damages.m_frost = frost;
			component.m_itemData.m_shared.m_damages.m_lightning = lightning;
			component.m_itemData.m_shared.m_damages.m_poison = poison;
			component.m_itemData.m_shared.m_damages.m_spirit = spirit;
			component.m_itemData.m_shared.m_damagesPerLevel.m_pierce = 4f;
			component.m_itemData.m_shared.m_damagesPerLevel.m_fire = 0f;
			component.m_itemData.m_shared.m_damagesPerLevel.m_frost = 4f;
			component.m_itemData.m_shared.m_damagesPerLevel.m_lightning = 4f;
			component.m_itemData.m_shared.m_damagesPerLevel.m_poison = 0f;
			component.m_itemData.m_shared.m_damagesPerLevel.m_spirit = 4f;
		}

		private void editSpiritDamageStat(GameObject gameObject, int spiritDamage)
		{
			ItemDrop component = gameObject.GetComponent<ItemDrop>();
			component.m_itemData.m_shared.m_damages.m_spirit = spiritDamage;
			if (((Object)gameObject).name == "skeleton_mace" || ((Object)gameObject).name == "imp_fireball_attack")
			{
				component.m_itemData.m_shared.m_damages.m_blunt += spiritDamage;
			}
		}

		private void editFoodStat(GameObject gameObject, int hp, int stam, int eitr)
		{
			ItemDrop component = gameObject.GetComponent<ItemDrop>();
			component.m_itemData.m_shared.m_food = hp;
			component.m_itemData.m_shared.m_foodStamina = stam;
			component.m_itemData.m_shared.m_foodEitr = eitr;
		}

		public List<Recipe> createRecipes(List<GameObject> items, List<GameObject> newItems)
		{
			this.items = items;
			this.newItems = newItems;
			pieces = items.Find((GameObject x) => ((Object)x).name == "Hammer").GetComponent<ItemDrop>().m_itemData.m_shared.m_buildPieces.m_pieces;
			List<Recipe> list = new List<Recipe>();
			CraftingStation component = pieces.Find((GameObject x) => ((Object)x).name == "forge").GetComponent<CraftingStation>();
			int minStationLevel = 3;
			foreach (GameObject newItem in newItems)
			{
				if (toRecipe.Contains(((Object)newItem).name))
				{
					Recipe val = ScriptableObject.CreateInstance<Recipe>();
					val.m_craftingStation = component;
					val.m_repairStation = component;
					val.m_minStationLevel = minStationLevel;
					val = createResources(newItem, val);
					list.Add(val);
				}
			}
			editItems();
			return list;
		}

		public Sprite LoadNewSprite(string FilePath, float PixelsPerUnit = 100f)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = LoadTexture(FilePath);
			return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0f, 0f), PixelsPerUnit);
		}

		public Texture2D LoadTexture(string fileName)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string name = executingAssembly.GetManifestResourceNames().Single((string str) => str.EndsWith(fileName));
			using (Stream stream = executingAssembly.GetManifestResourceStream(name))
			{
				byte[] array = new byte[stream.Length];
				stream.Read(array, 0, (int)stream.Length);
				Texture2D val = new Texture2D(2, 2);
				if (ImageConversion.LoadImage(val, array))
				{
					return val;
				}
			}
			return null;
		}

		private Recipe createResources(GameObject item, Recipe newRecipe)
		{
			((Object)newRecipe).name = "Recipe_" + ((Object)item).name;
			newRecipe.m_item = item.GetComponent<ItemDrop>();
			newRecipe.m_amount = 1;
			newRecipe.m_enabled = true;
			List<Requirement> list = new List<Requirement>();
			switch (((Object)item).name)
			{
			case "Blidhr_base_bal":
			{
				item.GetComponent<ItemDrop>().m_itemData.m_shared.m_name = "Freyrs Rune Axe";
				list.Add(createReq("DarkSteel", 10, 5));
				list.Add(createReq("ElderBark", 10, 2));
				list.Add(createReq("Silver", 10, 2));
				list.Add(createReq("AncientSeed", 15, 6));
				List<Sprite> list3 = new List<Sprite>();
				list3.Add(LoadNewSprite("bladhir_base_ico.png"));
				item.GetComponent<ItemDrop>().m_itemData.m_shared.m_icons = list3.ToArray();
				break;
			}
			case "Blidhr_bal":
			{
				newRecipe.m_craftingStation = FindStation(pieces, "SacredForge");
				newRecipe.m_minStationLevel = 1;
				list.Add(createReq("Blidhr_base_bal", 1, 0));
				list.Add(createReq("AmethystSteel", 8, 4));
				list.Add(createReq("AcidSludge_bal", 20, 10));
				list.Add(createReq("YmirRemains", 20, 10));
				List<Sprite> list2 = new List<Sprite>();
				list2.Add(LoadNewSprite("bladhir_ico.png"));
				item.GetComponent<ItemDrop>().m_itemData.m_shared.m_icons = list2.ToArray();
				break;
			}
			case "BowRazorStrikes":
				newRecipe.m_craftingStation = FindStation(pieces, "piece_workbench");
				newRecipe.m_minStationLevel = 1;
				list.Add(createReq("Electrum", 15, 5));
				list.Add(createReq("Eitr", 30, 2));
				list.Add(createReq("MediumSpiritPotion_bal", 5, 2));
				break;
			case "FenrirSword_bal":
				newRecipe.m_craftingStation = FindStation(pieces, "SacredForge");
				newRecipe.m_minStationLevel = 1;
				list.Add(createReq("FenrirSword_base_bal", 1, 0));
				list.Add(createReq("Frosteel", 8, 4));
				list.Add(createReq("SeedFrost_bal", 20, 10));
				list.Add(createReq("Crystal", 20, 10));
				break;
			case "FenrirSword_base_bal":
				list.Add(createReq("DarkSteel", 10, 5));
				list.Add(createReq("ElderBark", 10, 2));
				list.Add(createReq("Silver", 10, 2));
				list.Add(createReq("WolfPelt", 10, 2));
				break;
			case "Gugnir_base_bal":
				item.GetComponent<ItemDrop>().m_itemData.m_shared.m_name = "Spear of Penitents";
				list.Add(createReq("DarkSteel", 10, 5));
				list.Add(createReq("ElderBark", 10, 2));
				list.Add(createReq("Silver", 10, 2));
				list.Add(createReq("MushroomYellow", 20, 5));
				break;
			case "Gugnir_bal":
				newRecipe.m_craftingStation = FindStation(pieces, "SacredForge");
				newRecipe.m_minStationLevel = 1;
				list.Add(createReq("Gugnir_base_bal", 1, 0));
				list.Add(createReq("Electrum", 8, 4));
				list.Add(createReq("GoldBar", 20, 10));
				list.Add(createReq("Thunderstone", 20, 10));
				break;
			case "HoundsSycle":
				list.Add(createReq("DarkSteel", 10, 5));
				list.Add(createReq("ElderBark", 10, 2));
				list.Add(createReq("Silver", 10, 2));
				list.Add(createReq("Bloodbag", 15, 6));
				break;
			case "HoundsScythe":
				newRecipe.m_craftingStation = FindStation(pieces, "SacredForge");
				newRecipe.m_minStationLevel = 1;
				list.Add(createReq("HoundsSycle", 1, 0));
				list.Add(createReq("Bloodsteel", 8, 4));
				list.Add(createReq("BlackTissue", 20, 10));
				list.Add(createReq("SurtlingCore", 20, 10));
				break;
			case "Electrum":
				newRecipe.m_craftingStation = FindStation(pieces, "SacredForge");
				newRecipe.m_minStationLevel = 1;
				list.Add(createReq("FlametalNew", 4, 0));
				list.Add(createReq("DarkSteel", 3, 0));
				list.Add(createReq("GjallCore_bal", 5, 0));
				list.Add(createReq("Coal", 8, 0));
				break;
			case "Frosteel":
				newRecipe.m_craftingStation = FindStation(pieces, "SacredForge");
				newRecipe.m_minStationLevel = 1;
				list.Add(createReq("FlametalNew", 4, 0));
				list.Add(createReq("DarkSteel", 3, 0));
				list.Add(createReq("SeedFrost_bal", 5, 0));
				list.Add(createReq("Coal", 8, 0));
				break;
			case "GoldBar":
				newRecipe.m_minStationLevel = 5;
				list.Add(createReq("Coins", 999, 0));
				list.Add(createReq("Coal", 10, 0));
				break;
			case "Bloodsteel":
				newRecipe.m_craftingStation = FindStation(pieces, "SacredForge");
				newRecipe.m_minStationLevel = 1;
				list.Add(createReq("FlametalNew", 4, 0));
				list.Add(createReq("DarkSteel", 3, 0));
				list.Add(createReq("SeekerBruteBlood", 5, 0));
				list.Add(createReq("Coal", 8, 0));
				break;
			case "DarkSteel":
				list.Add(createReq("Iron", 3, 0));
				list.Add(createReq("Obsidian", 6, 0));
				list.Add(createReq("Coal", 5, 0));
				break;
			case "AmethystSteel":
				newRecipe.m_craftingStation = FindStation(pieces, "SacredForge");
				newRecipe.m_minStationLevel = 1;
				list.Add(createReq("FlametalNew", 4, 0));
				list.Add(createReq("DarkSteel", 3, 0));
				list.Add(createReq("Amethyst_bal", 5, 0));
				list.Add(createReq("Coal", 8, 0));
				break;
			case "MeadBaseLightingResistMedium_bal":
				newRecipe.m_craftingStation = FindStation(pieces, "piece_cauldron");
				newRecipe.m_minStationLevel = 2;
				list.Add(createReq("Thunderstone", 3, 0));
				list.Add(createReq("Thistle", 5, 0));
				list.Add(createReq("GreydwarfEye", 25, 0));
				list.Add(createReq("TrophyFrostTroll", 2, 0));
				break;
			case "MeadBaseSpiritResistMedium_bal":
				newRecipe.m_craftingStation = FindStation(pieces, "piece_cauldron");
				newRecipe.m_minStationLevel = 2;
				list.Add(createReq("DraugrInsygnia", 6, 0));
				list.Add(createReq("Honey", 10, 0));
				list.Add(createReq("Bloodbag", 4, 0));
				list.Add(createReq("TrophyGreydwarfShaman", 2, 0));
				break;
			}
			newRecipe.m_resources = list.ToArray();
			return newRecipe;
		}

		public Requirement createReq(string name, int amount, int amountPerLevel)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			Requirement val = new Requirement();
			val.m_recover = true;
			ItemDrop val2 = (val.m_resItem = items.Find((GameObject x) => ((Object)x).name == name).GetComponent<ItemDrop>());
			val.m_amount = amount;
			val.m_amountPerLevel = amountPerLevel;
			return val;
		}

		private GameObject FindItem(string name)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			GameObject val = items.Find((GameObject x) => ((Object)x).name == name);
			if ((Object)val == (Object)null)
			{
				val = newItems.Find((GameObject x) => ((Object)x).name == name);
				if ((Object)val != (Object)null)
				{
					return val;
				}
				Debug.LogWarning((object)("Item Not Found - " + name + ", Replaced With Wood"));
				return items.Find((GameObject x) => ((Object)x).name == "Wood");
			}
			if ((Object)val != (Object)null)
			{
				return val;
			}
			Debug.LogWarning((object)("Item Not Found - " + name + ", Replaced With Wood"));
			return items.Find((GameObject x) => ((Object)x).name == "Wood");
		}

		private CraftingStation FindStation(List<GameObject> list, string name)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			GameObject val = list.Find((GameObject x) => ((Object)x).name == name);
			if ((Object)val != (Object)null)
			{
				return val.GetComponent<CraftingStation>();
			}
			return null;
		}

		internal void fixWaveGround(List<GameObject> m_prefabs)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				GameObject g = m_prefabs.Find((GameObject x) => ((Object)x).name == "Wave_Ground");
				recolorParticleEmitterColorsRecursively(g, new Color(0f, 0.64f, 1f));
				GameObject g2 = m_prefabs.Find((GameObject x) => ((Object)x).name == "vfx_spiritbolt_explosion");
				recolorParticleEmitterColorsRecursively(g2, new Color(0f, 0.64f, 1f));
				GameObject val = m_prefabs.Find((GameObject x) => ((Object)x).name == "Blidhr_base_bal");
				Transform val2 = RecursiveFindChild(val.transform, "RuneRock_3 (1)");
				((Component)val2).GetComponent<Renderer>().material.SetColor("_EmissionColor", new Color(0f, 0.6f, 1f));
				GameObject val3 = m_prefabs.Find((GameObject x) => ((Object)x).name == "Blidhr_bal");
				Transform val4 = RecursiveFindChild(val3.transform, "RuneRock_1");
				((Component)val4).GetComponent<Renderer>().material.SetColor("_EmissionColor", new Color(0f, 0.6f, 1f));
			}
			catch (Exception ex)
			{
				Debug.Log((object)"######################################################################");
				Debug.Log((object)"Failed to fixwaveground");
				Debug.Log((object)ex);
			}
		}

		private static void recolorParticleEmitterColorsRecursively(GameObject g, Color c)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: 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)
			ParticleSystem component = g.GetComponent<ParticleSystem>();
			if ((Object)(object)component != (Object)null)
			{
				MainModule main = component.main;
				MinMaxGradient startColor = ((MainModule)(ref main)).startColor;
				c.a = ((MinMaxGradient)(ref startColor)).color.a;
				((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(c);
				TrailModule trails = component.trails;
				if (((TrailModule)(ref trails)).enabled)
				{
					TrailModule trails2 = component.trails;
					((TrailModule)(ref trails2)).colorOverLifetime = MinMaxGradient.op_Implicit(c);
				}
				ColorOverLifetimeModule colorOverLifetime = component.colorOverLifetime;
				if (((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled)
				{
					try
					{
						ColorOverLifetimeModule colorOverLifetime2 = component.colorOverLifetime;
						((ColorOverLifetimeModule)(ref colorOverLifetime2)).color = MinMaxGradient.op_Implicit(c);
					}
					catch (Exception ex)
					{
						Debug.Log((object)"######################################################################");
						Debug.Log((object)"Failed to recolorParticleEmitterColorsRecursively");
						Debug.Log((object)ex);
					}
				}
			}
			for (int i = 0; i < g.transform.childCount; i++)
			{
				recolorParticleEmitterColorsRecursively(((Component)g.transform.GetChild(i)).gameObject, c);
			}
		}

		private Transform RecursiveFindChild(Transform parent, string childName)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			foreach (Transform item in parent)
			{
				Transform val = item;
				if (((Object)val).name == childName)
				{
					return val;
				}
				Transform val2 = RecursiveFindChild(val, childName);
				if ((Object)(object)val2 != (Object)null)
				{
					return val2;
				}
			}
			return null;
		}
	}
	public class ShaderReplacment
	{
		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 List<Shader> shaders = new List<Shader>();

		public void findShadersByName()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			string[] array = shaderlist;
			string[] array2 = array;
			foreach (string text in array2)
			{
				Shader val = Shader.Find(text);
				if ((Object)val != (Object)null)
				{
					shaders.Add(val);
				}
			}
		}

		public void ReplaceShadersInObject(GameObject gameObject)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Expected O, but got Unknown
			if ((Object)gameObject == (Object)null)
			{
				return;
			}
			Renderer[] componentsInChildren = gameObject.GetComponentsInChildren<Renderer>();
			if (componentsInChildren == null || componentsInChildren.Length == 0)
			{
				return;
			}
			Renderer[] array = componentsInChildren;
			Renderer[] array2 = array;
			foreach (Renderer val in array2)
			{
				int num = 0;
				Material[] sharedMaterials = val.sharedMaterials;
				if (sharedMaterials == null || sharedMaterials.Length == 0)
				{
					continue;
				}
				Material[] array3 = sharedMaterials;
				Material[] array4 = array3;
				foreach (Material val2 in array4)
				{
					string name = ((Object)val2.shader).name;
					if (!(name == "Standard") && name.Contains("Balrond"))
					{
						string name2 = name.Replace("Balrond", "Custom");
						name2 = checkNaming(name2);
						Shader val3 = Shader.Find(name2);
						if ((Object)val3 == (Object)null)
						{
							Debug.LogWarning((object)("[Project Ashlands]: Shader not found " + name2));
							continue;
						}
						val2.shader = val3;
						num++;
					}
				}
			}
		}

		private 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;
		}
	}
}