Barotrauma Client Doc
Barotrauma.CampaignMode Class Referenceabstract
Inheritance diagram for Barotrauma.CampaignMode:
Barotrauma.GameMode Barotrauma.GameMode Barotrauma.MultiPlayerCampaign Barotrauma.MultiPlayerCampaign Barotrauma.SinglePlayerCampaign

Public Types

enum class  InteractionType {
  None , Talk , Examine , Map ,
  Crew , Store , Upgrade , PurchaseSub ,
  MedicalClinic , Cargo
}
 
enum class  TransitionType {
  None , LeaveLocation , ProgressToNextLocation , ReturnToPreviousLocation ,
  ReturnToPreviousEmptyLocation , ProgressToNextEmptyLocation , End
}
 

Public Member Functions

virtual Wallet GetWallet (Client client=null)
 
virtual bool TryPurchase (Client client, int price)
 
virtual int GetBalance (Client client=null)
 
bool CanAfford (int cost, Client client=null)
 
Location GetCurrentDisplayLocation ()
 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 More...
 
override void Start ()
 
void InitFactions ()
 
override void AddExtraMissions (LevelData levelData)
 
void LoadNewLevel ()
 
TransitionType GetAvailableTransition (out LevelData nextLevel, out Submarine leavingSub)
 Which type of transition between levels is currently possible (if any) More...
 
TransitionType GetAvailableTransition ()
 
override void End (CampaignMode.TransitionType transitionType=CampaignMode.TransitionType.None)
 
void UpdateStoreStock ()
 Updates store stock before saving the game More...
 
void EndCampaign ()
 
Faction GetRandomFaction (Rand.RandSync randSync, bool allowEmpty=true)
 Returns a random faction based on their ControlledOutpostPercentage More...
 
Faction GetRandomSecondaryFaction (Rand.RandSync randSync, bool allowEmpty=true)
 Returns a random faction based on their SecondaryControlledOutpostPercentage More...
 
bool TryHireCharacter (Location location, CharacterInfo characterInfo, Character hirer, Client client=null)
 
void AssignNPCMenuInteraction (Character character, InteractionType interactionType)
 
void OutpostNPCAttacked (Character npc, Character attacker, AttackResult attackResult)
 
Faction GetFaction (Identifier identifier)
 
float GetReputation (Identifier factionIdentifier)
 
FactionAffiliation GetFactionAffiliation (Identifier factionIdentifier)
 
abstract void Save (XElement element)
 
void LogState ()
 
override void Remove ()
 
int NumberOfMissionsAtLocation (Location location)
 
void CheckTooManyMissions (Location currentLocation, Client sender)
 
void SwitchSubs ()
 
void SavePets (XElement parentElement=null)
 
void LoadPets ()
 
void SaveActiveOrders (XElement parentElement=null)
 
void LoadActiveOrders ()
 
override void ShowStartMessage ()
 
override void Draw (SpriteBatch spriteBatch)
 
Task SelectSummaryScreen (RoundSummary roundSummary, LevelData newLevel, bool mirror, Action action)
 
void CancelStartRound ()
 
void ThrowIfStartRoundCancellationRequested ()
 
override void AddToGUIUpdateList ()
 
override void Update (float deltaTime)
 
- Public Member Functions inherited from Barotrauma.GameMode
virtual void UpdateWhilePaused (float deltaTime)
 
 GameMode (GameModePreset preset)
 
virtual void End (CampaignMode.TransitionType transitionType=CampaignMode.TransitionType.None)
 
virtual void HUDScaleChanged ()
 

Static Public Member Functions

static bool BlocksInteraction (InteractionType interactionType)
 
static List< SubmarineGetSubsToLeaveBehind (Submarine leavingSub)
 
static int GetHullRepairCost ()
 
static int GetItemRepairCost ()
 
static Faction GetRandomFaction (IEnumerable< Faction > factions, Rand.RandSync randSync, bool secondary=false, bool allowEmpty=true)
 
static Faction GetRandomFaction (IEnumerable< Faction > factions, Random random, bool secondary=false, bool allowEmpty=true)
 
static bool AllowedToManageCampaign (ClientPermissions permissions)
 There is a server-side implementation of the method in MultiPlayerCampaign More...
 
static bool AllowedToManageWallets ()
 
static bool AllowImmediateItemDelivery ()
 

Public Attributes

double TotalPlayTime
 
int TotalPassedLevels
 
readonly CargoManager CargoManager
 
UpgradeManager UpgradeManager
 
MedicalClinic MedicalClinic
 
readonly CampaignMetadata CampaignMetadata
 
CampaignSettings Settings
 
readonly NamedEvent< WalletChangedEvent > OnMoneyChanged = new NamedEvent<WalletChangedEvent>()
 
bool CheatsEnabled
 
SubmarineInfo PendingSubmarineSwitch
 
Wallet Bank
 
bool PurchasedLostShuttlesInLatestSave
 
bool DivingSuitWarningShown
 
GUIButton ReadyCheckButton
 
CampaignUI CampaignUI
 

Static Public Attributes

readonly record struct SaveInfo(string FilePath, Option< SerializableDateTime > SaveTime, string SubmarineName, ImmutableArray< string > EnabledContentPackageNames) const int MaxMoney = int.MaxValue / 2
 
const int InitialMoney = 8500
 
const float HullRepairCostPerDamage = 0.1f
 
const int ShuttleReplaceCost = 1000
 
const int MaxHullRepairCost = 600
 
- Static Public Attributes inherited from Barotrauma.GameMode
static List< GameModePresetPresetList = new List<GameModePreset>()
 

Protected Member Functions

 CampaignMode (GameModePreset preset, CampaignSettings settings)
 
abstract void LoadInitialLevel ()
 Load the first level and start the round after loading a save file More...
 
abstract IEnumerable< CoroutineStatusDoLevelTransition (TransitionType transitionType, LevelData newLevel, Submarine leavingSub, bool mirror)
 
virtual void EndCampaignProjSpecific ()
 
void KeepCharactersCloseToOutpost (float deltaTime)
 
void LoadStats (XElement element)
 
XElement SaveStats ()
 
void TransferItemsBetweenSubs ()
 Also serializes the current sub. More...
 
void RefreshOwnedSubmarines ()
 
GUIButton CreateEndRoundButton ()
 
SubmarineInfo GetPredefinedStartOutpost ()
 
void TryEndRoundWithFuelCheck (Action onConfirm, Action onReturnToMapScreen)
 

Static Protected Member Functions

static void LeaveUnconnectedSubs (Submarine leavingSub)
 

Protected Attributes

XElement petsElement
 
bool wasDocked
 
Map map
 
bool crewDead
 
Color overlayColor
 
Sprite overlaySprite
 
GUIButton endRoundButton
 
GUIFrame campaignUIContainer
 
- Protected Attributes inherited from Barotrauma.GameMode
DateTime startTime
 
GameModePreset preset
 

Static Protected Attributes

const float EndTransitionDuration = 5.0f
 

Properties

IReadOnlyList< FactionFactions [get]
 
XElement ActiveOrdersElement [get, set]
 
bool IsFirstRound = true [get, protected set]
 
bool DisableEvents [get]
 
bool TransferItemsOnSubSwitch [get, set]
 
bool SwitchedSubsThisRound [get]
 
Map Map [get]
 
override IEnumerable< MissionMissions [get]
 
Location CurrentLocation [get]
 
LevelData NextLevel [get, protected set]
 
virtual bool PurchasedHullRepairs [get, set]
 
virtual bool PurchasedLostShuttles [get, set]
 
virtual bool PurchasedItemRepairs [get, set]
 
GUIButton EndRoundButton [get]
 
SlideshowPlayer SlideshowPlayer [get, protected set]
 
bool ForceMapUI [get, protected set]
 
bool??????? ShowCampaignUI [get, set]
 
virtual Wallet Wallet [get]
 Gets the current personal wallet In singleplayer this is the campaign bank and in multiplayer this is the personal wallet More...
 
- Properties inherited from Barotrauma.GameMode
CrewManagerCrewManager [get]
 
virtual IEnumerable< MissionMissions [get]
 
bool IsSinglePlayer [get]
 
LocalizedString Name [get]
 
