Skip to content

Commit

Permalink
ECS: Remove struct health_s
Browse files Browse the repository at this point in the history
  • Loading branch information
Saverio976 committed Oct 31, 2023
1 parent c35db01 commit 1efd1ac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 6 additions & 0 deletions include/B-luga/Plugins/Systems/ECSCustomTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
// all values are in percentage of the screen
namespace Types {

struct Health {
int hp;

NLOHMANN_DEFINE_TYPE_INTRUSIVE(Health, hp);
};

struct CollisionRect {
int width;
int height;
Expand Down
10 changes: 5 additions & 5 deletions include/B-luga/Plugins/Systems/ECSSystems.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
#include <functional>
#include <string>
#include <vector>
#include "nlohmann/json.hpp"
#include "B-luga/Json.hpp"
#include <nlohmann/json.hpp>
#include "B-luga/Plugins/Systems/ECSCustomTypes.hpp"
#include "B-luga/Maths/Maths.hpp"
#include "B-luga/Registry.hpp"
Expand Down Expand Up @@ -66,8 +66,8 @@ namespace Systems {
{
Registry::components<Types::Damage> arrDamage =
Registry::getInstance().getComponents<Types::Damage>();
Registry::components<struct health_s> arrHealth =
Registry::getInstance().getComponents<struct health_s>();
Registry::components<Types::Health> arrHealth =
Registry::getInstance().getComponents<Types::Health>();

if (arrDamage.exist(firstEntity) && arrDamage[firstEntity].damage > 0) {
if (arrHealth.exist(secondEntity)) {
Expand Down Expand Up @@ -200,8 +200,8 @@ namespace Systems {
static void deathChecker(std::size_t /*unused*/, std::size_t /*unused*/)
{
std::lock_guard<std::mutex> lock(Registry::getInstance().mutex);
Registry::components<struct health_s> arrHealth =
Registry::getInstance().getComponents<struct health_s>();
Registry::components<Types::Health> arrHealth =
Registry::getInstance().getComponents<Types::Health>();
Registry::components<Types::Dead> arrDead = Registry::getInstance().getComponents<Types::Dead>();

std::vector<std::size_t> ids = arrHealth.getExistingsId();
Expand Down

0 comments on commit 1efd1ac

Please sign in to comment.