Skip to content

Commit

Permalink
version = 1.7.3
Browse files Browse the repository at this point in the history
1.) Hotfix for a bug that could zero newgame budgets.
2.) More UI improvements courtesy Github user AlexSkylark.
3.) Numerous display text improvements to be less confusing for the end user.
4.) Level 1 facilities are now 2/3rds of base maintanence cost to help with early game.
5.) LaunchCosts are now displayed properly.
6.) UseItorLoseIt is now default off.
  • Loading branch information
R-T-B committed Dec 1, 2024
1 parent 2a0aad4 commit ad67103
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 49 deletions.
6 changes: 3 additions & 3 deletions Bureaucracy/Budget/BudgetEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public override void OnEventCompleted()
funding -= CrewManager.Instance.Bonuses(funding, true);
double facilityDebt = Costs.Instance.GetFacilityMaintenanceCosts();
double wageDebt = Math.Abs(funding + facilityDebt);
if (funding < 0)
if (funding <= 0)
{
Debug.Log("[Bureaucracy]: Funding < 0. Paying debts");
Debug.Log("[Bureaucracy]: Funding <= 0. Paying debts");
//pay wages first then facilities
Utilities.Instance.PayWageDebt(wageDebt);
Utilities.Instance.PayFacilityDebt(facilityDebt, wageDebt);
Expand All @@ -56,7 +56,6 @@ public override void OnEventCompleted()
if(!SettingsClass.Instance.UseItOrLoseIt || Funding.Instance.Funds <= 0.0d || funding <= 0.0d || Utilities.Instance.IsBootstrapBudgetCycle) Funding.Instance.AddFunds(funding, TransactionReasons.Contracts);
Debug.Log("[Bureaucracy]: OnBudgetAwarded. Awarding "+funding+" Costs: "+facilityDebt);
InternalListeners.OnBudgetAwarded.Fire(funding, facilityDebt);
Costs.Instance.ResetLaunchCosts();
repDecay.ApplyRepDecay(Bureaucracy.Instance.settings.RepDecayPercent);


Expand All @@ -82,6 +81,7 @@ public override void OnEventCompleted()
}

