Decompiled source of Eotenas v0.1.2

plugins/Balrond-BalrondEotenasClanRebuild/BalrondEotenasClanRebuild.dll

Decompiled 4 months ago
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Configuration;
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 UnityEngine;

[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: Guid("f405ea1c-ac25-47a3-9aa2-a8f56c14bfd6")]
[assembly: ComVisible(false)]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyProduct("BalrondEotenasClanRebuild")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyTitle("BalrondEotenasClanRebuild")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[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 EotenasClans
{
	public class ClanObject
	{
		public string clanName;

		public string msg;

		public StatusEffect status;

		public GameObject item;

		public GameObject sfx;

		public EffectList clanEffects = new EffectList();
	}
	public class ClanTotem : MonoBehaviour, Interactable, Hoverable
	{
		private ZNetView _znv;

		private string chosenClan = "";

		private void Awake()
		{
			_znv = ((Component)this).GetComponent<ZNetView>();
			if (_znv.IsValid())
			{
				_znv.Register<string>("UseClanTotem", (Action<long, string>)UseClanTotem);
				chosenClan = _znv.m_zdo.GetString("Clan", "");
				SetVisuals(chosenClan);
			}
		}

		private void UseClanTotem(long sender, string name)
		{
			//IL_005c: 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)
			if (_znv.IsOwner())
			{
				Debug.Log((object)("And the name is: " + name));
				chosenClan = name;
				_znv.m_zdo.Set("Clan", name);
				EffectList vfxForClan = ClanManager.getVfxForClan(chosenClan);
				if (vfxForClan != null)
				{
					vfxForClan.Create(((Component)this).transform.position, ((Component)this).transform.rotation, (Transform)null, 1f, -1);
				}
			}
			SetVisuals(name);
		}

		private void SetVisuals(string clan)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			if (clan == "" || clan == null)
			{
				return;
			}
			Transform val = ((Component)this).transform.Find("Items");
			foreach (Transform item in val)
			{
				Transform val2 = item;
				((Component)val2).gameObject.SetActive(false);
			}
			((Component)val.Find(clan)).gameObject.SetActive(true);
		}

		public bool Interact(Humanoid user, bool hold, bool alt)
		{
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			if (chosenClan == "" || chosenClan == null)
			{
				chosenClan = _znv.m_zdo.GetString("Clan", "");
			}
			if (chosenClan != "" && chosenClan != null)
			{
				string msgForClan = ClanManager.getMsgForClan(chosenClan);
				MessageHud.instance.ShowMessage((MessageType)2, msgForClan, 0, (Sprite)null);
				ClanManager.SetFaction(chosenClan);
				EffectList vfxForClan = ClanManager.getVfxForClan(chosenClan);
				if (vfxForClan != null)
				{
					vfxForClan.Create(((Component)this).transform.position, ((Component)this).transform.rotation, (Transform)null, 1f, -1);
				}
				return true;
			}
			MessageHud.instance.ShowMessage((MessageType)2, "This totem does not belong to any clan", 0, (Sprite)null);
			return false;
		}

		public bool UseItem(Humanoid user, ItemData item)
		{
			if (chosenClan == "" || chosenClan == null)
			{
				chosenClan = _znv.m_zdo.GetString("Clan", "");
			}
			if (Player.m_debugMode || Terminal.m_cheat)
			{
				Debug.Log((object)("Clan amount:" + ClanManager.clans.Count));
				foreach (ClanObject clan in ClanManager.clans)
				{
					if (clan == null || !(((Object)clan.item).name == ((Object)item.m_dropPrefab).name))
					{
						continue;
					}
					Debug.Log((object)("Found clan: " + clan.clanName));
					_znv.InvokeRPC(ZNetView.Everybody, "UseClanTotem", new object[1] { clan.clanName });
					user.m_inventory.RemoveOneItem(item);
					return true;
				}
			}
			if (chosenClan != "" && chosenClan != null)
			{
				return false;
			}
			return false;
		}

		public string GetHoverText()
		{
			string text = ((_znv.m_zdo.GetString("Clan", "") != "") ? Localization.instance.Localize("\n[<color=yellow><b>$KEY_Use</b></color>] Set Clan") : "");
			return Localization.instance.Localize("[<color=yellow><b>1-8</b></color>] Use clan item") + text;
		}

		public string GetHoverName()
		{
			return "Clan Totem";
		}
	}
	public class DatabaseAddMethods
	{
		public static string projectName = "EotenasClans";

		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.GetStatusEffect(((object)status).GetHashCode()) == (Object)null)
				{
					ObjectDB.instance.m_StatusEffects.Add(status);
					Debug.Log((object)(projectName + ":  " + ((Object)status).name + " - Status Added to the Game"));
				}
			}
			else
			{
				Debug.LogError((object)(projectName + ":  " + ((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);
					Debug.Log((object)(projectName + ":  " + ((Object)recipe).name + " - Recipe Added to the Game"));
				}
			}
			else
			{
				Debug.LogError((object)(projectName + ":  " + ((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;
					Debug.Log((object)(projectName + ":  " + ((Object)newPrefab).name + " - Item Added to the Game"));
				}
			}
			else
			{
				Debug.LogError((object)(projectName + ":  " + ((Object)newPrefab).name + " - ItemDrop not found on prefab"));
			}
		}
	}
	public static class ClanManager
	{
		public static List<ClanObject> clans = new List<ClanObject>();

		public static void setup()
		{
			createClans();
		}

		public static StatusEffect getStatusForClan(string clanName)
		{
			return clans.Find((ClanObject x) => x.clanName == clanName)?.status;
		}

		public static string getMsgForClan(string clanName)
		{
			ClanObject clanObject = clans.Find((ClanObject x) => x.clanName == clanName);
			if (clanObject != null)
			{
				return clanObject.msg;
			}
			return "Behold the Clan";
		}

		public static EffectList getVfxForClan(string clanName)
		{
			return clans.Find((ClanObject x) => x.clanName == clanName)?.clanEffects;
		}

		public static GameObject getClanItem(string clanName)
		{
			return clans.Find((ClanObject x) => x.clanName == clanName)?.item;
		}

		public static void SetFaction(string clanName)
		{
			if (Player.m_localPlayer.m_customData.ContainsKey("Balrond_EotenasClan") && !Player.m_debugMode && !Terminal.m_cheat)
			{
				Debug.Log((object)"Player already have asigned clan");
				return;
			}
			Player.m_localPlayer.m_customData["Balrond_EotenasClan"] = clanName;
			LoadClanStatus();
		}

		public static void LoadClanStatus()
		{
			if (!Player.m_localPlayer.m_customData.ContainsKey("Balrond_EotenasClan"))
			{
				Debug.Log((object)"Player has no clan asigned");
				return;
			}
			string clanName = Player.m_localPlayer.m_customData["Balrond_EotenasClan"];
			StatusEffect statusForClan = getStatusForClan(clanName);
			if ((Object)(object)statusForClan != (Object)null && (Object)(object)((Character)Player.m_localPlayer).GetSEMan().GetStatusEffect(((object)statusForClan).GetHashCode()) == (Object)null)
			{
				((Character)Player.m_localPlayer).GetSEMan().AddStatusEffect(statusForClan, false, 0, 0f);
			}
		}

		private static void createClans()
		{
			serpentClan();
			drakeClan();
			ravenClan();
			wolfClan();
		}

		private static void serpentClan()
		{
			ClanObject clanObject = new ClanObject();
			clanObject.clanName = "Serpent";
			clanObject.item = Launch.Serpents;
			clanObject.status = Launch.SerpentStatus;
			clanObject.clanEffects = createEffectListFromObject(Launch.vfxPrefabs.Find((GameObject x) => ((Object)x).name == "sfx_clanSerpent"));
			clanObject.sfx = Launch.vfxPrefabs.Find((GameObject x) => ((Object)x).name == "sfx_clanSerpent");
			clanObject.msg = "Scream of the Serpent!";
			clans.Add(clanObject);
		}

		private static void drakeClan()
		{
			ClanObject clanObject = new ClanObject();
			clanObject.clanName = "Drake";
			clanObject.item = Launch.Drakes;
			clanObject.status = Launch.DrakeStatus;
			clanObject.clanEffects = createEffectListFromObject(Launch.vfxPrefabs.Find((GameObject x) => ((Object)x).name == "sfx_clanDrake"));
			clanObject.sfx = Launch.vfxPrefabs.Find((GameObject x) => ((Object)x).name == "sfx_clanDrake");
			clanObject.msg = "Roar of the Drake!";
			clans.Add(clanObject);
		}

		private static void ravenClan()
		{
			ClanObject clanObject = new ClanObject();
			clanObject.clanName = "Raven";
			clanObject.item = Launch.Ravens;
			clanObject.status = Launch.RavenStatus;
			clanObject.clanEffects = createEffectListFromObject(Launch.vfxPrefabs.Find((GameObject x) => ((Object)x).name == "sfx_clanRaven"));
			clanObject.sfx = Launch.vfxPrefabs.Find((GameObject x) => ((Object)x).name == "sfx_clanRaven");
			clanObject.msg = "Screech of the Raven!";
			clans.Add(clanObject);
		}

		private static void wolfClan()
		{
			ClanObject clanObject = new ClanObject();
			clanObject.clanName = "Wolf";
			clanObject.item = Launch.Wolfs;
			clanObject.status = Launch.WolfStatus;
			clanObject.clanEffects = createEffectListFromObject(Launch.vfxPrefabs.Find((GameObject x) => ((Object)x).name == "sfx_clanWolf"));
			clanObject.sfx = Launch.vfxPrefabs.Find((GameObject x) => ((Object)x).name == "sfx_clanWolf");
			clanObject.msg = "Howl of the wolf!";
			clans.Add(clanObject);
		}

		private static EffectList createEffectListFromObject(GameObject gameObject)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			EffectList val = new EffectList();
			List<EffectData> list = new List<EffectData>();
			EffectData val2 = new EffectData();
			val2.m_prefab = gameObject;
			list.Add(val2);
			val.m_effectPrefabs = list.ToArray();
			return val;
		}
	}
	public class FxReplacment
	{
		private List<GameObject> allPrefabs;

		private string projectName = "BalrondAstafaraios.EotenasClans";

		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;
					}
				}
			}
		}
	}
	[BepInPlugin("BalrondAstafaraios.EotenasClans", "BalrondAstafaraios.EotenasClans", "1.0.5")]
	public class Launch : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(Player), "Load")]
		private class InitClasn
		{
			private static void Postfix()
			{
				if (Object.op_Implicit((Object)(object)Player.m_localPlayer))
				{
					ClanManager.LoadClanStatus();
				}
			}
		}

		[HarmonyPatch(typeof(Player), "OnRespawn")]
		private class InitClanOnRespawn
		{
			private static void Postfix()
			{
				if (Object.op_Implicit((Object)(object)Player.m_localPlayer))
				{
					ClanManager.LoadClanStatus();
				}
			}
		}

		[HarmonyPatch(typeof(AudioMan), "Awake")]
		private static class AudioMan_Awake_Patch
		{
			private static void Postfix(AudioMan __instance)
			{
				GameObject[] array = asset.LoadAllAssets<GameObject>();
				foreach (GameObject val in array)
				{
					AudioSource[] componentsInChildren = val.GetComponentsInChildren<AudioSource>(true);
					foreach (AudioSource val2 in componentsInChildren)
					{
						val2.outputAudioMixerGroup = __instance.m_masterMixer.outputAudioMixerGroup;
					}
				}
			}
		}

		[HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")]
		public static class Object_CopyOtherDB_Path
		{
			public static void Postfix()
			{
				if (IsObjectDBValid())
				{
					List<GameObject> list = new List<GameObject>();
					list.Add(Ravens);
					list.Add(Serpents);
					list.Add(Drakes);
					list.Add(Wolfs);
					list.AddRange(itemList);
					List<StatusEffect> list2 = new List<StatusEffect>();
					list2.Add(RavenStatus);
					list2.Add(SerpentStatus);
					list2.Add(DrakeStatus);
					list2.Add(WolfStatus);
					list2.AddRange(statusList);
					databaseAddMethods.AddItems(list);
					databaseAddMethods.AddStatuseffects(list2);
					recipes = recipeBuilder.setupRecipes(list, ObjectDB.instance.m_items);
					databaseAddMethods.AddRecipes(recipes);
				}
			}
		}

		[HarmonyPatch(typeof(ObjectDB), "Awake")]
		public static class ObjectDB_Awake_Path
		{
			public static void Postfix()
			{
				if (IsObjectDBValid())
				{
					List<GameObject> list = new List<GameObject>();
					list.Add(Ravens);
					list.Add(Serpents);
					list.Add(Drakes);
					list.Add(Wolfs);
					list.AddRange(itemList);
					List<StatusEffect> list2 = new List<StatusEffect>();
					list2.Add(RavenStatus);
					list2.Add(SerpentStatus);
					list2.Add(DrakeStatus);
					list2.Add(WolfStatus);
					list2.AddRange(statusList);
					databaseAddMethods.AddItems(list);
					databaseAddMethods.AddStatuseffects(list2);
					recipes = recipeBuilder.setupRecipes(list, ObjectDB.instance.m_items);
					databaseAddMethods.AddRecipes(recipes);
				}
			}
		}

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

			private static void Prefix(ZNetScene __instance)
			{
				if ((Object)(object)__instance == (Object)null)
				{
					Debug.LogWarning((object)"BalrondAstafaraios.EotenasClans: No ZnetScene found");
					return;
				}
				GameObject val = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "Hammer");
				PieceTable buildPieces = val.GetComponent<ItemDrop>().m_itemData.m_shared.m_buildPieces;
				GameObject val2 = buildPieces.m_pieces.Find((GameObject x) => ((Object)x).name == ((Object)ClanAltar).name);
				if ((Object)(object)val2 == (Object)null && !hasSpawned)
				{
					buildPieces.m_pieces.Add(ClanAltar);
				}
				createTotemRecipe(__instance);
				foreach (GameObject piece in pieceList)
				{
					GameObject val3 = buildPieces.m_pieces.Find((GameObject x) => ((Object)x).name == ((Object)piece).name);
					if ((Object)(object)val3 == (Object)null && !hasSpawned)
					{
						buildPieces.m_pieces.Add(piece);
					}
				}
				hasSpawned = true;
				List<GameObject> list = new List<GameObject>();
				list.Add(Ravens);
				list.Add(Serpents);
				list.Add(Drakes);
				list.Add(Wolfs);
				list.AddRange(itemList);
				__instance.m_prefabs.Add(draconis);
				__instance.m_prefabs.Add(ClanAltar);
				__instance.m_prefabs.AddRange(list);
				recipeBuilder.setupPieces(pieceList, __instance.m_prefabs);
				__instance.m_prefabs.AddRange(pieceList);
			}
		}

		private const string GUID = "BalrondAstafaraios.EotenasClans";

		public const string PluginName = "BalrondAstafaraios.EotenasClans";

		private const string PluginVersion = "1.0.5";

		private static AssetBundle asset;

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

		public static RecipeBuilder recipeBuilder = new RecipeBuilder();

		public static DatabaseAddMethods databaseAddMethods = new DatabaseAddMethods();

		public static ShaderReplacment shaderReplacment = new ShaderReplacment();

		public static GameObject Ravens;

		public static GameObject Serpents;

		public static GameObject Drakes;

		public static GameObject Wolfs;

		public static StatusEffect RavenStatus;

		public static StatusEffect SerpentStatus;

		public static StatusEffect DrakeStatus;

		public static StatusEffect WolfStatus;

		public static List<GameObject> itemList = new List<GameObject>();

		public static string[] prefabNames = new string[62]
		{
			"ShieldClanSerpent", "ShieldClanDrake", "ShieldClanRaven", "ShieldClanWolf", "ArmorSerpentT1Legs", "ArmorSerpentT2Legs", "ArmorSerpentT3Legs", "ArmorSerpentT1Chest", "ArmorSerpentT2Chest", "ArmorSerpentT3Chest",
			"HelmetSerpentT1", "HelmetSerpentT2", "HelmetSerpentT3", "ArmorDrakeT1Legs", "ArmorDrakeT2Legs", "ArmorDrakeT3Legs", "ArmorDrakeT1Chest", "ArmorDrakeT2Chest", "ArmorDrakeT3Chest", "HelmetDrakeT1",
			"HelmetDrakeT2", "HelmetDrakeT3", "ArmorRavenT1Legs", "ArmorRavenT2Legs", "ArmorRavenT3Legs", "ArmorRavenT1Chest", "ArmorRavenT2Chest", "ArmorRavenT3Chest", "HelmetRavenT1", "HelmetRavenT2",
			"HelmetRavenT3", "ArmorWolfT1Legs", "ArmorWolfT2Legs", "ArmorWolfT3Legs", "ArmorWolfT1Chest", "ArmorWolfT2Chest", "ArmorWolfT3Chest", "HelmetWolfT1", "HelmetWolfT2", "HelmetWolfT3",
			"CapeClanDrake", "CapeClanRaven", "CapeClanSerpent", "CapeClanWolf", "ClanDrakeAxe", "ClanSerpentSpear", "ClanRavenStaff", "ClanWolfSword", "ArmorClanDrakeChest", "ArmorClanRavenChest",
			"ArmorClanSerpentChest", "ArmorClanWolfChest", "ArmorClanLegs", "HelmetClanDrake", "HelmetClanRaven", "HelmetClanSerpent", "HelmetClanWolf", "CapeFeatherDrake", "CapeFeatherSerpent", "CapeFeatherReaven",
			"CapeFeatherWolf", "Dragonetta_NPC_Strike"
		};

		public static List<GameObject> pieceList = new List<GameObject>();

		public static string[] pieceNames = new string[8] { "piece_banner_drakes", "piece_banner_serpents", "piece_banner_ravens", "piece_banner_wolfs", "carpetClanDrake", "carpetClanSerpent", "carpetClanRaven", "carpetClanWolf" };

		public static List<StatusEffect> statusList = new List<StatusEffect>();

		public static string[] statusNames = new string[13]
		{
			"DrakeT1", "DrakeT2", "DrakeT3", "RavenT1", "RavenT2", "RavenT3", "SerpentT1", "SerpentT2", "SerpentT3", "WolfT1",
			"WolfT2", "WolfT3", "BaseClanSet"
		};

		public static GameObject ClanAltar;

		public static List<GameObject> vfxPrefabs = new List<GameObject>();

		public static string[] vfxNames = new string[18]
		{
			"sfx_Dragonetta_alerted", "sfx_Dragonetta_death", "sfx_Dragonetta_Hit", "sfx_Dragonetta_hurt", "sfx_Dragonetta_idle", "fx_eikthyr_forwardshockwave_raven", "projectile_tridentharpoon", "sfx_clanDrake", "sfx_clanRaven", "sfx_clanSerpent",
			"sfx_clanWolf", "thunderbolt_projectile_raven", "vfx_clanDrake", "vfx_clanRaven", "vfx_clanSerpent", "vfx_clanWolf", "vfx_thunderbolt_explosion_raven", "Wave_Ground_drake"
		};

		public static GameObject draconis;

		private void Awake()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			asset = GetAssetBundle("balrondclans");
			LoadAssets();
			ClanManager.setup();
			new Harmony("BalrondAstafaraios.EotenasClans").PatchAll();
		}

		private void LoadAssets()
		{
			Ravens = asset.LoadAsset<GameObject>("Assets/Custom/Comission/EotenasClans/SymbolRaven.prefab");
			Serpents = asset.LoadAsset<GameObject>("Assets/Custom/Comission/EotenasClans/SymbolSerpent.prefab");
			Drakes = asset.LoadAsset<GameObject>("Assets/Custom/Comission/EotenasClans/SymbolDrake.prefab");
			Wolfs = asset.LoadAsset<GameObject>("Assets/Custom/Comission/EotenasClans/SymbolWolf.prefab");
			shaderReplacment.ReplaceShadersInObject(Ravens);
			shaderReplacment.ReplaceShadersInObject(Serpents);
			shaderReplacment.ReplaceShadersInObject(Drakes);
			shaderReplacment.ReplaceShadersInObject(Wolfs);
			draconis = asset.LoadAsset<GameObject>("Assets/Custom/Comission/EotenasClans/DragonettaNPC.prefab");
			shaderReplacment.ReplaceShadersInObject(draconis);
			RavenStatus = asset.LoadAsset<StatusEffect>("Assets/Custom/Comission/EotenasClans/StatusClanRaven.asset");
			SerpentStatus = asset.LoadAsset<StatusEffect>("Assets/Custom/Comission/EotenasClans/StatusClanSerpent.asset");
			DrakeStatus = asset.LoadAsset<StatusEffect>("Assets/Custom/Comission/EotenasClans/StatusClanDrake.asset");
			WolfStatus = asset.LoadAsset<StatusEffect>("Assets/Custom/Comission/EotenasClans/StatusClanWolf.asset");
			ClanAltar = asset.LoadAsset<GameObject>("Assets/Custom/Comission/EotenasClans/ClanTotem.prefab");
			ClanAltar.AddComponent<ClanTotem>();
			shaderReplacment.ReplaceShadersInObject(ClanAltar);
			string[] array = vfxNames;
			foreach (string text in array)
			{
				GameObject val = asset.LoadAsset<GameObject>("Assets/Custom/Comission/EotenasClans/vfx/" + text + ".prefab");
				if ((Object)(object)val != (Object)null)
				{
					shaderReplacment.ReplaceShadersInObject(val);
					vfxPrefabs.Add(val);
				}
				else
				{
					Debug.LogWarning((object)("Item not found: " + text));
				}
			}
			string[] array2 = prefabNames;
			foreach (string text2 in array2)
			{
				GameObject val2 = asset.LoadAsset<GameObject>("Assets/Custom/Comission/EotenasClans/items/" + text2 + ".prefab");
				if ((Object)(object)val2 != (Object)null)
				{
					shaderReplacment.ReplaceShadersInObject(val2);
					itemList.Add(val2);
				}
				else
				{
					Debug.LogWarning((object)("Item not found: " + text2));
				}
			}
			string[] array3 = pieceNames;
			foreach (string text3 in array3)
			{
				GameObject val3 = asset.LoadAsset<GameObject>("Assets/Custom/Comission/EotenasClans/pieces/" + text3 + ".prefab");
				if ((Object)(object)val3 != (Object)null)
				{
					shaderReplacment.ReplaceShadersInObject(val3);
					pieceList.Add(val3);
				}
				else
				{
					Debug.LogWarning((object)("Piece not found: " + text3));
				}
			}
			string[] array4 = statusNames;
			foreach (string text4 in array4)
			{
				StatusEffect val4 = asset.LoadAsset<StatusEffect>("Assets/Custom/Comission/EotenasClans/Status/" + text4 + ".asset");
				if ((Object)(object)val4 != (Object)null)
				{
					statusList.Add(val4);
				}
				else
				{
					Debug.LogWarning((object)("Status not found: " + text4));
				}
			}
		}

		private static AssetBundle GetAssetBundle(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 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 Requirement createReq(string name, int amount, int amountPerLevel, ZNetScene zNetScene)
		{
			//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 = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == name).GetComponent<ItemDrop>();
			val.m_resItem = component;
			val.m_amount = amount;
			val.m_amountPerLevel = amountPerLevel;
			return val;
		}

		public static void createTotemRecipe(ZNetScene zNetScene)
		{
			List<Requirement> list = new List<Requirement>();
			list.Add(createReq("SwordCheat", 1, 0, zNetScene));
			ClanAltar.GetComponent<Piece>().m_resources = list.ToArray();
			Debug.Log((object)"i set Req on altar");
		}
	}
	public class RecipeRebalance
	{
		public string name = "";

		public string item = "Wood";

		public int amount = 1;

		public string craftingStation = "";

		public string minStationLevel = "1";

		public bool enabled = true;

		public string repairStation = "";

		public string res1 = "";

		public string res2 = "";

		public string res3 = "";

		public string res4 = "";

		public string res5 = "";

		public string res6 = "";

		public List<Resource> resources = new List<Resource>();

		public bool wasLoaded = false;

		public void convertResToList()
		{
			int num = 0;
			if (resources.Count == 0)
			{
				num += stringArrayToResource(splitString(res1));
				num += stringArrayToResource(splitString(res2));
				num += stringArrayToResource(splitString(res3));
				num += stringArrayToResource(splitString(res4));
				num += stringArrayToResource(splitString(res5));
				num += stringArrayToResource(splitString(res6));
				if (num == 6)
				{
					Debug.LogWarning((object)("DVERGER FURNITURE: No resources found for recipe: " + name));
				}
			}
		}

		private string[] splitString(string res)
		{
			if (res != "")
			{
				return res.Split(new char[1] { ':' });
			}
			return null;
		}

		private int stringArrayToResource(string[] array)
		{
			if (array != null)
			{
				if (array.Length == 4)
				{
					Resource resource = new Resource();
					resource.item = array[0];
					resource.amount = Convert.ToInt32(array[1]);
					resource.amountPerLevel = Convert.ToInt32(array[2]);
					resource.recovery = Convert.ToBoolean(array[3]);
					resources.Add(resource);
					return 0;
				}
				Debug.LogWarning((object)("DVERGER FURNITURE: Incomplete array resource length: " + array.Length));
				return 1;
			}
			return 1;
		}

		public string ObjectToString()
		{
			return "Name:" + name + " Item:" + item + " Amount:" + amount + " Table:" + craftingStation + " Level:" + minStationLevel + " Enabled:" + enabled + " Repair:" + repairStation + " Resources:" + ResourcesToString();
		}

		public string ResourcesToString()
		{
			string text = "";
			foreach (Resource resource in resources)
			{
				text = text + " Name:" + resource.item + " Amount:" + resource.amount + " PerLevel:" + resource.amountPerLevel + " Recover:" + resource.recovery + ",";
			}
			return text;
		}
	}
	public class Resource
	{
		public int amount = 1;

		public int amountPerLevel = 0;

		public bool recovery = true;

		public ItemDrop itemDrop;

		public Requirement pieceConfig;

		public string item = "Wood";

		public Resource()
		{
		}

		public Resource(string item, int amount, int amountPerLevel = 0, bool recovery = true)
		{
			this.item = item;
			this.amount = amount;
			this.amountPerLevel = amountPerLevel;
			this.recovery = recovery;
		}

		public void setItemDrop(GameObject prefab)
		{
			if ((Object)(object)prefab.GetComponent<ItemDrop>() != (Object)null)
			{
				itemDrop = prefab.GetComponent<ItemDrop>();
			}
			else
			{
				Debug.LogWarning((object)("DVERGER FURNITURE: NO ITEM DROP FOUND on prefab name: " + ((Object)prefab).name));
			}
		}

		public Requirement getPieceConfig()
		{
			//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_0013: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_003e: Expected O, but got Unknown
			Requirement val = new Requirement
			{
				m_resItem = itemDrop,
				m_amount = amount,
				m_amountPerLevel = amountPerLevel,
				m_recover = recovery
			};
			Requirement result = val;
			pieceConfig = val;
			return result;
		}
	}
	public class RecipeBuilder
	{
		private List<GameObject> pieces;

		private List<GameObject> items;

		public List<Recipe> setupRecipes(List<GameObject> items, List<GameObject> objectDbItems)
		{
			this.items = objectDbItems;
			pieces = this.items.Find((GameObject x) => ((Object)x).name == "Hammer").GetComponent<ItemDrop>().m_itemData.m_shared.m_buildPieces.m_pieces;
			List<Recipe> list = new List<Recipe>();
			foreach (GameObject item in items)
			{
				if (!(((Object)item).name == "Dragonetta_NPC_Strike"))
				{
					Recipe val = createItemRecipe(item, objectDbItems);
					if ((Object)(object)val != (Object)null)
					{
						list.Add(val);
					}
				}
			}
			return list;
		}

		private Recipe createItemRecipe(GameObject item, List<GameObject> objectDbItems)
		{
			if (!isItemOnTheList(((Object)item).name))
			{
				return null;
			}
			Recipe val = ScriptableObject.CreateInstance<Recipe>();
			List<Requirement> list = new List<Requirement>();
			((Object)val).name = "Recipe_ClanItem_" + ((Object)item).name;
			val.m_item = item.GetComponent<ItemDrop>();
			switch (((Object)item).name)
			{
			case "ShieldClanSerpent":
				val.m_craftingStation = FindStation(pieces, "forge");
				val.m_minStationLevel = 3;
				list.Add(createReq("SymbolSerpent", 1, 1));
				list.Add(createReq("FineWood", 15, 8));
				list.Add(createReq("Iron", 15, 10));
				list.Add(createReq("TrollHide", 5, 2));
				break;
			case "ShieldClanDrake":
				val.m_craftingStation = FindStation(pieces, "forge");
				val.m_minStationLevel = 3;
				list.Add(createReq("SymbolDrake", 1, 1));
				list.Add(createReq("FineWood", 15, 8));
				list.Add(createReq("Iron", 15, 10));
				list.Add(createReq("TrollHide", 5, 2));
				break;
			case "ShieldClanRaven":
				val.m_craftingStation = FindStation(pieces, "forge");
				val.m_minStationLevel = 3;
				list.Add(createReq("SymbolRaven", 1, 1));
				list.Add(createReq("FineWood", 15, 8));
				list.Add(createReq("Iron", 15, 10));
				list.Add(createReq("TrollHide", 5, 2));
				break;
			case "ShieldClanWolf":
				val.m_craftingStation = FindStation(pieces, "forge");
				val.m_minStationLevel = 3;
				list.Add(createReq("SymbolWolf", 1, 1));
				list.Add(createReq("FineWood", 15, 8));
				list.Add(createReq("Iron", 15, 10));
				list.Add(createReq("TrollHide", 5, 2));
				break;
			case "ArmorSerpentT1Legs":
				val.m_craftingStation = FindStation(pieces, "forge");
				val.m_minStationLevel = 3;
				list.Add(createReq("SymbolSerpent", 1, 1));
				list.Add(createReq("BearFur", 5, 2));
				list.Add(createReq("BlackMetal", 20, 10));
				list.Add(createReq("Root", 20, 10));
				break;
			case "ArmorSerpentT2Legs":
				val.m_craftingStation = FindStation(pieces, "piece_workbench");
				val.m_minStationLevel = 3;
				list.Add(createReq("SymbolSerpent", 2, 2));
				list.Add(createReq("ArmorSerpentT1Legs", 1, 0));
				list.Add(createReq("ScaleHide", 20, 10));
				list.Add(createReq("SerpentScale", 20, 10));
				break;
			case "ArmorSerpentT3Legs":
				val.m_craftingStation = FindStation(pieces, "blackforge");
				val.m_minStationLevel = 1;
				list.Add(createReq("SymbolSerpent", 3, 3));
				list.Add(createReq("ArmorSerpentT2Legs", 1, 0));
				list.Add(createReq("DragonScale", 10, 5));
				list.Add(createReq("StormScale", 10, 5));
				break;
			case "ArmorSerpentT1Chest":
				val.m_craftingStation = FindStation(pieces, "forge");
				val.m_minStationLevel = 3;
				list.Add(createReq("SymbolSerpent", 1, 1));
				list.Add(createReq("Chitin", 15, 7));
				list.Add(createReq("BlackMetal", 15, 7));
				list.Add(createReq("SerpentScale", 10, 5));
				break;
			case "ArmorSerpentT2Chest":
				val.m_craftingStation = FindStation(pieces, "piece_workbench");
				val.m_minStationLevel = 3;
				list.Add(createReq("SymbolSerpent", 2, 2));
				list.Add(createReq("ArmorSerpentT1Chest", 1, 0));
				list.Add(createReq("SerpentScale", 10, 5));
				list.Add(createReq("Mandible", 5, 3));
				break;
			case "ArmorSerpentT3Chest":
				val.m_craftingStation = FindStation(pieces, "blackforge");
				val.m_minStationLevel = 1;
				list.Add(createReq("SymbolSerpent", 3, 3));
				list.Add(createReq("ArmorSerpentT2Chest", 1, 0));
				list.Add(createReq("Carapace", 10, 5));
				list.Add(createReq("DragonScale", 10, 5));
				break;
			case "HelmetSerpentT1":
				val.m_craftingStation = FindStation(pieces, "forge");
				val.m_minStationLevel = 3;
				list.Add(createReq("SymbolSerpent", 1, 1));
				list.Add(createReq("TrophySerpent", 1, 0));
				list.Add(createReq("BlackMetal", 10, 7));
				list.Add(createReq("Chitin", 15, 10));
				break;
			case "HelmetSerpentT2":
				val.m_craftingStation = FindStation(pieces, "piece_workbench");
				val.m_minStationLevel = 3;
				list.Add(createReq("SymbolSerpent", 2, 2));
				list.Add(createReq("HelmetSerpentT1", 1, 0));
				list.Add(createReq("SerpentScale", 1, 1));
				list.Add(createReq("RedKelp", 20, 10));
				break;
			case "HelmetSerpentT3":
				val.m_craftingStation = FindStation(pieces, "blackforge");
				val.m_minStationLevel = 1;
				list.Add(createReq("SymbolSerpent", 3, 3));
				list.Add(createReq("HelmetSerpentT2", 1, 0));
				list.Add(createReq("TrophySerpent", 4, 2));
				list.Add(createReq("SilkReinforcedThread", 6, 3));
				break;
			case "ArmorDrakeT1Legs":
				val.m_craftingStation = FindStation(pieces, "forge");
				val.m_minStationLevel = 3;
				list.Add(createReq("SymbolDrake", 1, 1));
				list.Add(createReq("BlackMetal", 10, 5));
				list.Add(createReq("FreezeGland", 6, 2));
				list.Add(createReq("DrakeSkin", 10, 5, "WolfPelt", 10, 5));
				break;
			case "ArmorDrakeT2Legs":
				val.m_craftingStation = FindStation(pieces, "piece_workbench");
				val.m_minStationLevel = 3;
				list.Add(createReq("SymbolDrake", 2, 2));
				list.Add(createReq("ArmorDrakeT1Legs", 1, 0));
				list.Add(createReq("ScaleHide", 8, 4));
				list.Add(createReq("DrakeSkin", 10, 5, "WolfPelt", 10, 5));
				break;
			case "ArmorDrakeT3Legs":
				val.m_craftingStation = FindStation(pieces, "blackforge");
				val.m_minStationLevel = 1;
				list.Add(createReq("SymbolDrake", 3, 3));
				list.Add(createReq("ArmorDrakeT3Legs", 1, 0));
				list.Add(createReq("Flametal", 10, 5));
				list.Add(createReq("DragonScale", 10, 5));
				break;
			case "ArmorDrakeT1Chest":
				val.m_craftingStation = FindStation(pieces, "forge");
				val.m_minStationLevel = 3;
				list.Add(createReq("SymbolDrake", 1, 1));
				list.Add(createReq("BlackMetal", 10, 5));
				list.Add(createReq("Chain", 4, 1));
				list.Add(createReq("DrakeSkin", 10, 5, "WolfPelt", 10, 5));
				break;
			case "ArmorDrakeT2Chest":
				val.m_craftingStation = FindStation(pieces, "piece_workbench");
				val.m_minStationLevel = 3;
				list.Add(createReq("SymbolDrake", 2, 2));
				list.Add(createReq("ArmorDrakeT1Chest", 1, 0));
				list.Add(createReq("Carapace", 8, 4));
				list.Add(createReq("Crystal", 10, 5));
				break;
			case "ArmorDrakeT3Chest":
				val.m_craftingStation = FindStation(pieces, "blackforge");
				val.m_minStationLevel = 1;
				list.Add(createReq("SymbolDrake", 3, 3));
				list.Add(createReq("ArmorDrakeT2Chest", 1, 0));
				list.Add(createReq("Cobalt", 10, 5));
				list.Add(createReq("DragonScale", 10, 5));
				break;
			case "HelmetDrakeT1":
				val.m_craftingStation = FindStation(pieces, "forge");
				val.m_minStationLevel = 3;
				list.Add(createReq("SymbolDrake", 1, 1));
				list.Add(createReq("TrophyHatchling", 4, 0));
				list.Add(createReq("BlackMetal", 10, 5));
				list.Add(createReq("Crystal", 10, 5));
				break;
			case "HelmetDrakeT2":
				val.m_craftingStation = FindStation(pieces, "piece_workbench");
				val.m_minStationLevel = 3;
				list.Add(createReq("SymbolDrake", 2, 2));
				list.Add(createReq("HelmetDrakeT1", 1, 0));
				list.Add(createReq("DarkSteel", 8, 4));
				list.Add(createReq("StormScale", 6, 3));
				break;
			case "HelmetDrakeT3":
				val.m_craftingStation = FindStation(pieces, "blackforge");
				val.m_minStationLevel = 1;
				list.Add(createReq("SymbolDrake", 3, 3));
				list.Add(createReq("HelmetDrakeT2", 1, 0));
				list.Add(createReq("TrophyStormdrake", 1, 1));
				list.Add(createReq("Cobalt", 10, 5));
				break;
			case "ArmorRavenT1Legs":
				val.m_craftingStation = FindStation(pieces, "forge");
				val.m_minStationLevel = 3;
				list.Add(createReq("SymbolRaven", 1, 1));
				list.Add(createReq("BearFur", 6, 2));
				list.Add(createReq("BlackMetal", 10, 5));
				list.Add(createReq("CorruptedEitr", 20, 10));
				break;
			case "ArmorRavenT2Legs":
				val.m_craftingStation = FindStation(pieces, "piece_workbench");
				val.m_minStationLevel = 3;
				list.Add(createReq("SymbolRaven", 2, 2));
				list.Add(createReq("ArmorRavenT1Legs", 1, 0));
				list.Add(createReq("JuteRed", 10, 5));
				list.Add(createReq("Eitr", 20, 10));
				break;
			case "ArmorRavenT3Legs":
				val.m_craftingStation = FindStation(pieces, "blackforge");
				val.m_minStationLevel = 1;
				list.Add(createReq("SymbolRaven", 3, 3));
				list.Add(createReq("ArmorRavenT2Legs", 1, 0));
				list.Add(createReq("Ignicap", 10, 5));
				list.Add(createReq("Cobalt", 10, 5));
				break;
			case "ArmorRavenT1Chest":
				val.m_craftingStation = FindStation(pieces, "forge");
				val.m_minStationLevel = 3;
				list.Add(createReq("SymbolRaven", 1, 1));
				list.Add(createReq("WolfHairBundle", 10, 5, "Feathers", 60));
				list.Add(createReq("BlackMetal", 10, 5));
				list.Add(createReq("CorruptedEitr", 20, 10));
				break;
			case "ArmorRavenT2Chest":
				val.m_craftingStation = FindStation(pieces, "piece_workbench");
				val.m_minStationLevel = 3;
				list.Add(createReq("SymbolRaven", 2, 2));
				list.Add(createReq("ArmorRavenT1Chest", 1, 0));
				list.Add(createReq("BoraxCrystal", 20, 10));
				list.Add(createReq("Eitr", 20, 10));
				break;
			case "ArmorRavenT3Chest":
				val.m_craftingStation = FindStation(pieces, "blackforge");
				val.m_minStationLevel = 1;
				list.Add(createReq("SymbolRaven", 3, 3));
				list.Add(createReq("ArmorRavenT2Chest", 1, 0));
				list.Add(createReq("SilkReinforcedThread", 20, 10));
				list.Add(createReq("Flametal", 10, 5));
				break;
			case "HelmetRavenT1":
				val.m_craftingStation = FindStation(pieces, "forge");
				val.m_minStationLevel = 3;
				list.Add(createReq("SymbolRaven", 1, 1));
				list.Add(createReq("Feathers", 60, 10, "Feathers", 60));
				list.Add(createReq("BlackMetal", 10, 5));
				list.Add(createReq("Ooze", 10, 5));
				break;
			case "HelmetRavenT2":
				val.m_craftingStation = FindStation(pieces, "piece_workbench");
				val.m_minStationLevel = 3;
				list.Add(createReq("SymbolRaven", 2, 2));
				list.Add(createReq("HelmetRavenT1", 1, 0));
				list.Add(createReq("JuteRed", 10, 5));
				list.Add(createReq("MushroomJotunPuffs", 10, 5));
				break;
			case "HelmetRavenT3":
				val.m_craftingStation = FindStation(pieces, "blackforge");
				val.m_minStationLevel = 1;
				list.Add(createReq("SymbolRaven", 3, 3));
				list.Add(createReq("HelmetRavenT2", 1, 0));
				list.Add(createReq("SilkReinforcedThread", 10, 5));
				list.Add(createReq("Ignicap", 16, 8));
				break;
			case "ArmorWolfT1Legs":
				val.m_craftingStation = FindStation(pieces, "forge");
				val.m_minStationLevel = 3;
				list.Add(createReq("SymbolWolf", 1, 1));
				list.Add(createReq("WolfPelt", 10, 5));
				list.Add(createReq("BlackMetal", 20, 10));
				list.Add(createReq("Bloodbag", 20, 0));
				break;
			case "ArmorWolfT2Legs":
				val.m_craftingStation = FindStation(pieces, "piece_workbench");
				val.m_minStationLevel = 3;
				list.Add(createReq("SymbolWolf", 2, 2));
				list.Add(createReq("ArmorWolfT1Legs", 1, 0));
				list.Add(createReq("DarkSteel", 18, 9));
				list.Add(createReq("GiantBloodSack", 16, 8));
				break;
			case "ArmorWolfT3Legs":
				val.m_craftingStation = FindStation(pieces, "blackforge");
				val.m_minStationLevel = 1;
				list.Add(createReq("SymbolWolf", 3, 3));
				list.Add(createReq("ArmorWolfT2Legs", 1, 0));
				list.Add(createReq("Bloodymarry", 30, 15));
				list.Add(createReq("Bloodsteel", 20, 10));
				break;
			case "ArmorWolfT1Chest":
				val.m_craftingStation = FindStation(pieces, "forge");
				val.m_minStationLevel = 3;
				list.Add(createReq("SymbolWolf", 1, 1));
				list.Add(createReq("TrophyWolf", 6, 3));
				list.Add(createReq("BlackMetal", 15, 8));
				list.Add(createReq("JuteRed", 10, 5));
				break;
			case "ArmorWolfT2Chest":
				val.m_craftingStation = FindStation(pieces, "piece_workbench");
				val.m_minStationLevel = 3;
				list.Add(createReq("SymbolWolf", 2, 2));
				list.Add(createReq("ArmorWolfT1Chest", 1, 0));
				list.Add(createReq("DarkSteel", 30, 15));
				list.Add(createReq("GiantBloodSack", 16, 8));
				break;
			case "ArmorWolfT3Chest":
				val.m_craftingStation = FindStation(pieces, "blackforge");
				val.m_minStationLevel = 1;
				list.Add(createReq("SymbolWolf", 3, 3));
				list.Add(createReq("ArmorWolfT2Chest", 1, 0));
				list.Add(createReq("FenringInsygnia", 10, 5, "Chain", 6, 3));
				list.Add(createReq("Bloodsteel", 10, 5));
				break;
			case "HelmetWolfT1":
				val.m_craftingStation = FindStation(pieces, "forge");
				val.m_minStationLevel = 3;
				list.Add(createReq("SymbolWolf", 1, 1));
				list.Add(createReq("TrophyCultist", 1, 0));
				list.Add(createReq("WolfHairBundle", 10, 5));
				list.Add(createReq("JuteRed", 10, 5));
				break;
			case "HelmetWolfT2":
				val.m_craftingStation = FindStation(pieces, "piece_workbench");
				val.m_minStationLevel = 3;
				list.Add(createReq("SymbolWolf", 2, 2));
				list.Add(createReq("HelmetWolfT1", 1, 0));
				list.Add(createReq("DarkSteel", 20, 10));
				list.Add(createReq("GiantBloodSack", 10, 5));
				break;
			case "HelmetWolfT3":
				val.m_craftingStation = FindStation(pieces, "blackforge");
				val.m_minStationLevel = 1;
				list.Add(createReq("SymbolWolf", 3, 3));
				list.Add(createReq("HelmetWolfT2", 1, 0));
				list.Add(createReq("ForsakenHeart", 10, 5));
				list.Add(createReq("Bloodsteel", 10, 5));
				break;
			case "CapeClanDrake":
				val.m_craftingStation = FindStation(pieces, "piece_workbench");
				val.m_minStationLevel = 3;
				list.Add(createReq("SymbolDrake", 1, 0));
				list.Add(createReq("TrophyDraugrElite", 1, 1));
				list.Add(createReq("DarkSteel", 3, 1, "Chain", 3));
				list.Add(createReq("WolfPelt", 6, 2));
				break;
			case "CapeClanRaven":
				val.m_craftingStation = FindStation(pieces, "piece_workbench");
				val.m_minStationLevel = 3;
				list.Add(createReq("SymbolRaven", 1, 0));
				list.Add(createReq("TrophyDraugrElite", 1, 1));
				list.Add(createReq("DarkSteel", 3, 1, "Chain", 3));
				list.Add(createReq("WolfPelt", 6, 2));
				break;
			case "CapeClanSerpent":
				val.m_craftingStation = FindStation(pieces, "piece_workbench");
				val.m_minStationLevel = 3;
				list.Add(createReq("SymbolSerpent", 1, 1));
				list.Add(createReq("TrophyDraugrElite", 1, 1));
				list.Add(createReq("DarkSteel", 3, 1, "Chain", 3));
				list.Add(createReq("WolfPelt", 6, 2));
				break;
			case "CapeClanWolf":
				val.m_craftingStation = FindStation(pieces, "piece_workbench");
				val.m_minStationLevel = 3;
				list.Add(createReq("SymbolWolf", 1, 1));
				list.Add(createReq("TrophyDraugrElite", 1, 1));
				list.Add(createReq("DarkSteel", 3, 1, "Chain", 3));
				list.Add(createReq("WolfPelt", 6, 2));
				break;
			case "ClanDrakeAxe":
				val.m_craftingStation = FindStation(pieces, "blackforge");
				val.m_minStationLevel = 1;
				list.Add(createReq("SymbolDrake", 2, 2));
				list.Add(createReq("Cobalt", 30, 10));
				list.Add(createReq("Sapphire", 6, 1));
				list.Add(createReq("Crystal", 20, 10));
				break;
			case "ClanSerpentSpear":
				val.m_craftingStation = FindStation(pieces, "blackforge");
				val.m_minStationLevel = 1;
				list.Add(createReq("SymbolSerpent", 2, 2));
				list.Add(createReq("Cobalt", 20, 7));
				list.Add(createReq("Emerald", 5, 1));
				list.Add(createReq("SerpentScale", 10, 5));
				break;
			case "ClanRavenStaff":
				val.m_craftingStation = FindStation(pieces, "blackforge");
				val.m_minStationLevel = 1;
				list.Add(createReq("SymbolRaven", 2, 2));
				list.Add(createReq("Cobalt", 30, 15));
				list.Add(createReq("Opal", 7, 1));
				list.Add(createReq("ThunderGland", 18, 9, "Thunderstone", 10, 5));
				break;
			case "ClanWolfSword":
				val.m_craftingStation = FindStation(pieces, "blackforge");
				val.m_minStationLevel = 1;
				list.Add(createReq("SymbolWolf", 2, 2));
				list.Add(createReq("Cobalt", 30, 15));
				list.Add(createReq("Ruby", 8, 2));
				list.Add(createReq("Bloodsteel", 10, 5));
				break;
			case "ArmorClanDrakeChest":
				val.m_craftingStation = FindStation(pieces, "piece_workbench");
				val.m_minStationLevel = 1;
				list.Add(createReq("SymbolDrake", 1, 0));
				list.Add(createReq("Bronze", 20, 10));
				list.Add(createReq("TrollHide", 10, 2));
				list.Add(createReq("LeatherScraps", 10, 5));
				break;
			case "ArmorClanRavenChest":
				val.m_craftingStation = FindStation(pieces, "piece_workbench");
				val.m_minStationLevel = 1;
				list.Add(createReq("SymbolRaven", 1, 0));
				list.Add(createReq("Bronze", 20, 10));
				list.Add(createReq("TrollHide", 10, 2));
				list.Add(createReq("LeatherScraps", 10, 5));
				break;
			case "ArmorClanSerpentChest":
				val.m_craftingStation = FindStation(pieces, "piece_workbench");
				val.m_minStationLevel = 1;
				list.Add(createReq("SymbolSerpent", 1, 0));
				list.Add(createReq("Bronze", 20, 10));
				list.Add(createReq("TrollHide", 10, 2));
				list.Add(createReq("LeatherScraps", 10, 5));
				break;
			case "ArmorClanWolfChest":
				val.m_craftingStation = FindStation(pieces, "piece_workbench");
				val.m_minStationLevel = 1;
				list.Add(createReq("SymbolWolf", 1, 0));
				list.Add(createReq("Bronze", 20, 10));
				list.Add(createReq("TrollHide", 10, 2));
				list.Add(createReq("LeatherScraps", 10, 5));
				break;
			case "ArmorClanLegs":
				val.m_craftingStation = FindStation(pieces, "piece_workbench");
				val.m_minStationLevel = 1;
				list.Add(createReq("SymbolWolf", 1, 0));
				list.Add(createReq("Bronze", 10, 5));
				list.Add(createReq("LeatherScraps", 10, 5));
				list.Add(createReq("BearFur", 10, 2));
				break;
			case "HelmetClanDrake":
				val.m_craftingStation = FindStation(pieces, "piece_workbench");
				val.m_minStationLevel = 1;
				list.Add(createReq("SymbolDrake", 1, 0));
				list.Add(createReq("TrollHide", 10, 2));
				list.Add(createReq("BearFur", 10, 2));
				list.Add(createReq("LeatherScraps", 10, 5));
				break;
			case "HelmetClanSerpent":
				val.m_craftingStation = FindStation(pieces, "piece_workbench");
				val.m_minStationLevel = 1;
				list.Add(createReq("SymbolSerpent", 1, 0));
				list.Add(createReq("TrollHide", 10, 2));
				list.Add(createReq("BearFur", 10, 2));
				list.Add(createReq("LeatherScraps", 10, 5));
				break;
			case "HelmetClanRaven":
				val.m_craftingStation = FindStation(pieces, "piece_workbench");
				val.m_minStationLevel = 1;
				list.Add(createReq("SymbolRaven", 1, 0));
				list.Add(createReq("TrollHide", 10, 2));
				list.Add(createReq("BearFur", 10, 2));
				list.Add(createReq("LeatherScraps", 10, 5));
				break;
			case "HelmetClanWolf":
				val.m_craftingStation = FindStation(pieces, "piece_workbench");
				val.m_minStationLevel = 1;
				list.Add(createReq("SymbolWolf", 1, 0));
				list.Add(createReq("TrollHide", 10, 2));
				list.Add(createReq("BearFur", 10, 2));
				list.Add(createReq("LeatherScraps", 10, 5));
				break;
			case "CapeFeatherDrake":
				val.m_craftingStation = FindStation(pieces, "blackforge");
				val.m_minStationLevel = 1;
				list.Add(createReq("SymbolDrake", 1, 0));
				list.Add(createReq("Feathers", 10, 0));
				list.Add(createReq("ScaleHide", 5, 2));
				list.Add(createReq("Eitr", 20, 0));
				break;
			case "CapeFeatherSerpent":
				val.m_craftingStation = FindStation(pieces, "blackforge");
				val.m_minStationLevel = 1;
				list.Add(createReq("SymbolSerpent", 1, 0));
				list.Add(createReq("Feathers", 10, 0));
				list.Add(createReq("ScaleHide", 5, 2));
				list.Add(createReq("Eitr", 20, 0));
				break;
			case "CapeFeatherReaven":
				val.m_craftingStation = FindStation(pieces, "blackforge");
				val.m_minStationLevel = 1;
				list.Add(createReq("SymbolRaven", 1, 0));
				list.Add(createReq("Feathers", 10, 0));
				list.Add(createReq("ScaleHide", 5, 2));
				list.Add(createReq("Eitr", 20, 0));
				break;
			case "CapeFeatherWolf":
				val.m_craftingStation = FindStation(pieces, "blackforge");
				val.m_minStationLevel = 1;
				list.Add(createReq("SymbolWolf", 1, 0));
				list.Add(createReq("Feathers", 10, 0));
				list.Add(createReq("ScaleHide", 5, 2));
				list.Add(createReq("Eitr", 20, 0));
				break;
			}
			val.m_amount = 1;
			val.m_repairStation = val.m_craftingStation;
			val.m_resources = list.ToArray();
			return val;
		}

		private bool isItemOnTheList(string name)
		{
			return Launch.prefabNames.Contains(name);
		}

		public void setupPieces(List<GameObject> pieces, List<GameObject> prefabs)
		{
			items = prefabs;
			foreach (GameObject piece in pieces)
			{
				createPieceRecipe(piece, prefabs);
			}
		}

		private void createPieceRecipe(GameObject gameObject, List<GameObject> prefabs)
		{
			Piece component = gameObject.gameObject.GetComponent<Piece>();
			if (!((Object)(object)component == (Object)null))
			{
				List<Requirement> list = new List<Requirement>();
				switch (((Object)component).name)
				{
				case "piece_banner_drakes":
					component.m_craftingStation = FindStation(prefabs, "piece_workbench");
					list.Add(createReq("SymbolDrake", 1, 0));
					list.Add(createReq("Wood", 3, 0));
					list.Add(createReq("LeatherScraps", 2, 0));
					list.Add(createReq("BoneFragments", 3, 0));
					component.m_resources = list.ToArray();
					break;
				case "piece_banner_serpents":
					component.m_craftingStation = FindStation(prefabs, "piece_workbench");
					list.Add(createReq("SymbolSerpent", 1, 0));
					list.Add(createReq("Wood", 3, 0));
					list.Add(createReq("LeatherScraps", 2, 0));
					list.Add(createReq("BoneFragments", 3, 0));
					component.m_resources = list.ToArray();
					break;
				case "piece_banner_ravens":
					component.m_craftingStation = FindStation(prefabs, "piece_workbench");
					list.Add(createReq("SymbolRaven", 1, 0));
					list.Add(createReq("Wood", 3, 0));
					list.Add(createReq("LeatherScraps", 2, 0));
					list.Add(createReq("BoneFragments", 3, 0));
					component.m_resources = list.ToArray();
					break;
				case "piece_banner_wolfs":
					component.m_craftingStation = FindStation(prefabs, "piece_workbench");
					list.Add(createReq("SymbolWolf", 1, 0));
					list.Add(createReq("Wood", 3, 0));
					list.Add(createReq("LeatherScraps", 2, 0));
					list.Add(createReq("BoneFragments", 3, 0));
					component.m_resources = list.ToArray();
					break;
				case "carpetClanDrake":
					component.m_craftingStation = FindStation(prefabs, "piece_workbench");
					list.Add(createReq("SymbolDrake", 1, 0));
					list.Add(createReq("LinenThread", 5, 0));
					list.Add(createReq("DyeKit", 1, 0));
					break;
				case "carpetClanSerpent":
					component.m_craftingStation = FindStation(prefabs, "piece_workbench");
					list.Add(createReq("SymbolSerpent", 1, 0));
					list.Add(createReq("LinenThread", 5, 0));
					list.Add(createReq("DyeKit", 1, 0));
					component.m_resources = list.ToArray();
					break;
				case "carpetClanRaven":
					component.m_craftingStation = FindStation(prefabs, "piece_workbench");
					list.Add(createReq("SymbolRaven", 1, 0));
					list.Add(createReq("LinenThread", 5, 0));
					list.Add(createReq("DyeKit", 1, 0));
					component.m_resources = list.ToArray();
					break;
				case "carpetClanWolf":
					component.m_craftingStation = FindStation(prefabs, "piece_workbench");
					list.Add(createReq("SymbolWolf", 1, 0));
					list.Add(createReq("LinenThread", 5, 0));
					list.Add(createReq("DyeKit", 1, 0));
					component.m_resources = list.ToArray();
					break;
				}
			}
		}

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

		private Requirement createReq(string name, int amount, int amountPerLevel, string altItem = "", int altAmount = 0, int altAmountPerLevel = 0)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			Requirement val = new Requirement();
			val.m_recover = true;
			GameObject val2 = items.Find((GameObject x) => ((Object)x).name == name);
			if ((Object)(object)val2 != (Object)null)
			{
				ItemDrop component = val2.GetComponent<ItemDrop>();
				val.m_amount = amount;
				val.m_amountPerLevel = amountPerLevel;
				val.m_resItem = component;
			}
			else
			{
				val2 = items.Find((GameObject x) => ((Object)x).name == altItem);
				ItemDrop component2 = val2.GetComponent<ItemDrop>();
				val.m_amount = altAmount;
				val.m_amountPerLevel = altAmountPerLevel;
				val.m_resItem = component2;
			}
			return val;
		}
	}
	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)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			if (new ZNet().IsDedicated() || (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)
				{
					Debug.Log((object)("There was no shader on material: " + ((Object)val).name));
					continue;
				}
				string name = ((Object)shader).name;
				if (name.Contains("Custom/Standard2Face"))
				{
					Debug.LogWarning((object)("Broken Material: " + ((Object)val).name));
				}
				if (name.Contains("CustomDiffuseDoubleSide"))
				{
					Debug.LogWarning((object)("Broken Material: " + ((Object)val).name));
				}
				if (!(name == "Standard") && !name.Contains("ScrollingTex") && 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;
		}
	}
}
namespace EotenasClans.Properties
{
	[GeneratedCode("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.4.0.0")]
	[CompilerGenerated]
	internal sealed class Settings : ApplicationSettingsBase
	{
		private static Settings defaultInstance = (Settings)(object)SettingsBase.Synchronized((SettingsBase)(object)new Settings());

