Faction Test v1.0.1.0

This commit is contained in:
Regalis11
2023-02-16 15:01:28 +02:00
parent caa5a2f762
commit 2c5a7923b0
309 changed files with 7502 additions and 4335 deletions
@@ -692,11 +692,13 @@ namespace Barotrauma
/// Gets the progress that is shown on the store interface.
/// Includes values stored in the metadata and <see cref="PendingUpgrades"/>, and takes submarine tier and class restrictions into account
/// </summary>
public int GetUpgradeLevel(UpgradePrefab prefab, UpgradeCategory category)
/// <param name="info">Submarine used to determine the upgrade limit. If not defined, will default to the current sub.</param>
public int GetUpgradeLevel(UpgradePrefab prefab, UpgradeCategory category, SubmarineInfo? info = null)
{
if (!Metadata.HasKey(FormatIdentifier(prefab, category))) { return GetPendingLevel(); }
return Math.Min(GetRealUpgradeLevel(prefab, category) + GetPendingLevel(), prefab.GetMaxLevelForCurrentSub());
int maxLevel = info is null ? prefab.GetMaxLevelForCurrentSub() : prefab.GetMaxLevel(info);
return Math.Min(GetRealUpgradeLevel(prefab, category) + GetPendingLevel(), maxLevel);
int GetPendingLevel()
{
@@ -713,6 +715,14 @@ namespace Barotrauma
return !Metadata.HasKey(FormatIdentifier(prefab, category)) ? 0 : Metadata.GetInt(FormatIdentifier(prefab, category), 0);
}
/// <summary>
/// Gets the level of the upgrade that is stored in the metadata. Takes into account the limits of the provided submarine.
/// </summary>
public int GetRealUpgradeLevelForSub(UpgradePrefab prefab, UpgradeCategory category, SubmarineInfo info)
{
return Math.Min(GetRealUpgradeLevel(prefab, category), prefab.GetMaxLevel(info));
}
/// <summary>
/// Stores the target upgrade level in the campaign metadata.
/// </summary>