Decompiled source of balrond furRandomizer v1.0.6

plugins/BalrondFurRandomizer.dll

Decompiled 7 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 BalrondFurRandomizer;

public class FxReplacment
{
	private List<GameObject> allPrefabs;

	private string projectName = "[BalrondFurRandomizer]";

	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 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 void ReplaceMaterial(Material material)
	{
		if ((Object)(object)material == (Object)null)
		{
			Debug.LogWarning((object)"Material is empty !");
		}
		else
		{
			materialsInPrefabs.Add(material);
		}
	}

	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)
		{
			if ((Object)(object)materialsInPrefab == (Object)null)
			{
				Debug.Log((object)"I had a null in list");
				continue;
			}
			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;
	}
}
public class BaseLevelEffectSetupValue
{
	public float scale = 1.1f;

	public float saturation = 0.5f;

	public float hue = -0.1f;

	public float value = -0.1f;

	public LevelSetup setup = null;

	public GameObject enabledObject = null;

	public GameObject enabledObjectLevel2 = null;

	public GameObject enabledObjectLevel3 = null;

	public bool setEmmisive = false;

	public Color emissive = Color.white;

	public float sumValue = 0.05f;

	public void getSetup(LevelEffects levelEffects)
	{
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)levelEffects == (Object)null)
		{
			Debug.LogWarning((object)"I should not be here i am null");
			return;
		}
		int num = 0;
		if (levelEffects.m_levelSetups != null && levelEffects.m_levelSetups.Count > 0)
		{
			num = levelEffects.m_levelSetups.Count;
			setup = levelEffects.m_levelSetups.Last();
		}
		if (num != 0 && setup != null)
		{
			scale = setup.m_scale;
			saturation = setup.m_saturation;
			hue = setup.m_hue;
			value = setup.m_value;
			enabledObject = setup.m_enableObject;
			emissive = setup.m_emissiveColor;
			setEmmisive = setup.m_setEmissiveColor;
			enabledObjectLevel2 = enabledObject;
			enabledObjectLevel3 = enabledObject;
		}
		else
		{
			setValues(num, levelEffects);
		}
		if ((Object)(object)levelEffects.m_character != (Object)null)
		{
			if (((Object)((Component)levelEffects.m_character).gameObject).name == "Deer")
			{
				EditDeer(levelEffects);
			}
			if (((Object)((Component)levelEffects.m_character).gameObject).name == "Boar")
			{
				EditBoar(levelEffects);
			}
		}
	}

	private void EditDeer(LevelEffects levelEffects)
	{
		GameObject enableObject = levelEffects.m_levelSetups[0].m_enableObject;
		GameObject enableObject2 = levelEffects.m_levelSetups[1].m_enableObject;
		enabledObjectLevel2 = enableObject;
		enabledObjectLevel3 = enableObject2;
		Transform parent = enableObject.transform.parent;
		GameObject enableObject3 = (enabledObject = ((Component)parent.Find("Antler1")).gameObject);
		levelEffects.m_levelSetups[0].m_enableObject = enableObject3;
		levelEffects.m_levelSetups[1].m_enableObject = enableObject3;
	}

	private void EditBoar(LevelEffects gameObject)
	{
	}

	private void setValues(int levels, LevelEffects levelEffects)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		float y = ((Component)levelEffects).transform.localScale.y;
		if (levels == 0)
		{
			scale = y;
			saturation = 0f;
			hue = 0f;
			value = 0f;
		}
		if (levels == 1)
		{
			scale = y + 0.05f;
			saturation = 0.5f;
			hue = -0.05f;
			value = -0.05f;
		}
		if (levels == 2)
		{
			scale = y + 0.1f;
			saturation = 0.5f;
			hue = -0.1f;
			value = -0.1f;
		}
	}
}
public class ItemSetBuilder
{
	public List<ItemSet> itemSets = new List<ItemSet>();

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

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

	public ModResourceLoader modResourceLoader = null;

	public static List<MaterialPack> materialPacks = new List<MaterialPack>();

	public void setup(List<GameObject> prefabs)
	{
		this.prefabs = prefabs;
	}

