/// <summary> /// Easily get a private instance field of type T from StarmapScreen. /// Note that something like an int can't be set via this. /// </summary> public static void Get <T>(this StarmapScreen screen, out T value, string fieldName) { Type type = screen.GetType(); FieldInfo field = type.GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic); if (field == null) { field = type.GetField(fieldName, BindingFlags.Instance | BindingFlags.Public); } value = (T)field.GetValue(screen); }
} // skip original method static void Postfix(StarmapScreen __instance) { var ranges = SolidBoosterStats.Ranges; List <string> rangeDivisors = new List <string>(); foreach (var range in ranges) { rangeDivisors.Add(StarmapScreenOverhaul.FormatDistance(range, "")); } __instance.Get(out BreakdownList rocketDetailsFuel, nameof(rocketDetailsFuel)); BreakdownList list = rocketDetailsFuel; __instance.Get(out CommandModule currentCommandModule, nameof(currentCommandModule)); RocketStatsOverhaul stats = (RocketStatsOverhaul)currentCommandModule.rocketStats; list.SetTitle(StarmapScreenOverhaul.Caption.TotalBoosterThrust); list.SetIcon(__instance.rocketDetailsFuelIcon); list.gameObject.name = nameof(rocketDetailsFuel); list.ClearRows(); string moduleName = ""; int boosterCount = 0; foreach (GameObject gameObject in stats.BuildingNetworkEnumerable()) { SolidBooster component = gameObject.GetComponent <SolidBooster>(); if (component != null) { moduleName = gameObject.gameObject.GetProperName(); boosterCount++; } } float boosterKmRemaining = stats.GetBoosterThrust(); for (int i = 0; i < boosterCount; ++i) { if (boosterKmRemaining <= GetRange(ranges, i)) { list.AddRow().ShowData(moduleName, StarmapScreenOverhaul.FormatDistance(boosterKmRemaining, "+", "") + "/" + rangeDivisors[i]); boosterKmRemaining -= boosterKmRemaining; } else { list.AddRow().ShowData(moduleName, StarmapScreenOverhaul.FormatDistance(GetRange(ranges, i), "+", "") + "/" + rangeDivisors[i]); boosterKmRemaining -= GetRange(ranges, i); } } AddImportant(list, StarmapScreenOverhaul.Caption.TotalBoosterThrust, stats.GetBoosterThrust()); }
} // skip original method static void Postfix(StarmapScreen __instance) { __instance.Get(out BreakdownList rocketDetailsRange, nameof(rocketDetailsRange)); BreakdownList list = rocketDetailsRange; __instance.Get(out RocketThrustWidget rocketThrustWidget, nameof(rocketThrustWidget)); __instance.Get(out CommandModule currentCommandModule, nameof(currentCommandModule)); RocketStatsOverhaul stats = (RocketStatsOverhaul)currentCommandModule.rocketStats; list.ClearRows(); AddImportant(list, StarmapScreenOverhaul.Caption.TotalEngineThrust, stats.GetEngineThrust()); AddImportantOxidizer(list, StarmapScreenOverhaul.Caption.TotalOxidizerEfficiency, stats.GetAverageOxidizerEfficiency(), stats.GetEfficiencyContribution()); AddImportant(list, StarmapScreenOverhaul.Caption.TotalBoosterThrust, stats.GetBoosterThrust()); AddImportant(list, StarmapScreenOverhaul.Caption.TotalPayload, -stats.GetModulePenalty()); AddImportant(list, StarmapScreenOverhaul.Caption.TotalDistance, stats.GetRocketMaxDistance()); }
} // skip original method static void Postfix(StarmapScreen __instance) { __instance.Get(out BreakdownList rocketDetailsOxidizer, nameof(rocketDetailsOxidizer)); BreakdownList list = rocketDetailsOxidizer; __instance.Get(out CommandModule currentCommandModule, nameof(currentCommandModule)); RocketStatsOverhaul stats = (RocketStatsOverhaul)currentCommandModule.rocketStats; list.SetTitle(StarmapScreenOverhaul.Caption.TotalPayload); list.SetIcon(__instance.rocketDetailsStorageIcon); list.gameObject.name = nameof(rocketDetailsOxidizer); list.ClearRows(); // add row for each module foreach (GameObject gameObject in stats.BuildingNetworkEnumerable()) { string penalty = null; if (gameObject.GetComponent <CargoBay>() != null) { penalty = StarmapScreenOverhaul.FormatDistance(-ModulePenalties.CargoPenalty); } else if (gameObject.GetComponent <TouristModule>() != null) { penalty = StarmapScreenOverhaul.FormatDistance(-ModulePenalties.TouristPenalty); } else if (gameObject.GetComponent <ResearchModule>() != null) { penalty = StarmapScreenOverhaul.FormatDistance(-ModulePenalties.ResearchPenalty); } if (penalty != null) // was this a module that we are counting? { string moduleName = gameObject.gameObject.GetProperName(); list.AddRow().ShowData(moduleName, penalty); } } AddImportant(list, StarmapScreenOverhaul.Caption.TotalPayload, -stats.GetModulePenalty()); }
} // skip original method static void Postfix(StarmapScreen __instance) { __instance.Get(out BreakdownList rocketDetailsStorage, nameof(rocketDetailsStorage)); BreakdownList list = rocketDetailsStorage; __instance.Get(out CommandModule currentCommandModule, nameof(currentCommandModule)); RocketStatsOverhaul stats = (RocketStatsOverhaul)currentCommandModule.rocketStats; list.SetTitle(StarmapScreenOverhaul.Caption.TotalOxidizerEfficiency); list.SetIcon(__instance.rocketDetailsOxidizerIcon); list.gameObject.name = nameof(rocketDetailsStorage); list.ClearRows(); stats.GetOxidizerAmounts(out float oxyrockAmount, out float loxAmount, out float mixedAmount); float totalEfficiency = stats.GetAverageOxidizerEfficiency(); list.AddRow().ShowData(StarmapScreenOverhaul.Caption.OxyRock, StarmapScreenOverhaul.FormatDistance(oxyrockAmount, "", "kg")); list.AddRow().ShowData(StarmapScreenOverhaul.Caption.LiquidOxygen, StarmapScreenOverhaul.FormatDistance(loxAmount, "", "kg")); list.AddRow().ShowData(StarmapScreenOverhaul.Caption.Mixed, StarmapScreenOverhaul.FormatDistance(mixedAmount, "", "kg")); AddImportantOxidizer(list, StarmapScreenOverhaul.Caption.TotalOxidizerEfficiency, totalEfficiency, stats.GetEfficiencyContribution()); }
} // skip original method static void Postfix(StarmapScreen __instance) { __instance.Get(out BreakdownList rocketDetailsMass, nameof(rocketDetailsMass)); BreakdownList list = rocketDetailsMass; __instance.Get(out RocketThrustWidget rocketThrustWidget, nameof(rocketThrustWidget)); __instance.Get(out CommandModule currentCommandModule, nameof(currentCommandModule)); RocketStatsPatches.TryLog("before cast"); RocketStatsOverhaul stats = (RocketStatsOverhaul)currentCommandModule.rocketStats; RocketStatsPatches.TryLog("after1 cast"); RocketEngineImproved engine = (RocketEngineImproved)stats.GetMainEngine(); RocketStatsPatches.TryLog("after2 cast"); list.SetTitle(StarmapScreenOverhaul.Caption.TotalEngineThrust); list.ClearRows(); string fuelRange = StarmapScreenOverhaul.FormatDistance(engine.MinFuel, "", "kg") + " to " + StarmapScreenOverhaul.FormatDistance(engine.MaxFuel, "", "kg"); list.AddRow().ShowData(StarmapScreenOverhaul.Caption.EngineExhaustVelocity, StarmapScreenOverhaul.FormatDistance(engine.ExhaustVelocity, "", "m/s")); list.AddRow().ShowData(StarmapScreenOverhaul.Caption.RecommendedOxidizableFuel, fuelRange); list.AddRow().ShowData(StarmapScreenOverhaul.Caption.TotalOxidizableFuel, StarmapScreenOverhaul.FormatDistance(stats.GetTotalOxidizableFuel(), "", "kg")); AddImportant(list, StarmapScreenOverhaul.Caption.TotalEngineThrust, stats.GetEngineThrust()); }
protected override void OnPrefabInit() { base.OnPrefabInit(); Instance = this; CodexCache.Init(); ScheduledUIInstantiation component = GameScreenManager.Instance.ssOverlayCanvas.GetComponent <ScheduledUIInstantiation>(); instantiator.Instantiate(); jobsScreen = instantiator.GetComponentInChildren <JobsTableScreen>(true); consumablesScreen = instantiator.GetComponentInChildren <ConsumablesTableScreen>(true); vitalsScreen = instantiator.GetComponentInChildren <VitalsTableScreen>(true); starmapScreen = component.GetInstantiatedObject <StarmapScreen>(); codexScreen = instantiator.GetComponentInChildren <CodexScreen>(true); scheduleScreen = instantiator.GetComponentInChildren <ScheduleScreen>(true); skillsScreen = component.GetInstantiatedObject <SkillsScreen>(); Subscribe(Game.Instance.gameObject, 288942073, OnUIClear); consumablesInfo = new ToggleInfo(UI.CONSUMABLES, "OverviewUI_consumables_icon", null, Action.ManageConsumables, UI.TOOLTIPS.MANAGEMENTMENU_CONSUMABLES, string.Empty); vitalsInfo = new ToggleInfo(UI.VITALS, "OverviewUI_vitals_icon", null, Action.ManageVitals, UI.TOOLTIPS.MANAGEMENTMENU_VITALS, string.Empty); reportsInfo = new ToggleInfo(UI.REPORT, "OverviewUI_reports_icon", null, Action.ManageReport, UI.TOOLTIPS.MANAGEMENTMENU_DAILYREPORT, string.Empty); reportsInfo.prefabOverride = smallPrefab; researchInfo = new ToggleInfo(UI.RESEARCH, "OverviewUI_research_nav_icon", null, Action.ManageResearch, UI.TOOLTIPS.MANAGEMENTMENU_RESEARCH, string.Empty); jobsInfo = new ToggleInfo(UI.JOBS, "OverviewUI_priority_icon", null, Action.ManagePriorities, UI.TOOLTIPS.MANAGEMENTMENU_JOBS, string.Empty); skillsInfo = new ToggleInfo(UI.SKILLS, "OverviewUI_jobs_icon", null, Action.ManageSkills, UI.TOOLTIPS.MANAGEMENTMENU_SKILLS, string.Empty); starmapInfo = new ToggleInfo(UI.STARMAP.MANAGEMENT_BUTTON, "OverviewUI_starmap_icon", null, Action.ManageStarmap, UI.TOOLTIPS.MANAGEMENTMENU_STARMAP, string.Empty); codexInfo = new ToggleInfo(UI.CODEX.MANAGEMENT_BUTTON, "OverviewUI_database_icon", null, Action.ManageDatabase, UI.TOOLTIPS.MANAGEMENTMENU_CODEX, string.Empty); codexInfo.prefabOverride = smallPrefab; scheduleInfo = new ToggleInfo(UI.SCHEDULE, "OverviewUI_schedule2_icon", null, Action.ManageSchedule, UI.TOOLTIPS.MANAGEMENTMENU_SCHEDULE, string.Empty); ScreenInfoMatch.Add(consumablesInfo, new ScreenData { screen = consumablesScreen, tabIdx = 3, toggleInfo = consumablesInfo }); ScreenInfoMatch.Add(vitalsInfo, new ScreenData { screen = vitalsScreen, tabIdx = 2, toggleInfo = vitalsInfo }); ScreenInfoMatch.Add(reportsInfo, new ScreenData { screen = reportsScreen, tabIdx = 4, toggleInfo = reportsInfo }); ScreenInfoMatch.Add(jobsInfo, new ScreenData { screen = jobsScreen, tabIdx = 1, toggleInfo = jobsInfo }); ScreenInfoMatch.Add(skillsInfo, new ScreenData { screen = skillsScreen, tabIdx = 0, toggleInfo = skillsInfo }); ScreenInfoMatch.Add(codexInfo, new ScreenData { screen = codexScreen, tabIdx = 6, toggleInfo = codexInfo }); ScreenInfoMatch.Add(scheduleInfo, new ScreenData { screen = scheduleScreen, tabIdx = 7, toggleInfo = scheduleInfo }); ScreenInfoMatch.Add(starmapInfo, new ScreenData { screen = starmapScreen, tabIdx = 7, toggleInfo = starmapInfo }); List <ToggleInfo> list = new List <ToggleInfo>(); list.Add(vitalsInfo); list.Add(consumablesInfo); list.Add(scheduleInfo); list.Add(jobsInfo); list.Add(skillsInfo); list.Add(researchInfo); list.Add(starmapInfo); list.Add(reportsInfo); list.Add(codexInfo); Setup(list); base.onSelect += OnButtonClick; PauseMenuButton.onClick += OnPauseMenuClicked; PauseMenuButton.transform.SetAsLastSibling(); PauseMenuButton.GetComponent <ToolTip>().toolTip = GameUtil.ReplaceHotkeyString(UI.TOOLTIPS.MANAGEMENTMENU_PAUSEMENU, Action.Escape); Components.ResearchCenters.OnAdd += CheckResearch; Components.ResearchCenters.OnRemove += CheckResearch; Components.RoleStations.OnAdd += CheckSkills; Components.RoleStations.OnRemove += CheckSkills; Game.Instance.Subscribe(-809948329, CheckResearch); Game.Instance.Subscribe(-809948329, CheckSkills); Components.Telescopes.OnAdd += CheckStarmap; Components.Telescopes.OnRemove += CheckStarmap; skillsTooltipDisabled = UI.TOOLTIPS.MANAGEMENTMENU_REQUIRES_SKILL_STATION; skillsTooltip = GameUtil.ReplaceHotkeyString(UI.TOOLTIPS.MANAGEMENTMENU_SKILLS, Action.ManageSkills); researchTooltipDisabled = UI.TOOLTIPS.MANAGEMENTMENU_REQUIRES_RESEARCH; researchTooltip = GameUtil.ReplaceHotkeyString(UI.TOOLTIPS.MANAGEMENTMENU_RESEARCH, Action.ManageResearch); starmapTooltipDisabled = UI.TOOLTIPS.MANAGEMENTMENU_REQUIRES_TELESCOPE; starmapTooltip = GameUtil.ReplaceHotkeyString(UI.TOOLTIPS.MANAGEMENTMENU_STARMAP, Action.ManageStarmap); CheckResearch(null); CheckSkills(null); CheckStarmap(null); researchInfo.toggle.soundPlayer.AcceptClickCondition = (() => ResearchAvailable() || activeScreen == ScreenInfoMatch[Instance.researchInfo]); KButton[] closeButtons = CloseButtons; foreach (KButton kButton in closeButtons) { kButton.onClick += CloseAll; kButton.soundPlayer.Enabled = false; } foreach (KToggle toggle in toggles) { toggle.soundPlayer.toggle_widget_sound_events[0].PlaySound = false; toggle.soundPlayer.toggle_widget_sound_events[1].PlaySound = false; } }