		public static Settings Default => defaultInstance;
	}
}

plugins/BalrondBiomes/BalrondBiomes.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 System.Text;
using BalrondBiomes.WorldEdit;
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("Balrond Biomes")]
[assembly: AssemblyDescription("Valheim Game Rework")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Balrond - Worm Works Studio")]
[assembly: AssemblyProduct("Balrond")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("Balrond")]
[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]
public class Barter : MonoBehaviour, Hoverable, Interactable
{
	public string m_name = "Merchant";

	public string m_useItemText = "Trade";

	public bool m_spawnItem = true;

	public bool m_canTrade = true;

	public ItemDrop m_requiredItem;

	public int m_requiredItemAmount = 1;

	public int m_traderAmount = 10;

	public int m_traderAmountMax = 10;

	public int m_traderAmountCooldown = 10;

	public int m_traderAmountTimer = 0;

	public ItemDrop m_itemPrefab;

	public int m_itemPrefabAmount = 1;

	public Transform m_itemSpawnPoint;

	public string m_setGlobalKey = "";

	public float m_SpawnDelay = 1f;

	public float m_spawnOffset = 0f;

	[Header("Effects")]
	public EffectList m_fuelAddedEffects = new EffectList();

	public EffectList m_spawnStartEffects = new EffectList();

	public EffectList m_spawnFinishEffects = new EffectList();

	public GameObject m_enabledObject;

	public GameObject m_disabledObject;

	public GameObject m_haveFuelObject;

	private MonsterAI monsterAI;

	private Character character;

	private ZNetView m_nview;

	private string m_requiredItemName;

	private string preparedText;

	private NpcTalk npcTalk;

	private Animator m_animator;

	private LookAt m_lookAt;

	private void Start()
	{
		m_animator = ((Component)this).GetComponentInChildren<Animator>();
		m_lookAt = ((Component)this).GetComponentInChildren<LookAt>();
	}

	private void Awake()
	{
		m_nview = ((Component)this).GetComponent<ZNetView>();
		if ((Object)(object)m_nview == (Object)null || m_nview.GetZDO() == null)
		{
			ZLog.Log((object)"Missing ZnetView Component");
			return;
		}
		character = ((Component)this).GetComponent<Character>();
		monsterAI = ((Component)this).GetComponent<MonsterAI>();
		m_requiredItemName = m_requiredItem.m_itemData.m_shared.m_name;
		preparedText = m_requiredItemAmount + " " + Localization.instance.Localize(((Component)m_requiredItem).GetComponent<ItemDrop>().m_itemData.m_shared.m_name) + " for " + m_itemPrefabAmount + " " + Localization.instance.Localize(((Component)m_itemPrefab).GetComponent<ItemDrop>().m_itemData.m_shared.m_name);
		Debug.LogWarning((object)("Testing text: " + preparedText));
		npcTalk = ((Component)this).GetComponent<NpcTalk>();
		if ((Object)(object)npcTalk != (Object)null)
		{
			npcTalk.m_greetRange = 3f;
			npcTalk.m_byeRange = 5f;
			npcTalk.m_maxRange = 5f;
			npcTalk.m_name = m_name;
			((MonoBehaviour)this).InvokeRepeating("UpdateOfferingStation", 1f, 1f);
			npcTalk.m_randomTalk.Add("Always so busy");
			npcTalk.m_randomGoodbye.Add("Farewell Warrior");
			npcTalk.m_randomGreets.Add("Hello I be happy to trade " + preparedText);
		}
	}

	private void DiscoverItems(Player player)
	{
		player.AddKnownItem(m_requiredItem.m_itemData);
	}

	private void Update()
	{
		//IL_0007: 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_0040: 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)
		Player closestPlayer = Player.GetClosestPlayer(((Component)this).transform.position, npcTalk.m_greetRange);
		if (Object.op_Implicit((Object)(object)closestPlayer))
		{
			m_lookAt.SetLoockAtTarget(((Character)closestPlayer).GetHeadPoint());
			float num = Vector3.Distance(((Component)closestPlayer).transform.position, ((Component)this).transform.position);
		}
		else
		{
			m_lookAt.ResetTarget();
		}
	}

	public string GetHoverText()
	{
		if (!IsActive())
		{
			return m_name + " Has Nothing to Trade";
		}
		return Localization.instance.Localize("\n [<color=yellow><b>1-8</b></color>] \n") + preparedText;
	}

	public string GetHoverName()
	{
		return Localization.instance.Localize(m_name);
	}

	public bool Interact(Humanoid user, bool hold, bool alt)
	{
		if (hold)
		{
			return false;
		}
		if (!IsActive())
		{
			return false;
		}
		return true;
	}

	public bool UseItem(Humanoid user, ItemData item)
	{
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0189: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		if (!IsActive())
		{
			return false;
		}
		if ((Object)(object)m_requiredItem == (Object)null)
		{
			return false;
		}
		if (item.m_shared.m_name == m_requiredItemName)
		{
			int num = user.GetInventory().CountItems(m_requiredItemName, -1, true);
			if (num < m_requiredItemAmount)
			{
				((Character)user).Message((MessageType)2, "Not enough item: " + Localization.instance.Localize(m_requiredItemName) + " " + num + " / " + m_requiredItemAmount, 0, (Sprite)null);
				return true;
			}
			if ((Object)(object)m_itemPrefab == (Object)null)
			{
				Debug.LogWarning((object)"Missing ItemDrop Prefab");
				return true;
			}
			bool flag = false;
			if ((Object)(object)m_itemPrefab != (Object)null)
			{
				flag = Spawn(GetSpawnPosition());
			}
			if (flag)
			{
				user.GetInventory().RemoveItem(item.m_shared.m_name, m_requiredItemAmount, -1, true);
				((Character)user).ShowRemovedMessage(m_requiredItem.m_itemData, m_requiredItemAmount);
				((Character)user).Message((MessageType)2, "Trade Complete", 0, (Sprite)null);
				if (Object.op_Implicit((Object)(object)m_itemSpawnPoint))
				{
					m_fuelAddedEffects.Create(m_itemSpawnPoint.position, ((Component)this).transform.rotation, (Transform)null, 1f, -1);
				}
				if (!string.IsNullOrEmpty(m_setGlobalKey))
				{
					ZoneSystem.instance.SetGlobalKey(m_setGlobalKey);
				}
			}
			return flag;
		}
		((Character)user).Message((MessageType)2, "You have nothing to trade", 0, (Sprite)null);
		return true;
	}

	public bool IsActive()
	{
		return m_canTrade && m_traderAmount > 0;
	}

	private void UpdateGameObjectState()
	{
		bool flag = IsActive();
		m_enabledObject.SetActive(flag);
		if (Object.op_Implicit((Object)(object)m_disabledObject))
		{
			m_disabledObject.SetActive(!flag);
		}
	}

	private float GetDeltaTime()
	{
		DateTime time = ZNet.instance.GetTime();
		DateTime dateTime = new DateTime(m_nview.GetZDO().GetLong("StartTime", time.Ticks));
		double totalSeconds = (time - dateTime).TotalSeconds;
		m_nview.GetZDO().Set("StartTime", time.Ticks);
		return (float)totalSeconds;
	}

	private void UpdateOfferingStation()
	{
		if (m_nview.IsValid())
		{
		}
	}

	private Vector3 GetSpawnPosition()
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		return ((Object)(object)m_itemSpawnPoint != (Object)null) ? m_itemSpawnPoint.position : ((Component)this).transform.position;
	}

	private bool Spawn(Vector3 point)
	{
		//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)
		m_spawnStartEffects.Create(point, Quaternion.identity, (Transform)null, 1f, -1);
		((MonoBehaviour)this).Invoke("DelayedSpawn", m_SpawnDelay);
		return true;
	}

	private bool IsSpawnQueued()
	{
		return ((MonoBehaviour)this).IsInvoking("DelayedSpawn");
	}

	private void DelayedSpawn()
	{
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: 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)
		if (m_spawnItem)
		{
			Object.Instantiate<GameObject>(((Component)m_itemPrefab).gameObject.gameObject, GetSpawnPosition(), Quaternion.identity).GetComponent<ItemDrop>().m_itemData.m_stack = m_itemPrefabAmount;
		}
		m_spawnFinishEffects.Create(GetSpawnPosition(), Quaternion.identity, (Transform)null, 1f, -1);
	}
}
public class OfferingStation : MonoBehaviour, Hoverable, Interactable
{
	public string m_name = "Offer station";

