Decompiled source of RavenwoodColosseum v1.0.0

plugins/RavenwoodColosseum/RavenwoodColosseum.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 BepInEx;
using HarmonyLib;
using TMPro;
using UnityEngine;
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: AssemblyTitle("BalrondRavenwoodRome")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BalrondRavenwoodRome")]
[assembly: AssemblyCopyright("Copyright ©  2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("cde312a0-cf19-4264-8616-e1c74774beed")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BalrondRavenwoodRome;

public class BankContainer : MonoBehaviour, Hoverable, Interactable
{
	private float m_lastTakeAllTime;

	public Action m_onTakeAllSuccess;

	public string m_name = "BankContainer";

	public Sprite m_bkg;

	public int m_width = 8;

	public int m_height = 8;

	public PrivacySetting m_privacy = (PrivacySetting)2;

	public ZNetView m_rootObjectOverride;

	public GameObject m_open;

	public GameObject m_closed;

	public EffectList m_openEffects = new EffectList();

	public EffectList m_closeEffects = new EffectList();

	private ZNetView m_nview;

	private Piece m_piece;

	public Dictionary<long, Container> m_inventories = new Dictionary<long, Container>();

	public GameObject m_spawnContainer;

	private bool m_inUse;

	private bool m_loading;

	private uint m_lastRevision = uint.MaxValue;

	private string m_lastDataString;

	private void Awake()
	{
		m_nview = (Object.op_Implicit((Object)(object)m_rootObjectOverride) ? ((Component)m_rootObjectOverride).GetComponent<ZNetView>() : ((Component)this).GetComponent<ZNetView>());
		if (m_nview.GetZDO() != null)
		{
			m_piece = ((Component)this).GetComponent<Piece>();
			if (Object.op_Implicit((Object)(object)m_nview))
			{
				m_nview.Register<long>("RequestOpen", (Action<long, long>)RPC_RequestOpen);
				m_nview.Register<long, bool>("OpenRespons", (Action<long, long, bool>)RPC_OpenRespons);
				m_nview.Register<long>("RPC_RequestStack", (Action<long, long>)RPC_RequestStack);
				m_nview.Register<long, bool>("RPC_StackResponse", (Action<long, long, bool>)RPC_StackResponse);
				m_nview.Register<long>("RequestTakeAll", (Action<long, long>)RPC_RequestTakeAll);
				m_nview.Register<long, bool>("TakeAllRespons", (Action<long, long, bool>)RPC_TakeAllRespons);
			}
			WearNTear val = (Object.op_Implicit((Object)(object)m_rootObjectOverride) ? ((Component)m_rootObjectOverride).GetComponent<WearNTear>() : ((Component)this).GetComponent<WearNTear>());
			if (Object.op_Implicit((Object)(object)val))
			{
				val.m_onDestroyed = (Action)Delegate.Combine(val.m_onDestroyed, new Action(OnDestroyed));
			}
			Destructible val2 = (Object.op_Implicit((Object)(object)m_rootObjectOverride) ? ((Component)m_rootObjectOverride).GetComponent<Destructible>() : ((Component)this).GetComponent<Destructible>());
			if (Object.op_Implicit((Object)(object)val2))
			{
				val2.m_onDestroyed = (Action)Delegate.Combine(val2.m_onDestroyed, new Action(OnDestroyed));
			}
			((MonoBehaviour)this).InvokeRepeating("CheckForChanges", 0f, 1f);
		}
	}

	private void DropAllItems()
	{
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		foreach (KeyValuePair<long, Container> inventory in m_inventories)
		{
			List<ItemData> allItems = inventory.Value.GetInventory().GetAllItems();
			int num = 1;
			foreach (ItemData item in allItems)
			{
				Vector3 val = ((Component)this).transform.position + Vector3.up * 0.5f + Random.insideUnitSphere * 0.3f;
				Quaternion val2 = Quaternion.Euler(0f, (float)Random.Range(0, 360), 0f);
				Vector3 val3 = val;
				Quaternion val4 = val2;
				ItemDrop.DropItem(item, 0, val3, val4);
				num++;
			}
			inventory.Value.GetInventory().RemoveAll();
			Save(inventory.Value);
			m_inventories.Remove(inventory.Key);
			inventory.Value.m_autoDestroyEmpty = false;
		}
	}

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

	private Container GetContainer(long playerID)
	{
		m_inventories.TryGetValue(playerID, out var value);
		return value;
	}

	private void creatContainer(long playerID)
	{
		//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)
		Container component = Object.Instantiate<GameObject>(m_spawnContainer, ((Component)this).transform.position, ((Component)this).transform.rotation).GetComponent<Container>();
		component.m_name = "Bank-" + playerID;
		m_inventories.Add(playerID, component);
	}

	private void CheckForChanges()
	{
		if (!m_nview.IsValid())
		{
			return;
		}
		foreach (KeyValuePair<long, Container> inventory in m_inventories)
		{
			Load(inventory.Value);
		}
		UpdateUseVisual();
	}

	private void UpdateUseVisual()
	{
		bool flag;
		if (m_nview.IsOwner())
		{
			flag = m_inUse;
			m_nview.GetZDO().Set(ZDOVars.s_inUse, 0, false);
		}
		else
		{
			flag = m_nview.GetZDO().GetInt(ZDOVars.s_inUse, 0) == 1;
		}
		if (Object.op_Implicit((Object)(object)m_open))
		{
			m_open.SetActive(flag);
		}
		if (Object.op_Implicit((Object)(object)m_closed))
		{
			m_closed.SetActive(!flag);
		}
	}

	public string GetHoverText()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		return (!PrivateArea.CheckAccess(((Component)this).transform.position, 0f, false, false)) ? Localization.instance.Localize(m_name + "\n$piece_noaccess") : Localization.instance.Localize(m_name + "\n[<color=yellow><b>$KEY_Use</b></color>] $piece_container_open $msg_stackall_hover");
	}

	public string GetHoverName()
	{
		return m_name;
	}

	bool Interactable.Interact(Humanoid user, bool hold, bool alt)
	{
		throw new NotImplementedException();
	}

	private bool CheckAccess(long playerID)
	{
		//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_001c: Expected I4, but got Unknown
		PrivacySetting privacy = m_privacy;
		PrivacySetting val = privacy;
		return (int)val switch
		{
			0 => m_piece.GetCreator() == playerID, 
			1 => false, 
			2 => true, 
			_ => false, 
		};
	}

	public bool IsOwner()
	{
		return m_nview.IsOwner();
	}

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

	public bool CanBeRemoved()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Invalid comparison between Unknown and I4
		return (int)m_privacy > 0;
	}

	private void Save(Container container)
	{
		container.Save();
	}

	private void Load(Container container)
	{
		container.Load();
	}

	private void RPC_RequestOpen(long uid, long playerID)
	{
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		ZLog.Log((object)("Player " + uid + " wants to open " + ((Object)((Component)this).gameObject).name + "   im: " + ZDOMan.GetSessionID()));
		if (!m_nview.IsOwner())
		{
			ZLog.Log((object)"  but im not the owner");
		}
		else if (uid != ZNet.GetUID())
		{
			ZLog.Log((object)"  in use");
			m_nview.InvokeRPC(uid, "OpenRespons", new object[2] { playerID, false });
		}
		else if (!CheckAccess(playerID))
		{
			ZLog.Log((object)"  not yours");
			m_nview.InvokeRPC(uid, "OpenRespons", new object[2] { playerID, false });
		}
		else
		{
			ZDOMan.instance.ForceSendZDO(uid, m_nview.GetZDO().m_uid);
			m_nview.GetZDO().SetOwner(uid);
			m_nview.InvokeRPC(uid, "OpenRespons", new object[2] { playerID, true });
		}
	}

	private void RPC_OpenRespons(long uid, long playerId, bool granted)
	{
		if (Object.op_Implicit((Object)(object)Player.m_localPlayer))
		{
			if (granted)
			{
				Container container = GetContainer(playerId);
				InventoryGui.instance.Show(container, 1);
			}
			else
			{
				((Character)Player.m_localPlayer).Message((MessageType)2, "$msg_inuse", 0, (Sprite)null);
			}
		}
	}

	public void StackAll()
	{
		m_nview.InvokeRPC("RPC_RequestStack", new object[1] { Game.instance.GetPlayerProfile().GetPlayerID() });
	}

	private void RPC_RequestStack(long uid, long playerID)
	{
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		ZLog.Log((object)("Player " + uid + " wants to stack all in " + ((Object)((Component)this).gameObject).name + "   im: " + ZDOMan.GetSessionID()));
		if (!m_nview.IsOwner())
		{
			ZLog.Log((object)"  but im not the owner");
		}
		else if (uid != ZNet.GetUID())
		{
			ZLog.Log((object)"  in use");
			m_nview.InvokeRPC(uid, "RPC_StackResponse", new object[2] { playerID, false });
		}
		else if (!CheckAccess(playerID))
		{
			ZLog.Log((object)"  not yours");
			m_nview.InvokeRPC(uid, "RPC_StackResponse", new object[2] { playerID, false });
		}
		else
		{
			ZDOMan.instance.ForceSendZDO(uid, m_nview.GetZDO().m_uid);
			m_nview.GetZDO().SetOwner(uid);
			m_nview.InvokeRPC(uid, "RPC_StackResponse", new object[2] { playerID, true });
		}
	}

	private void RPC_StackResponse(long uid, long playerId, bool granted)
	{
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)Player.m_localPlayer))
		{
			return;
		}
		if (granted)
		{
			Container container = GetContainer(playerId);
			if (container.m_inventory.StackAll(((Humanoid)Player.m_localPlayer).GetInventory(), true) > 0)
			{
				InventoryGui.instance.m_moveItemEffects.Create(((Component)this).transform.position, Quaternion.identity, (Transform)null, 1f, -1);
			}
		}
		else
		{
			((Character)Player.m_localPlayer).Message((MessageType)2, "$msg_inuse", 0, (Sprite)null);
		}
	}

	public bool TakeAll(Humanoid character)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		if (!PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false))
		{
			return false;
		}
		long playerID = Game.instance.GetPlayerProfile().GetPlayerID();
		if (!CheckAccess(playerID))
		{
			((Character)character).Message((MessageType)2, "$msg_cantopen", 0, (Sprite)null);
			return false;
		}
		m_nview.InvokeRPC("RequestTakeAll", new object[1] { playerID });
		return true;
	}

	private void RPC_RequestTakeAll(long uid, long playerID)
	{
		ZLog.Log((object)("Player " + uid + " wants to takeall from " + ((Object)((Component)this).gameObject).name + "   im: " + ZDOMan.GetSessionID()));
		if (!m_nview.IsOwner())
		{
			ZLog.Log((object)"  but im not the owner");
		}
		else if (uid != ZNet.GetUID())
		{
			ZLog.Log((object)"  in use");
			m_nview.InvokeRPC(uid, "TakeAllRespons", new object[2] { playerID, false });
		}
		else if (!CheckAccess(playerID))
		{
			ZLog.Log((object)"  not yours");
			m_nview.InvokeRPC(uid, "TakeAllRespons", new object[2] { playerID, false });
		}
		else if (!((double)Time.time - (double)m_lastTakeAllTime < 2.0))
		{
			m_lastTakeAllTime = Time.time;
			m_nview.InvokeRPC(uid, "TakeAllRespons", new object[2] { playerID, true });
		}
	}

	private void RPC_TakeAllRespons(long uid, long playerID, bool granted)
	{
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)Player.m_localPlayer))
		{
			return;
		}
		if (granted)
		{
			m_nview.ClaimOwnership();
			ZDOMan.instance.ForceSendZDO(uid, m_nview.GetZDO().m_uid);
			Container container = GetContainer(playerID);
			((Humanoid)Player.m_localPlayer).GetInventory().MoveAll(container.m_inventory);
			if (m_onTakeAllSuccess != null)
			{
				m_onTakeAllSuccess();
			}
		}
		else
		{
			((Character)Player.m_localPlayer).Message((MessageType)2, "$msg_inuse", 0, (Sprite)null);
		}
	}
}
internal class BuildPieceList
{
	public static string[] buildPieces = new string[4] { "RavenwoodColosseum_bal", "bigwood_gate1_bal", "bigwood_gate2_bal", "mainwood_gate_bal" };
}
public class DatabaseAddMethods
{
	public void AddItems(List<GameObject> items)
	{
		foreach (GameObject item in items)
		{
			AddItem(item);
		}
	}

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

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

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

