Inventory system basically works now but is in a alpha hack stage. Time to refactor.

This commit is contained in:
Zed A. Shaw 2025-02-23 22:57:27 -05:00
parent b7f49aa719
commit e0e7a1027c
11 changed files with 92 additions and 33 deletions

View file

@ -10,6 +10,7 @@
#include "events.hpp"
#include "constants.hpp"
#include "components.hpp"
#include <any>
namespace guecs {
using std::shared_ptr, std::make_shared;
@ -50,7 +51,10 @@ namespace guecs {
};
struct Clickable {
std::function<void(DinkyECS::Entity ent, std::string &name)> action;
/* This is actually called by UI::mouse and passed the entity ID of the
* button pressed so you can interact with it in the event handler.
*/
std::function<void(DinkyECS::Entity ent, std::any data)> action;
};
struct Sprite {
@ -95,6 +99,10 @@ namespace guecs {
}
};
struct ActionData {
std::any data;
};
struct CellName {
std::string name;
};
@ -157,6 +165,7 @@ namespace guecs {
template <typename Comp>
void set_init(DinkyECS::Entity ent, Comp val) {
dbc::check(has<lel::Cell>(ent),"WRONG! slot is missing its cell?!");
auto& cell = get<lel::Cell>(ent);
val.init(cell);
$world.set<Comp>(ent, val);