	public string m_useItemText = "Use";

	public ItemDrop m_requiredItem;

	public int m_requiredItemAmount = 1;

	public string m_statusEffectName = "";

	public bool m_spawnStatusEffect = true;

	public GameObject m_aoePrefab;

	public GameObject m_spawnPoint = null;

	public bool m_spawnItem = false;

	public ItemDrop m_itemPrefab;

	public Transform m_itemSpawnPoint;

	public string m_setGlobalKey = "";

	public float m_SpawnDelay = 2f;

	public float m_spawnOffset = 0f;

	[Header("Effects")]
	public EffectList m_fuelAddedEffects = new EffectList();

	public EffectList m_spawnStartEffects = new EffectList();

	public EffectList m_spawnFinishEffects = new EffectList();

	public GameObject m_enabledObject;

	public GameObject m_disabledObject;

	public GameObject m_haveFuelObject;

	public Transform m_roofCheckPoint;

	public bool m_requiresRoof = false;

	public bool m_canBeOutside = true;

	private float m_updateCoverTimer;

	public Switch m_addWoodSwitch;

	public bool m_useFuel = false;

	public ItemDrop m_fuelItem;

	public int m_maxFuel = 0;

	public float m_secPerFuel = 2000f;

	public bool m_requireFire = false;

	public Transform[] m_fireCheckPoints;

	public float m_fireCheckRadius = 0.25f;

	private bool m_blockedSmoke;

	public SmokeSpawner m_smokeSpawner;

	public Animator[] m_animators;

	private ZNetView m_nview;

	private string m_requiredItemName;

	private void Awake()
	{
		m_nview = ((Component)this).GetComponent<ZNetView>();
		if ((Object)(object)m_nview == (Object)null || m_nview.GetZDO() == null)
		{
			ZLog.Log((object)"Missing ZnetView Component");
			return;
		}
		validateAoe();
		m_requiredItemName = m_requiredItem.m_itemData.m_shared.m_name;
		if (Object.op_Implicit((Object)(object)m_addWoodSwitch))
		{
		}
		((MonoBehaviour)this).InvokeRepeating("UpdateOfferingStation", 1f, 1f);
	}

	private bool validateAoe()
	{
		if ((Object)(object)m_aoePrefab.GetComponent<Aoe>() == (Object)null)
		{
			ZLog.Log((object)"m_aoePrefab Missing Aoe Component");
			return false;
		}
		return true;
	}

	public string GetHoverText()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		if (!PrivateArea.CheckAccess(((Component)this).transform.position, 0f, false, false))
		{
			return Localization.instance.Localize(m_name + "\n$piece_noaccess");
		}
		return Localization.instance.Localize(m_name + "\n[<color=yellow><b>1-8</b></color>] \n" + m_useItemText) + " " + Localization.instance.Localize(((Component)m_requiredItem).GetComponent<ItemDrop>().m_itemData.m_shared.m_name) + " amount: " + m_requiredItemAmount;
	}

	public string GetHoverName()
	{
		return m_name;
	}

	public bool Interact(Humanoid user, bool hold, bool alt)
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		if (hold || IsSpawnQueued())
		{
			return false;
		}
		if (!PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false))
		{
			return true;
		}
		if (m_blockedSmoke)
		{
			((Character)user).Message((MessageType)2, "Smoke blocked", 0, (Sprite)null);
			return false;
		}
		if (!IsActive())
		{
			return false;
		}
		if (Spawn(GetSpawnPosition()))
		{
			((Character)user).Message((MessageType)2, "$msg_offerdone", 0, (Sprite)null);
			if (Object.op_Implicit((Object)(object)m_itemSpawnPoint))
			{
				m_fuelAddedEffects.Create(m_itemSpawnPoint.position, ((Component)this).transform.rotation, (Transform)null, 1f, -1);
			}
		}
		return true;
	}

	public bool UseItem(Humanoid user, ItemData item)
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0245: Unknown result type (might be due to invalid IL or missing references)
		//IL_0250: Unknown result type (might be due to invalid IL or missing references)
		if (IsSpawnQueued())
		{
			return true;
		}
		if (!PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false))
		{
			return true;
		}
		if (m_blockedSmoke)
		{
			((Character)user).Message((MessageType)2, "Smoke blocked", 0, (Sprite)null);
			return false;
		}
		if (!IsActive())
		{
			return false;
		}
		if ((Object)(object)m_requiredItem == (Object)null)
		{
			return false;
		}
		if (item.m_shared.m_name == m_requiredItemName)
		{
			int num = user.GetInventory().CountItems(m_requiredItemName, -1, true);
			if (num < m_requiredItemAmount)
			{
				((Character)user).Message((MessageType)2, "$msg_incompleteoffering: " + Localization.instance.Localize(m_requiredItemName) + " " + num + " / " + m_requiredItemAmount, 0, (Sprite)null);
				return true;
			}
			if (m_spawnStatusEffect && (Object)(object)m_aoePrefab == (Object)null)
			{
				Debug.LogWarning((object)"Missing Status Effect Prefab[AoE]");
				return true;
			}
			if (m_spawnItem && (Object)(object)m_itemPrefab == (Object)null)
			{
				Debug.LogWarning((object)"Missing ItemDrop Prefab");
				return true;
			}
			bool flag = false;
			if (((Object)(object)m_aoePrefab != (Object)null && m_spawnStatusEffect) || ((Object)(object)m_itemPrefab != (Object)null && m_spawnItem))
			{
				flag = Spawn(GetSpawnPosition());
			}
			if (flag)
			{
				user.GetInventory().RemoveItem(item.m_shared.m_name, m_requiredItemAmount, -1, true);
				((Character)user).ShowRemovedMessage(m_requiredItem.m_itemData, m_requiredItemAmount);
				((Character)user).Message((MessageType)2, "$msg_offerdone", 0, (Sprite)null);
				if (Object.op_Implicit((Object)(object)m_itemSpawnPoint))
				{
					m_fuelAddedEffects.Create(m_itemSpawnPoint.position, ((Component)this).transform.rotation, (Transform)null, 1f, -1);
				}
				if (!string.IsNullOrEmpty(m_setGlobalKey))
				{
					ZoneSystem.instance.SetGlobalKey(m_setGlobalKey);
				}
			}
			return flag;
		}
		((Character)user).Message((MessageType)2, "$msg_offerwrong", 0, (Sprite)null);
		return true;
	}

	public bool IsActive()
	{
		return (m_maxFuel == 0 || (double)GetFuel() > 0.0) && !m_blockedSmoke;
	}

	private void UpdateGameObjectState()
	{
		bool flag = IsActive();
		m_enabledObject.SetActive(flag);
		if (Object.op_Implicit((Object)(object)m_disabledObject))
		{
			m_disabledObject.SetActive(!flag);
		}
		if (Object.op_Implicit((Object)(object)m_haveFuelObject))
		{
			m_haveFuelObject.SetActive((double)GetFuel() > 0.0);
		}
		SetAnimation(flag);
	}

	private void SetAnimation(bool active)
	{
		Animator[] animators = m_animators;
		foreach (Animator val in animators)
		{
			if (((Component)val).gameObject.activeInHierarchy)
			{
				val.SetBool("active", active);
				val.SetFloat("activef", active ? 1f : 0f);
			}
		}
	}

	private float GetDeltaTime()
	{
		DateTime time = ZNet.instance.GetTime();
		DateTime dateTime = new DateTime(m_nview.GetZDO().GetLong("StartTime", time.Ticks));
		double totalSeconds = (time - dateTime).TotalSeconds;
		m_nview.GetZDO().Set("StartTime", time.Ticks);
		return (float)totalSeconds;
	}

	private void UpdateFuel(float dt)
	{
		if (m_useFuel)
		{
			float num = dt / m_secPerFuel;
			float num2 = GetFuel() - num;
			if ((double)num2 < 0.0)
			{
				num2 = 0f;
			}
			SetFuel(num2);
		}
	}

	private void RPC_AddFuel(long sender)
	{
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		if (m_nview.IsOwner())
		{
			SetFuel(GetFuel() + 1f);
			m_fuelAddedEffects.Create(((Component)this).transform.position, ((Component)this).transform.rotation, ((Component)this).transform, 1f, -1);
		}
	}

	private void UpdateOfferingStation()
	{
		if (m_nview.IsValid())
		{
		}
	}

	private Vector3 GetSpawnPosition()
	{
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		return ((Object)(object)m_spawnPoint != (Object)null) ? m_spawnPoint.transform.position : ((Component)this).transform.position;
	}

	private bool Spawn(Vector3 point)
	{
		//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)
		m_spawnStartEffects.Create(point, Quaternion.identity, (Transform)null, 1f, -1);
		((MonoBehaviour)this).Invoke("DelayedSpawn", m_SpawnDelay);
		return true;
	}

	private void UpdateSmoke()
	{
		if ((Object)(object)m_smokeSpawner != (Object)null)
		{
			m_blockedSmoke = m_smokeSpawner.IsBlocked();
		}
		else
		{
			m_blockedSmoke = false;
		}
	}

	private float GetFuel()
	{
		return m_nview.GetZDO().GetFloat("fuel", 0f);
	}

	private void SetFuel(float fuel)
	{
		m_nview.GetZDO().Set("fuel", fuel);
	}

	private bool OnAddFuel(Switch sw, Humanoid user, ItemData item)
	{
		if (!m_useFuel)
		{
			((Character)user).Message((MessageType)2, "No fuel required", 0, (Sprite)null);
			return false;
		}
		if (item != null && item.m_shared.m_name != m_fuelItem.m_itemData.m_shared.m_name)
		{
			((Character)user).Message((MessageType)2, "$msg_wrongitem", 0, (Sprite)null);
			return false;
		}
		if (!user.GetInventory().HaveItem(m_fuelItem.m_itemData.m_shared.m_name, true))
		{
			((Character)user).Message((MessageType)2, "$msg_donthaveany " + m_fuelItem.m_itemData.m_shared.m_name, 0, (Sprite)null);
			return false;
		}
		((Character)user).Message((MessageType)2, "$msg_added " + m_fuelItem.m_itemData.m_shared.m_name, 0, (Sprite)null);
		user.GetInventory().RemoveItem(m_fuelItem.m_itemData.m_shared.m_name, 1, -1, true);
		m_nview.InvokeRPC("AddFuel", Array.Empty<object>());
		return true;
	}

	private bool IsSpawnQueued()
	{
		return ((MonoBehaviour)this).IsInvoking("DelayedSpawn");
	}

	private void DelayedSpawn()
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: 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_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		if (m_spawnStatusEffect)
		{
			Aoe component = Object.Instantiate<GameObject>(m_aoePrefab, GetSpawnPosition(), Quaternion.identity).GetComponent<Aoe>();
			component.m_statusEffect = m_statusEffectName;
		}
		if (m_spawnItem)
		{
			Object.Instantiate<GameObject>(((Component)m_itemPrefab).gameObject, GetSpawnPosition(), Quaternion.identity);
		}
		m_spawnFinishEffects.Create(GetSpawnPosition(), Quaternion.identity, (Transform)null, 1f, -1);
	}
}
public class RandomItemSpawner : MonoBehaviour
{
	public List<GameObject> spawnList;

	public int amount = 1;

	private void Start()
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		for (int i = 0; i < amount; i++)
		{
			int number = pickNumber();
			GameObject objectToSpawn = getObjectToSpawn(number);
			if ((Object)(object)objectToSpawn != (Object)null)
			{
				Object.Instantiate<GameObject>(objectToSpawn, ((Component)this).transform.position, Quaternion.identity);
			}
		}
	}

	private int pickNumber()
	{
		int num;
		for (num = Random.Range(0, spawnList.Count - 1); num > spawnList.Count - 1; num = Random.Range(0, spawnList.Count - 1))
		{
		}
		return num;
	}

	private GameObject getObjectToSpawn(int number)
	{
		GameObject val = null;
		while (number > spawnList.Count - 1 || (Object)(object)val == (Object)null)
		{
			number = pickNumber();
			val = spawnList[number];
		}
		return val;
	}
}
[Serializable]
public class VegetationSpawnerManager : MonoBehaviour
{
	public enum SpawnType
	{
		Destructable,
		Pickable,
		Monster,
		Piece
	}

	public class SpawnField
	{
		public string name;

		public GameObject prefab;
	}

	private ZNetView m_nview;

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

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

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

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

	public string spawnPrefix = "SpawnMe_";

	public string pickPrefix = "PickMe_";

	public string destructablesPrefix = "HitMe_";

	public bool enforceCreation = false;

	public List<Transform> usedSpawners = new List<Transform>();

	public List<Transform> usedPickables = new List<Transform>();

	public List<Transform> usedDestructables = new List<Transform>();

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

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

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

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

	private void Awake()
	{
		m_nview = ((Component)this).GetComponent<ZNetView>();
		if (!m_nview.GetZDO().GetBool("spawned", false) || enforceCreation)
		{
			StartSpawn();
			m_nview.GetZDO().Set("spawned", true);
		}
	}

	private void StartSpawn()
	{
		SpawnDestructables();
		SpawnPickables();
		SpawnMonsters();
	}

	private void SpawnDestructables()
	{
		foreach (Transform usedDestructable in usedDestructables)
		{
			Spawn(usedDestructable, destructablesPrefix, SpawnType.Destructable);
		}
	}

	private void SpawnMonsters()
	{
		foreach (Transform usedSpawner in usedSpawners)
		{
			Spawn(usedSpawner, spawnPrefix, SpawnType.Monster);
		}
	}

	private void SpawnPickables()
	{
		foreach (Transform usedPickable in usedPickables)
		{
			Spawn(usedPickable, pickPrefix, SpawnType.Pickable);
		}
	}

	private void Spawn(Transform thisTransform, string prefix, SpawnType type)
	{
		//IL_0060: 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)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		string text = ((Object)thisTransform).name.Replace(prefix, "").Trim();
		GameObject val = null;
		val = ((!(text != "") || text == null || !(text != "Random")) ? GetPrefabFromList(type) : GetPrefabByName(text));
		if ((Object)(object)val != (Object)null)
		{
			GameObject val2 = Object.Instantiate<GameObject>(val, thisTransform.position, thisTransform.rotation);
			if (type == SpawnType.Destructable)
			{
				val2.transform.localScale = thisTransform.localScale;
			}
			AddToList(type, val2);
		}
	}

	private void AddToList(SpawnType type, GameObject gameObject)
	{
		switch (type)
		{
		case SpawnType.Monster:
			spawnedMonsters.Add(gameObject);
			break;
		case SpawnType.Pickable:
			spawnedPickables.Add(gameObject);
			break;
		case SpawnType.Piece:
			spawnedPieces.Add(gameObject);
			break;
		case SpawnType.Destructable:
			spawnedDestructables.Add(gameObject);
			break;
		}
	}

	private GameObject GetPrefabByName(string name)
	{
		return ZNetScene.instance.m_prefabs.Find((GameObject x) => ((Object)x).name == name);
	}

	private GameObject GetPrefabFromList(SpawnType type)
	{
		List<GameObject> list = null;
		switch (type)
		{
		case SpawnType.Monster:
			list = spawners;
			break;
		case SpawnType.Pickable:
			list = pickables;
			break;
		case SpawnType.Piece:
			list = pieces;
			break;
		case SpawnType.Destructable:
			list = destructables;
			break;
		default:
			return null;
		}
		return GetRandomPrefab(list);
	}

	private GameObject GetRandomPrefab(List<GameObject> list)
	{
		int count = list.Count;
		int index = Random.Range(0, count - 1);
		return list[index];
	}
}
internal class BloodBowl : MonoBehaviour, Hoverable, Interactable
{
	public string m_name = "";

	public Transform m_coverPoint;

	public Transform m_spawnPoint;

	public GameObject spilling;

	public float m_secPerUnit = 10f;

	public int m_maxBlood = 4;

	public ItemDrop m_bloodyItem;

	public EffectList m_spawnEffect = new EffectList();

	private ZNetView m_nview;

	private void Awake()
	{
		spilling.SetActive(false);
		m_nview = ((Component)this).GetComponent<ZNetView>();
		if (m_nview.GetZDO() != null)
		{
			if (m_nview.IsOwner() && m_nview.GetZDO().GetLong("lastTime", 0L) == 0)
			{
				m_nview.GetZDO().Set("lastTime", ZNet.instance.GetTime().Ticks);
			}
			m_nview.Register("Extract", (Action<long>)RPC_Extract);
			((MonoBehaviour)this).InvokeRepeating("UpdateBowl", 0f, 10f);
		}
	}

	public string GetHoverText()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		if (!PrivateArea.CheckAccess(((Component)this).transform.position, 0f, false, false))
		{
			return Localization.instance.Localize(m_name + "\n$piece_noaccess");
		}
		int bloodLevel = GetBloodLevel();
		if (bloodLevel <= 0)
		{
			return Localization.instance.Localize(m_name + " ( $piece_container_empty )\n[<color=yellow><b>$KEY_Use</b></color>] Check Bowl");
		}
		return Localization.instance.Localize(m_name + " ( " + m_bloodyItem.m_itemData.m_shared.m_name + " x " + bloodLevel + " )\n[<color=yellow><b>$KEY_Use</b></color>] Fill the vials");
	}

	public string GetHoverName()
	{
		return m_name;
	}

	public bool Interact(Humanoid character, bool repeat, bool alt)
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		if (repeat)
		{
			return false;
		}
		if (!PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false))
		{
			return true;
		}
		if (GetBloodLevel() > 0)
		{
			Extract();
			spilling.SetActive(false);
		}
		else
		{
			((Character)character).Message((MessageType)2, "Blood is boiling", 0, (Sprite)null);
		}
		return true;
	}

	public bool UseItem(Humanoid user, ItemData item)
	{
		return false;
	}

	private void Extract()
	{
		m_nview.InvokeRPC("Extract", Array.Empty<object>());
	}

	private void RPC_Extract(long caller)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: 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_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_007f: Unknown result type (might be due to invalid IL or missing references)
		int bloodLevel = GetBloodLevel();
		if (bloodLevel > 0)
		{
			m_spawnEffect.Create(m_spawnPoint.position, Quaternion.identity, (Transform)null, 1f, -1);
			for (int i = 0; i < bloodLevel; i++)
			{
				Vector2 val = Random.insideUnitCircle * 0.5f;
				Object.Instantiate<ItemDrop>(m_bloodyItem, m_spawnPoint.position + new Vector3(val.x, 0.25f * (float)i, val.y), Quaternion.identity);
			}
			ResetLevel();
		}
	}

	private float GetTimeSinceLastUpdate()
	{
		DateTime dateTime = new DateTime(m_nview.GetZDO().GetLong("lastTime", ZNet.instance.GetTime().Ticks));
		DateTime time = ZNet.instance.GetTime();
		TimeSpan timeSpan = time - dateTime;
		m_nview.GetZDO().Set("lastTime", time.Ticks);
		double num = timeSpan.TotalSeconds;
		if (num < 0.0)
		{
			num = 0.0;
		}
		return (float)num;
	}

	private void ResetLevel()
	{
		m_nview.GetZDO().Set("level", 0);
	}

	private void IncreseLevel(int i)
	{
		int num = Mathf.Clamp(GetBloodLevel() + i, 0, m_maxBlood);
		m_nview.GetZDO().Set("level", num);
	}

	private int GetBloodLevel()
	{
		return m_nview.GetZDO().GetInt("level", 0);
	}

	private void UpdateBowl()
	{
		if (m_nview.IsOwner())
		{
			float timeSinceLastUpdate = GetTimeSinceLastUpdate();
			float num = m_nview.GetZDO().GetFloat("product", 0f) + timeSinceLastUpdate;
			if ((double)num > (double)m_secPerUnit)
			{
				IncreseLevel((int)((double)num / (double)m_secPerUnit));
				num = 0f;
			}
			if (GetBloodLevel() == m_maxBlood)
			{
				spilling.SetActive(true);
			}
			m_nview.GetZDO().Set("product", num);
		}
	}
}
internal class BalDoor : MonoBehaviour, Hoverable, Interactable
{
	public string m_name = "door";

	public ItemDrop m_keyItem;

	public bool m_canNotBeClosed;

	public bool m_invertedOpenClosedText;

	public bool m_checkGuardStone = true;

	public GameObject m_openEnable;

	public EffectList m_openEffects = new EffectList();

	public EffectList m_closeEffects = new EffectList();

	public EffectList m_lockedEffects = new EffectList();

	private ZNetView m_nview;

	private Animator m_animator;

	private void Awake()
	{
		m_nview = ((Component)this).GetComponent<ZNetView>();
		if (m_nview.GetZDO() != null)
		{
			m_animator = ((Component)this).GetComponentInChildren<Animator>();
			if (Object.op_Implicit((Object)(object)m_nview))
			{
				m_nview.Register<bool>("UseBalDoor", (Action<long, bool>)RPC_UseBalDoor);
			}
			((MonoBehaviour)this).InvokeRepeating("UpdateState", 0f, 0.2f);
		}
	}

	private void UpdateState()
	{
		if (m_nview.IsValid())
		{
			SetState(m_nview.GetZDO().GetInt("state", 0));
		}
	}

	private void SetState(int state)
	{
		//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)
		//IL_0030: 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)
		if (m_animator.GetInteger("state") != state)
		{
			if (state != 0)
			{
				m_openEffects.Create(((Component)this).transform.position, ((Component)this).transform.rotation, (Transform)null, 1f, -1);
			}
			else
			{
				m_closeEffects.Create(((Component)this).transform.position, ((Component)this).transform.rotation, (Transform)null, 1f, -1);
			}
			m_animator.SetInteger("state", state);
		}
		if (Object.op_Implicit((Object)(object)m_openEnable))
		{
			m_openEnable.SetActive(state != 0);
		}
	}

	private bool CanInteract()
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		AnimatorStateInfo currentAnimatorStateInfo = m_animator.GetCurrentAnimatorStateInfo(0);
		int result;
		if (!((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsTag("open"))
		{
			currentAnimatorStateInfo = m_animator.GetCurrentAnimatorStateInfo(0);
			result = (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsTag("closed") ? 1 : 0);
		}
		else
		{
			result = 1;
		}
		return (byte)result != 0;
	}

	public string GetHoverText()
	{
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		if (!m_nview.IsValid() || (m_canNotBeClosed && !CanInteract()))
		{
			return "";
		}
		if (m_checkGuardStone && !PrivateArea.CheckAccess(((Component)this).transform.position, 0f, false, false))
		{
			return Localization.instance.Localize(m_name + "\n$piece_noaccess");
		}
		if (!CanInteract())
		{
			return Localization.instance.Localize(m_name);
		}
		return (m_nview.GetZDO().GetInt("state", 0) != 0) ? Localization.instance.Localize(m_name + "\n[<color=yellow><b>$KEY_Use</b></color>] " + (m_invertedOpenClosedText ? "$piece_door_open" : "$piece_door_close")) : Localization.instance.Localize(m_name + "\n[<color=yellow><b>$KEY_Use</b></color>] " + (m_invertedOpenClosedText ? "$piece_door_close" : "$piece_door_open"));
	}

	public string GetHoverName()
	{
		return m_name;
	}

	public bool Interact(Humanoid character, bool hold, bool alt)
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: 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)
		if (hold || !CanInteract())
		{
			return false;
		}
		if (m_checkGuardStone && !PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false))
		{
			return true;
		}
		if ((Object)(object)m_keyItem != (Object)null)
		{
			if (!HaveKey(character))
			{
				m_lockedEffects.Create(((Component)this).transform.position, ((Component)this).transform.rotation, (Transform)null, 1f, -1);
				((Character)character).Message((MessageType)2, Localization.instance.Localize("$msg_door_needkey", new string[1] { m_keyItem.m_itemData.m_shared.m_name }), 0, (Sprite)null);
				return true;
			}
			((Character)character).Message((MessageType)2, Localization.instance.Localize("$msg_door_usingkey", new string[1] { m_keyItem.m_itemData.m_shared.m_name }), 0, (Sprite)null);
		}
		Vector3 val = ((Component)character).transform.position - ((Component)this).transform.position;
		Open(((Vector3)(ref val)).normalized);
		return true;
	}

	private void Open(Vector3 userDir)
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		m_nview.InvokeRPC("UseBalDoor", new object[1] { (double)Vector3.Dot(((Component)this).transform.forward, userDir) < 0.0 });
	}

	public bool UseItem(Humanoid user, ItemData item)
	{
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)m_keyItem != (Object)null) || !(m_keyItem.m_itemData.m_shared.m_name == item.m_shared.m_name) || !CanInteract())
		{
			return false;
		}
		if (m_checkGuardStone && !PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false))
		{
			return true;
		}
		((Character)user).Message((MessageType)2, Localization.instance.Localize("$msg_door_usingkey", new string[1] { m_keyItem.m_itemData.m_shared.m_name }), 0, (Sprite)null);
		Vector3 val = ((Component)user).transform.position - ((Component)this).transform.position;
		Open(((Vector3)(ref val)).normalized);
		return true;
	}

	private bool HaveKey(Humanoid player)
	{
		return (Object)(object)m_keyItem == (Object)null || player.GetInventory().HaveItem(m_keyItem.m_itemData.m_shared.m_name, true);
	}

	private void RPC_UseBalDoor(long uid, bool forward)
	{
		if (!CanInteract())
		{
			return;
		}
		if (m_nview.GetZDO().GetInt("state", 0) == 0)
		{
			if (forward)
			{
				m_nview.GetZDO().Set("state", 1);
			}
			else
			{
				m_nview.GetZDO().Set("state", -1);
			}
		}
		else
		{
			m_nview.GetZDO().Set("state", 0);
		}
		UpdateState();
	}
}
internal class IcePillar : MonoBehaviour, Hoverable, Interactable
{
	public string m_name = "";

	public Transform m_coverPoint;

	public Transform m_spawnPoint;

	public GameObject spilling;

	public float m_secPerUnit = 10f;

	public int m_maxBlood = 4;

	public ItemDrop m_bloodyItem;

	public EffectList m_spawnEffect = new EffectList();

	private ZNetView m_nview;

	private void Awake()
	{
		m_nview = ((Component)this).GetComponent<ZNetView>();
		if (m_nview.GetZDO() != null)
		{
			if (m_nview.IsOwner() && m_nview.GetZDO().GetLong("lastTime", 0L) == 0)
			{
				m_nview.GetZDO().Set("lastTime", ZNet.instance.GetTime().Ticks);
			}
			m_nview.Register("Extract", (Action<long>)RPC_Extract);
			((MonoBehaviour)this).InvokeRepeating("UpdateCrystal", 0f, 10f);
		}
	}

	public string GetHoverText()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		if (!PrivateArea.CheckAccess(((Component)this).transform.position, 0f, false, false))
		{
			return Localization.instance.Localize(m_name + "\n$piece_noaccess");
		}
		int bloodLevel = GetBloodLevel();
		if (bloodLevel <= 0)
		{
			return Localization.instance.Localize(m_name + " ( $piece_container_empty )\n[<color=yellow><b>$KEY_Use</b></color>] Check Crystal");
		}
		return Localization.instance.Localize(m_name + " ( " + m_bloodyItem.m_itemData.m_shared.m_name + " x " + bloodLevel + " )\n[<color=yellow><b>$KEY_Use</b></color>] Shred the ice");
	}

	public string GetHoverName()
	{
		return m_name;
	}

	public bool Interact(Humanoid character, bool repeat, bool alt)
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		if (repeat)
		{
			return false;
		}
		if (!PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false))
		{
			return true;
		}
		if (GetBloodLevel() > 0)
		{
			Extract();
		}
		else
		{
			((Character)character).Message((MessageType)2, "The Crystal is crackling", 0, (Sprite)null);
		}
		return true;
	}

	public bool UseItem(Humanoid user, ItemData item)
	{
		return false;
	}

	private void Extract()
	{
		m_nview.InvokeRPC("Extract", Array.Empty<object>());
	}

	private void RPC_Extract(long caller)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: 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_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_007f: Unknown result type (might be due to invalid IL or missing references)
		int bloodLevel = GetBloodLevel();
		if (bloodLevel > 0)
		{
			m_spawnEffect.Create(m_spawnPoint.position, Quaternion.identity, (Transform)null, 1f, -1);
			for (int i = 0; i < bloodLevel; i++)
			{
				Vector2 val = Random.insideUnitCircle * 0.5f;
				Object.Instantiate<ItemDrop>(m_bloodyItem, m_spawnPoint.position + new Vector3(val.x, 0.25f * (float)i, val.y), Quaternion.identity);
			}
			ResetLevel();
		}
	}

	private float GetTimeSinceLastUpdate()
	{
		DateTime dateTime = new DateTime(m_nview.GetZDO().GetLong("lastTime", ZNet.instance.GetTime().Ticks));
		DateTime time = ZNet.instance.GetTime();
		TimeSpan timeSpan = time - dateTime;
		m_nview.GetZDO().Set("lastTime", time.Ticks);
		double num = timeSpan.TotalSeconds;
		if (num < 0.0)
		{
			num = 0.0;
		}
		return (float)num;
	}

	private void ResetLevel()
	{
		m_nview.GetZDO().Set("level", 0);
	}

	private void IncreseLevel(int i)
	{
		int num = Mathf.Clamp(GetBloodLevel() + i, 0, m_maxBlood);
		m_nview.GetZDO().Set("level", num);
	}

	private int GetBloodLevel()
	{
		return m_nview.GetZDO().GetInt("level", 0);
	}

	private void UpdateCrystal()
	{
		if (m_nview.IsOwner())
		{
			float timeSinceLastUpdate = GetTimeSinceLastUpdate();
			float num = m_nview.GetZDO().GetFloat("product", 0f) + timeSinceLastUpdate;
			if ((double)num > (double)m_secPerUnit)
			{
				IncreseLevel((int)((double)num / (double)m_secPerUnit));
				num = 0f;
			}
			if (GetBloodLevel() == m_maxBlood)
			{
			}
			m_nview.GetZDO().Set("product", num);
		}
	}
}
namespace BalrondTeleportableComponent
{
	public class BalrondTeleporter : MonoBehaviour
	{
		public Projectile projectile;

		private Character character;

		private ZNetView zNetView;

		private void Awake()
		{
			projectile = ((Component)this).GetComponent<Projectile>();
			zNetView = projectile.m_nview;
		}

		private void Update()
		{
			character = projectile.m_owner;
		}

		private void OnDisable()
		{
			TeleportOwner();
		}

		private void TeleportOwner()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			character.TeleportTo(((Component)this).transform.position, ((Component)this).transform.rotation, true);
		}
	}
}
namespace BalrondBiomes
{
	public class ConversionChanges
	{
		private enum ConversionType
		{
			smelter,
			fermenter,
			cooking,
			balrondConverter
		}

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

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

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

		private string[] buildPiecesNames = new string[15]
		{
			"portal_wood", "piece_workbench", "piece_chest_private", "piece_chest_wood", "piece_banner01", "piece_banner02", "piece_banner03", "piece_banner04", "piece_banner05", "piece_banner06",
			"piece_banner07", "piece_banner08", "piece_banner09", "piece_banner10", "piece_banner11"
		};

		public void editBuidlPieces(List<GameObject> buildpieces, List<GameObject> items)
		{
			buildPieces = buildpieces;
			this.items = items;
			editFermenter();
			editSmelter();
			editCooking();
			editIronCooking();
			editOven();
			editFurnace();
			editKiln();
			editWHeel();
			editRefinery();
			editWIndMIll();
			editSap();
			editBeehive();
			editSawMill();
			editBoiler();
			editLeatherRack();
			EditRecipes();
		}

		private void EditRecipes()
		{
			string[] array = buildPiecesNames;
			foreach (string name in array)
			{
				GameObject val = FindBuildPiece(name);
				if ((Object)(object)val != (Object)null)
				{
					changeBuildPiece(val);
				}
			}
		}

		private void changeBuildPiece(GameObject buildPiece)
		{
			switch (((Object)buildPiece).name)
			{
			case "piece_chest_private":
				ChangeChest(buildPiece, 3, 6);
				break;
			case "piece_chest_wood":
				ChangeChest(buildPiece, 2, 7);
				break;
			case "portal_wood":
				ChangeRecipe(buildPiece);
				break;
			case "piece_workbench":
				ChcangeCraftingStation(buildPiece, requireRoof: false);
				break;
			case "piece_banner01":
			case "piece_banner02":
			case "piece_banner03":
			case "piece_banner04":
			case "piece_banner05":
			case "piece_banner06":
			case "piece_banner07":
			case "piece_banner08":
			case "piece_banner09":
			case "piece_banner10":
			case "piece_banner11":
				setBannerRecipe(buildPiece);
				break;
			}
		}

		private void setBannerRecipe(GameObject gameObject)
		{
			Piece component = gameObject.GetComponent<Piece>();
			component.m_resources = createResources(gameObject);
		}

		private void ChangeChest(GameObject gameObject, int height, int width)
		{
			Container component = gameObject.GetComponent<Container>();
			component.m_width = width;
			component.m_height = height;
		}

		private void ChcangeCraftingStation(GameObject buildPiece, bool requireRoof)
		{
			CraftingStation component = buildPiece.GetComponent<CraftingStation>();
			if ((Object)(object)component != (Object)null)
			{
				component.m_craftRequireRoof = requireRoof;
			}
		}

		private GameObject FindBuildPiece(string name)
		{
			return buildPieces.Find((GameObject x) => ((Object)x).name == name);
		}

		private void ChangeRecipe(GameObject gameObject)
		{
			Piece component = gameObject.GetComponent<Piece>();
			component.m_resources = createResources(gameObject);
		}

		private Requirement[] createResources(GameObject item)
		{
			List<Requirement> list = new List<Requirement>();
			switch (((Object)item).name)
			{
			case "portal_wood":
				list.Add(createReq("Crystal", 5, 0));
				list.Add(createReq("FineWood", 25, 0));
				list.Add(createReq("SurtlingCore", 5, 0));
				list.Add(createReq("HardAntler", 1, 0));
				list.Add(createReq("Resin", 20, 0));
				break;
			case "piece_banner01":
			case "piece_banner02":
			case "piece_banner03":
			case "piece_banner04":
			case "piece_banner05":
			case "piece_banner06":
			case "piece_banner07":
			case "piece_banner08":
			case "piece_banner09":
			case "piece_banner10":
			case "piece_banner11":
				list.Add(createReq("DyeKit", 1, 0));
				list.Add(createReq("FineWood", 2, 0));
				list.Add(createReq("LeatherScraps", 3, 0));
				list.Add(createReq("StrawThread", 3, 0));
				break;
			}
			return list.ToArray();
		}

		private Requirement createReq(string name, int amount, int amountPerLevel)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			Requirement val = new Requirement();
			val.m_recover = true;
			ItemDrop component = FindItem(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)
			{
				return val;
			}
			Debug.LogWarning((object)("Item Not Found - " + name + ", Replaced With Wood"));
			return items.Find((GameObject x) => ((Object)x).name == "Wood");
		}

