From 748b92fc7f295679afaf23ac6aa1934d12c12960 Mon Sep 17 00:00:00 2001 From: Andrei Alexeyev Date: Sat, 5 Nov 2022 22:12:28 +0100 Subject: [PATCH] enemy: add max_viewport_dist attribute Analogous to the max_viewport_dist in Projectiles --- src/enemy.c | 6 +++++- src/enemy.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/enemy.c b/src/enemy.c index 3ca0a7c1..5e273d6f 100644 --- a/src/enemy.c +++ b/src/enemy.c @@ -287,7 +287,11 @@ bool enemy_is_targetable(Enemy *enemy) { } bool enemy_in_viewport(Enemy *enemy) { - double s = 60; // TODO: make this adjustable + // FIXME: Ideally this is supposed to be the size of the visual, as in with projectiles, but + // we don't have access to this information here. + real base = 60; + + real s = base + enemy->max_viewport_dist; return creal(enemy->pos) >= -s && diff --git a/src/enemy.h b/src/enemy.h index dd090e2a..692d5efc 100644 --- a/src/enemy.h +++ b/src/enemy.h @@ -112,6 +112,8 @@ DEFINE_ENTITY_TYPE(Enemy, { float hit_radius; float hurt_radius; + float max_viewport_dist; + bool moving; IF_ENEMY_DEBUG(