virtual bool Paused [get]
 
GameModePreset Preset [get]
 

Events

Action BeforeLevelLoading
 Automatically cleared after triggering -> no need to unregister More...
 

Detailed Description

Member Enumeration Documentation

◆ InteractionType

Enumerator
None 
Talk 
Examine 
Map 
Crew 
Store 
Upgrade 
PurchaseSub 
MedicalClinic 
Cargo 

Definition at line 34 of file BarotraumaShared/SharedSource/GameSession/GameModes/CampaignMode.cs.

◆ TransitionType

Enumerator
None 
LeaveLocation 
ProgressToNextLocation 
ReturnToPreviousLocation 
ReturnToPreviousEmptyLocation 
ProgressToNextEmptyLocation 
End 

Definition at line 60 of file BarotraumaShared/SharedSource/GameSession/GameModes/CampaignMode.cs.

Constructor & Destructor Documentation

◆ CampaignMode()

Barotrauma.CampaignMode.CampaignMode ( GameModePreset  preset,
CampaignSettings  settings 
)
protected

Member Function Documentation

◆ AddExtraMissions()

override void Barotrauma.CampaignMode.AddExtraMissions ( LevelData  levelData)
virtual

◆ AddToGUIUpdateList()

override void Barotrauma.CampaignMode.AddToGUIUpdateList ( )
virtual

◆ AllowedToManageCampaign()

static bool Barotrauma.CampaignMode.AllowedToManageCampaign ( ClientPermissions  permissions)
static

There is a server-side implementation of the method in MultiPlayerCampaign

Definition at line 111 of file BarotraumaClient/ClientSource/GameSession/GameModes/CampaignMode.cs.

◆ AllowedToManageWallets()

static bool Barotrauma.CampaignMode.AllowedToManageWallets ( )
static

◆ AllowImmediateItemDelivery()

static bool Barotrauma.CampaignMode.AllowImmediateItemDelivery ( )
static

◆ AssignNPCMenuInteraction()

void Barotrauma.CampaignMode.AssignNPCMenuInteraction ( Character  character,
InteractionType  interactionType 
)

◆ BlocksInteraction()

static bool Barotrauma.CampaignMode.BlocksInteraction ( InteractionType  interactionType)
static

◆ CanAfford()

bool Barotrauma.CampaignMode.CanAfford ( int  cost,
Client  client = null 
)

◆ CancelStartRound()

void Barotrauma.CampaignMode.CancelStartRound ( )

◆ CheckTooManyMissions()

void Barotrauma.CampaignMode.CheckTooManyMissions ( Location  currentLocation,
Client  sender 
)

◆ CreateEndRoundButton()

GUIButton Barotrauma.CampaignMode.CreateEndRoundButton ( )
protected

◆ DoLevelTransition()

abstract IEnumerable<CoroutineStatus> Barotrauma.CampaignMode.DoLevelTransition ( TransitionType  transitionType,
LevelData  newLevel,
Submarine  leavingSub,
bool  mirror 
)
protectedpure virtual

◆ Draw()

override void Barotrauma.CampaignMode.Draw ( SpriteBatch  spriteBatch)
virtual

◆ End()

override void Barotrauma.CampaignMode.End ( CampaignMode.TransitionType  transitionType = CampaignMode.TransitionType.None)

◆ EndCampaign()

void Barotrauma.CampaignMode.EndCampaign ( )

◆ EndCampaignProjSpecific()

virtual void Barotrauma.CampaignMode.EndCampaignProjSpecific ( )
protectedvirtual

◆ GetAvailableTransition() [1/2]

TransitionType Barotrauma.CampaignMode.GetAvailableTransition ( )

◆ GetAvailableTransition() [2/2]

TransitionType Barotrauma.CampaignMode.GetAvailableTransition ( out LevelData  nextLevel,
out Submarine  leavingSub 
)

Which type of transition between levels is currently possible (if any)

Definition at line 607 of file BarotraumaShared/SharedSource/GameSession/GameModes/CampaignMode.cs.

◆ GetBalance()

virtual int Barotrauma.CampaignMode.GetBalance ( Client  client = null)
virtual

