-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLowOxygenAlert.cs
32 lines (30 loc) · 1.38 KB
/
LowOxygenAlert.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using HarmonyLib;
namespace O2AlertsInHardcore
{
[HarmonyPatch(typeof(LowOxygenAlert))]
[HarmonyPatch("Update")]
internal class LowOxygenAlert_Update_Patch
{
[HarmonyPrefix]
public static bool Prefix(LowOxygenAlert __instance)
{
__instance.secondsMonitor.Update(__instance.player.GetOxygenAvailable());
float oxygenCapacity = __instance.player.GetOxygenCapacity();
if (Utils.NearlyEqual(oxygenCapacity, __instance.lastOxygenCapacity, 1E-45f) || oxygenCapacity < __instance.lastOxygenCapacity)
{
for (int i = __instance.alertList.Count - 1; i >= 0; i--)
{
LowOxygenAlert.Alert alert = __instance.alertList[i];
if (oxygenCapacity >= alert.minO2Capacity && __instance.secondsMonitor.JustDroppedBelow((float)alert.oxygenTriggerSeconds) && Ocean.GetDepthOf(Utils.GetLocalPlayer()) > alert.minDepth && (__instance.player.IsSwimming() || (__instance.player.GetMode() == Player.Mode.LockedPiloting && !__instance.player.IsInsidePoweredVehicle()) || (__instance.player.IsInSub() && !__instance.player.CanBreathe())))
{
Subtitles.Add(alert.notification.text, null);
alert.soundSFX.Play();
break;
}
}
}
__instance.lastOxygenCapacity = oxygenCapacity;
return true;
}
}
}