Fixed up building enemies and items using componentsin the JSON.

This commit is contained in:
Zed A. Shaw 2025-01-09 14:01:40 -05:00
parent 9ce4fbd552
commit 222b39c403
13 changed files with 76 additions and 60 deletions

View file

@ -32,15 +32,17 @@ void System::lighting(DinkyECS::World &world, Map &game_map, LightRender &light,
void System::enemy_pathing(DinkyECS::World &world, Map &game_map, Player &player) {
// TODO: this will be on each enemy not a global thing
const auto &config = world.get_the<EnemyConfig>();
const auto &player_position = world.get<Position>(player.entity);
game_map.set_target(player_position.location);
game_map.make_paths();
world.query<Position, Motion>([&](const auto &ent, auto &position, auto &motion) {
if(ent != player.entity) {
dbc::check(world.has<EnemyConfig>(ent), "enemy is missing config");
const auto &config = world.get<EnemyConfig>(ent);
Point out = position.location; // copy
if(game_map.distance(out) < config.HEARING_DISTANCE) {
if(game_map.distance(out) < config.hearing_distance) {
game_map.neighbors(out);
motion = { int(out.x - position.location.x), int(out.y - position.location.y)};
}