	private void AddStatus(StatusEffect status)
	{
		if (!IsObjectDBValid())
		{
			return;
		}
		if ((Object)(object)status != (Object)null)
		{
			if ((Object)(object)ObjectDB.instance.GetStatusEffect(status.m_nameHash) == (Object)null)
			{
				ObjectDB.instance.m_StatusEffects.Add(status);
			}
			else
			{
				Debug.Log((object)(Launch.projectName + ":  " + ((Object)status).name + " - Status already in the game"));
			}
		}
		else
		{
			Debug.LogError((object)(Launch.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.m_recipes.Find((Recipe x) => ((Object)x).name == ((Object)recipe).name) == (Object)null)
			{
				if ((Object)(object)recipe.m_item != (Object)null)
				{
					ObjectDB.instance.m_recipes.Add(recipe);
				}
			}
			else
			{
				Debug.Log((object)(Launch.projectName + ":  " + ((Object)recipe).name + " - Recipe with this name already in the Game"));
			}
		}
		else
		{
			Debug.LogError((object)(Launch.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;
			}
			else
			{
				Debug.LogWarning((object)(Launch.projectName + ": " + ((Object)newPrefab).name + " - ItemDrop already exist"));
			}
		}
		else
		{
			Debug.LogError((object)(Launch.projectName + ": " + ((Object)newPrefab).name + " - ItemDrop not found on prefab"));
		}
	}
}
public class FxReplacment
{
	private List<GameObject> allPrefabs;

	private string projectName = "[BalrondRavenwoodRome]";

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	public FxReplacment fxReplacment = null;

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

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

	public StatusEffect newBarleyStatus = null;

	public ShaderReplacment shaderReplacment = new ShaderReplacment();

	public Sprite newLogo = null;

	public void loadAssets()
	{
		assetBundle = GetAssetBundleFromResources("balrondrome");
		string basePath = "Assets/Custom/Comission/Rome/";
		loadPieces(basePath);
	}

	public void AddPrefabsToZnetScene(ZNetScene zNetScene)
	{
		zNetScene.m_prefabs.AddRange(vegetationPrefabs);
		foreach (GameObject gm in itemPrefabs)
		{
			GameObject val = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == ((Object)gm).name);
			if ((Object)(object)val == (Object)null)
			{
				zNetScene.m_prefabs.Add(gm);
			}
			else
			{
				Debug.LogWarning((object)("Object exists: " + ((Object)gm).name));
			}
		}
		foreach (GameObject gm2 in buildPrefabs)
		{
			GameObject val2 = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == ((Object)gm2).name);
			if ((Object)(object)val2 == (Object)null)
			{
				zNetScene.m_prefabs.Add(gm2);
			}
			else
			{
				Debug.LogWarning((object)("Object exists: " + ((Object)gm2).name));
			}
		}
		foreach (GameObject gm3 in vfxPrefabs)
		{
			GameObject val3 = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == ((Object)gm3).name);
			if ((Object)(object)val3 == (Object)null)
			{
				zNetScene.m_prefabs.Add(gm3);
			}
			else
			{
				Debug.LogWarning((object)("Object exists: " + ((Object)gm3).name));
			}
		}
		zNetScene.m_prefabs.RemoveAll((GameObject x) => (Object)(object)x == (Object)null);
		addPlantstoCultivator(zNetScene);
		setupBuildPiecesList(zNetScene);
	}

	private void setupBuildPiecesList(ZNetScene zNetScene)
	{
		string[] array = new string[4] { "Hammer", "HammerIron", "HammerDverger", "HammerBlackmetal" };
		GameObject val = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "Hammer");
		PieceTable buildPieces = val.GetComponent<ItemDrop>().m_itemData.m_shared.m_buildPieces;
		string[] array2 = array;
		foreach (string name in array2)
		{
			addBuildpiecesToOtherHammer(name, buildPieces, zNetScene);
		}
		List<GameObject> pieces = buildPieces.m_pieces;
		foreach (GameObject buildPrefab in buildPrefabs)
		{
			setupRavenGuide(buildPrefab, zNetScene.m_prefabs);
			AddToBuildList(buildPrefab, pieces);
		}
	}

	private void addBuildpiecesToOtherHammer(string name, PieceTable pieceTable, ZNetScene zNetScene)
	{
		GameObject val = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == name);
		if (!((Object)(object)val == (Object)null))
		{
			val.GetComponent<ItemDrop>().m_itemData.m_shared.m_buildPieces = pieceTable;
		}
	}

	public void setupRavenGuide(GameObject gameObject, List<GameObject> gameObjects)
	{
		GameObject val = null;
		Transform val2 = gameObject.transform.Find("GuidePoint");
		if ((Object)(object)val2 == (Object)null)
		{
			return;
		}
		GameObject val3 = gameObjects.Find((GameObject x) => ((Object)x).name == "piece_workbench");
		if ((Object)(object)val3 != (Object)null)
		{
			GameObject gameObject2 = ((Component)val3.transform.Find("GuidePoint")).gameObject;
			if ((Object)(object)gameObject2 != (Object)null)
			{
				GuidePoint component = gameObject2.GetComponent<GuidePoint>();
				if ((Object)(object)component != (Object)null)
				{
					val = component.m_ravenPrefab;
				}
			}
		}
		if ((Object)(object)val == (Object)null)
		{
			Debug.LogWarning((object)"Ravens not found");
		}
		else
		{
			((Component)val2).GetComponent<GuidePoint>().m_ravenPrefab = val;
		}
	}

	public void setupBuildPiecesListDB()
	{
		GameObject val = ObjectDB.instance.m_items.Find((GameObject x) => ((Object)x).name == "Hammer");
		List<GameObject> pieces = val.GetComponent<ItemDrop>().m_itemData.m_shared.m_buildPieces.m_pieces;
		foreach (GameObject buildPrefab in buildPrefabs)
		{
			AddToBuildList(buildPrefab, pieces);
		}
	}

	private void AddToBuildList(GameObject prefab, List<GameObject> buildPieces)
	{
		if ((Object)(object)buildPieces.Find((GameObject x) => ((Object)x).name == ((Object)prefab).name) == (Object)null)
		{
			buildPieces.Add(prefab);
		}
	}

	private void addPlantstoCultivator(ZNetScene zNetScene)
	{
		GameObject val = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "Cultivator");
		PieceTable buildPieces = val.GetComponent<ItemDrop>().m_itemData.m_shared.m_buildPieces;
		List<GameObject> pieces = buildPieces.m_pieces;
		foreach (GameObject plantPrefab in plantPrefabs)
		{
			pieces.Add(plantPrefab);
		}
	}

	public void FixAllFx(FxReplacment fxReplacment)
	{
		this.fxReplacment = fxReplacment;
		fixBuildPiecesFX();
		fixVegetationFX();
		fixItemFX();
		fixMonsterFX();
		fixOtherFX();
	}

	private void loadStatusFromPotion()
	{
		string[] source = new string[0];
		foreach (GameObject itemPrefab in itemPrefabs)
		{
			if (source.Contains(((Object)itemPrefab).name))
			{
				ItemDrop component = itemPrefab.GetComponent<ItemDrop>();
				SharedData shared = component.m_itemData.m_shared;
				checkForStatus(shared.m_consumeStatusEffect);
				checkForStatus(shared.m_setStatusEffect);
				checkForStatus(shared.m_equipStatusEffect);
				checkForStatus(shared.m_attackStatusEffect);
			}
		}
		Debug.Log((object)("Loaded Potion status: " + statusEffects.Count));
	}

	private void checkForStatus(StatusEffect status)
	{
		if ((Object)(object)status != (Object)null)
		{
			statusEffects.Add(status);
		}
	}

	private void fixVegetationFX()
	{
		foreach (GameObject vegetationPrefab in vegetationPrefabs)
		{
			fxReplacment.ReplaceOnVegetation(vegetationPrefab);
		}
	}

	private void fixBuildPiecesFX()
	{
		foreach (GameObject buildPrefab in buildPrefabs)
		{
			fxReplacment.ReplaceFxOnPiece(buildPrefab);
		}
	}

	private void fixItemFX()
	{
		foreach (GameObject itemPrefab in itemPrefabs)
		{
			fxReplacment.ReplaceOnItem(itemPrefab);
		}
	}

	private void fixMonsterFX()
	{
		foreach (GameObject monsterPrefab in monsterPrefabs)
		{
			fxReplacment.ReplaceOnMonster(monsterPrefab);
		}
	}

	private void fixOtherFX()
	{
		foreach (GameObject vfxPrefab in vfxPrefabs)
		{
			fxReplacment.ReplaceOnObject(vfxPrefab);
		}
	}

	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 loadPlants(string basePath)
	{
		string text = basePath + "Plants/";
		string[] array = new string[0];
		string[] array2 = array;
		foreach (string text2 in array2)
		{
			GameObject val = assetBundle.LoadAsset<GameObject>(text + text2 + ".prefab");
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogWarning((object)("Could not find plant with name: " + text2));
				continue;
			}
			ShaderReplacment.Replace(val);
			plantPrefabs.Add(val);
		}
	}

	private void loadPieces(string basePath)
	{
		string text = basePath + "Pieces/";
		string[] buildPieces = BuildPieceList.buildPieces;
		string[] array = buildPieces;
		foreach (string text2 in array)
		{
			GameObject val = assetBundle.LoadAsset<GameObject>(text + text2 + ".prefab");
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogWarning((object)("Could not find piece with name: " + text2));
				continue;
			}
			ShaderReplacment.Replace(val);
			buildPrefabs.Add(val);
		}
	}

	private void loadItems(string basePath)
	{
		string text = basePath + "Items/";
		string[] array = new string[0];
		string[] array2 = array;
		foreach (string text2 in array2)
		{
			GameObject val = assetBundle.LoadAsset<GameObject>(text + text2 + ".prefab");
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogWarning((object)("Could not find item with name: " + text2));
				continue;
			}
			ShaderReplacment.Replace(val);
			itemPrefabs.Add(val);
		}
	}

	private void loadVegetation(string basePath)
	{
		string text = basePath + "Vegetation/";
		string[] array = new string[0];
		string[] array2 = array;
		foreach (string text2 in array2)
		{
			GameObject val = assetBundle.LoadAsset<GameObject>(text + text2 + ".prefab");
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogWarning((object)("Could not find vegegation with name: " + text2));
				continue;
			}
			ShaderReplacment.Replace(val);
			vegetationPrefabs.Add(val);
		}
	}

	private void loadOther(string basePath)
	{
		string text = basePath + "Other/";
		string[] array = new string[1] { "sfx_queendoor_open1" };
		string[] array2 = array;
		foreach (string text2 in array2)
		{
			GameObject val = assetBundle.LoadAsset<GameObject>(text + text2 + ".prefab");
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogWarning((object)("Could not find object with name: " + text2));
				continue;
			}
			ShaderReplacment.Replace(val);
			vfxPrefabs.Add(val);
		}
	}

	public void setIronHook(ZNetScene zNetScene)
	{
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Expected O, but got Unknown
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Expected O, but got Unknown
		GameObject val = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "piece_cookingstation_iron");
		GameObject val2 = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "piece_cookingstation");
		ItemConversion val3 = new ItemConversion();
		val3.m_from = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "BearMeat").GetComponent<ItemDrop>();
		val3.m_to = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "BearMeatCooked").GetComponent<ItemDrop>();
		val3.m_cookTime = 40f;
		ItemConversion val4 = new ItemConversion();
		val4.m_from = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "Potato").GetComponent<ItemDrop>();
		val4.m_to = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "PotatoFried").GetComponent<ItemDrop>();
		val4.m_cookTime = 30f;
		if ((Object)(object)val != (Object)null)
		{
			CookingStation component = val.GetComponent<CookingStation>();
			component.m_conversion.Add(val4);
			component.m_conversion.Add(val3);
		}
		if ((Object)(object)val2 != (Object)null)
		{
			CookingStation component2 = val2.GetComponent<CookingStation>();
			component2.m_conversion.Add(val4);
			component2.m_conversion.Add(val3);
		}
	}

	public void setupPickableDrops(ZNetScene zNetScene)
	{
		GameObject val = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "Pickable_MeadowsMeatPile01");
		GameObject val2 = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "Pickable_MeadowsMeatPile02");
		Pickable component = val.GetComponent<Pickable>();
		Pickable component2 = val2.GetComponent<Pickable>();
		GameObject item = getItem(zNetScene, "RawMeat");
		if ((Object)(object)item != (Object)null)
		{
			component.m_itemPrefab = item;
			component2.m_itemPrefab = item;
		}
		createExtraDrops(component, zNetScene);
		createExtraDrops(component2, zNetScene);
	}

	private void createExtraDrops(Pickable pickable, ZNetScene zNetScene)
	{
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		List<DropData> list = new List<DropData>();
		string name = ((Object)((Component)pickable).gameObject).name;
		string text = name;
		if (!(text == "Pickable_MeadowsMeatPile01"))
		{
			if (text == "Pickable_MeadowsMeatPile02")
			{
				list.Add(createDrop(zNetScene, "RawMeat", 1, 1, 0.4f));
				list.Add(createDrop(zNetScene, "Coins", 5, 15, 0.2f));
				list.Add(createDrop(zNetScene, "BoneFragments", 1, 3, 0.2f));
				list.Add(createDrop(zNetScene, "NeckTail", 1, 2, 0.3f));
			}
		}
		else
		{
			list.Add(createDrop(zNetScene, "RawMeat", 1, 1, 0.4f));
			list.Add(createDrop(zNetScene, "DeerMeat", 1, 1, 0.2f));
			list.Add(createDrop(zNetScene, "NeckTail", 1, 2, 0.3f));
			list.Add(createDrop(zNetScene, "Honey", 1, 2, 0.1f));
		}
		pickable.m_extraDrops.m_drops = list;
	}

	private DropData createDrop(ZNetScene zNetScene, string name, int min, int max, float chance)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: 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_0036: Unknown result type (might be due to invalid IL or missing references)
		DropData result = default(DropData);
		result.m_stackMin = min;
		result.m_stackMax = max;
		result.m_weight = chance;
		result.m_item = getItem(zNetScene, name);
		return result;
	}

	private GameObject getItem(ZNetScene zNetScene, string name)
	{
		return zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == name);
	}
}
public class ShaderReplacment
{
	public static List<GameObject> prefabsToReplaceShader = new List<GameObject>();

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

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

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

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

