Build 0.17.13.0
This commit is contained in:
@@ -5,6 +5,7 @@ using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Barotrauma
|
||||
@@ -28,6 +29,8 @@ namespace Barotrauma
|
||||
protected GUIFrame campaignUIContainer;
|
||||
public CampaignUI CampaignUI;
|
||||
|
||||
public static CancellationTokenSource StartRoundCancellationToken { get; private set; }
|
||||
|
||||
public bool ForceMapUI
|
||||
{
|
||||
get;
|
||||
@@ -99,6 +102,16 @@ namespace Barotrauma
|
||||
GameMain.Client.ConnectedClients.None(c => c.InGame && (c.IsOwner || c.HasPermission(permissions)));
|
||||
}
|
||||
|
||||
public static bool AllowedToManageWallets()
|
||||
{
|
||||
if (GameMain.Client == null) { return true; }
|
||||
|
||||
return
|
||||
GameMain.Client.HasPermission(ClientPermissions.ManageMoney) ||
|
||||
GameMain.Client.HasPermission(ClientPermissions.ManageCampaign) ||
|
||||
GameMain.Client.IsServerOwner;
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (overlayColor.A > 0)
|
||||
@@ -245,10 +258,11 @@ namespace Barotrauma
|
||||
|
||||
GUI.ClearCursorWait();
|
||||
|
||||
StartRoundCancellationToken = new CancellationTokenSource();
|
||||
var loadTask = Task.Run(async () =>
|
||||
{
|
||||
await Task.Yield();
|
||||
Rand.ThreadId = System.Threading.Thread.CurrentThread.ManagedThreadId;
|
||||
Rand.ThreadId = Thread.CurrentThread.ManagedThreadId;
|
||||
try
|
||||
{
|
||||
GameMain.GameSession.StartRound(newLevel, mirrorLevel: mirror);
|
||||
@@ -258,7 +272,7 @@ namespace Barotrauma
|
||||
roundSummaryScreen.LoadException = e;
|
||||
}
|
||||
Rand.ThreadId = 0;
|
||||
});
|
||||
}, StartRoundCancellationToken.Token);
|
||||
TaskPool.Add("AsyncCampaignStartRound", loadTask, (t) =>
|
||||
{
|
||||
overlayColor = Color.Transparent;
|
||||
|
||||
@@ -37,6 +37,16 @@ namespace Barotrauma
|
||||
public Wallet PersonalWallet => Character.Controlled?.Wallet ?? Wallet.Invalid;
|
||||
public override Wallet Wallet => GetWallet();
|
||||
|
||||
public override int GetBalance(Client client = null)
|
||||
{
|
||||
if (!AllowedToManageWallets())
|
||||
{
|
||||
return PersonalWallet.Balance;
|
||||
}
|
||||
|
||||
return PersonalWallet.Balance + Bank.Balance;
|
||||
}
|
||||
|
||||
public override Wallet GetWallet(Client client = null)
|
||||
{
|
||||
return PersonalWallet;
|
||||
@@ -913,6 +923,31 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public override bool TryPurchase(Client client, int price)
|
||||
{
|
||||
if (!AllowedToManageCampaign(ClientPermissions.ManageCampaign))
|
||||
{
|
||||
return PersonalWallet.TryDeduct(price);
|
||||
}
|
||||
|
||||
int balance = PersonalWallet.Balance;
|
||||
|
||||
if (balance >= price)
|
||||
{
|
||||
return PersonalWallet.TryDeduct(price);
|
||||
}
|
||||
|
||||
if (balance + Bank.Balance >= price)
|
||||
{
|
||||
int remainder = price - balance;
|
||||
if (balance > 0) { PersonalWallet.Deduct(balance); }
|
||||
Bank.Deduct(remainder);
|
||||
return true ;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Save(XElement element)
|
||||
{
|
||||
//do nothing, the clients get the save files from the server
|
||||
|
||||
Reference in New Issue
Block a user