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
|
|
|
|
|
{
|
2024-11-01 13:23:31 +00:00
|
|
|
|
public static GClass1962 ProfileDescriptor { get; private set; }
|
|
|
|
|
|
2024-07-09 10:33:42 +01:00
|
|
|
|
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 13:23:31 +00:00
|
|
|
|
ProfileDescriptor = new GClass1962(__instance.Profile_0, GClass1971.Instance);
|
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
|
|
|
|
{
|
2024-11-01 13:23:31 +00:00
|
|
|
|
Profile profile = new(GetProfileAtEndOfRaidPatch.ProfileDescriptor);
|
|
|
|
|
|
|
|
|
|
if (profile.Side != EPlayerSide.Savage)
|
2024-07-09 10:33:42 +01:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-07-12 16:29:50 +01:00
|
|
|
|
|
2024-07-09 10:33:42 +01:00
|
|
|
|
var session = (ProfileEndpointFactoryAbstractClass)___iSession;
|
2024-11-01 13:23:31 +00:00
|
|
|
|
session.AllProfiles =
|
|
|
|
|
[
|
|
|
|
|
session.AllProfiles.First(x => x.Side != EPlayerSide.Savage),
|
2024-07-09 10:33:42 +01:00
|
|
|
|
profile
|
2024-11-01 13:23:31 +00:00
|
|
|
|
];
|
2024-08-20 20:25:53 +01:00
|
|
|
|
session.ProfileOfPet.LearnAll();
|
2024-11-01 13:23:31 +00:00
|
|
|
|
|
|
|
|
|
// 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());
|
2024-07-09 10:33:42 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|