using System;
using System.Collections.Generic;
using System.Diagnostics;
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("MeuModMuck")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MeuModMuck")]
[assembly: AssemblyTitle("MeuModMuck")]
[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("meu.mod.itens", "Mod de Itens", "1.0")]
public class MeuMod : BaseUnityPlugin
{
[HarmonyPatch(typeof(ItemManager), "InitAllItems")]
private class Patch_Items
{
private static void Postfix(ItemManager __instance)
{
Debug.Log((object)"Injetando item custom...");
foreach (InventoryItem value in __instance.allItems.Values)
{
if (value.name == "Super Pickaxe")
{
Debug.Log((object)"Item já existe no jogo!");
meuItem = value;
meuItemId = value.id;
return;
}
}
InventoryItem val = __instance.allItems[118];
InventoryItem val2 = __instance.allItems[27];
InventoryItem val3 = __instance.allItems[82];
InventoryItem novoItem = Object.Instantiate<InventoryItem>(val);
novoItem.name = "Super Pickaxe";
novoItem.description = "Normal damage is 100 the resource damage is 200";
novoItem.amount = 1;
novoItem.stackable = false;
novoItem.attackDamage = 100;
novoItem.attackSpeed = 1.2f;
novoItem.resourceDamage = 200;
novoItem.material = val3.material;
novoItem.unlockWithFirstRequirementOnly = false;
novoItem.stationRequirement = val2.stationRequirement;
novoItem.craftable = true;
novoItem.requirements = val2.requirements;
int count = __instance.allItems.Count;
novoItem.id = count;
__instance.allItems.Add(count, novoItem);
if (novoItem.requirements != null)
{
CraftRequirement[] requirements = novoItem.requirements;
foreach (CraftRequirement val4 in requirements)
{
if (__instance.allItems.ContainsKey(val4.item.id) && !(__instance.allItems[val4.item.id].name != val4.item.name))
{
continue;
}
foreach (InventoryItem value2 in __instance.allItems.Values)
{
if (value2.name == val4.item.name)
{
val4.item.id = value2.id;
Debug.Log((object)("Corrigido ID de: " + value2.name));
break;
}
}
}
}
if (!anvilWeapons.Any((InventoryItem i) => i.name == novoItem.name))
{
anvilWeapons.Add(novoItem);
}
meuItemId = count;
meuItem = novoItem;
Debug.Log((object)("Item registrado: " + novoItem.name + " ID: " + novoItem.id));
}
}
[HarmonyPatch(typeof(CraftingUI), "Start")]
private class Patch_Crafting
{
public static bool jacrido;
private static void Postfix(CraftingUI __instance)
{
if (jacrido)
{
return;
}
Debug.Log((object)"Injetando receitas custom...");
Tab[] tabs = __instance.tabs;
foreach (Tab val in tabs)
{
if (Array.TrueForAll(val.items, (InventoryItem item) => (int)item.type == 3))
{
if (!val.items.Contains(meuItem))
{
val.items = val.items.Concat(anvilWeapons).ToArray();
Debug.Log((object)"Craft adicionado!");
}
break;
}
}
}
}
public static int meuItemId;
public static InventoryItem meuItem;
public static List<InventoryItem> anvilWeapons = new List<InventoryItem>();
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.itens");
val.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Mod carregado.");
}
}
namespace MeuModMuck
{
public class Class1
{
}
}