mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-13 02:10:45 -05:00
Clothing service fix (!165)
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>
This commit is contained in:
parent
9b53ad0752
commit
9c248719e7
@ -0,0 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SPT.SinglePlayer.Models.MainMenu;
|
||||
|
||||
public class ModdedTraders
|
||||
{
|
||||
public List<string> clothingService { get; set; }
|
||||
}
|
@ -5,6 +5,7 @@ using SPT.SinglePlayer.Patches.Progression;
|
||||
using SPT.SinglePlayer.Patches.RaidFix;
|
||||
using SPT.SinglePlayer.Patches.ScavMode;
|
||||
using BepInEx;
|
||||
using SPT.SinglePlayer.Utils.MainMenu;
|
||||
|
||||
namespace SPT.SinglePlayer
|
||||
{
|
||||
@ -67,5 +68,10 @@ namespace SPT.SinglePlayer
|
||||
|
||||
Logger.LogInfo("Completed: SPT.SinglePlayer");
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
TraderServiceManager.GetModdedTraderData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,49 @@
|
||||
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);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user