Esempio n. 1
0
        /**
         * Update the ship countdown display text
         */
        static void updateShip(ref uGUI_SunbeamCountdown __instance, float timeLeft)
        {
            TimeSpan timeSpan = TimeSpan.FromSeconds((double)timeLeft);
            string   text     = string.Format("{0:D2}:{1:D2}:{2:D2}", timeSpan.Hours, timeSpan.Minutes, timeSpan.Seconds);

            __instance.countdownText.text = text;
        }
Esempio n. 2
0
 /**
  * Hide the ship countdown if we're currently showing it
  */
 static void hideShip(ref uGUI_SunbeamCountdown __instance)
 {
     if (!showingShip)
     {
         return;
     }
     __instance.countdownHolder.SetActive(false);
     showingShip = false;
 }
        public static void uGUI_SunbeamCountdown_Start_Postfix(uGUI_SunbeamCountdown __instance)
        {
            Vector2 midCenter = new Vector2(0.5f, 0.5f);

            __instance.countdownHolder.GetComponent <RectTransform>().anchorMax        = midCenter;
            __instance.countdownHolder.GetComponent <RectTransform>().anchorMin        = midCenter;
            __instance.countdownHolder.GetComponent <RectTransform>().pivot            = midCenter;
            __instance.countdownHolder.GetComponent <RectTransform>().anchoredPosition = new Vector2(0f, -275f);
            __instance.countdownHolder.GetComponent <RectTransform>().localScale       = Vector3.one * 0.75f;
            __instance.transform.Find("Background").GetComponent <CanvasRenderer>().SetAlpha(0f);
        }
Esempio n. 4
0
        /**
         * Show the ship countdown, if not already showing
         */
        static void showShip(ref uGUI_SunbeamCountdown __instance)
        {
            if (showingShip)
            {
                return;
            }

            __instance.countdownTitle.text = "Drive Core Explosion";
            __instance.countdownHolder.SetActive(true);

            showingShip = true;
        }
Esempio n. 5
0
        /**
         * Returns true if we're currently showing the Sunbeam Arrival countdown
         */
        static bool isSunbeamShowing(uGUI_SunbeamCountdown __instance)
        {
            StoryGoalCustomEventHandler main = StoryGoalCustomEventHandler.main;

            return(main && main.countdownActive);
        }
Esempio n. 6
0
        public static void Postfix(ref uGUI_SunbeamCountdown __instance)
        {
            if (DayNightCycle.main == null)
            {
                return;
            }
            if (CrashedShipExploder.main == null)
            {
                return;
            }

            // These are the internal parameters for the Aurora story events (see AuroraWarnings for time thresholds)
            float timeToStartWarning   = CrashedShipExploder.main.GetTimeToStartWarning();
            float timeToStartCountdown = CrashedShipExploder.main.GetTimeToStartCountdown();
            float timeNow = DayNightCycle.main.timePassedAsFloat;

            DeathRun.countdownMonitor.Update(timeNow);

            int deep;

            if (Config.EXPLOSION_DEATHRUN.Equals(DeathRun.config.explodeDepth))
            {
                deep = 100;
            }
            else if (Config.EXPLOSION_HARD.Equals(DeathRun.config.explodeDepth))
            {
                deep = 50;
            }
            else
            {
                deep = 0;
            }

            if (deep > 0)
            {
                // At time of second Aurora warning
                if (DeathRun.countdownMonitor.JustWentAbove(Mathf.Lerp(timeToStartWarning, timeToStartCountdown, 0.5f)))
                {
                    DeathRunUtils.CenterMessage("Explosion Shockwave Will Be", MESSAGE_TIME);
                    DeathRunUtils.CenterMessage("Over " + deep + "m Deep!", MESSAGE_TIME, 1);
                }

                if (DeathRun.countdownMonitor.JustWentAbove(Mathf.Lerp(timeToStartWarning, timeToStartCountdown, 0.5f) + MESSAGE_TIME))
                {
                    ErrorMessage.AddMessage("WARNING: Explosion will produce shockwave over " + deep + "m deep!");
                }

                // At time of third Aurora warning
                if (DeathRun.countdownMonitor.JustWentAbove(Mathf.Lerp(timeToStartWarning, timeToStartCountdown, 0.8f)))
                {
                    DeathRunUtils.CenterMessage("Prepare To Evacuate At Least", MESSAGE_TIME);
                    DeathRunUtils.CenterMessage("" + deep + "m Deep. Preferably Inside.", MESSAGE_TIME, 1);
                }

                if (DeathRun.countdownMonitor.JustWentAbove(Mathf.Lerp(timeToStartWarning, timeToStartCountdown, 0.8f) + MESSAGE_TIME))
                {
                    ErrorMessage.AddMessage("Prepare to evacuate at least " + deep + "m deep, preferably inside!");
                }

                // At time of final countdown
                if (DeathRun.countdownMonitor.JustWentAbove(timeToStartCountdown))
                {
                    DeathRunUtils.CenterMessage("Seek Safe Depth Immediately!", MESSAGE_TIME);
                    DeathRunUtils.CenterMessage("Preferably Inside!", MESSAGE_TIME, 1);
                }

                if (DeathRun.countdownMonitor.JustWentAbove(timeToStartCountdown + MESSAGE_TIME))
                {
                    ErrorMessage.AddMessage("Seek safe depth immediately! Preferably inside!");
                }
            }

            deep = (int)RadiationUtils.getRadiationMaxDepth();
            if (deep > 0)
            {
                if (DeathRun.countdownMonitor.JustWentAbove(timeToStartCountdown + 100f))
                {
                    DeathRunUtils.CenterMessage("Radiation Will Gradually Permeate", MESSAGE_TIME);
                    DeathRunUtils.CenterMessage("Ocean As Deep As " + deep + "m.", MESSAGE_TIME, 1);
                }
                if (DeathRun.countdownMonitor.JustWentAbove(timeToStartCountdown + 100f + MESSAGE_TIME))
                {
                    ErrorMessage.AddMessage("Radiation will gradually permeate the sea, as deep as " + deep + "m.");
                }

                if (DeathRun.countdownMonitor.JustWentAbove(timeToStartCountdown + 100f + MESSAGE_TIME * 2))
                {
                    DeathRunUtils.CenterMessage("All devices will consume power more rapidly", MESSAGE_TIME);
                    DeathRunUtils.CenterMessage("while exposed to RADIATION, and recharge slowly.", MESSAGE_TIME, 1);
                }

                if (DeathRun.countdownMonitor.JustWentAbove(timeToStartCountdown + 100f + MESSAGE_TIME * 3))
                {
                    ErrorMessage.AddMessage("All devices will consume power more rapidly while exposed to RADIATION and recharge slowly.");
                }
            }

            // If the Sunbeam rescue timer is showing, give that precedence over our countdown timer.
            if (isSunbeamShowing(__instance))
            {
                showingShip = false;
                return;
            }

            // This is the time of the very first warning about the Aurora
            if (timeNow >= Mathf.Lerp(timeToStartWarning, timeToStartCountdown, 0.2f) && // Time of first Aurora warning
                (timeNow < timeToStartCountdown + 24f))                                  // Actual explosion time (24 sec after countdown)
            {
                float timeLeft = (timeToStartCountdown + 24f) - timeNow;
                if (timeLeft < 0)
                {
                    timeLeft *= -1;
                }
                showShip(ref __instance);
                updateShip(ref __instance, timeLeft);
            }
            else
            {
                hideShip(ref __instance);
            }
        }