mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-13 09:10:44 -05:00
![Lacyway](/assets/img/avatar_default.png)
This fixes the logic of FixSavageInventoryScreenPatch. NOTE: The code below is untested and will most likely not work. It's what I theoretically believe is the right way to turn the `JObject` into a string for the server, however BSG has a `JsonWriter` in the client now that might have to be utilized? I will leave it like this until we have more info. ```c# RequestHandler.PutJson("/raid/profile/scavsave", GetProfileAtEndOfRaidPatch.ProfileDescriptor.ToUnparsedData([]).JObject.ToString()); ``` Co-authored-by: Lacyway <20912169+Lacyway@users.noreply.github.com> Reviewed-on: SPT/Modules#173 Co-authored-by: Lacyway <lacyway@noreply.dev.sp-tarkov.com> Co-committed-by: Lacyway <lacyway@noreply.dev.sp-tarkov.com>
66 lines
2.1 KiB
C#
66 lines
2.1 KiB
C#
using EFT;
|
|
using HarmonyLib;
|
|
using SPT.Reflection.Patching;
|
|
using System.Reflection;
|
|
using System.Linq;
|
|
using Newtonsoft.Json;
|
|
using SPT.Common.Http;
|
|
using System;
|
|
|
|
|
|
namespace SPT.SinglePlayer.Patches.ScavMode
|
|
{
|
|
/// <summary>
|
|
/// Get Profile at LocalGame End to use in FixSavageInventoryScreenPatch
|
|
/// </summary>
|
|
public class GetProfileAtEndOfRaidPatch : ModulePatch
|
|
{
|
|
public static GClass1962 ProfileDescriptor { get; private set; }
|
|
|
|
protected override MethodBase GetTargetMethod()
|
|
{
|
|
return AccessTools.Method(typeof(LocalGame), nameof(LocalGame.Stop));
|
|
}
|
|
|
|
[PatchPrefix]
|
|
public static void PatchPrefix(LocalGame __instance)
|
|
{
|
|
ProfileDescriptor = new GClass1962(__instance.Profile_0, GClass1971.Instance);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Get profile from other patch (GetProfileAtEndOfRaidPatch)
|
|
/// if our profile is savage Create new Session.AllProfiles and pass in our own profile to allow us to use the ScavengerInventoryScreen
|
|
/// </summary>
|
|
public class FixSavageInventoryScreenPatch : ModulePatch
|
|
{
|
|
protected override MethodBase GetTargetMethod()
|
|
{
|
|
return AccessTools.Method(typeof(PostRaidHealthScreenClass), nameof(PostRaidHealthScreenClass.method_2));
|
|
}
|
|
|
|
[PatchPrefix]
|
|
public static void PatchPrefix(ref ISession ___iSession)
|
|
{
|
|
Profile profile = new(GetProfileAtEndOfRaidPatch.ProfileDescriptor);
|
|
|
|
if (profile.Side != EPlayerSide.Savage)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var session = (ProfileEndpointFactoryAbstractClass)___iSession;
|
|
session.AllProfiles =
|
|
[
|
|
session.AllProfiles.First(x => x.Side != EPlayerSide.Savage),
|
|
profile
|
|
];
|
|
session.ProfileOfPet.LearnAll();
|
|
|
|
// make a request to the server, so it knows of the items we might transfer
|
|
RequestHandler.PutJson("/raid/profile/scavsave",
|
|
GetProfileAtEndOfRaidPatch.ProfileDescriptor.ToUnparsedData([]).JObject.ToString());
|
|
}
|
|
}
|
|
}
|