3 using Microsoft.Xna.Framework;
4 using Microsoft.Xna.Framework.Graphics;
7 using System.Threading;
8 using System.Threading.Tasks;
12 internal abstract partial class CampaignMode : GameMode
39 private CancellationTokenSource startRoundCancellationToken;
47 private bool showCampaignUI;
48 private bool wasChatBoxOpen;
51 get {
return showCampaignUI; }
54 if (value == showCampaignUI) {
return; }
61 chatBox.ToggleOpen =
false;
64 else if (chatBox !=
null)
66 chatBox.ToggleOpen = wasChatBoxOpen;
84 showCampaignUI = value;
98 if (!mission.
Prefab.ShowStartMessage) {
continue; }
104 UserData =
"missionstartmessage"
109 private static bool IsOwner(
Client client) => client !=
null && client.IsOwner;
123 AnyOneAllowedToManageCampaign(permissions);
142 int buttonWidth = (int)(450 * GUI.xScale * (GUI.IsUltrawide ? 3.0f : 1.0f));
143 int buttonHeight = (int)(40 * GUI.yScale);
144 var rectT = HUDLayoutSettings.ToRectTransform(
new Rectangle((
GameMain.
GraphicsWidth / 2), HUDLayoutSettings.ButtonAreaTop.Center.Y, buttonWidth, buttonHeight), GUI.Canvas);
146 return new GUIButton(rectT, TextManager.Get(
"EndRound"), textAlignment: Alignment.Center, style:
"EndRoundButton")
152 AutoScaleHorizontal =
true
158 public override void Draw(SpriteBatch spriteBatch)
176 if (GUI.DisableHUD || GUI.DisableUpperHUD ||
ForceMapUI ||
177 CoroutineManager.IsCoroutineRunning(
"LevelTransition"))
188 bool allowEndingRound =
false;
191 RichString overrideEndRoundButtonToolTip =
string.Empty;
194 switch (availableTransition)
200 string textTag = availableTransition ==
TransitionType.ProgressToNextLocation ?
"EnterLocation" :
"EnterEmptyLocation";
213 string textTag = availableTransition ==
TransitionType.ReturnToPreviousLocation ?
"EnterLocation" :
"EnterEmptyLocation";
226 overrideEndRoundButtonToolTip = TextManager.Get(
"SalvageTargetNotInSub");
235 allowEndingRound =
false;
242 allowEndingRound =
false;
254 buttonText = TextManager.Get(
"map");
256 else if (prevCampaignUIAutoOpenType != availableTransition &&
257 availableTransition ==
TransitionType.ProgressToNextEmptyLocation)
259 HintManager.OnAvailableTransition(availableTransition);
261 HintManager.Update();
264 prevCampaignUIAutoOpenType = availableTransition;
267 if (overrideEndRoundButtonToolTip !=
string.Empty)
293 if (ReadyCheck.ReadyCheckCooldown > DateTime.Now)
295 float progress = (ReadyCheck.ReadyCheckCooldown - DateTime.Now).Seconds / 60.0f;
305 GUI.ClearCursorWait();
307 startRoundCancellationToken =
new CancellationTokenSource();
308 var loadTask = Task.Run(async () =>
311 Rand.ThreadId = Environment.CurrentManagedThreadId;
318 roundSummaryScreen.LoadException = e;
321 startRoundCancellationToken =
null;
322 }, startRoundCancellationToken.Token);
323 TaskPool.Add(
"AsyncCampaignStartRound", loadTask, (t) =>
334 startRoundCancellationToken?.Cancel();
339 if (startRoundCancellationToken !=
null &&
340 startRoundCancellationToken.Token.IsCancellationRequested)
342 startRoundCancellationToken.Token.ThrowIfCancellationRequested();
343 startRoundCancellationToken =
null;
349 if (npc ==
null || interactor ==
null) {
return; }
373 if (npc.
AIController is HumanAIController humanAi && humanAi.IsInHostileFaction())
375 npc.
Speak(TextManager.Get(
"dialoglowrepcampaigninteraction").Value, identifier:
"dialoglowrepcampaigninteraction".ToIdentifier(), minDurationBetweenSimilar: 60.0f);
384 if (
CampaignUI?.UpgradeStore?.HoveredEntity !=
null)
390 base.AddToGUIUpdateList();
406 var extraConfirmationBox =
408 TextManager.Get(
"lowfuelwarning"),
409 new LocalizedString[2] { TextManager.Get(
"ok"), TextManager.Get(
"cancel") });
410 extraConfirmationBox.Buttons[0].OnClicked = (b, o) => { Confirm();
return true; };
411 extraConfirmationBox.Buttons[0].OnClicked += extraConfirmationBox.Close;
412 extraConfirmationBox.Buttons[1].OnClicked = extraConfirmationBox.Close;
436 onReturnToMapScreen();
441 public override void Update(
float deltaTime)
443 base.Update(deltaTime);
452 if (GUI.KeyboardDispatcher.Subscriber ==
null &&
PlayerInput.
KeyHit(Microsoft.Xna.Framework.Input.Keys.M))
UpgradeManager UpgradeManager
override void ShowStartMessage()
static bool AllowedToManageWallets()
Task SelectSummaryScreen(RoundSummary roundSummary, LevelData newLevel, bool mirror, Action action)
TransitionType GetAvailableTransition()
static bool AllowImmediateItemDelivery()
MedicalClinic MedicalClinic
GUIFrame campaignUIContainer
bool??????? ShowCampaignUI
virtual Wallet GetWallet(Client client=null)
virtual Wallet Wallet
Gets the current personal wallet In singleplayer this is the campaign bank and in multiplayer this is...
SubmarineInfo PendingSubmarineSwitch
static bool AllowedToManageCampaign(ClientPermissions permissions)
There is a server-side implementation of the method in MultiPlayerCampaign
override void Update(float deltaTime)
override void AddToGUIUpdateList()
override IEnumerable< Mission > Missions
override void Draw(SpriteBatch spriteBatch)
GUIButton ReadyCheckButton
GUIButton CreateEndRoundButton()
void ThrowIfStartRoundCancellationRequested()
SubmarineInfo GetPredefinedStartOutpost()
bool TransferItemsOnSubSwitch
void TryEndRoundWithFuelCheck(Action onConfirm, Action onReturnToMapScreen)
UpgradeStore UpgradeStore
CampaignMode.InteractionType SelectedTab
void SelectTab(CampaignMode.InteractionType tab, Character npc=null)
void Update(float deltaTime)
MedicalClinicUI MedicalClinic
Dictionary< Identifier, List< PurchasedItem > > PurchasedItems
void Speak(string message, ChatMessageType? messageType=null, float delay=0.0f, Identifier identifier=default, float minDurationBetweenSimilar=0.0f)
CharacterHealth CharacterHealth
virtual AIController AIController
CampaignMode.InteractionType CampaignInteractionType
static Character? Controlled
Responsible for keeping track of the characters in the player crew, saving and loading their orders,...
ChatBox ChatBox
Present only in single player games. In multiplayer. The chatbox is found from GameSession....
void AddToGUIUpdateList()
virtual void AddToGUIUpdateList(bool ignoreChildren=false, int order=0)
virtual void DrawManually(SpriteBatch spriteBatch, bool alsoChildren=false, bool recursive=true)
By default, all the gui elements are drawn automatically in the same order they appear on the update ...
RectTransform RectTransform
readonly Color HoverColor
static readonly List< GUIComponent > MessageBoxes
static GameSession?? GameSession
static int GraphicsHeight
void StartRound(string levelSeed, float? difficulty=null, LevelGenerationParams? levelGenerationParams=null)
RoundSummary RoundSummary
void SendCrewState(bool updatePending,(CharacterInfo info, string newName) renameCharacter=default, CharacterInfo firedCharacter=null, bool validateHires=false)
Notify the server of crew changes
IEnumerable< Identifier > OutpostModuleTags
Inherited flags from outpost generation.
static bool IsLoadedFriendlyOutpost
Is there a loaded level set, and is it a friendly outpost (FriendlyNPC or Team1). Does not take reput...
static bool IsLoadedOutpost
Is there a loaded level set and is it an outpost?
LocalizedString DisplayName
void SelectLocation(int index)
readonly MissionPrefab Prefab
virtual LocalizedString Name
virtual LocalizedString Description
readonly bool IsSideObjective
GUITickBox FollowSubTickBox
bool HasPermission(ClientPermissions permission)
bool IsFollowSubTickBoxVisible
static RichString Rich(LocalizedString str, Func< string, string >? postProcess=null)
GUIFrame CreateSummaryFrame(GameSession gameSession, string endMessage, CampaignMode.TransitionType transitionType=CampaignMode.TransitionType.None, TraitorManager.TraitorResults? traitorResults=null)
static RoundSummaryScreen Select(Sprite backgroundSprite, RoundSummary roundSummary)
bool AnyTargetNeedsToBeRetrievedToSub
void Draw(ISpriteBatch spriteBatch, Vector2 pos, float rotate=0.0f, float scale=1.0f, SpriteEffects spriteEffect=SpriteEffects.None)
IEnumerable< Submarine > DockedTo
bool LowFuel
Note: Refreshed for loaded submarines when they are saved, when they are loaded, and on round end....
void CreateUpgradeErrorMessage(string text, bool isSinglePlayer, Character character)