Exemple #1
0
            public static void Postfix(ReportManager __instance, ref List <ReportManager.DailyReport> ___dailyReports)
            {
                try
                {
                    var missingCycles = GameUtil.GetCurrentCycle() - ___dailyReports.Count();

                    if (missingCycles > 0)
                    {
                        var missingDailyReports = new ReportManager.DailyReport[missingCycles];

                        for (int i = 0; i < missingCycles; i++)
                        {
                            var newDailyReport = new ReportManager.DailyReport(__instance)
                            {
                                day = i
                            };
                            newDailyReport.reportEntries.Clear();
                            missingDailyReports[i] = newDailyReport;
                        }
                        ___dailyReports.InsertRange(0, missingDailyReports);
                    }
                }
                catch (Exception e)
                {
                    Debug.Log("RDR: Error while trying to fix missing daily reports: " + e);
                }
            }
Exemple #2
0
        public override bool Success()
        {
            float num = 0f;

            ReportManager.DailyReport todaysReport = ReportManager.Instance.TodaysReport;
            ReportManager.ReportEntry entry        = todaysReport.GetEntry(ReportManager.ReportType.ChoreStatus);
            for (int i = 0; i < entry.contextEntries.Count; i++)
            {
                ReportManager.ReportEntry reportEntry = entry.contextEntries[i];
                if (reportEntry.context == Db.Get().ChoreTypes.PowerTinker.Name)
                {
                    num += reportEntry.Negative;
                }
            }
            for (int j = 0; j < ReportManager.Instance.reports.Count; j++)
            {
                for (int k = 0; k < ReportManager.Instance.reports[j].GetEntry(ReportManager.ReportType.ChoreStatus).contextEntries.Count; k++)
                {
                    ReportManager.ReportEntry reportEntry2 = ReportManager.Instance.reports[j].GetEntry(ReportManager.ReportType.ChoreStatus).contextEntries[k];
                    if (reportEntry2.context == Db.Get().ChoreTypes.PowerTinker.Name)
                    {
                        num += reportEntry2.Negative;
                    }
                }
            }
            choresCompleted = Math.Abs(num);
            return(Math.Abs(num) >= numChoreseToComplete);
        }
 protected override void OnShow(bool bShow)
 {
     base.OnShow(bShow);
     if ((Object)ReportManager.Instance != (Object)null)
     {
         currentReport = ReportManager.Instance.TodaysReport;
     }
 }
Exemple #4
0
            /// <summary>
            /// Applied after Refresh runs.
            /// </summary>
            internal static void Postfix(ReportManager.DailyReport ___currentReport,
                                         KButton ___prevButton)
            {
                int prevDay = ___currentReport.day - 1;

                if (ReportManager.Instance.FindReport(prevDay) == null)
                {
                    // Do not allow previous day if it cannot be found
                    ___prevButton.isInteractable = false;
                }
            }
Exemple #5
0
 /// <summary>
 /// Calculates how many calories were produced and consumed in the specified cycle.
 /// </summary>
 /// <param name="report">The report to analyze.</param>
 /// <param name="produced">The location where the produced kcal will be stored.</param>
 /// <param name="consumed">The location where the consumed kcal will be stored.</param>
 private static void GetCalorieDeltas(ReportManager.DailyReport report,
                                      out float produced, out float consumed)
 {
     ReportManager.ReportEntry entry;
     if ((entry = report?.GetEntry(ReportManager.ReportType.CaloriesCreated)) != null)
     {
         // Consumption is negative
         produced = entry.accPositive;
         consumed = -entry.accNegative;
     }
     else
     {
         produced = 0.0f;
         consumed = 0.0f;
     }
 }
Exemple #6
0
    private List <DailyReportMetricsData> GetDailyReportMetrics()
    {
        List <DailyReportMetricsData> list = new List <DailyReportMetricsData>();
        int cycle = GameClock.Instance.GetCycle();

        ReportManager.DailyReport dailyReport = ReportManager.Instance.FindReport(cycle);
        if (dailyReport != null)
        {
            foreach (ReportManager.ReportEntry reportEntry in dailyReport.reportEntries)
            {
                DailyReportMetricsData item = default(DailyReportMetricsData);
                item.Name = reportEntry.reportType.ToString();
                if (!float.IsInfinity(reportEntry.Net) && !float.IsNaN(reportEntry.Net))
                {
                    item.Net = reportEntry.Net;
                }
                if (force_infinity)
                {
                    item.Net = null;
                }
                if (!float.IsInfinity(reportEntry.Positive) && !float.IsNaN(reportEntry.Positive))
                {
                    item.Positive = reportEntry.Positive;
                }
                if (!float.IsInfinity(reportEntry.Negative) && !float.IsNaN(reportEntry.Negative))
                {
                    item.Negative = reportEntry.Negative;
                }
                list.Add(item);
            }
            list.Add(new DailyReportMetricsData
            {
                Name     = "MinionCount",
                Net      = new float?((float)Components.LiveMinionIdentities.Count),
                Positive = new float?(0f),
                Negative = new float?(0f)
            });
        }
        return(list);
    }
