protected override void OnPrefabInit()
 {
     base.OnPrefabInit();
     Instance            = this;
     prevButton.onClick += delegate
     {
         ShowReport(currentReport.day - 1);
     };
     nextButton.onClick += delegate
     {
         ShowReport(currentReport.day + 1);
     };
     summaryButton.onClick += delegate
     {
         RetiredColonyData currentColonyRetiredColonyData = RetireColonyUtility.GetCurrentColonyRetiredColonyData();
         MainMenu.ActivateRetiredColoniesScreenFromData(PauseScreen.Instance.transform.parent.gameObject, currentColonyRetiredColonyData);
     };
     ConsumeMouseScroll = true;
 }
Exemple #2
0
        /// <summary>
        /// Checks the colony summary to guess the date of the last possible death.
        /// </summary>
        private void InitGrimReaper()
        {
            // Look for the last dip in Duplicant count
            float lastValue = -1.0f;

            RetiredColonyData.RetiredColonyStatistic[] stats;
            try {
                var data = RetireColonyUtility.GetCurrentColonyRetiredColonyData();
                if ((stats = data?.Stats) != null && data.cycleCount > 0)
                {
                    var liveDupes = new SortedList <int, float>(stats.Length);
                    // Copy and sort the values
                    foreach (var cycleData in stats)
                    {
                        if (cycleData.id == RetiredColonyData.DataIDs.LiveDuplicants)
                        {
                            foreach (var entry in cycleData.value)
                            {
                                liveDupes[Mathf.RoundToInt(entry.first)] = entry.second;
                            }
                            break;
                        }
                    }
                    LastDeath = 0;
                    // Sorted by cycle now
                    foreach (var pair in liveDupes)
                    {
                        float dupes = pair.Value;
                        if (dupes < lastValue)
                        {
                            LastDeath = pair.Key;
                        }
                        lastValue = dupes;
                    }
                    liveDupes.Clear();
                }
            } catch (Exception e) {
                PUtil.LogWarning("Unable to determine the last date of death:");
                PUtil.LogExcWarn(e);
                LastDeath = GameClock.Instance?.GetCycle() ?? 0;
            }
        }
 public override void Update()
 {
     if (lastDeath < 0)
     {
         // Look for the last dip in Duplicant count
         float lastValue = -1.0f;
         RetiredColonyData.RetiredColonyStatistic[] stats;
         var data = RetireColonyUtility.GetCurrentColonyRetiredColonyData();
         if ((stats = data?.Stats) != null && data.cycleCount > 0)
         {
             var liveDupes = new SortedList <int, float>(stats.Length);
             // Copy and sort the values
             foreach (var cycleData in stats)
             {
                 if (cycleData.id == RetiredColonyData.DataIDs.LiveDuplicants)
                 {
                     foreach (var entry in cycleData.value)
                     {
                         liveDupes[Mathf.RoundToInt(entry.first)] = entry.second;
                     }
                     break;
                 }
             }
             lastDeath = 0;
             // Sorted by cycle now
             foreach (var pair in liveDupes)
             {
                 float dupes = pair.Value;
                 if (dupes < lastValue)
                 {
                     lastDeath = pair.Key;
                 }
                 lastValue = dupes;
             }
             liveDupes.Clear();
         }
     }
 }
Exemple #4
0
    private void OnColonySummary()
    {
        RetiredColonyData currentColonyRetiredColonyData = RetireColonyUtility.GetCurrentColonyRetiredColonyData();

        MainMenu.ActivateRetiredColoniesScreenFromData(Instance.transform.parent.gameObject, currentColonyRetiredColonyData);
    }