Barotrauma Client Doc
|
This class handles all upgrade logic. Storing, applying, checking and validation of upgrades. More...
Public Member Functions | |
UpgradeManager (CampaignMode campaign) | |
UpgradeManager (CampaignMode campaign, XElement element, bool isSingleplayer) | |
int | DetermineItemSwapCost (Item item, ItemPrefab? replacement) |
void | PurchaseUpgrade (UpgradePrefab prefab, UpgradeCategory category, bool force=false, Client? client=null) |
Purchases an upgrade and handles logic for deducting the credit. More... | |
void | PurchaseItemSwap (Item itemToRemove, ItemPrefab itemToInstall, bool force=false, Client? client=null) |
Purchases an item swap and handles logic for deducting the credit. More... | |
void | CancelItemSwap (Item itemToRemove, bool force=false) |
Cancels the currently pending item swap, or uninstalls the item if there's no swap pending More... | |
void | ApplyUpgrades () |
Applies all our pending upgrades to the submarine. More... | |
void | CreateUpgradeErrorMessage (string text, bool isSinglePlayer, Character character) |
void | SanityCheckUpgrades () |
Validates that upgrade values stored in CampaignMetadata matches the values on the submarine and fixes any inconsistencies. Should be called after every round start right after ApplyUpgrades More... | |
int | GetUpgradeLevel (UpgradePrefab prefab, UpgradeCategory category, SubmarineInfo? info=null) |
Gets the progress that is shown on the store interface. Includes values stored in the metadata and PendingUpgrades, and takes submarine tier and class restrictions into account More... | |
int | GetRealUpgradeLevel (UpgradePrefab prefab, UpgradeCategory category) |
Gets the level of the upgrade that is stored in the metadata. May be higher than the apparent level on the current sub if the player has switched to a lower-tier sub More... | |
int | GetRealUpgradeLevelForSub (UpgradePrefab prefab, UpgradeCategory category, SubmarineInfo info) |
Gets the level of the upgrade that is stored in the metadata. Takes into account the limits of the provided submarine. More... | |
bool | CanUpgradeSub () |
void | Save (XElement? parent) |
void | SetPendingUpgrades (List< PurchasedUpgrade > upgrades) |
Used to sync the pending upgrades list in multiplayer. More... | |
Static Public Member Functions | |
static ICollection< Item > | GetLinkedItemsToSwap (Item item) |
static void | LogError (string text, Dictionary< string, object?> data, Exception? e=null) |
static void | DebugLog (string msg, Color? color=null) |
Public Attributes | |
readonly List< PurchasedUpgrade > | PurchasedUpgrades = new List<PurchasedUpgrade>() |
This is used by the client to notify the server which upgrades are yet to be paid for. More... | |
readonly List< PurchasedUpgrade > | PendingUpgrades = new List<PurchasedUpgrade>() |
readonly List< PurchasedItemSwap > | PurchasedItemSwaps = new List<PurchasedItemSwap>() |
readonly NamedEvent< UpgradeManager > | OnUpgradesChanged = new NamedEvent<UpgradeManager>() |
Static Public Attributes | |
const bool | UpgradeAlsoConnectedSubs = true |
This one toggles whether or not connected submarines get upgraded too. Could probably be removed, I just didn't like magic numbers. More... | |
This class handles all upgrade logic. Storing, applying, checking and validation of upgrades.
Upgrades are applied per item basis meaning each item has their own set of slots for upgrades. The store applies upgrades globally to categories of items so the purpose of this class is to keep those individual "upgrade slots" in sync. The target level of an upgrade is stored in the metadata and is what the store displays and modifies while this class will make sure that the upgrades on the items match the values stored in the metadata.
Definition at line 55 of file BarotraumaShared/SharedSource/GameSession/UpgradeManager.cs.
Barotrauma.UpgradeManager.UpgradeManager | ( | CampaignMode | campaign | ) |
Definition at line 89 of file BarotraumaShared/SharedSource/GameSession/UpgradeManager.cs.
Barotrauma.UpgradeManager.UpgradeManager | ( | CampaignMode | campaign, |
XElement | element, | ||
bool | isSingleplayer | ||
) |
Definition at line 97 of file BarotraumaShared/SharedSource/GameSession/UpgradeManager.cs.
void Barotrauma.UpgradeManager.ApplyUpgrades | ( | ) |
Applies all our pending upgrades to the submarine.
Upgrades are applied similarly to how items on the submarine are spawned at the start of the round. Upgrades should be applied at the start of the round and after the round ends they are written into the submarine save and saved there. Because of the difficulty of accessing the actual Submarine object from and outpost or when the campaign UI is created we modify levels that are shown on the store interface using campaign metadata.
This method should be called by both the client and the server during level generation. SetUpgradeLevel
Definition at line 479 of file BarotraumaShared/SharedSource/GameSession/UpgradeManager.cs.
void Barotrauma.UpgradeManager.CancelItemSwap | ( | Item | itemToRemove, |
bool | force = false |
||
) |
Cancels the currently pending item swap, or uninstalls the item if there's no swap pending
Definition at line 385 of file BarotraumaShared/SharedSource/GameSession/UpgradeManager.cs.
bool Barotrauma.UpgradeManager.CanUpgradeSub | ( | ) |
Definition at line 738 of file BarotraumaShared/SharedSource/GameSession/UpgradeManager.cs.
void Barotrauma.UpgradeManager.CreateUpgradeErrorMessage | ( | string | text, |
bool | isSinglePlayer, | ||
Character | character | ||
) |
Definition at line 514 of file BarotraumaShared/SharedSource/GameSession/UpgradeManager.cs.
|
static |
Definition at line 832 of file BarotraumaShared/SharedSource/GameSession/UpgradeManager.cs.
int Barotrauma.UpgradeManager.DetermineItemSwapCost | ( | Item | item, |
ItemPrefab? | replacement | ||
) |
Definition at line 121 of file BarotraumaShared/SharedSource/GameSession/UpgradeManager.cs.
Definition at line 446 of file BarotraumaShared/SharedSource/GameSession/UpgradeManager.cs.
int Barotrauma.UpgradeManager.GetRealUpgradeLevel | ( | UpgradePrefab | prefab, |
UpgradeCategory | category | ||
) |
Gets the level of the upgrade that is stored in the metadata. May be higher than the apparent level on the current sub if the player has switched to a lower-tier sub
Definition at line 717 of file BarotraumaShared/SharedSource/GameSession/UpgradeManager.cs.
int Barotrauma.UpgradeManager.GetRealUpgradeLevelForSub | ( | UpgradePrefab | prefab, |
UpgradeCategory | category, | ||
SubmarineInfo | info | ||
) |
Gets the level of the upgrade that is stored in the metadata. Takes into account the limits of the provided submarine.
Definition at line 725 of file BarotraumaShared/SharedSource/GameSession/UpgradeManager.cs.
int Barotrauma.UpgradeManager.GetUpgradeLevel | ( | UpgradePrefab | prefab, |
UpgradeCategory | category, | ||
SubmarineInfo? | info = null |
||
) |
Gets the progress that is shown on the store interface. Includes values stored in the metadata and PendingUpgrades, and takes submarine tier and class restrictions into account
info | Submarine used to determine the upgrade limit. If not defined, will default to the current sub. |
Definition at line 700 of file BarotraumaShared/SharedSource/GameSession/UpgradeManager.cs.
|
static |
Definition at line 810 of file BarotraumaShared/SharedSource/GameSession/UpgradeManager.cs.
void Barotrauma.UpgradeManager.PurchaseItemSwap | ( | Item | itemToRemove, |
ItemPrefab | itemToInstall, | ||
bool | force = false , |
||
Client? | client = null |
||
) |
Purchases an item swap and handles logic for deducting the credit.
Definition at line 284 of file BarotraumaShared/SharedSource/GameSession/UpgradeManager.cs.
void Barotrauma.UpgradeManager.PurchaseUpgrade | ( | UpgradePrefab | prefab, |
UpgradeCategory | category, | ||
bool | force = false , |
||
Client? | client = null |
||
) |
Purchases an upgrade and handles logic for deducting the credit.
Purchased upgrades are temporarily stored in PendingUpgrades and they are applied after the next round starts similarly how items are spawned in the stowage room after the round starts.
Definition at line 172 of file BarotraumaShared/SharedSource/GameSession/UpgradeManager.cs.
void Barotrauma.UpgradeManager.SanityCheckUpgrades | ( | ) |
Validates that upgrade values stored in CampaignMetadata matches the values on the submarine and fixes any inconsistencies. Should be called after every round start right after ApplyUpgrades
submarine |
Definition at line 546 of file BarotraumaShared/SharedSource/GameSession/UpgradeManager.cs.
void Barotrauma.UpgradeManager.Save | ( | XElement? | parent | ) |
Definition at line 745 of file BarotraumaShared/SharedSource/GameSession/UpgradeManager.cs.
void Barotrauma.UpgradeManager.SetPendingUpgrades | ( | List< PurchasedUpgrade > | upgrades | ) |
Used to sync the pending upgrades list in multiplayer.
upgrades |
Definition at line 825 of file BarotraumaShared/SharedSource/GameSession/UpgradeManager.cs.
readonly NamedEvent<UpgradeManager> Barotrauma.UpgradeManager.OnUpgradesChanged = new NamedEvent<UpgradeManager>() |
Definition at line 87 of file BarotraumaShared/SharedSource/GameSession/UpgradeManager.cs.
readonly List<PurchasedUpgrade> Barotrauma.UpgradeManager.PendingUpgrades = new List<PurchasedUpgrade>() |
Definition at line 80 of file BarotraumaShared/SharedSource/GameSession/UpgradeManager.cs.
readonly List<PurchasedItemSwap> Barotrauma.UpgradeManager.PurchasedItemSwaps = new List<PurchasedItemSwap>() |
Definition at line 82 of file BarotraumaShared/SharedSource/GameSession/UpgradeManager.cs.
readonly List<PurchasedUpgrade> Barotrauma.UpgradeManager.PurchasedUpgrades = new List<PurchasedUpgrade>() |
This is used by the client to notify the server which upgrades are yet to be paid for.
In singleplayer this does nothing.
Definition at line 78 of file BarotraumaShared/SharedSource/GameSession/UpgradeManager.cs.
|
static |
This one toggles whether or not connected submarines get upgraded too. Could probably be removed, I just didn't like magic numbers.
Definition at line 61 of file BarotraumaShared/SharedSource/GameSession/UpgradeManager.cs.