	public static bool debug = true;

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

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

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

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

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

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

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

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

	private static string checkNaming(string name)
	{
		string result = name;
		if (name.Contains("Bumped"))
		{
			result = name.Replace("Custom", "Lux Lit Particles");
		}
		if (name.Contains("Tess Bumped"))
		{
			result = name.Replace("Custom", "Lux Lit Particles");
		}
		if (name.Contains("Standard Surface"))
		{
			result = name.Replace("Custom", "Particles");
			result = result.Replace("Standard Surface2", "Standard Surface");
		}
		if (name.Contains("Standard Unlit"))
		{
			result = name.Replace("Custom", "Particles");
			result = result.Replace("Standard Unlit", "Standard Unlit2");
			result = result.Replace("Standard Unlit22", "Standard Unlit2");
		}
		return result;
	}
}
[BepInPlugin("balrond.astafaraios.RavenwoodColosseum", "RavenwoodColosseum", "1.0.0")]
public class Launch : BaseUnityPlugin
{
	[HarmonyPatch(typeof(Player), "UseStamina")]
	private class Player_UseStamina
	{
		private static bool Prefix()
		{
			if (Player.m_debugMode && ((Terminal)Console.instance).IsCheatsEnabled())
			{
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(AudioMan), "Awake")]
	private static class AudioMan_Awake_Patch
	{
		private static void Postfix(AudioMan __instance)
		{
			foreach (GameObject itemPrefab in modResourceLoader.itemPrefabs)
			{
				AudioSource[] componentsInChildren = itemPrefab.GetComponentsInChildren<AudioSource>(true);
				foreach (AudioSource val in componentsInChildren)
				{
					val.outputAudioMixerGroup = __instance.m_masterMixer.outputAudioMixerGroup;
				}
			}
			foreach (GameObject buildPrefab in modResourceLoader.buildPrefabs)
			{
				AudioSource[] componentsInChildren2 = buildPrefab.GetComponentsInChildren<AudioSource>(true);
				foreach (AudioSource val2 in componentsInChildren2)
				{
					val2.outputAudioMixerGroup = __instance.m_masterMixer.outputAudioMixerGroup;
				}
			}
			foreach (GameObject monsterPrefab in modResourceLoader.monsterPrefabs)
			{
				AudioSource[] componentsInChildren3 = monsterPrefab.GetComponentsInChildren<AudioSource>(true);
				foreach (AudioSource val3 in componentsInChildren3)
				{
					val3.outputAudioMixerGroup = __instance.m_masterMixer.outputAudioMixerGroup;
				}
			}
			foreach (GameObject vfxPrefab in modResourceLoader.vfxPrefabs)
			{
				AudioSource[] componentsInChildren4 = vfxPrefab.GetComponentsInChildren<AudioSource>(true);
				foreach (AudioSource val4 in componentsInChildren4)
				{
					val4.outputAudioMixerGroup = __instance.m_masterMixer.outputAudioMixerGroup;
				}
			}
			foreach (GameObject vegetationPrefab in modResourceLoader.vegetationPrefabs)
			{
				AudioSource[] componentsInChildren5 = vegetationPrefab.GetComponentsInChildren<AudioSource>(true);
				foreach (AudioSource val5 in componentsInChildren5)
				{
					val5.outputAudioMixerGroup = __instance.m_masterMixer.outputAudioMixerGroup;
				}
			}
		}
	}

	[HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")]
	public static class Object_CopyOtherDB_Path
	{
		public static void Postfix()
		{
			if (IsObjectDBValid())
			{
				modResourceLoader.setupBuildPiecesListDB();
				databaseAddMethods.AddItems(modResourceLoader.itemPrefabs);
				databaseAddMethods.AddStatuseffects(modResourceLoader.statusEffects);
				databaseAddMethods.AddRecipes(modResourceLoader.recipes);
			}
		}
	}

	[HarmonyPatch(typeof(ObjectDB), "Awake")]
	public static class ObjectDB_Awake_Path
	{
		public static void Postfix()
		{
			if (IsObjectDBValid())
			{
				modResourceLoader.setupBuildPiecesListDB();
				databaseAddMethods.AddItems(modResourceLoader.itemPrefabs);
				databaseAddMethods.AddStatuseffects(modResourceLoader.statusEffects);
				databaseAddMethods.AddRecipes(modResourceLoader.recipes);
				ObjectDB.instance.m_recipes.Sort(SortByScore);
			}
		}

		private static int SortByScore(Recipe p1, Recipe p2)
		{
			if ((Object)(object)p1.m_item == (Object)null)
			{
				return 0;
			}
			if ((Object)(object)p2.m_item == (Object)null)
			{
				return 1;
			}
			return ((Object)p1.m_item).name.CompareTo(((Object)p2.m_item).name);
		}
	}

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

		public static void Prefix(ZNetScene __instance)
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)null)
			{
				Debug.LogWarning((object)(projectName + ": No ZnetScene found"));
				return;
			}
			fxReplacment.setInstance(__instance.m_prefabs);
			modResourceLoader.FixAllFx(fxReplacment);
			modResourceLoader.AddPrefabsToZnetScene(__instance);
			if (!Launch.hasSpawned)
			{
				buildPieceBuilder.SetupBuildPieces(__instance.m_prefabs);
				hasSpawned = true;
				if (!new ZNet().IsDedicated())
				{
					ShaderReplacment.runMaterialFix();
				}
			}
		}
	}

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

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

	public const string PluginName = "RavenwoodColosseum";

	public const string PluginVersion = "1.0.0";

	public static ModResourceLoader modResourceLoader = new ModResourceLoader();

	public static FxReplacment fxReplacment = new FxReplacment();

	public static DatabaseAddMethods databaseAddMethods = new DatabaseAddMethods();

	public static BuildPieceBuilder buildPieceBuilder = new BuildPieceBuilder();

	public static string projectName = "RavenwoodColosseum";

	public static GameObject RootObject;

	public static GameObject PrefabContainer;

	public static bool hasSpawned = false;

	private void Awake()
	{
		createPrefabContainer();
		modResourceLoader.loadAssets();
		harmony.PatchAll();
	}

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

	public static GameObject cloneMe(GameObject source, string name)
	{
		GameObject val = Object.Instantiate<GameObject>(source, PrefabContainer.transform);
		((Object)val).name = name;
		fixMaterials(val, source);
		val.SetActive(true);
		return val;
	}

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

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

	private static bool IsObjectDBValid()
	{
		return (Object)(object)ObjectDB.instance != (Object)null && ObjectDB.instance.m_items.Count != 0 && ObjectDB.instance.m_recipes.Count != 0 && (Object)(object)ObjectDB.instance.GetItemPrefab("Amber") != (Object)null;
	}
}
public class BuildPieceBuilder
{
	private List<GameObject> list;

