/// <summary> /// Applied before GetStressedMinions runs. /// </summary> internal static bool Prefix(MeterScreen __instance, ref IList <MinionIdentity> __result) { var stressAmount = Db.Get().Amounts.Stress; var duplicants = __instance.GetWorldMinionIdentities(); var result = CACHED_LIST; int n = duplicants.Count; var byStress = ListPool <StressEntry, MeterScreen> .Allocate(); result.Clear(); // The previous comparer looked up the stress on every comparison! for (int i = 0; i < n; i++) { var duplicant = duplicants[i]; if (!duplicant.IsNullOrDestroyed()) { // These are equatable structs which will not allocate (owned by byStress) byStress.Add(new StressEntry(duplicant, stressAmount.Lookup(duplicant). value)); } } byStress.Sort(); for (int i = 0; i < n; i++) { // Copies the struct on deref, but using an array would require reallocation // every time the count changes result.Add(byStress[i].identity); } byStress.Recycle(); __result = result; return(false); }
public static void Postfix(MeterScreen __instance) { if (ForcedExit.Options.IngameClock) { Clock.Instantiate(__instance); } }
public static void RefreshPatch(MeterScreen __instance) { if (__instance.RationsText.text.Contains("|")) { string text = __instance.RationsText.text.Split(new char[] { '|' })[0]; __instance.RationsText.text = text.Trim() + " | " + STclockMod.FormatAsClock(STclockMod.GetClock()); return; } LocText rationsText = __instance.RationsText; rationsText.text = rationsText.text + " | " + STclockMod.FormatAsClock(STclockMod.GetClock()); return; }
/// <summary> /// Shows food consumption and production stats for the current cycle, last cycle, and /// last 5 cycle average. /// </summary> /// <param name="screen">The screen to add the stats.</param> internal static void ShowFoodUseStats(MeterScreen screen) { var tooltip = screen.RationsTooltip; var style = screen.ToolTipStyle_Property; var reports = ReportManager.Instance; if (tooltip != null && reports != null) { GetCalorieDeltas(reports.TodaysReport, out float produced, out float consumed); tooltip.AddMultiStringTooltip(FormatDeltaTooltip(FoodTooltipStrings. FOOD_RATE_CURRENT, produced, consumed), style); // Returns null if not present GetCalorieDeltas(reports.YesterdaysReport, out produced, out consumed); tooltip.AddMultiStringTooltip(FormatDeltaTooltip(FoodTooltipStrings. FOOD_RATE_LAST1, produced, consumed), style); int days = 0, cycle = GameUtil.GetCurrentCycle(); float totalProduced = 0.0f, totalConsumed = 0.0f; // Last 5 cycles, arithmetic average foreach (var report in reports.reports) { if (report.day >= cycle - CYCLES_FOR_SUMMARY) { GetCalorieDeltas(report, out produced, out consumed); totalProduced += produced; totalConsumed += consumed; days++; } } // Do not divide by zero if (days == 0) { days = 1; } tooltip.AddMultiStringTooltip(FormatDeltaTooltip(FoodTooltipStrings. FOOD_RATE_LAST5, totalProduced / days, totalConsumed / days), style); } }
/// <summary> /// Applied before RefreshMinions runs. /// </summary> internal static bool Prefix(MeterScreen __instance) { int living = Components.LiveMinionIdentities.Count; int identities = __instance.GetWorldMinionIdentities().Count; var currentMinions = __instance.currentMinions; var tt = __instance.MinionsTooltip; if (identities != __instance.cachedMinionCount && currentMinions != null && tt != null) { string ttText; WorldContainer activeWorld; __instance.cachedMinionCount = identities; string alive = living.ToString(); if (DlcManager.FeatureClusterSpaceEnabled() && (activeWorld = ClusterManager. Instance.activeWorld) != null && activeWorld.TryGetComponent( out ClusterGridEntity world)) { var text = CACHED_BUILDER; string ids = identities.ToString(); text.Clear().Append(STRINGS.UI.TOOLTIPS.METERSCREEN_POPULATION_CLUSTER); ttText = text.Replace("{0}", world.Name).Replace("{1}", ids).Replace( "{2}", alive).ToString(); text.Clear().Append(ids).Append('/').Append(alive); currentMinions.SetText(text); } else { ttText = STRINGS.UI.TOOLTIPS.METERSCREEN_POPULATION.Format(alive); currentMinions.SetText(alive); } tt.ClearMultiStringTooltip(); tt.AddMultiStringTooltip(ttText, __instance.ToolTipStyle_Header); } return(false); }
public override async Task LoadContent() { await base.LoadContent(); meterRenderer = new MeterRenderer(Content, "MeterShader.fx"); var timerRect = new Rectangle(0, 0, 128, 128); CountdownClock = new TimerMeter(QuestionTime, Content, "TimerBackground.png", "TimerMeter.png", "TimerGradient.png", timerRect) { NearEndTime = QuestionTime * 0.5f, }; //add the meter screen TimerScreen = new MeterScreen(CountdownClock, new Point((int)Resolution.TitleSafeArea.Left, (int)Resolution.TitleSafeArea.Top), TransitionWipeType.PopLeft, Content, VerticalAlignment.Top, HorizontalAlignment.Left); //make the player stare at this screen for 2 seconds before they can quit AutoQuit.Start(QuestionTime); CountdownClock.Reset(); await ScreenManager.AddScreen(TimerScreen); //add the speech button for the question word AddListenButton(QuestionScreen.QuestionWordLabel, QuestionScreen.QuestionWordSoundEffect); //Add the speech button for each menuentry foreach (var entry in QuestionScreen.Entries) { AddListenButton(entry.QuestionLabel, entry.SoundEffect); } }
/// <summary> /// Applied after OnRationsTooltip runs. /// </summary> internal static void Postfix(MeterScreen __instance) { FoodTooltipUtils.ShowFoodUseStats(__instance); }
public static void Instantiate(MeterScreen parentScreen) { Instance = new Clock(); PUIUtils.AddTo(Instance, parentScreen.gameObject); }
public static void Postfix(MeterScreen __instance) { __instance.RationsText.text = RationUtil.CountRation(); }
protected override void OnPrefabInit() { Instance = this; }
public static void DestroyInstance() { Instance = null; }