Faction Test v1.0.1.0

This commit is contained in:
Regalis11
2023-02-16 15:01:28 +02:00
parent caa5a2f762
commit 2c5a7923b0
309 changed files with 7502 additions and 4335 deletions
@@ -33,7 +33,7 @@ namespace Barotrauma
protected set;
}
public static CancellationTokenSource StartRoundCancellationToken { get; private set; }
private CancellationTokenSource startRoundCancellationToken;
public bool ForceMapUI
{
@@ -62,10 +62,19 @@ namespace Barotrauma
{
chatBox.ToggleOpen = wasChatBoxOpen;
}
if (!value && CampaignUI?.SelectedTab == InteractionType.PurchaseSub)
if (!value)
{
SubmarinePreview.Close();
switch (CampaignUI?.SelectedTab)
{
case InteractionType.PurchaseSub:
SubmarinePreview.Close();
break;
case InteractionType.MedicalClinic:
CampaignUI.MedicalClinic?.OnDeselected();
break;
}
}
showCampaignUI = value;
}
}
@@ -110,12 +119,7 @@ namespace Barotrauma
public static bool AllowedToManageWallets()
{
if (GameMain.Client == null) { return true; }
return
GameMain.Client.HasPermission(ClientPermissions.ManageMoney) ||
GameMain.Client.HasPermission(ClientPermissions.ManageCampaign) ||
GameMain.Client.IsServerOwner;
return AllowedToManageCampaign(ClientPermissions.ManageMoney);
}
public override void Draw(SpriteBatch spriteBatch)
@@ -247,11 +251,11 @@ namespace Barotrauma
GUI.ClearCursorWait();
StartRoundCancellationToken = new CancellationTokenSource();
startRoundCancellationToken = new CancellationTokenSource();
var loadTask = Task.Run(async () =>
{
await Task.Yield();
Rand.ThreadId = Thread.CurrentThread.ManagedThreadId;
Rand.ThreadId = Environment.CurrentManagedThreadId;
try
{
GameMain.GameSession.StartRound(newLevel, mirrorLevel: mirror, startOutpost: GetPredefinedStartOutpost());
@@ -261,7 +265,8 @@ namespace Barotrauma
roundSummaryScreen.LoadException = e;
}
Rand.ThreadId = 0;
}, StartRoundCancellationToken.Token);
startRoundCancellationToken = null;
}, startRoundCancellationToken.Token);
TaskPool.Add("AsyncCampaignStartRound", loadTask, (t) =>
{
overlayColor = Color.Transparent;
@@ -271,6 +276,21 @@ namespace Barotrauma
return loadTask;
}
public void CancelStartRound()
{
startRoundCancellationToken?.Cancel();
}
public void ThrowIfStartRoundCancellationRequested()
{
if (startRoundCancellationToken != null &&
startRoundCancellationToken.Token.IsCancellationRequested)
{
startRoundCancellationToken.Token.ThrowIfCancellationRequested();
startRoundCancellationToken = null;
}
}
protected SubmarineInfo GetPredefinedStartOutpost()
{
if (Map?.CurrentLocation?.Type?.GetForcedOutpostGenerationParams() is OutpostGenerationParams parameters && !parameters.OutpostFilePath.IsNullOrEmpty())
@@ -304,7 +324,7 @@ namespace Barotrauma
goto default;
default:
ShowCampaignUI = true;
CampaignUI.SelectTab(npc.CampaignInteractionType, storeIdentifier: npc.MerchantIdentifier);
CampaignUI.SelectTab(npc.CampaignInteractionType, npc);
CampaignUI.UpgradeStore?.RequestRefresh();
break;
}
@@ -962,25 +962,20 @@ namespace Barotrauma
foreach (NetWalletTransaction transaction in update.Transactions)
{
WalletInfo info = transaction.Info;
switch (transaction.CharacterID)
if (transaction.CharacterID.TryUnwrap(out var charID))
{
case Some<ushort> { Value: var charID }:
{
Character targetCharacter = Character.CharacterList?.FirstOrDefault(c => c.ID == charID);
if (targetCharacter is null) { break; }
Wallet wallet = targetCharacter.Wallet;
Character targetCharacter = Character.CharacterList?.FirstOrDefault(c => c.ID == charID);
if (targetCharacter is null) { break; }
Wallet wallet = targetCharacter.Wallet;
wallet.Balance = info.Balance;
wallet.RewardDistribution = info.RewardDistribution;
TryInvokeEvent(wallet, transaction.ChangedData, info);
break;
}
case None<ushort> _:
{
Bank.Balance = info.Balance;
TryInvokeEvent(Bank, transaction.ChangedData, info);
break;
}
wallet.Balance = info.Balance;
wallet.RewardDistribution = info.RewardDistribution;
TryInvokeEvent(wallet, transaction.ChangedData, info);
}
else
{
Bank.Balance = info.Balance;
TryInvokeEvent(Bank, transaction.ChangedData, info);
}
}
@@ -995,7 +990,7 @@ namespace Barotrauma
public override bool TryPurchase(Client client, int price)
{
if (!AllowedToManageCampaign(ClientPermissions.ManageCampaign))
if (!AllowedToManageCampaign(ClientPermissions.ManageMoney))
{
return PersonalWallet.TryDeduct(price);
}
@@ -421,6 +421,7 @@ namespace Barotrauma
TotalPassedLevels++;
break;
case TransitionType.ProgressToNextEmptyLocation:
Map.Visit(Map.CurrentLocation);
TotalPassedLevels++;
break;
case TransitionType.End:
@@ -437,9 +438,9 @@ namespace Barotrauma
if (transitionType != TransitionType.End)
{
var endTransition = new CameraTransition(Submarine.MainSub, GameMain.GameScreen.Cam, null,
transitionType == TransitionType.LeaveLocation ? Alignment.BottomCenter : Alignment.Center,
fadeOut: false,
panDuration: EndTransitionDuration);
transitionType == TransitionType.LeaveLocation ? Alignment.BottomCenter : Alignment.Center,
fadeOut: false,
panDuration: EndTransitionDuration);
Location portraitLocation = Map.SelectedLocation ?? Map.CurrentLocation;
overlaySprite = portraitLocation.Type.GetPortrait(portraitLocation.PortraitId);