◆ GetCurrentDisplayLocation()

Location Barotrauma.CampaignMode.GetCurrentDisplayLocation ( )

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

Definition at line 229 of file BarotraumaShared/SharedSource/GameSession/GameModes/CampaignMode.cs.

◆ GetFaction()

Faction Barotrauma.CampaignMode.GetFaction ( Identifier  identifier)

◆ GetFactionAffiliation()

FactionAffiliation Barotrauma.CampaignMode.GetFactionAffiliation ( Identifier  factionIdentifier)

◆ GetHullRepairCost()

static int Barotrauma.CampaignMode.GetHullRepairCost ( )
static

◆ GetItemRepairCost()

static int Barotrauma.CampaignMode.GetItemRepairCost ( )
static

◆ GetPredefinedStartOutpost()

SubmarineInfo Barotrauma.CampaignMode.GetPredefinedStartOutpost ( )
protected

◆ GetRandomFaction() [1/3]

static Faction Barotrauma.CampaignMode.GetRandomFaction ( IEnumerable< Faction factions,
Rand.RandSync  randSync,
bool  secondary = false,
bool  allowEmpty = true 
)
static

◆ GetRandomFaction() [2/3]

static Faction Barotrauma.CampaignMode.GetRandomFaction ( IEnumerable< Faction factions,
Random  random,
bool  secondary = false,
bool  allowEmpty = true 
)
static

◆ GetRandomFaction() [3/3]

Faction Barotrauma.CampaignMode.GetRandomFaction ( Rand.RandSync  randSync,
bool  allowEmpty = true 
)

Returns a random faction based on their ControlledOutpostPercentage

Parameters
allowEmptyIf true, the method can return null if the sum of the factions ControlledOutpostPercentage is less than 100%

Definition at line 994 of file BarotraumaShared/SharedSource/GameSession/GameModes/CampaignMode.cs.

◆ GetRandomSecondaryFaction()

Faction Barotrauma.CampaignMode.GetRandomSecondaryFaction ( Rand.RandSync  randSync,
bool  allowEmpty = true 
)

Returns a random faction based on their SecondaryControlledOutpostPercentage

Parameters
allowEmptyIf true, the method can return null if the sum of the factions SecondaryControlledOutpostPercentage is less than 100%

Definition at line 1003 of file BarotraumaShared/SharedSource/GameSession/GameModes/CampaignMode.cs.

◆ GetReputation()

float Barotrauma.CampaignMode.GetReputation ( Identifier  factionIdentifier)

◆ GetSubsToLeaveBehind()

static List<Submarine> Barotrauma.CampaignMode.GetSubsToLeaveBehind ( Submarine  leavingSub)
static

◆ GetWallet()

virtual Wallet Barotrauma.CampaignMode.GetWallet ( Client  client = null)
virtual

◆ InitFactions()

void Barotrauma.CampaignMode.InitFactions ( )

◆ KeepCharactersCloseToOutpost()

void Barotrauma.CampaignMode.KeepCharactersCloseToOutpost ( float  deltaTime)
protected

◆ LeaveUnconnectedSubs()

static void Barotrauma.CampaignMode.LeaveUnconnectedSubs ( Submarine  leavingSub)
staticprotected

◆ LoadActiveOrders()

void Barotrauma.CampaignMode.LoadActiveOrders ( )

◆ LoadInitialLevel()

abstract void Barotrauma.CampaignMode.LoadInitialLevel ( )
protectedpure virtual

Load the first level and start the round after loading a save file

Implemented in Barotrauma.SinglePlayerCampaign, and Barotrauma.MultiPlayerCampaign.

◆ LoadNewLevel()

void Barotrauma.CampaignMode.LoadNewLevel ( )

◆ LoadPets()

void Barotrauma.CampaignMode.LoadPets ( )

◆ LoadStats()

void Barotrauma.CampaignMode.LoadStats ( XElement  element)
protected

◆ LogState()

void Barotrauma.CampaignMode.LogState ( )

◆ NumberOfMissionsAtLocation()

int Barotrauma.CampaignMode.NumberOfMissionsAtLocation ( Location  location)

◆ OutpostNPCAttacked()

void Barotrauma.CampaignMode.OutpostNPCAttacked ( Character  npc,
Character  attacker,
AttackResult  attackResult 
)

◆ RefreshOwnedSubmarines()

void Barotrauma.CampaignMode.RefreshOwnedSubmarines ( )
protected

◆ Remove()

override void Barotrauma.CampaignMode.Remove ( )
virtual

◆ Save()

abstract void Barotrauma.CampaignMode.Save ( XElement  element)
pure virtual

◆ SaveActiveOrders()

void Barotrauma.CampaignMode.SaveActiveOrders ( XElement  parentElement = null)

◆ SavePets()

void Barotrauma.CampaignMode.SavePets ( XElement  parentElement = null)

◆ SaveStats()

XElement Barotrauma.CampaignMode.SaveStats ( )
protected

◆ SelectSummaryScreen()

Task Barotrauma.CampaignMode.SelectSummaryScreen ( RoundSummary  roundSummary,
LevelData  newLevel,
bool  mirror,
Action  action 
)

◆ ShowStartMessage()

override void Barotrauma.CampaignMode.ShowStartMessage ( )
virtual

◆ Start()

override void Barotrauma.CampaignMode.Start ( )
virtual

◆ SwitchSubs()

void Barotrauma.CampaignMode.SwitchSubs ( )

◆ ThrowIfStartRoundCancellationRequested()

void Barotrauma.CampaignMode.ThrowIfStartRoundCancellationRequested ( )

◆ TransferItemsBetweenSubs()

void Barotrauma.CampaignMode.TransferItemsBetweenSubs ( )
protected

Also serializes the current sub.

Definition at line 1353 of file BarotraumaShared/SharedSource/GameSession/GameModes/CampaignMode.cs.

◆ TryEndRoundWithFuelCheck()

void Barotrauma.CampaignMode.TryEndRoundWithFuelCheck ( Action  onConfirm,
Action  onReturnToMapScreen 
)
protected

◆ TryHireCharacter()

bool Barotrauma.CampaignMode.TryHireCharacter ( Location  location,
CharacterInfo  characterInfo,
Character  hirer,
Client  client = null 
)

◆ TryPurchase()

virtual bool Barotrauma.CampaignMode.TryPurchase ( Client  client,
int  price 
)
virtual

◆ Update()

override void Barotrauma.CampaignMode.Update ( float  deltaTime)
virtual

◆ UpdateStoreStock()

void Barotrauma.CampaignMode.UpdateStoreStock ( )

Updates store stock before saving the game

Definition at line 917 of file BarotraumaShared/SharedSource/GameSession/GameModes/CampaignMode.cs.

Member Data Documentation

◆ Bank

Wallet Barotrauma.CampaignMode.Bank

◆ CampaignMetadata

readonly CampaignMetadata Barotrauma.CampaignMode.CampaignMetadata

◆ CampaignUI

CampaignUI Barotrauma.CampaignMode.CampaignUI

◆ campaignUIContainer

GUIFrame Barotrauma.CampaignMode.campaignUIContainer
protected

◆ CargoManager

readonly CargoManager Barotrauma.CampaignMode.CargoManager

◆ CheatsEnabled

bool Barotrauma.CampaignMode.CheatsEnabled

◆ crewDead

bool Barotrauma.CampaignMode.crewDead
protected

◆ DivingSuitWarningShown

bool Barotrauma.CampaignMode.DivingSuitWarningShown

◆ endRoundButton

GUIButton Barotrauma.CampaignMode.endRoundButton
protected

◆ EndTransitionDuration

const float Barotrauma.CampaignMode.EndTransitionDuration = 5.0f
staticprotected

◆ HullRepairCostPerDamage

const float Barotrauma.CampaignMode.HullRepairCostPerDamage = 0.1f
static

◆ InitialMoney

const int Barotrauma.CampaignMode.InitialMoney = 8500
static

◆ map

Map Barotrauma.CampaignMode.map
protected

◆ MaxHullRepairCost

const int Barotrauma.CampaignMode.MaxHullRepairCost = 600
static

◆ MaxMoney

