Finally can pick things up, but it's really bad so far. Need a bunch of refactoring in how the collision system works, and make it so collision and maps can have multiple entities in the same square.

This commit is contained in:
Zed A. Shaw 2025-06-12 13:06:36 -04:00
parent 2458f01ebd
commit 2aa4f0a2e8
13 changed files with 78 additions and 43 deletions

View file

@ -302,21 +302,7 @@ void System::collision(GameLevel &level) {
world.send<Events::GUI>(Events::GUI::COMBAT_START, entity, entity);
}
} else if(world.has<InventoryItem>(entity)) {
auto item = world.get<InventoryItem>(entity);
auto& item_pos = world.get<Position>(entity);
if(world.has<ritual::JunkPile>(entity)) {
auto& pile = world.get<ritual::JunkPile>(entity);
auto& blanket = world.get_the<ritual::Blanket>();
for(auto& junk : pile.contents) {
blanket.add(junk);
}
}
collider.remove(item_pos.location);
world.remove<Tile>(entity);
world.send<Events::GUI>(Events::GUI::LOOT, entity, item);
dbc::log("Hit an inventory item, use Sysem::pickup?");
} else if(world.has<Device>(entity)) {
System::device(world, player.entity, entity);
} else {
@ -330,6 +316,28 @@ void System::collision(GameLevel &level) {
}
}
void System::pickup(GameLevel &level, DinkyECS::Entity entity) {
auto &world = *level.world;
if(world.has<InventoryItem>(entity)) {
auto item = world.get<InventoryItem>(entity);
auto& item_pos = world.get<Position>(entity);
if(world.has<ritual::JunkPile>(entity)) {
auto& pile = world.get<ritual::JunkPile>(entity);
auto& blanket = world.get_the<ritual::Blanket>();
for(auto& junk : pile.contents) {
blanket.add(junk);
}
}
level.collision->remove(item_pos.location);
world.remove<Tile>(entity);
world.send<Events::GUI>(Events::GUI::LOOT, entity, item);
}
}
void System::device(DinkyECS::World &world, DinkyECS::Entity actor, DinkyECS::Entity item) {
auto& device = world.get<Device>(item);