diff options
Diffstat (limited to 'src/mob.cpp')
-rw-r--r-- | src/mob.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/mob.cpp b/src/mob.cpp index 20273d6..99d6f34 100644 --- a/src/mob.cpp +++ b/src/mob.cpp @@ -432,11 +432,26 @@ Chest::Chest(void) : Mob() width = HLINES(10); height = HLINES(5); tex = TextureIterator({"assets/chest.png"}); + inv = new Inventory(1); } void Chest::act(void) { - //die(); + if (isInside(ui::mouse) && player->isNear(this)) { + if ((SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_RIGHT)) && !ui::dialogBoxExists) + for (auto &i : inv->Items) { + player->inv->addItem(i.first->name, i.second); + inv->takeItem(i.first->name, i.second); + } + } + + for (auto &e : currentWorld->entity) { + if (e->type == OBJECTT && e->isNear(this)) { + auto o = dynamic_cast<Object *>(e); + inv->addItem(o->iname, 1); + e->health = 0; + } + } } void Chest::onHit(unsigned int _health) |