2023-07-08 23:42:42 +03:00
|
|
|
using BepInEx;
|
2024-12-02 15:59:14 +02:00
|
|
|
using EFT;
|
2023-07-08 23:42:42 +03:00
|
|
|
using EFT.InventoryLogic;
|
2024-07-10 23:03:39 +03:00
|
|
|
using SPT.Reflection.Patching;
|
2023-07-08 23:42:42 +03:00
|
|
|
using System.Reflection;
|
|
|
|
|
2024-03-05 22:48:21 +02:00
|
|
|
namespace IcyClawz.ItemSellPrice;
|
|
|
|
|
2024-12-02 15:59:14 +02:00
|
|
|
[BepInPlugin("com.IcyClawz.ItemSellPrice", "IcyClawz.ItemSellPrice", "1.5.0")]
|
2024-03-05 22:48:21 +02:00
|
|
|
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();
|
2024-12-02 15:59:14 +02:00
|
|
|
new AmmoItemPatch().Enable();
|
|
|
|
new ThrowWeapItemPatch().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-12-02 15:59:14 +02:00
|
|
|
internal class AmmoItemPatch : ModulePatch
|
2024-03-05 22:48:21 +02:00
|
|
|
{
|
|
|
|
protected override MethodBase GetTargetMethod() =>
|
2024-12-02 15:59:14 +02:00
|
|
|
typeof(AmmoItemClass).GetConstructors()[0];
|
2023-07-08 23:42:42 +03:00
|
|
|
|
2024-03-05 22:48:21 +02:00
|
|
|
[PatchPostfix]
|
2024-12-02 15:59:14 +02:00
|
|
|
private static void PatchPostfix(ref AmmoItemClass __instance) =>
|
2024-03-05 22:48:21 +02:00
|
|
|
__instance.AddTraderOfferAttribute();
|
|
|
|
}
|
2023-07-08 23:42:42 +03:00
|
|
|
|
2024-12-02 15:59:14 +02:00
|
|
|
internal class ThrowWeapItemPatch : ModulePatch
|
2024-03-05 22:48:21 +02:00
|
|
|
{
|
|
|
|
protected override MethodBase GetTargetMethod() =>
|
2024-12-02 15:59:14 +02:00
|
|
|
typeof(ThrowWeapItemClass).GetConstructors()[0];
|
2023-07-08 23:42:42 +03:00
|
|
|
|
2024-03-05 22:48:21 +02:00
|
|
|
[PatchPostfix]
|
2024-12-02 15:59:14 +02:00
|
|
|
private static void PatchPostfix(ref ThrowWeapItemClass __instance) =>
|
2024-03-05 22:48:21 +02:00
|
|
|
__instance.AddTraderOfferAttribute();
|
2023-07-08 23:42:42 +03:00
|
|
|
}
|