-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLowOxygenAlert.cs
36 lines (31 loc) · 1.31 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
33
34
35
36
using HarmonyLib;
using UnityEngine;
namespace HardcoreWarnings
{
[HarmonyPatch(typeof(LowOxygenAlert))]
[HarmonyPatch("Update")]
internal class LowOxygenAlert_Update_Patch
{
[HarmonyPrefix]
public static bool Prefix(LowOxygenAlert __instance, ref Utils.ScalarMonitor ___secondsMonitor, Player ___player, ref float ___lastOxygenCapacity)
{
___secondsMonitor.Update(___player.GetOxygenAvailable());
float oxygenCapacity = ___player.GetOxygenCapacity();
if (Utils.NearlyEqual(oxygenCapacity, ___lastOxygenCapacity, 1.401298E-45f) || oxygenCapacity < ___lastOxygenCapacity)
{
for (int i = __instance.alertList.Count - 1; i >= 0; i--)
{
LowOxygenAlert.Alert alert = __instance.alertList[i];
if (oxygenCapacity >= alert.minO2Capacity && ___secondsMonitor.JustDroppedBelow((float)alert.oxygenTriggerSeconds) && Ocean.main.GetDepthOf(Utils.GetLocalPlayer()) > alert.minDepth && (___player.IsSwimming() || (___player.GetMode() == Player.Mode.LockedPiloting && !___player.GetVehicle().IsPowered()) || (___player.IsInSub() && !___player.CanBreathe())))
{
Subtitles.main.Add(alert.notification.text);
alert.soundSFX.Play();
break;
}
}
}
___lastOxygenCapacity = oxygenCapacity;
return false;
}
}
}