public static bool PlayReachSurfaceSound(WaterAmbience __instance)
        {
            if (!IsRadiativeAir(Player.main))
            {
                return(true);
            }

            var time = __instance.GetType().GetField("timeReachSurfaceSoundPlayed", System.Reflection.BindingFlags.NonPublic
                                                     | System.Reflection.BindingFlags.Instance);

            if (Time.time < (float)time.GetValue(__instance) + 1f)
            {
                return(false);
            }

            // Skip other sounds as they are dependent on breathing

            time.SetValue(__instance, Time.time);
            __instance.reachSurfaceWithTank.Play(); // Different sound so no splash

            return(false);
        }
예제 #2
0
        public static bool PlayReachSurfaceSound(WaterAmbience __instance)
        {
            if (!isAirPoisoned(Player.main))
            {
                if (!isSurfaceAirPoisoned() && !Player.main.IsInside() && (Ocean.main.GetDepthOf(Player.main.gameObject) < 5))
                {
                    if (warnedNotBreathable)
                    {
                        warnedNotBreathable = true;
                        warningTime         = Time.time;
                        ErrorMessage.AddMessage("You find the surface air is now breathable!");
                    }
                }

                return(true);
            }

            // If we're at a pipe so we can actually breathe, treat it normally.
            if (DeathRun.saveData.nitroSave.atPipe)
            {
                return(true);
            }

            if (Player.main.currentMountedVehicle != null)
            {
                return(true);
            }

            // Smoke choke sounds in unbreathable atmosphere
            PlayerDamageSounds s = Player.main.gameObject.GetComponent <PlayerDamageSounds>();

            if (s != null)
            {
                s.painSmoke.Play();
            }

            if (!Config.NEVER.Equals(DeathRun.config.showWarnings))
            {
                if (!warnedNotBreathable ||
                    Config.WHENEVER.Equals(DeathRun.config.showWarnings) ||
                    (Config.OCCASIONAL.Equals(DeathRun.config.showWarnings) && (Time.time > warningTime + 300)))
                {
                    if (!warnedNotBreathable || (Time.time > warningTime + 30f))
                    {
                        warnedNotBreathable = true;
                        warningTime         = Time.time;
                        if (Config.POISONED.Equals(DeathRun.config.surfaceAir))
                        {
                            DeathRunUtils.CenterMessage("WARNING! Surface air not breathable!", 5);
                            DeathRunUtils.CenterMessage("A Floating Pump could filter it.", 5, 1);

                            ErrorMessage.AddMessage("WARNING! The surface air on this planet is not breathable!");
                            ErrorMessage.AddMessage("Use of a Floating Pump could filter it however.");
                        }
                        else
                        {
                            DeathRunUtils.CenterMessage("WARNING! Surface air now too irradiated to breathe!", 5);
                            DeathRunUtils.CenterMessage("A Floating Pump could filter it.", 5, 1);

                            ErrorMessage.AddMessage("The surface air is now too irradiated to breathe!");
                        }
                    }
                }
            }

            var time = __instance.GetType().GetField("timeReachSurfaceSoundPlayed", System.Reflection.BindingFlags.NonPublic
                                                     | System.Reflection.BindingFlags.Instance);

            if (Time.time < (float)time.GetValue(__instance) + 1f)
            {
                return(false);
            }

            // Skip other sounds as they are dependent on breathing

            time.SetValue(__instance, Time.time);
            __instance.reachSurfaceWithTank.Play(); // Different sound so no splash

            return(false);
        }