InformParent();
Costs.Instance.ResetLaunchCosts();
}

}
Expand Down
2 changes: 1 addition & 1 deletion Bureaucracy/Budget/BudgetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void OnLoad(ConfigNode cn)
CreateNewBudget(nextBudgetTime);
}
else Bureaucracy.Instance.YieldAndCreateBudgetOnNewGame();
ConfigNode costsNode = cn.GetNode("COSTS");
ConfigNode costsNode = managerNode.GetNode("COSTS");
Costs.Instance.OnLoad(costsNode);
Debug.Log("[Bureaucracy]: Budget Manager: OnLoad Complete");
}
Expand Down
9 changes: 7 additions & 2 deletions Bureaucracy/Budget/BudgetReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@ public override string ReportBody()
ReportBuilder.AppendLine($"Net Budget: {Utilities.Instance.FundsSymbol}{Math.Max(0, netBudget)}");
if (netBudget > 0 && netBudget < Funding.Instance.Funds) ReportBuilder.AppendLine("We can't justify extending your funding");
// ReSharper disable once InvertIf
if (netBudget < 0)
if (netBudget + Utilities.Instance.fundsStored < 0)
{
ReportBuilder.AppendLine("The budget didn't fully cover your space programs costs.");
ReportBuilder.Append($"A penalty of {Utilities.Instance.FundsSymbol}{Math.Round(netBudget, 0)} will be applied");
ReportBuilder.Append($"A budget shortfall of {Utilities.Instance.FundsSymbol}{Math.Round(netBudget + Utilities.Instance.fundsStored, 0)} was experienced.");
}
else if (netBudget < 0)
{
ReportBuilder.AppendLine("The budget didn't fully cover your space programs costs, so we used your remaining treasury to pay dues.");
ReportBuilder.Append($"This cost {Utilities.Instance.FundsSymbol}{Math.Round(Math.Abs(netBudget), 0)} from our treasury.");
}
return ReportBuilder.ToString();
}
Expand Down
5 changes: 2 additions & 3 deletions Bureaucracy/Budget/Costs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public double GetTotalMaintenanceCosts()
costs += GetFacilityMaintenanceCosts();
costs += GetWageCosts();
costs += GetLaunchCosts();
cachedCosts = costs;
cachedCosts = Math.Round(costs);
costsDirty = false;
Debug.Log("[Bureaucracy]: Cached costs "+costs+". Setting Costs not dirty for next 5 seconds");
Debug.Log("[Bureaucracy]: Cached costs " + Math.Round(costs) + ". Setting Costs not dirty for next 5 seconds");
Bureaucracy.Instance.Invoke(nameof(Bureaucracy.Instance.SetCalcsDirty), 5.0f);
return Math.Round(costs);
}
Expand Down Expand Up @@ -90,7 +90,6 @@ public double GetFacilityMaintenanceCosts()
for (int i = 0; i < FacilityManager.Instance.Facilities.Count; i++)
{
BureaucracyFacility bf = FacilityManager.Instance.Facilities.ElementAt(i);
if (bf.IsClosed) continue;
d += bf.MaintenanceCost * FacilityManager.Instance.CostMultiplier;
}
}
Expand Down
41 changes: 13 additions & 28 deletions Bureaucracy/Bureaucracy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,47 +34,47 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>D:\KSPDebug\KSP_x64_Data\Managed\Assembly-CSharp.dll</HintPath>
<HintPath>C:\Program Files\Kerbal Space Program\KSP_x64_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>D:\KSPDebug\KSP_x64_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
<HintPath>C:\Program Files\Kerbal Space Program\KSP_x64_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="FlightTracker">
<HintPath>..\..\..\..\Desktop\UABE\FlightTracker.dll</HintPath>
<HintPath>..\..\..\..\..\..\..\Program Files\Kerbal Space Program\GameData\FlightTracker\FlightTracker.dll</HintPath>
</Reference>
<Reference Include="mscorlib">
<HintPath>H:\KSP1123\KSP_x64_Data\Managed\mscorlib.dll</HintPath>
<HintPath>C:\Program Files\Kerbal Space Program\KSP_x64_Data\Managed\mscorlib.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration">
<HintPath>H:\KSP1123\KSP_x64_Data\Managed\System.Configuration.dll</HintPath>
<HintPath>C:\Program Files\Kerbal Space Program\KSP_x64_Data\Managed\System.Configuration.dll</HintPath>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Security">
<HintPath>H:\KSP1123\KSP_x64_Data\Managed\System.Security.dll</HintPath>
<HintPath>C:\Program Files\Kerbal Space Program\KSP_x64_Data\Managed\System.Security.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<HintPath>D:\KSPDebug\KSP_x64_Data\Managed\UnityEngine.dll</HintPath>
<HintPath>C:\Program Files\Kerbal Space Program\KSP_x64_Data\Managed\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AnimationModule">
<HintPath>D:\KSPDebug\KSP_x64_Data\Managed\UnityEngine.AnimationModule.dll</HintPath>
<HintPath>C:\Program Files\Kerbal Space Program\KSP_x64_Data\Managed\UnityEngine.AnimationModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AssetBundleModule">
<HintPath>D:\KSPDebug\KSP_x64_Data\Managed\UnityEngine.AssetBundleModule.dll</HintPath>
<HintPath>C:\Program Files\Kerbal Space Program\KSP_x64_Data\Managed\UnityEngine.AssetBundleModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>D:\KSPDebug\KSP_x64_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
<HintPath>C:\Program Files\Kerbal Space Program\KSP_x64_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.TextRenderingModule">
<HintPath>D:\KSPDebug\KSP_x64_Data\Managed\UnityEngine.TextRenderingModule.dll</HintPath>
<HintPath>C:\Program Files\Kerbal Space Program\KSP_x64_Data\Managed\UnityEngine.TextRenderingModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>D:\KSPDebug\KSP_x64_Data\Managed\UnityEngine.UI.dll</HintPath>
<HintPath>C:\Program Files\Kerbal Space Program\KSP_x64_Data\Managed\UnityEngine.UI.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UIModule">
<HintPath>D:\KSPDebug\KSP_x64_Data\Managed\UnityEngine.UIModule.dll</HintPath>
<HintPath>C:\Program Files\Kerbal Space Program\KSP_x64_Data\Managed\UnityEngine.UIModule.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -122,21 +122,6 @@
<Compile Include="Utilities.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>echo Running debug post-build event...

