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