Fix laser beam blocked by own tile, consolidate enemy-type checks

Beam raycast now skips the tile the turret is mounted on, so
wall-embedded laser turrets can shoot outward.

Extract entity_is_enemy() into engine/entity.c as single source
of truth for enemy-type checks. Replaces triplicated type lists
in level.c, drone.c, and projectile.c that caused the collision
bug when new enemy types were added.
This commit is contained in:
Thomas
2026-03-02 20:56:45 +00:00
parent 196b4f35b9
commit af0a9904c2
6 changed files with 33 additions and 19 deletions

View File

@@ -126,3 +126,17 @@ void entity_register(EntityManager *em, EntityType type,
em->render_fn[type] = render;
em->destroy_fn[type] = destroy;
}
bool entity_is_enemy(const Entity *e) {
switch (e->type) {
case ENT_ENEMY_GRUNT:
case ENT_ENEMY_FLYER:
case ENT_TURRET:
case ENT_ENEMY_CHARGER:
case ENT_SPAWNER:
case ENT_LASER_TURRET:
return true;
default:
return false;
}
}

View File

@@ -80,4 +80,8 @@ void entity_register(EntityManager *em, EntityType type,
EntityUpdateFn update, EntityRenderFn render,
EntityDestroyFn destroy);
/* Returns true if the entity is a hostile enemy type.
* Single source of truth — add new enemy types here. */
bool entity_is_enemy(const Entity *e);
#endif /* JNR_ENTITY_H */