Swapping and putting back now work in the status_ui inventory, but now I need to refactor so this operation works on any inventory::Model.
This commit is contained in:
parent
784f753e72
commit
2421a33bb0
3 changed files with 34 additions and 4 deletions
|
@ -135,4 +135,25 @@ namespace gui {
|
|||
$gui.remove<guecs::GrabSource>(slot_id);
|
||||
$gui.remove<guecs::Sprite>(slot_id);
|
||||
}
|
||||
|
||||
void StatusUI::swap(guecs::Entity gui_a, guecs::Entity gui_b) {
|
||||
if(gui_a != gui_b) {
|
||||
auto& inventory = $level.world->get_the<inventory::Model>();
|
||||
auto& a_name = $slot_to_name.at(gui_a);
|
||||
auto& b_name = $slot_to_name.at(gui_b);
|
||||
auto a_ent = inventory.get(a_name);
|
||||
auto b_ent = inventory.get(b_name);
|
||||
inventory.swap(a_ent, b_ent);
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
bool StatusUI::occupied(guecs::Entity slot) {
|
||||
dbc::check($slot_to_name.contains(slot), "jank ass slot to name thing isn't loaded right you idiot.");
|
||||
|
||||
auto& inventory = $level.world->get_the<inventory::Model>();
|
||||
auto& slot_name = $slot_to_name.at(slot);
|
||||
return inventory.has(slot_name);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue