Client LuaCsForBarotrauma
SinglePlayerCampaign.cs
2 using Microsoft.Xna.Framework;
3 using System;
4 using System.Collections.Generic;
5 using System.Linq;
6 using System.Xml.Linq;
7 
8 namespace Barotrauma
9 {
11  {
12  public const int MinimumInitialMoney = 0;
13 
14  public override bool Paused
15  {
16  get
17  {
18  return
19  ForceMapUI || CoroutineManager.IsCoroutineRunning("LevelTransition") ||
22  }
23  }
24 
25  public override void UpdateWhilePaused(float deltaTime)
26  {
27  if (CoroutineManager.IsCoroutineRunning("LevelTransition") || CoroutineManager.IsCoroutineRunning("SubmarineTransition") || gameOver) { return; }
28 
30  PlayerInput.KeyHit(Microsoft.Xna.Framework.Input.Keys.Escape))
31  {
32  ShowCampaignUI = false;
33  if (GUIMessageBox.VisibleBox?.UserData is RoundSummary roundSummary &&
34  roundSummary.ContinueButton != null &&
35  roundSummary.ContinueButton.Visible)
36  {
38  }
39  }
40 
41  SlideshowPlayer?.UpdateManually(deltaTime);
42 
43  CrewManager.ChatBox?.Update(deltaTime);
45  }
46 
47  private float endTimer;
48 
49  private bool savedOnStart;
50 
51  private bool gameOver;
52 
53  private Character lastControlledCharacter;
54 
55  private bool showCampaignResetText;
56 
57  public override bool PurchasedHullRepairs
58  {
59  get { return PurchasedHullRepairsInLatestSave; }
60  set
61  {
62  PurchasedHullRepairsInLatestSave = value;
63  }
64  }
65  public override bool PurchasedLostShuttles
66  {
67  get { return PurchasedLostShuttlesInLatestSave; }
68  set
69  {
71  }
72  }
73  public override bool PurchasedItemRepairs
74  {
75  get { return PurchasedItemRepairsInLatestSave; }
76  set
77  {
78  PurchasedItemRepairsInLatestSave = value;
79  }
80  }
81 
82  #region Constructors/initialization
83 
87  private SinglePlayerCampaign(string mapSeed, CampaignSettings settings) : base(GameModePreset.SinglePlayerCampaign, settings)
88  {
89  UpgradeManager = new UpgradeManager(this);
90  Settings = settings;
91  InitFactions();
92  map = new Map(this, mapSeed);
93  foreach (JobPrefab jobPrefab in JobPrefab.Prefabs)
94  {
95  for (int i = 0; i < jobPrefab.InitialCount; i++)
96  {
97  var variant = Rand.Range(0, jobPrefab.Variants);
98  CrewManager.AddCharacterInfo(new CharacterInfo(CharacterPrefab.HumanSpeciesName, jobOrJobPrefab: jobPrefab, variant: variant));
99  }
100  }
101  InitUI();
102  }
103 
107  private SinglePlayerCampaign(XElement element) : base(GameModePreset.SinglePlayerCampaign, CampaignSettings.Empty)
108  {
109  IsFirstRound = false;
110  foreach (var subElement in element.Elements())
111  {
112  switch (subElement.Name.ToString().ToLowerInvariant())
113  {
114  case "metadata":
115  CampaignMetadata.Load(subElement);
116  break;
117  }
118  }
119 
120  InitFactions();
121 
122  foreach (var subElement in element.Elements())
123  {
124  switch (subElement.Name.ToString().ToLowerInvariant())
125  {
126  case CampaignSettings.LowerCaseSaveElementName:
127  Settings = new CampaignSettings(subElement);
128  break;
129  case "crew":
130  GameMain.GameSession.CrewManager = new CrewManager(subElement, true);
131  ActiveOrdersElement = subElement.GetChildElement("activeorders");
132  break;
133  case "map":
134  map = Map.Load(this, subElement);
135  break;
136  case "cargo":
137  CargoManager.LoadPurchasedItems(subElement);
138  break;
139  case "pendingupgrades": //backwards compatibility
140  case "upgrademanager":
141  UpgradeManager = new UpgradeManager(this, subElement, isSingleplayer: true);
142  break;
143  case "pets":
144  petsElement = subElement;
145  break;
146  case Wallet.LowerCaseSaveElementName:
147  Bank = new Wallet(Option<Character>.None(), subElement);
148  break;
149  case "stats":
150  LoadStats(subElement);
151  break;
152  case "eventmanager":
153  GameMain.GameSession.EventManager.Load(subElement);
154  break;
155  }
156  }
157 
158  UpgradeManager ??= new UpgradeManager(this);
159 
160  InitUI();
161 
162  //backwards compatibility for saves made prior to the addition of personal wallets
163  int oldMoney = element.GetAttributeInt("money", 0);
164  if (oldMoney > 0)
165  {
166  Bank = new Wallet(Option<Character>.None())
167  {
168  Balance = oldMoney
169  };
170  }
171 
172  PurchasedLostShuttlesInLatestSave = element.GetAttributeBool("purchasedlostshuttles", false);
173  PurchasedHullRepairsInLatestSave = element.GetAttributeBool("purchasedhullrepairs", false);
174  PurchasedItemRepairsInLatestSave = element.GetAttributeBool("purchaseditemrepairs", false);
175  CheatsEnabled = element.GetAttributeBool("cheatsenabled", false);
176  if (CheatsEnabled)
177  {
178  DebugConsole.CheatsEnabled = true;
179  if (!AchievementManager.CheatsEnabled)
180  {
181  AchievementManager.CheatsEnabled = true;
182  new GUIMessageBox("Cheats enabled", "Cheat commands have been enabled on the campaign. You will not receive Steam Achievements until you restart the game.");
183  }
184  }
185 
186  if (map == null)
187  {
188  throw new System.Exception("Failed to load the campaign save file (saved with an older, incompatible version of Barotrauma).");
189  }
190 
191  savedOnStart = true;
192  }
193 
197  public static SinglePlayerCampaign StartNew(string mapSeed, CampaignSettings startingSettings) => new SinglePlayerCampaign(mapSeed, startingSettings);
198 
204  public static SinglePlayerCampaign Load(XElement element) => new SinglePlayerCampaign(element);
205 
206  private void InitUI()
207  {
209 
210  campaignUIContainer = new GUIFrame(new RectTransform(Vector2.One, GUI.Canvas, Anchor.Center), style: "InnerGlow", color: Color.Black);
212  {
213  StartRound = () => { TryEndRound(); }
214  };
215 
217  endRoundButton.OnClicked = (btn, userdata) =>
218  {
220  onConfirm: () => TryEndRound(),
221  onReturnToMapScreen: () => { ShowCampaignUI = true; CampaignUI.SelectTab(InteractionType.Map); });
222  return true;
223  };
224  }
225 
226  public override void HUDScaleChanged()
227  {
229  }
230 
231  #endregion
232 
233  public override void Start()
234  {
235  base.Start();
239 
240  if (!savedOnStart)
241  {
242  GUI.SetSavingIndicatorState(true);
243  SaveUtil.SaveGame(GameMain.GameSession.SavePath);
244  savedOnStart = true;
245  }
246 
247  CrewDead = false;
248  endTimer = 5.0f;
250  LoadPets();
252 
254 
255  GUI.DisableSavingIndicatorDelayed();
256  }
257 
258  protected override void LoadInitialLevel()
259  {
260  //no level loaded yet -> show a loading screen and load the current location (outpost)
264  }
265 
266  private IEnumerable<CoroutineStatus> DoLoadInitialLevel(LevelData level, bool mirror)
267  {
268  GameMain.GameSession.StartRound(level, mirrorLevel: mirror, startOutpost: GetPredefinedStartOutpost());
270 
271  CoroutineManager.StartCoroutine(DoInitialCameraTransition(), "SinglePlayerCampaign.DoInitialCameraTransition");
272 
273  yield return CoroutineStatus.Success;
274  }
275 
276  private IEnumerable<CoroutineStatus> DoInitialCameraTransition()
277  {
278  while (GameMain.Instance.LoadingScreenOpen)
279  {
280  yield return CoroutineStatus.Running;
281  }
282  Character prevControlled = Character.Controlled;
283  if (prevControlled?.AIController != null)
284  {
285  prevControlled.AIController.Enabled = false;
286  }
287  Character.Controlled = null;
288  prevControlled?.ClearInputs();
289 
290  GUI.DisableHUD = true;
291  while (GameMain.Instance.LoadingScreenOpen)
292  {
293  yield return CoroutineStatus.Running;
294  }
295 
296  if (IsFirstRound || showCampaignResetText)
297  {
298  if (SlideshowPrefab.Prefabs.TryGet("campaignstart".ToIdentifier(), out var slideshow))
299  {
300  SlideshowPlayer = new SlideshowPlayer(GUICanvas.Instance, slideshow);
301  }
302  var outpost = GameMain.GameSession.Level.StartOutpost;
303  var borders = outpost.GetDockedBorders();
304  borders.Location += outpost.WorldPosition.ToPoint();
305  GameMain.GameScreen.Cam.Position = new Vector2(borders.X + borders.Width / 2, borders.Y - borders.Height / 2);
306  float startZoom = 0.8f /
307  ((float)Math.Max(borders.Width, borders.Height) / (float)GameMain.GameScreen.Cam.Resolution.X);
308  GameMain.GameScreen.Cam.Zoom = GameMain.GameScreen.Cam.MinZoom = Math.Min(startZoom, GameMain.GameScreen.Cam.MinZoom);
309  while (SlideshowPlayer != null && !SlideshowPlayer.LastTextShown)
310  {
311  GUI.PreventPauseMenuToggle = true;
312  yield return CoroutineStatus.Running;
313  }
314  GUI.PreventPauseMenuToggle = false;
315  var transition = new CameraTransition(prevControlled, GameMain.GameScreen.Cam,
316  null, null,
317  fadeOut: false,
318  losFadeIn: true,
319  waitDuration: 1,
320  panDuration: 5,
321  startZoom: startZoom, endZoom: 1.0f)
322  {
323  AllowInterrupt = true,
324  RemoveControlFromCharacter = false
325  };
326  while (transition.Running)
327  {
328  yield return CoroutineStatus.Running;
329  }
330  showCampaignResetText = false;
331  }
332  else
333  {
334  ISpatialEntity transitionTarget;
335  transitionTarget = (ISpatialEntity)prevControlled ?? Submarine.MainSub;
336 
337  var transition = new CameraTransition(transitionTarget, GameMain.GameScreen.Cam,
338  null, null,
339  fadeOut: false,
340  losFadeIn: prevControlled != null,
341  panDuration: 5,
342  startZoom: 0.5f, endZoom: 1.0f)
343  {
344  AllowInterrupt = true,
345  RemoveControlFromCharacter = false
346  };
347  while (transition.Running)
348  {
349  yield return CoroutineStatus.Running;
350  }
351  }
352 
353  if (prevControlled != null)
354  {
355  prevControlled.SelectedItem = prevControlled.SelectedSecondaryItem = null;
356  if (prevControlled.AIController != null)
357  {
358  prevControlled.AIController.Enabled = true;
359  }
360  }
361 
362  if (prevControlled != null)
363  {
364  Character.Controlled = prevControlled;
365  }
366  GUI.DisableHUD = false;
367  yield return CoroutineStatus.Success;
368  }
369 
370  protected override IEnumerable<CoroutineStatus> DoLevelTransition(TransitionType transitionType, LevelData newLevel, Submarine leavingSub, bool mirror)
371  {
372  NextLevel = newLevel;
373  bool success = CrewManager.GetCharacters().Any(c => !c.IsDead);
374  SoundPlayer.OverrideMusicType = (success ? "endround" : "crewdead").ToIdentifier();
375  SoundPlayer.OverrideMusicDuration = 18.0f;
376  GUI.SetSavingIndicatorState(success);
377  CrewDead = false;
378 
379  if (success)
380  {
381  // Event history must be registered before ending the round or it will be cleared
383  }
384  GameMain.GameSession.EndRound("", transitionType);
385  var continueButton = GameMain.GameSession.RoundSummary?.ContinueButton;
386  RoundSummary roundSummary = null;
388  {
389  roundSummary = GUIMessageBox.VisibleBox?.UserData as RoundSummary;
390  }
391  if (continueButton != null)
392  {
393  continueButton.Visible = false;
394  }
395 
396  lastControlledCharacter = Character.Controlled;
397  Character.Controlled = null;
398 
399  switch (transitionType)
400  {
401  case TransitionType.None:
402  throw new InvalidOperationException("Level transition failed (no transitions available).");
403  case TransitionType.ReturnToPreviousLocation:
404  //deselect destination on map
405  map.SelectLocation(-1);
406  break;
407  case TransitionType.ProgressToNextLocation:
410  break;
411  case TransitionType.ProgressToNextEmptyLocation:
414  break;
415  case TransitionType.End:
416  EndCampaign();
417  IsFirstRound = true;
418  break;
419  }
420 
421  Map.ProgressWorld(this, transitionType, GameMain.GameSession.RoundDuration);
422 
423  GUI.ClearMessages();
424 
425  //--------------------------------------
426  if (transitionType != TransitionType.End)
427  {
428  var endTransition = new CameraTransition(Submarine.MainSub, GameMain.GameScreen.Cam, null,
429  transitionType == TransitionType.LeaveLocation ? Alignment.BottomCenter : Alignment.Center,
430  fadeOut: false,
431  panDuration: EndTransitionDuration);
432 
433  Location portraitLocation = Map.SelectedLocation ?? Map.CurrentLocation;
434  overlaySprite = portraitLocation.Type.GetPortrait(portraitLocation.PortraitId);
435  float fadeOutDuration = endTransition.PanDuration;
436  float t = 0.0f;
437  while (t < fadeOutDuration || endTransition.Running)
438  {
439  t += CoroutineManager.DeltaTime;
440  overlayColor = Color.Lerp(Color.Transparent, Color.White, t / fadeOutDuration);
441  yield return CoroutineStatus.Running;
442  }
443  overlayColor = Color.White;
444  yield return CoroutineStatus.Running;
445 
446  //--------------------------------------
447 
448  if (success)
449  {
451  SaveUtil.SaveGame(GameMain.GameSession.SavePath);
452  }
453  else
454  {
455  PendingSubmarineSwitch = null;
456  EnableRoundSummaryGameOverState();
457  }
458 
460 
461  SelectSummaryScreen(roundSummary, newLevel, mirror, () =>
462  {
464  if (continueButton != null)
465  {
466  continueButton.Visible = true;
467  }
468 
469  GUI.DisableHUD = false;
470  GUI.ClearCursorWait();
471  overlayColor = Color.Transparent;
472  });
473  }
474 
475  GUI.SetSavingIndicatorState(false);
476  yield return CoroutineStatus.Success;
477  }
478 
479  protected override void EndCampaignProjSpecific()
480  {
482  SaveUtil.SaveGame(GameMain.GameSession.SavePath);
484  GUI.DisableHUD = false;
486  {
487  showCampaignResetText = true;
489  IsFirstRound = true;
490  };
491  }
492 
493  public override void Update(float deltaTime)
494  {
495  if (CoroutineManager.IsCoroutineRunning("LevelTransition") || CoroutineManager.IsCoroutineRunning("SubmarineTransition") || gameOver) { return; }
496 
497  base.Update(deltaTime);
498 
499  SlideshowPlayer?.UpdateManually(deltaTime);
500 
501  Map?.Radiation?.UpdateRadiation(deltaTime);
502 
504  PlayerInput.KeyHit(Microsoft.Xna.Framework.Input.Keys.Escape))
505  {
506  ShowCampaignUI = false;
507  if (GUIMessageBox.VisibleBox?.UserData is RoundSummary roundSummary &&
508  roundSummary.ContinueButton != null &&
509  roundSummary.ContinueButton.Visible)
510  {
512  }
513  }
514 
515  if (ShowCampaignUI || ForceMapUI)
516  {
517  Character.DisableControls = true;
518  }
519 
520  if (!GUI.DisableHUD && !GUI.DisableUpperHUD)
521  {
522  endRoundButton.UpdateManually(deltaTime);
523  if (CoroutineManager.IsCoroutineRunning("LevelTransition") || ForceMapUI) { return; }
524  }
525 
526  if (Level.Loaded.Type == LevelData.LevelType.Outpost)
527  {
528  KeepCharactersCloseToOutpost(deltaTime);
529  if (wasDocked)
530  {
531  var connectedSubs = Submarine.MainSub.GetConnectedSubs();
532  bool isDocked = Level.Loaded.StartOutpost != null && connectedSubs.Contains(Level.Loaded.StartOutpost);
533  if (!isDocked)
534  {
535  //undocked from outpost, need to choose a destination
536  ForceMapUI = true;
538  }
539  }
540  else if (Level.Loaded.IsEndBiome)
541  {
542  var transitionType = GetAvailableTransition(out _, out Submarine leavingSub);
543  if (transitionType == TransitionType.ProgressToNextLocation)
544  {
545  LoadNewLevel();
546  }
547  }
548  else
549  {
550  //force the map to open if the sub is somehow not at the start of the outpost level
551  //UNLESS the level has specific exit points, in that case the sub needs to get to those
553  /*there should normally always be a start outpost in outpost levels,
554  * but that might not always be the case e.g. mods or outdated saves (see #13042)*/
555  Level.Loaded.StartOutpost is not { ExitPoints.Count: > 0 })
556  {
557  ForceMapUI = true;
559  }
560  }
561  }
562  else
563  {
564  var transitionType = GetAvailableTransition(out _, out Submarine leavingSub);
565  if (Level.Loaded.IsEndBiome && transitionType == TransitionType.ProgressToNextLocation)
566  {
567  LoadNewLevel();
568  }
569  else if (transitionType == TransitionType.ProgressToNextLocation &&
570  Level.Loaded.EndOutpost != null && Level.Loaded.EndOutpost.DockedTo.Contains(leavingSub))
571  {
572  LoadNewLevel();
573  }
574  else if (transitionType == TransitionType.ReturnToPreviousLocation &&
575  Level.Loaded.StartOutpost != null && Level.Loaded.StartOutpost.DockedTo.Contains(leavingSub))
576  {
577  LoadNewLevel();
578  }
579  else if (transitionType == TransitionType.None && CampaignUI.SelectedTab == InteractionType.Map)
580  {
581  ShowCampaignUI = false;
582  }
583  HintManager.OnAvailableTransition(transitionType);
584  }
585 
586  if (!CrewDead)
587  {
588  if (CrewManager.GetCharacters().None(c => !c.IsDead && !CrewManager.IsFired(c)))
589  {
590  CrewDead = true;
591  }
592  }
593  else
594  {
595  endTimer -= deltaTime;
596  if (endTimer <= 0.0f) { GameOver(); }
597  }
598  }
599 
600  private bool TryEndRound()
601  {
602  var transitionType = GetAvailableTransition(out LevelData nextLevel, out Submarine leavingSub);
603  if (leavingSub == null || transitionType == TransitionType.None) { return false; }
604 
605  if (nextLevel == null)
606  {
607  //no level selected -> force the player to select one
608  ForceMapUI = true;
610  map.SelectLocation(-1);
611  return false;
612  }
613  else if (transitionType == TransitionType.ProgressToNextEmptyLocation)
614  {
615  Map.SetLocation(Map.Locations.IndexOf(Level.Loaded.EndLocation ?? Map.CurrentLocation));
616  }
617 
618  var subsToLeaveBehind = GetSubsToLeaveBehind(leavingSub);
619  if (subsToLeaveBehind.Any())
620  {
621  LocalizedString msg = TextManager.Get(subsToLeaveBehind.Count == 1 ? "LeaveSubBehind" : "LeaveSubsBehind");
622 
623  var msgBox = new GUIMessageBox(TextManager.Get("Warning"), msg, new LocalizedString[] { TextManager.Get("Yes"), TextManager.Get("No") });
624  msgBox.Buttons[0].OnClicked += (btn, userdata) => { LoadNewLevel(); return true; } ;
625  msgBox.Buttons[0].OnClicked += msgBox.Close;
626  msgBox.Buttons[0].UserData = Submarine.Loaded.FindAll(s => !subsToLeaveBehind.Contains(s));
627  msgBox.Buttons[1].OnClicked += msgBox.Close;
628  }
629  else
630  {
631  LoadNewLevel();
632  }
633 
634  return true;
635  }
636 
637  private void GameOver()
638  {
639  gameOver = true;
640  GameMain.GameSession.EndRound("", transitionType: TransitionType.None);
641  EnableRoundSummaryGameOverState();
642  }
643 
644  private void EnableRoundSummaryGameOverState()
645  {
646  var roundSummary = GameMain.GameSession.RoundSummary;
647  if (roundSummary != null)
648  {
649  roundSummary.ContinueButton.Visible = false;
650  roundSummary.ContinueButton.IgnoreLayoutGroups = true;
651 
652  new GUIButton(new RectTransform(new Vector2(0.25f, 1.0f), roundSummary.ButtonArea.RectTransform),
653  TextManager.Get("QuitButton"))
654  {
655  OnClicked = (GUIButton button, object obj) =>
656  {
657  GameMain.MainMenuScreen.Select();
658  GUIMessageBox.MessageBoxes.Remove(roundSummary.Frame);
659  return true;
660  }
661  };
662  new GUIButton(new RectTransform(new Vector2(0.25f, 1.0f), roundSummary.ButtonArea.RectTransform),
663  TextManager.Get("LoadGameButton"))
664  {
665  OnClicked = (GUIButton button, object obj) =>
666  {
667  GameMain.GameSession.LoadPreviousSave();
668  GUIMessageBox.MessageBoxes.Remove(roundSummary.Frame);
669  return true;
670  }
671  };
672  }
673  }
674 
675  public override void Save(XElement element)
676  {
677  XElement modeElement = new XElement("SinglePlayerCampaign",
678  new XAttribute("purchasedlostshuttles", PurchasedLostShuttles),
679  new XAttribute("purchasedhullrepairs", PurchasedHullRepairs),
680  new XAttribute("purchaseditemrepairs", PurchasedItemRepairs),
681  new XAttribute("cheatsenabled", CheatsEnabled));
682  modeElement.Add(Settings.Save());
683  modeElement.Add(SaveStats());
684 
685  if (GameMain.GameSession?.EventManager != null)
686  {
687  modeElement.Add(GameMain.GameSession?.EventManager.Save());
688  }
689 
690  //save and remove all items that are in someone's inventory so they don't get included in the sub file as well
691  foreach (Character c in Character.CharacterList)
692  {
693  if (c.Info == null) { continue; }
695  c.Info.LastControlled = c == lastControlledCharacter;
696  c.Info.HealthData = new XElement("health");
698  if (c.Inventory != null)
699  {
700  c.Info.InventoryData = new XElement("inventory");
701  c.SaveInventory();
703  }
704  c.Info.SaveOrderData();
705  }
706 
707  SavePets(modeElement);
708  var crewManagerElement = CrewManager.Save(modeElement);
709  SaveActiveOrders(crewManagerElement);
710 
711  CampaignMetadata.Save(modeElement);
712  Map.Save(modeElement);
713  CargoManager?.SavePurchasedItems(modeElement);
714  UpgradeManager?.Save(modeElement);
715  modeElement.Add(Bank.Save());
716  element.Add(modeElement);
717  }
718  }
719 }
Task SelectSummaryScreen(RoundSummary roundSummary, LevelData newLevel, bool mirror, Action action)
TransitionType GetAvailableTransition()
virtual Wallet Wallet
Gets the current personal wallet In singleplayer this is the campaign bank and in multiplayer this is...
static List< Submarine > GetSubsToLeaveBehind(Submarine leavingSub)
void TryEndRoundWithFuelCheck(Action onConfirm, Action onReturnToMapScreen)
CampaignMode.InteractionType SelectedTab
Definition: CampaignUI.cs:18
void SelectTab(CampaignMode.InteractionType tab, Character npc=null)
Definition: CampaignUI.cs:577
static void SaveInventory(Inventory inventory, XElement parentElement)
Stores information about the Character that is needed between rounds in the menu etc....
static void SaveOrderData(CharacterInfo characterInfo, XElement parentElement)
Save current orders to the parameter element
static readonly Identifier HumanSpeciesName
void Update(float deltaTime)
Definition: ChatBox.cs:614
static CoroutineStatus Running
static CoroutineStatus Success
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 RemoveCharacterInfo(CharacterInfo characterInfo)
Remove info of a selected character. The character will not be visible in any menus or the round summ...
XElement Save(XElement parentElement)
Saves the current crew. Note that this is client-only code (only used in the single player campaign) ...
void UpdateReports()
Enables/disables report buttons when needed
void RegisterEventHistory(bool registerFinishedOnly=false)
Registers the exhaustible events in the level as exhausted, and adds the current events to the event ...
OnClickedHandler OnClicked
Definition: GUIButton.cs:16
void UpdateManually(float deltaTime, bool alsoChildren=false, bool recursive=true)
By default, all the gui elements are updated automatically in the same order they appear on the updat...
static readonly List< GUIComponent > MessageBoxes
static GUIComponent VisibleBox
static GameSession?? GameSession
Definition: GameMain.cs:88
CoroutineHandle ShowLoading(IEnumerable< CoroutineStatus > loader, bool waitKeyHit=true)
Definition: GameMain.cs:1241
static GameScreen GameScreen
Definition: GameMain.cs:52
static CampaignEndScreen CampaignEndScreen
Definition: GameMain.cs:76
static GameMain Instance
Definition: GameMain.cs:144
void StartRound(string levelSeed, float? difficulty=null, LevelGenerationParams? levelGenerationParams=null)
void EndRound(string endMessage, CampaignMode.TransitionType transitionType=CampaignMode.TransitionType.None, TraitorManager.TraitorResults? traitorResults=null)
void DeleteAllItems()
Deletes all items inside the inventory (and also recursively all items inside the items)
static readonly PrefabCollection< JobPrefab > Prefabs
LocationType Type
Definition: Location.cs:91
LevelData LevelData
Definition: Location.cs:95
Sprite GetPortrait(int randomSeed)
void ProgressWorld(CampaignMode campaign, CampaignMode.TransitionType transitionType, float roundDuration)
static Map Load(CampaignMode campaign, XElement element)
Load a previously saved map from an xml element
override void Save(XElement element)
static SinglePlayerCampaign StartNew(string mapSeed, CampaignSettings startingSettings)
Start a completely new single player campaign
override IEnumerable< CoroutineStatus > DoLevelTransition(TransitionType transitionType, LevelData newLevel, Submarine leavingSub, bool mirror)
override void UpdateWhilePaused(float deltaTime)
static SinglePlayerCampaign Load(XElement element)
Load a previously saved single player campaign from xml
override void Update(float deltaTime)
override void LoadInitialLevel()
Load the first level and start the round after loading a save file
IEnumerable< Submarine > GetConnectedSubs()
Returns a list of all submarines that are connected to this one via docking ports,...
This class handles all upgrade logic. Storing, applying, checking and validation of upgrades.
void SanityCheckUpgrades()
Validates that upgrade values stored in CampaignMetadata matches the values on the submarine and fixe...
void ApplyUpgrades()
Applies all our pending upgrades to the submarine.