v1.5.7.0 (Summer Update)

This commit is contained in:
Regalis11
2024-06-18 16:49:51 +03:00
parent 4a63dacbce
commit 230d1b6e78
263 changed files with 7792 additions and 2845 deletions
@@ -295,7 +295,7 @@ namespace Barotrauma
/// <summary>
/// Purchases an item swap and handles logic for deducting the credit.
/// </summary>
public void PurchaseItemSwap(Item itemToRemove, ItemPrefab itemToInstall, bool force = false, Client? client = null)
public void PurchaseItemSwap(Item itemToRemove, ItemPrefab itemToInstall, bool isNetworkMessage = false, Client? client = null)
{
if (!CanUpgradeSub())
{
@@ -343,12 +343,14 @@ namespace Barotrauma
price = itemToInstall.SwappableItem.GetPrice(Campaign.Map?.CurrentLocation) * linkedItems.Count;
}
if (force)
if (isNetworkMessage)
{
price = 0;
}
if (Campaign.TryPurchase(client, price))
//do not try to purchase if this is a network message (if the server is telling us that an item swap was purchased)
//we want to do the purchase no matter what, and the server handles deducting the money
if (isNetworkMessage || Campaign.TryPurchase(client, price))
{
PurchasedItemSwaps.RemoveAll(p => linkedItems.Contains(p.ItemToRemove));
if (GameMain.NetworkMember == null || GameMain.NetworkMember.IsServer)
@@ -433,8 +435,7 @@ namespace Barotrauma
{
if (itemToCancel.PendingItemSwap == null)
{
var replacement = MapEntityPrefab.Find("", swappableItem.ReplacementOnUninstall) as ItemPrefab;
if (replacement == null)
if (MapEntityPrefab.FindByIdentifier(swappableItem.ReplacementOnUninstall) is not ItemPrefab replacement)
{
DebugConsole.ThrowError($"Failed to uninstall item \"{itemToCancel.Name}\". Could not find the replacement item \"{swappableItem.ReplacementOnUninstall}\".");
return;
@@ -786,11 +787,10 @@ namespace Barotrauma
private void LoadPendingUpgrades(XElement? element, bool isSingleplayer = true)
{
if (!(element is { HasElements: true })) { return; }
if (element is not { HasElements: true }) { return; }
List<PurchasedUpgrade> pendingUpgrades = new List<PurchasedUpgrade>();
// ReSharper disable once LoopCanBeConvertedToQuery
foreach (XElement upgrade in element.Elements())
{
Identifier categoryIdentifier = upgrade.GetAttributeIdentifier("category", Identifier.Empty);