2022-05-08 01:48:04 +03:00
|
|
|
|
using Aki.Reflection.Patching;
|
2022-09-02 02:28:40 +03:00
|
|
|
|
using Aki.Reflection.Utils;
|
2022-05-08 01:48:04 +03:00
|
|
|
|
using Comfort.Common;
|
|
|
|
|
using EFT;
|
2022-09-02 02:28:40 +03:00
|
|
|
|
using EFT.Airdrop;
|
2022-05-08 01:48:04 +03:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace SamSWAT.HeliCrash
|
|
|
|
|
{
|
|
|
|
|
public class HeliCrashPatch : ModulePatch
|
|
|
|
|
{
|
|
|
|
|
protected override MethodBase GetTargetMethod()
|
|
|
|
|
{
|
2023-06-29 19:30:53 +03:00
|
|
|
|
//return PatchConstants.LocalGameType.BaseType.GetMethod("method_10", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
|
|
|
return typeof(GameWorld).GetMethod(nameof(GameWorld.OnGameStarted));
|
2022-05-08 01:48:04 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[PatchPostfix]
|
2022-09-02 02:28:40 +03:00
|
|
|
|
public static void PatchPostfix()
|
2022-05-08 01:48:04 +03:00
|
|
|
|
{
|
|
|
|
|
var gameWorld = Singleton<GameWorld>.Instance;
|
2023-06-29 19:30:53 +03:00
|
|
|
|
var crashAvailable = LocationScene.GetAll<AirdropPoint>().Any();
|
|
|
|
|
var location = gameWorld.RegisteredPlayers[0].Location;
|
|
|
|
|
|
|
|
|
|
if (gameWorld == null || !crashAvailable || !BlessRNG.RngBool(Plugin.HeliCrashChance.Value)) return;
|
|
|
|
|
|
|
|
|
|
var heliCrash = gameWorld.gameObject.AddComponent<HeliCrash>();
|
|
|
|
|
heliCrash.Init(location);
|
2022-05-08 01:48:04 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|