	private string[] piecesNames = BuildPieceList.buildPieces;

	private CraftingStation workbench;

	private CraftingStation tannery;

	private CraftingStation runeForge;

	private CraftingStation alchemyLab;

	private CraftingStation grill;

	private CraftingStation fletcher;

	private CraftingStation blackforge;

	private CraftingStation forge;

	private CraftingStation cauldron;

	private CraftingStation stonecutter;

	public void SetupBuildPieces(List<GameObject> list)
	{
		setupTables(list);
		this.list = list;
		string[] array = piecesNames;
		foreach (string name in array)
		{
			GameObject val = list.Find((GameObject x) => ((Object)x).name == name);
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogWarning((object)("Cant find buildpiece with name: " + name));
			}
			else
			{
				EditBuildPiece(val);
			}
		}
	}

	private void EditBuildPiece(GameObject gameObject)
	{
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_015a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0227: Unknown result type (might be due to invalid IL or missing references)
		Piece component = gameObject.gameObject.GetComponent<Piece>();
		component.m_resources = (Requirement[])(object)new Requirement[0];
		SetStation(component, workbench);
		switch (((Object)gameObject).name)
		{
		case "RavenwoodColosseum_bal":
			component.m_name = "Ravenwood Colosseum";
			component.m_description = "";
			SetStation(component, stonecutter);
			component.m_resources = (Requirement[])(object)new Requirement[0];
			AddResources(component, "BronzeNails", 500);
			AddResources(component, "Stone", 1000);
			AddResources(component, "Coins", 4000);
			component.m_category = (PieceCategory)0;
			break;
		case "mainwood_gate_bal":
			component.m_name = "Main Colosseum Gate";
			component.m_description = "Main gates for the Colosseum";
			SetStation(component, workbench);
			component.m_resources = (Requirement[])(object)new Requirement[0];
			AddResources(component, "FineWood", 5);
			AddResources(component, "Bronze", 5);
			component.m_category = (PieceCategory)0;
			break;
		case "bigwood_gate1_bal":
			component.m_name = "Colosseum Gate 2";
			component.m_description = "Inner gates for the Colosseum ";
			SetStation(component, workbench);
			component.m_resources = (Requirement[])(object)new Requirement[0];
			AddResources(component, "FineWood", 8);
			AddResources(component, "Bronze", 8);
			component.m_category = (PieceCategory)0;
			break;
		case "bigwood_gate2_bal":
			component.m_name = "Colosseum Gate 1";
			component.m_description = "Inner gates for the Colosseum ";
			SetStation(component, workbench);
			component.m_resources = (Requirement[])(object)new Requirement[0];
			AddResources(component, "FineWood", 8);
			AddResources(component, "Bronze", 8);
			component.m_category = (PieceCategory)0;
			break;
		}
	}

	private void setFireplaceFuelItem(Piece piece, string name, int startFuel = -1, int maxFuel = -1, float secPerFuel = -1f)
	{
		Fireplace component = ((Component)piece).GetComponent<Fireplace>();
		component.m_fuelItem = FindItem(list, name).GetComponent<ItemDrop>();
		component.m_startFuel = ((startFuel != -1) ? ((float)startFuel) : component.m_startFuel);
		component.m_maxFuel = ((maxFuel != -1) ? ((float)maxFuel) : component.m_maxFuel);
		component.m_secPerFuel = ((secPerFuel != -1f) ? secPerFuel : component.m_secPerFuel);
	}

	private void SetStation(Piece piece, CraftingStation station)
	{
		piece.m_craftingStation = station;
	}

	private void EditResource(Piece piece, string itemName, int amount, bool remove = false)
	{
		if (remove)
		{
			List<Requirement> list = new List<Requirement>();
			Requirement[] resources = piece.m_resources;
			foreach (Requirement val in resources)
			{
				if (((Object)((Component)val.m_resItem).gameObject).name != itemName)
				{
					list.Add(val);
				}
			}
			piece.m_resources = list.ToArray();
			return;
		}
		Requirement[] resources2 = piece.m_resources;
		foreach (Requirement val2 in resources2)
		{
			if (((Object)((Component)val2.m_resItem).gameObject).name == itemName)
			{
				val2.m_amount = amount;
			}
		}
	}

	private void AddResources(Piece piece, string itemName, int amount, int amountPerLevel = 0, string altItem = "", int altAmount = 0, int altAmountPerLevel = 0)
	{
		List<Requirement> list = new List<Requirement>();
		list.AddRange(piece.m_resources);
		Requirement item = createReq(itemName, amount, amountPerLevel, altItem, altAmount, altAmountPerLevel);
		list.Add(item);
		piece.m_resources = list.ToArray();
	}

	private Requirement createReq(string name, int amount, int amountPerLevel, string altItem = "", int altAmount = 0, int altAmountPerLevel = 0)
	{
		//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;
		GameObject val2 = list.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 = FindItem(list, altItem);
			ItemDrop component2 = val2.GetComponent<ItemDrop>();
			val.m_amount = altAmount;
			val.m_amountPerLevel = altAmountPerLevel;
			val.m_resItem = component2;
		}
		return val;
	}

	private GameObject FindItem(List<GameObject> list, string name, bool isStation = false)
	{
		GameObject val = list.Find((GameObject x) => ((Object)x).name == name);
		if ((Object)(object)val != (Object)null)
		{
			return val;
		}
		if ((Object)(object)val == (Object)null && isStation)
		{
			return null;
		}
		Debug.LogWarning((object)(Launch.projectName + ": Item Not Found - " + name + ", Replaced With Wood"));
		return list.Find((GameObject x) => ((Object)x).name == "Wood");
	}

	private CraftingStation FindStation(List<GameObject> list, string name)
	{
		GameObject val = FindItem(list, name, isStation: true);
		if ((Object)(object)val != (Object)null)
		{
			return val.GetComponent<CraftingStation>();
		}
		return null;
	}

	private void getSignToWork(Piece newSign)
	{
		//IL_006d: 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)
		GameObject val = list.Find((GameObject x) => ((Object)x).name == "Sign");
		if ((Object)(object)val != (Object)null)
		{
			Debug.LogWarning((object)"Fixing sign values");
			TextMeshProUGUI textWidget = val.GetComponent<Sign>().m_textWidget;
			TextMeshProUGUI textWidget2 = ((Component)newSign).GetComponent<Sign>().m_textWidget;
			((TMP_Text)textWidget2).font = ((TMP_Text)textWidget).font;
			((Graphic)textWidget2).color = ((Graphic)textWidget).color;
			((TMP_Text)textWidget2).fontSize = ((TMP_Text)textWidget).fontSize;
			((TMP_Text)textWidget2).fontStyle = ((TMP_Text)textWidget).fontStyle;
			((TMP_Text)textWidget2).fontSizeMax = ((TMP_Text)textWidget).fontSizeMax;
			((TMP_Text)textWidget2).fontFeatures = ((TMP_Text)textWidget).fontFeatures;
			((TMP_Text)textWidget2).fontSharedMaterial = ((TMP_Text)textWidget).fontSharedMaterial;
			((TMP_Text)textWidget2).fontSharedMaterials = ((TMP_Text)textWidget).fontSharedMaterials;
			((TMP_Text)textWidget2).fontMaterial = ((TMP_Text)textWidget).fontMaterial;
			((TMP_Text)textWidget2).fontMaterials = ((TMP_Text)textWidget).fontMaterials;
		}
	}

	private void setupTables(List<GameObject> list)
	{
		workbench = FindStation(list, "piece_workbench");
		if ((Object)(object)workbench == (Object)null)
		{
			Debug.LogWarning((object)"Did not foundpiece_workbench");
		}
		tannery = FindStation(list, "piece_tannery");
		if ((Object)(object)tannery == (Object)null)
		{
			tannery = workbench;
		}
		blackforge = FindStation(list, "blackforge");
		if ((Object)(object)blackforge == (Object)null)
		{
			Debug.LogWarning((object)"Did not foundblackforge");
		}
		forge = FindStation(list, "forge");
		if ((Object)(object)forge == (Object)null)
		{
			Debug.LogWarning((object)"Did not foundforge");
		}
		cauldron = FindStation(list, "piece_cauldron");
		if ((Object)(object)cauldron == (Object)null)
		{
			Debug.LogWarning((object)"Did not foundpiece_cauldron");
		}
		runeForge = FindStation(list, "piece_runeforge");
		if ((Object)(object)runeForge == (Object)null)
		{
			runeForge = forge;
		}
		alchemyLab = FindStation(list, "piece_alchemylab");
		if ((Object)(object)alchemyLab == (Object)null)
		{
			alchemyLab = cauldron;
		}
		grill = FindStation(list, "piece_grill");
		if ((Object)(object)grill == (Object)null)
		{
			grill = cauldron;
		}
		fletcher = FindStation(list, "piece_fletcher");
		if ((Object)(object)fletcher == (Object)null)
		{
			fletcher = workbench;
		}
		stonecutter = FindStation(list, "piece_stonecutter");
		if ((Object)(object)stonecutter == (Object)null)
		{
			Debug.LogWarning((object)"Did not foundpiece_stonecutter");
			stonecutter = workbench;
		}
	}
}
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 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;
	}
}