0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 09:50:43 -05:00
DrakiaXYZ 4dee774efc Refactor trader services into its own manager in Aki.Singleplayer (!61)
I've moved trader services handling from Aki.Debugging BTR code into Aki.SinglePlayer
This simplifies some of the code, and allows a more "generic" implementation.

I've also patched the GetTraderServicesDataFromServer and TryPurchaseTraderService methods to properly utilize the TraderServicesManager for storing service state

For now, this makes Aki.Debugging depend on Aki.SinglePlayer, this can be reverted once the BTR stuff is moved

Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: SPT-AKI/Modules#61
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
2024-01-15 09:09:31 +00:00

41 lines
1.4 KiB
C#

using Aki.Common.Http;
using Comfort.Common;
using EFT;
using EFT.InventoryLogic;
using HarmonyLib;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;
using static BackendConfigSettingsClass;
using TraderServiceClass = GClass1789;
namespace Aki.Debugging.BTR.Utils
{
public static class BTRUtil
{
public static readonly string BTRTraderId = Profile.TraderInfo.BTR_TRADER_ID;
public static readonly string BTRMachineGunWeaponTplId = "657857faeff4c850222dff1b"; // BTR PKTM machine gun
public static readonly string BTRMachineGunAmmoTplId = "5e023d34e8a400319a28ed44"; // 7.62x54mmR BT
private static FieldInfo _traderAvailableServicesField = AccessTools.Field(typeof(Profile.TraderInfo), "_availableServices");
static BTRUtil()
{
// Sanity checks for compile time failure in the event the GClass changes
_ = nameof(TraderServiceClass.CanAfford);
_ = nameof(TraderServiceClass.WasPurchasedInThisRaid);
}
/// <summary>
/// Used to create an instance of the item in-raid.
/// </summary>
public static Item CreateItem(string tplId)
{
var id = Guid.NewGuid().ToString("N").Substring(0, 24);
return Singleton<ItemFactory>.Instance.CreateItem(id, tplId, null);
}
}
}