		private void editBoiler()
		{
			GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "piece_runeforge_ext3");
			Smelter component = val.GetComponent<Smelter>();
			component.m_maxFuel = 10;
			component.m_maxOre = 10;
			component.m_secPerProduct = 60f;
			component.m_fuelPerProduct = 2;
			component.m_fuelItem = ObjectDB.instance.m_items.Find((GameObject x) => ((Object)x).name == "Wood").GetComponent<ItemDrop>();
			component.m_conversion.Clear();
			addConversion(val, "Sulfur", "AcidVial", ConversionType.smelter);
		}

		private void editLeatherRack()
		{
			GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "piece_workbench_ext5");
			BalrondConverter component = val.GetComponent<BalrondConverter>();
			component.m_conversion.Clear();
			addConversion(val, "PatchworkDeer", "DeerHide", ConversionType.balrondConverter, 30, 2);
			addConversion(val, "PatchworkBoar", "BoarHide", ConversionType.balrondConverter, 30, 2);
			addConversion(val, "PatchworkTroll", "TrollHide", ConversionType.balrondConverter, 30, 2);
			addConversion(val, "PatchworkWolf", "WolfPelt", ConversionType.balrondConverter, 30, 2);
			addConversion(val, "PatchworkLox", "LoxPelt", ConversionType.balrondConverter, 30, 2);
		}

		private void editSawMill()
		{
			GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "piece_sawmill");
			BalrondConverter component = val.GetComponent<BalrondConverter>();
			component.m_conversion.Clear();
			addConversion(val, "RoundLog", "Wood", ConversionType.balrondConverter, 30, 2);
			addConversion(val, "FineWood", "Wood", ConversionType.balrondConverter, 30, 4);
			addConversion(val, "ElderBark", "Wood", ConversionType.balrondConverter, 30, 2);
			addConversion(val, "HardWood", "FineWood", ConversionType.balrondConverter, 30, 2);
			addConversion(val, "YggdrasilWood", "FineWood", ConversionType.balrondConverter, 30, 2);
			addConversion(val, "EmberWood", "YggdrasilWood", ConversionType.balrondConverter, 30, 2);
		}

		private void editFermenter()
		{
			GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "fermenter");
			Fermenter component = val.GetComponent<Fermenter>();
			component.m_fermentationDuration = 2000f;
			component.m_conversion.Clear();
			addConversion(val, "BarleyWineBase", "BarleyWine", ConversionType.fermenter);
			addConversion(val, "MeadBaseTasty", "MeadTasty", ConversionType.fermenter);
			addConversion(val, "MeadBaseMoonshine", "Moonshine", ConversionType.fermenter);
			addConversion(val, "MeadBaseElementalBrew", "ElementalBrew", ConversionType.fermenter);
			addConversion(val, "MeadBaseProteinPotion", "ElementalBrew", ConversionType.fermenter);
			addConversion(val, "SurstrommingBase", "Surstromming", ConversionType.fermenter);
			addConversion(val, "MeadBaseWhiteCheese", "WhiteCheese", ConversionType.fermenter);
			addConversion(val, "MeadBaseFireResistMajor", "MajorFirePotion", ConversionType.fermenter);
			addConversion(val, "MeadBaseFireResistMedium", "MediumFirePotion", ConversionType.fermenter);
			addConversion(val, "MeadBaseFireResistMinor", "MinorFirePotion", ConversionType.fermenter);
			addConversion(val, "MeadBaseFrostResistMajor", "MajorFrostPotion", ConversionType.fermenter);
			addConversion(val, "MeadBaseFrostResistMedium", "MediumFrostPotion", ConversionType.fermenter);
			addConversion(val, "MeadBaseFrostResistMinor", "MinorFrostPotion", ConversionType.fermenter);
			addConversion(val, "MeadBaseHealingMajor", "MajorHealthPotion", ConversionType.fermenter);
			addConversion(val, "MeadBaseHealingMedium", "MediumHealthPotion", ConversionType.fermenter);
			addConversion(val, "MeadBaseHealingMinor", "MinorHealthPotion", ConversionType.fermenter);
			addConversion(val, "MeadBaseLightingResistMajor", "MajorLightPotion", ConversionType.fermenter);
			addConversion(val, "MeadBaseLightingResistMedium", "MediumThunderPotion", ConversionType.fermenter);
			addConversion(val, "MeadBaseLightingResistMinor", "MinorThunderPotion", ConversionType.fermenter);
			addConversion(val, "MeadBasePoisonResistMajor", "MajorPoisonPotion", ConversionType.fermenter);
			addConversion(val, "MeadBasePoisonResistMedium", "MediumPoisonPotion", ConversionType.fermenter);
			addConversion(val, "MeadBasePoisonResistMinor", "MinorPoisonPotion", ConversionType.fermenter);
			addConversion(val, "MeadBaseRejuvenationMajor", "MajorRejuvenationPotion", ConversionType.fermenter);
			addConversion(val, "MeadBaseRejuvenationMedium", "MediumRejuvenationPotion", ConversionType.fermenter);
			addConversion(val, "MeadBaseRejuvenationMinor", "MinorRejuvenationPotion", ConversionType.fermenter);
			addConversion(val, "MeadBaseSpiritResistMajor", "MajorSpiritPotion", ConversionType.fermenter);
			addConversion(val, "MeadBaseSpiritResistMedium", "MediumSpiritPotion", ConversionType.fermenter);
			addConversion(val, "MeadBaseSpiritResistMinor", "MinorSpiritPotion", ConversionType.fermenter);
			addConversion(val, "MeadBaseStaminaMajorNew", "MajorStaminaPotion", ConversionType.fermenter);
			addConversion(val, "MeadBaseStaminaMediumNew", "MediumStaminaPotion", ConversionType.fermenter);
			addConversion(val, "MeadBaseStaminaMinorNew", "MinorStaminaPotion", ConversionType.fermenter);
			addConversion(val, "MeadBaseEitrMajorNew", "MajorEitrPotion", ConversionType.fermenter);
			addConversion(val, "MeadBaseEitrMediumNew", "MediumEitrPotion", ConversionType.fermenter);
			addConversion(val, "MeadBaseEitrMinorNew", "MinorEitrPotion", ConversionType.fermenter);
			addConversion(val, "MeadBaseLingeringEitrNew", "LingeringEitrPotion", ConversionType.fermenter);
			addConversion(val, "MeadBaseLingeringHealingNew", "LingeringHealthPotion", ConversionType.fermenter);
			addConversion(val, "MeadBaseLingeringeRejuvenationNew", "LingeringRejuvenationPotion", ConversionType.fermenter);
			addConversion(val, "MeadBaseLingeringStaminaNew", "LingeringStaminaPotion", ConversionType.fermenter);
		}

		private void editSmelter()
		{
			GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "smelter");
			Smelter component = val.GetComponent<Smelter>();
			component.m_maxFuel = 45;
			component.m_maxOre = 15;
			component.m_secPerProduct = 40f;
			component.m_fuelPerProduct = 3;
			component.m_conversion.Clear();
			addConversion(val, "CopperOre", "Copper", ConversionType.smelter);
			addConversion(val, "TinOre", "Tin", ConversionType.smelter);
			addConversion(val, "IronOre", "Iron", ConversionType.smelter);
			addConversion(val, "SilverOre", "Silver", ConversionType.smelter);
			addConversion(val, "GoldOre", "GoldBar", ConversionType.smelter);
			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_maxFuel = 60;
			component.m_maxOre = 30;
			component.m_secPerProduct = 20f;
			component.m_fuelPerProduct = 2;
			component.m_conversion.Clear();
			addConversion(val, "BlackMetalOre", "BlackMetal", ConversionType.smelter);
			addConversion(val, "DarkIron", "DarkSteel", ConversionType.smelter);
			addConversion(val, "CobaltOre", "Cobalt", ConversionType.smelter);
			addConversion(val, "FlametalOre", "Flametal", ConversionType.smelter);
			component.m_conversion.AddRange(allConversions);
		}

		private void editCooking()
		{
			GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "piece_cookingstation");
			CookingStation component = val.GetComponent<CookingStation>();
			component.m_conversion.Clear();
			addConversion(val, "FishRaw", "FishCooked", ConversionType.cooking, 25);
			addConversion(val, "NeckTail", "NeckTailGrilled", ConversionType.cooking, 25);
			addConversion(val, "BatWing", "BatWingCooked", ConversionType.cooking, 25);
			addConversion(val, "Potato", "PotatoFried", ConversionType.cooking, 25);
			addConversion(val, "BearMeat", "BearMeatCooked", ConversionType.cooking, 40);
			addConversion(val, "RawMeat", "CookedMeat", ConversionType.cooking);
			addConversion(val, "WolfMeat", "CookedWolfMeat", ConversionType.cooking, 35);
			addConversion(val, "DeerMeat", "CookedDeerMeat", ConversionType.cooking, 35);
			addConversion(val, "ChickenMeat", "CookedChickenMeat", ConversionType.cooking);
			addConversion(val, "SharkMeat_bal", "SharkMeatCooked_bal", ConversionType.cooking, 35);
			addConversion(val, "CrabLegs", "CrabLegsCooked", ConversionType.cooking);
		}

		private void editIronCooking()
		{
			GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "piece_cookingstation_iron");
			CookingStation component = val.GetComponent<CookingStation>();
			component.m_conversion.Clear();
			addConversion(val, "CrabLegs", "CrabLegsCooked", ConversionType.cooking, 25);
			addConversion(val, "SharkMeat_bal", "SharkMeatCooked_bal", ConversionType.cooking);
			addConversion(val, "SerpentMeat", "SerpentMeatCooked", ConversionType.cooking, 60);
			addConversion(val, "FenringMeat", "FenringMeatCooked", ConversionType.cooking, 60);
			addConversion(val, "FishRaw", "FishCooked", ConversionType.cooking, 20);
			addConversion(val, "NeckTail", "NeckTailGrilled", ConversionType.cooking, 20);
			addConversion(val, "BatWing", "BatWingCooked", ConversionType.cooking, 20);
			addConversion(val, "Potato", "PotatoFried", ConversionType.cooking, 20);
			addConversion(val, "RawMeat", "CookedMeat", ConversionType.cooking, 25);
			addConversion(val, "WolfMeat", "CookedWolfMeat", ConversionType.cooking);
			addConversion(val, "DeerMeat", "CookedDeerMeat", ConversionType.cooking);
			addConversion(val, "ChickenMeat", "CookedChickenMeat", ConversionType.cooking, 25);
			addConversion(val, "BearMeat", "BearMeatCooked", ConversionType.cooking, 35);
			addConversion(val, "LoxMeat", "CookedLoxMeat", ConversionType.cooking, 35);
			addConversion(val, "BugMeat", "CookedBugMeat", ConversionType.cooking, 35);
			addConversion(val, "HareMeat", "CookedHareMeat", ConversionType.cooking);
			addConversion(val, "DrakeMeat", "DrakeMeatCooked", ConversionType.cooking);
		}

		private void editOven()
		{
			GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "piece_oven");
			CookingStation component = val.GetComponent<CookingStation>();
			component.m_conversion.Clear();
			addConversion(val, "ApplePieUncooked", "ApplePie", ConversionType.cooking, 50);
			addConversion(val, "BlueberryPieUncooked", "BlueberryPie", ConversionType.cooking, 50);
			addConversion(val, "CloudberryPieUncooked", "CloudberryPie", ConversionType.cooking, 50);
			addConversion(val, "BlueberryPieUncooked", "BlueberryPie", ConversionType.cooking, 50);
			addConversion(val, "FishWrapsUncooked", "FishWraps", ConversionType.cooking, 50);
			addConversion(val, "LoxPieUncooked", "LoxPie", ConversionType.cooking, 50);
			addConversion(val, "MisthareSupremeUncooked", "MisthareSupreme", ConversionType.cooking, 50);
			addConversion(val, "Potato", "PotatoFried", ConversionType.cooking, 20);
			addConversion(val, "BreadDough", "Bread", ConversionType.cooking, 50);
			addConversion(val, "MeatPlatterUncooked", "MeatPlatter", ConversionType.cooking, 50);
			addConversion(val, "FishAndBreadUncooked", "FishAndBread", ConversionType.cooking, 50);
			addConversion(val, "HoneyGlazedChickenUncooked", "HoneyGlazedChicken", ConversionType.cooking, 50);
		}

		private void editWHeel()
		{
			GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "piece_spinningwheel");
			Smelter component = val.GetComponent<Smelter>();
			component.m_maxOre = 80;
			component.m_secPerProduct = 25f;
			addConversion(val, "Straw", "StrawThread", ConversionType.smelter);
			addConversion(val, "RawSilk", "SilkReinforcedThread", ConversionType.smelter);
		}

		private void editRefinery()
		{
			GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "eitrrefinery");
			Smelter component = val.GetComponent<Smelter>();
			component.m_maxOre = 60;
			component.m_maxFuel = 60;
			component.m_spawnStack = true;
			component.m_secPerProduct = 40f;
		}

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

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

		private void editKiln()
		{
			GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "charcoal_kiln");
			Smelter component = val.GetComponent<Smelter>();
			component.m_maxOre = 50;
			component.m_secPerProduct = 10f;
			addConversion(val, "Clay", "ClayBrick", ConversionType.smelter);
		}

		private void editBeehive()
		{
			GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "piece_beehive");
			Beehive component = val.GetComponent<Beehive>();
			component.m_maxHoney = 40;
		}

		private void addConversion(GameObject source, string nameIn, string nameOut, ConversionType type, int time = 30, int amount = 5)
		{
			switch (type)
			{
			case ConversionType.smelter:
				SmelterConversion(source, nameIn, nameOut);
				break;
			case ConversionType.fermenter:
				FermenterConversion(source, nameIn, nameOut, amount);
				break;
			case ConversionType.cooking:
				CookingConversion(source, nameIn, nameOut, time);
				break;
			case ConversionType.balrondConverter:
				BalrondConversion(source, nameIn, nameOut, amount);
				break;
			}
		}

		private void BalrondConversion(GameObject source, string nameIn, string nameOut, int amount = 1)
		{
			BalrondConverter component = source.GetComponent<BalrondConverter>();
			BalrondConverter.ItemConversion itemConversion = new BalrondConverter.ItemConversion();
			itemConversion.m_from = FindItem(nameIn).GetComponent<ItemDrop>();
			itemConversion.m_to = FindItem(nameOut).GetComponent<ItemDrop>();
			itemConversion.m_count = amount;
			component.m_conversion.Add(itemConversion);
		}

		private void SmelterConversion(GameObject source, string nameIn, string nameOut)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			Smelter component = source.GetComponent<Smelter>();
			ItemConversion val = new ItemConversion();
			val.m_from = FindItem(nameIn).GetComponent<ItemDrop>();
			val.m_to = FindItem(nameOut).GetComponent<ItemDrop>();
			component.m_conversion.Add(val);
		}

		private void FermenterConversion(GameObject source, string nameIn, string nameOut, int amount = 1)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			Fermenter component = source.GetComponent<Fermenter>();
			ItemConversion val = new ItemConversion();
			val.m_from = FindItem(nameIn).GetComponent<ItemDrop>();
			val.m_to = FindItem(nameOut).GetComponent<ItemDrop>();
			val.m_producedItems = amount;
			component.m_conversion.Add(val);
		}

		private void CookingConversion(GameObject source, string nameIn, string nameOut, int time = 25)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			CookingStation component = source.GetComponent<CookingStation>();
			ItemConversion val = new ItemConversion();
			val.m_from = FindItem(nameIn).GetComponent<ItemDrop>();
			val.m_to = FindItem(nameOut).GetComponent<ItemDrop>();
			val.m_cookTime = time;
			component.m_conversion.Add(val);
		}
	}
	public class CraftingStationEdits
	{
		private GameObject connectorVfx;

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

		private CraftingStationNaming craftingStationNaming = new CraftingStationNaming();

		private CraftingStationRecipes craftingStationRecipes = new CraftingStationRecipes();

		public void setup(List<GameObject> list)
		{
			buildPieces = list;
			GameObject val = list.Find((GameObject x) => ((Object)x).name == "forge_ext1");
			StationExtension component = val.GetComponent<StationExtension>();
			connectorVfx = component.m_connectionPrefab;
			retargetBuildpieceTables();
			AddExtensionToTables();
			editTableExtension();
			DisablePiece("piece_magetable");
			DisablePiece("piece_workbench_ext2");
		}

		private void retargetBuildpieceTables()
		{
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			craftingStationRecipes.setupTables(buildPieces);
			foreach (GameObject buildPiece in buildPieces)
			{
				Piece component = buildPiece.GetComponent<Piece>();
				Plant component2 = buildPiece.GetComponent<Plant>();
				if ((Object)(object)component == (Object)null || (Object)(object)component2 != (Object)null || (Object)(object)component.m_craftingStation == (Object)null)
				{
					continue;
				}
				if (((Object)component.m_craftingStation).name == "piece_artisanstation")
				{
					component.m_craftingStation = buildPieces.Find((GameObject x) => ((Object)x).name == "forge").GetComponent<CraftingStation>();
					List<Requirement> list = new List<Requirement>();
					list.AddRange(component.m_resources);
					Requirement val = new Requirement();
					val.m_amount = 1;
					val.m_recover = true;
					val.m_resItem = buildPieces.Find((GameObject x) => ((Object)x).name == "DragonTear").GetComponent<ItemDrop>();
					list.Add(val);
					component.m_resources = list.ToArray();
				}
				craftingStationRecipes.editBuildRecipeForPiece(component);
			}
		}

		private void DisablePiece(string name)
		{
			GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == name);
			Piece component = val.GetComponent<Piece>();
			((Behaviour)component).enabled = false;
			buildPieces.Remove(val);
		}

		private void AddExtensionToTables()
		{
			setupStationExtension("piece_fletcher", "piece_tannery");
			setupStationExtension("forge", "piece_workbench");
			setupStationExtension("piece_stonecutter", "piece_workbench");
			setupStationExtension("piece_tannery", "piece_workbench");
			setupStationExtension("piece_runeforge", "forge");
			setupStationExtension("blackforge", "forge");
			setupStationExtension("piece_oven", "piece_cauldron");
			setupStationExtension("piece_cookingstation_iron", "piece_grill");
			setupStationExtension("piece_grill", "piece_cauldron");
			setupStationExtension("piece_alchemylab", "piece_cauldron");
			setupStationExtension("piece_artisanstation", "piece_runeforge");
		}

		private void setupStationExtension(string tableName, string craftingStation, int range = 15)
		{
			GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == craftingStation);
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogWarning((object)("Target table not found: " + craftingStation));
				return;
			}
			GameObject val2 = buildPieces.Find((GameObject x) => ((Object)x).name == tableName);
			if ((Object)(object)val2 == (Object)null)
			{
				Debug.LogWarning((object)("Table not found: " + (object)val2));
				return;
			}
			Piece component = val2.GetComponent<Piece>();
			craftingStationNaming.pieceNaming(component);
			component.m_craftingStation = val.GetComponent<CraftingStation>();
			StationExtension val3 = val2.GetComponent<StationExtension>();
			if ((Object)(object)val3 == (Object)null)
			{
				val3 = val2.AddComponent<StationExtension>();
			}
			val3.m_connectionPrefab = connectorVfx;
			val3.m_craftingStation = val.GetComponent<CraftingStation>();
			val3.m_maxStationDistance = range;
		}

		private void editTableExtension()
		{
			updateTableExtension("cauldron_ext4_pots", "piece_grill");
			updateTableExtension("cauldron_ext3_butchertable", "piece_grill");
			updateTableExtension("cooking_ext9", "piece_cauldron");
			updateTableExtension("blackforge_ext2", "blackforge");
			updateTableExtension("blackforge_ext3", "blackforge");
			updateTableExtension("piece_magetable_ext", "piece_runeforge");
			updateTableExtension("piece_runeforge_ext4", "piece_runeforge");
			updateTableExtension("piece_runeforge_ext3", "piece_runeforge");
			updateTableExtension("fletcher_ext1", "piece_fletcher");
			updateTableExtension("fletcher_ext2", "piece_fletcher");
			updateTableExtension("alchemy_extension", "piece_alchemylab");
			updateTableExtension("alchemy_ext2", "piece_alchemylab");
			updateTableExtension("piece_sawmill", "piece_workbench");
			updateTableExtension("forge_ext2", "piece_tannery");
			updateTableExtension("tannery_ext2", "piece_tannery");
			updateTableExtension("piece_workbench_ext5", "piece_tannery");
			updateTableExtension("tannery_ext7", "piece_tannery");
			updateTableExtension("tannery_ext3", "piece_tannery");
		}

		private void updateTableExtension(string name, string targetName, int range = 15)
		{
			GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == targetName);
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogWarning((object)("Target Table not found: " + targetName));
				return;
			}
			GameObject val2 = buildPieces.Find((GameObject x) => ((Object)x).name == name);
			if ((Object)(object)val2 == (Object)null)
			{
				Debug.LogWarning((object)("Target Extension not found: " + name));
				return;
			}
			Piece component = val2.GetComponent<Piece>();
			if ((Object)(object)component != (Object)null)
			{
				craftingStationNaming.pieceNaming(component);
				component.m_craftingStation = val.GetComponent<CraftingStation>();
				StationExtension component2 = val2.GetComponent<StationExtension>();
				component2.m_connectionPrefab = connectorVfx;
				component2.m_craftingStation = val.GetComponent<CraftingStation>();
				component2.m_maxStationDistance = range;
			}
		}
	}
	internal class CraftingStationNaming
	{
		public void pieceNaming(Piece gameObject, bool isTable = false)
		{
			string text = "";
			string text2 = "";
			switch (((Object)gameObject).name)
			{
			case "piece_replace_ext3":
				text = "Carpenter station";
				text2 = "Used to covert wood. Workbench $piece_upgrade";
				break;
			case "fletcher_ext2":
				text = "Fletcher's arrow baskets";
				text2 = "Fletcher $piece_upgrade";
				break;
			case "fletcher_ext1":
				text = "Target Practice";
				text2 = "Fletcher $piece_upgrade";
				break;
			case "forge_ext2":
				text = "Anvils";
				text2 = "Tannery $piece_upgrade";
				break;
			case "tannery_ext2":
				text = "Animal Cages";
				text2 = "Tannery $piece_upgrade";
				break;
			case "piece_workbench_ext2":
				text = "Tanning Rack";
				text2 = "Tannery $piece_upgrade";
				break;
			case "tannery_ext7":
				text = "Crafting Supplies";
				text2 = "Tannery $piece_upgrade";
				break;
			case "tannery_ext3":
				text = "Weapon Rack";
				text2 = "Tannery $piece_upgrade";
				break;
			case "alchemy_extension":
				text = "Rostrum";
				text2 = "Alchemy lab $piece_upgrade";
				break;
			case "alchemy_ext2":
				text = "Destiller";
				text2 = "Alchemy lab $piece_upgrade";
				break;
			case "piece_magetable_ext":
				text = "Enchanted Stones";
				text2 = "Runeforge $piece_upgrade";
				break;
			case "piece_runeforge_ext4":
				text = "Spirit Altar";
				text2 = "Runeforge $piece_upgrade";
				break;
			case "piece_runeforge_ext3":
				text = "Sulfur boiler";
				text2 = "Runeforge $piece_upgrade";
				break;
			case "blackforge_ext3":
				text = "Molten Grinding stone";
				text2 = "Blackforge $piece_upgrade";
				break;
			case "blackforge_ext7":
				text = "Compact steelworks";
				text2 = "Blackforge $piece_upgrade. Can be used for quick smelting";
				break;
			case "cauldron_ext4_pots":
				text = "Pots and utensils";
				text2 = "Grill $piece_upgrade";
				break;
			case "cauldron_ext3_butchertable":
				text = "Butcher's Table";
				text2 = "Grill $piece_upgrade";
				break;
			case "smoker_ext":
				text = "Food smoker";
				text2 = "Used for long cooking. Grill $piece_upgrade";
				break;
			case "cooking_ext9":
				text = "Fishing Rack";
				text2 = "Cauldron $piece_upgrade";
				break;
			case "piece_fletcher":
				text = "Fleather's table";
				text2 = "$piece_craftingstation. Tanner $piece_upgrade";
				break;
			case "forge":
				text2 = "$piece_craftingstation. Workbench $piece_upgrade";
				break;
			case "piece_tannery":
				text = "Tanner Table";
				text2 = "$piece_craftingstation. Workbench $piece_upgrade";
				break;
			case "piece_runeforge":
				text = "Runeforge";
				text2 = "$piece_craftingstation. Forge $piece_upgrade";
				break;
			case "blackforge":
				text2 = "$piece_craftingstation. Forge $piece_upgrade";
				break;
			case "piece_oven":
				text2 = "$piece_craftingstation. Cauldron $piece_upgrade";
				break;
			case "piece_grill":
				text = "Stone Grill";
				text2 = "$piece_craftingstation. Cauldron $piece_upgrade";
				break;
			case "piece_alchemylab":
				text = "Alchemy lab";
				text2 = "$piece_craftingstation. Cauldron $piece_upgrade";
				break;
			case "piece_artisanstation":
				text2 = "$piece_craftingstation. Runforge $piece_upgrade";
				break;
			}
			if (text != "")
			{
				gameObject.m_name = text;
			}
			if (isTable)
			{
				gameObject.m_description += text2;
			}
			else if (text2 != "" && text2 != " ")
			{
				gameObject.m_description = text2;
			}
		}
	}
	internal class CraftingStationRecipes
	{
		private List<GameObject> buildPieces = new List<GameObject>();

		private GameObject workbench;

		private GameObject tannery;

		private GameObject runeForge;

		private GameObject alchemyLab;

		private GameObject grill;

		private GameObject fletcher;

		private GameObject blackforge;

		private GameObject forge;

		private GameObject cauldron;

		private GameObject stonecutter;

		public void setupTables(List<GameObject> buildPieces)
		{
			this.buildPieces = buildPieces;
			workbench = buildPieces.Find((GameObject x) => ((Object)x).name == "piece_workbench");
			if ((Object)(object)workbench == (Object)null)
			{
				Debug.LogWarning((object)"Did not foundpiece_workbench");
			}
			tannery = buildPieces.Find((GameObject x) => ((Object)x).name == "piece_tannery");
			if ((Object)(object)tannery == (Object)null)
			{
				Debug.LogWarning((object)"Did not foundpiece_tannery");
				tannery = workbench;
			}
			blackforge = buildPieces.Find((GameObject x) => ((Object)x).name == "blackforge");
			if ((Object)(object)blackforge == (Object)null)
			{
				Debug.LogWarning((object)"Did not foundblackforge");
			}
			forge = buildPieces.Find((GameObject x) => ((Object)x).name == "forge");
			if ((Object)(object)forge == (Object)null)
			{
				Debug.LogWarning((object)"Did not foundforge");
			}
			cauldron = buildPieces.Find((GameObject x) => ((Object)x).name == "piece_cauldron");
			if ((Object)(object)cauldron == (Object)null)
			{
				Debug.LogWarning((object)"Did not foundpiece_cauldron");
			}
			runeForge = buildPieces.Find((GameObject x) => ((Object)x).name == "piece_runeforge");
			if ((Object)(object)runeForge == (Object)null)
			{
				Debug.LogWarning((object)"Did not foundpiece_runeforge");
				runeForge = forge;
			}
			alchemyLab = buildPieces.Find((GameObject x) => ((Object)x).name == "piece_alchemylab");
			if ((Object)(object)alchemyLab == (Object)null)
			{
				Debug.LogWarning((object)"Did not foundpiece_alchemylab");
				alchemyLab = cauldron;
			}
			grill = buildPieces.Find((GameObject x) => ((Object)x).name == "piece_grill");
			if ((Object)(object)grill == (Object)null)
			{
				Debug.LogWarning((object)"Did not foundpiece_grill");
				grill = cauldron;
			}
			fletcher = buildPieces.Find((GameObject x) => ((Object)x).name == "piece_fletcher");
			if ((Object)(object)fletcher == (Object)null)
			{
				Debug.LogWarning((object)"Did not foundpiece_fletcher");
				fletcher = workbench;
			}
		}

		public void editBuildRecipeForPiece(Piece piece)
		{
			List<Requirement> list = new List<Requirement>();
			switch (((Object)((Component)piece).gameObject).name)
			{
			case "piece_sawmill":
				piece.m_craftingStation = workbench.GetComponent<CraftingStation>();
				list.Add(createReq("FineWood", 10, 6));
				list.Add(createReq("Bronze", 5, 0));
				break;
			case "fletcher_ext2":
				piece.m_craftingStation = fletcher.GetComponent<CraftingStation>();
				list.Add(createReq("ArrowBronze", 50, 6));
				list.Add(createReq("ArrowFlint", 50, 0));
				list.Add(createReq("Wood", 2, 0));
				list.Add(createReq("Iron", 2, 0));
				break;
			case "fletcher_ext1":
				piece.m_craftingStation = fletcher.GetComponent<CraftingStation>();
				list.Add(createReq("Wood", 10, 6));
				list.Add(createReq("LeatherScraps", 10, 0));
				list.Add(createReq("Bloodbag", 2, 0));
				break;
			case "forge_ext2":
				piece.m_craftingStation = tannery.GetComponent<CraftingStation>();
				list.Add(createReq("Wood", 10, 6));
				list.Add(createReq("Bronze", 10, 0));
				break;
			case "tannery_ext2":
				piece.m_craftingStation = tannery.GetComponent<CraftingStation>();
				list.Add(createReq("Wood", 10, 6));
				list.Add(createReq("LeatherScraps", 10, 0));
				list.Add(createReq("Resin", 2, 0));
				break;
			case "piece_workbench_ext2":
				piece.m_craftingStation = tannery.GetComponent<CraftingStation>();
				list.Add(createReq("Wood", 10, 6));
				list.Add(createReq("LeatherScraps", 10, 0));
				list.Add(createReq("Flint", 2, 0));
				list.Add(createReq("Resin", 2, 0));
				break;
			case "tannery_ext7":
				piece.m_craftingStation = tannery.GetComponent<CraftingStation>();
				list.Add(createReq("RoundLog", 10, 6));
				list.Add(createReq("Iron", 10, 0));
				list.Add(createReq("Bronze", 2, 0));
				list.Add(createReq("FineWood", 2, 0));
				break;
			case "tannery_ext3":
				piece.m_craftingStation = tannery.GetComponent<CraftingStation>();
				list.Add(createReq("PickaxeAntler", 10, 6));
				list.Add(createReq("ShieldWood", 10, 0));
				list.Add(createReq("AxeBronze", 2, 0));
				list.Add(createReq("Battleaxe", 2, 0));
				break;
			case "piece_fletcher":
				piece.m_craftingStation = tannery.GetComponent<CraftingStation>();
				list.Add(createReq("FineWood", 10, 0));
				list.Add(createReq("ArrowFlint", 50, 0));
				list.Add(createReq("DeerHide", 2, 0));
				list.Add(createReq("Iron", 2, 0));
				break;
			case "alchemy_extension":
				piece.m_craftingStation = alchemyLab.GetComponent<CraftingStation>();
				list.Add(createReq("Honey", 10, 6));
				list.Add(createReq("FineWood", 10, 0));
				list.Add(createReq("Resin", 2, 0));
				list.Add(createReq("DeerHide", 2, 0));
				break;
			case "alchemy_ext2":
				piece.m_craftingStation = alchemyLab.GetComponent<CraftingStation>();
				list.Add(createReq("Iron", 10, 6));
				list.Add(createReq("FineWood", 10, 0));
				list.Add(createReq("Resin", 2, 0));
				list.Add(createReq("WolfPelt", 2, 0));
				break;
			case "piece_magetable_ext":
				piece.m_craftingStation = runeForge.GetComponent<CraftingStation>();
				list.Add(createReq("BlackMarble", 10, 6));
				list.Add(createReq("Eitr", 10, 0));
				list.Add(createReq("YggdrasilWood", 2, 0));
				break;
			case "piece_runeforge_ext4":
				piece.m_craftingStation = runeForge.GetComponent<CraftingStation>();
				list.Add(createReq("BlackCore", 10, 6));
				list.Add(createReq("BlackMetal", 10, 0));
				list.Add(createReq("YggdrasilWood", 2, 0));
				break;
			case "piece_runeforge_ext3":
				piece.m_craftingStation = runeForge.GetComponent<CraftingStation>();
				list.Add(createReq("BlackMetal", 10, 6));
				list.Add(createReq("FineWood", 10, 0));
				list.Add(createReq("SurtlingCore", 2, 0));
				list.Add(createReq("RoyalJelly", 2, 0));
				break;
			case "piece_artisanstation":
				piece.m_craftingStation = runeForge.GetComponent<CraftingStation>();
				list.Add(createReq("FineWood", 10, 0));
				list.Add(createReq("GreydwarfEye", 10, 0));
				list.Add(createReq("DragonTear", 1, 0));
				break;
			case "blackforge_ext2":
				piece.m_craftingStation = blackforge.GetComponent<CraftingStation>();
				list.Add(createReq("BlackMarble", 10, 6));
				list.Add(createReq("Eitr", 10, 0));
				list.Add(createReq("YggdrasilWood", 2, 0));
				break;
			case "blackforge_ext3":
				piece.m_craftingStation = blackforge.GetComponent<CraftingStation>();
				list.Add(createReq("BlackMarble", 10, 6));
				list.Add(createReq("Eitr", 10, 0));
				list.Add(createReq("YggdrasilWood", 2, 0));
				break;
			case "blackforge":
				piece.m_craftingStation = forge.GetComponent<CraftingStation>();
				list.Add(createReq("BlackMarble", 10, 0));
				list.Add(createReq("BlackCore", 5, 0));
				list.Add(createReq("BlackMetal", 10, 0));
				list.Add(createReq("YggdrasilWood", 10, 0));
				break;
			case "piece_runeforge":
				piece.m_craftingStation = forge.GetComponent<CraftingStation>();
				list.Add(createReq("FineWood", 10, 0));
				list.Add(createReq("Darksteel", 10, 0));
				list.Add(createReq("Resin", 20, 0));
				list.Add(createReq("SurtlingCore", 5, 0));
				break;
			case "cauldron_ext4_pots":
				piece.m_craftingStation = grill.GetComponent<CraftingStation>();
				list.Add(createReq("Copper", 10, 6));
				list.Add(createReq("BlackMetal", 10, 6));
				list.Add(createReq("Iron", 10, 0));
				list.Add(createReq("Silver", 2, 0));
				break;
			case "cauldron_ext3_butchertable":
				piece.m_craftingStation = grill.GetComponent<CraftingStation>();
				list.Add(createReq("ElderBark", 10, 6));
				list.Add(createReq("RoundLog", 10, 0));
				list.Add(createReq("FineWood", 2, 0));
				break;
			case "smoker_ext":
				piece.m_craftingStation = grill.GetComponent<CraftingStation>();
				list.Add(createReq("BlackMarble", 10, 6));
				list.Add(createReq("SurtlingCore", 2, 0));
				list.Add(createReq("YggdrasilWood", 2, 0));
				break;
			case "cooking_ext9":
				piece.m_craftingStation = cauldron.GetComponent<CraftingStation>();
				list.Add(createReq("FineWood", 10, 0));
				list.Add(createReq("FishRaw", 10, 0));
				list.Add(createReq("LeatherScraps", 10, 0));
				break;
			case "piece_oven":
				piece.m_craftingStation = cauldron.GetComponent<CraftingStation>();
				list.Add(createReq("Wood", 15, 6));
				list.Add(createReq("Stone", 20, 0));
				list.Add(createReq("Iron", 15, 0));
				list.Add(createReq("SurtlingCore", 5, 0));
				break;
			case "piece_grill":
				piece.m_craftingStation = cauldron.GetComponent<CraftingStation>();
				list.Add(createReq("FineWood", 10, 6));
				list.Add(createReq("Stone", 30, 0));
				list.Add(createReq("Iron", 10, 0));
				break;
			case "piece_alchemylab":
				piece.m_craftingStation = cauldron.GetComponent<CraftingStation>();
				list.Add(createReq("Tin", 10, 6));
				list.Add(createReq("FineWood", 10, 0));
				list.Add(createReq("Resin", 2, 0));
				list.Add(createReq("DeerHide", 2, 0));
				break;
			case "forge":
				piece.m_craftingStation = workbench.GetComponent<CraftingStation>();
				list.Add(createReq("Wood", 10, 6));
				list.Add(createReq("Stone", 4, 0));
				list.Add(createReq("Copper", 6, 0));
				list.Add(createReq("Coal", 4, 0));
				break;
			case "piece_tannery":
				piece.m_craftingStation = workbench.GetComponent<CraftingStation>();
				list.Add(createReq("Wood", 10, 0));
				list.Add(createReq("Resin", 10, 0));
				list.Add(createReq("LeatherScraps", 20, 0));
				list.Add(createReq("TrophyBoar", 1, 0));
				break;
			case "piece_stonecutter":
				piece.m_craftingStation = workbench.GetComponent<CraftingStation>();
				list.Add(createReq("FineWood", 10, 0));
				list.Add(createReq("Bronze", 10, 0));
				list.Add(createReq("Stone", 10, 0));
				break;
			case "piece_metalworks":
				piece.m_craftingStation = workbench.GetComponent<CraftingStation>();
				list.Add(createReq("Wood", 5, 0));
				list.Add(createReq("Copper", 3, 0));
				break;
			default:
				list.AddRange(piece.m_resources);
				break;
			}
			if (list.Count == 0)
			{
				Debug.LogWarning((object)(Launch.projectName + " " + ((Object)piece).name + " Build Piece resource is empty!"));
			}
			piece.m_resources = 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 component = buildPieces.Find((GameObject x) => ((Object)x).name == name).GetComponent<ItemDrop>();
			if ((Object)(object)component == (Object)null)
			{
				component = buildPieces.Find((GameObject x) => ((Object)x).name == name).GetComponent<ItemDrop>();
			}
			if ((Object)(object)component == (Object)null)
			{
				Debug.LogWarning((object)(name + " Item not found replace with wood"));
				component = buildPieces.Find((GameObject x) => ((Object)x).name == "Wood").GetComponent<ItemDrop>();
			}
			val.m_resItem = component;
			val.m_amount = amount;
			val.m_amountPerLevel = amountPerLevel;
			return val;
		}
	}
	public class BalrondConverter : MonoBehaviour
	{
		[Serializable]
		public class ItemConversion
		{
			public ItemDrop m_from;

			public ItemDrop m_to;

			public int m_count;
		}

		public string m_name = "BalrondConverter";

		public string m_addOreTooltip = "Add Non-Base Wood";

		public string m_emptyOreTooltip = "Pick up wood";

		public Switch m_addWoodSwitch;

		public Switch m_addOreSwitch;

		public Switch m_emptyOreSwitch;

		public Transform m_outputPoint;

		public Transform m_roofCheckPoint;

		public GameObject m_enabledObject;

		public GameObject m_disabledObject;

		public GameObject m_haveFuelObject;

		public GameObject m_haveOreObject;

		public GameObject m_noOreObject;

		public Animator[] m_animators;

		public ItemDrop m_fuelItem;

		public int m_maxOre = 1;

		public int m_maxFuel = 1;

		public int m_fuelPerProduct = 0;

		public float m_secPerProduct = 30f;

		public bool m_spawnStack = true;

		public bool m_requiresRoof = false;

		public Windmill m_windmill;

		public SmokeSpawner m_smokeSpawner;

		public float m_addOreAnimationDuration;

		public List<ItemConversion> m_conversion = new List<ItemConversion>();

		public EffectList m_oreAddedEffects = new EffectList();

		public EffectList m_fuelAddedEffects = new EffectList();

		public EffectList m_produceEffects = new EffectList();

		private ZNetView m_nview;

		private bool m_haveRoof;

		private bool m_blockedSmoke;

		private float m_addedOreTime = -1000f;

		private StringBuilder m_sb = new StringBuilder();

		private void Awake()
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Expected O, but got Unknown
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Expected O, but got Unknown
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Expected O, but got Unknown
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Expected O, but got Unknown
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Expected O, but got Unknown
			m_nview = ((Component)this).GetComponent<ZNetView>();
			if (!((Object)(object)m_nview == (Object)null) && m_nview.GetZDO() != null)
			{
				if (Object.op_Implicit((Object)(object)m_addOreSwitch))
				{
					Switch addOreSwitch = m_addOreSwitch;
					addOreSwitch.m_onUse = (Callback)Delegate.Combine((Delegate?)(object)addOreSwitch.m_onUse, (Delegate?)new Callback(OnAddWood));
					m_addOreSwitch.m_onHover = new TooltipCallback(OnHoverAddWood);
				}
				if (Object.op_Implicit((Object)(object)m_addWoodSwitch))
				{
					Switch addWoodSwitch = m_addWoodSwitch;
					addWoodSwitch.m_onUse = (Callback)Delegate.Combine((Delegate?)(object)addWoodSwitch.m_onUse, (Delegate?)new Callback(OnAddPowerSource));
					m_addWoodSwitch.m_onHover = new TooltipCallback(OnHoverAddPowerSource);
				}
				if (Object.op_Implicit((Object)(object)m_emptyOreSwitch))
				{
					Switch emptyOreSwitch = m_emptyOreSwitch;
					emptyOreSwitch.m_onUse = (Callback)Delegate.Combine((Delegate?)(object)emptyOreSwitch.m_onUse, (Delegate?)new Callback(OnEmpty));
					Switch emptyOreSwitch2 = m_emptyOreSwitch;
					emptyOreSwitch2.m_onHover = (TooltipCallback)Delegate.Combine((Delegate?)(object)emptyOreSwitch2.m_onHover, (Delegate?)new TooltipCallback(OnHoverEmptyOre));
				}
				m_nview.Register<string>("AddWood", (Action<long, string>)RPC_AddWood);
				m_nview.Register("AddPowerSource", (Action<long>)RPC_AddPowerSource);
				m_nview.Register("ConverterEmptyProcessed", (Action<long>)RPC_ConverterEmptyProcessed);
				WearNTear component = ((Component)this).GetComponent<WearNTear>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.m_onDestroyed = (Action)Delegate.Combine(component.m_onDestroyed, new Action(OnDestroyed));
				}
				((MonoBehaviour)this).InvokeRepeating("UpdateBalrondConverter", 1f, 1f);
			}
		}

		private void DropAllItems()
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			SpawnProcessed();
			if ((Object)(object)m_fuelItem != (Object)null)
			{
				float @float = m_nview.GetZDO().GetFloat(ZDOVars.s_fuel, 0f);
				for (int i = 0; i < (int)@float; i++)
				{
					Object.Instantiate<GameObject>(((Component)m_fuelItem).gameObject, ((Component)this).transform.position + Vector3.up + Random.insideUnitSphere * 0.3f, Quaternion.Euler(0f, (float)Random.Range(0, 360), 0f));
				}
			}
			while (GetQueueSize() > 0)
			{
				string queuedOre = GetQueuedOre();
				RemoveOneOre();
				ItemConversion itemConversion = GetItemConversion(queuedOre);
				if (itemConversion != null)
				{
					Vector3 val = ((Component)this).transform.position + Vector3.up + Random.insideUnitSphere * 0.3f;
					Quaternion val2 = Quaternion.Euler(0f, (float)Random.Range(0, 360), 0f);
					Object.Instantiate<GameObject>(((Component)itemConversion.m_from).gameObject, val, val2);
				}
			}
		}

		private void OnDestroyed()
		{
			if (m_nview.IsOwner())
			{
				DropAllItems();
			}
		}

		private bool IsItemAllowed(ItemData item)
		{
			return IsItemAllowed(((Object)item.m_dropPrefab).name);
		}

		private bool IsItemAllowed(string itemName)
		{
			foreach (ItemConversion item in m_conversion)
			{
				if (((Object)((Component)item.m_from).gameObject).name == itemName)
				{
					return true;
				}
			}
			return false;
		}

		private ItemData FindCookableItem(Inventory inventory)
		{
			foreach (ItemConversion item2 in m_conversion)
			{
				ItemData item = inventory.GetItem(item2.m_from.m_itemData.m_shared.m_name, -1, false);
				if (item != null)
				{
					return item;
				}
			}
			return null;
		}

		private bool OnAddWood(Switch sw, Humanoid user, ItemData item)
		{
			if (item == null)
			{
				item = FindCookableItem(user.GetInventory());
				if (item == null)
				{
					((Character)user).Message((MessageType)2, "$msg_noprocessableitems", 0, (Sprite)null);
					return false;
				}
			}
			if (!IsItemAllowed(((Object)item.m_dropPrefab).name))
			{
				((Character)user).Message((MessageType)2, "$msg_wontwork", 0, (Sprite)null);
				return false;
			}
			ZLog.Log((object)("trying to add " + item.m_shared.m_name));
			if (GetQueueSize() >= m_maxOre)
			{
				((Character)user).Message((MessageType)2, "$msg_itsfull", 0, (Sprite)null);
				return false;
			}
			((Character)user).Message((MessageType)2, "$msg_added " + item.m_shared.m_name, 0, (Sprite)null);
			user.GetInventory().RemoveItem(item, 1);
			m_nview.InvokeRPC("AddWood", new object[1] { ((Object)item.m_dropPrefab).name });
			m_addedOreTime = Time.time;
			if ((double)m_addOreAnimationDuration > 0.0)
			{
				SetAnimation(active: true);
			}
			return true;
		}

		private float GetBakeTimer()
		{
			return m_nview.GetZDO().GetFloat(ZDOVars.s_bakeTimer, 0f);
		}

		private void SetBakeTimer(float t)
		{
			m_nview.GetZDO().Set(ZDOVars.s_bakeTimer, t);
		}

		private float GetFuel()
		{
			return m_nview.GetZDO().GetFloat(ZDOVars.s_fuel, 0f);
		}

		private void SetFuel(float fuel)
		{
			m_nview.GetZDO().Set(ZDOVars.s_fuel, fuel);
		}

		private int GetQueueSize()
		{
			return m_nview.GetZDO().GetInt(ZDOVars.s_queued, 0);
		}

		private void RPC_AddWood(long sender, string name)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			if (m_nview.IsOwner())
			{
				if (!IsItemAllowed(name))
				{
					ZLog.Log((object)("Item not allowed " + name));
					return;
				}
				QueueOre(name);
				m_oreAddedEffects.Create(((Component)this).transform.position, ((Component)this).transform.rotation, (Transform)null, 1f, -1);
				ZLog.Log((object)("Added ore " + name));
			}
		}

		private void QueueOre(string name)
		{
			int queueSize = GetQueueSize();
			m_nview.GetZDO().Set("item" + queueSize, name);
			m_nview.GetZDO().Set(ZDOVars.s_queued, queueSize + 1, false);
		}

		private string GetQueuedOre()
		{
			return (GetQueueSize() == 0) ? "" : m_nview.GetZDO().GetString(ZDOVars.s_item0, "");
		}

		private void RemoveOneOre()
		{
			int queueSize = GetQueueSize();
			if (queueSize != 0)
			{
				for (int i = 0; i < queueSize; i++)
				{
					string @string = m_nview.GetZDO().GetString("item" + (i + 1), "");
					m_nview.GetZDO().Set("item" + i, @string);
				}
				m_nview.GetZDO().Set(ZDOVars.s_queued, queueSize - 1, false);
			}
		}

		private bool OnEmpty(Switch sw, Humanoid user, ItemData item)
		{
			if (GetProcessedQueueSize() <= 0)
			{
				return false;
			}
			m_nview.InvokeRPC("ConverterEmptyProcessed", Array.Empty<object>());
			return true;
		}

		private void RPC_ConverterEmptyProcessed(long sender)
		{
			if (m_nview.IsOwner())
			{
				SpawnProcessed();
			}
		}

		private bool OnAddPowerSource(Switch sw, Humanoid user, ItemData item)
		{
			if (item != null && item.m_shared.m_name != m_fuelItem.m_itemData.m_shared.m_name)
			{
				((Character)user).Message((MessageType)2, "$msg_wrongitem", 0, (Sprite)null);
				return false;
			}
			if ((double)GetFuel() > (double)(m_maxFuel - 1))
			{
				((Character)user).Message((MessageType)2, "$msg_itsfull", 0, (Sprite)null);
				return false;
			}
			if (!user.GetInventory().HaveItem(m_fuelItem.m_itemData.m_shared.m_name, true))
			{
				((Character)user).Message((MessageType)2, "$msg_donthaveany " + m_fuelItem.m_itemData.m_shared.m_name, 0, (Sprite)null);
				return false;
			}
			((Character)user).Message((MessageType)2, "$msg_added " + m_fuelItem.m_itemData.m_shared.m_name, 0, (Sprite)null);
			user.GetInventory().RemoveItem(m_fuelItem.m_itemData.m_shared.m_name, 1, -1, true);
			m_nview.InvokeRPC("AddPowerSource", Array.Empty<object>());
			return true;
		}

		private void RPC_AddPowerSource(long sender)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			if (m_nview.IsOwner())
			{
				SetFuel(GetFuel() + 1f);
				m_fuelAddedEffects.Create(((Component)this).transform.position, ((Component)this).transform.rotation, ((Component)this).transform, 1f, -1);
			}
		}

		private double GetDeltaTime()
		{
			DateTime time = ZNet.instance.GetTime();
			DateTime dateTime = new DateTime(m_nview.GetZDO().GetLong(ZDOVars.s_startTime, time.Ticks));
			double totalSeconds = (time - dateTime).TotalSeconds;
			m_nview.GetZDO().Set(ZDOVars.s_startTime, time.Ticks);
			return totalSeconds;
		}

		private float GetAccumulator()
		{
			return m_nview.GetZDO().GetFloat(ZDOVars.s_accTime, 0f);
		}

		private void SetAccumulator(float t)
		{
			m_nview.GetZDO().Set(ZDOVars.s_accTime, t);
		}

		private void UpdateRoof()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (m_requiresRoof)
			{
				m_haveRoof = Cover.IsUnderRoof(m_roofCheckPoint.position);
			}
		}

		private void UpdateSmoke()
		{
			if ((Object)(object)m_smokeSpawner != (Object)null)
			{
				m_blockedSmoke = m_smokeSpawner.IsBlocked();
			}
			else
			{
				m_blockedSmoke = false;
			}
		}

		private void UpdateBalrondConverter()
		{
			if (!m_nview.IsValid())
			{
				return;
			}
			UpdateRoof();
			UpdateSmoke();
			UpdateState();
			if (!m_nview.IsOwner())
			{
				return;
			}
			double deltaTime = GetDeltaTime();
			float num = GetAccumulator() + (float)deltaTime;
			if ((double)num > 3600.0)
			{
				num = 3600f;
			}
			float num2 = (Object.op_Implicit((Object)(object)m_windmill) ? m_windmill.GetPowerOutput() : 1f);
			while ((double)num >= 1.0)
			{
				num -= 1f;
				float fuel = GetFuel();
				string queuedOre = GetQueuedOre();
				if ((m_maxFuel != 0 && !((double)fuel > 0.0)) || (m_maxOre != 0 && !(queuedOre != "")) || !((double)m_secPerProduct > 0.0) || (m_requiresRoof && !m_haveRoof) || m_blockedSmoke)
				{
					continue;
				}
				float num3 = 1f * num2;
				if (m_maxFuel > 0)
				{
					float num4 = m_secPerProduct / (float)m_fuelPerProduct;
					float num5 = fuel - num3 / num4;
					if ((double)num5 < 9.99999974737875E-05)
					{
						num5 = 0f;
					}
					SetFuel(num5);
				}
				if (queuedOre != "")
				{
					float num6 = GetBakeTimer() + num3;
					SetBakeTimer(num6);
					if ((double)num6 >= (double)m_secPerProduct)
					{
						SetBakeTimer(0f);
						RemoveOneOre();
						QueueProcessed(queuedOre);
					}
				}
			}
			if (GetQueuedOre() == "" || ((double)m_maxFuel > 0.0 && (double)GetFuel() == 0.0))
			{
				SpawnProcessed();
			}
			SetAccumulator(num);
		}

		private void QueueProcessed(string ore)
		{
			if (!m_spawnStack)
			{
				Spawn(ore, 1);
				return;
			}
			string @string = m_nview.GetZDO().GetString(ZDOVars.s_spawnOre, "");
			int @int = m_nview.GetZDO().GetInt(ZDOVars.s_spawnAmount, 0);
			if (@string.Length > 0)
			{
				if (@string != ore)
				{
					SpawnProcessed();
					m_nview.GetZDO().Set(ZDOVars.s_spawnOre, ore);
					m_nview.GetZDO().Set(ZDOVars.s_spawnAmount, 1, false);
					return;
				}
				int num = @int + 1;
				ItemConversion itemConversion = GetItemConversion(ore);
				if (itemConversion == null || num >= itemConversion.m_to.m_itemData.m_shared.m_maxStackSize)
				{
					Spawn(ore, num);
					m_nview.GetZDO().Set(ZDOVars.s_spawnOre, "");
					m_nview.GetZDO().Set(ZDOVars.s_spawnAmount, 0, false);
				}
				else
				{
					m_nview.GetZDO().Set(ZDOVars.s_spawnAmount, num, false);
				}
			}
			else
			{
				m_nview.GetZDO().Set(ZDOVars.s_spawnOre, ore);
				m_nview.GetZDO().Set(ZDOVars.s_spawnAmount, 1, false);
			}
		}

		private void SpawnProcessed()
		{
			int @int = m_nview.GetZDO().GetInt(ZDOVars.s_spawnAmount, 0);
			if (@int > 0)
			{
				Spawn(m_nview.GetZDO().GetString(ZDOVars.s_spawnOre, ""), @int);
				m_nview.GetZDO().Set(ZDOVars.s_spawnOre, "");
				m_nview.GetZDO().Set(ZDOVars.s_spawnAmount, 0, false);
			}
		}

		private int GetProcessedQueueSize()
		{
			return m_nview.GetZDO().GetInt(ZDOVars.s_spawnAmount, 0);
		}

		private void Spawn(string ore, int stack)
		{
			//IL_001f: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			ItemConversion itemConversion = GetItemConversion(ore);
			if (itemConversion != null)
			{
				m_produceEffects.Create(((Component)this).transform.position, ((Component)this).transform.rotation, (Transform)null, 1f, -1);
				Object.Instantiate<GameObject>(((Component)itemConversion.m_to).gameObject, m_outputPoint.position, m_outputPoint.rotation).GetComponent<ItemDrop>().m_itemData.m_stack = stack;
			}
		}

		private ItemConversion GetItemConversion(string itemName)
		{
			foreach (ItemConversion item in m_conversion)
			{
				if (((Object)((Component)item.m_from).gameObject).name == itemName)
				{
					return item;
				}
			}
			return null;
		}

		private void UpdateState()
		{
			bool flag = IsActive();
			m_enabledObject.SetActive(flag);
			if (Object.op_Implicit((Object)(object)m_disabledObject))
			{
				m_disabledObject.SetActive(!flag);
			}
			if (Object.op_Implicit((Object)(object)m_haveFuelObject))
			{
				m_haveFuelObject.SetActive((double)GetFuel() > 0.0);
			}
			if (Object.op_Implicit((Object)(object)m_haveOreObject))
			{
				m_haveOreObject.SetActive(GetQueueSize() > 0);
			}
			if (Object.op_Implicit((Object)(object)m_noOreObject))
			{
				m_noOreObject.SetActive(GetQueueSize() == 0);
			}
			if ((double)m_addOreAnimationDuration > 0.0 && (double)Time.time - (dou

plugins/BalrondServerCore.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.Versioning;
using System.Security;
using System.Security.Permissions;
using BalrondServerCore;
using BepInEx;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace BalrondMadnessWorld
{
	[BepInPlugin("balrond.astafaraios.BalrondServerCore", "BalrondServerCore", "1.0.3")]
	public class Launch : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(Player), "SetControls")]
		private static class SetControls
		{
			private static void Prefix(Player __instance, ref bool jump)
			{
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Expected O, but got Unknown
				if (((Character)__instance).IsRiding() & jump)
				{
					Sadle val = (Sadle)__instance.m_doodadController;
					if ((Object)(object)val != (Object)null)
					{
						((BaseAI)val.m_monsterAI).m_character.Jump(false);
						jump = false;
					}
				}
				else if (((Character)__instance).IsRiding())
				{
					jump = false;
				}
			}
		}

		[HarmonyPatch(typeof(SE_Demister), "Setup")]
		internal static class SeDemisterPatch
		{
			private static void Postfix(SE_Demister __instance)
			{
				ParticleSystemForceField component = ((Component)Utils.FindChild(__instance.m_ballInstance.transform, "Particle System Force Field")).GetComponent<ParticleSystemForceField>();
				component.endRange *= 5f;
			}
		}

		[HarmonyPatch(typeof(ObjectDB), "Awake")]
		public static class ObjectDB_Awake_Path
		{
			public static void Prefix(ObjectDB __instance)
			{
				List<GameObject> items = __instance.m_items;
				change.editItems(items);
			}
		}

		[HarmonyPatch(typeof(InventoryGui), "Awake")]
		public static class RepairAllItems
		{
			private static void Postfix(ref InventoryGui __instance)
			{
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Expected O, but got Unknown
				((UnityEvent)__instance.m_repairButton.onClick).AddListener(new UnityAction(RepairAll));
			}

			private static bool canRepair(ItemData item)
			{
				Recipe recipe = ObjectDB.instance.GetRecipe(item);
				CraftingStation currentCraftingStation = Player.m_localPlayer.GetCurrentCraftingStation();
				bool result = true;
				if ((Object)(object)recipe == (Object)null || (Object)(object)currentCraftingStation == (Object)null || ((Object)(object)recipe.m_craftingStation == (Object)null && (Object)(object)recipe.m_repairStation == (Object)null))
				{
					return false;
				}
				return result;
			}

			private static void RepairAll()
			{
				//IL_0095: Unknown result type (might be due to invalid IL or missing references)
				//IL_009a: Unknown result type (might be due to invalid IL or missing references)
				int num = 0;
				CraftingStation currentCraftingStation = Player.m_localPlayer.GetCurrentCraftingStation();
				foreach (ItemData allItem in ((Humanoid)Player.m_localPlayer).GetInventory().GetAllItems())
				{
					if (canRepair(allItem) && (double)allItem.m_durability < (double)allItem.GetMaxDurability())
					{
						num++;
						allItem.m_durability = allItem.GetMaxDurability();
					}
				}
				if (Object.op_Implicit((Object)(object)currentCraftingStation))
				{
					currentCraftingStation.m_repairItemDoneEffects.Create(((Component)currentCraftingStation).transform.position, Quaternion.identity, (Transform)null, 1f, -1);
				}
				((Character)Player.m_localPlayer).Message((MessageType)2, num + 1 + " item" + ((num + 1 > 1) ? "s" : "") + " repaired!", 0, (Sprite)null);
			}
		}

		[HarmonyPatch(typeof(ZNetScene), "Awake")]
		public static class ZNetScene_Awake_Path
		{
			public static bool done;

			public static void Prefix(ZNetScene __instance)
			{
				if (done)
				{
					return;
				}
				List<GameObject> list = __instance.m_prefabs.FindAll((GameObject x) => (Object)(object)x.GetComponent<Piece>() != (Object)null);
				List<GameObject> list2 = __instance.m_prefabs.FindAll((GameObject x) => (Object)(object)x.GetComponent<ItemDrop>() != (Object)null);
				List<GameObject> list3 = __instance.m_prefabs.FindAll((GameObject x) => (Object)(object)x.GetComponent<MonsterAI>() != (Object)null);
				List<GameObject> list4 = __instance.m_prefabs.FindAll((GameObject x) => (Object)(object)x.GetComponent<AnimalAI>() != (Object)null);
				buildPieceTargeting.changePieceTargeting(list);
				foreach (GameObject item in list2)
				{
					ItemDrop component = item.GetComponent<ItemDrop>();
					component.m_itemData.m_shared.m_teleportable = true;
					DestroyLeftover destroyLeftover = item.GetComponent<DestroyLeftover>();
					if ((Object)(object)destroyLeftover == (Object)null)
					{
						destroyLeftover = item.AddComponent<DestroyLeftover>();
					}
					destroyLeftover.m_timeout = destructionTime;
					destroyLeftover.m_triggerOnAwake = true;
				}
				GameObject player = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "Player");
				changePlayer(player);
				buildChanges.editBuidlPieces(list, list2);
				List<GameObject> list5 = __instance.m_prefabs.FindAll((GameObject x) => (Object)(object)x.GetComponent<DungeonGenerator>() != (Object)null);
				foreach (GameObject item2 in list5)
				{
					DungeonGenerator component2 = item2.GetComponent<DungeonGenerator>();
					component2.m_minRooms *= 2;
					component2.m_maxRooms *= 2;
				}
				monsterEdit.editMonsters(__instance.m_prefabs);
				done = true;
			}
		}

		[HarmonyPatch(typeof(Player), "UpdateMovementModifier")]
		private static class UpdateMovementModifier_Patch
		{
			private static void Postfix(Player __instance, ref float ___m_equipmentMovementModifier, ItemData ___m_utilityItem)
			{
				try
				{
					foreach (ItemData item in ((Humanoid)__instance).GetInventory().GetAllItems().FindAll((ItemData i) => i.m_equipped && (int)i.m_shared.m_itemType == 18 && i != ___m_utilityItem))
					{
						___m_equipmentMovementModifier += item.m_shared.m_movementModifier;
					}
				}
				catch
				{
				}
			}
		}

		private static class ApplyArmorDamageMods_Patch
		{
			private static void Postfix(Player __instance, ref DamageModifiers mods, ItemData ___m_utilityItem)
			{
				try
				{
					foreach (ItemData item in ((Humanoid)__instance).GetInventory().GetAllItems().FindAll((ItemData i) => i.m_equipped && (int)i.m_shared.m_itemType == 18 && i != ___m_utilityItem))
					{
						((DamageModifiers)(ref mods)).Apply(item.m_shared.m_damageModifiers);
					}
				}
				catch
				{
				}
			}
		}

		private static class GetBodyArmor_Patch
		{
			private static void Postfix(Player __instance, ref float __result)
			{
				try
				{
					foreach (ItemData item in ((Humanoid)__instance).GetInventory().GetAllItems().FindAll((ItemData i) => i.m_equipped && (int)i.m_shared.m_itemType == 18))
					{
						__result += item.GetArmor();
					}
				}
				catch
				{
				}
			}
		}

		[HarmonyPatch(typeof(Humanoid), "IsItemEquiped")]
		private static class Humanoid_IsItemEquiped_Patch
		{
			private static void Postfix(Humanoid __instance, ItemData item, ItemData ___m_utilityItem, ref bool __result)
			{
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0021: Invalid comparison between Unknown and I4
				if (__result)
				{
					return;
				}
				try
				{
					__result = item.m_equipped && (int)item.m_shared.m_itemType == 18 && item != ___m_utilityItem;
				}
				catch
				{
				}
			}
		}

		[HarmonyPatch(typeof(Player), "GetEquipmentEitrRegenModifier")]
		private static class GetEquipmentEitrRegenModifier_Patch
		{
			private static void Postfix(Player __instance, ItemData ___m_utilityItem, ref float __result)
			{
				try
				{
					foreach (ItemData item in ((Humanoid)__instance).GetInventory().GetAllItems().FindAll((ItemData i) => i.m_equipped && (int)i.m_shared.m_itemType == 18 && i != ___m_utilityItem))
					{
						__result += item.m_shared.m_eitrRegenModifier;
					}
				}
				catch
				{
				}
			}
		}

		[HarmonyPatch(typeof(Player), "QueueEquipAction")]
		private static class QueueEquipItem_Patch
		{
			private static bool Prefix(Player __instance, ItemData item)
			{
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Invalid comparison between Unknown and I4
				if (item == null || __instance.IsEquipActionQueued(item) || (int)item.m_shared.m_itemType != 18)
				{
					return true;
				}
				try
				{
					List<ItemData> list = ((Humanoid)__instance).GetInventory().GetAllItems().FindAll((ItemData i) => i.m_equipped && (int)i.m_shared.m_itemType == 18);
					if (list.Exists((ItemData i) => i.m_shared.m_name == item.m_shared.m_name))
					{
						return false;
					}
					if (list.Count >= maxUtility)
					{
						return false;
					}
				}
				catch
				{
					Debug.LogError((object)("Error: " + Environment.StackTrace));
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(Humanoid), "EquipItem")]
		private static class EquipItem_Patch
		{
			private static bool Prefix(Humanoid __instance, ItemData item, bool triggerEquipEffects, Inventory ___m_inventory, ref bool __result, ref ItemData ___m_utilityItem)
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Invalid comparison between Unknown and I4
				try
				{
					if (item == null || (int)item.m_shared.m_itemType != 18 || !((Character)__instance).IsPlayer() || !___m_inventory.ContainsItem(item) || ((Character)__instance).InAttack() || ((Character)__instance).InDodge() || (((Character)__instance).IsPlayer() && !((Character)__instance).IsDead() && ((Character)__instance).IsSwimming() && !((Character)__instance).IsOnGround()) || (item.m_shared.m_useDurability && (double)item.m_durability <= 0.0) || (item.m_shared.m_dlc.Length > 0 && !DLCMan.instance.IsDLCInstalled(item.m_shared.m_dlc)))
					{
						return true;
					}
					if (__instance.GetInventory().GetAllItems().FindAll((ItemData i) => i.m_equipped && (int)i.m_shared.m_itemType == 18)
						.Count >= maxUtility)
					{
						__result = false;
						return false;
					}
					if (___m_utilityItem == null)
					{
						___m_utilityItem = item;
					}
					item.m_equipped = true;
					typeof(Humanoid).GetMethod("SetupEquipment", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[0]);
					if (triggerEquipEffects)
					{
						typeof(Humanoid).GetMethod("TriggerEquipEffect", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[1] { item });
					}
					__result = true;
					return false;
				}
				catch
				{
					Debug.LogError((object)("Error: " + Environment.StackTrace));
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(Humanoid), "UpdateEquipmentStatusEffects")]
		private static class UpdateEquipmentStatusEffects_Patch
		{
			private static void Prefix(Humanoid __instance, ItemData ___m_utilityItem, SEMan ___m_seman)
			{
				try
				{
					if (!((Character)__instance).IsPlayer())
					{
						return;
					}
					List<ItemData> list = __instance.GetInventory().GetAllItems().FindAll((ItemData i) => !i.m_equipped && (int)i.m_shared.m_itemType == 18 && i != ___m_utilityItem && Object.op_Implicit((Object)(object)i.m_shared.m_equipStatusEffect));
					List<ItemData> list2 = __instance.GetInventory().GetAllItems().FindAll((ItemData i) => i.m_equipped && (int)i.m_shared.m_itemType == 18 && i != ___m_utilityItem && Object.op_Implicit((Object)(object)i.m_shared.m_equipStatusEffect));
					foreach (ItemData item in list)
					{
						foreach (StatusEffect item2 in AccessTools.FieldRefAccess<SEMan, List<StatusEffect>>(___m_seman, "m_statusEffects"))
						{
							StatusEffect statusEffect = item2;
							if (((Object)statusEffect).name == ((Object)item.m_shared.m_equipStatusEffect).name && (___m_utilityItem == null || ((Object)___m_utilityItem.m_shared.m_equipStatusEffect).name != ((Object)statusEffect).name) && !list2.Exists((ItemData i) => ((Object)i.m_shared.m_equipStatusEffect).name == ((Object)statusEffect).name))
							{
								___m_seman.RemoveStatusEffect(statusEffect, false);
							}
						}
					}
				}
				catch
				{
				}
			}

			private static void Postfix(Humanoid __instance, ItemData ___m_utilityItem, SEMan ___m_seman)
			{
				try
				{
					if (!((Character)__instance).IsPlayer())
					{
						return;
					}
					foreach (ItemData item in __instance.GetInventory().GetAllItems().FindAll((ItemData i) => i.m_equipped && (int)i.m_shared.m_itemType == 18 && i != ___m_utilityItem && Object.op_Implicit((Object)(object)i.m_shared.m_equipStatusEffect)))
					{
						___m_seman.AddStatusEffect(item.m_shared.m_equipStatusEffect, false, 0, 0f);
					}
				}
				catch
				{
				}
			}
		}

		[HarmonyPatch(typeof(Humanoid), "UnequipAllItems")]
		private static class UnequipAllItems_Patch
		{
			private static void Postfix(Humanoid __instance, ItemData ___m_utilityItem)
			{
				try
				{
					if (!((Character)__instance).IsPlayer())
					{
						return;
					}
					foreach (ItemData item in __instance.GetInventory().GetAllItems().FindAll((ItemData i) => i.m_equipped && (int)i.m_shared.m_itemType == 18 && i != ___m_utilityItem))
					{
						__instance.UnequipItem(item, false);
					}
				}
				catch
				{
					Debug.LogError((object)("Error: " + Environment.StackTrace));
				}
			}
		}

		[HarmonyPatch(typeof(Player), "UnequipDeathDropItems")]
		private static class UnequipDeathDropItems_PatchUnequipItem
		{
			private static void Postfix(Player __instance, ItemData ___m_utilityItem)
			{
				try
				{
					if (!((Character)__instance).IsPlayer())
					{
						return;
					}
					foreach (ItemData item in ((Humanoid)__instance).GetInventory().GetAllItems().FindAll((ItemData i) => i.m_equipped && (int)i.m_shared.m_itemType == 18 && i != ___m_utilityItem))
					{
						((Humanoid)__instance).UnequipItem(item, false);
					}
				}
				catch
				{
					Debug.LogError((object)("Error: " + Environment.StackTrace));
				}
			}
		}

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

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

		public const string PluginName = "BalrondServerCore";

		public const string PluginVersion = "1.0.3";

		public static BuildChanges buildChanges = new BuildChanges();

		public static ItemChange change = new ItemChange();

		public static BuildPieceTargeting buildPieceTargeting = new BuildPieceTargeting();

		public static MonsterEdit monsterEdit = new MonsterEdit();

		public static int maxUtility = 5;

		private static GameObject LogoObject;

		private Sprite newLogo;

		private GameObject gui;

		public static float destructionTime = 1200f;

		private void Awake()
		{
			AssetBundle assetBundleFromResources = GetAssetBundleFromResources("madness");
			newLogo = assetBundleFromResources.LoadAsset<Sprite>("Assets/Custom/Madness/AshlandsLogo.png");
			harmony.PatchAll();
		}

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

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

		private void LateUpdate()
		{
		}

		private void changeLogo()
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.Find("/GuiRoot/GUI/StartGui/Menu/Logo/Mist");
			GameObject val2 = GameObject.Find("/GuiRoot/GUI/StartGui/Menu/Logo/Mist (1)");
			GameObject val3 = GameObject.Find("/GuiRoot/GUI/StartGui/Menu/Logo/Mist (2)");
			GameObject val4 = GameObject.Find("/GuiRoot/GUI/StartGui/Menu/Logo/Mist (3)");
			Color val5 = default(Color);
			((Color)(ref val5))..ctor(58f / 85f, 3f / 85f, 46f / 51f, 0.4745f);
			Color val6 = default(Color);
			((Color)(ref val6))..ctor(0.6509804f, 0.02745098f, 0.20392157f, 0.4745f);
			LogoObject.GetComponent<Image>().sprite = newLogo;
			((Graphic)val.GetComponent<Image>()).material.SetColor("_Color", val5);
			((Graphic)val2.GetComponent<Image>()).material.SetColor("_Color", val6);
			((Graphic)val3.GetComponent<Image>()).material.SetColor("_Color", val6);
			((Graphic)val4.GetComponent<Image>()).material.SetColor("_Color", val5);
		}

		public static void changePlayer(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;
			Player component2 = player.GetComponent<Player>();
			component2.m_maxCarryWeight = 350f;
			component2.m_encumberedStaminaDrain = 3f;
		}
	}
}
namespace BalrondServerCore
{
	public class BuildChanges
	{
		private List<GameObject> buildPieces = new List<GameObject>();

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

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

