Decompiled source of balrond BannerColorizer v1.0.6

plugins/BalrondBannerColorizer.dll

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

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

public class FxReplacment
{
	private List<GameObject> allPrefabs;

	private string projectName = "[BalrondBannerColorizer]";

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	public static bool debug = true;

	public static void ReplaceMaterial(Material material)
	{
		materialsInPrefabs.Add(material);
	}

	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;
	}
}
[Serializable]
public class BannerColorizer : MonoBehaviour, Hoverable, Interactable
{
	private ZNetView m_zview;

	private Piece m_piece;

	public List<ColorizerPack> m_packs;

	private string skinName = "";

	public string defaultSkinName = "";

	public static ModResourceLoader modResourceLoader = Launch.modResourceLoader;

	private List<ColorizerPack> colorizerPacks = new List<ColorizerPack>();

	private List<ColorizerPack> colorizerPacksFull = Launch.colorizerPacks;

	private ColorizerPack m_colorizerPack;

	public List<MeshRenderer> banner = new List<MeshRenderer>();

	private List<MeshRenderer> m_destruction = new List<MeshRenderer>();

	private MeshRenderer main;

	private string m_useItemText = "Add dye";

	private void Awake()
	{
		if (!validatePrefab())
		{
			Debug.LogWarning((object)("I should not  be randomized: " + ((Object)((Component)this).gameObject).name));
			return;
		}
		filterPacks();
		if ((Object)(object)modResourceLoader.banner01black == (Object)null)
		{
			Debug.LogWarning((object)"Nothing loaded");
		}
		m_zview = ((Component)this).GetComponent<ZNetView>();
		m_piece = ((Component)this).GetComponent<Piece>();
		if ((Object)(object)m_zview == (Object)null || !m_zview.IsValid() || m_zview.GetZDO() == null)
		{
			return;
		}
		m_zview.Register<string>("RPC_Paint", (Action<long, string>)RPC_Paint);
		setDefaulDyeName();
		if (!setupColorizer())
		{
			Debug.LogWarning((object)"Unable to setup colorizer");
			return;
		}
		if (m_packs.Count == 0)
		{
			Debug.LogWarning((object)"Material list is empty");
		}
		bool dye = IsColorizerActive();
		setDye(dye);
	}

	public string GetHoverText()
	{
		return Localization.instance.Localize(m_piece.m_name + "\n[<color=yellow><b>1-8</b></color>] " + m_useItemText + "\n[Current dye] " + skinName + ")\n[<color=yellow>Default dye</color>] " + defaultSkinName + ")");
	}

	public string GetHoverName()
	{
		return m_piece.m_name;
	}

	public bool Interact(Humanoid character, bool repeat, bool alt)
	{
		return false;
	}

	public bool UseItem(Humanoid user, ItemData item)
	{
		//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 true;
		}
		ColorizerPack colorPackByItemData = getColorPackByItemData(item);
		if (item != null && colorPackByItemData != null && skinName == colorPackByItemData.skin)
		{
			((Character)user).Message((MessageType)2, "$msg_wrongitem", 0, (Sprite)null);
			return false;
		}
		if (item != null && colorPackByItemData == null)
		{
			((Character)user).Message((MessageType)2, "$msg_wrongitem", 0, (Sprite)null);
			return false;
		}
		((Character)user).Message((MessageType)2, "$msg_added " + item.m_shared.m_name, 0, (Sprite)null);
		user.GetInventory().RemoveItem(item.m_shared.m_name, 1, -1, true);
		Paint(colorPackByItemData.skin);
		return true;
	}

	private void Paint(string dyeName)
	{
		m_zview.InvokeRPC(ZNetView.Everybody, "RPC_Paint", new object[1] { dyeName });
	}

	private void RPC_Paint(long caller, string dyeName)
	{
		setColorizerId(dyeName);
		ColorizerPack colorizerPack = findDyeByName(dyeName);
		useDye(colorizerPack);
	}

	public void filterPacks()
	{
		foreach (ColorizerPack item in colorizerPacksFull)
		{
			if (item != null && editZnetName(((Object)this).name) == item.buildPieceName)
			{
				colorizerPacks.Add(item);
			}
		}
	}

	private void setColorizerId(string id)
	{
		if (m_zview.IsValid())
		{
			m_zview.m_zdo.Set("colorizerSet", id);
			m_zview.m_zdo.Set("colorizerIsActive", true);
		}
	}

	private bool IsColorizerActive()
	{
		return m_zview.m_zdo.GetBool("colorizerIsActive", false);
	}

	private bool validatePrefab()
	{
		string[] source = new string[25]
		{
			"piece_banner01", "piece_banner02", "piece_banner03", "piece_banner04", "piece_banner05", "piece_banner06", "piece_banner07", "piece_banner08", "piece_banner09", "piece_banner10",
			"piece_banner11", "piece_cloth_hanging_door", "piece_cloth_hanging_door_blue", "piece_cloth_hanging_door_blue2", "jute_carpet", "jute_carpet_blue", "crystal_wall_1x1", "darkwood_roof_icorner", "darkwood_roof_icorner_45", "darkwood_roof_ocorner",
			"darkwood_roof_ocorner_45", "darkwood_roof_top", "darkwood_roof_top_45", "darkwood_roof_45", "darkwood_roof"
		};
		string name = ((Object)((Component)this).gameObject).name;
		name = editZnetName(name);
		return source.Contains(name);
	}

	private void setDefaulDyeName()
	{
		string name = ((Object)((Component)this).gameObject).name;
		switch (editZnetName(name))
		{
		case "darkwood_roof_icorner":
		case "darkwood_roof_icorner_45":
		case "darkwood_roof_ocorner":
		case "darkwood_roof_ocorner_45":
		case "darkwood_roof_top":
		case "darkwood_roof_top_45":
		case "darkwood_roof_45":
		case "darkwood_roof":
			defaultSkinName = "black";
			break;
		case "crystal_wall_1x1":
			defaultSkinName = "white";
			break;
		case "piece_banner01":
			defaultSkinName = "black";
			break;
		case "piece_banner02":
			defaultSkinName = "blue";
			break;
		case "piece_banner03":
			defaultSkinName = "red";
			break;
		case "piece_banner04":
			defaultSkinName = "red";
			break;
		case "piece_banner05":
			defaultSkinName = "green";
			break;
		case "piece_banner06":
			defaultSkinName = "blue";
			break;
		case "piece_banner07":
			defaultSkinName = "blue";
			break;
		case "piece_banner08":
			defaultSkinName = "yellow";
			break;
		case "piece_banner09":
			defaultSkinName = "purple";
			break;
		case "piece_banner10":
			defaultSkinName = "orange";
			break;
		case "piece_banner11":
			defaultSkinName = "white";
			break;
		case "piece_cloth_hanging_door":
			defaultSkinName = "red";
			break;
		case "piece_cloth_hanging_door_blue":
			defaultSkinName = "blue";
			break;
		case "piece_cloth_hanging_door_blue2":
			defaultSkinName = "blue";
			break;
		case "jute_carpet":
			defaultSkinName = "red";
			break;
		case "jute_carpet_blue":
			defaultSkinName = "blue";
			break;
		}
	}

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

	private void setDye(bool isColorizerActive)
	{
		string @string = defaultSkinName;
		if (isColorizerActive)
		{
			@string = m_zview.m_zdo.GetString("colorizerSet", "");
		}
		if (@string == "" || @string == null)
		{
			@string = defaultSkinName;
		}
		Paint(@string);
	}

	private ColorizerPack findDyeByName(string name)
	{
		foreach (ColorizerPack colorizerPack in colorizerPacks)
		{
			if (colorizerPack != null && name == colorizerPack.skin && editZnetName(((Object)this).name) == colorizerPack.buildPieceName)
			{
				return colorizerPack;
			}
		}
		return null;
	}

	private ColorizerPack getColorPackByItemData(ItemData itemData)
	{
		foreach (ColorizerPack colorizerPack in colorizerPacks)
		{
			if (colorizerPack != null && ((Object)itemData.m_dropPrefab).name == ((Object)colorizerPack.dyeItem).name)
			{
				return colorizerPack;
			}
		}
		return null;
	}

	private void useDye(ColorizerPack colorizerPack)
	{
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Expected O, but got Unknown
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Expected O, but got Unknown
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Expected O, but got Unknown
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Expected O, but got Unknown
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Expected O, but got Unknown
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Expected O, but got Unknown
		foreach (MeshRenderer item in banner)
		{
			((Renderer)item).material = new Material(colorizerPack.body);
			((Renderer)item).sharedMaterial = new Material(colorizerPack.body);
			skinName = colorizerPack.skin;
			m_colorizerPack = colorizerPack;
		}
		if ((Object)(object)main != (Object)null)
		{
			((Renderer)main).material = new Material(colorizerPack.rugmain);
			((Renderer)main).sharedMaterial = new Material(colorizerPack.rugmain);
		}
		foreach (MeshRenderer item2 in m_destruction)
		{
			((Renderer)item2).material = new Material(colorizerPack.rugdestruction);
			((Renderer)item2).sharedMaterial = new Material(colorizerPack.rugdestruction);
		}
	}

	private bool setupColorizer()
	{
		string name = ((Object)((Component)this).gameObject).name;
		name = editZnetName(name);
		List<ColorizerPack> packs = colorizerPacks.FindAll((ColorizerPack x) => x.buildPieceName == name);
		m_packs = packs;
		switch (name)
		{
		case "darkwood_roof_icorner":
		case "darkwood_roof_icorner_45":
		case "darkwood_roof_ocorner":
		case "darkwood_roof_ocorner_45":
		case "darkwood_roof_top":
		case "darkwood_roof_top_45":
		case "darkwood_roof_45":
		case "darkwood_roof":
		{
			Transform val9 = ((Component)this).transform.Find("New");
			banner.Add(((Component)val9.GetChild(0)).GetComponent<MeshRenderer>());
			banner.Add(((Component)val9.GetChild(1)).GetComponent<MeshRenderer>());
			Transform val10 = ((Component)this).transform.Find("Worn");
			m_destruction.AddRange(((Component)val10).GetComponentsInChildren<MeshRenderer>());
			Transform val11 = ((Component)this).transform.Find("Broken");
			m_destruction.AddRange(((Component)val11).GetComponentsInChildren<MeshRenderer>());
			Transform val12 = ((Component)this).transform.Find("Destruction");
			m_destruction.AddRange(((Component)val12).GetComponentsInChildren<MeshRenderer>());
			break;
		}
		case "crystal_wall_1x1":
		{
			Transform val8 = ((Component)this).transform.Find("New");
			banner.Add(((Component)val8.GetChild(0)).GetComponent<MeshRenderer>());
			banner.Add(((Component)val8.GetChild(1)).GetComponent<MeshRenderer>());
			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":
			banner.Add(((Component)((Component)this).transform.Find("default")).GetComponent<MeshRenderer>());
			break;
		case "piece_cloth_hanging_door":
			banner.Add(((Component)((Component)this).transform.Find("new/cloth")).GetComponent<MeshRenderer>());
			break;
		case "piece_cloth_hanging_door_blue":
		{
			Transform val7 = ((Component)this).transform.Find("new");
			banner.Add(((Component)val7.GetChild(0)).GetComponent<MeshRenderer>());
			banner.Add(((Component)val7.GetChild(1)).GetComponent<MeshRenderer>());
			break;
		}
		case "piece_cloth_hanging_door_blue2":
		{
			Transform val3 = ((Component)this).transform.Find("new");
			banner.Add(((Component)val3.GetChild(1)).GetComponent<MeshRenderer>());
			banner.Add(((Component)val3.GetChild(2)).GetComponent<MeshRenderer>());
			Transform val4 = ((Component)this).transform.Find("worn");
			banner.Add(((Component)val4.GetChild(1)).GetComponent<MeshRenderer>());
			banner.Add(((Component)val4.GetChild(2)).GetComponent<MeshRenderer>());
			Transform val5 = ((Component)this).transform.Find("broken");
			banner.Add(((Component)val5.GetChild(1)).GetComponent<MeshRenderer>());
			banner.Add(((Component)val5.GetChild(2)).GetComponent<MeshRenderer>());
			Transform val6 = ((Component)this).transform.Find("destruction");
			banner.Add(((Component)val6.GetChild(0)).GetComponent<MeshRenderer>());
			break;
		}
		case "jute_carpet":
		{
			main = ((Component)((Component)this).transform.GetChild(1)).GetComponent<MeshRenderer>();
			banner.Add(((Component)((Component)this).transform.GetChild(2)).GetComponent<MeshRenderer>());
			banner.Add(((Component)((Component)this).transform.GetChild(3)).GetComponent<MeshRenderer>());
			Transform val2 = ((Component)this).transform.Find("destruction");
			m_destruction.AddRange(((Component)val2).GetComponentsInChildren<MeshRenderer>());
			break;
		}
		case "jute_carpet_blue":
		{
			main = ((Component)((Component)this).transform.GetChild(1)).GetComponent<MeshRenderer>();
			banner.Add(((Component)((Component)this).transform.GetChild(2)).GetComponent<MeshRenderer>());
			banner.Add(((Component)((Component)this).transform.GetChild(3)).GetComponent<MeshRenderer>());
			Transform val = ((Component)this).transform.Find("destruction");
			m_destruction.AddRange(((Component)val).GetComponentsInChildren<MeshRenderer>());
			break;
		}
		}
		return true;
	}
}
public class ItemSetBuilder
{
	public List<GameObject> prefabs = new List<GameObject>();

