Finally get rid of this weird thing in dinkyecs where I was passing a const& to an _integer_ when a copy of the integer is exactly the same.

This commit is contained in:
Zed A. Shaw 2025-02-18 11:39:27 -05:00
parent 49a71e257e
commit 9c66e870d2
3 changed files with 18 additions and 17 deletions

View file

@ -22,13 +22,13 @@ void System::lighting(GameLevel &level) {
light.reset_light();
world.query<Position>([&](const auto &ent[[maybe_unused]], auto &position) {
world.query<Position>([&](auto, auto &position) {
light.set_light_target(position.location);
});
light.path_light(map.walls());
world.query<Position, LightSource>([&](const auto &ent[[maybe_unused]], auto &position, auto &lightsource) {
world.query<Position, LightSource>([&](auto, auto &position, auto &lightsource) {
light.render_light(lightsource, position.location);
});
}
@ -43,7 +43,7 @@ void System::enemy_pathing(GameLevel &level) {
map.set_target(player_position.location);
map.make_paths();
world.query<Position, Motion>([&](const auto &ent, auto &position, auto &motion) {
world.query<Position, Motion>([&](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);
@ -55,13 +55,14 @@ void System::enemy_pathing(GameLevel &level) {
}
}
});
map.clear_target(player_position.location);
}
void System::init_positions(DinkyECS::World &world, SpatialMap &collider) {
// BUG: instead of separate things maybe just one
// BUG: Collision component that references what is collide
world.query<Position>([&](const auto &ent, auto &pos) {
world.query<Position>([&](auto ent, auto &pos) {
if(world.has<Combat>(ent)) {
const auto& combat = world.get<Combat>(ent);
if(!combat.dead) {
@ -95,7 +96,7 @@ void System::motion(GameLevel &level) {
auto &world = *level.world;
auto &collider = *level.collision;
world.query<Position, Motion>([&](const auto &ent, auto &position, auto &motion) {
world.query<Position, Motion>([&](auto ent, auto &position, auto &motion) {
// don't process entities that don't move
if(motion.dx != 0 || motion.dy != 0) {
move_entity(collider, map, position, motion, ent);
@ -112,7 +113,7 @@ void System::death(GameLevel &level) {
// BUG: eachother and overlap their corpse
// BUG: maybe that can be allowed and looting just shows
// BUG: all dead things there?
world.query<Position, Combat>([&](const auto &ent, auto &position, auto &combat) {
world.query<Position, Combat>([&](auto ent, auto &position, auto &combat) {
// bring out yer dead
if(combat.hp <= 0 && !combat.dead) {
fmt::println("DIE! entity {} died", ent);
@ -256,7 +257,7 @@ void System::plan_motion(DinkyECS::World& world, Point move_to) {
void System::draw_entities(DinkyECS::World &world, Map &map, const Matrix &lights, ftxui::Canvas &canvas, const Point &cam_orig, size_t view_x, size_t view_y) {
auto &tiles = map.tiles();
world.query<Position, Tile>([&](auto &ent[[maybe_unused]], auto &pos, auto &tile) {
world.query<Position, Tile>([&](auto, auto &pos, auto &tile) {
if(pos.location.x >= cam_orig.x && pos.location.x <= cam_orig.x + view_x
&& pos.location.y >= cam_orig.y && pos.location.y <= cam_orig.y + view_y) {
Point loc = map.map_to_camera(pos.location, cam_orig);