2021-04-12 10:31:21 +00:00
|
|
|
|
using QSB.Events;
|
|
|
|
|
using QSB.Patches;
|
2021-04-12 11:02:08 +00:00
|
|
|
|
using UnityEngine;
|
2021-04-12 10:31:21 +00:00
|
|
|
|
|
|
|
|
|
namespace QSB.ShipSync.Patches
|
|
|
|
|
{
|
|
|
|
|
class ShipPatches : QSBPatch
|
|
|
|
|
{
|
|
|
|
|
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
|
|
|
|
|
|
2021-04-12 10:43:22 +00:00
|
|
|
|
public override void DoPatches()
|
|
|
|
|
{
|
|
|
|
|
QSBCore.HarmonyHelper.AddPrefix<HatchController>("OnPressInteract", typeof(ShipPatches), nameof(HatchController_OnPressInteract));
|
|
|
|
|
QSBCore.HarmonyHelper.AddPrefix<HatchController>("OnEntry", typeof(ShipPatches), nameof(HatchController_OnEntry));
|
|
|
|
|
}
|
2021-04-12 10:31:21 +00:00
|
|
|
|
|
2021-04-12 10:43:22 +00:00
|
|
|
|
public override void DoUnpatches()
|
|
|
|
|
{
|
|
|
|
|
QSBCore.HarmonyHelper.Unpatch<HatchController>("OnPressInteract");
|
|
|
|
|
QSBCore.HarmonyHelper.Unpatch<HatchController>("OnEntry");
|
|
|
|
|
}
|
2021-04-12 10:31:21 +00:00
|
|
|
|
|
|
|
|
|
public static bool HatchController_OnPressInteract()
|
|
|
|
|
{
|
2021-04-12 10:43:22 +00:00
|
|
|
|
QSBEventManager.FireEvent(EventNames.QSBHatchState, true);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-12 11:02:08 +00:00
|
|
|
|
public static bool HatchController_OnEntry(GameObject hitObj)
|
2021-04-12 10:43:22 +00:00
|
|
|
|
{
|
|
|
|
|
if (hitObj.CompareTag("PlayerDetector"))
|
|
|
|
|
{
|
|
|
|
|
QSBEventManager.FireEvent(EventNames.QSBHatchState, false);
|
|
|
|
|
}
|
2021-04-12 10:31:21 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|