Decompiled source of balrond cultist armor v1.0.4

plugins/BalrondCultistArmor.dll

Decompiled 3 months ago
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 BepInEx;
using HarmonyLib;
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: AssemblyVersion("1.0.0.0")]
namespace BalrondCultistArmor;

[BepInPlugin("balrond.astafaraios.BalrondCultistArmor", "BalrondCultistArmor", "1.0.4")]
public class Launch : BaseUnityPlugin
{
	[HarmonyPatch(typeof(ZNetScene), "Awake")]
	public static class ZNetScene_Awake_Path
	{
		public static void Prefix(ZNetScene __instance)
		{
			if ((Object)(object)__instance == (Object)null)
			{
				return;
			}
			GameObject val = createUlvMInion(__instance);
			GameObject val2 = vfxList.Find((GameObject x) => ((Object)x).name == "staff_ulv_spawn");
			val2.GetComponent<SpawnAbility>().m_spawnPrefab[0] = val;
			foreach (GameObject newPrefab2 in vfxList)
			{
				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 prefabs)
			{
				if (!Object.op_Implicit((Object)(object)__instance.m_prefabs.Find((GameObject x) => ((Object)x).name == ((Object)newPrefab).name)))
				{
					__instance.m_prefabs.Add(newPrefab);
				}
			}
			setIronHook(__instance);
			monsterManager.setupMonsters(__instance.m_prefabs, __instance.m_prefabs);
		}
	}

	[HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")]
	public static class Object_CopyOtherDB_Path
	{
		public static void Postfix()
		{
			if (!IsObjectDBValid())
			{
				return;
			}
			foreach (StatusEffect statusEffect in statusEffects)
			{
				AddStatus(statusEffect);
			}
			foreach (GameObject prefab in prefabs)
			{
				AddNewPrefab(prefab);
			}
		}
	}

	[HarmonyPatch(typeof(ObjectDB), "Awake")]
	public static class Object_Awake_Path
	{
		public static void Postfix()
		{
			if (!IsObjectDBValid())
			{
				return;
			}
			foreach (StatusEffect statusEffect in statusEffects)
			{
				AddStatus(statusEffect);
			}
			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.BalrondCultistArmor");

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

	public const string PluginName = "BalrondCultistArmor";

	public const string PluginVersion = "1.0.4";

	private static AssetBundle assetBundle;

	private static readonly string bundleName = "cultistset";

	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 MonsterManager monsterManager = new MonsterManager();

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

	public static GameObject RootObject;

	public static GameObject PrefabContainer;

	private static readonly string[] prefabNames = new string[5] { "ArmorCultistChest", "ArmorCultistLegs", "CapeCultist", "CursedHand", "HelmetCultist" };

	private static readonly string[] resourceNames = new string[4] { "CultInsygnia", "CorruptedEitr", "FenringMeat", "FenringMeatCooked" };

	private static readonly string[] vfxNames = new string[1] { "staff_ulv_spawn" };

	public static Sprite iconSpirit = null;

	public static 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);
		((Object)val).name = name;
		val = fixMaterials(val, source);
		val.SetActive(true);
		return val;
	}

	public static GameObject fixMaterials(GameObject clone, GameObject source)
	{
		MeshRenderer[] componentsInChildren = source.GetComponentsInChildren<MeshRenderer>();
		foreach (MeshRenderer val in componentsInChildren)
		{
			MeshRenderer[] componentsInChildren2 = clone.GetComponentsInChildren<MeshRenderer>();
			foreach (MeshRenderer val2 in componentsInChildren2)
			{
				if (((Object)val).name == ((Object)val2).name)
				{
					((Renderer)val2).materials = ((Renderer)val).sharedMaterials;
					((Renderer)val2).sharedMaterials = ((Renderer)val).sharedMaterials;
					break;
				}
			}
		}
		return clone;
	}

	private void Awake()
	{
		init();
	}

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

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

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

	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)
	{
		iconSpirit = assetBundle.LoadAsset<Sprite>("Assets/Custom/BalrondFenringCultist/ico/spiritburn1.png");
		string[] array = vfxNames;
		foreach (string text in array)
		{
			GameObject val = assetBundle.LoadAsset<GameObject>("Assets/Custom/BalrondFenringCultist/" + text + ".prefab");
			val.SetActive(true);
			vfxList.Add(val);
		}
		string[] array2 = resourceNames;
		foreach (string text2 in array2)
		{
			GameObject val2 = assetBundle.LoadAsset<GameObject>("Assets/Custom/BalrondFenringCultist/" + text2 + ".prefab");
			val2.SetActive(true);
			prefabs.Add(val2);
		}
		string[] array3 = prefabNames;
		foreach (string text3 in array3)
		{
			GameObject val3 = assetBundle.LoadAsset<GameObject>("Assets/Custom/BalrondFenringCultist/" + text3 + ".prefab");
			val3.SetActive(true);
			prefabs.Add(val3);
		}
		ItemDrop component = prefabs.Find((GameObject x) => ((Object)x).name == "CapeCultist").GetComponent<ItemDrop>();
		statusEffects.Add(component.m_itemData.m_shared.m_setStatusEffect);
	}

