4#include <aegis2d/core/hot_reload.hpp>
5#include <aegis2d/core/math.hpp>
6#include <aegis2d/ecs/entity.hpp>
7#include <aegis2d/ecs/registry.hpp>
8#include <aegis2d/script/state.hpp>
23 aegis2d::Vec2
size{32.0F, 32.0F};
43[[nodiscard]] std::vector<std::string>
70 [[nodiscard]]
const std::vector<EnemyType>&
types() const noexcept;
75 [[nodiscard]] const
EnemyType*
find(std::string_view name) const noexcept;
89 aegis2d::ecs::Entity
spawn(std::string_view type, aegis2d::Vec2 position,
float random = 0.0F,
90 float shot_delay = 0.0F);
105 void watch(aegis2d::core::HotReload& hot);
109 void stop(aegis2d::ecs::Entity enemy);
117 [[nodiscard]] aegis2d::script::ScriptState&
lua() noexcept;
120 aegis2d::ecs::Registry* registry_;
121 std::filesystem::path directory_;
122 aegis2d::script::ScriptState lua_;
The enemy types of a directory of Lua scripts, and the behaviors of their enemies.
Definition enemy_scripts.hpp:57
void reload(std::string_view type)
Reads the script of a type again, as when it changed on disk.
const std::vector< EnemyType > & types() const noexcept
The types loaded.
aegis2d::script::ScriptState & lua() noexcept
State of the scripts.
void watch(aegis2d::core::HotReload &hot)
Reloads the script of each type when its file changes.
const EnemyType * find(std::string_view name) const noexcept
Finds a type by name.
void stop(aegis2d::ecs::Entity enemy)
Stops running the behavior of an enemy: it keeps its components and its speed.
EnemyScripts(aegis2d::ecs::Registry ®istry, const std::filesystem::path &directory=default_enemies_directory())
Loads every .lua file of a directory.
void update(float seconds)
Runs the update of every enemy alive, and forgets the others.
aegis2d::ecs::Entity spawn(std::string_view type, aegis2d::Vec2 position, float random=0.0F, float shot_delay=0.0F)
Creates an enemy and runs the spawn of its type.
R-Type game code, built on the Aegis2D engine.
Definition enemy_scripts.hpp:16
std::vector< std::string > enemy_types(const std::filesystem::path &directory=default_enemies_directory())
The enemy types of a directory, as waves files name them.
std::filesystem::path default_enemies_directory()
Directory of the enemy scripts the server plays.
Values of an enemy type, as its script gives them to enemy { ... }.
Definition enemy_scripts.hpp:19
std::string name
Name of the type: its file name without .lua, as waves files name it.
Definition enemy_scripts.hpp:21
float fire_every
Seconds between two shots (fire_every), or 0, the default, to never fire.
Definition enemy_scripts.hpp:29
float first_shot
Seconds before its first shot (first_shot, 1 by default).
Definition enemy_scripts.hpp:31
std::uint32_t score
Points for its killer (score, 100 by default).
Definition enemy_scripts.hpp:27
std::int32_t health
Health points (health, 1 by default).
Definition enemy_scripts.hpp:25
aegis2d::Vec2 size
Size on screen, also its hit box (width and height, 32 by default).
Definition enemy_scripts.hpp:23