diff --git a/.idea/editor.xml b/.idea/editor.xml
index 5fff85e..12f1328 100644
--- a/.idea/editor.xml
+++ b/.idea/editor.xml
@@ -1,6 +1,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -240,5 +284,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1b88a9c..840df42 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -51,7 +51,7 @@ macro(blt_add_project name source type)
project(tower-defense)
endmacro()
-project(tower-defense VERSION 0.0.11)
+project(tower-defense VERSION 0.0.12)
option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF)
option(ENABLE_UBSAN "Enable the ub sanitizer" OFF)
diff --git a/include/enemies.h b/include/enemies.h
index b1a6e7f..027682c 100644
--- a/include/enemies.h
+++ b/include/enemies.h
@@ -21,19 +21,121 @@
#include
#include
+#include
+#include
namespace td
{
+ // define enemies here
+ // if you add more you must register them.
enum class enemy_id_t
{
+ TEST
+ };
+ struct enemy_instance_t
+ {
+ enemy_id_t id;
};
class enemy_t
{
public:
+ enemy_t(std::string texture_name, std::vector children, damage_type_t damage_resistence, blt::i32 health = 1, blt::i32 damage = 1,
+ float speed = 1.0f);
+
+ enemy_t(std::string texture_name, std::vector children);
+
+ [[nodiscard]] blt::i32 get_health() const
+ {
+ return m_health;
+ }
+
+ [[nodiscard]] damage_type_t get_damage_resistence() const
+ {
+ return m_damage_resistence;
+ }
+
+ [[nodiscard]] const std::vector& get_children() const
+ {
+ return m_children;
+ }
+
+ [[nodiscard]] const std::string& get_texture_name() const
+ {
+ return m_texture_name;
+ }
+
+ [[nodiscard]] blt::i32 get_damage() const
+ {
+ return m_damage;
+ }
+
+ [[nodiscard]] float get_speed() const
+ {
+ return m_speed;
+ }
+
+ enemy_t& set_health(const blt::i32 value)
+ {
+ m_health = value;
+ return *this;
+ }
+
+ enemy_t& set_damage_resistence(const damage_type_t value)
+ {
+ m_damage_resistence = value;
+ return *this;
+ }
+
+ enemy_t& set_children(const std::vector& value)
+ {
+ m_children = value;
+ return *this;
+ }
+
+ enemy_t& set_texture_name(const std::string& value)
+ {
+ m_texture_name = value;
+ return *this;
+ }
+
+ enemy_t& set_m_damage(const blt::i32 m_damage)
+ {
+ this->m_damage = m_damage;
+ return *this;
+ }
+
+ enemy_t& set_m_speed(const float m_speed)
+ {
+ this->m_speed = m_speed;
+ return *this;
+ }
+
private:
- std::string texture_name;
+ std::string m_texture_name;
+ std::vector m_children;
+ damage_type_t m_damage_resistence = damage_type_t::BASE;
+ blt::i32 m_health = 1;
+ blt::i32 m_damage = 1;
+ float m_speed = 1.0f;
+ };
+
+ class enemy_database_t
+ {
+ public:
+ void add_enemy(enemy_id_t enemy_id, const enemy_t& enemy)
+ {
+ const auto index = static_cast(enemy_id);
+ if (enemies_registry.size() <= index)
+ enemies_registry.resize(index + 1);
+ enemies_registry[index] = enemy;
+ }
+
+ private:
+ void register_entities();
+
+ std::vector enemies_registry;
};
}
diff --git a/src/enemies.cpp b/src/enemies.cpp
index a3c29ae..85b2d1e 100644
--- a/src/enemies.cpp
+++ b/src/enemies.cpp
@@ -15,4 +15,19 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-#include
\ No newline at end of file
+#include
+
+td::enemy_t::enemy_t(std::string texture_name, std::vector children, const damage_type_t damage_resistence, const blt::i32 health,
+ const blt::i32 damage, const float speed): m_texture_name(std::move(texture_name)), m_children(std::move(children)),
+ m_damage_resistence(damage_resistence), m_health(health), m_damage(damage),
+ m_speed(speed)
+{}
+
+td::enemy_t::enemy_t(std::string texture_name, std::vector children): m_texture_name(std::move(texture_name)),
+ m_children(std::move(children))
+{}
+
+void td::enemy_database_t::register_entities()
+{
+ add_enemy(enemy_id_t::TEST, enemy_t{"test", {}});
+}