60 lines
1.6 KiB
C#
Raw Normal View History

using BepInEx;
using EFT;
using EFT.InventoryLogic;
using SPT.Reflection.Patching;
using System.Reflection;
2024-03-05 22:48:21 +02:00
namespace IcyClawz.ItemSellPrice;
[BepInPlugin("com.IcyClawz.ItemSellPrice", "IcyClawz.ItemSellPrice", "1.5.0")]
2024-03-05 22:48:21 +02:00
public class Plugin : BaseUnityPlugin
{
2024-03-05 22:48:21 +02:00
private void Awake()
{
2024-03-05 22:48:21 +02:00
new TraderPatch().Enable();
new ItemPatch().Enable();
new AmmoItemPatch().Enable();
new ThrowWeapItemPatch().Enable();
}
2024-03-05 22:48:21 +02:00
}
2024-03-05 22:48:21 +02:00
internal class TraderPatch : ModulePatch
{
protected override MethodBase GetTargetMethod() =>
typeof(TraderClass).GetConstructors()[0];
2024-03-05 22:48:21 +02:00
[PatchPostfix]
private static void PatchPostfix(ref TraderClass __instance) =>
__instance.UpdateSupplyData();
}
2024-03-05 22:48:21 +02:00
internal class ItemPatch : ModulePatch
{
protected override MethodBase GetTargetMethod() =>
typeof(Item).GetConstructors()[0];
2024-03-05 22:48:21 +02:00
[PatchPostfix]
private static void PatchPostfix(ref Item __instance) =>
__instance.AddTraderOfferAttribute();
}
internal class AmmoItemPatch : ModulePatch
2024-03-05 22:48:21 +02:00
{
protected override MethodBase GetTargetMethod() =>
typeof(AmmoItemClass).GetConstructors()[0];
2024-03-05 22:48:21 +02:00
[PatchPostfix]
private static void PatchPostfix(ref AmmoItemClass __instance) =>
2024-03-05 22:48:21 +02:00
__instance.AddTraderOfferAttribute();
}
internal class ThrowWeapItemPatch : ModulePatch
2024-03-05 22:48:21 +02:00
{
protected override MethodBase GetTargetMethod() =>
typeof(ThrowWeapItemClass).GetConstructors()[0];
2024-03-05 22:48:21 +02:00
[PatchPostfix]
private static void PatchPostfix(ref ThrowWeapItemClass __instance) =>
2024-03-05 22:48:21 +02:00
__instance.AddTraderOfferAttribute();
}