	public void createMaterialPacks(ModResourceLoader modResourceLoader)
	{
		this.modResourceLoader = modResourceLoader;
		buildPack(this.modResourceLoader.loxFace_Default, this.modResourceLoader.loxtBody_Default, this.modResourceLoader.loxFur_Default, "Lox", "Default");
		buildPack(this.modResourceLoader.loxFace_Albino, this.modResourceLoader.loxtBody_Albino, this.modResourceLoader.loxFur_Albino, "Lox", "Albino");
		buildPack(this.modResourceLoader.loxFace_Black, this.modResourceLoader.loxtBody_Black, this.modResourceLoader.loxFur_Black, "Lox", "Black");
		buildPack(this.modResourceLoader.loxFace_Blond, this.modResourceLoader.loxtBody_Blond, this.modResourceLoader.loxFur_Blond, "Lox", "Blond");
		buildPack(this.modResourceLoader.loxFace_DarkBrown, this.modResourceLoader.loxtBody_DarkBrown, this.modResourceLoader.loxFur_DarkBrown, "Lox", "Brown");
		buildPack(this.modResourceLoader.loxFace_Ginger, this.modResourceLoader.loxtBody_Ginger, this.modResourceLoader.loxFur_Ginger, "Lox", "Ginger");
		buildPack(this.modResourceLoader.wolfBody_Default, this.modResourceLoader.wolfBody_Default, this.modResourceLoader.wolfBody_Default, "Wolf", "Default");
		buildPack(this.modResourceLoader.wolfBody_Albino, this.modResourceLoader.wolfBody_Albino, this.modResourceLoader.wolfBody_Albino, "Wolf", "Albino");
		buildPack(this.modResourceLoader.wolfBody_Black, this.modResourceLoader.wolfBody_Black, this.modResourceLoader.wolfBody_Black, "Wolf", "Black");
		buildPack(this.modResourceLoader.wolfBody_DarkBrown, this.modResourceLoader.wolfBody_DarkBrown, this.modResourceLoader.wolfBody_DarkBrown, "Wolf", "Brown");
		buildPack(this.modResourceLoader.wolfBody_Grey, this.modResourceLoader.wolfBody_Grey, this.modResourceLoader.wolfBody_Grey, "Wolf", "Grey");
		buildPack(this.modResourceLoader.deerBody_Default, this.modResourceLoader.deerBody_Default, this.modResourceLoader.deerBody_Default, "Deer", "Default");
		buildPack(this.modResourceLoader.deerBody_Albino, this.modResourceLoader.deerBody_Albino, this.modResourceLoader.deerBody_Albino, "Deer", "Albino");
		buildPack(this.modResourceLoader.deerBody_Red, this.modResourceLoader.deerBody_Red, this.modResourceLoader.deerBody_Red, "Deer", "Red");
		buildPack(this.modResourceLoader.deerBody_DarkBrown, this.modResourceLoader.deerBody_DarkBrown, this.modResourceLoader.deerBody_DarkBrown, "Deer", "Brown");
		buildPack(this.modResourceLoader.deerBody_Grey, this.modResourceLoader.deerBody_Grey, this.modResourceLoader.deerBody_Grey, "Deer", "Grey");
		buildPack(this.modResourceLoader.boarBody_Default, this.modResourceLoader.boarBody_Default, this.modResourceLoader.boarBody_Default, "Boar", "Default");
		buildPack(this.modResourceLoader.boarBody_Grey, this.modResourceLoader.boarBody_Grey, this.modResourceLoader.boarBody_Grey, "Boar", "Grey");
		buildPack(this.modResourceLoader.boarBody_Black, this.modResourceLoader.boarBody_Black, this.modResourceLoader.boarBody_Black, "Boar", "Black");
		buildPack(this.modResourceLoader.boarBody_DarkBrown, this.modResourceLoader.boarBody_DarkBrown, this.modResourceLoader.boarBody_DarkBrown, "Boar", "Brown");
		buildPack(this.modResourceLoader.boarBody_LightBrown, this.modResourceLoader.boarBody_LightBrown, this.modResourceLoader.boarBody_LightBrown, "Wolf", "Brown2");
		buildPack(this.modResourceLoader.neckBody_Default, this.modResourceLoader.neckBody_Default, this.modResourceLoader.neckBody_Default, "Neck", "Default");
		buildPack(this.modResourceLoader.neckBody_Albino, this.modResourceLoader.neckBody_Albino, this.modResourceLoader.neckBody_Albino, "Neck", "Albino");
		buildPack(this.modResourceLoader.neckBody_DarkBlue, this.modResourceLoader.neckBody_DarkBlue, this.modResourceLoader.neckBody_DarkBlue, "Neck", "Dark");
		buildPack(this.modResourceLoader.neckBody_DarkGreen, this.modResourceLoader.neckBody_DarkGreen, this.modResourceLoader.neckBody_DarkGreen, "Neck", "Green");
		buildPack(this.modResourceLoader.neckBody_Blue, this.modResourceLoader.neckBody_Blue, this.modResourceLoader.neckBody_Blue, "Neck", "Blue");
		buildPack(this.modResourceLoader.askvinBody_Default, this.modResourceLoader.askvinBody_Default, this.modResourceLoader.askvinBody_Default, "Asksvin", "Default");
		buildPack(this.modResourceLoader.askvinBody_Albino, this.modResourceLoader.askvinBody_Albino, this.modResourceLoader.askvinBody_Albino, "Asksvin", "Albino");
		buildPack(this.modResourceLoader.askvinBody_Black, this.modResourceLoader.askvinBody_Black, this.modResourceLoader.askvinBody_Black, "Asksvin", "Dark");
		buildPack(this.modResourceLoader.askvinBody_Purple, this.modResourceLoader.askvinBody_Purple, this.modResourceLoader.askvinBody_Purple, "Asksvin", "Purple");
		buildPack(this.modResourceLoader.askvinBody_Grey, this.modResourceLoader.askvinBody_Grey, this.modResourceLoader.askvinBody_Grey, "Asksvin", "Grey");
		buildPack(this.modResourceLoader.hareBody_Default, this.modResourceLoader.hareBody_Default, this.modResourceLoader.hareBody_Default, "Hare", "Default");
		buildPack(this.modResourceLoader.hareBody_Albino, this.modResourceLoader.hareBody_Albino, this.modResourceLoader.hareBody_Albino, "Hare", "Albino");
		buildPack(this.modResourceLoader.hareBody_Black, this.modResourceLoader.hareBody_Black, this.modResourceLoader.hareBody_Black, "Hare", "Black");
		buildPack(this.modResourceLoader.hareBody_DarkBlue, this.modResourceLoader.hareBody_DarkBlue, this.modResourceLoader.hareBody_DarkBlue, "Hare", "Blue");
		buildPack(this.modResourceLoader.hareBody_Ginger, this.modResourceLoader.hareBody_Ginger, this.modResourceLoader.hareBody_Ginger, "Hare", "Ginger");
		buildPack(this.modResourceLoader.drakeBody_Default, this.modResourceLoader.drakeBody_Default, this.modResourceLoader.drakeBody_Default, "Hatchling", "Default");
		buildPack(this.modResourceLoader.drakeBody_Red, this.modResourceLoader.drakeBody_Red, this.modResourceLoader.drakeBody_Red, "Hatchling", "Albino");
		buildPack(this.modResourceLoader.drakeBody_DarkBlue, this.modResourceLoader.drakeBody_DarkBlue, this.modResourceLoader.drakeBody_DarkBlue, "Hatchling", "Blue");
		buildPack(this.modResourceLoader.drakeBody_IceBlue, this.modResourceLoader.drakeBody_IceBlue, this.modResourceLoader.drakeBody_IceBlue, "Hatchling", "Ice");
		buildPack(this.modResourceLoader.drakeBody_Purple, this.modResourceLoader.drakeBody_Purple, this.modResourceLoader.drakeBody_Purple, "Hatchling", "Purple");
		buildPack(this.modResourceLoader.serpentBody_Default, this.modResourceLoader.serpentBody_Default, this.modResourceLoader.serpentBody_Default, "Serpent", "Default");
		buildPack(this.modResourceLoader.serpentBody_Albino, this.modResourceLoader.serpentBody_Albino, this.modResourceLoader.serpentBody_Albino, "Serpent", "Albino");
		buildPack(this.modResourceLoader.serpentBody_Black, this.modResourceLoader.serpentBody_Black, this.modResourceLoader.serpentBody_Black, "Serpent", "Black");
		buildPack(this.modResourceLoader.serpentBody_Blue, this.modResourceLoader.serpentBody_Blue, this.modResourceLoader.serpentBody_Blue, "Serpent", "Blue");
		buildPack(this.modResourceLoader.serpentBody_Green, this.modResourceLoader.serpentBody_Green, this.modResourceLoader.serpentBody_Green, "Serpent", "Green");
		buildPack(this.modResourceLoader.serpentBody_Red, this.modResourceLoader.serpentBody_Red, this.modResourceLoader.serpentBody_Red, "Serpent", "Green");
	}

	private void buildPack(Material face, Material body, Material body2, string name, string skin)
	{
		materialPacks.Add(new MaterialPack(face, body, body2, name, skin));
	}

	public void setupFurRandomizerForMonster(GameObject monster)
	{
		if ((Object)(object)monster == (Object)null)
		{
			Debug.LogWarning((object)"Monster not found");
		}
		FurRandomizer furRandomizer = monster.AddComponent<FurRandomizer>();
	}
}
[Serializable]
public class FurRandomizer : MonoBehaviour
{
	private ZNetView m_zview;

	private MonsterAI m_monsterAI;

	private AnimalAI m_animalAI;

	private Humanoid m_humanoid;

	public List<MaterialPack> m_materials;

	private string skinName;

	public static ModResourceLoader modResourceLoader = Launch.modResourceLoader;

	private List<MaterialPack> materialPacks = ItemSetBuilder.materialPacks;

	private MaterialPack m_materialPack;

	public SkinnedMeshRenderer face;

	public SkinnedMeshRenderer body;

	public SkinnedMeshRenderer fur;

