treballant en sistema de portes i claus
This commit is contained in:
34
source/game/gameplay/inventory.cpp
Normal file
34
source/game/gameplay/inventory.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
#include "game/gameplay/inventory.hpp"
|
||||
|
||||
// [SINGLETON]
|
||||
Inventory* Inventory::inventory = nullptr;
|
||||
|
||||
// [SINGLETON] Crearemos el objeto con esta función estática
|
||||
void Inventory::init() {
|
||||
Inventory::inventory = new Inventory();
|
||||
}
|
||||
|
||||
// [SINGLETON] Destruiremos el objeto con esta función estática
|
||||
void Inventory::destroy() {
|
||||
delete Inventory::inventory;
|
||||
}
|
||||
|
||||
// [SINGLETON] Con este método obtenemos el objeto y podemos trabajar con él
|
||||
auto Inventory::get() -> Inventory* {
|
||||
return Inventory::inventory;
|
||||
}
|
||||
|
||||
// Añade una llave al inventario
|
||||
void Inventory::addKey(const std::string& key_id) {
|
||||
keys_.insert(key_id);
|
||||
}
|
||||
|
||||
// Comprueba si el inventario contiene una llave
|
||||
auto Inventory::hasKey(const std::string& key_id) const -> bool {
|
||||
return keys_.contains(key_id);
|
||||
}
|
||||
|
||||
// Vacía el inventario
|
||||
void Inventory::clear() {
|
||||
keys_.clear();
|
||||
}
|
||||
Reference in New Issue
Block a user