Decompiled source of KEKSPACK Mistlands v2.2.8

plugins/MonsterMobs.dll

Decompiled a year 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.Permissions;
using BepInEx;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("MonsterMobs")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MonsterMobs")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("1.1.10.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.10.0")]
namespace MonsterMobs;

[BepInPlugin("thedefside.MonsterMobs", "MonsterMobs", "1.1.10")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency("MonsterLabZ", "2.4.1")]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
internal class MonsterMobs : BaseUnityPlugin
{
	public const string PluginGUID = "thedefside.MonsterMobs";

	public const string PluginName = "MonsterMobs";

	public const string PluginVersion = "1.1.10";

	public static bool Debug = false;

	private AssetBundle bundle;

	public static CustomLocalization Localization = LocalizationManager.Instance.GetLocalization();

	private void Awake()
	{
		bundle = AssetUtils.LoadAssetBundleFromResources("mmbundle", typeof(MonsterMobs).Assembly);
		PrefabManager.OnVanillaPrefabsAvailable += AddClonedItems;
	}

	private void AddClonedItems()
	{
		//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a6: Expected O, but got Unknown
		//IL_045d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0462: Unknown result type (might be due to invalid IL or missing references)
		//IL_046a: Expected O, but got Unknown
		//IL_046c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0471: Unknown result type (might be due to invalid IL or missing references)
		//IL_0487: Expected O, but got Unknown
		//IL_0489: Unknown result type (might be due to invalid IL or missing references)
		//IL_048e: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a4: Expected O, but got Unknown
		//IL_0509: Unknown result type (might be due to invalid IL or missing references)
		//IL_0510: Expected O, but got Unknown
		//IL_05cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_05dd: Expected O, but got Unknown
		//IL_05df: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_05fa: Expected O, but got Unknown
		//IL_05fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0601: Unknown result type (might be due to invalid IL or missing references)
		//IL_0617: Expected O, but got Unknown
		//IL_066c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0673: Expected O, but got Unknown
		//IL_06ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_06d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_06dc: Expected O, but got Unknown
		//IL_06de: Unknown result type (might be due to invalid IL or missing references)
		//IL_06e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_06f9: Expected O, but got Unknown
		//IL_06fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0700: Unknown result type (might be due to invalid IL or missing references)
		//IL_0716: Expected O, but got Unknown
		//IL_0740: Unknown result type (might be due to invalid IL or missing references)
		//IL_0745: Unknown result type (might be due to invalid IL or missing references)
		//IL_0752: Unknown result type (might be due to invalid IL or missing references)
		//IL_075c: Expected O, but got Unknown
		//IL_0789: Unknown result type (might be due to invalid IL or missing references)
		//IL_07d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_07d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_07df: Expected O, but got Unknown
		//IL_07e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_07e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_07ef: Expected O, but got Unknown
		//IL_080b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0812: Expected O, but got Unknown
		//IL_083e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0845: Expected O, but got Unknown
		//IL_0885: Unknown result type (might be due to invalid IL or missing references)
		//IL_088c: Expected O, but got Unknown
		//IL_08b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_08bf: Expected O, but got Unknown
		//IL_08e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_08e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0921: Unknown result type (might be due to invalid IL or missing references)
		//IL_0928: Expected O, but got Unknown
		//IL_0956: Unknown result type (might be due to invalid IL or missing references)
		//IL_095b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0962: Unknown result type (might be due to invalid IL or missing references)
		//IL_096d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0975: Expected O, but got Unknown
		//IL_0985: Unknown result type (might be due to invalid IL or missing references)
		//IL_098c: Expected O, but got Unknown
		//IL_0a38: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a3f: Expected O, but got Unknown
		//IL_0a6b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a72: Expected O, but got Unknown
		//IL_0aa6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0aab: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ae2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ae7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0af4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0afe: Expected O, but got Unknown
		//IL_0b24: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b29: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b36: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b40: Expected O, but got Unknown
		//IL_0b5b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b60: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b6b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b7b: Expected O, but got Unknown
		//IL_0b76: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b80: Expected O, but got Unknown
		//IL_0b92: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b99: Expected O, but got Unknown
		//IL_0bdf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0be4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0beb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bf6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bfe: Expected O, but got Unknown
		//IL_0c05: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c0c: Expected O, but got Unknown
		//IL_0c33: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c3a: Expected O, but got Unknown
		//IL_0c60: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c65: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c6c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c77: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c7f: Expected O, but got Unknown
		//IL_0c81: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c86: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c8d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c99: Expected O, but got Unknown
		//IL_0c9b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ca0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ca7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cb2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cba: Expected O, but got Unknown
		//IL_0cc1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ccb: Expected O, but got Unknown
		//IL_0ce6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ced: Expected O, but got Unknown
		//IL_0d13: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d18: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d1f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d2a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d32: Expected O, but got Unknown
		//IL_0d34: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d39: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d40: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d4c: Expected O, but got Unknown
		//IL_0d4e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d53: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d5a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d65: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d6d: Expected O, but got Unknown
		//IL_0d74: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d7e: Expected O, but got Unknown
		//IL_0d96: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d9d: Expected O, but got Unknown
		//IL_0dd1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0dd8: Expected O, but got Unknown
		//IL_0e08: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e0d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e36: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e3d: Expected O, but got Unknown
		//IL_0e71: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e78: Expected O, but got Unknown
		//IL_0ea8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ead: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ed6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0edd: Expected O, but got Unknown
		//IL_0f09: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f10: Expected O, but got Unknown
		//IL_0f40: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f45: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f6e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f75: Expected O, but got Unknown
		//IL_0fa1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fa8: Expected O, but got Unknown
		//IL_0fd8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fdd: Unknown result type (might be due to invalid IL or missing references)
		//IL_1006: Unknown result type (might be due to invalid IL or missing references)
		//IL_100d: Expected O, but got Unknown
		//IL_1039: Unknown result type (might be due to invalid IL or missing references)
		//IL_1040: Expected O, but got Unknown
		//IL_1070: Unknown result type (might be due to invalid IL or missing references)
		//IL_1075: Unknown result type (might be due to invalid IL or missing references)
		//IL_109e: Unknown result type (might be due to invalid IL or missing references)
		//IL_10a5: Expected O, but got Unknown
		//IL_10d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_10d8: Expected O, but got Unknown
		//IL_1108: Unknown result type (might be due to invalid IL or missing references)
		//IL_110d: Unknown result type (might be due to invalid IL or missing references)
		//IL_1136: Unknown result type (might be due to invalid IL or missing references)
		//IL_113d: Expected O, but got Unknown
		//IL_1169: Unknown result type (might be due to invalid IL or missing references)
		//IL_1170: Expected O, but got Unknown
		//IL_11a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_11a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_11dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_11e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_11ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_11f8: Expected O, but got Unknown
		//IL_121e: Unknown result type (might be due to invalid IL or missing references)
		//IL_1223: Unknown result type (might be due to invalid IL or missing references)
		//IL_1230: Unknown result type (might be due to invalid IL or missing references)
		//IL_123a: Expected O, but got Unknown
		//IL_1252: Unknown result type (might be due to invalid IL or missing references)
		//IL_1259: Expected O, but got Unknown
		//IL_1285: Unknown result type (might be due to invalid IL or missing references)
		//IL_128c: Expected O, but got Unknown
		//IL_12c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_12e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_12ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_09c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_09cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_09db: Unknown result type (might be due to invalid IL or missing references)
		//IL_09ea: Expected O, but got Unknown
		//IL_139a: Unknown result type (might be due to invalid IL or missing references)
		//IL_139f: Unknown result type (might be due to invalid IL or missing references)
		//IL_132d: Unknown result type (might be due to invalid IL or missing references)
		//IL_1332: Unknown result type (might be due to invalid IL or missing references)
		//IL_1333: Unknown result type (might be due to invalid IL or missing references)
		//IL_1342: Expected O, but got Unknown
		Cache.GetPrefab<GameObject>("TentaRoot").AddComponent<CharacterDrop>();
		foreach (Clone item in new List<Clone>
		{
			new Clone("Deathsquito", "AshMosquito", "AshMosquito"),
			new Clone("Fenring", "DevourerFenring", "DevourerFenring"),
			new Clone("Fenring_ragdoll", "DevourerFenring_ragdoll", "DevourerFenring"),
			new Clone("Troll", "Jotunn_mm", "Jotunn"),
			new Clone("Troll_ragdoll", "Jotunn_ragdoll_mm", "Jotunn"),
			new Clone("Fenring", "PolarFenring", "PolarFenring"),
			new Clone("Fenring_ragdoll", "PolarFenring_ragdoll", "PolarFenring"),
			new Clone("Lox", "PolarLox", "PolarLox"),
			new Clone("lox_ragdoll", "PolarLox_ragdoll", "PolarLox"),
			new Clone("Fenring", "StormFenring", "StormFenring"),
			new Clone("Fenring_ragdoll", "StormFenring_ragdoll", "StormFenring"),
			new Clone("Wolf", "StormWolf", "StormWolf"),
			new Clone("Wolf_Ragdoll", "StormWolf_ragdoll", "StormWolf"),
			new Clone("Draugr", "SwollenBody", "SwollenBody"),
			new Clone("Draugr_ragdoll", "SwollenBody_ragdoll", "SwollenBody"),
			new Clone("NormalSkeletonWarrior", "BurnedBones", "BurnedBones"),
			new Clone("TreeSpider", "DarkSpider", "DarkSpider"),
			new Clone("TreeSpider_ragdoll", "DarkSpider_ragdoll", "DarkSpider"),
			new Clone("TreeSpider", "MotherDarkSpider", "MotherDarkSpider"),
			new Clone("Wolf", "ArcticWolf", "ArcticWolf"),
			new Clone("Wolf_Ragdoll", "ArcticWolf_ragdoll", "ArcticWolf"),
			new Clone("TentaRoot", "Froot", "Froot")
		})
		{
			try
			{
				Logger.LogDebug((object)("Creating new Prefab: " + item.NewPrefab + " from " + item.BasePrefab));
				GameObject val = PrefabManager.Instance.CreateClonedPrefab(item.NewPrefab, item.BasePrefab);
				Logger.LogDebug((object)("Setting texture: " + item.Texture + ".png"));
				Texture2D texture = LoadEmbeddedTexture(item.Texture);
				val.ChangeTexture(texture);
				Logger.LogDebug((object)("Add Prefab: " + item.NewPrefab));
				PrefabManager.Instance.AddPrefab(val);
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Adding prefab failed for " + item.NewPrefab));
				Logger.LogError((object)ex.Message);
				Logger.LogError((object)ex.StackTrace);
			}
		}
		GameObject val2 = bundle.LoadAsset<GameObject>("AshHatchling");
		PrefabManager.Instance.AddPrefab(val2);
		GameObject val3 = PrefabManager.Instance.CreateClonedPrefab("AshHatchling_ragdoll", "Hatchling_ragdoll");
		Transform val4 = val3.transform.Find("Hatchling_mountain");
		SkinnedMeshRenderer component = ((Component)((Component)val4).transform.Find("eyes")).GetComponent<SkinnedMeshRenderer>();
		Material val5 = new Material(((Renderer)component).material);
		val5.SetTexture("_MainTex", (Texture)(object)LoadEmbeddedTexture("AshHatchling"));
		val5.SetTexture("_BumpMap", (Texture)(object)LoadEmbeddedTexture("Hatchling_n"));
		val5.SetTexture("_EmissionMap", (Texture)(object)LoadEmbeddedTexture("Hatchling_E"));
		((Renderer)component).material = val5;
		((Renderer)((Component)((Component)val4).transform.Find("Hatchling")).GetComponent<SkinnedMeshRenderer>()).material = val5;
		((Renderer)((Component)((Component)val4).transform.Find("Hatchling.001")).GetComponent<SkinnedMeshRenderer>()).material = val5;
		((Renderer)((Component)((Component)val4).transform.Find("Horns")).GetComponent<SkinnedMeshRenderer>()).material = val5;
		PrefabManager.Instance.AddPrefab(val3);
		((Character)val2.GetComponent<Humanoid>()).m_deathEffects.m_effectPrefabs = (EffectData[])(object)new EffectData[3]
		{
			new EffectData
			{
				m_prefab = val3
			},
			new EffectData
			{
				m_prefab = PrefabManager.Instance.GetPrefab("vfx_hatchling_death")
			},
			new EffectData
			{
				m_prefab = PrefabManager.Instance.GetPrefab("sfx_hatchling_death")
			}
		};
		GameObject val6 = bundle.LoadAsset<GameObject>("StormHatchling");
		PrefabManager.Instance.AddPrefab(val6);
		GameObject val7 = PrefabManager.Instance.CreateClonedPrefab("StormHatchling_ragdoll", "Hatchling_ragdoll");
		Transform obj = val7.transform.Find("Hatchling_mountain");
		SkinnedMeshRenderer component2 = ((Component)((Component)val4).transform.Find("eyes")).GetComponent<SkinnedMeshRenderer>();
		Material val8 = new Material(((Renderer)component2).material);
		val8.SetTexture("_MainTex", (Texture)(object)LoadEmbeddedTexture("StormHatchling"));
		val8.SetTexture("_BumpMap", (Texture)(object)LoadEmbeddedTexture("Hatchling_n"));
		val8.SetTexture("_Emission", (Texture)(object)LoadEmbeddedTexture("Hatchling_E"));
		((Renderer)component2).material = val8;
		((Renderer)((Component)((Component)obj).transform.Find("Hatchling")).GetComponent<SkinnedMeshRenderer>()).material = val8;
		((Renderer)((Component)((Component)obj).transform.Find("Hatchling.001")).GetComponent<SkinnedMeshRenderer>()).material = val8;
		((Renderer)((Component)((Component)obj).transform.Find("Horns")).GetComponent<SkinnedMeshRenderer>()).material = val8;
		PrefabManager.Instance.AddPrefab(val7);
		((Character)val6.GetComponent<Humanoid>()).m_deathEffects.m_effectPrefabs = (EffectData[])(object)new EffectData[3]
		{
			new EffectData
			{
				m_prefab = val7
			},
			new EffectData
			{
				m_prefab = PrefabManager.Instance.GetPrefab("vfx_hatchling_death")
			},
			new EffectData
			{
				m_prefab = PrefabManager.Instance.GetPrefab("sfx_hatchling_death")
			}
		};
		GameObject val9 = bundle.LoadAsset<GameObject>("AshNeck");
		PrefabManager.Instance.AddPrefab(val9);
		GameObject val10 = PrefabManager.Instance.CreateClonedPrefab("AshNeck_ragdoll1", "Neck_Ragdoll");
		SkinnedMeshRenderer component3 = ((Component)val10.transform.Find("Body")).GetComponent<SkinnedMeshRenderer>();
		Material val11 = new Material(((Renderer)component3).material);
		val11.SetTexture("_MainTex", (Texture)(object)LoadEmbeddedTexture("AshNeck"));
		((Renderer)component3).material = val11;
		((Renderer)((Component)val10.transform.Find("Lillies")).GetComponent<SkinnedMeshRenderer>()).material = val11;
		PrefabManager.Instance.AddPrefab(val10);
		((Character)val9.GetComponent<Humanoid>()).m_deathEffects.m_effectPrefabs = (EffectData[])(object)new EffectData[3]
		{
			new EffectData
			{
				m_prefab = val10
			},
			new EffectData
			{
				m_prefab = PrefabManager.Instance.GetPrefab("vfx_neck_death")
			},
			new EffectData
			{
				m_prefab = PrefabManager.Instance.GetPrefab("sfx_dragon_death")
			}
		};
		GameObject val12 = bundle.LoadAsset<GameObject>("AshNeckTrophy");
		val12.GetComponent<ItemDrop>().m_itemData.m_shared.m_trophyPos = new Vector2Int(0, 8);
		ItemManager.Instance.AddItem(new CustomItem(val12, false));
		GameObject val13 = PrefabManager.Instance.CreateClonedPrefab("fx_polarlox_death", "fx_lox_death");
		((Component)val13.transform.Find("skinflakes")).GetComponent<ParticleSystem>().startColor = Color.white;
		PrefabManager.Instance.AddPrefab(val13);
		GameObject prefab = PrefabManager.Instance.GetPrefab("PolarLox");
		GameObject prefab2 = PrefabManager.Instance.GetPrefab("PolarLox_ragdoll");
		((Character)prefab.GetComponent<Humanoid>()).m_deathEffects.m_effectPrefabs = (EffectData[])(object)new EffectData[2]
		{
			new EffectData
			{
				m_prefab = prefab2
			},
			new EffectData
			{
				m_prefab = val13
			}
		};
		Sprite val14 = LoadEmbeddedSprite("ArcticWolfPeltIcon");
		ItemConfig val15 = new ItemConfig();
		val15.Name = "Arctic Wolf Pelt";
		val15.Description = "The fur of an Arctic Wolf";
		val15.Icons = (Sprite[])(object)new Sprite[1] { val14 };
		CustomItem val16 = new CustomItem("ArcticWolfPelt", "WolfPelt", val15);
		Texture2D texture2 = LoadEmbeddedTexture("ArcticWolfPelt");
		val16.ItemPrefab.ChangeMeshTexture(texture2);
		ItemManager.Instance.AddItem(val16);
		Sprite val17 = LoadEmbeddedSprite("ArcticWolfTrophy");
		val15 = new ItemConfig();
		val15.Name = "Arctic Wolf Trophy";
		val15.Description = "The head of the beast";
		val15.Icons = (Sprite[])(object)new Sprite[1] { val17 };
		CustomItem val18 = new CustomItem("ArcticWolfTrophy", "TrophyWolf", val15);
		Texture2D texture3 = LoadEmbeddedTexture("ArcticWolf");
		val18.ItemPrefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_trophyPos = new Vector2Int(0, 7);
		val18.ItemPrefab.ChangeMeshTexture(texture3);
		ItemManager.Instance.AddItem(val18);
		Sprite icon = LoadEmbeddedSprite("ArcticWolfRugIcon");
		PieceConfig val19 = new PieceConfig();
		val19.Name = "Arctic Wolf Rug";
		val19.Description = "A rug made from the fur of the frozen beast.";
		val19.PieceTable = "Hammer";
		val19.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig
			{
				Amount = 4,
				Item = "ArcticWolfPelt",
				Recover = true
			}
		};
		val19.Icon = icon;
		CustomPiece val20 = new CustomPiece("ArcticWolfRug", "rug_wolf", val19);
		MeshRenderer[] componentsInChildren = val20.PiecePrefab.GetComponentsInChildren<MeshRenderer>();
		foreach (MeshRenderer val21 in componentsInChildren)
		{
			List<Material> list = new List<Material>();
			Material[] materials = ((Renderer)val21).materials;
			foreach (Material val22 in materials)
			{
				list.Add(new Material(val22)
				{
					color = new Color(1.5f, 1.5f, 1.5f)
				});
			}
			((Renderer)val21).materials = list.ToArray();
		}
		PieceManager.Instance.AddPiece(val20);
		Sprite val23 = LoadEmbeddedSprite("StormWolfTrophy");
		val15 = new ItemConfig();
		val15.Name = "Storm Wolf Trophy";
		val15.Description = "The head of a Storm Wolf";
		val15.Icons = (Sprite[])(object)new Sprite[1] { val23 };
		CustomItem val24 = new CustomItem("StormWolfTrophy", "TrophyWolf", val15);
		Texture2D texture4 = LoadEmbeddedTexture("StormWolf");
		val24.ItemPrefab.ChangeMeshTexture(texture4);
		val24.ItemPrefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_trophyPos = new Vector2Int(2, 5);
		ItemManager.Instance.AddItem(val24);
		GameObject val25 = bundle.LoadAsset<GameObject>("StormHatchlingTrophy");
		val25.GetComponent<ItemDrop>().m_itemData.m_shared.m_trophyPos = new Vector2Int(3, 5);
		ItemManager.Instance.AddItem(new CustomItem(val25, false));
		GameObject val26 = bundle.LoadAsset<GameObject>("AshHatchlingTrophy");
		val26.GetComponent<ItemDrop>().m_itemData.m_shared.m_trophyPos = new Vector2Int(1, 8);
		ItemManager.Instance.AddItem(new CustomItem(val26, false));
		GameObject val27 = bundle.LoadAsset<GameObject>("StormWolfPelt");
		ItemManager.Instance.AddItem(new CustomItem(val27, false, new ItemConfig
		{
			Name = "Storm Wolf Pelt",
			Description = "The pelt of a Storm Wolf"
		}));
		GameObject obj2 = bundle.LoadAsset<GameObject>("StormWolfRug");
		val19 = new PieceConfig();
		val19.CraftingStation = "piece_workbench";
		val19.PieceTable = "Hammer";
		val19.Category = "Furniture";
		val19.Name = "Storm Wolf Rug";
		val19.Description = "It's soft and warm and makes your hair stand on end";
		val19.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig
			{
				Amount = 4,
				Item = "StormWolfPelt",
				Recover = true
			}
		};
		CustomPiece val28 = new CustomPiece(obj2, false, val19);
		PieceManager.Instance.AddPiece(val28);
		GameObject val29 = bundle.LoadAsset<GameObject>("StormWolfCape");
		ItemManager instance = ItemManager.Instance;
		val15 = new ItemConfig();
		val15.Amount = 1;
		val15.CraftingStation = "piece_workbench";
		val15.MinStationLevel = 1;
		val15.Requirements = (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig
			{
				Amount = 8,
				Item = "StormWolfPelt",
				AmountPerLevel = 2
			},
			new RequirementConfig
			{
				Amount = 1,
				Item = "StormWolfTrophy"
			},
			new RequirementConfig
			{
				Amount = 1,
				Item = "Thunderstone",
				AmountPerLevel = 1
			}
		};
		instance.AddItem(new CustomItem(val29, false, val15));
		GameObject val30 = bundle.LoadAsset<GameObject>("ArcticWolfCape");
		ItemManager instance2 = ItemManager.Instance;
		val15 = new ItemConfig();
		val15.Amount = 1;
		val15.CraftingStation = "piece_alchemystation";
		val15.MinStationLevel = 1;
		val15.Requirements = (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig
			{
				Amount = 8,
				Item = "ArcticWolfPelt",
				AmountPerLevel = 2
			},
			new RequirementConfig
			{
				Amount = 1,
				Item = "ArcticWolfTrophy"
			},
			new RequirementConfig
			{
				Amount = 1,
				Item = "FrometalBar",
				AmountPerLevel = 1
			}
		};
		instance2.AddItem(new CustomItem(val30, false, val15));
		Sprite val31 = LoadEmbeddedSprite("StormFenringTrophy");
		val15 = new ItemConfig();
		val15.Amount = 1;
		val15.Name = "Storm Fenring Trophy";
		val15.Description = "All that remains from the mighty beast";
		val15.Icons = (Sprite[])(object)new Sprite[1] { val31 };
		CustomItem val32 = new CustomItem("StormFenringTrophy", "TrophyFenring", val15);
		val32.ItemPrefab.ChangeMeshTexture(LoadEmbeddedTexture("StormFenring"));
		val32.ItemPrefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_trophyPos = new Vector2Int(4, 5);
		ItemManager.Instance.AddItem(val32);
		Sprite val33 = LoadEmbeddedSprite("DevourerFenringTrophy");
		val15 = new ItemConfig();
		val15.Amount = 1;
		val15.Name = "Blood-thirsty Fenring Trophy";
		val15.Description = "A blood-soaked arm of a Fenring";
		val15.Icons = (Sprite[])(object)new Sprite[1] { val33 };
		CustomItem val34 = new CustomItem("DevourerFenringTrophy", "TrophyFenring", val15);
		val34.ItemPrefab.ChangeMeshTexture(LoadEmbeddedTexture("DevourerFenring"));
		val34.ItemPrefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_trophyPos = new Vector2Int(1, 7);
		ItemManager.Instance.AddItem(val34);
		Sprite val35 = LoadEmbeddedSprite("PolarLoxTrophy");
		val15 = new ItemConfig();
		val15.Name = "Ice-breaker Lox Trophy";
		val15.Description = "The head of a Polar Lox";
		val15.Icons = (Sprite[])(object)new Sprite[1] { val35 };
		CustomItem val36 = new CustomItem("PolarLoxTrophy", "TrophyLox", val15);
		val36.ItemPrefab.ChangeMeshTexture(LoadEmbeddedTexture("PolarLox"));
		val36.ItemPrefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_trophyPos = new Vector2Int(2, 7);
		ItemManager.Instance.AddItem(val36);
		Sprite val37 = LoadEmbeddedSprite("BurnedBonesTrophy");
		val15 = new ItemConfig();
		val15.Name = "Burned Bones Trophy";
		val15.Description = "The head of a Burned Bones";
		val15.Icons = (Sprite[])(object)new Sprite[1] { val37 };
		CustomItem val38 = new CustomItem("BurnedBonesTrophy", "TrophySkeleton", val15);
		val38.ItemPrefab.ChangeMeshTexture(LoadEmbeddedTexture("BurnedBonesTex"));
		val38.ItemPrefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_trophyPos = new Vector2Int(2, 8);
		ItemManager.Instance.AddItem(val38);
		Sprite val39 = LoadEmbeddedSprite("FrozenCorpseTrophy");
		val15 = new ItemConfig();
		val15.Name = "Frozen Corpse Trophy";
		val15.Description = "The head of a Frozen Corpse";
		val15.Icons = (Sprite[])(object)new Sprite[1] { val39 };
		CustomItem val40 = new CustomItem("FrozenCorpseTrophy", "TrophySkeleton", val15);
		val40.ItemPrefab.ChangeMeshTexture(LoadEmbeddedTexture("FrozenCorpse"));
		val40.ItemPrefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_trophyPos = new Vector2Int(5, 7);
		ItemManager.Instance.AddItem(val40);
		Sprite val41 = LoadEmbeddedSprite("SwollenBodyTrophy");
		val15 = new ItemConfig();
		val15.Name = "Swollen Body Trophy";
		val15.Description = "A foul piece of rotting flesh";
		val15.Icons = (Sprite[])(object)new Sprite[1] { val41 };
		CustomItem val42 = new CustomItem("SwollenBodyTrophy", "TrophyDraugr", val15);
		val42.ItemPrefab.ChangeMeshTexture(LoadEmbeddedTexture("SwollenBody"));
		val42.ItemPrefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_trophyPos = new Vector2Int(4, 8);
		ItemManager.Instance.AddItem(val42);
		Sprite val43 = LoadEmbeddedSprite("PolarFenringTrophy");
		val15 = new ItemConfig();
		val15.Name = "Pale-coat Fenring Trophy";
		val15.Description = "The arm of a Polar Fenring";
		val15.Icons = (Sprite[])(object)new Sprite[1] { val43 };
		CustomItem val44 = new CustomItem("PolarFenringTrophy", "TrophyFenring", val15);
		val44.ItemPrefab.ChangeMeshTexture(LoadEmbeddedTexture("PolarFenring"));
		val44.ItemPrefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_trophyPos = new Vector2Int(6, 7);
		ItemManager.Instance.AddItem(val44);
		GameObject val45 = bundle.LoadAsset<GameObject>("JotunnTrophy");
		val45.GetComponent<ItemDrop>().m_itemData.m_shared.m_trophyPos = new Vector2Int(3, 7);
		ItemManager.Instance.AddItem(new CustomItem(val45, false));
		GameObject val46 = bundle.LoadAsset<GameObject>("SmallPolarSerpentTrophy");
		val46.GetComponent<ItemDrop>().m_itemData.m_shared.m_trophyPos = new Vector2Int(4, 7);
		ItemManager.Instance.AddItem(new CustomItem(val46, false));
		Sprite val47 = LoadEmbeddedSprite("SilverGolemTrophyIcon");
		val15 = new ItemConfig();
		val15.Name = "Silver Golem Trophy";
		val15.Description = "The massive head of a defeated Silver Golem";
		val15.Icons = (Sprite[])(object)new Sprite[1] { val47 };
		CustomItem val48 = new CustomItem("SilverGolemTrophy", "TrophySGolem", val15);
		Object.DestroyImmediate((Object)(object)((Component)((Component)val48.ItemPrefab.transform.Find("attach")).transform.Find("Particle System")).gameObject);
		val48.ItemPrefab.GetComponentInChildren<Light>().color = Color.gray;
		val48.ItemPrefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_trophyPos = new Vector2Int(4, 6);
		componentsInChildren = val48.ItemPrefab.GetComponentsInChildren<MeshRenderer>();
		foreach (MeshRenderer val49 in componentsInChildren)
		{
			List<Material> list2 = new List<Material>();
			Material[] materials = ((Renderer)val49).materials;
			foreach (Material val50 in materials)
			{
				list2.Add(new Material(val50)
				{
					color = Color.gray
				});
			}
			((Renderer)val49).materials = list2.ToArray();
		}
		ItemManager.Instance.AddItem(val48);
		ItemDrop component4 = PrefabManager.Instance.GetPrefab("TrophyHelDemon").GetComponent<ItemDrop>();
		component4.m_itemData.m_shared.m_trophyPos = new Vector2Int(3, 8);
		component4.m_itemData.m_shared.m_name = "Blazing Damned One Trophy";
		PrefabManager.OnVanillaPrefabsAvailable -= AddClonedItems;
		bundle.Unload(false);
	}

	private Texture2D LoadEmbeddedTexture(string imageName)
	{
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Expected O, but got Unknown
		//IL_006d: Expected O, but got Unknown
		Assembly executingAssembly = Assembly.GetExecutingAssembly();
		string text = executingAssembly.GetManifestResourceNames().Single((string str) => str == "MonsterMobs.Assets." + imageName + ".png");
		Logger.LogDebug((object)("Resource name : " + text));
		byte[] array = ReadFully(executingAssembly.GetManifestResourceStream(text));
		Logger.LogDebug((object)$"Byte array length : {array.Length}");
		Texture2D val = new Texture2D(2, 2);
		ImageConversion.LoadImage(val, array);
		return val;
	}

	private Sprite LoadEmbeddedSprite(string imageName)
	{
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Expected O, but got Unknown
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		Assembly executingAssembly = Assembly.GetExecutingAssembly();
		string text = executingAssembly.GetManifestResourceNames().SingleOrDefault((string str) => str == "MonsterMobs.Assets.Sprites." + imageName + ".png");
		if (text == null)
		{
			throw new Exception(imageName + ".png not found.");
		}
		Logger.LogDebug((object)("Resource name : " + text));
		byte[] array = ReadFully(executingAssembly.GetManifestResourceStream(text));
		Logger.LogDebug((object)$"Byte array length : {array.Length}");
		Texture2D val = new Texture2D(2, 2);
		ImageConversion.LoadImage(val, array);
		return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), Vector2.zero);
	}

	public static byte[] ReadFully(Stream input)
	{
		using MemoryStream memoryStream = new MemoryStream();
		input.CopyTo(memoryStream);
		return memoryStream.ToArray();
	}

	public static void WriteChildren(Transform go)
	{
		if (go.childCount == 0)
		{
			DebugLog(((Object)go).name);
			return;
		}
		for (int i = 0; i < go.childCount; i++)
		{
			Transform child = go.GetChild(i);
			DebugLog($"{((Object)go).name} {i} {((Object)child).name}");
			WriteChildren(((Component)child).transform);
		}
	}

	public static void DebugLog(string message)
	{
		if (Debug)
		{
			Logger.LogInfo((object)("DEBUG | " + message));
		}
	}
}
public static class GameObjectExtensions
{
	public static GameObject ChangeTexture(this GameObject go, Texture2D texture)
	{
		MonsterMobs.DebugLog("Changing texture for " + ((Object)go).name);
		if ((Object)(object)texture == (Object)null)
		{
			MonsterMobs.DebugLog("Texture is null for " + ((Object)go).name);
		}
		Renderer[] componentsInChildren = go.GetComponentsInChildren<Renderer>();
		foreach (Renderer val in componentsInChildren)
		{
			MonsterMobs.DebugLog("Changing texture for material " + ((Object)val).name);
			val.materials = ((IEnumerable<Material>)val.materials).Select((Func<Material, Material>)((Material m) => new Material(m)
			{
				mainTexture = (Texture)(object)texture
			})).ToArray();
		}
		return go;
	}

	public static GameObject ChangeMeshTexture(this GameObject go, Texture2D texture)
	{
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Expected O, but got Unknown
		MeshRenderer[] componentsInChildren = go.GetComponentsInChildren<MeshRenderer>();
		foreach (MeshRenderer val in componentsInChildren)
		{
			List<Material> list = new List<Material>();
			Material[] materials = ((Renderer)val).materials;
			foreach (Material val2 in materials)
			{
				list.Add(new Material(val2)
				{
					mainTexture = (Texture)(object)texture
				});
			}
			((Renderer)val).materials = list.ToArray();
		}
		return go;
	}
}
public struct Clone
{
	public string BasePrefab { get; set; }

	public string NewPrefab { get; set; }

	public string Texture { get; set; }

	public Clone(string basePrefab, string newPrefab, string texture)
	{
		BasePrefab = basePrefab;
		NewPrefab = newPrefab;
		Texture = texture;
	}
}