	private void Awake()
	{
		if (!validatePrefab())
		{
			Debug.LogWarning((object)("I should not  be randomized: " + ((Object)((Component)this).gameObject).name));
			return;
		}
		if ((Object)(object)modResourceLoader.drakeBody_DarkBlue == (Object)null)
		{
			Debug.LogWarning((object)"Nothing loaded");
		}
		m_zview = ((Component)this).GetComponent<ZNetView>();
		m_monsterAI = ((Component)this).GetComponent<MonsterAI>();
		m_animalAI = ((Component)this).GetComponent<AnimalAI>();
		m_humanoid = ((Component)this).GetComponent<Humanoid>();
		createMaterialPacks();
		if (setupFurRandomizerForMonster())
		{
			if (m_materials.Count == 0)
			{
				Debug.LogWarning((object)"Material list is empty");
			}
			bool @bool = m_zview.m_zdo.GetBool("furRandomizerSetActive", false);
			PickRandomSet(@bool);
		}
	}

	private bool validatePrefab()
	{
		string[] source = new string[9] { "Wolf", "Lox", "Serpent", "Neck", "Hatchling", "Hare", "Boar", "Deer", "Asksvin" };
		string name = ((Object)((Component)this).gameObject).name;
		name = editZnetName(name);
		return source.Contains(name);
	}

	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 PickRandomSet(bool chosen = false)
	{
		int num = -1;
		if (chosen)
		{
			num = m_zview.m_zdo.GetInt("furRandomizerSet", 0);
		}
		if (num == -1)
		{
			num = Random.Range(0, m_materials.Count - 1);
			m_zview.m_zdo.Set("furRandomizerSet", num);
		}
		if (m_materials.Count - 1 < num)
		{
			num = Random.Range(0, m_materials.Count - 1);
			m_zview.m_zdo.Set("furRandomizerSet", num);
		}
		if (m_materials.Count != 0)
		{
			MaterialPack materialPack = m_materials[num];
			skinName = materialPack.skin;
			m_materialPack = materialPack;
			m_zview.m_zdo.Set("furRandomizerSetActive", true);
			setSkin(materialPack);
		}
	}

	private void setSkin(MaterialPack m_materialPack)
	{
		//IL_0358: Unknown result type (might be due to invalid IL or missing references)
		//IL_035e: Expected O, but got Unknown
		//IL_0285: Unknown result type (might be due to invalid IL or missing references)
		//IL_028f: Expected O, but got Unknown
		//IL_029c: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a6: Expected O, but got Unknown
		//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f5: Expected O, but got Unknown
		//IL_0302: Unknown result type (might be due to invalid IL or missing references)
		//IL_030c: Expected O, but got Unknown
		//IL_0195: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Expected O, but got Unknown
		//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c2: Expected O, but got Unknown
		//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e9: Expected O, but got Unknown
		//IL_020c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0212: Expected O, but got Unknown
		//IL_0236: Unknown result type (might be due to invalid IL or missing references)
		//IL_023c: Expected O, but got Unknown
		//IL_0260: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: Expected O, but got Unknown
		//IL_031e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0328: Expected O, but got Unknown
		//IL_0335: Unknown result type (might be due to invalid IL or missing references)
		//IL_033f: Expected O, but got Unknown
		//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c2: Expected O, but got Unknown
		//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d9: Expected O, but got Unknown
		string name = ((Object)((Component)this).gameObject).name;
		switch (editZnetName(name))
		{
		case "Lox":
		{
			Material[] materials2 = ((Renderer)face).materials;
			materials2[0] = new Material(m_materialPack.body);
			((Renderer)face).materials = materials2;
			Material[] materials3 = ((Renderer)body).materials;
			materials3[0] = new Material(m_materialPack.body);
			((Renderer)body).materials = materials3;
			Material[] materials4 = ((Renderer)fur).materials;
			materials4[0] = new Material(m_materialPack.body2);
			((Renderer)fur).materials = materials4;
			Material[] sharedMaterials = ((Renderer)face).sharedMaterials;
			sharedMaterials[1] = new Material(m_materialPack.face);
			((Renderer)face).sharedMaterials = sharedMaterials;
			Material[] sharedMaterials2 = ((Renderer)body).sharedMaterials;
			sharedMaterials2[0] = new Material(m_materialPack.body);
			((Renderer)body).sharedMaterials = sharedMaterials2;
			Material[] sharedMaterials3 = ((Renderer)fur).sharedMaterials;
			sharedMaterials3[0] = new Material(m_materialPack.body2);
			((Renderer)fur).sharedMaterials = sharedMaterials3;
			break;
		}
		case "Hare":
		case "Serpent":
		case "Neck":
		case "Wolf":
			((Renderer)body).sharedMaterial = new Material(m_materialPack.face);
			((Renderer)body).material = new Material(m_materialPack.face);
			break;
		case "Boar":
			((Renderer)body).sharedMaterial = new Material(m_materialPack.face);
			((Renderer)body).material = new Material(m_materialPack.face);
			break;
		case "Deer":
			((Renderer)body).sharedMaterial = new Material(m_materialPack.face);
			((Renderer)body).material = new Material(m_materialPack.face);
			break;
		case "Asksvin":
			((Renderer)body).sharedMaterial = new Material(m_materialPack.face);
			((Renderer)body).material = new Material(m_materialPack.face);
			break;
		case "Hatchling":
		{
			Material[] materials = ((Renderer)face).materials;
			materials[0] = new Material(m_materialPack.body);
			((Renderer)face).materials = materials;
			((Renderer)body).materials = materials;
			((Renderer)fur).materials = materials;
			((Renderer)face).sharedMaterials = materials;
			((Renderer)body).sharedMaterials = materials;
			((Renderer)fur).sharedMaterials = materials;
			break;
		}
		}
	}