readonly record struct SaveInfo ( string FilePath, Option<SerializableDateTime> SaveTime, string SubmarineName, ImmutableArray<string> EnabledContentPackageNames) const int Barotrauma.CampaignMode.MaxMoney = int.MaxValue / 2
static

◆ MedicalClinic

MedicalClinic Barotrauma.CampaignMode.MedicalClinic

◆ OnMoneyChanged

readonly NamedEvent<WalletChangedEvent> Barotrauma.CampaignMode.OnMoneyChanged = new NamedEvent<WalletChangedEvent>()

◆ overlayColor

Color Barotrauma.CampaignMode.overlayColor
protected

◆ overlaySprite

Sprite Barotrauma.CampaignMode.overlaySprite
protected

◆ PendingSubmarineSwitch

SubmarineInfo Barotrauma.CampaignMode.PendingSubmarineSwitch

◆ petsElement

XElement Barotrauma.CampaignMode.petsElement
protected

◆ PurchasedLostShuttlesInLatestSave

bool Barotrauma.CampaignMode.PurchasedLostShuttlesInLatestSave

◆ ReadyCheckButton

GUIButton Barotrauma.CampaignMode.ReadyCheckButton

◆ Settings

CampaignSettings Barotrauma.CampaignMode.Settings

◆ ShuttleReplaceCost

const int Barotrauma.CampaignMode.ShuttleReplaceCost = 1000
static

◆ TotalPassedLevels

int Barotrauma.CampaignMode.TotalPassedLevels

◆ TotalPlayTime

double Barotrauma.CampaignMode.TotalPlayTime

◆ UpgradeManager

UpgradeManager Barotrauma.CampaignMode.UpgradeManager

◆ wasDocked

bool Barotrauma.CampaignMode.wasDocked
protected

Property Documentation

◆ ActiveOrdersElement

XElement Barotrauma.CampaignMode.ActiveOrdersElement
getsetprotected

◆ CurrentLocation

Location Barotrauma.CampaignMode.CurrentLocation
get

◆ DisableEvents

bool Barotrauma.CampaignMode.DisableEvents
get

◆ EndRoundButton

GUIButton Barotrauma.CampaignMode.EndRoundButton
get

◆ Factions

IReadOnlyList<Faction> Barotrauma.CampaignMode.Factions
get

◆ ForceMapUI

bool Barotrauma.CampaignMode.ForceMapUI
getprotected set

◆ IsFirstRound

bool Barotrauma.CampaignMode.IsFirstRound = true
getprotected set

◆ Map

Map Barotrauma.CampaignMode.Map
get

◆ Missions

override IEnumerable<Mission> Barotrauma.CampaignMode.Missions
get

◆ NextLevel

LevelData Barotrauma.CampaignMode.NextLevel
getprotected set

◆ PurchasedHullRepairs

virtual bool Barotrauma.CampaignMode.PurchasedHullRepairs
getset

◆ PurchasedItemRepairs

virtual bool Barotrauma.CampaignMode.PurchasedItemRepairs
getset

◆ PurchasedLostShuttles

virtual bool Barotrauma.CampaignMode.PurchasedLostShuttles
getset

◆ ShowCampaignUI

bool??????? Barotrauma.CampaignMode.ShowCampaignUI
getset

◆ SlideshowPlayer

SlideshowPlayer Barotrauma.CampaignMode.SlideshowPlayer
getprotected set

◆ SwitchedSubsThisRound

bool Barotrauma.CampaignMode.SwitchedSubsThisRound
get

◆ TransferItemsOnSubSwitch

bool Barotrauma.CampaignMode.TransferItemsOnSubSwitch
getset

◆ Wallet

virtual Wallet Barotrauma.CampaignMode.Wallet
get

Gets the current personal wallet In singleplayer this is the campaign bank and in multiplayer this is the personal wallet

Definition at line 89 of file BarotraumaClient/ClientSource/GameSession/GameModes/CampaignMode.cs.

Event Documentation

◆ BeforeLevelLoading

Action Barotrauma.CampaignMode.BeforeLevelLoading

Automatically cleared after triggering -> no need to unregister

Definition at line 346 of file BarotraumaShared/SharedSource/GameSession/GameModes/CampaignMode.cs.