cntrl/src/game/enemies.hpp

48 lines
1.4 KiB
C++

#pragma once
#include "core/events.hpp"
#include "core/math.hpp"
#include "core/pool.hpp"
#include "game/buffs.hpp"
#include "game/corruption.hpp"
#include "game/player.hpp"
enum class EnemyType { HissStaff, MoldSpore, HissBrute, HissGhost };
struct EnemyDef {
const char* name;
float hp;
float speed;
float contact_damage;
float radius;
float xp;
};
const EnemyDef& enemy_def(EnemyType type);
struct Enemy {
Vec2 pos{};
float hp = 1.0f;
float max_hp = 1.0f;
float speed = 1.0f;
float contact_damage = 1.0f;
float radius = 0.7f;
float attack_cooldown = 0.0f;
float hit_flash = 0.0f;
float bob_phase = 0.0f;
EnemyType type = EnemyType::HissStaff;
EnemyMods mods{}; // Transient buffs/debuffs, recomputed each tick
};
struct EnemySystem {
DensePool<Enemy> enemies{512};
void clear();
void spawn(EnemyType type, Vec2 pos, const Corruption& corruption);
// Steering toward the player + spatial-hash separation + contact attacks.
// Corruption is read every tick so the whole horde — not just fresh spawns —
// gets faster and deadlier as the House decays.
void update(float dt, Player& player, BuffSystem& buff_system, EventQueue& events,
const class Floor& floor, const Corruption& corruption);
int alive_count() const { return static_cast<int>(enemies.size()); }
};