diff --git a/GameData/RP-1/MaintenanceSettings.cfg b/GameData/RP-1/MaintenanceSettings.cfg index 6a2e2fd7b5e..ed345e3d3f8 100644 --- a/GameData/RP-1/MaintenanceSettings.cfg +++ b/GameData/RP-1/MaintenanceSettings.cfg @@ -9,9 +9,12 @@ MAINTENANCESETTINGS salaryResearchers = 600 researchersToUnlockCreditSalaryMultiplier { - key = 300 0.6 0 0 - key = 600 0.35 - key = 1600 0.2 0 0 + 150 = 0.6 + 300 = 0.5 + 600 = 0.35 + 1000 = 0.25 + 1600 = 0.2 + 9999999 = 0.15 } nautYearlyUpkeepAdd = 10000 nautYearlyUpkeepBase = 2500 diff --git a/Source/Maintenance/MaintenanceSettings.cs b/Source/Maintenance/MaintenanceSettings.cs index f41ec10f346..78dd66d10bc 100644 --- a/Source/Maintenance/MaintenanceSettings.cs +++ b/Source/Maintenance/MaintenanceSettings.cs @@ -1,4 +1,6 @@ -namespace RP0 +using RP0.DataTypes; + +namespace RP0 { public class MaintenanceSettings { @@ -15,7 +17,7 @@ public class MaintenanceSettings public int salaryResearchers = 1000; [Persistent] - public FloatCurve researchersToUnlockCreditSalaryMultiplier = new FloatCurve(); + public PersistentSortedListValueTypes researchersToUnlockCreditSalaryMultiplier = new PersistentSortedListValueTypes(); [Persistent] public double hangarCostForMaintenanceOffset = 240000d; diff --git a/Source/UnlockCreditHandler.cs b/Source/UnlockCreditHandler.cs index 23f03759d17..1d36f755ee5 100644 --- a/Source/UnlockCreditHandler.cs +++ b/Source/UnlockCreditHandler.cs @@ -15,9 +15,30 @@ public class UnlockCreditHandler : ScenarioModule public double TotalCredit => _totalCredit; - public double CreditForTime(double UT) => UT - * MaintenanceHandler.Instance.ResearchSalaryPerDay * (1d / 86400d) - * MaintenanceHandler.Settings.researchersToUnlockCreditSalaryMultiplier.Evaluate((float)MaintenanceHandler.Instance.Researchers); + public double CreditForTime(double UT) + { + double sum = 0d; + double mult = UT * MaintenanceHandler.Settings.salaryResearchers * (1d / (86400d * 365.25d)); + + int res = KerbalConstructionTimeData.Instance.Researchers; + int totalCounted = 0; + + foreach (var kvp in MaintenanceHandler.Settings.researchersToUnlockCreditSalaryMultiplier) + { + if (totalCounted >= res) + break; + + int amountToCount = kvp.Key - totalCounted; + int remaining = res - totalCounted; + if (amountToCount > remaining) + amountToCount = remaining; + + sum += amountToCount * kvp.Value; + totalCounted += amountToCount; + } + + return sum * mult; + } public double GetCreditAmount(string tech) => _totalCredit; public double GetCreditAmount(List partList) => _totalCredit;