39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using Aki.Reflection.Patching;
|
|
using Aki.Reflection.Utils;
|
|
using Comfort.Common;
|
|
using EFT;
|
|
using EFT.Airdrop;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using UnityEngine;
|
|
|
|
namespace SamSWAT.HeliCrash
|
|
{
|
|
public class HeliCrashPatch : ModulePatch
|
|
{
|
|
protected override MethodBase GetTargetMethod()
|
|
{
|
|
return PatchConstants.LocalGameType.BaseType.GetMethod("method_11", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
}
|
|
|
|
[PatchPostfix]
|
|
public static void PatchPostfix()
|
|
{
|
|
var gameWorld = Singleton<GameWorld>.Instance;
|
|
bool crashAvailable = LocationScene.GetAll<AirdropPoint>().Any();
|
|
string location = gameWorld.RegisteredPlayers[0].Location;
|
|
|
|
if (gameWorld != null && crashAvailable && WillHeliCrash())
|
|
{
|
|
var heliCrash = gameWorld.gameObject.AddComponent<HeliCrash>();
|
|
heliCrash.Init(location);
|
|
}
|
|
}
|
|
|
|
private static bool WillHeliCrash()
|
|
{
|
|
return Random.Range(0, 100) <= Plugin.HeliCrashChance.Value;
|
|
}
|
|
}
|
|
}
|