mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-12 17:10:44 -05:00
Fix bots not spawning: Correctly look for public method + force bot to be cleared from client cache on spawn
This commit is contained in:
parent
610f5e596b
commit
c038c9fced
@ -23,8 +23,12 @@ namespace Aki.SinglePlayer.Patches.RaidFix
|
||||
|
||||
public GetNewBotTemplatesPatch()
|
||||
{
|
||||
_getNewProfileMethod = typeof(BotsPresets)
|
||||
.GetMethod(nameof(BotsPresets.GetNewProfile), PatchConstants.PrivateFlags);
|
||||
var desiredType = typeof(BotsPresets);
|
||||
_getNewProfileMethod = desiredType
|
||||
.GetMethod(nameof(BotsPresets.GetNewProfile), PatchConstants.PublicFlags);
|
||||
|
||||
Logger.LogDebug($"{this.GetType().Name} Type: {desiredType?.Name}");
|
||||
Logger.LogDebug($"{this.GetType().Name} Method: {_getNewProfileMethod?.Name}");
|
||||
}
|
||||
|
||||
protected override MethodBase GetTargetMethod()
|
||||
@ -43,7 +47,7 @@ namespace Aki.SinglePlayer.Patches.RaidFix
|
||||
}
|
||||
|
||||
[PatchPrefix]
|
||||
private static bool PatchPrefix(ref Task<Profile> __result, BotsPresets __instance, IBotData data)
|
||||
private static bool PatchPrefix(ref Task<Profile> __result, BotsPresets __instance, GClass626 data, bool withDelete)
|
||||
{
|
||||
/*
|
||||
in short when client wants new bot and GetNewProfile() return null (if not more available templates or they don't satisfy by Role and Difficulty condition)
|
||||
@ -58,7 +62,7 @@ namespace Aki.SinglePlayer.Patches.RaidFix
|
||||
|
||||
var taskScheduler = TaskScheduler.FromCurrentSynchronizationContext();
|
||||
var taskAwaiter = (Task<Profile>)null;
|
||||
var profile = (Profile)_getNewProfileMethod.Invoke(__instance, new object[] { data });
|
||||
var profile = (Profile)_getNewProfileMethod.Invoke(__instance, new object[] { data, true });
|
||||
|
||||
// load from server
|
||||
var source = data.PrepareToLoadBackend(1).ToList();
|
||||
|
@ -2,7 +2,6 @@ using Aki.Reflection.Patching;
|
||||
using Aki.Reflection.Utils;
|
||||
using EFT;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
@ -21,7 +20,7 @@ namespace Aki.SinglePlayer.Patches.RaidFix
|
||||
|
||||
_flags = BindingFlags.Instance | BindingFlags.NonPublic;
|
||||
_targetInterface = PatchConstants.EftTypes.Single(IsTargetInterface);
|
||||
_targetType = PatchConstants.EftTypes.Single(IsTargetType);
|
||||
_targetType = typeof(BotsPresets);
|
||||
_profilesField = _targetType.GetField("list_0", _flags);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user