feat(entities): migrar la configuració dels 3 enemics a data/entities/<type>/*.yaml

This commit is contained in:
2026-05-25 10:01:12 +02:00
parent ed4d3a3915
commit 39bda0775e
14 changed files with 431 additions and 212 deletions
+5 -30
View File
@@ -8,38 +8,13 @@
#include "core/physics/collision.hpp"
#include "core/types.hpp"
#include "game/constants.hpp"
#include "game/entities/enemy_config.hpp"
namespace Systems::Collision {
namespace {
constexpr uint8_t NO_SHOOTER = 0xFF;
// Lookup tabla puntos / color por tipo de enemy (mantiene la lógica
// anterior pero centralizada para reutilizar entre paths).
auto scoreForType(EnemyType type) -> int {
switch (type) {
case EnemyType::PENTAGON:
return Defaults::Enemies::Scoring::PENTAGON_SCORE;
case EnemyType::SQUARE:
return Defaults::Enemies::Scoring::SQUARE_SCORE;
case EnemyType::PINWHEEL:
return Defaults::Enemies::Scoring::PINWHEEL_SCORE;
}
return 0;
}
auto colorForType(EnemyType type) -> SDL_Color {
switch (type) {
case EnemyType::PENTAGON:
return Defaults::Palette::PENTAGON;
case EnemyType::SQUARE:
return Defaults::Palette::SQUARE;
case EnemyType::PINWHEEL:
return Defaults::Palette::PINWHEEL;
}
return SDL_Color{};
}
// Mata al enemy con explosión: floating score, debris con velocity heredada,
// sonido. Si shooter_id ≠ NO_SHOOTER, suma puntos a ese jugador.
// CRUCIAL: leer velocity/datos ANTES de destruir() (que zera la velocity).
@@ -48,10 +23,10 @@ namespace Systems::Collision {
const Vec2 ENEMY_VEL = enemy.getVelocityVector();
const float BRIGHTNESS = enemy.getBrightness();
const auto SHAPE = enemy.getShape();
const EnemyType TYPE = enemy.getType();
const int POINTS = scoreForType(TYPE);
const SDL_Color COLOR = colorForType(TYPE);
const int POINTS = enemy.getConfig().score;
const SDL_Color COLOR = enemy.getConfig().colors.normal;
const SDL_Color WOUNDED_COLOR = enemy.getConfig().colors.wounded;
if (shooter_id != NO_SHOOTER) {
ctx.score_per_player[shooter_id] += POINTS;
@@ -86,7 +61,7 @@ namespace Systems::Collision {
Defaults::FX::Firework::N_POINTS,
Defaults::FX::Firework::INITIAL_BRIGHTNESS,
/*glow=*/true,
Defaults::Palette::WOUNDED);
WOUNDED_COLOR);
}
// Trenca una bala en debris (8 fragments de l'octàgon) + so HIT + desactiva.