	public ModResourceLoader modResourceLoader = null;

	public static List<ColorizerPack> colorizerPacks = new List<ColorizerPack>();

	public static List<ColorizerPack> createColorPacks(ModResourceLoader modResourceLoader)
	{
		buildPack(modResourceLoader.crystal01black, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlack"), "crystal_wall_1x1", "black");
		buildPack(modResourceLoader.crystal01blue, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlue"), "crystal_wall_1x1", "blue");
		buildPack(modResourceLoader.crystal01green, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeGreen"), "crystal_wall_1x1", "green");
		buildPack(modResourceLoader.crystal01orange, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeOrange"), "crystal_wall_1x1", "orange");
		buildPack(modResourceLoader.crystal01purple, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyePurple"), "crystal_wall_1x1", "purple");
		buildPack(modResourceLoader.crystal01red, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeRed"), "crystal_wall_1x1", "red");
		buildPack(modResourceLoader.crystal01white, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeWhite"), "crystal_wall_1x1", "white");
		buildPack(modResourceLoader.crystal01yellow, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeYellow"), "crystal_wall_1x1", "yellow");
		buildPack(modResourceLoader.banner01black, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlack"), "piece_banner01", "black");
		buildPack(modResourceLoader.banner01blue, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlue"), "piece_banner01", "blue");
		buildPack(modResourceLoader.banner01green, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeGreen"), "piece_banner01", "green");
		buildPack(modResourceLoader.banner01orange, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeOrange"), "piece_banner01", "orange");
		buildPack(modResourceLoader.banner01purple, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyePurple"), "piece_banner01", "purple");
		buildPack(modResourceLoader.banner01red, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeRed"), "piece_banner01", "red");
		buildPack(modResourceLoader.banner01white, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeWhite"), "piece_banner01", "white");
		buildPack(modResourceLoader.banner01yellow, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeYellow"), "piece_banner01", "yellow");
		buildPack(modResourceLoader.banner02black, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlack"), "piece_banner02", "black");
		buildPack(modResourceLoader.banner02blue, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlue"), "piece_banner02", "blue");
		buildPack(modResourceLoader.banner02green, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeGreen"), "piece_banner02", "green");
		buildPack(modResourceLoader.banner02orange, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeOrange"), "piece_banner02", "orange");
		buildPack(modResourceLoader.banner02purple, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyePurple"), "piece_banner02", "purple");
		buildPack(modResourceLoader.banner02red, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeRed"), "piece_banner02", "red");
		buildPack(modResourceLoader.banner02white, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeWhite"), "piece_banner02", "white");
		buildPack(modResourceLoader.banner02yellow, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeYellow"), "piece_banner02", "yellow");
		buildPack(modResourceLoader.banner03black, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlack"), "piece_banner03", "black");
		buildPack(modResourceLoader.banner03blue, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlue"), "piece_banner03", "blue");
		buildPack(modResourceLoader.banner03green, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeGreen"), "piece_banner03", "green");
		buildPack(modResourceLoader.banner03orange, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeOrange"), "piece_banner03", "orange");
		buildPack(modResourceLoader.banner03purple, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyePurple"), "piece_banner03", "purple");
		buildPack(modResourceLoader.banner03red, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeRed"), "piece_banner03", "red");
		buildPack(modResourceLoader.banner03white, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeWhite"), "piece_banner03", "white");
		buildPack(modResourceLoader.banner03yellow, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeYellow"), "piece_banner03", "yellow");
		buildPack(modResourceLoader.banner04black, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlack"), "piece_banner04", "black");
		buildPack(modResourceLoader.banner04blue, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlue"), "piece_banner04", "blue");
		buildPack(modResourceLoader.banner04green, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeGreen"), "piece_banner04", "green");
		buildPack(modResourceLoader.banner04orange, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeOrange"), "piece_banner04", "orange");
		buildPack(modResourceLoader.banner04purple, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyePurple"), "piece_banner04", "purple");
		buildPack(modResourceLoader.banner04red, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeRed"), "piece_banner04", "red");
		buildPack(modResourceLoader.banner04white, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeWhite"), "piece_banner04", "white");
		buildPack(modResourceLoader.banner04yellow, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeYellow"), "piece_banner04", "yellow");
		buildPack(modResourceLoader.banner05black, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlack"), "piece_banner05", "black");
		buildPack(modResourceLoader.banner05blue, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlue"), "piece_banner05", "blue");
		buildPack(modResourceLoader.banner05green, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeGreen"), "piece_banner05", "green");
		buildPack(modResourceLoader.banner05orange, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeOrange"), "piece_banner05", "orange");
		buildPack(modResourceLoader.banner05purple, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyePurple"), "piece_banner05", "purple");
		buildPack(modResourceLoader.banner05red, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeRed"), "piece_banner05", "red");
		buildPack(modResourceLoader.banner05white, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeWhite"), "piece_banner05", "white");
		buildPack(modResourceLoader.banner05yellow, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeYellow"), "piece_banner05", "yellow");
		buildPack(modResourceLoader.banner06black, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlack"), "piece_banner06", "black");
		buildPack(modResourceLoader.banner06blue, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlue"), "piece_banner06", "blue");
		buildPack(modResourceLoader.banner06green, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeGreen"), "piece_banner06", "green");
		buildPack(modResourceLoader.banner06orange, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeOrange"), "piece_banner06", "orange");
		buildPack(modResourceLoader.banner06purple, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyePurple"), "piece_banner06", "purple");
		buildPack(modResourceLoader.banner06red, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeRed"), "piece_banner06", "red");
		buildPack(modResourceLoader.banner06white, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeWhite"), "piece_banner06", "white");
		buildPack(modResourceLoader.banner06yellow, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeYellow"), "piece_banner06", "yellow");
		buildPack(modResourceLoader.banner07black, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlack"), "piece_banner07", "black");
		buildPack(modResourceLoader.banner07blue, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlue"), "piece_banner07", "blue");
		buildPack(modResourceLoader.banner07green, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeGreen"), "piece_banner07", "green");
		buildPack(modResourceLoader.banner07orange, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeOrange"), "piece_banner07", "orange");
		buildPack(modResourceLoader.banner07purple, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyePurple"), "piece_banner07", "purple");
		buildPack(modResourceLoader.banner07red, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeRed"), "piece_banner07", "red");
		buildPack(modResourceLoader.banner07white, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeWhite"), "piece_banner07", "white");
		buildPack(modResourceLoader.banner07yellow, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeYellow"), "piece_banner07", "yellow");
		buildPack(modResourceLoader.banner08black, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlack"), "piece_banner08", "black");
		buildPack(modResourceLoader.banner08blue, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlue"), "piece_banner08", "blue");
		buildPack(modResourceLoader.banner08green, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeGreen"), "piece_banner08", "green");
		buildPack(modResourceLoader.banner08orange, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeOrange"), "piece_banner08", "orange");
		buildPack(modResourceLoader.banner08purple, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyePurple"), "piece_banner08", "purple");
		buildPack(modResourceLoader.banner08red, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeRed"), "piece_banner08", "red");
		buildPack(modResourceLoader.banner08white, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeWhite"), "piece_banner08", "white");
		buildPack(modResourceLoader.banner08yellow, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeYellow"), "piece_banner08", "yellow");
		buildPack(modResourceLoader.banner09black, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlack"), "piece_banner09", "black");
		buildPack(modResourceLoader.banner09blue, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlue"), "piece_banner09", "blue");
		buildPack(modResourceLoader.banner09green, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeGreen"), "piece_banner09", "green");
		buildPack(modResourceLoader.banner09orange, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeOrange"), "piece_banner09", "orange");
		buildPack(modResourceLoader.banner09purple, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyePurple"), "piece_banner09", "purple");
		buildPack(modResourceLoader.banner09red, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeRed"), "piece_banner09", "red");
		buildPack(modResourceLoader.banner09white, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeWhite"), "piece_banner09", "white");
		buildPack(modResourceLoader.banner09yellow, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeYellow"), "piece_banner09", "yellow");
		buildPack(modResourceLoader.banner10black, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlack"), "piece_banner10", "black");
		buildPack(modResourceLoader.banner10blue, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlue"), "piece_banner10", "blue");
		buildPack(modResourceLoader.banner10green, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeGreen"), "piece_banner10", "green");
		buildPack(modResourceLoader.banner10orange, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeOrange"), "piece_banner10", "orange");
		buildPack(modResourceLoader.banner10purple, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyePurple"), "piece_banner10", "purple");
		buildPack(modResourceLoader.banner10red, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeRed"), "piece_banner10", "red");
		buildPack(modResourceLoader.banner10white, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeWhite"), "piece_banner10", "white");
		buildPack(modResourceLoader.banner10yellow, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeYellow"), "piece_banner10", "yellow");
		buildPack(modResourceLoader.banner11black, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlack"), "piece_banner11", "black");
		buildPack(modResourceLoader.banner11blue, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlue"), "piece_banner11", "blue");
		buildPack(modResourceLoader.banner11green, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeGreen"), "piece_banner11", "green");
		buildPack(modResourceLoader.banner11orange, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeOrange"), "piece_banner11", "orange");
		buildPack(modResourceLoader.banner11purple, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyePurple"), "piece_banner11", "purple");
		buildPack(modResourceLoader.banner11red, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeRed"), "piece_banner11", "red");
		buildPack(modResourceLoader.banner11white, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeWhite"), "piece_banner11", "white");
		buildPack(modResourceLoader.banner11yellow, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeYellow"), "piece_banner11", "yellow");
		buildPack(modResourceLoader.bannerHangingblack, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlack"), "piece_cloth_hanging_door", "black");
		buildPack(modResourceLoader.bannerHangingblue, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlue"), "piece_cloth_hanging_door", "blue");
		buildPack(modResourceLoader.bannerHanginggreen, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeGreen"), "piece_cloth_hanging_door", "green");
		buildPack(modResourceLoader.bannerHangingorange, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeOrange"), "piece_cloth_hanging_door", "orange");
		buildPack(modResourceLoader.bannerHangingpurple, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyePurple"), "piece_cloth_hanging_door", "purple");
		buildPack(modResourceLoader.bannerHangingred, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeRed"), "piece_cloth_hanging_door", "red");
		buildPack(modResourceLoader.bannerHangingwhite, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeWhite"), "piece_cloth_hanging_door", "white");
		buildPack(modResourceLoader.bannerHangingyellow, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeYellow"), "piece_cloth_hanging_door", "yellow");
		buildPack(modResourceLoader.bannerHanging2black, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlack"), "piece_cloth_hanging_door_blue", "black");
		buildPack(modResourceLoader.bannerHanging2blue, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlue"), "piece_cloth_hanging_door_blue", "blue");
		buildPack(modResourceLoader.bannerHanging2green, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeGreen"), "piece_cloth_hanging_door_blue", "green");
		buildPack(modResourceLoader.bannerHanging2orange, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeOrange"), "piece_cloth_hanging_door_blue", "orange");
		buildPack(modResourceLoader.bannerHanging2purple, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyePurple"), "piece_cloth_hanging_door_blue", "purple");
		buildPack(modResourceLoader.bannerHanging2red, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeRed"), "piece_cloth_hanging_door_blue", "red");
		buildPack(modResourceLoader.bannerHanging2white, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeWhite"), "piece_cloth_hanging_door_blue", "white");
		buildPack(modResourceLoader.bannerHanging2yellow, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeYellow"), "piece_cloth_hanging_door_blue", "yellow");
		buildPack(modResourceLoader.bannerHanging3black, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlack"), "piece_cloth_hanging_door_blue2", "black");
		buildPack(modResourceLoader.bannerHanging3blue, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlue"), "piece_cloth_hanging_door_blue2", "blue");
		buildPack(modResourceLoader.bannerHanging3green, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeGreen"), "piece_cloth_hanging_door_blue2", "green");
		buildPack(modResourceLoader.bannerHanging3orange, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeOrange"), "piece_cloth_hanging_door_blue2", "orange");
		buildPack(modResourceLoader.bannerHanging3purple, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyePurple"), "piece_cloth_hanging_door_blue2", "purple");
		buildPack(modResourceLoader.bannerHanging3red, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeRed"), "piece_cloth_hanging_door_blue2", "red");
		buildPack(modResourceLoader.bannerHanging3white, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeWhite"), "piece_cloth_hanging_door_blue2", "white");
		buildPack(modResourceLoader.bannerHanging3yellow, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeYellow"), "piece_cloth_hanging_door_blue2", "yellow");
		buildPack(modResourceLoader.juteCarpetblack, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlack"), "jute_carpet", "black", modResourceLoader.juteCarpetMainblack, modResourceLoader.juteCarpetDestructionblack);
		buildPack(modResourceLoader.juteCarpetblue, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlue"), "jute_carpet", "blue", modResourceLoader.juteCarpetMainblue, modResourceLoader.juteCarpetDestructionblue);
		buildPack(modResourceLoader.juteCarpetgreen, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeGreen"), "jute_carpet", "green", modResourceLoader.juteCarpetMaingreen, modResourceLoader.juteCarpetDestructiongreen);
		buildPack(modResourceLoader.juteCarpetorange, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeOrange"), "jute_carpet", "orange", modResourceLoader.juteCarpetMainorange, modResourceLoader.juteCarpetDestructionorange);
		buildPack(modResourceLoader.juteCarpetpurple, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyePurple"), "jute_carpet", "purple", modResourceLoader.juteCarpetMainpurple, modResourceLoader.juteCarpetDestructionpurple);
		buildPack(modResourceLoader.juteCarpetred, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeRed"), "jute_carpet", "red", modResourceLoader.juteCarpetMainred, modResourceLoader.juteCarpetDestructionred);
		buildPack(modResourceLoader.juteCarpetwhite, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeWhite"), "jute_carpet", "white", modResourceLoader.juteCarpetMainwhite, modResourceLoader.juteCarpetDestructionwhite);
		buildPack(modResourceLoader.juteCarpetyellow, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeYellow"), "jute_carpet", "yellow", modResourceLoader.juteCarpetMainyellow, modResourceLoader.juteCarpetDestructionyellow);
		buildPack(modResourceLoader.juteCarpet2black, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlack"), "jute_carpet_blue", "black", modResourceLoader.juteCarpetMain2black, modResourceLoader.juteCarpetDestruction2black);
		buildPack(modResourceLoader.juteCarpet2blue, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlue"), "jute_carpet_blue", "blue", modResourceLoader.juteCarpetMain2blue, modResourceLoader.juteCarpetDestruction2blue);
		buildPack(modResourceLoader.juteCarpet2green, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeGreen"), "jute_carpet_blue", "green", modResourceLoader.juteCarpetMain2green, modResourceLoader.juteCarpetDestruction2green);
		buildPack(modResourceLoader.juteCarpet2orange, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeOrange"), "jute_carpet_blue", "orange", modResourceLoader.juteCarpetMain2orange, modResourceLoader.juteCarpetDestruction2orange);
		buildPack(modResourceLoader.juteCarpet2purple, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyePurple"), "jute_carpet_blue", "purple", modResourceLoader.juteCarpetMain2purple, modResourceLoader.juteCarpetDestruction2purple);
		buildPack(modResourceLoader.juteCarpet2red, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeRed"), "jute_carpet_blue", "red", modResourceLoader.juteCarpetMain2red, modResourceLoader.juteCarpetDestruction2red);
		buildPack(modResourceLoader.juteCarpet2white, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeWhite"), "jute_carpet_blue", "white", modResourceLoader.juteCarpetMain2white, modResourceLoader.juteCarpetDestruction2white);
		buildPack(modResourceLoader.juteCarpet2yellow, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeYellow"), "jute_carpet_blue", "yellow", modResourceLoader.juteCarpetMain2yellow, modResourceLoader.juteCarpetDestruction2yellow);
		buildPack(modResourceLoader.roofDarkMain2black, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlack"), "darkwood_roof_icorner", "black", modResourceLoader.roofDarkMain2black, modResourceLoader.roofDarkDestructionblack);
		buildPack(modResourceLoader.roofDarkMain2blue, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlue"), "darkwood_roof_icorner", "blue", modResourceLoader.roofDarkMain2blue, modResourceLoader.roofDarkDestructionblue);
		buildPack(modResourceLoader.roofDarkMain2green, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeGreen"), "darkwood_roof_icorner", "green", modResourceLoader.roofDarkMain2green, modResourceLoader.roofDarkDestructiongreen);
		buildPack(modResourceLoader.roofDarkMain2orange, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeOrange"), "darkwood_roof_icorner", "orange", modResourceLoader.roofDarkMain2orange, modResourceLoader.roofDarkDestructionorange);
		buildPack(modResourceLoader.roofDarkMain2purple, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyePurple"), "darkwood_roof_icorner", "purple", modResourceLoader.roofDarkMain2purple, modResourceLoader.roofDarkDestructionpurple);
		buildPack(modResourceLoader.roofDarkMain2red, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeRed"), "darkwood_roof_icorner", "red", modResourceLoader.roofDarkMain2red, modResourceLoader.roofDarkDestructionred);
		buildPack(modResourceLoader.roofDarkMain2white, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeWhite"), "darkwood_roof_icorner", "white", modResourceLoader.roofDarkMain2white, modResourceLoader.roofDarkDestructionwhite);
		buildPack(modResourceLoader.roofDarkMain2yellow, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeYellow"), "darkwood_roof_icorner", "yellow", modResourceLoader.roofDarkMain2yellow, modResourceLoader.roofDarkDestructionyellow);
		buildPack(modResourceLoader.roofDarkMain2black, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlack"), "darkwood_roof_icorner_45", "black", modResourceLoader.roofDarkMain2black, modResourceLoader.roofDarkDestructionblack);
		buildPack(modResourceLoader.roofDarkMain2blue, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlue"), "darkwood_roof_icorner_45", "blue", modResourceLoader.roofDarkMain2blue, modResourceLoader.roofDarkDestructionblue);
		buildPack(modResourceLoader.roofDarkMain2green, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeGreen"), "darkwood_roof_icorner_45", "green", modResourceLoader.roofDarkMain2green, modResourceLoader.roofDarkDestructiongreen);
		buildPack(modResourceLoader.roofDarkMain2orange, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeOrange"), "darkwood_roof_icorner_45", "orange", modResourceLoader.roofDarkMain2orange, modResourceLoader.roofDarkDestructionorange);
		buildPack(modResourceLoader.roofDarkMain2purple, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyePurple"), "darkwood_roof_icorner_45", "purple", modResourceLoader.roofDarkMain2purple, modResourceLoader.roofDarkDestructionpurple);
		buildPack(modResourceLoader.roofDarkMain2red, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeRed"), "darkwood_roof_icorner_45", "red", modResourceLoader.roofDarkMain2red, modResourceLoader.roofDarkDestructionred);
		buildPack(modResourceLoader.roofDarkMain2white, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeWhite"), "darkwood_roof_icorner_45", "white", modResourceLoader.roofDarkMain2white, modResourceLoader.roofDarkDestructionwhite);
		buildPack(modResourceLoader.roofDarkMain2yellow, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeYellow"), "darkwood_roof_icorner_45", "yellow", modResourceLoader.roofDarkMain2yellow, modResourceLoader.roofDarkDestructionyellow);
		buildPack(modResourceLoader.roofDarkMain2black, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlack"), "darkwood_roof_ocorner", "black", modResourceLoader.roofDarkMain2black, modResourceLoader.roofDarkDestructionblack);
		buildPack(modResourceLoader.roofDarkMain2blue, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlue"), "darkwood_roof_ocorner", "blue", modResourceLoader.roofDarkMain2blue, modResourceLoader.roofDarkDestructionblue);
		buildPack(modResourceLoader.roofDarkMain2green, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeGreen"), "darkwood_roof_ocorner", "green", modResourceLoader.roofDarkMain2green, modResourceLoader.roofDarkDestructiongreen);
		buildPack(modResourceLoader.roofDarkMain2orange, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeOrange"), "darkwood_roof_ocorner", "orange", modResourceLoader.roofDarkMain2orange, modResourceLoader.roofDarkDestructionorange);
		buildPack(modResourceLoader.roofDarkMain2purple, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyePurple"), "darkwood_roof_ocorner", "purple", modResourceLoader.roofDarkMain2purple, modResourceLoader.roofDarkDestructionpurple);
		buildPack(modResourceLoader.roofDarkMain2red, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeRed"), "darkwood_roof_ocorner", "red", modResourceLoader.roofDarkMain2red, modResourceLoader.roofDarkDestructionred);
		buildPack(modResourceLoader.roofDarkMain2white, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeWhite"), "darkwood_roof_ocorner", "white", modResourceLoader.roofDarkMain2white, modResourceLoader.roofDarkDestructionwhite);
		buildPack(modResourceLoader.roofDarkMain2yellow, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeYellow"), "darkwood_roof_ocorner", "yellow", modResourceLoader.roofDarkMain2yellow, modResourceLoader.roofDarkDestructionyellow);
		buildPack(modResourceLoader.roofDarkMain2black, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlack"), "darkwood_roof_ocorner_45", "black", modResourceLoader.roofDarkMain2black, modResourceLoader.roofDarkDestructionblack);
		buildPack(modResourceLoader.roofDarkMain2blue, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlue"), "darkwood_roof_ocorner_45", "blue", modResourceLoader.roofDarkMain2blue, modResourceLoader.roofDarkDestructionblue);
		buildPack(modResourceLoader.roofDarkMain2green, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeGreen"), "darkwood_roof_ocorner_45", "green", modResourceLoader.roofDarkMain2green, modResourceLoader.roofDarkDestructiongreen);
		buildPack(modResourceLoader.roofDarkMain2orange, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeOrange"), "darkwood_roof_ocorner_45", "orange", modResourceLoader.roofDarkMain2orange, modResourceLoader.roofDarkDestructionorange);
		buildPack(modResourceLoader.roofDarkMain2purple, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyePurple"), "darkwood_roof_ocorner_45", "purple", modResourceLoader.roofDarkMain2purple, modResourceLoader.roofDarkDestructionpurple);
		buildPack(modResourceLoader.roofDarkMain2red, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeRed"), "darkwood_roof_ocorner_45", "red", modResourceLoader.roofDarkMain2red, modResourceLoader.roofDarkDestructionred);
		buildPack(modResourceLoader.roofDarkMain2white, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeWhite"), "darkwood_roof_ocorner_45", "white", modResourceLoader.roofDarkMain2white, modResourceLoader.roofDarkDestructionwhite);
		buildPack(modResourceLoader.roofDarkMain2yellow, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeYellow"), "darkwood_roof_ocorner_45", "yellow", modResourceLoader.roofDarkMain2yellow, modResourceLoader.roofDarkDestructionyellow);
		buildPack(modResourceLoader.roofDarkMain2black, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlack"), "darkwood_roof_top", "black", modResourceLoader.roofDarkMain2black, modResourceLoader.roofDarkDestructionblack);
		buildPack(modResourceLoader.roofDarkMain2blue, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlue"), "darkwood_roof_top", "blue", modResourceLoader.roofDarkMain2blue, modResourceLoader.roofDarkDestructionblue);
		buildPack(modResourceLoader.roofDarkMain2green, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeGreen"), "darkwood_roof_top", "green", modResourceLoader.roofDarkMain2green, modResourceLoader.roofDarkDestructiongreen);
		buildPack(modResourceLoader.roofDarkMain2orange, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeOrange"), "darkwood_roof_top", "orange", modResourceLoader.roofDarkMain2orange, modResourceLoader.roofDarkDestructionorange);
		buildPack(modResourceLoader.roofDarkMain2purple, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyePurple"), "darkwood_roof_top", "purple", modResourceLoader.roofDarkMain2purple, modResourceLoader.roofDarkDestructionpurple);
		buildPack(modResourceLoader.roofDarkMain2red, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeRed"), "darkwood_roof_top", "red", modResourceLoader.roofDarkMain2red, modResourceLoader.roofDarkDestructionred);
		buildPack(modResourceLoader.roofDarkMain2white, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeWhite"), "darkwood_roof_top", "white", modResourceLoader.roofDarkMain2white, modResourceLoader.roofDarkDestructionwhite);
		buildPack(modResourceLoader.roofDarkMain2yellow, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeYellow"), "darkwood_roof_top", "yellow", modResourceLoader.roofDarkMain2yellow, modResourceLoader.roofDarkDestructionyellow);
		buildPack(modResourceLoader.roofDarkMain2black, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlack"), "darkwood_roof_top_45", "black", modResourceLoader.roofDarkMain2black, modResourceLoader.roofDarkDestructionblack);
		buildPack(modResourceLoader.roofDarkMain2blue, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlue"), "darkwood_roof_top_45", "blue", modResourceLoader.roofDarkMain2blue, modResourceLoader.roofDarkDestructionblue);
		buildPack(modResourceLoader.roofDarkMain2green, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeGreen"), "darkwood_roof_top_45", "green", modResourceLoader.roofDarkMain2green, modResourceLoader.roofDarkDestructiongreen);
		buildPack(modResourceLoader.roofDarkMain2orange, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeOrange"), "darkwood_roof_top_45", "orange", modResourceLoader.roofDarkMain2orange, modResourceLoader.roofDarkDestructionorange);
		buildPack(modResourceLoader.roofDarkMain2purple, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyePurple"), "darkwood_roof_top_45", "purple", modResourceLoader.roofDarkMain2purple, modResourceLoader.roofDarkDestructionpurple);
		buildPack(modResourceLoader.roofDarkMain2red, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeRed"), "darkwood_roof_top_45", "red", modResourceLoader.roofDarkMain2red, modResourceLoader.roofDarkDestructionred);
		buildPack(modResourceLoader.roofDarkMain2white, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeWhite"), "darkwood_roof_top_45", "white", modResourceLoader.roofDarkMain2white, modResourceLoader.roofDarkDestructionwhite);
		buildPack(modResourceLoader.roofDarkMain2yellow, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeYellow"), "darkwood_roof_top_45", "yellow", modResourceLoader.roofDarkMain2yellow, modResourceLoader.roofDarkDestructionyellow);
		buildPack(modResourceLoader.roofDarkMain2black, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlack"), "darkwood_roof_45", "black", modResourceLoader.roofDarkMain2black, modResourceLoader.roofDarkDestructionblack);
		buildPack(modResourceLoader.roofDarkMain2blue, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlue"), "darkwood_roof_45", "blue", modResourceLoader.roofDarkMain2blue, modResourceLoader.roofDarkDestructionblue);
		buildPack(modResourceLoader.roofDarkMain2green, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeGreen"), "darkwood_roof_45", "green", modResourceLoader.roofDarkMain2green, modResourceLoader.roofDarkDestructiongreen);
		buildPack(modResourceLoader.roofDarkMain2orange, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeOrange"), "darkwood_roof_45", "orange", modResourceLoader.roofDarkMain2orange, modResourceLoader.roofDarkDestructionorange);
		buildPack(modResourceLoader.roofDarkMain2purple, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyePurple"), "darkwood_roof_45", "purple", modResourceLoader.roofDarkMain2purple, modResourceLoader.roofDarkDestructionpurple);
		buildPack(modResourceLoader.roofDarkMain2red, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeRed"), "darkwood_roof_45", "red", modResourceLoader.roofDarkMain2red, modResourceLoader.roofDarkDestructionred);
		buildPack(modResourceLoader.roofDarkMain2white, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeWhite"), "darkwood_roof_45", "white", modResourceLoader.roofDarkMain2white, modResourceLoader.roofDarkDestructionwhite);
		buildPack(modResourceLoader.roofDarkMain2yellow, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeYellow"), "darkwood_roof_45", "yellow", modResourceLoader.roofDarkMain2yellow, modResourceLoader.roofDarkDestructionyellow);
		buildPack(modResourceLoader.roofDarkMain2black, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlack"), "darkwood_roof", "black", modResourceLoader.roofDarkMain2black, modResourceLoader.roofDarkDestructionblack);
		buildPack(modResourceLoader.roofDarkMain2blue, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeBlue"), "darkwood_roof", "blue", modResourceLoader.roofDarkMain2blue, modResourceLoader.roofDarkDestructionblue);
		buildPack(modResourceLoader.roofDarkMain2green, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeGreen"), "darkwood_roof", "green", modResourceLoader.roofDarkMain2green, modResourceLoader.roofDarkDestructiongreen);
		buildPack(modResourceLoader.roofDarkMain2orange, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeOrange"), "darkwood_roof", "orange", modResourceLoader.roofDarkMain2orange, modResourceLoader.roofDarkDestructionorange);
		buildPack(modResourceLoader.roofDarkMain2purple, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyePurple"), "darkwood_roof", "purple", modResourceLoader.roofDarkMain2purple, modResourceLoader.roofDarkDestructionpurple);
		buildPack(modResourceLoader.roofDarkMain2red, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeRed"), "darkwood_roof", "red", modResourceLoader.roofDarkMain2red, modResourceLoader.roofDarkDestructionred);
		buildPack(modResourceLoader.roofDarkMain2white, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeWhite"), "darkwood_roof", "white", modResourceLoader.roofDarkMain2white, modResourceLoader.roofDarkDestructionwhite);
		buildPack(modResourceLoader.roofDarkMain2yellow, modResourceLoader.items.Find((GameObject x) => ((Object)x).name == "DyeYellow"), "darkwood_roof", "yellow", modResourceLoader.roofDarkMain2yellow, modResourceLoader.roofDarkDestructionyellow);
		return colorizerPacks;
	}

	private static void buildPack(Material body, GameObject dyeItem, string name, string skin, Material rug = null, Material rugdestruction = null)
	{
		colorizerPacks.Add(new ColorizerPack(body, name, dyeItem, skin, rug, rugdestruction));
	}

	public void setupColorizer(GameObject piece)
	{
		BannerColorizer bannerColorizer = piece.AddComponent<BannerColorizer>();
		bannerColorizer.filterPacks();
	}
}
[Serializable]
public class ColorizerPack
{
	public Material body;

	public string buildPieceName;

	public GameObject dyeItem;

	public string skin;

	public Material rugmain;

	public Material rugdestruction;

	public ColorizerPack(Material body, string buildPieceName, GameObject dyeItem, string skin, Material rugmain = null, Material rugdestruction = null)
	{
		this.buildPieceName = buildPieceName;
		this.body = body;
		this.skin = skin;
		this.dyeItem = dyeItem;
		this.rugmain = rugmain;
		this.rugdestruction = rugdestruction;
	}
}
public class BuildPieceTargeting
{
	private static string[] names = new string[0];

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

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

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

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

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

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

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

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

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

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

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

	private void AddItem(GameObject newPrefab)
	{
		if (!IsObjectDBValid())
		{
			return;
		}
		ItemDrop component = newPrefab.GetComponent<ItemDrop>();
		if ((Object)(object)component != (Object)null)
		{
			if ((Object)(object)ObjectDB.instance.GetItemPrefab(((Object)newPrefab).name) == (Object)null)
			{
				ObjectDB.instance.m_items.Add(newPrefab);
				Dictionary<int, GameObject> dictionary = (Dictionary<int, GameObject>)typeof(ObjectDB).GetField("m_itemByHash", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(ObjectDB.instance);
				dictionary[((Object)newPrefab).name.GetHashCode()] = newPrefab;
			}
		}
		else
		{
			Debug.LogError((object)("BalrondBannerColorizer:  " + ((Object)newPrefab).name + " - ItemDrop not found on prefab"));
		}
	}
}
[BepInPlugin("balrond.astafaraios.BalrondBannerColorizer", "BalrondBannerColorizer", "1.0.6")]
public class Launch : BaseUnityPlugin
{
	[HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")]
	public static class Object_CopyOtherDB_Path
	{
		public static void Postfix()
		{
			if (IsObjectDBValid())
			{
				databaseAddMethods.AddItems(modResourceLoader.items);
				List<Recipe> recipes = createRecipesForDye(ObjectDB.instance.m_items);
				databaseAddMethods.AddRecipes(recipes);
			}
		}
	}

	[HarmonyPatch(typeof(ObjectDB), "Awake")]
	public static class ObjectDB_Awake_Path
	{
		public static void Postfix()
		{
			if (IsObjectDBValid())
			{
				databaseAddMethods.AddItems(modResourceLoader.items);
				List<Recipe> recipes = createRecipesForDye(ObjectDB.instance.m_items);
				databaseAddMethods.AddRecipes(recipes);
			}
		}
	}

	[HarmonyPatch(typeof(ZNetScene), "Awake")]
	public static class ZNetScene_Awake_Path
	{
		public static void Prefix(ZNetScene __instance)
		{
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)null)
			{
				Debug.LogWarning((object)"BalrondBannerColorizer: No ZnetScene found");
				return;
			}
			__instance.m_prefabs.AddRange(modResourceLoader.items);
			__instance.m_prefabs.Add(modResourceLoader.dyeTable);
			if (hasSpawned)
			{
				return;
			}
			Piece component = modResourceLoader.dyeTable.GetComponent<Piece>();
			List<Requirement> list = new List<Requirement>();
			list.Add(createReq("Wood", 5, 0, __instance.m_prefabs));
			list.Add(createReq("Resin", 5, 0, __instance.m_prefabs));
			component.m_resources = list.ToArray();
			setupRavenGuide(modResourceLoader.dyeTable, __instance.m_prefabs);
			GameObject val = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "Hammer");
			GameObject val2 = val.GetComponent<ItemDrop>().m_itemData.m_shared.m_buildPieces.m_pieces.Find((GameObject x) => ((Object)x).name == ((Object)modResourceLoader.dyeTable).name);
			if ((Object)(object)val2 == (Object)null)
			{
				val.GetComponent<ItemDrop>().m_itemData.m_shared.m_buildPieces.m_pieces.Add(modResourceLoader.dyeTable);
			}
			colorizerPacks = ItemSetBuilder.createColorPacks(modResourceLoader);
			string[] buildPieceNames = Launch.buildPieceNames;
			foreach (string name in buildPieceNames)
			{
				GameObject val3 = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == name);
				if ((Object)(object)val3 != (Object)null)
				{
					itemSetBuilder.setupColorizer(val3);
					swapBasicTexture(val3);
				}
			}
			if (!new ZNet().IsDedicated())
			{
				ShaderReplacment.runMaterialFix();
				hasSpawned = true;
			}
		}
	}

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

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

	public const string PluginName = "BalrondBannerColorizer";

	public const string PluginVersion = "1.0.6";

	public static ModResourceLoader modResourceLoader = new ModResourceLoader();

	public static ItemEdits itemEdits = new ItemEdits();

	public static DatabaseAddMethods databaseAddMethods = new DatabaseAddMethods();

	public static ItemSetBuilder itemSetBuilder = new ItemSetBuilder();

	public static GameObject RootObject;

	public static GameObject PrefabContainer;

	public static List<ColorizerPack> colorizerPacks = new List<ColorizerPack>();

	public static bool hasSpawned = false;

	public static string[] buildPieceNames = new string[25]
	{
		"piece_banner01", "piece_banner02", "piece_banner03", "piece_banner04", "piece_banner05", "piece_banner06", "piece_banner07", "piece_banner08", "piece_banner09", "piece_banner10",
		"piece_banner11", "piece_cloth_hanging_door", "piece_cloth_hanging_door_blue", "piece_cloth_hanging_door_blue2", "jute_carpet", "jute_carpet_blue", "crystal_wall_1x1", "darkwood_roof_icorner", "darkwood_roof_icorner_45", "darkwood_roof_ocorner",
		"darkwood_roof_ocorner_45", "darkwood_roof_top", "darkwood_roof_top_45", "darkwood_roof_45", "darkwood_roof"
	};

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

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

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

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

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

	public static void swapBasicTexture(GameObject gameObject)
	{
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Expected O, but got Unknown
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Expected O, but got Unknown
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Expected O, but got Unknown
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Expected O, but got Unknown
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Expected O, but got Unknown
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0144: Expected O, but got Unknown
		//IL_016b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0175: Expected O, but got Unknown
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: Expected O, but got Unknown
		//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01be: Expected O, but got Unknown
		//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Expected O, but got Unknown
		//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0205: Expected O, but got Unknown
		//IL_0212: Unknown result type (might be due to invalid IL or missing references)
		//IL_021c: Expected O, but got Unknown
		switch (((Object)gameObject).name)
		{
		case "piece_banner08":
		{
			MeshRenderer component6 = ((Component)gameObject.transform.Find("default")).GetComponent<MeshRenderer>();
			((Renderer)component6).material = new Material(modResourceLoader.banner08yellow);
			((Renderer)component6).sharedMaterial = new Material(modResourceLoader.banner08yellow);
			break;
		}
		case "piece_banner05":
		{
			MeshRenderer component5 = ((Component)gameObject.transform.Find("default")).GetComponent<MeshRenderer>();
			((Renderer)component5).material = new Material(modResourceLoader.banner05green);
			((Renderer)component5).sharedMaterial = new Material(modResourceLoader.banner05green);
			break;
		}
		case "piece_banner07":
		{
			MeshRenderer component4 = ((Component)gameObject.transform.Find("default")).GetComponent<MeshRenderer>();
			((Renderer)component4).material = new Material(modResourceLoader.banner07blue);
			((Renderer)component4).sharedMaterial = new Material(modResourceLoader.banner07blue);
			break;
		}
		case "piece_banner09":
		{
			MeshRenderer component3 = ((Component)gameObject.transform.Find("default")).GetComponent<MeshRenderer>();
			((Renderer)component3).material = new Material(modResourceLoader.banner09purple);
			((Renderer)component3).sharedMaterial = new Material(modResourceLoader.banner09purple);
			break;
		}
		case "piece_banner10":
		{
			MeshRenderer component2 = ((Component)gameObject.transform.Find("default")).GetComponent<MeshRenderer>();
			((Renderer)component2).material = new Material(modResourceLoader.banner10orange);
			((Renderer)component2).sharedMaterial = new Material(modResourceLoader.banner10orange);
			break;
		}
		case "piece_banner11":
		{
			MeshRenderer component = ((Component)gameObject.transform.Find("default")).GetComponent<MeshRenderer>();
			((Renderer)component).material = new Material(modResourceLoader.banner11white);
			((Renderer)component).sharedMaterial = new Material(modResourceLoader.banner11white);
			break;
		}
		}
	}

	public static 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 static List<Recipe> createRecipesForDye(List<GameObject> items)
	{
		List<Recipe> list = new List<Recipe>();
		foreach (GameObject item in modResourceLoader.items)
		{
			Recipe val = ScriptableObject.CreateInstance<Recipe>();
			((Object)val).name = "Recipe_" + ((Object)item).name;
			val.m_minStationLevel = 1;
			val.m_craftingStation = modResourceLoader.dyeTable.GetComponent<CraftingStation>();
			val.m_repairStation = val.m_craftingStation;
			val.m_item = item.GetComponent<ItemDrop>();
			val.m_resources = createRecipeResource(item, items);
			list.Add(val);
		}
		return list;
	}

	public static Requirement[] createRecipeResource(GameObject item, List<GameObject> items)
	{
		List<Requirement> list = new List<Requirement>();
		switch (((Object)item).name)
		{
		case "DyeBlack":
			list.Add(createReq("Coal", 1, 0, items));
			break;
		case "DyeBlue":
			list.Add(createReq("Blueberries", 2, 0, items));
			break;
		case "DyeGreen":
			list.Add(createReq("Guck", 1, 0, items));
			break;
		case "DyeOrange":
			list.Add(createReq("Raspberry", 1, 0, items));
			list.Add(createReq("Cloudberry", 1, 0, items));
			break;
		case "DyePurple":
			list.Add(createReq("Raspberry", 1, 0, items));
			list.Add(createReq("Blueberries", 1, 0, items));
			break;
		case "DyeRed":
			list.Add(createReq("Bloodbag", 1, 0, items));
			break;
		case "DyeWhite":
			list.Add(createReq("BoneFragments", 2, 0, items));
			break;
		case "DyeYellow":
			list.Add(createReq("Cloudberry", 2, 0, items));
			break;
		}
		return list.ToArray();
	}

	public static Requirement createReq(string name, int amount, int amountPerLevel, List<GameObject> items)
	{
		//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, items).GetComponent<ItemDrop>();
		val.m_resItem = component;
		val.m_amount = amount;
		val.m_amountPerLevel = amountPerLevel;
		return val;
	}

	public static GameObject FindItem(string name, List<GameObject> items)
	{
		GameObject val = items.Find((GameObject x) => ((Object)x).name == name);
		if ((Object)(object)val == (Object)null)
		{
			Debug.LogWarning((object)("Item Not Found - " + name + ", Replaced With Wood"));
			return items.Find((GameObject x) => ((Object)x).name == "Wood");
		}
		if ((Object)(object)val != (Object)null)
		{
			return val;
		}
		Debug.LogWarning((object)("Item Not Found At All - " + name + ", Replaced With Wood"));
		return items.Find((GameObject x) => ((Object)x).name == "Wood");
	}
}
public class ModResourceLoader
{
	public AssetBundle assetBundle;

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

	public ShaderReplacment shaderReplacment = new ShaderReplacment();

	public Material crystal01black;

	public Material crystal01blue;

	public Material crystal01green;

	public Material crystal01orange;

	public Material crystal01purple;

	public Material crystal01red;

	public Material crystal01white;

	public Material crystal01yellow;

	public Material banner01black;

	public Material banner01blue;

	public Material banner01green;

	public Material banner01orange;

	public Material banner01purple;

	public Material banner01red;

	public Material banner01white;

	public Material banner01yellow;

	public Material banner02black;

	public Material banner02blue;

	public Material banner02green;

	public Material banner02orange;

	public Material banner02purple;

	public Material banner02red;

	public Material banner02white;

	public Material banner02yellow;

	public Material banner03black;

	public Material banner03blue;

	public Material banner03green;

	public Material banner03orange;

	public Material banner03purple;

	public Material banner03red;

	public Material banner03white;

	public Material banner03yellow;

	public Material banner04black;

	public Material banner04blue;

	public Material banner04green;

	public Material banner04orange;

	public Material banner04purple;

	public Material banner04red;

	public Material banner04white;

	public Material banner04yellow;

	public Material banner05black;

	public Material banner05blue;

	public Material banner05green;

	public Material banner05orange;

	public Material banner05purple;

	public Material banner05red;

	public Material banner05white;

	public Material banner05yellow;

	public Material banner06black;

	public Material banner06blue;

	public Material banner06green;

	public Material banner06orange;

	public Material banner06purple;

	public Material banner06red;

	public Material banner06white;

	public Material banner06yellow;

	public Material banner07black;

	public Material banner07blue;

	public Material banner07green;

	public Material banner07orange;

	public Material banner07purple;

	public Material banner07red;

	public Material banner07white;

	public Material banner07yellow;

	public Material banner08black;

	public Material banner08blue;

	public Material banner08green;

	public Material banner08orange;

	public Material banner08purple;

	public Material banner08red;

	public Material banner08white;

	public Material banner08yellow;

	public Material banner09black;

	public Material banner09blue;

	public Material banner09green;

	public Material banner09orange;

	public Material banner09purple;

	public Material banner09red;

	public Material banner09white;

	public Material banner09yellow;

	public Material banner10black;

	public Material banner10blue;

	public Material banner10green;

	public Material banner10orange;

	public Material banner10purple;

	public Material banner10red;

	public Material banner10white;

	public Material banner10yellow;

	public Material banner11black;

	public Material banner11blue;

	public Material banner11green;

	public Material banner11orange;

	public Material banner11purple;

	public Material banner11red;

	public Material banner11white;

	public Material banner11yellow;

	public Material bannerHangingblack;

	public Material bannerHangingblue;

	public Material bannerHanginggreen;

	public Material bannerHangingorange;

	public Material bannerHangingpurple;

	public Material bannerHangingred;

	public Material bannerHangingwhite;

	public Material bannerHangingyellow;

	public Material bannerHanging2black;

	public Material bannerHanging2blue;

	public Material bannerHanging2green;

	public Material bannerHanging2orange;

	public Material bannerHanging2purple;

	public Material bannerHanging2red;

	public Material bannerHanging2white;

	public Material bannerHanging2yellow;

	public Material bannerHanging3black;

	public Material bannerHanging3blue;

	public Material bannerHanging3green;

	public Material bannerHanging3orange;

	public Material bannerHanging3purple;

	public Material bannerHanging3red;

	public Material bannerHanging3white;

	public Material bannerHanging3yellow;

	public Material juteCarpetblack;

	public Material juteCarpetblue;

	public Material juteCarpetgreen;

	public Material juteCarpetorange;

	public Material juteCarpetpurple;

	public Material juteCarpetred;

	public Material juteCarpetwhite;

	public Material juteCarpetyellow;

	public Material juteCarpetMainblack;

	public Material juteCarpetMainblue;

	public Material juteCarpetMaingreen;

	public Material juteCarpetMainorange;

	public Material juteCarpetMainpurple;

	public Material juteCarpetMainred;

	public Material juteCarpetMainwhite;

	public Material juteCarpetMainyellow;

	public Material juteCarpetDestructionblack;

	public Material juteCarpetDestructionblue;

	public Material juteCarpetDestructiongreen;

	public Material juteCarpetDestructionorange;

	public Material juteCarpetDestructionpurple;

	public Material juteCarpetDestructionred;

	public Material juteCarpetDestructionwhite;

	public Material juteCarpetDestructionyellow;

	public Material juteCarpet2black;

	public Material juteCarpet2blue;

	public Material juteCarpet2green;

	public Material juteCarpet2orange;

	public Material juteCarpet2purple;

	public Material juteCarpet2red;

	public Material juteCarpet2white;

	public Material juteCarpet2yellow;

	public Material juteCarpetMain2black;

	public Material juteCarpetMain2blue;

	public Material juteCarpetMain2green;

	public Material juteCarpetMain2orange;

	public Material juteCarpetMain2purple;

	public Material juteCarpetMain2red;

	public Material juteCarpetMain2white;

	public Material juteCarpetMain2yellow;

	public Material juteCarpetDestruction2black;

	public Material juteCarpetDestruction2blue;

	public Material juteCarpetDestruction2green;

	public Material juteCarpetDestruction2orange;

	public Material juteCarpetDestruction2purple;

	public Material juteCarpetDestruction2red;

	public Material juteCarpetDestruction2white;

	public Material juteCarpetDestruction2yellow;

	public Material roofDarkMain2black;

	public Material roofDarkMain2blue;

	public Material roofDarkMain2green;

	public Material roofDarkMain2orange;

	public Material roofDarkMain2purple;

	public Material roofDarkMain2red;

	public Material roofDarkMain2white;

	public Material roofDarkMain2yellow;

	public Material roofDarkDestructionblack;

	public Material roofDarkDestructionblue;

	public Material roofDarkDestructiongreen;

	public Material roofDarkDestructionorange;

	public Material roofDarkDestructionpurple;

	public Material roofDarkDestructionred;

	public Material roofDarkDestructionwhite;

	public Material roofDarkDestructionyellow;

	public string[] prefabNames = new string[8] { "DyeBlack", "DyeBlue", "DyeGreen", "DyeOrange", "DyePurple", "DyeRed", "DyeWhite", "DyeYellow" };

	public GameObject dyeTable;

	public void loadAssets()
	{
		assetBundle = GetAssetBundleFromResources("bannercolorizer");
		string text = "Assets/Custom/BalrondBannerColorizer/";
		string[] array = prefabNames;
		foreach (string text2 in array)
		{
			GameObject val = assetBundle.LoadAsset<GameObject>(text + "prefabs/" + text2 + ".prefab");
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogWarning((object)("Sail not found: " + text2));
			}
			else
			{
				items.Add(val);
			}
		}
		dyeTable = assetBundle.LoadAsset<GameObject>(text + "prefabs/piece_dyestation.prefab");
		Material temp = assetBundle.LoadAsset<Material>(text + "banner01/black.mat");
		CreateBanner01(temp, text);
		CreateBanner02(temp, text);
		CreateBanner03(temp, text);
		CreateBanner04(temp, text);
		CreateBanner05(temp, text);
		CreateBanner06(temp, text);
		CreateBanner07(temp, text);
		CreateBanner08(temp, text);
		CreateBanner09(temp, text);
		CreateBanner10(temp, text);
		CreateBanner11(temp, text);
		CreatebannerHanging(temp, text);
		CreatebannerHanging2(temp, text);
		CreatebannerHanging3(temp, text);
		CreatejuteCarpet(temp, text);
		CreatejuteCarpetMain(temp, text);
		CreatejuteCarpetDestruction(temp, text);
		CreatejuteCarpet2(temp, text);
		CreatejuteCarpetMain2(temp, text);
		CreatejuteCarpetDestruction2(temp, text);
		CreateCrystalWall1(temp, text);
		CreateroofDarkMain2(temp, text);
		CreateroofDarkDestruction(temp, text);
	}

	private void CreateCrystalWall1(Material temp, string mainPath)
	{
		temp = assetBundle.LoadAsset<Material>(mainPath + "crystalWall1/black.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		crystal01black = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "crystalWall1/blue.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		crystal01blue = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "crystalWall1/green.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		crystal01green = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "crystalWall1/orange.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		crystal01orange = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "crystalWall1/purple.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		crystal01purple = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "crystalWall1/red.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		crystal01red = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "crystalWall1/white.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		crystal01white = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "crystalWall1/yellow.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		crystal01yellow = temp;
	}

	private void CreateBanner01(Material temp, string mainPath)
	{
		temp = assetBundle.LoadAsset<Material>(mainPath + "banner01/black.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		banner01black = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "banner01/blue.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		banner01blue = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "banner01/green.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		banner01green = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "banner01/orange.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		banner01orange = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "banner01/purple.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		banner01purple = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "banner01/red.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		banner01red = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "banner01/white.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		banner01white = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "banner01/yellow.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		banner01yellow = temp;
	}

	private void CreateBanner02(Material temp, string mainPath)
	{
		temp = assetBundle.LoadAsset<Material>(mainPath + "banner02/black.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		banner02black = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "banner02/blue.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		banner02blue = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "banner02/green.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		banner02green = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "banner02/orange.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		banner02orange = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "banner02/purple.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		banner02purple = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "banner02/red.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		banner02red = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "banner02/white.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		banner02white = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "banner02/yellow.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		banner02yellow = temp;
	}

	private void CreateBanner03(Material temp, string mainPath)
	{
		temp = assetBundle.LoadAsset<Material>(mainPath + "banner03/black.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		banner03black = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "banner03/blue.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		banner03blue = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "banner03/green.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		banner03green = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "banner03/orange.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		banner03orange = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "banner03/purple.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		banner03purple = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "banner03/red.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		banner03red = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "banner03/white.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		banner03white = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "banner03/yellow.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		banner03yellow = temp;
	}

	private void CreateBanner04(Material temp, string mainPath)
	{
		temp = assetBundle.LoadAsset<Material>(mainPath + "banner04/black.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		banner04black = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "banner04/blue.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		banner04blue = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "banner04/green.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		banner04green = temp;
		ShaderReplacment.ReplaceMaterial(temp);
		temp = assetBundle.LoadAsset<Material>(mainPath + "banner04/orange.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		banner04orange = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "banner04/purple.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		banner04pu