	private void createMaterialPacks()
	{
		buildPack(modResourceLoader.loxFace_Default, modResourceLoader.loxtBody_Default, modResourceLoader.loxFur_Default, "Lox", "Default");
		buildPack(modResourceLoader.loxFace_Albino, modResourceLoader.loxtBody_Albino, modResourceLoader.loxFur_Albino, "Lox", "Albino");
		buildPack(modResourceLoader.loxFace_Black, modResourceLoader.loxtBody_Black, modResourceLoader.loxFur_Black, "Lox", "Black");
		buildPack(modResourceLoader.loxFace_Blond, modResourceLoader.loxtBody_Blond, modResourceLoader.loxFur_Blond, "Lox", "Blond");
		buildPack(modResourceLoader.loxFace_DarkBrown, modResourceLoader.loxtBody_DarkBrown, modResourceLoader.loxFur_DarkBrown, "Lox", "Brown");
		buildPack(modResourceLoader.loxFace_Ginger, modResourceLoader.loxtBody_Ginger, modResourceLoader.loxFur_Ginger, "Lox", "Ginger");
		buildPack(modResourceLoader.wolfBody_Default, modResourceLoader.wolfBody_Default, modResourceLoader.wolfBody_Default, "Wolf", "Default");
		buildPack(modResourceLoader.wolfBody_Albino, modResourceLoader.wolfBody_Albino, modResourceLoader.wolfBody_Albino, "Wolf", "Albino");
		buildPack(modResourceLoader.wolfBody_Black, modResourceLoader.wolfBody_Black, modResourceLoader.wolfBody_Black, "Wolf", "Black");
		buildPack(modResourceLoader.wolfBody_DarkBrown, modResourceLoader.wolfBody_DarkBrown, modResourceLoader.wolfBody_DarkBrown, "Wolf", "Brown");
		buildPack(modResourceLoader.wolfBody_Grey, modResourceLoader.wolfBody_Grey, modResourceLoader.wolfBody_Grey, "Wolf", "Grey");
		buildPack(modResourceLoader.neckBody_Default, modResourceLoader.neckBody_Default, modResourceLoader.neckBody_Default, "Neck", "Default");
		buildPack(modResourceLoader.neckBody_Albino, modResourceLoader.neckBody_Albino, modResourceLoader.neckBody_Albino, "Neck", "Albino");
		buildPack(modResourceLoader.neckBody_DarkBlue, modResourceLoader.neckBody_DarkBlue, modResourceLoader.neckBody_DarkBlue, "Neck", "Dark");
		buildPack(modResourceLoader.neckBody_DarkGreen, modResourceLoader.neckBody_DarkGreen, modResourceLoader.neckBody_DarkGreen, "Neck", "Green");
		buildPack(modResourceLoader.neckBody_Blue, modResourceLoader.neckBody_Blue, modResourceLoader.neckBody_Blue, "Neck", "Blue");
		buildPack(modResourceLoader.hareBody_Default, modResourceLoader.hareBody_Default, modResourceLoader.hareBody_Default, "Hare", "Default");
		buildPack(modResourceLoader.hareBody_Albino, modResourceLoader.hareBody_Albino, modResourceLoader.hareBody_Albino, "Hare", "Albino");
		buildPack(modResourceLoader.hareBody_Black, modResourceLoader.hareBody_Black, modResourceLoader.hareBody_Black, "Hare", "Black");
		buildPack(modResourceLoader.hareBody_DarkBlue, modResourceLoader.hareBody_DarkBlue, modResourceLoader.hareBody_DarkBlue, "Hare", "Blue");
		buildPack(modResourceLoader.hareBody_Ginger, modResourceLoader.hareBody_Ginger, modResourceLoader.hareBody_Ginger, "Hare", "Ginger");
		buildPack(modResourceLoader.drakeBody_Default, modResourceLoader.drakeBody_Default, modResourceLoader.drakeBody_Default, "Hatchling", "Default");
		buildPack(modResourceLoader.drakeBody_Red, modResourceLoader.drakeBody_Red, modResourceLoader.drakeBody_Red, "Hatchling", "Albino");
		buildPack(modResourceLoader.drakeBody_DarkBlue, modResourceLoader.drakeBody_DarkBlue, modResourceLoader.drakeBody_DarkBlue, "Hatchling", "Blue");
		buildPack(modResourceLoader.drakeBody_IceBlue, modResourceLoader.drakeBody_IceBlue, modResourceLoader.drakeBody_IceBlue, "Hatchling", "Ice");
		buildPack(modResourceLoader.drakeBody_Purple, modResourceLoader.drakeBody_Purple, modResourceLoader.drakeBody_Purple, "Hatchling", "Purple");
		buildPack(modResourceLoader.serpentBody_Default, modResourceLoader.serpentBody_Default, modResourceLoader.serpentBody_Default, "Serpent", "Default");
		buildPack(modResourceLoader.serpentBody_Albino, modResourceLoader.serpentBody_Albino, modResourceLoader.serpentBody_Albino, "Serpent", "Albino");
		buildPack(modResourceLoader.serpentBody_Black, modResourceLoader.serpentBody_Black, modResourceLoader.serpentBody_Black, "Serpent", "Black");
		buildPack(modResourceLoader.serpentBody_Blue, modResourceLoader.serpentBody_Blue, modResourceLoader.serpentBody_Blue, "Serpent", "Blue");
		buildPack(modResourceLoader.serpentBody_Green, modResourceLoader.serpentBody_Green, modResourceLoader.serpentBody_Green, "Serpent", "Green");
		buildPack(modResourceLoader.serpentBody_Red, modResourceLoader.serpentBody_Red, modResourceLoader.serpentBody_Red, "Serpent", "Red");
		buildPack(modResourceLoader.askvinBody_Default, modResourceLoader.askvinBody_Default, modResourceLoader.askvinBody_Default, "Asksvin", "Default");
		buildPack(modResourceLoader.askvinBody_Albino, modResourceLoader.askvinBody_Albino, modResourceLoader.askvinBody_Albino, "Asksvin", "Albino");
		buildPack(modResourceLoader.askvinBody_Black, modResourceLoader.askvinBody_Black, modResourceLoader.askvinBody_Black, "Asksvin", "Dark");
		buildPack(modResourceLoader.askvinBody_Purple, modResourceLoader.askvinBody_Purple, modResourceLoader.askvinBody_Purple, "Asksvin", "Purple");
		buildPack(modResourceLoader.askvinBody_Grey, modResourceLoader.askvinBody_Grey, modResourceLoader.askvinBody_Grey, "Asksvin", "Grey");
		buildPack(modResourceLoader.deerBody_Default, modResourceLoader.deerBody_Default, modResourceLoader.deerBody_Default, "Deer", "Default");
		buildPack(modResourceLoader.deerBody_Albino, modResourceLoader.deerBody_Albino, modResourceLoader.deerBody_Albino, "Deer", "Albino");
		buildPack(modResourceLoader.deerBody_Red, modResourceLoader.deerBody_Red, modResourceLoader.deerBody_Red, "Deer", "Red");
		buildPack(modResourceLoader.deerBody_DarkBrown, modResourceLoader.deerBody_DarkBrown, modResourceLoader.deerBody_DarkBrown, "Deer", "Brown");
		buildPack(modResourceLoader.deerBody_Grey, modResourceLoader.deerBody_Grey, modResourceLoader.deerBody_Grey, "Deer", "Grey");
		buildPack(modResourceLoader.boarBody_Default, modResourceLoader.boarBody_Default, modResourceLoader.boarBody_Default, "Boar", "Default");
		buildPack(modResourceLoader.boarBody_Grey, modResourceLoader.boarBody_Grey, modResourceLoader.boarBody_Grey, "Boar", "Grey");
		buildPack(modResourceLoader.boarBody_Black, modResourceLoader.boarBody_Black, modResourceLoader.boarBody_Black, "Boar", "Black");
		buildPack(modResourceLoader.boarBody_DarkBrown, modResourceLoader.boarBody_DarkBrown, modResourceLoader.boarBody_DarkBrown, "Boar", "Brown");
		buildPack(modResourceLoader.boarBody_LightBrown, modResourceLoader.boarBody_LightBrown, modResourceLoader.boarBody_LightBrown, "Wolf", "Brown2");
	}

	private void buildPack(Material face, Material body, Material body2, string name, string skin)
	{
		materialPacks.Add(new MaterialPack(face, body, body2, name, skin));
	}

