Skip to content

Commit

Permalink
Fix facility constructions not clearing
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanKell committed Nov 6, 2023
1 parent 66948fc commit 716ca19
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 14 deletions.
9 changes: 5 additions & 4 deletions Source/RP0/Singletons/Database.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,17 @@ public class ResourceInfo
public class Database : MonoBehaviour
{
public static readonly ResourceInfo ResourceInfo = new ResourceInfo();

public static readonly PersistentDictionaryNodeKeyed<PartEffectiveCostModifier> KCTCostModifiers = new PersistentDictionaryNodeKeyed<PartEffectiveCostModifier>();
public static readonly PersistentDictionaryNodeKeyed<TechPeriod> TechNodePeriods = new PersistentDictionaryNodeKeyed<TechPeriod>("id");
public static readonly PersistentDictionaryValueTypes<string, NodeType> NodeTypes = new PersistentDictionaryValueTypes<string, NodeType>();

public static readonly List<SpaceCenterFacility> LockedFacilities = new List<SpaceCenterFacility>();
public static readonly Dictionary<SpaceCenterFacility, List<int>> FacilityLevelCosts = new Dictionary<SpaceCenterFacility, List<int>>();
public static int GetFacilityLevelCount(SpaceCenterFacility fac) { return FacilityLevelCosts.ValueOrDefault(fac)?.Count ?? 1; }
public static int GetFacilityLevelCount(string facilityID) { return Database.GetFacilityLevelCount(Database.FacilityIDToFacility.ValueOrDefault(facilityID)); }
public static readonly Dictionary<string, SpaceCenterFacility> FacilityIDToFacility = new Dictionary<string, SpaceCenterFacility>();

public static readonly Dictionary<string, string> TechNameToTitle = new Dictionary<string, string>();
public static readonly Dictionary<string, List<string>> TechNameToParents = new Dictionary<string, List<string>>();
public static readonly PersistentDictionaryNodeKeyed<TechPeriod> TechNodePeriods = new PersistentDictionaryNodeKeyed<TechPeriod>("id");
public static readonly PersistentDictionaryValueTypes<string, NodeType> NodeTypes = new PersistentDictionaryValueTypes<string, NodeType>();
public static readonly Dictionary<string, Dictionary<string, HashSet<ExperimentSituations>>> StartCompletedExperiments = new Dictionary<string, Dictionary<string, HashSet<ExperimentSituations>>>();

public static readonly SpaceCenterSettings SettingsSC = new SpaceCenterSettings();
Expand Down
5 changes: 1 addition & 4 deletions Source/RP0/Singletons/SingletonHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,8 @@ public void Awake()
// Poke Kerbalism
KERBALISM.Settings.UseSamplingSunFactor = true;

// Cache facility ID -> enum
foreach (var kvp in ScenarioUpgradeableFacilities.facilityStrings)
Database.FacilityIDToFacility[kvp.Value] = kvp.Key;

List<Type> singletonTypes = KSPUtils.GetAllLoadedTypes<HostedSingleton>();
List <Type> singletonTypes = KSPUtils.GetAllLoadedTypes<HostedSingleton>();
foreach (var t in singletonTypes)
{
HostedSingleton s = (HostedSingleton)Activator.CreateInstance(t, new System.Object[] { this });
Expand Down
2 changes: 1 addition & 1 deletion Source/RP0/SpaceCenter/Projects/FacilityUpgradeProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void Apply()
facility.SetLevel(upgradeLevel);
}

int newLvl = KCTUtilities.GetFacilityLevel(id);
int newLvl = KCTUtilities.GetFacilityLevel(sFacilityType);
upgradeProcessed = newLvl == upgradeLevel;
if (upgradeProcessed)
{
Expand Down
5 changes: 0 additions & 5 deletions Source/RP0/Utilities/KCTUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1569,11 +1569,6 @@ public static int GetFacilityLevel(SpaceCenterFacility facility)
return GetIndexFromNorm(ScenarioUpgradeableFacilities.GetFacilityLevel(facility), Database.GetFacilityLevelCount(facility));
}

public static int GetFacilityLevel(string facility)
{
return GetIndexFromNorm(ScenarioUpgradeableFacilities.GetFacilityLevel(facility), Database.GetFacilityLevelCount(facility));
}

/// <summary>
/// Takes a normalized value and converts it to an array index
/// </summary>
Expand Down

0 comments on commit 716ca19

Please sign in to comment.