Skip to content

Commit

Permalink
Handle the ResearchBodies Observatory
Browse files Browse the repository at this point in the history
  • Loading branch information
severedsolo committed Jun 4, 2020
1 parent 63eaefe commit c1fa059
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 121 deletions.
1 change: 1 addition & 0 deletions .idea/.idea.Bureaucracy/.idea/contentModel.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

201 changes: 82 additions & 119 deletions .idea/.idea.Bureaucracy/.idea/workspace.xml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Bureaucracy/Bureaucracy.csproj
Expand Up @@ -99,6 +99,7 @@
<Compile Include="RandomEvents\TrainingEvent.cs" />
<Compile Include="RandomEvents\WageEvent.cs" />
<Compile Include="Report.cs" />
<Compile Include="ResearchBodiesWrapper.cs" />
<Compile Include="Science\ResearchManager.cs" />
<Compile Include="Science\ScienceEvent.cs" />
<Compile Include="Science\ScienceReport.cs" />
Expand Down
9 changes: 9 additions & 0 deletions Bureaucracy/Facilities/BureaucracyFacility.cs
Expand Up @@ -48,6 +48,12 @@ public BureaucracyFacility(SpaceCenterFacility spf)
Debug.Log("[Bureaucracy]: Setup Facility " + Name);
}

public BureaucracyFacility(string facilityName)
{
Name = facilityName;
upkeepCost = SetCosts();
Debug.Log("[Bureaucracy]: Setup Facility " + Name);
}
private int GetFacilityLevel()
{
foreach (KeyValuePair<string, ScenarioUpgradeableFacilities.ProtoUpgradeable> config in ScenarioUpgradeableFacilities.protoUpgradeables)
Expand Down Expand Up @@ -118,6 +124,9 @@ private int SetCosts()
case "VehicleAssemblyBuilding":
cost = SettingsClass.Instance.VabCost;
break;
case "Observatory":
cost = SettingsClass.Instance.ObservatoryCost;
break;
case "Other Facility":
cost = SettingsClass.Instance.OtherFacilityCost;
break;
Expand Down
3 changes: 3 additions & 0 deletions Bureaucracy/Facilities/FacilityManager.cs
Expand Up @@ -24,6 +24,9 @@ public FacilityManager()
SpaceCenterFacility spf = spaceCentreFacilities.ElementAt(i);
Facilities.Add(new BureaucracyFacility(spf));
}
//RB loads super late, well after we're done here, so we need to check if it's installed and set up a BureaucracyFacility for the Observatory.
ResearchBodiesWrapper rw = new ResearchBodiesWrapper();
if(rw.RBInstalled()) Facilities.Add(new BureaucracyFacility("Observatory"));
Name = "Construction";
ThisMonthsBudget = HighLogic.CurrentGame.Parameters.Career.StartingFunds * FundingAllocation;
Instance = this;
Expand Down
24 changes: 24 additions & 0 deletions Bureaucracy/ResearchBodiesWrapper.cs
@@ -0,0 +1,24 @@
using System;
using System.Reflection;
using UnityEngine;

namespace Bureaucracy
{
public class ResearchBodiesWrapper
{
public bool RBInstalled()
{
Debug.Log("[Bureaucracy]: Checking For ResearchBodies");
//Adapted from Kerbalism.Contracts
//We don't actually need to interface with ResearchBodies, just know if it's installed so FacilityManager can handle the Observatory
foreach (AssemblyLoader.LoadedAssembly a in AssemblyLoader.loadedAssemblies)
{
if (!a.name.Equals("ResearchBodies"))continue;
Debug.Log("[Bureaucracy]: Found ResearchBodies");
return true;
}
Debug.Log("[Bureaucracy]: Did not find ResearchBodies");
return false;
}
}
}
7 changes: 5 additions & 2 deletions Bureaucracy/SettingsClass.cs
Expand Up @@ -29,6 +29,7 @@ public class SettingsClass
public int TrackingStationCost = 4000;
public int RndCost = 8000;
public int VabCost = 8000;
public int ObservatoryCost = 5000;
public int OtherFacilityCost = 5000;
public int LaunchCostSph = 100;
public int LaunchCostVab = 1000;
Expand All @@ -44,7 +45,7 @@ public class SettingsClass
public int StrikeMemory = 6;
public int DeadKerbalPenalty = 25;
private readonly string defaultPath;
private const string SettingsVersion = "1.4";
private const string SettingsVersion = "1.4.0.1";
private const string PreviousVersion = "1.1";
private readonly string savePath;

Expand Down Expand Up @@ -119,13 +120,14 @@ private void OnLoad(string path)
int.TryParse(cn.GetValue("BaseStrikesBeforeKerbalQuits"), out BaseStrikesToQuit);
int.TryParse(cn.GetValue("StrikeMemoryMonths"), out StrikeMemory);
int.TryParse(cn.GetValue("DeadKerbalRepPenaltyPercent"), out DeadKerbalPenalty);
if (saveVersion == "1.4")
if (saveVersion == "1.4.0.1")
{
bool.TryParse(cn.GetValue("RetirementEnabled"), out RetirementEnabled);
double.TryParse(cn.GetValue("RetirementExtensionFactor"), out RetirementExtensionFactor);
int.TryParse(cn.GetValue("MinimumTerm"), out MinimumTerm);
int.TryParse(cn.GetValue("MaximumTerm"), out MaximumTerm);
int.TryParse(cn.GetValue("BaseTrainingFee"), out BaseTrainingFee);
int.TryParse(cn.GetValue("ObservatoryCost"), out ObservatoryCost);
}
if (RefreshBudget())
{
Expand Down Expand Up @@ -205,6 +207,7 @@ private void OnSave(string path)
cn.SetValue("TrackingStationBaseCost", TrackingStationCost, true);
cn.SetValue("RndBaseCost", RndCost, true);
cn.SetValue("VABBaseCost", VabCost, true);
cn.SetValue("ObservatoryCost", ObservatoryCost, true);
cn.SetValue("ModFacilityBaseCost", OtherFacilityCost, true);
cn.SetValue("BaseLaunchCostSPH", LaunchCostSph, true);
cn.SetValue("BaseLaunchCostVAB", LaunchCostVab, true);
Expand Down

0 comments on commit c1fa059

Please sign in to comment.