0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 09:50:43 -05:00
modules/project/Aki.Custom/Airdrops/Patches/AirdropFlarePatch.cs
2023-03-03 18:52:31 +00:00

32 lines
1.0 KiB
C#

using Aki.Reflection.Patching;
using Comfort.Common;
using EFT;
using EFT.Airdrop;
using System.Linq;
using System.Reflection;
namespace Aki.Custom.Airdrops.Patches
{
public class AirdropFlarePatch : ModulePatch
{
private static readonly string[] _usableFlares = { "624c09cfbc2e27219346d955", "62389ba9a63f32501b1b4451" };
protected override MethodBase GetTargetMethod()
{
return typeof(FlareCartridge).GetMethod(nameof(FlareCartridge.Init),
BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
}
[PatchPostfix]
private static void PatchPostfix(BulletClass flareCartridge)
{
var gameWorld = Singleton<GameWorld>.Instance;
var points = LocationScene.GetAll<AirdropPoint>().Any();
if (gameWorld != null && points && _usableFlares.Any(x => x == flareCartridge.Template._id))
{
gameWorld.gameObject.AddComponent<AirdropsManager>().isFlareDrop = true;
}
}
}
}