	public static void setIronHook(ZNetScene zNetScene)
	{
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Expected O, but got Unknown
		GameObject val = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "piece_cookingstation_iron");
		ItemConversion val2 = new ItemConversion();
		val2.m_from = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "FenringMeat").GetComponent<ItemDrop>();
		val2.m_to = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "FenringMeatCooked").GetComponent<ItemDrop>();
		val2.m_cookTime = 40f;
		if ((Object)(object)val != (Object)null)
		{
			CookingStation component = val.GetComponent<CookingStation>();
			component.m_conversion.Add(val2);
		}
	}

	public static void addConsumeFood(MonsterAI monsterAI, ZNetScene __instance, string name)
	{
		monsterAI.m_consumeItems.Add(__instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "BugMeat").GetComponent<ItemDrop>());
	}

	public static GameObject createUlvMInion(ZNetScene __instance)
	{
		//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01af: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "Ulv");
		GameObject val2 = cloneMe(val, "Ulv_minion");
		GameObject val3 = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "Skeleton_Friendly");
		MonsterAI component = val.GetComponent<MonsterAI>();
		addConsumeFood(component, __instance, "BugMeat");
		addConsumeFood(component, __instance, "ChickenMeat");
		addConsumeFood(component, __instance, "CookedBugMeat");
		addConsumeFood(component, __instance, "CookedChickenMeat");
		addConsumeFood(component, __instance, "CookedDeerMeat");
		addConsumeFood(component, __instance, "CookedMeat");
		addConsumeFood(component, __instance, "DeerMeat");
		addConsumeFood(component, __instance, "CookedWolfMeat");
		addConsumeFood(component, __instance, "CookedHareMeat");
		addConsumeFood(component, __instance, "CookedLoxMeat");
		addConsumeFood(component, __instance, "HareMeat");
		addConsumeFood(component, __instance, "LoxMeat");
		((Character)val.GetComponent<Humanoid>()).m_health = 300f;
		Tameable val4 = val2.AddComponent<Tameable>();
		Tameable component2 = val3.GetComponent<Tameable>();
		val4.m_commandable = true;
		val4.m_startsTamed = true;
		val4.m_fedDuration = component2.m_fedDuration;
		val4.m_petEffect = component2.m_petEffect;
		val4.m_sootheEffect = component2.m_sootheEffect;
		val4.m_tamedEffect = component2.m_tamedEffect;
		val4.m_unsummonDistance = component2.m_unsummonDistance;
		val4.m_unSummonEffect = component2.m_unSummonEffect;
		val4.m_tamingTime = component2.m_tamingTime;
		val4.m_unsummonOnOwnerLogoutSeconds = component2.m_unsummonOnOwnerLogoutSeconds;
		val4.m_levelUpOwnerSkill = component2.m_levelUpOwnerSkill;
		val4.m_levelUpFactor = component2.m_levelUpFactor;
		Object.Destroy((Object)(object)val2.GetComponent<CharacterDrop>());
		__instance.m_prefabs.Add(val2);
		return val2;
	}

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

	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)
	{
		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[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(((object)status).GetHashCode()) == (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)(object)x.GetComponent<MonsterAI>() != (Object)null);
		if (monsters == null)
		{
			Debug.LogWarning((object)"I DID NOT FOUND ANY MONSTERS!");
		}
		else
		{
			changeMonsterDrops();
		}
	}

	private void changeMonsterDrops()
	{
		string[] array = new string[3] { "Ulv", "Fenring", "Fenring_Cultist" };
		string[] array2 = array;
		foreach (string name in array2)
		{
			GameObject val = monsters.Find((GameObject x) => ((Object)x).name == name);
			if ((Object)(object)val != (Object)null)
			{
				monsterLootChange(val);
			}
		}
	}

	private void monsterLootChange(GameObject monster)
	{
		switch (((Object)monster).name)
		{
		case "Ulv":
			addItemToLootTable(monster, "FenringMeat", 1, 1, 0.15f);
			addItemToLootTable(monster, "WolfHairBundle", 1, 1, 0.25f);
			addItemToLootTable(monster, "WolfClaw", 1, 1, 0.15f);
			break;
		case "Fenring":
			addItemToLootTable(monster, "FenringMeat", 1, 1, 0.33f);
			addItemToLootTable(monster, "CultInsygnia", 1, 1, 0.05f);
			addItemToLootTable(monster, "CorruptedEitr", 1, 2, 0.15f);
			addItemToLootTable(monster, "WolfHairBundle", 1, 1, 0.2f);
			addItemToLootTable(monster, "WolfClaw", 1, 1, 0.2f);
			break;
		case "Fenring_Cultist":
			addItemToLootTable(monster, "FenringMeat", 1, 1, 0.33f);
			addItemToLootTable(monster, "CorruptedEitr", 2, 5, 0.7f);
			addItemToLootTable(monster, "CultInsygnia", 1, 2, 0.1f);
			addItemToLootTable(monster, "WolfHairBundle", 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 prefab = FindItem(itemName);
		val.m_prefab = prefab;
		component.m_drops.Add(val);
	}

	private void changeMonsterResistance()
	{
		foreach (GameObject monster in monsters)
		{
			Humanoid component = monster.GetComponent<Humanoid>();
			if ((Object)(object)component != (Object)null)
			{
				changeResistanceForException(component);
			}
		}
	}

	private GameObject FindItem(string name)
	{
		GameObject val = list.Find((GameObject x) => ((Object)x).name == name);
		if ((Object)(object)val == (Object)null)
		{
			val = list2.Find((GameObject x) => ((Object)x).name == name);
			if ((Object)(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)(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)
	{
		GameObject val = FindItem(name);
		if ((Object)(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_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_0036: Expected I4, but got Unknown
		//IL_003f: 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_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: 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_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		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)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 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()
	{
		string[] array = shaderlist;
		foreach (string text in array)
		{
			Shader val = Shader.Find(text);
			if ((Object)(object)val != (Object)null)
			{
				shaders.Add(val);
			}
		}
	}

	public void ReplaceShadersInObject(GameObject gameObject)
	{
		if ((Object)(object)gameObject == (Object)null)
		{
			return;
		}
		Renderer[] componentsInChildren = gameObject.GetComponentsInChildren<Renderer>();
		if (componentsInChildren == null || componentsInChildren.Length == 0)
		{
			return;
		}
		Renderer[] array = componentsInChildren;
		foreach (Renderer val in array)
		{
			Material[] sharedMaterials = val.sharedMaterials;
			if (sharedMaterials != null && sharedMaterials.Length != 0)
			{
				fixMaterial(sharedMaterials);
			}
		}
	}

	private void fixMaterial(Material[] shared)
	{
		foreach (Material val in shared)
		{
			if ((Object)(object)val == (Object)null)
			{
				continue;
			}
			Shader shader = val.shader;
			if (!((Object)(object)shader == (Object)null))
			{
				string name = ((Object)shader).name;
				if (!(name == "Standard") && name.Contains("Balrond"))
				{
					setProperValue(val, name);
				}
			}
		}
	}

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

	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;
	}
}
public class RecipeBuilder
{
	private List<GameObject> pieces;

	private List<GameObject> items;

	private List<GameObject> newItems;

	public List<Recipe> recipes;

	private string[] toRecipe = new string[6] { "ArmorCultistChest", "ArmorCultistLegs", "CapeCultist", "CursedHand", "HelmetCultist", "CultInsygnia" };

	private string[] itemEditNames = new string[18]
	{
		"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"
	};

	private void editItems()
	{
		string[] array = itemEditNames;
		foreach (string text in array)
		{
			GameObject val = FindItem(text);
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogWarning((object)("Could not find: " + text));
			}
			else
			{
				CheckStats(val);
			}
		}
	}

	private void CheckStats(GameObject gameObject)
	{
		switch (((Object)gameObject).name)
		{
		case "SeekerAspic":
			editFoodStat(gameObject, 125, 60, 150);
			break;
		case "YggdrasilPorridge":
			editFoodStat(gameObject, 120, 120, 150);
			break;
		case "StuffedMmushroom":
			editFoodStat(gameObject, 110, 80, 150);
			break;
		case "MushroomOmlette":
			editFoodStat(gameObject, 85, 150, 150);
			break;
		case "draugr_sword":
			editSpiritDamageStat(gameObject, 25);
			break;
		case "draugr_bow":
			editSpiritDamageStat(gameObject, 15);
			break;
		case "draugr_axe":
			editSpiritDamageStat(gameObject, 15);
			break;
		case "skeleton_bow":
		case "skeleton_sword":
		case "Ghost_attack":
			editSpiritDamageStat(gameObject, 10);
			break;
		case "skeleton_bow2":
		case "skeleton_mace":
		case "skeleton_sword2":
		case "gd_king_shoot":
		case "Greydwarf_shaman_attack":
		case "GoblinKing_Beam":
		case "GoblinShaman_attack_fireball":
			editSpiritDamageStat(gameObject, 20);
			break;
		case "imp_fireball_attack":
			editSpiritDamageStat(gameObject, 10);
			break;
		}
	}

	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);
			}
		}
		list.Add(createCorruptedEitrRecipe());
		return list;
	}

	private Recipe createCorruptedEitrRecipe()
	{
		Recipe val = ScriptableObject.CreateInstance<Recipe>();
		val.m_craftingStation = FindStation(pieces, "piece_magetable");
		((Object)val).name = "Recipe_CorruptedEitr";
		val.m_repairStation = val.m_craftingStation;
		val.m_enabled = true;
		val.m_amount = 3;
		val.m_minStationLevel = 1;
		val.m_item = FindItem("Eitr").GetComponent<ItemDrop>();
		List<Requirement> list = new List<Requirement>();
		list.Add(createReq("Thistle", 2, 0));
		list.Add(createReq("DragonTear", 1, 0));
		list.Add(createReq("CorruptedEitr", 5, 0));
		val.m_resources = list.ToArray();
		return val;
	}

	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>();
		CraftingStation craftingStation = FindStation(pieces, "piece_workbench");
		switch (((Object)item).name)
		{
		case "ArmorCultistChest":
			newRecipe.m_craftingStation = craftingStation;
			newRecipe.m_minStationLevel = 2;
			list.Add(createReq("JuteRed", 4, 2));
			list.Add(createReq("WolfPelt", 3, 2));
			list.Add(createReq("CultInsygnia", 5, 3));
			list.Add(createReq("LeatherScraps", 20, 10));
			break;
		case "ArmorCultistLegs":
			newRecipe.m_craftingStation = craftingStation;
			newRecipe.m_minStationLevel = 2;
			list.Add(createReq("JuteRed", 4, 2));
			list.Add(createReq("CultInsygnia", 5, 1));
			list.Add(createReq("WolfPelt", 5, 2));
			list.Add(createReq("LeatherScraps", 20, 10));
			break;
		case "CapeCultist":
			newRecipe.m_craftingStation = craftingStation;
			newRecipe.m_minStationLevel = 2;
			list.Add(createReq("JuteRed", 3, 3));
			list.Add(createReq("WolfPelt", 5, 2));
			list.Add(createReq("LeatherScraps", 0, 12));
			list.Add(createReq("TrophyUlv", 2, 1));
			break;
		case "CursedHand":
			newRecipe.m_craftingStation = craftingStation;
			newRecipe.m_minStationLevel = 2;
			list.Add(createReq("CorruptedEitr", 4, 2));
			list.Add(createReq("CultInsygnia", 2, 1));
			list.Add(createReq("TrophyFenring", 1, 1));
			list.Add(createReq("TrophyUlv", 2, 1));
			break;
		case "CultInsygnia":
			newRecipe.m_craftingStation = craftingStation;
			newRecipe.m_minStationLevel = 2;
			list.Add(createReq("WolfClaw", 2, 0));
			list.Add(createReq("WolfFang", 2, 0));
			list.Add(createReq("Iron", 2, 0));
			list.Add(createReq("WolfHairBundle", 1, 0));
			break;
		case "HelmetCultist":
			newRecipe.m_craftingStation = craftingStation;
			newRecipe.m_minStationLevel = 2;
			list.Add(createReq("TrophyCultist", 1, 1));
			list.Add(createReq("JuteRed", 3, 2));
			list.Add(createReq("CultInsygnia", 2, 1));
			list.Add(createReq("CorruptedEitr", 4, 2));
			break;
		}
		newRecipe.m_resources = list.ToArray();
		return newRecipe;
	}

	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 component = items.Find((GameObject x) => ((Object)x).name == name).GetComponent<ItemDrop>();
		val.m_resItem = component;
		val.m_amount = amount;
		val.m_amountPerLevel = amountPerLevel;
		return val;
	}

	private GameObject FindItem(string name)
	{
		GameObject val = items.Find((GameObject x) => ((Object)x).name == name);
		if ((Object)(object)val == (Object)null)
		{
			val = newItems.Find((GameObject x) => ((Object)x).name == name);
			if ((Object)(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)(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)
	{
		GameObject val = list.Find((GameObject x) => ((Object)x).name == name);
		if ((Object)(object)val != (Object)null)
		{
			return val.GetComponent<CraftingStation>();
		}
		return null;
	}
}