	private bool setupFurRandomizerForMonster()
	{
		string name = ((Object)((Component)this).gameObject).name;
		name = editZnetName(name);
		List<MaterialPack> materials = materialPacks.FindAll((MaterialPack x) => x.animal == name);
		m_materials = materials;
		switch (name)
		{
		case "Lox":
		{
			Transform[] componentsInChildren4 = ((Component)this).gameObject.GetComponentsInChildren<Transform>(true);
			Transform[] array4 = componentsInChildren4;
			foreach (Transform val4 in array4)
			{
				if (((Object)((Component)val4).gameObject).name == "Body" && Object.op_Implicit((Object)(object)((Component)val4).gameObject.GetComponent<SkinnedMeshRenderer>()))
				{
					face = ((Component)val4).GetComponent<SkinnedMeshRenderer>();
					body = ((Component)val4).GetComponent<SkinnedMeshRenderer>();
				}
				if (((Object)((Component)val4).gameObject).name == "Furr1" && Object.op_Implicit((Object)(object)((Component)val4).gameObject.GetComponent<SkinnedMeshRenderer>()))
				{
					fur = ((Component)val4).GetComponent<SkinnedMeshRenderer>();
				}
			}
			break;
		}
		case "Hatchling":
		{
			Transform[] componentsInChildren2 = ((Component)this).gameObject.GetComponentsInChildren<Transform>(true);
			Transform[] array2 = componentsInChildren2;
			foreach (Transform val2 in array2)
			{
				if (((Object)((Component)val2).gameObject).name == "Hatchling" && Object.op_Implicit((Object)(object)((Component)val2).gameObject.GetComponent<SkinnedMeshRenderer>()))
				{
					body = ((Component)val2).GetComponent<SkinnedMeshRenderer>();
					face = ((Component)this).gameObject.GetComponentInChildren<SkinnedMeshRenderer>();
				}
				if (((Object)((Component)val2).gameObject).name == "Hatchling.001" && Object.op_Implicit((Object)(object)((Component)val2).gameObject.GetComponent<SkinnedMeshRenderer>()))
				{
					fur = ((Component)val2).GetComponent<SkinnedMeshRenderer>();
				}
			}
			break;
		}
		case "Neck":
		{
			Transform[] componentsInChildren3 = ((Component)this).gameObject.GetComponentsInChildren<Transform>(true);
			Transform[] array3 = componentsInChildren3;
			foreach (Transform val3 in array3)
			{
				if (((Object)((Component)val3).gameObject).name == "Body" && Object.op_Implicit((Object)(object)((Component)val3).GetComponent<SkinnedMeshRenderer>()))
				{
					face = ((Component)val3).GetComponent<SkinnedMeshRenderer>();
					body = ((Component)val3).GetComponent<SkinnedMeshRenderer>();
					fur = ((Component)val3).GetComponent<SkinnedMeshRenderer>();
				}
			}
			break;
		}
		case "Boar":
		{
			SkinnedMeshRenderer[] componentsInChildren = ((Component)this).gameObject.GetComponentsInChildren<SkinnedMeshRenderer>(true);
			SkinnedMeshRenderer[] array = componentsInChildren;
			foreach (SkinnedMeshRenderer val in array)
			{
				if (((Object)val).name == "Poly Art Boar")
				{
					face = val;
					body = val;
					fur = val;
				}
			}
			break;
		}
		case "Asksvin":
		case "Deer":
		case "Serpent":
		case "Wolf":
		case "Hare":
			face = ((Component)this).gameObject.GetComponentInChildren<SkinnedMeshRenderer>(true);
			body = ((Component)this).gameObject.GetComponentInChildren<SkinnedMeshRenderer>(true);
			fur = ((Component)this).gameObject.GetComponentInChildren<SkinnedMeshRenderer>(true);
			break;
		}
		if ((Object)(object)face == (Object)null || (Object)(object)body == (Object)null || (Object)(object)fur == (Object)null)
		{
			Debug.LogWarning((object)"Couldnt find renderers!");
			return false;
		}
		return true;
	}
}
public class LevelEffectGenerator
{
	private BaseLevelEffectSetupValue baseLevelEffectSetupValue = new BaseLevelEffectSetupValue();

	public void CreateVisuals(LevelEffects levelEffects)
	{
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		baseLevelEffectSetupValue.getSetup(levelEffects);
		int num = 0;
		if (levelEffects.m_levelSetups != null)
		{
			num = levelEffects.m_levelSetups.Count;
		}
		int num2 = 6 - num;
		for (int i = 0; i < num2; i++)
		{
			LevelSetup item = createSetup(baseLevelEffectSetupValue.scale, baseLevelEffectSetupValue.saturation, baseLevelEffectSetupValue.hue, baseLevelEffectSetupValue.value, baseLevelEffectSetupValue.setEmmisive, baseLevelEffectSetupValue.emissive, baseLevelEffectSetupValue.sumValue * (float)(i + 1), num2, i + 1);
			levelEffects.m_levelSetups.Add(item);
		}
	}

	public LevelEffects CreateLevelEffectAt(Transform visual, SkinnedMeshRenderer meshRenderer)
	{
		if ((Object)(object)meshRenderer == (Object)null)
		{
			Debug.LogWarning((object)("NO renderer to create Visual Effects:" + ((Object)visual.parent).name));
			return null;
		}
		if ((Object)(object)meshRenderer != (Object)null)
		{
			LevelEffects val = ((Component)visual).gameObject.AddComponent<LevelEffects>();
			val.m_mainRender = (Renderer)(object)meshRenderer;
			val.m_character = (Character)(object)((Component)visual.parent).gameObject.GetComponent<Humanoid>();
			return val;
		}
		return null;
	}

	public LevelEffects CreateLevelEffectComponent(Transform visual)
	{
		SkinnedMeshRenderer[] componentsInChildren = ((Component)visual).GetComponentsInChildren<SkinnedMeshRenderer>();
		if (componentsInChildren.Length > 1)
		{
			Debug.LogWarning((object)("To many renderers to create Visual Effects:" + ((Object)visual.parent).name));
			return null;
		}
		if (componentsInChildren.Length == 1)
		{
			LevelEffects val = ((Component)visual).gameObject.AddComponent<LevelEffects>();
			val.m_mainRender = (Renderer)(object)componentsInChildren[0];
			val.m_character = (Character)(object)((Component)visual.parent).gameObject.GetComponent<Humanoid>();
			return val;
		}
		return null;
	}

	private LevelSetup createSetup(float scale, float saturation, float hue, float value, bool isEmmisive, Color emission, float changeValue, int maxAmount, int lvl)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		LevelSetup val = new LevelSetup();
		val.m_scale = scale + changeValue;
		val.m_saturation = saturation + changeValue;
		val.m_hue = hue + changeValue;
		val.m_value = value + changeValue;
		val.m_enableObject = pickEnabledObject(maxAmount, lvl);
		val.m_setEmissiveColor = isEmmisive;
		val.m_emissiveColor = new Color(emission.r + changeValue, emission.g + changeValue, emission.b + changeValue, emission.a);
		return val;
	}

	private GameObject pickEnabledObject(int maxAmount, int lvl)
	{
		if (maxAmount == 6)
		{
			if (lvl > 4)
			{
				return baseLevelEffectSetupValue.enabledObjectLevel3;
			}
			if (lvl > 2)
			{
				return baseLevelEffectSetupValue.enabledObjectLevel2;
			}
		}
		if (maxAmount == 3)
		{
			if (lvl > 3)
			{
				return baseLevelEffectSetupValue.enabledObjectLevel3;
			}
			if (lvl > 2)
			{
				return baseLevelEffectSetupValue.enabledObjectLevel2;
			}
		}
		if (maxAmount < 3)
		{
			switch (lvl)
			{
			case 2:
				return baseLevelEffectSetupValue.enabledObjectLevel3;
			case 1:
				return baseLevelEffectSetupValue.enabledObjectLevel2;
			}
		}
		return baseLevelEffectSetupValue.enabledObject;
	}
}
[Serializable]
public class MaterialPack
{
	public Material face;

