Now added a System::multi_path which can target to multiple entities.
This commit is contained in:
parent
fc678c6b42
commit
4365aa4bfc
2 changed files with 25 additions and 21 deletions
22
systems.hpp
22
systems.hpp
|
@ -3,6 +3,7 @@
|
|||
#include <SFML/Graphics/RenderTexture.hpp>
|
||||
#include "map.hpp"
|
||||
#include "spatialmap.hpp"
|
||||
#include "game_level.hpp"
|
||||
|
||||
namespace System {
|
||||
using namespace components;
|
||||
|
@ -43,4 +44,25 @@ namespace System {
|
|||
|
||||
void set_position(DinkyECS::World& world, SpatialMap& collision, Entity entity, Position pos);
|
||||
bool use_item(const std::string& slot_name);
|
||||
|
||||
template <typename T>
|
||||
void multi_path(GameDB::Level& level, Pathing& paths, Matrix& walls) {
|
||||
// first, put everything of this type as a target
|
||||
level.world->query<Position, T>(
|
||||
[&](const auto ent, auto& position, auto&) {
|
||||
if(ent != level.player) {
|
||||
paths.set_target(position.location);
|
||||
}
|
||||
});
|
||||
|
||||
level.world->query<Collision>(
|
||||
[&](const auto ent, auto& collision) {
|
||||
if(collision.has && ent != level.player) {
|
||||
auto& pos = level.world->get<Position>(ent);
|
||||
walls[pos.location.y][pos.location.x] = WALL_VALUE;
|
||||
}
|
||||
});
|
||||
|
||||
paths.compute_paths(walls);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue