Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
NovemberOrWhatever committed Aug 7, 2023
2 parents a3a882c + 696f72d commit 990350c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 9 deletions.
13 changes: 9 additions & 4 deletions GameData/RP-1/MaintenanceSettings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions Source/Maintenance/MaintenanceSettings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace RP0
using RP0.DataTypes;

namespace RP0
{
public class MaintenanceSettings
{
Expand All @@ -15,7 +17,7 @@ public class MaintenanceSettings
public int salaryResearchers = 1000;

[Persistent]
public FloatCurve researchersToUnlockCreditSalaryMultiplier = new FloatCurve();
public PersistentSortedListValueTypes<int, double> researchersToUnlockCreditSalaryMultipliers = new PersistentSortedListValueTypes<int, double>();

[Persistent]
public double hangarCostForMaintenanceOffset = 240000d;
Expand Down
27 changes: 24 additions & 3 deletions Source/UnlockCreditHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<AvailablePart> partList) => _totalCredit;
Expand Down

0 comments on commit 990350c

Please sign in to comment.