0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 09:50:43 -05:00
modules/project/Aki.Custom/BTR/Patches/BTRControllerInitPatch.cs
Arys c5a0c6998d Fixed BTR exceptions introduced by previous commit (!107)
Todo:

- Fix BTR spawning in and driving around at a weird angle
  - Perhaps because the serverside BTR is missing an instance of `VehicleSuspension`
- Randomise BTR spawn time instead of always spawning at raid start
- Add spawn chance for BTR instead of guaranteed spawn in raid
- Test BTR trader services

Reviewed-on: SPT-AKI/Modules#107
Co-authored-by: Arys <arys@noreply.dev.sp-tarkov.com>
Co-committed-by: Arys <arys@noreply.dev.sp-tarkov.com>
2024-04-07 08:05:07 +00:00

35 lines
1.0 KiB
C#

using Aki.Reflection.Patching;
using HarmonyLib;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
namespace Aki.Custom.BTR.Patches
{
public class BTRControllerInitPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.FirstMethod(typeof(BTRControllerClass), IsTargetMethod);
}
private bool IsTargetMethod(MethodInfo method)
{
ParameterInfo[] parameters = method.GetParameters();
return method.ReturnType == typeof(Task)
&& parameters.Length == 1
&& parameters[0].ParameterType == typeof(CancellationToken);
}
[PatchPrefix]
private static bool PatchPrefix(ref Task __result)
{
// The BTRControllerClass constructor expects the original method to return a Task,
// as it calls another method on said Task.
__result = Task.CompletedTask;
return false;
}
}
}