diff --git a/GameData/RP-1/MaintenanceSettings.cfg b/GameData/RP-1/MaintenanceSettings.cfg index 6a2e2fd7b5e..d9e1f912e57 100644 --- a/GameData/RP-1/MaintenanceSettings.cfg +++ b/GameData/RP-1/MaintenanceSettings.cfg @@ -7,11 +7,16 @@ MAINTENANCESETTINGS lcCostMultiplier = 2 salaryEngineers = 500 salaryResearchers = 600 - researchersToUnlockCreditSalaryMultiplier + researchersToUnlockCreditSalaryMultipliers { - key = 300 0.6 0 0 - key = 600 0.35 - key = 1600 0.2 0 0 + 100 = 0.6 + 200 = 0.5 + 300 = 0.4 + 400 = 0.35 + 600 = 0.3 + 1000 = 0.2 + 1600 = 0.15 + 9999999 = 0.1 } nautYearlyUpkeepAdd = 10000 nautYearlyUpkeepBase = 2500 diff --git a/Source/Maintenance/MaintenanceSettings.cs b/Source/Maintenance/MaintenanceSettings.cs index f41ec10f346..0f4adb8f046 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 researchersToUnlockCreditSalaryMultipliers = new PersistentSortedListValueTypes(); [Persistent] public double hangarCostForMaintenanceOffset = 240000d; diff --git a/Source/UnlockCreditHandler.cs b/Source/UnlockCreditHandler.cs index 23f03759d17..9a837f1eb61 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.researchersToUnlockCreditSalaryMultipliers) + { + 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;