Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2010-09-19 19:44:13 +0000
committerStijn Buys <ingar@osirion.org>2010-09-19 19:44:13 +0000
commitcc18095cded14f5e7e3f049e47fca2224134b647 (patch)
tree2a057f4836925083a19988d571dc0664925c9e48 /src/core/inventory.h
parentbadfb31888a6bd62e0a019b3f3dec517df4121ec (diff)
text rendering cleanups, inventory capacity & cargo volume
Diffstat (limited to 'src/core/inventory.h')
-rw-r--r--src/core/inventory.h77
1 files changed, 62 insertions, 15 deletions
diff --git a/src/core/inventory.h b/src/core/inventory.h
index 0a412b0..aff9790 100644
--- a/src/core/inventory.h
+++ b/src/core/inventory.h
@@ -21,20 +21,59 @@ class Inventory
{
public:
/**
- * @brief type definition for the items in the inventory
+ * @brief type definition for items in the inventory
*/
typedef std::vector<Item *> Items;
/**
* @brief default constructor
*/
- Inventory();
+ Inventory(const float capacity = 0);
/**
* @brief default destructor
*/
~Inventory();
+ /* ---- inspectors ------------------------------------------------- */
+
+ /**
+ * @brief items in the inventory
+ */
+ inline Items &items() {
+ return inventory_items;
+ };
+
+ /**
+ * @brief return the timestamp
+ */
+ inline const unsigned long timestamp() const {
+ return inventory_timestamp;
+ }
+
+ /**
+ * @brief return the maximal inventory capacity, in cubic meters
+ */
+ inline const float capacity() const {
+ return inventory_capacity;
+ }
+
+ /**
+ * @brief return the used inventory capacity, in cubic meters
+ */
+ inline const float capacity_used() const {
+ return inventory_capacity_used;
+ }
+
+ /**
+ * @brief return the availableinventory capacity, in cubic meters
+ */
+ inline const float capacity_available() const {
+ return inventory_capacity - inventory_capacity_used;
+ }
+
+ /* ---- mutators --------------------------------------------------- */
+
/**
* @brief add an item to the inventory
*/
@@ -54,32 +93,40 @@ public:
* @brief search the inventory for a specific item type
*/
Item *find(const Info *info);
-
- inline Items &items() {
- return inventory_items;
- };
-
- /**
- * @brief return the timestamp
- */
- inline const unsigned long timestamp() const {
- return inventory_timestamp;
- }
-
+
/**
* @brief set the timestamp
*/
void set_timestamp(const unsigned long timestamp);
/**
- * @brief set the timestamp to the current game time
+ * @brief mark the inventory as dirty
+ * This method will set the timestamp to the current game time
+ * and will recalculate the available capacity
+ * @see recalculate()
*/
void set_dirty();
+ /**
+ * @brief set the maximal inventory capacity, in cubic meters
+ */
+ void set_capacity(const float capacity);
+
private:
+ // recalculate inventory capacity
+ void recalculate();
+
+ // items in the inventory
Items inventory_items;
+
// timestamp when inventory was last updated
unsigned long inventory_timestamp;
+
+ // maximum inventory capacity, in cubic meters
+ float inventory_capacity;
+
+ // current capacity used, in cubic meters
+ float inventory_capacity_used;
};
} // namsepace core