2024-07-09 10:33:42 +01:00
|
|
|
|
using EFT;
|
|
|
|
|
using HarmonyLib;
|
|
|
|
|
using SPT.Reflection.Patching;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System.Linq;
|
2024-11-01 11:35:41 +00:00
|
|
|
|
using Newtonsoft.Json;
|
2024-07-12 16:29:50 +01:00
|
|
|
|
using SPT.Common.Http;
|
2024-11-01 11:35:41 +00:00
|
|
|
|
using System;
|
2024-07-09 10:33:42 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace SPT.SinglePlayer.Patches.ScavMode
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Get Profile at LocalGame End to use in FixSavageInventoryScreenPatch
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class GetProfileAtEndOfRaidPatch : ModulePatch
|
|
|
|
|
{
|
|
|
|
|
public static string Profile { get; private set; }
|
|
|
|
|
protected override MethodBase GetTargetMethod()
|
|
|
|
|
{
|
|
|
|
|
return AccessTools.Method(typeof(LocalGame), nameof(LocalGame.Stop));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[PatchPrefix]
|
2024-08-02 16:57:59 +01:00
|
|
|
|
public static void PatchPrefix(LocalGame __instance)
|
2024-07-09 10:33:42 +01:00
|
|
|
|
{
|
2024-11-01 11:35:41 +00:00
|
|
|
|
//var test = new GClass1962(__instance.Profile_0, GClass1971.Instance);
|
|
|
|
|
//Profile = test.ToUnparsedData([]);
|
2024-07-09 10:33:42 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <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]
|
2024-08-02 16:57:59 +01:00
|
|
|
|
public static void PatchPrefix(ref ISession ___iSession)
|
2024-07-09 10:33:42 +01:00
|
|
|
|
{
|
|
|
|
|
var profile = GetProfileAtEndOfRaidPatch.Profile.ParseJsonTo<Profile>();
|
2024-07-12 16:29:50 +01:00
|
|
|
|
|
2024-07-09 10:33:42 +01:00
|
|
|
|
if (profile.Side != EPlayerSide.Savage)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-07-12 16:29:50 +01:00
|
|
|
|
|
2024-07-09 10:33:42 +01:00
|
|
|
|
var session = (ProfileEndpointFactoryAbstractClass)___iSession;
|
|
|
|
|
session.AllProfiles = new Profile[]
|
|
|
|
|
{
|
|
|
|
|
session.AllProfiles.First(x => x.Side != EPlayerSide.Savage),
|
|
|
|
|
profile
|
|
|
|
|
};
|
2024-08-20 20:25:53 +01:00
|
|
|
|
session.ProfileOfPet.LearnAll();
|
2024-07-12 16:29:50 +01:00
|
|
|
|
|
|
|
|
|
// make a request to the server, so it knows of the items we might transfer
|
|
|
|
|
RequestHandler.PutJson("/raid/profile/scavsave", new
|
|
|
|
|
{
|
|
|
|
|
profile = session.ProfileOfPet
|
|
|
|
|
}
|
|
|
|
|
.ToJson());
|
2024-07-09 10:33:42 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|