	public Material body;

	public Material body2;

	public string animal;

	public string skin;

	public MaterialPack(Material body, Material body2, Material face, string monsterName, string skinName)
	{
		animal = monsterName;
		this.face = face;
		this.body = body;
		this.body2 = body2;
		skin = skinName;
	}
}
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)("BalrondFurRandomizer:  " + ((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)("BalrondFurRandomizer:  " + ((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)("BalrondFurRandomizer:  " + ((Object)newPrefab).name + " - ItemDrop not found on prefab"));
		}
	}
}
[BepInPlugin("balrond.astafaraios.BalrondFurRandomizer", "BalrondFurRandomizer", "1.0.6")]
public class Launch : BaseUnityPlugin
{
	[HarmonyPatch(typeof(Game), "Awake")]
	public static class Game_Awake_Path
	{
		public static void Prefix()
		{
			ZNetScene_Awake_Path.hasSpawned = false;
		}
	}

	[HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")]
	public static class Object_CopyOtherDB_Path
	{
		public static void Postfix()
		{
			if (IsObjectDBValid())
			{
			}
		}
	}

	[HarmonyPatch(typeof(ObjectDB), "Awake")]
	public static class ObjectDB_Awake_Path
	{
		public static void Postfix()
		{
			if (IsObjectDBValid())
			{
			}
		}
	}

	[HarmonyPatch(typeof(Character), "OnDeath")]
	public static class Character_OnDeath_Path
	{
		public static bool hasSpawned;

		public static void Prefix(Character __instance)
		{
			if ((Object)(object)__instance != (Object)null)
			{
				EffectData[] effectPrefabs = __instance.m_deathEffects.m_effectPrefabs;
				foreach (EffectData val in effectPrefabs)
				{
					Ragdoll component = val.m_prefab.GetComponent<Ragdoll>();
					if ((Object)(object)component != (Object)null)
					{
						LevelEffects componentInChildren = ((Component)__instance).GetComponentInChildren<LevelEffects>();
						if ((Object)(object)componentInChildren != (Object)null && (Object)(object)componentInChildren.m_mainRender != (Object)null && componentInChildren.m_mainRender.sharedMaterials.Length != 0 && (Object)(object)component.m_mainModel != (Object)null)
						{
							component.m_mainModel.sharedMaterials = componentInChildren.m_mainRender.sharedMaterials;
						}
					}
				}
			}
			else
			{
				Debug.LogWarning((object)"Instance dont yet exists");
			}
		}
	}

	[HarmonyPatch(typeof(LevelEffects), "SetupLevelVisualization")]
	public static class LevelEffects_Awake_Path
	{
		public static bool hasSpawned;

		public static bool Prefix(LevelEffects __instance, int level)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			if (level <= 1 || __instance.m_levelSetups.Count < level - 1)
			{
				return false;
			}
			LevelSetup val = __instance.m_levelSetups[level - 2];
			((Component)__instance).transform.localScale = new Vector3(val.m_scale, val.m_scale, val.m_scale);
			if (Object.op_Implicit((Object)(object)__instance.m_mainRender))
			{
				Material[] sharedMaterials = __instance.m_mainRender.sharedMaterials;
				sharedMaterials[0] = new Material(sharedMaterials[0]);
				sharedMaterials[0].SetFloat("_Hue", val.m_hue);
				sharedMaterials[0].SetFloat("_Saturation", val.m_saturation);
				sharedMaterials[0].SetFloat("_Value", val.m_value);
				if (val.m_setEmissiveColor)
				{
					sharedMaterials[0].SetColor("_EmissionColor", val.m_emissiveColor);
				}
				__instance.m_mainRender.sharedMaterials = sharedMaterials;
				string key = Utils.GetPrefabName(((Component)__instance.m_character).gameObject) + level;
				LevelEffects.m_materials[key] = sharedMaterials[0];
			}
			if (Object.op_Implicit((Object)(object)__instance.m_baseEnableObject))
			{
				__instance.m_baseEnableObject.SetActive(false);
			}
			if (!Object.op_Implicit((Object)(object)val.m_enableObject))
			{
				return false;
			}
			val.m_enableObject.SetActive(true);
			return false;
		}
	}

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

		public static void Prefix(ZNetScene __instance)
		{
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)null)
			{
				Debug.LogWarning((object)"BalrondFurRandomizer: No ZnetScene found");
			}
			else if (!hasSpawned)
			{
				itemSetBuilder.createMaterialPacks(modResourceLoader);
				GameObject monster = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "Wolf");
				GameObject monster2 = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "Neck");
				GameObject monster3 = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "Hare");
				GameObject monster4 = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "Serpent");
				GameObject monster5 = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "Hatchling");
				GameObject monster6 = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "Lox");
				GameObject monster7 = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "Deer");
				GameObject monster8 = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "Boar");
				GameObject monster9 = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "Asksvin");
				itemSetBuilder.setupFurRandomizerForMonster(monster);
				itemSetBuilder.setupFurRandomizerForMonster(monster2);
				itemSetBuilder.setupFurRandomizerForMonster(monster3);
				itemSetBuilder.setupFurRandomizerForMonster(monster4);
				itemSetBuilder.setupFurRandomizerForMonster(monster5);
				itemSetBuilder.setupFurRandomizerForMonster(monster6);
				itemSetBuilder.setupFurRandomizerForMonster(monster7);
				itemSetBuilder.setupFurRandomizerForMonster(monster8);
				itemSetBuilder.setupFurRandomizerForMonster(monster9);
				if (!new ZNet().IsDedicated())
				{
					ShaderReplacment.runMaterialFix();
					hasSpawned = true;
				}
			}
		}
	}

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

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

	public const string PluginName = "BalrondFurRandomizer";

	public const string PluginVersion = "1.0.6";

	public static ModResourceLoader modResourceLoader = new ModResourceLoader();

	public static DatabaseAddMethods databaseAddMethods = new DatabaseAddMethods();

	public static MonsterManager monsterSpiritResistanceManager = new MonsterManager();

	public static ItemSetBuilder itemSetBuilder = new ItemSetBuilder();

	public static GameObject gui;

	public static GameObject gui2;

	public static GameObject RootObject;

	public static GameObject PrefabContainer;

	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 addStatusToAttackField(GameObject gameObject, StatusEffect statusEffect)
	{
		ItemDrop component = gameObject.GetComponent<ItemDrop>();
		component.m_itemData.m_shared.m_attackStatusEffect = statusEffect;
	}
}
public class ModResourceLoader
{
	public AssetBundle assetBundle;

	public Material loxFace_Default;

	public Material loxtBody_Default;

	public Material loxFur_Default;