		private string[] buildPiecesNames = new string[5] { "portal_wood", "piece_workbench", "piece_chest_private", "piece_chest_wood", "forge" };

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

		private void EditRecipes()
		{
			string[] array = buildPiecesNames;
			foreach (string name in array)
			{
				GameObject val = FindBuildPiece(name);
				if ((Object)(object)val != (Object)null)
				{
					changeBuildPiece(val);
				}
			}
		}

		private void changeBuildPiece(GameObject buildPiece)
		{
			switch (((Object)buildPiece).name)
			{
			case "piece_chest_private":
				ChangeChest(buildPiece, 3, 6);
				break;
			case "piece_chest_wood":
				ChangeChest(buildPiece, 2, 6);
				break;
			case "portal_wood":
				ChangeRecipe(buildPiece);
				break;
			case "forge":
			case "piece_workbench":
				ChcangeCraftingStation(buildPiece, requireRoof: false);
				break;
			}
		}

		private void ChangeChest(GameObject gameObject, int height, int width)
		{
			Container component = gameObject.GetComponent<Container>();
			component.m_width = width;
			component.m_height = height;
		}

		private void ChcangeCraftingStation(GameObject buildPiece, bool requireRoof)
		{
			CraftingStation component = buildPiece.GetComponent<CraftingStation>();
			if ((Object)(object)component != (Object)null)
			{
				component.m_craftRequireRoof = requireRoof;
			}
		}

