Build 0.20.0.0

This commit is contained in:
Markus Isberg
2022-10-27 17:54:57 +03:00
parent 05c7b1f869
commit edaf4b09fe
197 changed files with 4344 additions and 1773 deletions
@@ -43,9 +43,9 @@ namespace Barotrauma
}
}
public int GetBuyprice(int level, Location? location = null)
public int GetBuyPrice(int level, Location? location = null)
{
int maxLevel = Prefab.MaxLevel;
int maxLevel = Prefab.GetMaxLevelForCurrentSub();
if (level > maxLevel) { maxLevel = level; }
@@ -209,9 +209,17 @@ namespace Barotrauma
{
if (type is MaxLevelModType.Invalid) { return false; }
int subTier = sub.Tier;
if (GameMain.GameSession?.Campaign?.CampaignMetadata is { } metadata)
{
int modifier = metadata.GetInt(new Identifier("tiermodifieroverride"), 0);
subTier = Math.Max(modifier, subTier);
}
if (tierOrClass.TryGet(out int tier))
{
return sub.Tier == tier;
return subTier == tier;
}
if (tierOrClass.TryGet(out SubmarineClass subClass))
@@ -292,16 +300,10 @@ namespace Barotrauma
onRemoveOverrideFile: null
);
private readonly int maxLevel;
public int MaxLevel
{
get
{
Submarine? sub = GameMain.GameSession?.Submarine ?? Submarine.MainSub;
return sub is { Info: var info } ? GetMaxLevel(info) : maxLevel;
}
}
/// <summary>
/// Maximum upgrade level without taking submarine tier or class restrictions into account
/// </summary>
public readonly int MaxLevel;
public LocalizedString Name { get; }
@@ -343,7 +345,7 @@ namespace Barotrauma
{
Name = element.GetAttributeString("name", string.Empty)!;
Description = element.GetAttributeString("description", string.Empty)!;
maxLevel = element.GetAttributeInt("maxlevel", 1);
MaxLevel = element.GetAttributeInt("maxlevel", 1);
SuppressWarnings = element.GetAttributeBool("supresswarnings", false);
HideInMenus = element.GetAttributeBool("hideinmenus", false);
SourceElement = element;
@@ -428,15 +430,33 @@ namespace Barotrauma
.ToImmutableHashSet() ?? ImmutableHashSet<Identifier>.Empty;
}
/// <summary>
/// Returns the maximum upgrade level for the current sub, taking tier and class restrictions into account
/// </summary>
public int GetMaxLevelForCurrentSub()
{
Submarine? sub = GameMain.GameSession?.Submarine ?? Submarine.MainSub;
return sub is { Info: var info } ? GetMaxLevel(info) : MaxLevel;
}
/// <summary>
/// Returns the maximum upgrade level for the specified sub, taking tier and class restrictions into account
/// </summary>
public int GetMaxLevel(SubmarineInfo info)
{
int level = maxLevel;
int level = MaxLevel;
foreach (UpgradeMaxLevelMod mod in MaxLevelsMods)
{
if (mod.AppliesTo(info)) { level = mod.GetLevelAfter(level); }
}
if (GameMain.GameSession?.Campaign?.CampaignMetadata is { } metadata)
{
int modifier = metadata.GetInt(new Identifier($"tiermodifiers.{Identifier}"), 0);
level += modifier;
}
return level;
}