Unstable v0.19.5.0
This commit is contained in:
+13
-9
@@ -1,4 +1,5 @@
|
||||
using Barotrauma.Networking;
|
||||
using System;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
@@ -20,19 +21,22 @@ namespace Barotrauma
|
||||
CharacterInfo = client.CharacterInfo;
|
||||
|
||||
healthData = new XElement("health");
|
||||
client.Character?.CharacterHealth?.Save(healthData);
|
||||
if (client.Character?.Inventory != null)
|
||||
|
||||
//the character may not be controlled by the client atm, but still exist
|
||||
Character character = client.Character ?? CharacterInfo?.Character;
|
||||
|
||||
character?.CharacterHealth?.Save(healthData);
|
||||
if (character?.Inventory != null)
|
||||
{
|
||||
itemData = new XElement("inventory");
|
||||
Character.SaveInventory(client.Character.Inventory, itemData);
|
||||
Character.SaveInventory(character.Inventory, itemData);
|
||||
}
|
||||
OrderData = new XElement("orders");
|
||||
if (client.CharacterInfo != null)
|
||||
if (CharacterInfo != null)
|
||||
{
|
||||
CharacterInfo.SaveOrderData(client.CharacterInfo, OrderData);
|
||||
CharacterInfo.SaveOrderData(CharacterInfo, OrderData);
|
||||
}
|
||||
|
||||
if (client.Character?.Wallet.Save() is { } walletSave)
|
||||
if (character?.Wallet.Save() is { } walletSave)
|
||||
{
|
||||
WalletData = walletSave;
|
||||
}
|
||||
@@ -118,9 +122,9 @@ namespace Barotrauma
|
||||
character.SpawnInventoryItems(inventory, itemData.FromPackage(null));
|
||||
}
|
||||
|
||||
public void ApplyHealthData(Character character)
|
||||
public void ApplyHealthData(Character character, Func<AfflictionPrefab, bool> afflictionPredicate = null)
|
||||
{
|
||||
CharacterInfo.ApplyHealthData(character, healthData);
|
||||
CharacterInfo.ApplyHealthData(character, healthData, afflictionPredicate);
|
||||
}
|
||||
|
||||
public void ApplyOrderData(Character character)
|
||||
|
||||
+7
-8
@@ -917,15 +917,14 @@ namespace Barotrauma
|
||||
|
||||
foreach (var kvp in purchasedItems)
|
||||
{
|
||||
foreach (var purchasedItemList in purchasedItems.Values)
|
||||
var storeId = kvp.Key;
|
||||
var purchasedItemList = kvp.Value;
|
||||
foreach (var purchasedItem in purchasedItemList)
|
||||
{
|
||||
foreach (var purchasedItem in purchasedItemList)
|
||||
{
|
||||
int availableQuantity = map.CurrentLocation.Stores[kvp.Key].Stock.Find(s => s.ItemPrefab == purchasedItem.ItemPrefab)?.Quantity ?? 0;
|
||||
purchasedItem.Quantity = Math.Min(purchasedItem.Quantity, availableQuantity);
|
||||
}
|
||||
}
|
||||
CargoManager.PurchaseItems(kvp.Key, kvp.Value, false, sender);
|
||||
int availableQuantity = map.CurrentLocation.Stores[storeId].Stock.Find(s => s.ItemPrefab == purchasedItem.ItemPrefab)?.Quantity ?? 0;
|
||||
purchasedItem.Quantity = Math.Min(purchasedItem.Quantity, availableQuantity);
|
||||
}
|
||||
CargoManager.PurchaseItems(storeId, purchasedItemList, false, sender);
|
||||
}
|
||||
|
||||
foreach (var (storeIdentifier, items) in CargoManager.PurchasedItems)
|
||||
|
||||
Reference in New Issue
Block a user