		private GameObject FindBuildPiece(string name)
		{
			return buildPieces.Find((GameObject x) => ((Object)x).name == name);
		}

		private void ChangeRecipe(GameObject gameObject)
		{
			Piece component = gameObject.GetComponent<Piece>();
			component.m_resources = createResources(gameObject);
		}

		private Requirement[] createResources(GameObject item)
		{
			List<Requirement> list = new List<Requirement>();
			string name = ((Object)item).name;
			string text = name;
			if (text == "portal_wood")
			{
				list.Add(createReq("Crystal", 5, 0));
				list.Add(createReq("FineWood", 25, 0));
				list.Add(createReq("SurtlingCore", 5, 0));
				list.Add(createReq("HardAntler", 1, 0));
				list.Add(createReq("Resin", 20, 0));
			}
			return list.ToArray();
		}

		private Requirement createReq(string name, int amount, int amountPerLevel)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			Requirement val = new Requirement();
			val.m_recover = true;
			ItemDrop component = FindItem(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)
			{
				return val;
			}
			Debug.LogWarning((object)("Item Not Found - " + name + ", Replaced With Wood"));
			return items.Find((GameObject x) => ((Object)x).name == "Wood");
		}

		private void editFermenter()
		{
			GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "fermenter");
			Fermenter component = val.GetComponent<Fermenter>();
			component.m_fermentationDuration = 2000f;
		}

		private void EditConversion(Fermenter fermenter, GameObject to, int amount)
		{
			foreach (ItemConversion item in fermenter.m_conversion)
			{
				if (((Object)item.m_to).name == ((Object)to).name)
				{
					item.m_producedItems = amount;
				}
			}
		}

		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_maxFuel = 45;
			component.m_maxOre = 15;
			component.m_secPerProduct = 40f;
			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_maxFuel = 60;
			component.m_maxOre = 30;
			component.m_secPerProduct = 20f;
			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_maxOre = 80;
			component.m_secPerProduct = 25f;
		}

		private void editRefinery()
		{
			GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "eitrrefinery");
			Smelter component = val.GetComponent<Smelter>();
			component.m_maxOre = 60;
			component.m_maxFuel = 60;
			component.m_spawnStack = true;
			component.m_secPerProduct = 40f;
		}

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

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

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

		private void editBeehive()
		{
			GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "piece_beehive");
			Beehive component = val.GetComponent<Beehive>();
			component.m_maxHoney = 40;
		}
	}
	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 CollisionDisabler : MonoBehaviour
	{
		public static string[] ignoredList = new string[1] { "" };

		public static bool IsIgnored(Collider collider)
		{
			return ignoredList.Contains(Utils.GetPrefabName(((Component)((Component)collider).transform).gameObject).ToLower());
		}

		private void OnCollisionEnter(Collision collision)
		{
			if (IsIgnored(collision.collider))
			{
				Physics.IgnoreCollision(((Component)this).GetComponent<Collider>(), collision.collider, true);
			}
		}
	}
	internal class DestroyLeftover : MonoBehaviour
	{
		public float m_timeout = 1200f;

		public float m_currentTime = 0f;

		public bool m_triggerOnAwake = true;

		public bool m_destroyMe = false;

		private ZNetView m_nview;

		private void Awake()
		{
			m_nview = ((Component)this).GetComponent<ZNetView>();
			if (m_triggerOnAwake)
			{
				((MonoBehaviour)this).InvokeRepeating("CheckShouldDestroy", 1f, 1f);
			}
		}

		private void CheckShouldDestroy()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)EffectArea.IsPointInsideArea(((Component)this).transform.position, (Type)4, 0f)))
			{
				m_currentTime += 1f;
			}
			else
			{
				m_currentTime = 0f;
			}
			if (m_currentTime >= m_timeout)
			{
				m_destroyMe = true;
				DestroyNow();
			}
		}

		private void DestroyNow()
		{
			if (Object.op_Implicit((Object)(object)m_nview))
			{
				if (m_nview.IsValid() && m_nview.IsOwner())
				{
					ZNetScene.instance.Destroy(((Component)this).gameObject);
				}
			}
			else
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}
	public class ItemChange
	{
		private string[] itemNames = new string[47]
		{
			"Wood", "FineWood", "YggdrasilWood", "Stone", "BlackMarble", "RoundLog", "Resin", "Ooze", "Guck", "Tar",
			"Tin", "TinOre", "Copper", "CopperOre", "CopperScrap", "IronScrap", "BronzeScrap", "Bronze", "BlackMetalScrap", "Iron",
			"Silver", "BlackMetal", "Coal", "DragonEgg", "IronOre", "BoltBlackmetal", "BoltBone", "BoltCarapace", "BoltIron", "LinenThread",
			"Coins", "Sap", "LeatherScraps", "ChickenEgg", "BlackMetalOre", "Club", "CrossbowArbalest", "Battleaxe", "BattleaxeCrystal", "SledgeStagbreaker",
			"SledgeIron", "SledgeDemolisher", "Feathers", "BoneFragments", "LinenThread", "SurtlingCore", "Hammer"
		};

		public void editItems(List<GameObject> items)
		{
			string[] array = itemNames;
			foreach (string name in array)
			{
				GameObject val = items.Find((GameObject x) => ((Object)x).name == name);
				if ((Object)(object)val != (Object)null)
				{
					changeItem(val);
				}
			}
			List<GameObject> list = items.FindAll((GameObject x) => ((Object)x).name.Contains("Arrow"));
			foreach (GameObject item in list)
			{
				editStackAndWeight(item, 0.1f, 999);
			}
			List<GameObject> list2 = items.FindAll((GameObject x) => ((Object)x).name.Contains("Trophy"));
			foreach (GameObject item2 in list2)
			{
				editStackAndWeight(item2, -1f, 50);
			}
			List<GameObject> list3 = items.FindAll((GameObject x) => statment(x));
			foreach (GameObject item3 in list3)
			{
				changeItem(item3);
			}
		}

		private bool statment(GameObject item)
		{
			return ((Object)item).name.Contains("Sword") || ((Object)item).name.Contains("Mace") || ((Object)item).name.Contains("Armor") || ((Object)item).name.Contains("Bow") || ((Object)item).name.Contains("Knife") || ((Object)item).name.Contains("Armor") || ((Object)item).name.Contains("Helmet") || ((Object)item).name.Contains("Axe") || ((Object)item).name.Contains("Spear") || ((Object)item).name.Contains("Atgeir") || ((Object)item).name.Contains("Nails") || ((Object)item).name.Contains("Shield") || ((Object)item).name.Contains("Meat");
		}

		private void changeItem(GameObject item)
		{
			switch (((Object)item).name)
			{
			case "SwordBronze":
				editQualityValues(item, 0.1f, 4, 1f, -0.02f);
				break;
			case "SwordIron":
				editQualityValues(item, 0.1f, 4, 1f, -0.02f);
				break;
			case "SwordSilver":
				editQualityValues(item, 0.1f, 4, 1f, -0.02f);
				break;
			case "SwordBlackmetal":
				editQualityValues(item, 0.1f, 4, 1f, -0.02f);
				break;
			case "SwordMistwalker":
				editQualityValues(item, 0.1f, 4, 1f, -0.02f);
				break;
			case "Club":
				editQualityValues(item, 0.1f, 4, 1.5f, -0.02f);
				break;
			case "MaceBronze":
			case "MaceIron":
				editQualityValues(item, 0.15f, 4, 2f, -0.03f);
				break;
			case "MaceSilver":
				editQualityValues(item, 0.15f, 4, 3f, -0.03f);
				break;
			case "MaceNeedle":
				editQualityValues(item, 0.15f, 4, 3f, -0.03f);
				break;
			case "AxeStone":
			case "AxeFlint":
				editQualityValues(item, 0.05f, 4, 1f, -0.01f);
				break;
			case "AxeBronze":
			case "AxeIron":
				editQualityValues(item, 0.1f, 4, 1.5f, -0.02f);
				break;
			case "AxeSilver":
				editQualityValues(item, 0.1f, 4, 3f, -0.02f);
				break;
			case "AxeBlackmetal":
				editQualityValues(item, 0.15f, 4, 2f, -0.02f);
				break;
			case "AxeJotunBane":
				editQualityValues(item, 0.15f, 4, 2f, -0.03f);
				break;
			case "SpearFlint":
				editQualityValues(item, 0.05f, 4, 1f, -0.01f);
				break;
			case "SpearBronze":
				editQualityValues(item, 0.1f, 4, 1.5f, -0.02f);
				break;
			case "SpearElderbark":
				editQualityValues(item, 0.1f, 4, 1.5f, -0.02f);
				break;
			case "SpearWolfFang":
				editQualityValues(item, 0.1f, 4, 1.5f, -0.02f);
				break;
			case "SpearChitin":
				editQualityValues(item, 0.1f, 4, 2f, -0.02f);
				break;
			case "SpearCarapace":
				editQualityValues(item, 0.1f, 4, 2f, -0.03f);
				break;
			case "AtgeirBronze":
				editQualityValues(item, 0.1f, 4, 2.5f, -0.03f);
				break;
			case "AtgeirIron":
				editQualityValues(item, 0.1f, 4, 2.5f, -0.03f);
				break;
			case "AtgeirBlackmetal":
				editQualityValues(item, 0.1f, 4, 3f, -0.04f);
				break;
			case "AtgeirHimminAfl":
				editQualityValues(item, 0.1f, 4, 3f, -0.04f);
				break;
			case "KnifeFlint":
				editQualityValues(item, 0.05f, 4, 0.5f, -0.01f);
				break;
			case "KnifeCopper":
				editQualityValues(item, 0.05f, 4, 0.5f, -0.01f);
				break;
			case "KnifeChitin":
				editQualityValues(item, 0.05f, 4, 0.5f, -0.01f);
				break;
			case "KnifeButcher":
				editQualityValues(item, 0.05f, 4, 0.5f, -0.01f);
				break;
			case "KnifeSilver":
				editQualityValues(item, 0.1f, 4, 0.5f, -0.01f);
				break;
			case "KnifeBlackMetal":
				editQualityValues(item, 0.1f, 4, 0.5f, -0.01f);
				break;
			case "KnifeSkollAndHati":
				editQualityValues(item, 0.2f, 4, 1f, -0.01f);
				break;
			case "Bow":
				editQualityValues(item, 0.05f, 4, 1f, -0.01f);
				break;
			case "BowFineWood":
				editQualityValues(item, 0.05f, 4, 1.5f, -0.01f);
				break;
			case "BowHuntsman":
				editQualityValues(item, 0.05f, 4, 1.5f, -0.01f);
				break;
			case "BowDraugrFang":
				editQualityValues(item, 0.1f, 4, 2f, -0.02f);
				break;
			case "BowSpineSnap":
				editQualityValues(item, 0.1f, 4, 2f, -0.02f);
				break;
			case "CrossbowArbalest":
				editQualityValues(item, 0.1f, 4, 2f, -0.03f);
				break;
			case "ShieldWood":
				editQualityValues(item, 0.1f, 4, 4f, -0.02f, 0.5f);
				editDefense(item, 5f, 5f, 20f, 5f, 1.4f);
				editArmor(item, 100f, 10f);
				break;
			case "ShieldWoodTower":
				editQualityValues(item, 0.15f, 4, 6f, -0.03f, 0.5f);
				editDefense(item, 10f, 10f, 100f, 10f, 0f);
				editArmor(item, 140f, 20f);
				editDurability(item, 300f, 50f);
				break;
			case "ShieldBronzeBuckler":
				editQualityValues(item, 0.15f, 4, 4f, -0.03f, 0.5f);
				editDefense(item, 20f, 5f, 30f, 0f, 2.5f);
				editArmor(item, 120f, 10f);
				editDurability(item, 250f, 50f, 2f);
				break;
			case "ShieldBoneTower":
				editQualityValues(item, 0.15f, 4, 4f, -0.05f, 0.5f);
				editDefense(item, 40f, 10f, 100f, 10f, 0f);
				editArmor(item, 160f, 20f);
				editDurability(item, 350f, 50f);
				break;
			case "ShieldIronBuckler":
				editQualityValues(item, 0.15f, 4, 5f, -0.04f, 0.5f);
				editDefense(item, 30f, 5f, 30f, 0f, 2.5f);
				editArmor(item, 140f, 10f);
				editDurability(item, 250f, 50f, 2f);
				break;
			case "ShieldBanded":
				editQualityValues(item, 0.15f, 4, 4f, -0.03f, 0.5f);
				editDefense(item, 50f, 5f, 40f, 10f, 1.6f);
				editArmor(item, 140f, 10f);
				editDurability(item, 300f, 50f, 1f);
				break;
			case "ShieldIronSquare":
				editQualityValues(item, 0.15f, 4, 6f, -0.04f, 0.5f);
				editDefense(item, 50f, 5f, 100f, 0f, 1.1f);
				editArmor(item, 180f, 10f);
				editDurability(item, 350f, 50f, 1f);
				break;
			case "ShieldIronTower":
				editQualityValues(item, 0.2f, 4, 6f, -0.05f, 0.5f);
				editDefense(item, 50f, 10f, 120f, 5f);
				editArmor(item, 200f, 20f);
				editDurability(item, 400f, 50f, 1f);
				break;
			case "ShieldSerpentscale":
				editQualityValues(item, 0.2f, 4, 6f, -0.06f, 0.5f);
				editDefense(item, 60f, 10f, 120f, 0f, 1.1f);
				editArmor(item, 250f, 20f);
				editDurability(item, 400f, 50f, 1f);
				break;
			case "ShieldSilver":
				editQualityValues(item, 0.15f, 4, 5f, -0.04f, 0.5f);
				editDefense(item, 60f, 5f, 60f, 10f, 1.7f);
				editArmor(item, 200f, 10f);
				editDurability(item, 350f, 50f, 1f);
				break;
			case "ShieldBlackmetal":
				editQualityValues(item, 0.15f, 4, 6f, -0.05f, 0.5f);
				editDefense(item, 80f, 5f, 60f, 5f, 1.7f);
				editArmor(item, 250f, 20f);
				editDurability(item, 400f, 50f, 1f);
				break;
			case "ShieldBlackmetalTower":
				editQualityValues(item, 0.2f, 4, 8f, -0.06f, 0.5f);
				editDefense(item, 120f, 10f, 160f, 0f, 1.1f);
				editArmor(item, 300f, 20f);
				editDurability(item, 450f, 50f, 1f);
				break;
			case "ShieldCarapaceBuckler":
				editQualityValues(item, 0.2f, 4, 6f, -0.05f, 0.5f);
				editDefense(item, 80f, 5f, 40f, 0f, 2.6f);
				editArmor(item, 200f, 10f);
				editDurability(item, 300f, 50f, 2f);
				break;
			case "ShieldCarapace":
				editQualityValues(item, 0.2f, 4, 8f, -0.06f, 0.5f);
				editDefense(item, 150f, 10f, 180f, 0f, 1.1f);
				editArmor(item, 350f, 20f);
				editDurability(item, 500f, 50f, 1f);
				break;
			case "Battleaxe":
				editQualityValues(item, 0.2f, 4, 5f, -0.1f, 0.5f);
				editDefense(item, 50f, 10f, 50f, 10f, 2f);
				editArmor(item, 40f, 20f);
				editDurability(item, 200f, 50f, 1f);
				break;
			case "BattleaxeCrystal":
				editQualityValues(item, 0.2f, 4, 5f, -0.1f, 0.5f);
				editDefense(item, 60f, 10f, 50f, 10f, 2f);
				editArmor(item, 50f, 20f);
				editDurability(item, 300f, 50f, 1f);
				break;
			case "SledgeStagbreaker":
				editQualityValues(item, 0.2f, 4, 5f, -0.1f, 0.5f);
				editDefense(item, 30f, 10f, 50f, 10f, 2f);
				editArmor(item, 20f, 20f);
				editDurability(item, 150f, 50f, 1f);
				break;
			case "SledgeIron":
				editQualityValues(item, 0.2f, 4, 5f, -0.1f, 0.5f);
				editDefense(item, 50f, 10f, 50f, 10f, 2f);
				editArmor(item, 40f, 20f);
				editDurability(item, 200f, 50f, 1f);
				break;
			case "SledgeDemolisher":
				editQualityValues(item, 0.2f, 4, 5f, -0.1f, 0.5f);
				editDefense(item, 70f, 10f, 50f, 10f, 2f);
				editArmor(item, 60f, 20f);
				editDurability(item, 300f, 50f, 1f);
				break;
			case "THSwordKrom":
				editQualityValues(item, 0.2f, 4, 5f, -0.1f, 0.5f);
				editDefense(item, 70f, 10f, 50f, 10f, 2f);
				editArmor(item, 50f, 20f);
				editDurability(item, 250f, 50f, 1f);
				break;
			case "ArmorRagsChest":
			case "ArmorRagsLegs":
				editQualityValues(item, 0.1f, 4, 2f);
				break;
			case "ArmorLeatherLegs":
			case "ArmorLeatherChest":
				editQualityValues(item, 0.1f, 4, 4f, -0.01f);
				break;
			case "ArmorTrollLeatherLegs":
			case "ArmorTrollLeatherChest":
				editQualityValues(item, 0.1f, 4, 4f, -0.01f);
				break;
			case "ArmorBronzeLegs":
			case "ArmorBronzeChest":
				editQualityValues(item, 0.15f, 4, 6f, -0.02f);
				break;
			case "ArmorRootLegs":
			case "ArmorRootChest":
				editQualityValues(item, 0.1f, 4, 6f, -0.02f);
				break;
			case "ArmorIronLegs":
			case "ArmorIronChest":
				editQualityValues(item, 0.15f, 4, 8f, -0.03f);
				break;
			case "ArmorWolfLegs":
			case "ArmorWolfChest":
				editQualityValues(item, 0.15f, 4, 8f, -0.03f);
				break;
			case "ArmorFenringChest":
			case "ArmorFenringLegs":
				editQualityValues(item, 0.1f, 4, 6f, -0.03f);
				break;
			case "ArmorPaddedGreaves":
			case "ArmorPaddedCuirass":
				editQualityValues(item, 0.15f, 4, 8f, -0.02f);
				break;
			case "ArmorMageLegs":
			case "ArmorMageChest":
				editQualityValues(item, 0.1f, 4, 8f, -0.01f);
				break;
			case "ArmorCarapaceChest":
			case "ArmorCarapaceLegs":
				editQualityValues(item, 0.15f, 4, 8f, -0.03f);
				break;
			case "HelmetRags":
				editQualityValues(item, 0.1f, 4, 1f);
				break;
			case "HelmetLeather":
				editQualityValues(item, 0.1f, 4, 1f);
				break;
			case "HelmetTrollLeather":
				editQualityValues(item, 0.1f, 4, 0.5f);
				break;
			case "HelmetBronze":
				editQualityValues(item, 0.1f, 4, 2f, -0.01f);
				break;
			case "HelmetRoot":
				editQualityValues(item, 0.1f, 4, 2f, -0.01f);
				break;
			case "HelmetIron":
				editQualityValues(item, 0.1f, 4, 3f, -0.01f);
				break;
			case "HelmetDrake":
				editQualityValues(item, 0.1f, 4, 3f, -0.01f);
				break;
			case "HelmetPadded":
				editQualityValues(item, 0.1f, 4, 2f);
				break;
			case "HelmetMage":
				editQualityValues(item, 0.1f, 4, 2f);
				break;
			case "HelmetCarapace":
				editQualityValues(item, 0.1f, 4, 3f, -0.01f);
				break;
			case "Hammer":
				editQualityValues(item, 0f, 5, 1f, 0.03f);
				editDurability(item, 300f, 150f, 1f);
				break;
			case "Coins":
				editStackAndWeight(item, 0.02f, 999);
				break;
			case "BoltBlackmetal":
			case "BoltBone":
			case "BoltCarapace":
			case "BoltIron":
				editStackAndWeight(item, 0.1f, 999);
				break;
			case "Feathers":
				editStackAndWeight(item, 0.05f, 400);
				break;
			case "LeatherScraps":
			case "ChickenEgg":
			case "LinenThread":
			case "BoneFragments":
				editStackAndWeight(item, 0.2f, 200);
				break;
			case "Sap":
				editStackAndWeight(item, 0.1f, 100);
				break;
			case "SurtlingCore":
				editStackAndWeight(item, 3f, 50);
				break;
			case "Wood":
				editStackAndWeight(item, 1f, 200);
				break;
			case "RoundLog":
			case "FineWood":
				editStackAndWeight(item, 1.25f, 200);
				break;
			case "YggdrasilWood":
			case "Stone":
			case "BlackMarble":
				editStackAndWeight(item, 1.5f, 200);
				break;
			case "Resin":
				editStackAndWeight(item, 0.2f, 200);
				break;
			case "Ooze":
			case "Guck":
				editStackAndWeight(item, 0.25f, 100);
				break;
			case "Tar":
				editStackAndWeight(item, 1f, 100);
				break;
			case "Tin":
				editStackAndWeight(item, 3f, 100);
				break;
			case "TinOre":
				editStackAndWeight(item, 4f, 100);
				break;
			case "Copper":
				editStackAndWeight(item, 4f, 100);
				break;
			case "CopperOre":
				editStackAndWeight(item, 5f, 100);
				break;
			case "CopperScrap":
				editStackAndWeight(item, 3f, 100);
				break;
			case "Bronze":
				editStackAndWeight(item, 4f, 100);
				break;
			case "BronzeScrap":
				editStackAndWeight(item, 3f, 100);
				break;
			case "Iron":
				editStackAndWeight(item, 5f, 100);
				break;
			case "IronScrap":
				editStackAndWeight(item, 4f, 100);
				break;
			case "IronOre":
				editStackAndWeight(item, 6f, 100);
				break;
			case "SilverOre":
				editStackAndWeight(item, 6f, 100);
				break;
			case "Silver":
				editStackAndWeight(item, 5f, 100);
				break;
			case "BlackMetal":
				editStackAndWeight(item, 5f, 100);
				break;
			case "BlackMetalOre":
				editStackAndWeight(item, 6f, 100);
				break;
			case "BlackMetalScrap":
				editStackAndWeight(item, 4f, 100);
				break;
			case "Coal":
				editStackAndWeight(item, 1f, 200);
				break;
			case "DragonEgg":
				editStackAndWeight(item, 100f, 10);
				break;
			case "TinNails":
			case "CopperNails":
			case "IronNails":
			case "BronzeNails":
			case "SilverNails":
			case "GoldNails":
			case "FlametalNails":
			case "BlackMetalNails":
				editStackAndWeight(item, 0.2f, 500);
				break;
			case "BearMeat":
			case "BugMeat":
			case "HareMeat":
			case "WolfMeat":
			case "DeerMeat":
			case "RawMeat":
			case "ChickenMeat":
				editStackAndWeight(item, 1.25f, 50);
				break;
			case "CookedBearMeat":
			case "CookedBugMeat":
			case "CookedHareMeat":
			case "CookedWolfMeat":
			case "CookedDeerMeat":
			case "CookedRawMeat":
			case "CookedChickenMeat":
				editStackAndWeight(item, 1f, 50);
				break;
			}
		}

		private void editStackAndWeight(GameObject gameObject, float weight = -1f, int stack = 1)
		{
			ItemDrop component = gameObject.GetComponent<ItemDrop>();
			component.m_itemData.m_shared.m_weight = ((weight == -1f) ? component.m_itemData.m_shared.m_weight : weight);
			component.m_itemData.m_shared.m_autoStack = true;
			component.m_itemData.m_shared.m_maxStackSize = stack;
		}

		private void editQualityValues(GameObject gameObject, float weightRatio = 0f, int quality = 4, float weight = -1f, float sppedDebuff = 0f, float equipeSpeed = -1f)
		{
			ItemDrop component = gameObject.GetComponent<ItemDrop>();
			component.m_itemData.m_shared.m_weight = ((weight == -1f) ? ((float)component.m_itemData.m_shared.m_maxQuality) : weight);
			component.m_itemData.m_shared.m_scaleWeightByQuality = ((weightRatio == 0f) ? component.m_itemData.m_shared.m_scaleWeightByQuality : weightRatio);
			component.m_itemData.m_shared.m_equipDuration = ((equipeSpeed == -1f) ? component.m_itemData.m_shared.m_equipDuration : equipeSpeed);
			component.m_itemData.m_shared.m_movementModifier = sppedDebuff;
			component.m_itemData.m_shared.m_maxQuality = quality;
		}

		private void editDefense(GameObject gameObject, float blockPower = -1f, float blockPowerPerLevel = -1f, float deflectionForce = -1f, float deflectionForcePerLevel = 0f, float blockBonus = -1f)
		{
			ItemDrop component = gameObject.GetComponent<ItemDrop>();
			component.m_itemData.m_shared.m_blockPower = ((blockPower == -1f) ? component.m_itemData.m_shared.m_blockPower : blockPower);
			component.m_itemData.m_shared.m_blockPowerPerLevel = ((blockPowerPerLevel == -1f) ? component.m_itemData.m_shared.m_blockPowerPerLevel : blockPowerPerLevel);
			component.m_itemData.m_shared.m_deflectionForce = ((deflectionForce == -1f) ? component.m_itemData.m_shared.m_deflectionForce : deflectionForce);
			component.m_itemData.m_shared.m_deflectionForcePerLevel = ((deflectionForcePerLevel == -1f) ? component.m_itemData.m_shared.m_deflectionForcePerLevel : deflectionForcePerLevel);
			component.m_itemData.m_shared.m_timedBlockBonus = ((blockBonus == -1f) ? component.m_itemData.m_shared.m_timedBlockBonus : blockBonus);
		}

		private void editArmor(GameObject gameObject, float armor = -1f, float armorPerLevel = -1f)
		{
			ItemDrop component = gameObject.GetComponent<ItemDrop>();
			component.m_itemData.m_shared.m_armor = ((armor == -1f) ? component.m_itemData.m_shared.m_armor : armor);
			component.m_itemData.m_shared.m_armorPerLevel = ((armorPerLevel == -1f) ? component.m_itemData.m_shared.m_armorPerLevel : armorPerLevel);
		}

		private void editDurability(GameObject gameObject, float durability = -1f, float durabilityPerLevel = -1f, float useDrain = -1f)
		{
			ItemDrop component = gameObject.GetComponent<ItemDrop>();
			component.m_itemData.m_durability = ((durability == -1f) ? component.m_itemData.m_durability : durability);
			component.m_itemData.m_shared.m_durabilityPerLevel = ((durabilityPerLevel == -1f) ? component.m_itemData.m_shared.m_durabilityPerLevel : durabilityPerLevel);
			component.m_itemData.m_shared.m_useDurabilityDrain = ((useDrain == -1f) ? component.m_itemData.m_shared.m_useDurabilityDrain : useDrain);
		}

		private void editFoodStat(GameObject gameObject, int hp = -99, int stam = -99, int eitr = -99, int time = -99, int regen = -99)
		{
			ItemDrop component = gameObject.GetComponent<ItemDrop>();
			component.m_itemData.m_shared.m_food = ((hp == -99) ? component.m_itemData.m_shared.m_food : ((float)hp));
			component.m_itemData.m_shared.m_foodStamina = ((stam == -99) ? component.m_itemData.m_shared.m_foodStamina : ((float)stam));
			component.m_itemData.m_shared.m_foodEitr = ((eitr == -99) ? component.m_itemData.m_shared.m_foodEitr : ((float)eitr));
			component.m_itemData.m_shared.m_foodRegen = ((regen == -99) ? component.m_itemData.m_shared.m_foodRegen : ((float)regen));
			component.m_itemData.m_shared.m_foodBurnTime = ((time == -99) ? component.m_itemData.m_shared.m_foodBurnTime : ((float)time));
		}

		private void editValueAndTeleport(GameObject gameObject, int newValue = -1, bool teleportable = true)
		{
			ItemDrop component = gameObject.GetComponent<ItemDrop>();
			int value = component.m_itemData.m_shared.m_value;
			component.m_itemData.m_shared.m_value = ((newValue != -1) ? newValue : value);
			component.m_itemData.m_shared.m_teleportable = teleportable;
		}
	}
	public class MonsterEdit
	{
		private List<GameObject> items = new List<GameObject>();

		private string[] monsterNames = new string[6] { "Skeleton", "Skeleton_Poison", "Skeleton_NoArcher", "Draugr", "Draugr_Ranged", "Draugr_Elite" };

		public void editMonsters(List<GameObject> gameObjects)
		{
			items = gameObjects;
			string[] array = monsterNames;
			foreach (string name in array)
			{
				GameObject val = gameObjects.Find((GameObject x) => ((Object)x).name == name);
				if ((Object)(object)val != (Object)null)
				{
					editMonster(val);
				}
			}
		}

		private void editMonster(GameObject gameObject)
		{
			switch (((Object)gameObject).name)
			{
			case "Skeleton":
				AddLoot(gameObject, "CopperScrap", 1, 1, 0.1f);
				AddLoot(gameObject, "BronzeScrap", 1, 1, 0.05f);
				break;
			case "Skeleton_NoArcher":
				AddLoot(gameObject, "CopperScrap", 1, 1, 0.1f);
				AddLoot(gameObject, "BronzeScrap", 1, 1, 0.05f);
				break;
			case "Skeleton_Poison":
				AddLoot(gameObject, "CopperScrap", 1, 1, 0.15f);
				AddLoot(gameObject, "BronzeScrap", 1, 1, 0.1f);
				break;
			case "Draugr":
				AddLoot(gameObject, "CopperScrap", 1, 1, 0.2f);
				AddLoot(gameObject, "BronzeScrap", 1, 1, 0.1f);
				AddLoot(gameObject, "IronScrap", 1, 1, 0.05f);
				break;
			case "Draugr_Ranged":
				AddLoot(gameObject, "CopperScrap", 1, 1, 0.2f);
				AddLoot(gameObject, "BronzeScrap", 1, 1, 0.1f);
				AddLoot(gameObject, "IronScrap", 1, 1, 0.05f);
				break;
			case "Draugr_Elite":
				AddLoot(gameObject, "CopperScrap", 1, 1, 0.3f);
				AddLoot(gameObject, "BronzeScrap", 1, 1, 0.2f);
				AddLoot(gameObject, "IronScrap", 1, 1, 0.1f);
				break;
			}
		}

		private void AddLoot(GameObject gameObject, string name, int min, int max, float chance)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			CharacterDrop component = gameObject.GetComponent<CharacterDrop>();
			Drop val = component.m_drops.Find((Drop x) => ((Object)x.m_prefab).name == name);
			if (val == null)
			{
				Drop val2 = new Drop();
				val2.m_amountMin = min;
				val2.m_amountMax = max;
				val2.m_chance = chance;
				val2.m_prefab = FindItem(name);
				component.m_drops.Add(val2);
			}
		}

		private GameObject FindItem(string name)
		{
			GameObject val = items.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");
		}
	}
}