Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recalc build rates when needed #2392

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Source/RP0/SpaceCenter/Projects/LCConstructionProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ private void ReassignEngineers(LaunchComplex lc)
if (engToAssign > 0)
{
KCTUtilities.ChangeEngineers(lc, engToAssign);
lc.RecalculateBuildRates();
}
}
}
Expand Down
15 changes: 6 additions & 9 deletions Source/RP0/UI/KCT/GUI_Personnel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,10 @@ private static void RenderEngineersSection(bool isCostCacheInvalid)
string assignStr = GetAssignText(true, currentLC, out int assignAmt);
string unassignStr = GetAssignText(false, currentLC, out int unassignAmt);

bool recalc = false;
ProjectType type = currentLC.LCType == LaunchComplexType.Pad ? ProjectType.VAB : ProjectType.SPH;
if (GUILayout.Button(unassignStr, GUILayout.ExpandWidth(false)) && unassignAmt > 0) { KCTUtilities.ChangeEngineers(currentLC, -unassignAmt); recalc = true; }
if (GUILayout.Button(unassignStr, GUILayout.ExpandWidth(false)) && unassignAmt > 0)
KCTUtilities.ChangeEngineers(currentLC, -unassignAmt);

if (Event.current.type == EventType.Repaint)
{
if (GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition))
Expand All @@ -136,7 +137,9 @@ private static void RenderEngineersSection(bool isCostCacheInvalid)

GUILayout.Label($" {currentLC.Engineers:N0} ", GetLabelCenterAlignStyle(), GUILayout.ExpandWidth(false));

if (GUILayout.Button(assignStr, GUILayout.ExpandWidth(false)) && assignAmt > 0) { KCTUtilities.ChangeEngineers(currentLC, assignAmt); recalc = true; }
if (GUILayout.Button(assignStr, GUILayout.ExpandWidth(false)) && assignAmt > 0)
KCTUtilities.ChangeEngineers(currentLC, assignAmt);

if (Event.current.type == EventType.Repaint)
{
if (GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition))
Expand All @@ -148,12 +151,6 @@ private static void RenderEngineersSection(bool isCostCacheInvalid)
GUILayout.Label($"Max: {currentLC.MaxEngineers:N0}", GetLabelRightAlignStyle());
GUILayout.EndHorizontal();

if (recalc)
{
currentLC.RecalculateBuildRates();
currentLC.KSC.RecalculateBuildRates(false);
}

int assignDelta = 0;
if (_currentPersonnelHover == PersonnelButtonHover.Assign)
assignDelta = assignAmt;
Expand Down
2 changes: 1 addition & 1 deletion Source/RP0/Utilities/KCTUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1345,7 +1345,6 @@ public static void HireStaff(bool isResearch, int workerAmount, LaunchComplex lc
ChangeEngineers(ksc, workerAmount);
if (lc != null)
ChangeEngineers(lc, workerAmount);
ksc.RecalculateBuildRates(false);
}
SpaceCenterManagement.Instance.Applicants = Math.Max(0, SpaceCenterManagement.Instance.Applicants - workerAmount);
if (SpaceCenterManagement.Instance.Applicants == 0)
Expand All @@ -1357,6 +1356,7 @@ public static void ChangeEngineers(LaunchComplex currentLC, int delta)
currentLC.Engineers += delta;
SCMEvents.OnPersonnelChange.Fire();
MaintenanceHandler.Instance.ScheduleMaintenanceUpdate();
currentLC.RecalculateBuildRates();
KCT_GUI.BuildRateForDisplay = null;
}

Expand Down
Loading