	public Material loxFace_Albino;

	public Material loxtBody_Albino;

	public Material loxFur_Albino;

	public Material loxFace_Black;

	public Material loxtBody_Black;

	public Material loxFur_Black;

	public Material loxFace_Blond;

	public Material loxtBody_Blond;

	public Material loxFur_Blond;

	public Material loxFace_DarkBrown;

	public Material loxtBody_DarkBrown;

	public Material loxFur_DarkBrown;

	public Material loxFace_Ginger;

	public Material loxtBody_Ginger;

	public Material loxFur_Ginger;

	public Material wolfBody_Default;

	public Material wolfBody_Albino;

	public Material wolfBody_Black;

	public Material wolfBody_DarkBrown;

	public Material wolfBody_Grey;

	public Material boarBody_Default;

	public Material boarBody_Grey;

	public Material boarBody_Black;

	public Material boarBody_DarkBrown;

	public Material boarBody_LightBrown;

	public Material askvinBody_Default;

	public Material askvinBody_Albino;

	public Material askvinBody_Purple;

	public Material askvinBody_Black;

	public Material askvinBody_Grey;

	public Material deerBody_Default;

	public Material deerBody_Albino;

	public Material deerBody_Red;

	public Material deerBody_DarkBrown;

	public Material deerBody_Grey;

	public Material neckBody_Default;

	public Material neckBody_Albino;

	public Material neckBody_Blue;

	public Material neckBody_DarkBlue;

	public Material neckBody_DarkGreen;

	public Material hareBody_Default;

	public Material hareBody_Albino;

	public Material hareBody_Black;

	public Material hareBody_DarkBlue;

	public Material hareBody_Ginger;

	public Material drakeBody_Default;

	public Material drakeBody_DarkBlue;

	public Material drakeBody_IceBlue;

	public Material drakeBody_Purple;

	public Material drakeBody_Red;

	public Material serpentBody_Default;

	public Material serpentBody_Albino;

	public Material serpentBody_Black;

	public Material serpentBody_Blue;

	public Material serpentBody_Green;

	public Material serpentBody_Red;

	public void loadAssets()
	{
		assetBundle = GetAssetBundleFromResources("furrandomizer");
		string text = "Assets/BalrondFurRandomizer/";
		Material temp = assetBundle.LoadAsset<Material>(text + "Lox/Default/lox_face.mat");
		CreateLoxMaterial(temp, text);
		CreateWolfMaterial(temp, text);
		CreateNeckMaterial(temp, text);
		CreateHareMaterial(temp, text);
		CreateDrakeMaterial(temp, text);
		CreateSerpentMaterials(temp, text);
		CreateAskvinMaterial(temp, text);
		CreateBoarMaterial(temp, text);
		CreateDeerMaterial(temp, text);
	}

	private void CreateLoxMaterial(Material temp, string mainPath)
	{
		ShaderReplacment.ReplaceMaterial(temp);
		loxFace_Default = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Lox/Default/lox_body1.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		loxtBody_Default = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Lox/Default/lox_fur1.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		loxFur_Default = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Lox/Albino/lox_face.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		loxFace_Albino = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Lox/Albino/lox_body1.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		loxtBody_Albino = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Lox/Albino/lox_fur1.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		loxFur_Albino = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Lox/Black/lox_face.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		loxFace_Black = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Lox/Black/lox_body1.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		loxtBody_Black = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Lox/Black/lox_fur1.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		loxFur_Black = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Lox/Blonde/lox_face.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		loxFace_Blond = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Lox/Blonde/lox_body1.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		loxtBody_Blond = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Lox/Blonde/lox_fur1.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		loxFur_Blond = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Lox/DarkBrown/lox_face.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		loxFace_DarkBrown = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Lox/DarkBrown/lox_body1.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		loxtBody_DarkBrown = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Lox/DarkBrown/lox_fur1.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		loxFur_DarkBrown = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Lox/Ginger/lox_face.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		loxFace_Ginger = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Lox/Ginger/lox_body1.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		loxtBody_Ginger = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Lox/Ginger/lox_fur1.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		loxFur_Ginger = temp;
	}

	private void CreateWolfMaterial(Material temp, string mainPath)
	{
		temp = assetBundle.LoadAsset<Material>(mainPath + "Wolf/Default/wolfMat.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		wolfBody_Default = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Wolf/Albino/wolfMat.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		wolfBody_Albino = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Wolf/Black/wolfMat.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		wolfBody_Black = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Wolf/DarkBrown/wolfMat.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		wolfBody_DarkBrown = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Wolf/Grey/wolfMat.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		wolfBody_Grey = temp;
	}

	private void CreateBoarMaterial(Material temp, string mainPath)
	{
		temp = assetBundle.LoadAsset<Material>(mainPath + "Boar/Default/Material_default.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		boarBody_Default = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Boar/Grey/Material_grey.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		boarBody_Grey = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Boar/Black/Material_black.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		boarBody_Black = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Boar/DarkBrown/Material_darkBrown.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		boarBody_DarkBrown = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Boar/Young/Material_young.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		boarBody_LightBrown = temp;
	}

	private void CreateDeerMaterial(Material temp, string mainPath)
	{
		temp = assetBundle.LoadAsset<Material>(mainPath + "Deer/Default/Deer_default.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		deerBody_Default = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Deer/Albino/Deer_albino.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		deerBody_Albino = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Deer/Red/Deer_red.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		deerBody_Red = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Deer/LightBrown/Deer_brown.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		deerBody_DarkBrown = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Deer/Grey/Deer_gray.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		deerBody_Grey = temp;
	}

	private void CreateAskvinMaterial(Material temp, string mainPath)
	{
		temp = assetBundle.LoadAsset<Material>(mainPath + "Askvin/Default/asksvin_Mat_default.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		askvinBody_Default = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Askvin/Albino/asksvin_Mat_albino.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		askvinBody_Albino = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Askvin/Purple/asksvin_Mat_purple.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		askvinBody_Purple = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Askvin/Black/asksvin_Mat_black.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		askvinBody_Black = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Askvin/Young/asksvincub_Mat_young.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		askvinBody_Grey = temp;
	}

	private void CreateNeckMaterial(Material temp, string mainPath)
	{
		temp = assetBundle.LoadAsset<Material>(mainPath + "Neck/Default/neck1.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		neckBody_Default = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Neck/Albino/neck1.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		neckBody_Albino = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Neck/Blue/neck1.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		neckBody_Blue = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Neck/DarkBlue/neck1.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		neckBody_DarkBlue = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Neck/DarkGreen/neck1.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		neckBody_DarkGreen = temp;
	}

	private void CreateHareMaterial(Material temp, string mainPath)
	{
		temp = assetBundle.LoadAsset<Material>(mainPath + "Hare/Default/Hare_mat1.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		hareBody_Default = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Hare/Albino/Hare_mat1.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		hareBody_Albino = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Hare/Black/Hare_mat1.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		hareBody_Black = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Hare/DarkBlue/Hare_mat1.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		hareBody_DarkBlue = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Hare/Ginger/Hare_mat1.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		hareBody_Ginger = temp;
	}

	private void CreateDrakeMaterial(Material temp, string mainPath)
	{
		temp = assetBundle.LoadAsset<Material>(mainPath + "Drake/Default/Hatchling_mountain_mat1.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		drakeBody_Default = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Drake/DarkBlue/Hatchling_mountain_mat1.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		drakeBody_DarkBlue = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Drake/IceBlue/Hatchling_mountain_mat1.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		drakeBody_IceBlue = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Drake/Purple/Hatchling_mountain_mat1.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		drakeBody_Purple = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Drake/Red/Hatchling_mountain_mat1.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		drakeBody_Red = temp;
	}

	private void CreateSerpentMaterials(Material temp, string mainPath)
	{
		temp = assetBundle.LoadAsset<Material>(mainPath + "Serpent/Default/SeaSerpent_mat1.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		serpentBody_Default = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Serpent/Albino/SeaSerpent_mat1.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		serpentBody_Albino = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Serpent/Black/SeaSerpent_mat1.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		serpentBody_Black = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Serpent/Blue/SeaSerpent_mat1.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		serpentBody_Blue = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Serpent/Green/SeaSerpent_mat1.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		serpentBody_Green = temp;
		temp = assetBundle.LoadAsset<Material>(mainPath + "Serpent/Red/SeaSerpent_mat1.mat");
		ShaderReplacment.ReplaceMaterial(temp);
		serpentBody_Red = temp;
	}

	private AssetBundle GetAssetBundleFromResources(string filename)
	{
		Assembly executingAssembly = Assembly.GetExecutingAssembly();
		string name = executingAssembly.GetManifestResourceNames().Single((string str) => str.EndsWith(filename));
		using Stream stream = executingAssembly.GetManifestResourceStream(name);
		return AssetBundle.LoadFromStream(stream);
	}
}
public class MonsterManager
{
	private GameObject levelEffects = null;

	private GameObject stealEffect = null;

	private LevelEffectGenerator levelEffectGenerator = new LevelEffectGenerator();

	private List<GameObject> monsters;

	private string[] names = new string[0];

	private string[] thiefName = new string[14]
	{
		"Greyling", "Greydwarf", "Greydwarf_Elite", "Draugr", "Draugr_Elite", "Draugr_Ranged", "Skeleton", "Skeleton_NoArcher", "Skeleton_Poison", "Forsaken",
		"GoblinBrute", "GoblinArcher", "Goblin", "GoblinShaman"
	};

	public void SetVfx(GameObject levelEffects, GameObject stealEffect)
	{
		this.levelEffects = levelEffects;
		this.stealEffect = stealEffect;
	}

	public void setupMonsterList(List<GameObject> list)
	{
		if (list == null)
		{
			Debug.LogWarning((object)"I DID NOT FOUND PREFAB LIST!");
			return;
		}
		monsters = list.FindAll((GameObject x) => (Object)(object)x.GetComponent<MonsterAI>() != (Object)null);
	}

	public void changeMonsterResistance()
	{
		if (monsters == null)
		{
			Debug.LogWarning((object)"I DID NOT FOUND ANY MONSTERS!");
			return;
		}
		foreach (GameObject monster in monsters)
		{
			Humanoid component = monster.GetComponent<Humanoid>();
			SetupLevelVisual(monster);
			if ((Object)(object)component != (Object)null)
			{
				changeResistanceForException(component);
			}
		}
	}

	private void SetupLevelVisual(GameObject gameObject)
	{
		Transform visual = gameObject.transform.Find("Visual");
		LevelEffects val = gameObject.GetComponentInChildren<LevelEffects>();
		bool flag = true;
		string[] source = new string[15]
		{
			"Lox", "Wraith", "TentaRoot", "TheHive", "Hatchling", "GoblinKing", "Eikthyr", "Bonemass", "Frog", "Haugbui",
			"Greydwarf_Mystic", "Varsvin", "Varsvin_Brute", "Varsvin_Hunter", "SeekerQueen"
		};
		if (((Object)gameObject).name == "TheHive" || ((Object)gameObject).name == "Haugbui" || ((Object)gameObject).name == "Greydwarf_Mystic")
		{
			return;
		}
		if (source.Contains(((Object)gameObject).name))
		{
			Transform val2 = null;
			switch (((Object)gameObject).name)
			{
			case "Lox":
				val2 = gameObject.transform.Find("Visual/offset/Body");
				break;
			case "Wraith":
				val2 = gameObject.transform.Find("Visual/wraith/wraith");
				break;
			case "TentaRoot":
				val2 = gameObject.transform.Find("Visual/Tentaroots/Cube.001");
				break;
			case "Hatchling":
				val2 = gameObject.transform.Find("Visual/Hatchling_mountain/Hatchling");
				break;
			case "GoblinKing":
				val2 = gameObject.transform.Find("Visual/Yagluth");
				break;
			case "Eikthyr":
				val2 = gameObject.transform.Find("Visual/Deer");
				break;
			case "Bonemass":
				val2 = gameObject.transform.Find("Visual/model/bonemass");
				break;
			case "Varsvin":
			case "Varsvin_Brute":
			case "Varsvin_Hunter":
				val2 = gameObject.transform.Find("Visual/Body");
				break;
			case "Frog":
				val2 = gameObject.transform.Find("Visual/Frog2_mesh");
				break;
			case "Haugbui":
				val2 = gameObject.transform.Find("Visual/Frog2_mesh");
				break;
			case "Greydwarf_Mystic":
				val2 = gameObject.transform.Find("Visual/Frog2_mesh");
				break;
			case "SeekerQueen":
				val2 = gameObject.transform.Find("Visual/Cube");
				break;
			}
			if ((Object)(object)val2 == (Object)null)
			{
				return;
			}
			val = levelEffectGenerator.CreateLevelEffectAt(visual, ((Component)val2).GetComponent<SkinnedMeshRenderer>());
		}
		else if (flag && (Object)(object)val == (Object)null)
		{
			val = levelEffectGenerator.CreateLevelEffectComponent(visual);
		}
		if ((Object)(object)val != (Object)null)
		{
			levelEffectGenerator.CreateVisuals(val);
		}
	}

	private void changeSpiritResistance(Humanoid humanoid)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Expected I4, but got Unknown
		//IL_0037: 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)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		Faction faction = ((Character)humanoid).m_faction;
		Faction val = faction;
		switch (val - 1)
		{
		case 0:
			((Character)humanoid).m_damageModifiers.m_spirit = (DamageModifier)0;
			break;
		case 1:
			((Character)humanoid).m_damageModifiers.m_spirit = (DamageModifier)1;
			break;
		case 5:
			((Character)humanoid).m_damageModifiers.m_spirit = (DamageModifier)5;
			break;
		case 2:
			((Character)humanoid).m_damageModifiers.m_spirit = (DamageModifier)6;
			break;
		case 3:
			((Character)humanoid).m_damageModifiers.m_spirit = (DamageModifier)2;
			break;
		case 6:
			((Character)humanoid).m_damageModifiers.m_spirit = (DamageModifier)0;
			break;
		case 4:
			((Character)humanoid).m_damageModifiers.m_spirit = (DamageModifier)5;
			break;
		}
	}

	private void changeResistanceForException(Humanoid humanoid)
	{
		changeSpiritResistance(humanoid);
	}
}