Merge branch 'master' of https://github.com/Regalis11/Barotrauma.git
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)
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Barotrauma
|
||||
const float ConversationIntervalMax = 180.0f;
|
||||
const float ConversationIntervalMultiplierMultiplayer = 5.0f;
|
||||
private float conversationTimer, conversationLineTimer;
|
||||
private readonly List<Pair<Character, string>> pendingConversationLines = new List<Pair<Character, string>>();
|
||||
private readonly List<(Character speaker, string line)> pendingConversationLines = new List<(Character speaker, string line)>();
|
||||
|
||||
public const int MaxCrewSize = 16;
|
||||
|
||||
@@ -339,7 +339,7 @@ namespace Barotrauma
|
||||
|
||||
#region Dialog
|
||||
|
||||
public void AddConversation(List<Pair<Character, string>> conversationLines)
|
||||
public void AddConversation(List<(Character speaker, string line)> conversationLines)
|
||||
{
|
||||
if (conversationLines == null || conversationLines.Count == 0) { return; }
|
||||
pendingConversationLines.AddRange(conversationLines);
|
||||
@@ -428,16 +428,16 @@ namespace Barotrauma
|
||||
if (conversationLineTimer <= 0.0f)
|
||||
{
|
||||
//speaker of the next line can't speak, interrupt the conversation
|
||||
if (pendingConversationLines[0].First.SpeechImpediment >= 100.0f)
|
||||
if (pendingConversationLines[0].speaker.SpeechImpediment >= 100.0f)
|
||||
{
|
||||
pendingConversationLines.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
pendingConversationLines[0].First.Speak(pendingConversationLines[0].Second, null);
|
||||
pendingConversationLines[0].speaker.Speak(pendingConversationLines[0].line, null);
|
||||
if (pendingConversationLines.Count > 1)
|
||||
{
|
||||
conversationLineTimer = MathHelper.Clamp(pendingConversationLines[0].Second.Length * 0.1f, 1.0f, 5.0f);
|
||||
conversationLineTimer = MathHelper.Clamp(pendingConversationLines[0].line.Length * 0.1f, 1.0f, 5.0f);
|
||||
}
|
||||
pendingConversationLines.RemoveAt(0);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -14,6 +14,10 @@ namespace Barotrauma
|
||||
{
|
||||
partial class GameSession
|
||||
{
|
||||
#if DEBUG
|
||||
public static float MinimumLoadingTime;
|
||||
#endif
|
||||
|
||||
public enum InfoFrameTab { Crew, Mission, MyCharacter, Traitor };
|
||||
|
||||
public readonly EventManager EventManager;
|
||||
@@ -292,7 +296,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 +307,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);
|
||||
@@ -355,6 +359,9 @@ namespace Barotrauma
|
||||
|
||||
public void StartRound(LevelData? levelData, bool mirrorLevel = false, SubmarineInfo? startOutpost = null, SubmarineInfo? endOutpost = null)
|
||||
{
|
||||
#if DEBUG
|
||||
DateTime startTime = DateTime.Now;
|
||||
#endif
|
||||
AfflictionPrefab.LoadAllEffects();
|
||||
|
||||
MirrorLevel = mirrorLevel;
|
||||
@@ -485,6 +492,15 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
double startDuration = (DateTime.Now - startTime).TotalSeconds;
|
||||
if (startDuration < MinimumLoadingTime)
|
||||
{
|
||||
int sleepTime = (int)((MinimumLoadingTime - startDuration) * 1000);
|
||||
DebugConsole.NewMessage($"Stalling round start by {sleepTime / 1000.0f} s (minimum loading time set to {MinimumLoadingTime})...", Color.Magenta);
|
||||
System.Threading.Thread.Sleep(sleepTime);
|
||||
}
|
||||
#endif
|
||||
#if CLIENT
|
||||
if (GameMode is CampaignMode && levelData != null) { SteamAchievementManager.OnBiomeDiscovered(levelData.Biome); }
|
||||
|
||||
|
||||
@@ -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