OpenXcom
1.0
Open-source clone of the original X-Com
|
Represents the items contained by a certain entity, like base stores, craft equipment, etc. More...
#include <ItemContainer.h>
Public Member Functions | |
ItemContainer () | |
Creates an empty item container. More... | |
~ItemContainer () | |
Cleans up the item container. | |
void | load (const YAML::Node &node) |
Loads the item container from YAML. More... | |
YAML::Node | save () const |
Saves the item container to YAML. More... | |
void | addItem (const std::string &id, int qty=1) |
Adds an item to the container. More... | |
void | removeItem (const std::string &id, int qty=1) |
Removes an item from the container. More... | |
int | getItem (const std::string &id) const |
Gets an item in the container. More... | |
int | getTotalQuantity () const |
Gets the total quantity of items in the container. More... | |
double | getTotalSize (const Ruleset *rule) const |
Gets the total size of items in the container. More... | |
std::map< std::string, int > * | getContents () |
Gets all the items in the container. More... | |
Represents the items contained by a certain entity, like base stores, craft equipment, etc.
Handles all necessary item management tasks.
OpenXcom::ItemContainer::ItemContainer | ( | ) |
Creates an empty item container.
Initializes an item container with no contents.
void OpenXcom::ItemContainer::addItem | ( | const std::string & | id, |
int | qty = 1 |
||
) |
Adds an item to the container.
Adds an item amount to the container.
id | Item ID. |
qty | Item quantity. |
std::map< std::string, int > * OpenXcom::ItemContainer::getContents | ( | ) |
Gets all the items in the container.
Returns all the items currently contained within.
int OpenXcom::ItemContainer::getItem | ( | const std::string & | id | ) | const |
Gets an item in the container.
Returns the quantity of an item in the container.
id | Item ID. |
int OpenXcom::ItemContainer::getTotalQuantity | ( | ) | const |
Gets the total quantity of items in the container.
Returns the total quantity of the items in the container.
double OpenXcom::ItemContainer::getTotalSize | ( | const Ruleset * | rule | ) | const |
Gets the total size of items in the container.
Returns the total size of the items in the container.
rule | Pointer to ruleset. |
void OpenXcom::ItemContainer::load | ( | const YAML::Node & | node | ) |
Loads the item container from YAML.
Loads the item container from a YAML file.
node | YAML node. |
void OpenXcom::ItemContainer::removeItem | ( | const std::string & | id, |
int | qty = 1 |
||
) |
Removes an item from the container.
Removes an item amount from the container.
id | Item ID. |
qty | Item quantity. |
YAML::Node OpenXcom::ItemContainer::save | ( | ) | const |
Saves the item container to YAML.
Saves the item container to a YAML file.