xcopy /Y "$(TargetDir)$(ProjectName).dll" "D:\KSPDebug\GameData\Bureaucracy\"

if exist "$(TargetDir)$(ProjectName).pdb" (
xcopy /Y "$(TargetDir)$(ProjectName).pdb" "D:\KSPDebug\GameData\Bureaucracy\"
) else (
echo Target file does not exist. Skipping copy.
)

if "$(ConfigurationName)" == "Release" (
xcopy /Y "$(TargetDir)$(ProjectName).dll" "D:\SteamLibrary\steamapps\common\Kerbal Space Program\GameData"
)</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">
Expand Down
2 changes: 1 addition & 1 deletion Bureaucracy/Facilities/BureaucracyFacility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void CloseFacility()

public bool Upgrading { get; private set; }

public int MaintenanceCost => upkeepCost * (GetFacilityLevel() - 1) + (upkeepCost / 3 * 2);
public int MaintenanceCost => upkeepCost * (GetFacilityLevel() - 1) + (upkeepCost * 2 / 3);
public string Name { get; }

public BureaucracyFacility(SpaceCenterFacility spf)
Expand Down
20 changes: 18 additions & 2 deletions Bureaucracy/Facilities/FacilityReport.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Security.Policy;

namespace Bureaucracy
{
Expand All @@ -14,17 +15,32 @@ public FacilityReport()

public override string ReportBody()
{
bool facilityClosed = false;
ReportBuilder.Clear();
for (int i = 0; i < FacilityManager.Instance.Facilities.Count; i++)
{
BureaucracyFacility bf = FacilityManager.Instance.Facilities.ElementAt(i);
string s = bf.GetProgressReport(bf.Upgrade);
if (bf.IsClosed) ReportBuilder.AppendLine(bf.Name + " is closed");
if (bf.IsClosed)
{
ReportBuilder.AppendLine(bf.Name + " is closed");
facilityClosed = true;
}
if(s == String.Empty) continue;
ReportBuilder.AppendLine(s);
}
if (!facilityClosed)
{
ReportBuilder.AppendLine("All Facilities fully funded!");
}
string report = ReportBuilder.ToString();
if (String.IsNullOrEmpty(report)) report = "No Facility updates to report";
if (report.Length <= 31)
{
ReportBuilder.Clear();
ReportBuilder.AppendLine("All Facilities fully funded!");
ReportBuilder.AppendLine("No Facility updates to report");
report = ReportBuilder.ToString();
}
return report;
}
}
Expand Down
6 changes: 3 additions & 3 deletions Bureaucracy/SettingsClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class SettingsClass
public bool HandleKscUpgrades = true;
public bool HandleScience = true;
public bool StopTimeWarp = true;
public bool UseItOrLoseIt = true;
public bool UseItOrLoseIt = false;
public bool HardMode;
public bool RepDecayEnabled;
public bool RandomEventsEnabled = true;
Expand Down Expand Up @@ -123,8 +123,8 @@ private void OnLoad(string path)
int.TryParse(cn.GetValue("RndBaseCost"), out RndCost);
int.TryParse(cn.GetValue("VABBaseCost"), out VabCost);
int.TryParse(cn.GetValue("ModFacilityBaseCost"), out OtherFacilityCost);
int.TryParse(cn.GetValue("BaseLaunchCostSPH"), out SphCost);
int.TryParse(cn.GetValue("BaseLaunchCostVAB"), out VabCost);
int.TryParse(cn.GetValue("BaseLaunchCostSPH"), out LaunchCostSph);
int.TryParse(cn.GetValue("BaseLaunchCostVAB"), out LaunchCostVab);
int.TryParse(cn.GetValue("CrewBaseWage"), out KerbalBaseWage);
float.TryParse(cn.GetValue("LongTermMissionBonusPerYear"), out LongTermBonusYears);
float.TryParse(cn.GetValue("LongTermMissionBonusPerDay"), out LongTermBonusDays);
Expand Down
13 changes: 8 additions & 5 deletions Bureaucracy/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class Utilities
public double InitialFunds; // for processing of initial cycle
public bool IsBootstrapBudgetCycle; // master flag to control behavior of cycle processing.
public string FundsSymbol = "V";
public double fundsStored;

public Utilities()
{
Expand Down Expand Up @@ -75,7 +76,7 @@ public double GetNetBudget(string department)
if (m == BudgetManager.Instance) continue;
allocation -= m.FundingAllocation;
}
if (funding < 0.0f) return funding;
if (funding <= 0.0f) return funding;
return Math.Round(funding*allocation, 0);
}
case "Construction":
Expand Down Expand Up @@ -114,6 +115,7 @@ public double ConvertMonthlyBudgetToDaily(double amountToConvert)

public void PayWageDebt(double debt)
{
fundsStored = Funding.Instance.Funds;
debt = Math.Abs(debt);
debt -= Funding.Instance.Funds;
if (debt <= 0) return;
Expand All @@ -128,16 +130,17 @@ public void PayWageDebt(double debt)
CrewManager.Instance.ProcessUnpaidKerbals(unpaidKerbals);
}

public void PayFacilityDebt(double debt, double wageDebt)
public void PayFacilityDebt(double facilityDebt, double wageDebt)
{
facilityDebt = Math.Abs(facilityDebt);
double fundsAvailable = Funding.Instance.Funds - wageDebt;
debt -= fundsAvailable;
facilityDebt -= fundsAvailable;
for (int i = 0; i < FacilityManager.Instance.Facilities.Count; i++)
{
BureaucracyFacility bf = FacilityManager.Instance.Facilities.ElementAt(i);
bf.CloseFacility();
debt += bf.MaintenanceCost;
if (debt <= 0) break;
facilityDebt += bf.MaintenanceCost;
if (facilityDebt <= 0) break;
}
}

Expand Down
2 changes: 1 addition & 1 deletion GameData/Bureaucracy/Bureaucracy.version
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"MAJOR" : 1,
"MINOR" : 7,
"PATCH" : 2,
"PATCH" : 3,
"BUILD" : 0
},
"KSP_VERSION" :
Expand Down
10 changes: 10 additions & 0 deletions GameData/Bureaucracy/Changelog.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ KERBALCHANGELOG
showChangelog = True
modName = Bureaucracy
VERSION
{
version = 1.7.3
change = Hotfix for a bug that could zero newgame budgets.
change = More UI improvements courtesy Github user AlexSkylark.
change = Numerous display text improvements to be less confusing for the end user.
change = Level 1 facilities are now 2/3rds of base maintanence cost to help with early game.
change = LaunchCosts are now displayed properly.
change = UseItorLoseIt is now default off.
}
VERSION
{
version = 1.7.2
change = Hotfix for OPM CustomBarnKit Config file mistakes.
Expand Down

0 comments on commit ad67103

Please sign in to comment.