-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- v3.19.0.0
- v3.18.0.0
- v3.17.0.0
- v3.16.0.0
- v3.15.0.0
- v3.14.0.0
- v3.13.0.0
- v3.12.0.0
- v3.11.0.0
- v3.10.0.0
- v3.9.0.0
- v3.8.0.0
- v3.7.0.0
- v3.6.1.0
- v3.6.0.0
- v3.5.0.0
- v3.4.0.0
- v3.3.0.1
- v3.3.0.0
- v3.2.1.0
- v3.2.0.1
- v3.2.0.0
- v3.1.1.2
- v3.1.1.1
- v3.1.1.0
- v3.0.0.2
- v3.0.0.1
- v3.0.0.0
- v2.13.0.0
- v2.12.0.0
- v2.11.0.1
- v2.11.0.0
- v2.10.0.0
- v2.9.1.1
- v2.9.1.0
- v2.9.0.1
- v2.9.0.0
- v2.8.1.0
- v2.8.0.0
- v2.7.1.0
- v2.7.0.0
- v2.6.4.0
- v2.6.3.0
- v2.6.2.0
- v2.6.1.1
- v2.6.0.0
- v2.5.0.0
- v2.4.2.0
- v2.4.1.0
- v2.4.0.0
- v2.3.0.0
- v2.2.0.0
- v2.1.0.0
- v2.0.2.0
- v2.0.1.0
- v2.0.0.0
- v1.13.2.2
- v1.13.2.1
- v1.13.2.0
- v1.13.1.0
- v1.13.0.0
- v1.12.19.0
- v1.12.18.0
- v1.12.17.0
- v1.12.16.0
- v1.12.15.0
- v1.12.14.0
- v1.12.13.0
- v1.12.12.0
- v1.12.11.0
- v1.12.10.0
- v1.12.9.0
- v1.12.8.0
- v1.12.7.0
- v1.12.6.0
- v1.12.5.0
- v1.12.4.0
- v1.12.3.0
- v1.12.2.0
- v1.12.1.0
- v1.12.0.0
- v1.11.11.0
- v1.11.10.0
- v1.11.9.0
- v1.11.8.0
- v1.11.7.0
- v1.11.6.0
- v1.11.5.0
- v1.11.4.0
- v1.11.3.0
- v1.11.2.0
- v1.11.1.0
- v1.11.0.0
- v1.10.7.0
- v1.10.6.1
- v1.10.6.0
- v1.10.5.0
- v1.10.4.0
- v1.10.3.0
- v1.10.2.0
- v1.10.0.1
- v1.10.0.0
- v1.9.1
- v1.9.0
- v1.8.1
- v1.8
- v1.7
- v1.6
- v1.5
- v1.4.1
- v1.3
- v1.2.1
- v1.2
- v1.1.1
- v1.1
- v1.00
- 3.1.0.0
- 3.0.1.0
- 1.4
1 parent
41592c3
commit ecf9403
Showing
9 changed files
with
389 additions
and
1 deletion.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using UnityEngine; | ||
using KerbalConstructionTime; | ||
|
||
namespace RP0 | ||
{ | ||
[KSPScenario(ScenarioCreationOptions.AddToAllGames, new GameScenes[] { GameScenes.EDITOR, GameScenes.FLIGHT, GameScenes.SPACECENTER, GameScenes.TRACKSTATION })] | ||
public class KCTBinderModule : ScenarioModule | ||
{ | ||
// FIXME if we change the min build rate, FIX THIS. | ||
protected const double BuildRateOffset = -0.05001d; | ||
|
||
protected double nextTime = -1d; | ||
protected double checkInterval = 0.5d; | ||
protected int[] padCounts = new int[10]; | ||
protected void Update() | ||
{ | ||
if (HighLogic.CurrentGame == null) | ||
return; | ||
|
||
if (KerbalConstructionTime.KerbalConstructionTime.instance == null) | ||
return; | ||
|
||
if (MaintenanceHandler.Instance == null) | ||
return; | ||
|
||
double time = Planetarium.GetUniversalTime(); | ||
if (nextTime > time) | ||
return; | ||
|
||
nextTime = time + checkInterval; | ||
|
||
double buildRate = 0d; | ||
for (int i = padCounts.Length; i-- > 0;) | ||
padCounts[i] = 0; | ||
|
||
foreach (KCT_KSC ksc in KCT_GameStates.KSCs) | ||
{ | ||
|
||
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); | ||
for (int i = ksc.LaunchPads.Count; i-- > 0;) | ||
++padCounts[ksc.LaunchPads[i].level]; | ||
} | ||
double RDRate = KCT_MathParsing.ParseNodeRateFormula(10, 0, false); | ||
|
||
MaintenanceHandler.Instance.kctBuildRate = buildRate; | ||
MaintenanceHandler.Instance.kctResearcRate = RDRate; | ||
MaintenanceHandler.Instance.kctPadCounts = padCounts; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
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 })] | ||
public class MaintenanceHandler : ScenarioModule | ||
{ | ||
#region Fields | ||
|
||
protected double nextUpdate = -1d; | ||
protected double lastUpdate = 0d; | ||
protected double updateInterval = 3600d; | ||
protected bool wasWarpingHigh = false; | ||
|
||
public double kctBuildRate = 0; | ||
public double kctResearcRate = 0; | ||
public int[] kctPadCounts = new int[10]; | ||
|
||
protected double facilityLevelCostMult = 0.00001d; | ||
protected double kctBPMult = 1000000d; | ||
protected double kctResearchMult = 50000000d / 86400d; | ||
protected double nautYearlyUpkeepAdd = 5000d; | ||
protected double nautYearlyUpkeepBase = 500d; | ||
|
||
protected Dictionary<SpaceCenterFacility, Upgradeables.UpgradeableFacility.UpgradeLevel[]> facilityLevels = new Dictionary<SpaceCenterFacility, Upgradeables.UpgradeableFacility.UpgradeLevel[]>(); | ||
|
||
#region Instance | ||
|
||
private static MaintenanceHandler _instance = null; | ||
public static MaintenanceHandler Instance | ||
{ | ||
get | ||
{ | ||
return _instance; | ||
} | ||
} | ||
|
||
#endregion | ||
|
||
#endregion | ||
|
||
#region Overrides and Monobehaviour methods | ||
|
||
public override void OnAwake() | ||
{ | ||
|
||
if (_instance != null) | ||
{ | ||
GameObject.Destroy(_instance); | ||
} | ||
_instance = this; | ||
} | ||
|
||
public void Update() | ||
{ | ||
if (HighLogic.CurrentGame == null) | ||
return; | ||
|
||
if (facilityLevels.Count == 0) | ||
{ | ||
foreach (Upgradeables.UpgradeableFacility facility in GameObject.FindObjectsOfType<Upgradeables.UpgradeableFacility>()) | ||
{ | ||
facilityLevels[(SpaceCenterFacility)Enum.Parse(typeof(SpaceCenterFacility), facility.name)] = facility.UpgradeLevels; | ||
} | ||
} | ||
|
||
double time = Planetarium.GetUniversalTime(); | ||
if (nextUpdate > time) | ||
{ | ||
if (wasWarpingHigh && TimeWarp.CurrentRate <= 100f) | ||
wasWarpingHigh = false; | ||
else | ||
return; | ||
} | ||
|
||
Upgradeables.UpgradeableFacility.UpgradeLevel[] levels; | ||
double facilityUpkeep = 0d; | ||
|
||
// Pad | ||
if (facilityLevels.TryGetValue(SpaceCenterFacility.LaunchPad, out levels)) | ||
{ | ||
if (kctResearcRate > 0d) | ||
{ | ||
int lC = levels.Length - 1; | ||
for (int i = kctPadCounts.Length; i-- > 0;) | ||
{ | ||
if (i > lC) | ||
continue; | ||
|
||
facilityUpkeep += facilityLevelCostMult * levels[i].levelCost; | ||
} | ||
} | ||
else | ||
facilityUpkeep += facilityLevelCostMult * levels[(int)(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.LaunchPad) * (levels.Length + 0.05f))].levelCost; | ||
} | ||
|
||
// Runway | ||
if (facilityLevels.TryGetValue(SpaceCenterFacility.Runway, out levels)) | ||
facilityUpkeep += facilityLevelCostMult * levels[(int)(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.Runway) * (levels.Length + 0.05f))].levelCost; | ||
|
||
//VAB | ||
if (facilityLevels.TryGetValue(SpaceCenterFacility.VehicleAssemblyBuilding, out levels)) | ||
facilityUpkeep += facilityLevelCostMult * levels[(int)(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.VehicleAssemblyBuilding) * (levels.Length + 0.05f))].levelCost; | ||
|
||
//SPH | ||
if (facilityLevels.TryGetValue(SpaceCenterFacility.SpaceplaneHangar, out levels)) | ||
facilityUpkeep += facilityLevelCostMult * levels[(int)(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.SpaceplaneHangar) * (levels.Length + 0.05f))].levelCost; | ||
|
||
//RnD | ||
if (facilityLevels.TryGetValue(SpaceCenterFacility.ResearchAndDevelopment, out levels)) | ||
facilityUpkeep += facilityLevelCostMult * levels[(int)(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.ResearchAndDevelopment) * (levels.Length + 0.05f))].levelCost; | ||
|
||
// MC | ||
if (facilityLevels.TryGetValue(SpaceCenterFacility.MissionControl, out levels)) | ||
facilityUpkeep += facilityLevelCostMult * levels[(int)(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.MissionControl) * (levels.Length + 0.05f))].levelCost; | ||
|
||
// TS | ||
if (facilityLevels.TryGetValue(SpaceCenterFacility.TrackingStation, out levels)) | ||
facilityUpkeep += facilityLevelCostMult * levels[(int)(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.TrackingStation) * (levels.Length + 0.05f))].levelCost; | ||
|
||
// AC | ||
if (facilityLevels.TryGetValue(SpaceCenterFacility.AstronautComplex, out levels)) | ||
facilityUpkeep += facilityLevelCostMult * levels[(int)(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.AstronautComplex) * (levels.Length + 0.05f))].levelCost; | ||
|
||
|
||
double nautUpkeep = HighLogic.CurrentGame.CrewRoster.GetActiveCrewCount() | ||
* (nautYearlyUpkeepBase | ||
+ ((double)ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.AstronautComplex) | ||
* nautYearlyUpkeepAdd)) | ||
* (1d / (86400d * 365d)); | ||
|
||
double kctBPUpkeep = kctBuildRate * kctBPMult; | ||
double kctRDUpkeep = kctResearcRate * kctResearchMult; | ||
|
||
double totalUpkeep = facilityUpkeep + kctBPUpkeep + kctRDUpkeep + nautUpkeep; | ||
|
||
double timePassed = time - lastUpdate; | ||
|
||
Funding.Instance.AddFunds(-timePassed * (totalUpkeep * (1d / 86400d)), TransactionReasons.StructureRepair); | ||
|
||
lastUpdate = time; | ||
|
||
if (TimeWarp.CurrentRate <= 100f) | ||
{ | ||
wasWarpingHigh = false; | ||
if (HighLogic.LoadedScene == GameScenes.SPACECENTER) | ||
{ | ||
PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), | ||
new Vector2(0.5f, 0.5f), | ||
"Maintenance", | ||
"We are paying the following maintenance costs per day/year:\nFacilities: " | ||
+ facilityUpkeep.ToString("N0") + "/" + (facilityUpkeep * 365d).ToString("N0") | ||
+ "\nIntegration / Pad Support Teams: " + (kctBPUpkeep).ToString("N0") + "/" + (kctBPUpkeep*365d).ToString("N0") | ||
+ "\nResarch Teams:" + (kctRDUpkeep).ToString("N0") + "/" + (kctRDUpkeep* 365d).ToString("N0") | ||
+ "\nAstronauts:" + (nautUpkeep).ToString("N0") + "/" + (nautUpkeep* 365d).ToString("N0"), | ||
"OK", | ||
true, | ||
HighLogic.UISkin); | ||
} | ||
nextUpdate = time + updateInterval; | ||
} | ||
else | ||
{ | ||
wasWarpingHigh = true; | ||
nextUpdate = time + updateInterval * (TimeWarp.CurrentRate * (1f / 100f)); | ||
} | ||
} | ||
|
||
public void OnDestroy() | ||
{ | ||
|
||
} | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("RP0KCTBinder")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("RP0KCTBinder")] | ||
[assembly: AssemblyCopyright("Copyright © 2017")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("13cd17e5-381c-4782-b5f0-3da46513eeb8")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{13CD17E5-381C-4782-B5F0-3DA46513EEB8}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>RP0KCTBinder</RootNamespace> | ||
<AssemblyName>RP0KCTBinder</AssemblyName> | ||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<TargetFrameworkProfile /> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>TRACE;DEBUG</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>none</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>..\GameData\RP-0\Plugins\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"> | ||
<DebugSymbols>true</DebugSymbols> | ||
<OutputPath>bin\x86\Debug\</OutputPath> | ||
<DefineConstants>TRACE;DEBUG</DefineConstants> | ||
<DebugType>full</DebugType> | ||
<PlatformTarget>x86</PlatformTarget> | ||
<ErrorReport>prompt</ErrorReport> | ||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'"> | ||
<OutputPath>bin\x86\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<Optimize>true</Optimize> | ||
<PlatformTarget>x86</PlatformTarget> | ||
<ErrorReport>prompt</ErrorReport> | ||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="KCTBinderModule.cs" /> | ||
<Compile Include="Properties\AssemblyInfoKCT.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Reference Include="Assembly-CSharp"> | ||
<HintPath>..\..\..\Managed\Assembly-CSharp.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="Assembly-CSharp-firstpass, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>..\..\..\..\..\..\Games\Steam\steamapps\common\Kerbal Space Program\KSP_x64_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="KerbalConstructionTime"> | ||
<HintPath>..\..\..\..\..\..\Games\RO_122\GameData\KerbalConstructionTime\plugins\KerbalConstructionTime.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System"> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="UnityEngine"> | ||
<HintPath>..\..\..\Managed\UnityEngine.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="UnityEngine.UI"> | ||
<HintPath>..\..\..\Managed\UnityEngine.UI.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="RP0.csproj"> | ||
<Project>{997854f8-4efb-4a78-87bc-f7c8cea64669}</Project> | ||
<Name>RP0</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<PropertyGroup> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<PostBuildEvent>del "System.Core.dll"</PostBuildEvent> | ||
</PropertyGroup> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |