Decompiled source of MoreOresWeapons v1.0.0

MoreOresWeapons.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("MoreOresWeapons")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MoreOresWeapons")]
[assembly: AssemblyTitle("MoreOresWeapons")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
[BepInPlugin("davipereiraoliveira_MoreOresWeapons", "MoreOresWeapons", "1.0")]
public class MeuMod : BaseUnityPlugin
{
	[HarmonyPatch(typeof(ItemManager), "InitAllItems")]
	private class Patch_Items
	{
		[HarmonyPatch(typeof(CraftingUI), "Awake")]
		private class Patch_Crafting
		{
			public static bool jacrido;

			private static void Postfix(CraftingUI __instance)
			{
				Debug.Log((object)"Injetando receitas custom...");
				Tab[] tabs = __instance.tabs;
				foreach (Tab val in tabs)
				{
					bool flag = Array.TrueForAll(val.items, (InventoryItem item) => (int)item.type == 3);
					if (flag)
					{
						val.items = val.items.Concat(anvilWeapons).ToArray();
						break;
					}
					if (!flag)
					{
						val.items = val.items.Concat(anvilTools).ToArray();
						break;
					}
				}
				Tab[] tabs2 = __instance.tabs;
				foreach (Tab val2 in tabs2)
				{
					if (Array.TrueForAll(val2.items, (InventoryItem item) => (int)item.type == 9))
					{
						val2.items = val2.items.Concat(anvilBows).ToArray();
						break;
					}
				}
			}
		}

		private static void Postfix(ItemManager __instance)
		{
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Expected O, but got Unknown
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Expected O, but got Unknown
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Expected O, but got Unknown
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Expected O, but got Unknown
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Expected O, but got Unknown
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Expected O, but got Unknown
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Expected O, but got Unknown
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Expected O, but got Unknown
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Expected O, but got Unknown
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Expected O, but got Unknown
			meuItem = CriarItem(__instance, "Iron Bow", "This is a Iron Bow.", 115);
			meuItem2 = CriarItem(__instance, "Gold Bow", "aa", 115);
			meuItem3 = CriarItem(__instance, "Mithril Bow", "aa", 116);
			meuItem4 = CriarItem(__instance, "Adamantite Bow", "aa", 113);
			meuItem5 = CriarItem(__instance, "Obamium Bow", "aa", 117);
			anvilBows.Add(meuItem);
			anvilBows.Add(meuItem2);
			anvilBows.Add(meuItem3);
			anvilBows.Add(meuItem4);
			anvilBows.Add(meuItem5);
			Sprite sprite = CarregarSprite("moreoresweapons.Iron Bow.png");
			Sprite sprite2 = CarregarSprite("moreoresweapons.Gold Bow.png");
			Sprite sprite3 = CarregarSprite("moreoresweapons.Mithril Bow.png");
			Sprite sprite4 = CarregarSprite("moreoresweapons.Adamantite Bow.png");
			Sprite sprite5 = CarregarSprite("moreoresweapons.Obamium Bow.png");
			meuItem.sprite = sprite;
			meuItem2.sprite = sprite2;
			meuItem3.sprite = sprite3;
			meuItem4.sprite = sprite4;
			meuItem5.sprite = sprite5;
			InventoryItem item = __instance.allItems[94];
			InventoryItem val = __instance.allItems[69];
			InventoryItem val2 = __instance.allItems[68];
			InventoryItem val3 = __instance.allItems[70];
			InventoryItem val4 = __instance.allItems[66];
			InventoryItem val5 = __instance.allItems[71];
			InventoryItem item2 = __instance.allItems[65];
			InventoryItem val6 = __instance.allItems[50];
			meuItem.material = val.material;
			meuItem2.material = val2.material;
			meuItem3.material = val3.material;
			meuItem4.material = val4.material;
			meuItem5.material = val5.material;
			meuItem.requirements = (CraftRequirement[])(object)new CraftRequirement[2]
			{
				new CraftRequirement
				{
					item = item,
					amount = 10
				},
				new CraftRequirement
				{
					item = val,
					amount = 10
				}
			};
			meuItem2.requirements = (CraftRequirement[])(object)new CraftRequirement[2]
			{
				new CraftRequirement
				{
					item = val2,
					amount = 10
				},
				new CraftRequirement
				{
					item = val,
					amount = 10
				}
			};
			meuItem3.requirements = (CraftRequirement[])(object)new CraftRequirement[2]
			{
				new CraftRequirement
				{
					item = val3,
					amount = 10
				},
				new CraftRequirement
				{
					item = val,
					amount = 5
				}
			};
			meuItem4.requirements = (CraftRequirement[])(object)new CraftRequirement[2]
			{
				new CraftRequirement
				{
					item = val4,
					amount = 10
				},
				new CraftRequirement
				{
					item = val,
					amount = 3
				}
			};
			meuItem5.requirements = (CraftRequirement[])(object)new CraftRequirement[2]
			{
				new CraftRequirement
				{
					item = val5,
					amount = 10
				},
				new CraftRequirement
				{
					item = item2,
					amount = 1
				}
			};
			Debug.Log((object)"Items Feitos com sucesso MoreOresWeapons");
		}
	}

	public static InventoryItem meuItem;

	public static InventoryItem meuItem2;

	public static InventoryItem meuItem3;

	public static InventoryItem meuItem4;

	public static InventoryItem meuItem5;

	public static InventoryItem meuItem6;

	public static InventoryItem meuItem7;

	public static InventoryItem meuItem8;

	public static InventoryItem meuItem9;

	public static InventoryItem meuItem10;

	public static InventoryItem meuItem11;

	public static List<InventoryItem> anvilWeapons = new List<InventoryItem>();

	public static List<InventoryItem> anvilTools = new List<InventoryItem>();

	public static List<InventoryItem> anvilBows = new List<InventoryItem>();

	public static Sprite CarregarSprite(string resourceName)
	{
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Expected O, but got Unknown
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		Assembly executingAssembly = Assembly.GetExecutingAssembly();
		Stream manifestResourceStream = executingAssembly.GetManifestResourceStream(resourceName);
		if (manifestResourceStream == null)
		{
			Debug.LogError((object)("Imagem não encontrada: " + resourceName));
			return null;
		}
		byte[] array = new byte[manifestResourceStream.Length];
		manifestResourceStream.Read(array, 0, array.Length);
		Texture2D val = new Texture2D(2, 2);
		ImageConversion.LoadImage(val, array);
		((Texture)val).filterMode = (FilterMode)0;
		((Texture)val).wrapMode = (TextureWrapMode)1;
		val.Apply();
		return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(2f, 2f));
	}

	private static InventoryItem CriarItem(ItemManager __instance, string nome, string descricao, int baseitemid)
	{
		InventoryItem val = ((IEnumerable<InventoryItem>)__instance.allItems.Values).FirstOrDefault((Func<InventoryItem, bool>)((InventoryItem i) => i.name == nome));
		if ((Object)(object)val != (Object)null)
		{
			return val;
		}
		InventoryItem val2 = __instance.allItems[baseitemid];
		InventoryItem val3 = Object.Instantiate<InventoryItem>(val2);
		val3.name = nome;
		val3.description = descricao;
		int key = (val3.id = __instance.allItems.Keys.Max() + 1);
		__instance.allItems.Add(key, val3);
		return val3;
	}

	private void Awake()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		Harmony val = new Harmony("meu.mod.moreoresweapons");
		val.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Mod carregado.");
		string[] manifestResourceNames = Assembly.GetExecutingAssembly().GetManifestResourceNames();
		foreach (string text in manifestResourceNames)
		{
			Debug.Log((object)text);
		}
	}
}