Exemple #7
0
 internal SimpleInfoScreenWrapper()
 {
     allGeysers      = null;
     conditionParent = null;
     labelCache      = new Dictionary <string, CachedStorageLabel>(64);
     lastReport      = null;
     lastSelection   = default;
     lastStressEntry = null;
     processHeaders  = new List <ProcessConditionRow>(8);
     processRows     = new List <ProcessConditionRow>(24);
     processVisible  = new List <ProcessConditionRow>(32);
     rocketLabels    = new HashSet <CachedStorageLabel>();
     setInactive     = new HashSet <CachedStorageLabel>();
     statusActive    = false;
     storages        = new List <Storage>(8);
     storageActive   = false;
     storageLabels   = new HashSet <CachedStorageLabel>();
     storageParent   = null;
     stressActive    = false;
     vitalsActive    = false;
     wasPaused       = false;
     instance        = this;
 }
Exemple #8
0
        /// <summary>
        /// Refreshes the parts of the info screen that are only updated when a different item
        /// is selected.
        /// </summary>
        /// <param name="target">The selected target object.</param>
        private void OnSelectTarget(GameObject target)
        {
            lastReport = null;
            storages.Clear();
            if (target == null)
            {
                lastSelection = default;
                vitalsActive  = false;
            }
            else
            {
                var found = ListPool <Storage, SimpleInfoScreen> .Allocate();

                lastSelection = new LastSelectionDetails(target);
                target.GetComponentsInChildren(found);
                // Add only storages that should be shown
                int n = found.Count;
                for (int i = 0; i < n; i++)
                {
                    var storage = found[i];
                    if (storage != null && storage.ShouldShowInUI())
                    {
                        storages.Add(storage);
                    }
                }
                found.Recycle();
                // Geysers can be uncovered over time
                if (lastSelection.world != null)
                {
                    allGeysers = FindObjectsOfType <Geyser>();
                }
                else
                {
                    allGeysers = null;
                }
            }
        }
Exemple #9
0
        public override void OnCleanUp()
        {
            int n = processHeaders.Count;

            allGeysers = null;
            foreach (var pair in labelCache)
            {
                pair.Value.Dispose();
            }
            labelCache.Clear();
            // Avoid leaking the report
            lastReport      = null;
            lastStressEntry = null;
            lastSelection   = default;
            // Destroy all process rows
            for (int i = 0; i < n; i++)
            {
                processHeaders[i].Dispose();
            }
            n = processRows.Count;
            for (int i = 0; i < n; i++)
            {
                processRows[i].Dispose();
            }
            processHeaders.Clear();
            processRows.Clear();
            processVisible.Clear();
            storages.Clear();
            // All of these were in the label cache so they should already be disposed
            rocketLabels.Clear();
            storageLabels.Clear();
            storageParent   = null;
            conditionParent = null;
            instance        = null;
            base.OnCleanUp();
        }
 public void ShowReport(int day)
 {
     currentReport = ReportManager.Instance.FindReport(day);
     Debug.Assert(currentReport != null, "Can't find report for day: " + day.ToString());
     Refresh();
 }
Exemple #11
0
        /// <summary>
        /// Refreshes the Stress readout of the info screen.
        /// </summary>
        private void RefreshStress()
        {
            var stressDrawer   = sis.stressDrawer;
            var ri             = ReportManager.Instance;
            var allNoteEntries = ri.noteStorage.noteEntries;
            var report         = ri.TodaysReport;
            var stressEntry    = lastStressEntry;
            var stressPanel    = sis.stressPanel;

            if (lastSelection.identity != null)
            {
                // If new report, look up entry again
                if (report != lastReport || stressEntry == null)
                {
                    lastReport      = report;
                    lastStressEntry = stressEntry = report.GetEntry(ReportManager.ReportType.
                                                                    StressDelta);
                }
                string name          = lastSelection.selectable.GetProperName();
                var    stressEntries = stressEntry.contextEntries;
                int    n             = stressEntries.Count;
                stressDrawer.BeginDrawing();
                // Look for this Duplicant in the report
                for (int i = 0; i < n; i++)
                {
                    var reportEntry = stressEntries[i];
                    int nodeID      = reportEntry.noteStorageId;
                    // The IterateNotes callback allocates a delegate on the heap :/
                    if (reportEntry.context == name && allNoteEntries.entries.TryGetValue(
                            nodeID, out Dictionary <NoteEntryKey, float> nodeEntries))
                    {
                        var   text  = CACHED_BUILDER;
                        float total = CompileNotes(nodeEntries, stressDrawer);
                        // Ryu to the rescue again!
                        text.Clear();
                        total.ToRyuHardString(text, 2);
                        string totalText = text.ToString();
                        text.Clear();
                        if (total > 0.0f)
                        {
                            text.Append(UIConstants.ColorPrefixRed);
                        }
                        text.Append(DETAILTABS.DETAILS.NET_STRESS).Replace("{0}", totalText);
                        if (total > 0.0f)
                        {
                            text.Append(UIConstants.ColorSuffix);
                        }
                        stressDrawer.NewLabel(text.ToString());
                        break;
                    }
                }
                stressDrawer.EndDrawing();
                if (!stressActive)
                {
                    sis.stressPanel.SetActive(true);
                    stressActive = true;
                }
            }
            else if (stressActive)
            {
                stressPanel.SetActive(false);
                stressActive = false;
            }
        }