Build 0.17.13.0
This commit is contained in:
@@ -316,7 +316,7 @@ namespace Barotrauma
|
||||
}
|
||||
// Exchange money
|
||||
int itemValue = item.Quantity * buyValues[item.ItemPrefab];
|
||||
campaign.GetWallet(client).TryDeduct(itemValue);
|
||||
campaign.TryPurchase(client, itemValue);
|
||||
GameAnalyticsManager.AddMoneySpentEvent(itemValue, GameAnalyticsManager.MoneySink.Store, item.ItemPrefab.Identifier.Value);
|
||||
store.Balance += itemValue;
|
||||
if (removeFromCrate)
|
||||
|
||||
@@ -227,6 +227,21 @@ namespace Barotrauma
|
||||
return Bank;
|
||||
}
|
||||
|
||||
public virtual bool TryPurchase(Client client, int price)
|
||||
{
|
||||
return GetWallet(client).TryDeduct(price);
|
||||
}
|
||||
|
||||
public virtual int GetBalance(Client client = null)
|
||||
{
|
||||
return GetWallet(client).Balance;
|
||||
}
|
||||
|
||||
public bool CanAfford(int cost, Client client = null)
|
||||
{
|
||||
return GetBalance(client) >= cost;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The location that's displayed as the "current one" in the map screen. Normally the current outpost or the location at the start of the level,
|
||||
/// but when selecting the next destination at the end of the level at an uninhabited location we use the location at the end
|
||||
@@ -766,7 +781,7 @@ namespace Barotrauma
|
||||
public bool TryHireCharacter(Location location, CharacterInfo characterInfo, Client client = null)
|
||||
{
|
||||
if (characterInfo == null) { return false; }
|
||||
if (!GetWallet(client).TryDeduct(characterInfo.Salary)) { return false; }
|
||||
if (!TryPurchase(client, characterInfo.Salary)) { return false; }
|
||||
characterInfo.IsNewHire = true;
|
||||
location.RemoveHireableCharacter(characterInfo);
|
||||
CrewManager.AddCharacterInfo(characterInfo);
|
||||
|
||||
@@ -292,7 +292,7 @@ namespace Barotrauma
|
||||
|
||||
if ((GameMain.NetworkMember is null || GameMain.NetworkMember is { IsServer: true }) && cost > 0)
|
||||
{
|
||||
Campaign!.GetWallet(client).TryDeduct(cost);
|
||||
Campaign!.TryPurchase(client, cost);
|
||||
}
|
||||
GameAnalyticsManager.AddMoneySpentEvent(cost, GameAnalyticsManager.MoneySink.SubmarineSwitch, newSubmarine.Name);
|
||||
Campaign!.PendingSubmarineSwitch = newSubmarine;
|
||||
@@ -303,7 +303,7 @@ namespace Barotrauma
|
||||
public void PurchaseSubmarine(SubmarineInfo newSubmarine, Client? client = null)
|
||||
{
|
||||
if (Campaign is null) { return; }
|
||||
if ((GameMain.NetworkMember is null || GameMain.NetworkMember is { IsServer: true }) && !Campaign.GetWallet(client).TryDeduct(newSubmarine.Price)) { return; }
|
||||
if ((GameMain.NetworkMember is null || GameMain.NetworkMember is { IsServer: true }) && !Campaign.TryPurchase(client, newSubmarine.Price)) { return; }
|
||||
if (!OwnedSubmarines.Any(s => s.Name == newSubmarine.Name))
|
||||
{
|
||||
GameAnalyticsManager.AddMoneySpentEvent(newSubmarine.Price, GameAnalyticsManager.MoneySink.SubmarinePurchase, newSubmarine.Name);
|
||||
|
||||
@@ -213,7 +213,7 @@ namespace Barotrauma
|
||||
if (!force)
|
||||
{
|
||||
if (IsOutpostInCombat()) { return HealRequestResult.Refused; }
|
||||
if (!GetWallet(client).TryDeduct(totalCost)) { return HealRequestResult.InsufficientFunds; }
|
||||
if (!(campaign?.TryPurchase(client, totalCost) ?? false)) { return HealRequestResult.InsufficientFunds; }
|
||||
}
|
||||
|
||||
ImmutableArray<CharacterInfo> crew = GetCrewCharacters();
|
||||
@@ -314,10 +314,7 @@ namespace Barotrauma
|
||||
|
||||
private int GetAdjustedPrice(int price) => campaign?.Map?.CurrentLocation is { Type: { HasOutpost: true } } currentLocation ? currentLocation.GetAdjustedHealCost(price) : int.MaxValue;
|
||||
|
||||
public Wallet GetWallet(Client? c = null)
|
||||
{
|
||||
return campaign?.GetWallet(c) ?? Wallet.Invalid;
|
||||
}
|
||||
public int GetBalance() => campaign?.GetBalance() ?? 0;
|
||||
|
||||
public static ImmutableArray<CharacterInfo> GetCrewCharacters()
|
||||
{
|
||||
|
||||
@@ -216,7 +216,7 @@ namespace Barotrauma
|
||||
price = 0;
|
||||
}
|
||||
|
||||
if (Campaign.GetWallet(client).TryDeduct(price))
|
||||
if (Campaign.TryPurchase(client, price))
|
||||
{
|
||||
if (GameMain.NetworkMember == null || GameMain.NetworkMember.IsServer)
|
||||
{
|
||||
@@ -313,7 +313,7 @@ namespace Barotrauma
|
||||
price = 0;
|
||||
}
|
||||
|
||||
if (Campaign.GetWallet(client).TryDeduct(price))
|
||||
if (Campaign.TryPurchase(client, price))
|
||||
{
|
||||
PurchasedItemSwaps.RemoveAll(p => linkedItems.Contains(p.ItemToRemove));
|
||||
if (GameMain.NetworkMember == null || GameMain.NetworkMember.IsServer)
|
||||
|
||||
Reference in New Issue
Block a user