81 lines
2.2 KiB
C#
Raw Normal View History

using Aki.Reflection.Patching;
using BepInEx;
using EFT.InventoryLogic;
using System.Reflection;
namespace IcyClawz.ItemSellPrice
{
[BepInPlugin("com.IcyClawz.ItemSellPrice", "IcyClawz.ItemSellPrice", "1.0.2")]
public class Plugin : BaseUnityPlugin
{
private void Awake()
{
new TraderPatch().Enable();
new ItemPatch().Enable();
new AmmoPatch().Enable();
new GrenadePatch().Enable();
new SecureContainerPatch().Enable();
}
}
2023-07-09 22:38:08 +03:00
internal class TraderPatch : ModulePatch
{
protected override MethodBase GetTargetMethod() =>
typeof(TraderClass).GetConstructors()[0];
[PatchPostfix]
private static void PatchPostfix(ref TraderClass __instance)
{
__instance.UpdateSupplyData();
}
}
2023-07-09 22:38:08 +03:00
internal class ItemPatch : ModulePatch
{
protected override MethodBase GetTargetMethod() =>
typeof(Item).GetConstructors()[0];
[PatchPostfix]
private static void PatchPostfix(ref Item __instance)
{
__instance.AddTraderOfferAttribute();
}
}
2023-07-09 22:38:08 +03:00
internal class AmmoPatch : ModulePatch
{
protected override MethodBase GetTargetMethod() =>
typeof(BulletClass).GetConstructors()[0];
[PatchPostfix]
private static void PatchPostfix(ref BulletClass __instance)
{
__instance.AddTraderOfferAttribute();
}
}
2023-07-09 22:38:08 +03:00
internal class GrenadePatch : ModulePatch
{
protected override MethodBase GetTargetMethod() =>
typeof(GrenadeClass).GetConstructors()[0];
[PatchPostfix]
private static void PatchPostfix(ref GrenadeClass __instance)
{
__instance.AddTraderOfferAttribute();
}
}
2023-07-09 22:38:08 +03:00
internal class SecureContainerPatch : ModulePatch
{
2023-07-08 23:54:22 +03:00
protected override MethodBase GetTargetMethod() =>
typeof(ItemContainerClass).GetConstructors()[0];
[PatchPostfix]
private static void PatchPostfix(ref ItemContainerClass __instance)
{
__instance.AddTraderOfferAttribute();
}
}
}