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
@@ -45,19 +45,24 @@ namespace Barotrauma
public int GetBuyPrice(int level, Location? location = null, ImmutableHashSet<Character>? characterList = null)
{
int maxLevel = Prefab.GetMaxLevelForCurrentSub();
if (level > maxLevel) { maxLevel = level; }
float price = BasePrice;
price += price * MathHelper.Lerp(IncreaseLow, IncreaseHigh, level / (float)maxLevel) / 100f;
int maxLevel = Prefab.MaxLevel;
float lerpAmount = maxLevel is 0
? level // avoid division by 0
: level / (float)maxLevel;
float priceMultiplier = MathHelper.Lerp(IncreaseLow, IncreaseHigh, lerpAmount);
price += price * (priceMultiplier / 100f);
price = location?.GetAdjustedMechanicalCost((int)price) ?? price;
characterList ??= GameSession.GetSessionCrewCharacters(CharacterType.Both);
if (characterList.Any())
{
if (location?.Faction is { } faction && Faction.GetPlayerAffiliationStatus(faction, characterList) is FactionAffiliation.Positive)
if (location?.Faction is { } faction && Faction.GetPlayerAffiliationStatus(faction) is FactionAffiliation.Positive)
{
price *= 1f - characterList.Max(static c => c.GetStatValue(StatTypes.ShipyardBuyMultiplierAffiliated));
}
@@ -206,11 +211,10 @@ namespace Barotrauma
_ => throw new ArgumentOutOfRangeException()
};
public bool AppliesTo(SubmarineInfo sub)
public bool AppliesTo(SubmarineClass subClass, int subTier)
{
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);
@@ -223,9 +227,9 @@ namespace Barotrauma
return subTier == tier;
}
if (tierOrClass.TryGet(out SubmarineClass subClass))
if (tierOrClass.TryGet(out SubmarineClass targetClass))
{
return sub.SubmarineClass == subClass;
return subClass == targetClass;
}
return false;
@@ -504,15 +508,19 @@ namespace Barotrauma
{
int level = MaxLevel;
foreach (UpgradeMaxLevelMod mod in MaxLevelsMods)
{
if (mod.AppliesTo(info)) { level = mod.GetLevelAfter(level); }
}
int tier = info.Tier;
if (GameMain.GameSession?.Campaign?.CampaignMetadata is { } metadata)
{
int modifier = metadata.GetInt(new Identifier($"tiermodifiers.{Identifier}"), 0);
level += modifier;
tier += modifier;
}
tier = Math.Clamp(tier, 1, SubmarineInfo.HighestTier);
foreach (UpgradeMaxLevelMod mod in MaxLevelsMods)
{
if (mod.AppliesTo(info.SubmarineClass, tier)) { level = mod.GetLevelAfter(level); }
}
return level;
@@ -558,7 +566,7 @@ namespace Barotrauma
foreach (Item item in itemsToRemove)
{
item.Remove();
Entity.Spawner.AddItemToRemoveQueue(item);
}
if (GameMain.IsMultiplayer) { character.Inventory.CreateNetworkEvent(); }