2024-05-21 19:10:17 +01:00
|
|
|
using SPT.Reflection.Patching;
|
2023-03-03 18:52:31 +00:00
|
|
|
using Comfort.Common;
|
|
|
|
using EFT;
|
|
|
|
using System.Reflection;
|
2024-01-13 22:08:29 +00:00
|
|
|
using HarmonyLib;
|
2024-01-18 14:19:58 +00:00
|
|
|
using EFT.Interactive;
|
|
|
|
using System.Linq;
|
2023-03-03 18:52:31 +00:00
|
|
|
|
2024-05-21 19:10:17 +01:00
|
|
|
namespace SPT.SinglePlayer.Patches.ScavMode
|
2023-03-03 18:52:31 +00:00
|
|
|
{
|
|
|
|
/// <summary>
|
2024-09-25 19:17:10 +01:00
|
|
|
/// Disable PMC exfil points when playing as pscav, without this patch PMC extracts do not show in the side menu but can be extracted from
|
2023-03-03 18:52:31 +00:00
|
|
|
/// </summary>
|
2024-07-12 15:59:37 +01:00
|
|
|
public class DisablePMCExtractsForScavsPatch : ModulePatch
|
2023-03-03 18:52:31 +00:00
|
|
|
{
|
|
|
|
protected override MethodBase GetTargetMethod()
|
|
|
|
{
|
2024-01-13 22:08:29 +00:00
|
|
|
return AccessTools.Method(typeof(GameWorld), nameof(GameWorld.OnGameStarted));
|
2023-03-03 18:52:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[PatchPostfix]
|
|
|
|
public static void PatchPostFix()
|
|
|
|
{
|
|
|
|
var gameWorld = Singleton<GameWorld>.Instance;
|
|
|
|
|
2024-01-13 22:08:29 +00:00
|
|
|
// checks nothing is null otherwise bad things happen
|
2023-03-03 18:52:31 +00:00
|
|
|
if (gameWorld == null || gameWorld.RegisteredPlayers == null || gameWorld.ExfiltrationController == null)
|
|
|
|
{
|
2024-01-13 22:08:29 +00:00
|
|
|
Logger.LogError("Could not find GameWorld or RegisterPlayers... Unable to disable extracts for Scav raid");
|
2023-03-03 18:52:31 +00:00
|
|
|
}
|
|
|
|
|
2023-07-07 10:37:47 +01:00
|
|
|
Player player = gameWorld.MainPlayer;
|
2023-03-03 18:52:31 +00:00
|
|
|
|
2024-01-13 22:08:29 +00:00
|
|
|
// Only disable PMC extracts if current player is a scav
|
2023-03-03 18:52:31 +00:00
|
|
|
if (player.Fraction == ETagStatus.Scav && player.Location != "hideout")
|
|
|
|
{
|
2024-01-13 22:08:29 +00:00
|
|
|
foreach (var exfil in gameWorld.ExfiltrationController.ExfiltrationPoints)
|
2023-03-03 18:52:31 +00:00
|
|
|
{
|
2024-01-18 14:19:58 +00:00
|
|
|
if (exfil is ScavExfiltrationPoint scavExfil)
|
|
|
|
{
|
|
|
|
// We are checking if player exists in list so we dont disable the wrong extract
|
|
|
|
if(!scavExfil.EligibleIds.Contains(player.ProfileId))
|
|
|
|
{
|
2024-09-24 13:40:34 +01:00
|
|
|
Logger.LogError($"Disabled exfil: {exfil.name}");
|
2024-01-18 14:19:58 +00:00
|
|
|
exfil.Disable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Disabling extracts that aren't scav extracts
|
|
|
|
exfil.Disable();
|
|
|
|
// _authorityToChangeStatusExternally Changing this to false stop buttons from re-enabling extracts (d-2 extract, zb-013)
|
|
|
|
exfil.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance).First(x => x.Name == "_authorityToChangeStatusExternally").SetValue(exfil, false);
|
|
|
|
}
|
2023-03-03 18:52:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|