mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-13 08:50:43 -05:00
Client implementation of my `TraderServiceFix` mod into the SPT code base. Details on server PR, also is required to be merged with the accompanying server PR. Co-authored-by: Cj <161484149+CJ-SPT@users.noreply.github.com> Reviewed-on: SPT/Modules#165 Co-authored-by: Cj <cj@noreply.dev.sp-tarkov.com> Co-committed-by: Cj <cj@noreply.dev.sp-tarkov.com>
49 lines
1.4 KiB
C#
49 lines
1.4 KiB
C#
using System.Collections.Generic;
|
|
using System.Reflection;
|
|
using EFT;
|
|
using HarmonyLib;
|
|
using Newtonsoft.Json;
|
|
using SPT.Common.Http;
|
|
using SPT.SinglePlayer.Models.MainMenu;
|
|
|
|
namespace SPT.SinglePlayer.Utils.MainMenu;
|
|
|
|
public static class TraderServiceManager
|
|
{
|
|
private static Dictionary<string, Profile.ETraderServiceSource> _traderIdToTraderServiceDict = new()
|
|
{
|
|
{
|
|
"5ac3b934156ae10c4430e83c",
|
|
Profile.ETraderServiceSource.Ragman
|
|
},
|
|
{
|
|
"6617beeaa9cfa777ca915b7c",
|
|
Profile.ETraderServiceSource.ArenaManager
|
|
}
|
|
};
|
|
|
|
private static FieldInfo _traderIdToTraderServiceField;
|
|
|
|
static TraderServiceManager()
|
|
{
|
|
_traderIdToTraderServiceField = AccessTools.Field(typeof(Profile.TraderInfo), "TraderIdToTraderService");
|
|
}
|
|
|
|
public static void GetModdedTraderData()
|
|
{
|
|
var req = RequestHandler.GetJson("/singleplayer/moddedTraders");
|
|
var moddedTraders = JsonConvert.DeserializeObject<ModdedTraders>(req);
|
|
|
|
AddModdedTradersToClothingServiceDict(moddedTraders);
|
|
}
|
|
|
|
private static void AddModdedTradersToClothingServiceDict(ModdedTraders traders)
|
|
{
|
|
foreach (var trader in traders.clothingService)
|
|
{
|
|
_traderIdToTraderServiceDict.Add(trader, Profile.ETraderServiceSource.Ragman);
|
|
}
|
|
|
|
_traderIdToTraderServiceField.SetValue(_traderIdToTraderServiceField, _traderIdToTraderServiceDict);
|
|
}
|
|
} |