示例#1
0
        public override void Process(TimeChange timeChangePacket)
        {
            double oldTimePassedAsDouble = DayNightCycle.main.timePassedAsDouble;
            double newTimePassedAsDouble = timeChangePacket.CurrentTime;

            DayNightCycle.main.timePassedAsDouble = newTimePassedAsDouble;
            DayNightCycle.main.StopSkipTimeMode();

            if (timeChangePacket.InitialSync)
            {
                AuroraWarnings auroraWarnings = GameObject.Find("Player/SpawnPlayerSounds/PlayerSounds(Clone)/auroraWarnings").GetComponent <AuroraWarnings>();

                Utils.ScalarMonitor auroraTimeMonitor = auroraWarnings.timeMonitor;
                auroraTimeMonitor.Init((float)newTimePassedAsDouble);

                Utils.ScalarMonitor crashedTimeMonitor = CrashedShipExploder.main.timeMonitor;
                crashedTimeMonitor.Init((float)newTimePassedAsDouble);
            }

            Log.Info($"Processed a Time Change [from {oldTimePassedAsDouble} to {DayNightCycle.main.timePassedAsDouble}]");
        }
        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.GetDepthOf(Utils.GetLocalPlayer()) > alert.minDepth && (___player.IsSwimming() || (___player.GetMode() == Player.Mode.LockedPiloting && !___player.GetVehicle().IsPowered()) || (___player.IsInSub() && !___player.CanBreathe())))
                    {
                        Subtitles.Add(alert.notification.text);
                        alert.soundSFX.Play();
                        break;
                    }
                }
            }
            ___lastOxygenCapacity = oxygenCapacity;
            return(false);
        }