Skip to content

Commit

Permalink
Showing 46 changed files with 97 additions and 63 deletions.
2 changes: 2 additions & 0 deletions GameData/RP-0/KCT_Presets/RP0_KCTPresets.cfg
Original file line number Diff line number Diff line change
@@ -64,6 +64,8 @@ KCT_Preset
ModuleTagReentry = 2
ModuleTagNuclear = 5
ModuleTagDecoupler = 3
ModuleTagTankServiceModule = 2.5
ModuleTagTankBalloon = 2
}
Global_Variables
{
8 changes: 8 additions & 0 deletions GameData/RP-0/MaintenanceSettings.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
MAINTENANCESETTINGS
{
facilityLevelCostMult = 0.0000005
kctBPMult = 20
kctResearchMult = 8640000
nautYearlyUpkeepAdd = 5000
nautYearlyUpkeepBase = 500
}
Binary file modified GameData/RP-0/Plugins/RP0.dll
Binary file not shown.
Binary file modified GameData/RP-0/Plugins/RP0KCTBinder.dll
Binary file not shown.
1 change: 0 additions & 1 deletion Source/Avionics/ControlLocker.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KSP;
using UnityEngine;
1 change: 0 additions & 1 deletion Source/Avionics/ModuleAvionicsModifier.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KSP;
using UnityEngine;
1 change: 0 additions & 1 deletion Source/Avionics/ModuleScienceCore.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KSP;
using UnityEngine;
2 changes: 1 addition & 1 deletion Source/Crew/ActiveCourse.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UniLinq;
using System.Text;

namespace RP0.Crew
1 change: 0 additions & 1 deletion Source/Crew/CourseTemplate.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RP0.Crew
1 change: 0 additions & 1 deletion Source/Crew/CrewHandler.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KSP;
using UnityEngine;
1 change: 0 additions & 1 deletion Source/Crew/CrewHandlerSettings.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KSP;
using UnityEngine;
1 change: 0 additions & 1 deletion Source/Crew/FSGUI.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using KSP;
1 change: 0 additions & 1 deletion Source/Crew/TrainingDatabase.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;

1 change: 0 additions & 1 deletion Source/DifficultyPresets.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using KSP;
1 change: 0 additions & 1 deletion Source/EntryCostStorage.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using KSP;
27 changes: 18 additions & 9 deletions Source/KCTBinderModule.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using KerbalConstructionTime;
@@ -15,7 +14,8 @@ public class KCTBinderModule : ScenarioModule

protected double nextTime = -1d;
protected double checkInterval = 0.5d;
protected int[] padCounts = new int[10];
protected const int padLevels = 10;
protected int[] padCounts = new int[padLevels];

protected bool skipOne = true;
protected bool skipTwo = true;
@@ -76,14 +76,14 @@ protected void Update()
if (HighLogic.CurrentGame == null || KerbalConstructionTime.KerbalConstructionTime.instance == null)
return;

if (skipOne)
{
skipOne = false;
return;
}

if (skipTwo)
{
if (skipOne)
{
skipOne = false;
return;
}

skipTwo = false;
return;
}
@@ -103,14 +103,23 @@ protected void Update()
foreach (KCT_KSC ksc in KCT_GameStates.KSCs)
{
double buildRate = 0d;

for (int i = ksc.VABRates.Count; i-- > 0;)
buildRate += Math.Max(0d, ksc.VABRates[i] + BuildRateOffset);

for (int i = ksc.SPHRates.Count; i-- > 0;)
buildRate += Math.Max(0d, ksc.SPHRates[i] + BuildRateOffset);

if (buildRate > 0.001d)
MaintenanceHandler.Instance.kctBuildRates[ksc.KSCName] = buildRate;


for (int i = ksc.LaunchPads.Count; i-- > 0;)
++padCounts[ksc.LaunchPads[i].level];
{
int lvl = ksc.LaunchPads[i].level;
if (lvl >= 0 && lvl < padLevels)
++padCounts[lvl];
}
}
double RDRate = KCT_MathParsing.ParseNodeRateFormula(10, 0, false);

1 change: 0 additions & 1 deletion Source/LoadingScreenChanger.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using UnityEngine;
using KSP;
46 changes: 30 additions & 16 deletions Source/Maintenance/MaintenanceHandler.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KSP;
using UnityEngine;
using System.Reflection;

namespace RP0
{
[KSPScenario(ScenarioCreationOptions.AddToAllGames, new GameScenes[] { GameScenes.EDITOR, GameScenes.FLIGHT, GameScenes.SPACECENTER, GameScenes.TRACKSTATION })]
[KSPScenario((ScenarioCreationOptions)120, new GameScenes[] { GameScenes.EDITOR, GameScenes.FLIGHT, GameScenes.SPACECENTER, GameScenes.TRACKSTATION })]
public class MaintenanceHandler : ScenarioModule
{
#region Fields
@@ -72,13 +71,18 @@ public double facilityUpkeep { get {
return padCost + runwayCost + vabCost + sphCost + rndCost + mcCost + tsCost + acCost;
}}
public double integrationUpkeep { get {
return kctBuildRates.Values.Sum() * kctBPMult;
double tmp = 0d;
foreach (double d in kctBuildRates.Values)
tmp += d;
return tmp * kctBPMult;
}}
public double researchUpkeep = 0d;
public double nautYearlyUpkeep = 0d;
public double nautUpkeep = 0d;
public double totalUpkeep = 0d;

public MaintenanceSettings settings = new MaintenanceSettings();

#endregion

#region Overrides and Monobehaviour methods
@@ -93,6 +97,14 @@ public override void OnAwake()
_instance = this;
}

public override void OnLoad(ConfigNode node)
{
base.OnLoad(node);

foreach (ConfigNode n in GameDatabase.Instance.GetConfigNodes("MAINTENANCESETTINGS"))
settings.Load(n);
}

public void updateUpkeep()
{
Upgradeables.UpgradeableFacility.UpgradeLevel[] levels;
@@ -109,7 +121,9 @@ public void updateUpkeep()
if (i < lC)
padCosts[i] = facilityLevelCostMult * kctPadCounts[i] * levels[i].levelCost;
}
padCost = padCosts.Sum();
padCost = 0;
for (int i = padLevels; i-- > 0;)
padCost += padCosts[i];
}
else
padCost = facilityLevelCostMult * levels[(int)(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.LaunchPad) * (levels.Length + 0.05f))].levelCost;
@@ -155,21 +169,21 @@ public void Update()
{
if (HighLogic.CurrentGame == null)
return;

if (skipOne)
{
skipOne = false;
return;
}

if (skipTwo)
{
skipTwo = false;
return;
}

if (skipThree)
{
if (skipTwo)
{
if (skipOne)
{
skipOne = false;
return;
}

skipTwo = false;
return;
}

skipThree = false;
return;
}
37 changes: 37 additions & 0 deletions Source/Maintenance/MaintenanceSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Text;
using KSP;
using UnityEngine;
using System.Reflection;

namespace RP0
{
public class MaintenanceSettings : IConfigNode
{
[Persistent]
public double facilityLevelCostMult = 0.0000005d;

[Persistent]
public double kctBPMult = 20d;

[Persistent]
protected double kctResearchMult = 100d * 86400d;

[Persistent]
protected double nautYearlyUpkeepAdd = 5000d;

[Persistent]
protected double nautYearlyUpkeepBase = 500d;

public void Load(ConfigNode node)
{
ConfigNode.LoadObjectFromConfig(this, node);
}

public void Save(ConfigNode node)
{
ConfigNode.CreateConfigFromObject(this, node);
}
}
}
1 change: 0 additions & 1 deletion Source/ModuleNonReentryRated.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using KSP;
1 change: 0 additions & 1 deletion Source/ModuleShowInfo.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using KSP;
1 change: 0 additions & 1 deletion Source/ModuleTag/Avionics.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RP0.ModuleTags
1 change: 0 additions & 1 deletion Source/ModuleTag/Decoupler.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RP0.ModuleTags
1 change: 0 additions & 1 deletion Source/ModuleTag/DecreaseA.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RP0.ModuleTags
1 change: 0 additions & 1 deletion Source/ModuleTag/DecreaseB.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RP0.ModuleTags
1 change: 0 additions & 1 deletion Source/ModuleTag/DummyModule.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RP0.ModuleTags
1 change: 0 additions & 1 deletion Source/ModuleTag/EngineLiquidPF.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RP0.ModuleTags
1 change: 0 additions & 1 deletion Source/ModuleTag/EngineLiquidTurbo.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RP0.ModuleTags
1 change: 0 additions & 1 deletion Source/ModuleTag/EngineSolid.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RP0.ModuleTags
1 change: 0 additions & 1 deletion Source/ModuleTag/Habitable.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RP0.ModuleTags
1 change: 0 additions & 1 deletion Source/ModuleTag/HumanRated.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RP0.ModuleTags
1 change: 0 additions & 1 deletion Source/ModuleTag/Instruments.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RP0.ModuleTags
1 change: 0 additions & 1 deletion Source/ModuleTag/Nuclear.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RP0.ModuleTags
1 change: 0 additions & 1 deletion Source/ModuleTag/Reentry.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RP0.ModuleTags
1 change: 0 additions & 1 deletion Source/ModuleTag/TankBalloon.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RP0.ModuleTags
1 change: 0 additions & 1 deletion Source/ModuleTag/TankServiceModule.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RP0.ModuleTags
1 change: 0 additions & 1 deletion Source/ModuleTag/Toxic.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RP0.ModuleTags
1 change: 0 additions & 1 deletion Source/ModuleUnpressurizedCockpit.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using KSP;
1 change: 1 addition & 0 deletions Source/RP0.csproj
Original file line number Diff line number Diff line change
@@ -54,6 +54,7 @@
<Compile Include="Crew\TrainingDatabase.cs" />
<Compile Include="Crew\FSGUI.cs" />
<Compile Include="EntryCostStorage.cs" />
<Compile Include="Maintenance\MaintenanceSettings.cs" />
<Compile Include="Maintenance\MaintenanceHandler.cs" />
<Compile Include="Crew\CrewHandler.cs" />
<Compile Include="LoadingScreenChanger.cs" />
1 change: 0 additions & 1 deletion Source/Tooling/ModuleTooling.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KSP;
using UnityEngine;
1 change: 0 additions & 1 deletion Source/Tooling/ModuleToolingDiamLen.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KSP;
using UnityEngine;
1 change: 0 additions & 1 deletion Source/Tooling/ModuleToolingGeneric.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KSP;
using UnityEngine;
1 change: 0 additions & 1 deletion Source/Tooling/ModuleToolingPFSide.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KSP;
using UnityEngine;
1 change: 0 additions & 1 deletion Source/Tooling/ModuleToolingPTank.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KSP;
using UnityEngine;
1 change: 0 additions & 1 deletion Source/Tooling/ToolingDatabase.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KSP;
using UnityEngine;
1 change: 0 additions & 1 deletion Source/Tooling/ToolingScenario.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KSP;
using UnityEngine;

0 comments on commit 9c658fc

Please sign in to comment.