Mostly working spatical map with 2 level collision/space structure. Not the best implementation but this is the idea.
This commit is contained in:
parent
fd53f92fe6
commit
d6326c9e41
7 changed files with 60 additions and 31 deletions
13
systems.cpp
13
systems.cpp
|
@ -163,11 +163,10 @@ void System::distribute_loot(GameLevel &level, Position target_pos) {
|
|||
// BUG: inventory_count here isn't really used to remove it
|
||||
world.set<InventoryItem>(junk_entity, {inventory_count, entity_data});
|
||||
world.set<Position>(junk_entity, target_pos);
|
||||
level.collision->insert(target_pos.location, junk_entity);
|
||||
level.collision->insert(target_pos.location, junk_entity, false);
|
||||
level.world->send<Events::GUI>(Events::GUI::ENTITY_SPAWN, junk_entity, {});
|
||||
} else {
|
||||
dbc::log("DEAD BODY NOT IMPLEMENTED, for now just removing enemy");
|
||||
level.collision->remove(target_pos.location);
|
||||
// BUG: should maybe add a component to the world for "dead thing no loot" that
|
||||
// has no collision or goes away after some kind of animation
|
||||
// Something like:
|
||||
|
@ -213,9 +212,11 @@ void System::death(GameLevel &level) {
|
|||
}
|
||||
|
||||
auto pos = world.get<Position>(ent);
|
||||
// NOTE: distribute loot is responsible for either removing or replacing
|
||||
// the collision for this entity. It has to do this since it's determining
|
||||
// if a junkpile goes there or nothing
|
||||
|
||||
// need to remove _after_ getting the position
|
||||
level.collision->remove(pos.location);
|
||||
|
||||
// distribute_loot is then responsible for putting something there
|
||||
System::distribute_loot(level, pos);
|
||||
|
||||
world.destroy(ent);
|
||||
|
@ -454,7 +455,7 @@ bool System::drop_item(GameLevel& level, Entity item) {
|
|||
|
||||
if(map.can_move(pos.location) && !collision.occupied(pos.location)) {
|
||||
world.set<Position>(item, pos);
|
||||
collision.insert(pos.location, item);
|
||||
collision.insert(pos.location, item, false);
|
||||
// BUG: really there should be another system that handles loot->inv moves
|
||||
if(player_inv.has(item)) player_inv.remove(item);
|
||||
level.world->send<Events::GUI>(Events::GUI::ENTITY_SPAWN, item, {});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue