From 6ca2b902918a2bbf2c642191bdef71426744a0ad Mon Sep 17 00:00:00 2001 From: Askou Date: Thu, 17 Jun 2021 10:29:29 +0200 Subject: [PATCH] Remove controllable instead of checking health --- sources/Runner/GameScene.cpp | 3 +++ sources/System/Controllable/ControllableSystem.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/sources/Runner/GameScene.cpp b/sources/Runner/GameScene.cpp index 4a427712..187d4d7e 100644 --- a/sources/Runner/GameScene.cpp +++ b/sources/Runner/GameScene.cpp @@ -82,6 +82,9 @@ namespace BBM .addComponent(1, [](WAL::Entity &entity, WAL::Wal &) { auto &animation = entity.getComponent(); animation.setAnimIndex(5); + + if (entity.hasComponent()) + entity.removeComponent(); if (entity.hasComponent()) return; entity.addComponent(1s, [](WAL::Entity &entity, WAL::Wal &wal) { diff --git a/sources/System/Controllable/ControllableSystem.cpp b/sources/System/Controllable/ControllableSystem.cpp index aeeb40d5..36e9815a 100644 --- a/sources/System/Controllable/ControllableSystem.cpp +++ b/sources/System/Controllable/ControllableSystem.cpp @@ -22,7 +22,7 @@ namespace BBM auto health = entity->tryGetComponent(); Vector2f move = controllable.move.normalized() * controllable.speed; - if (health->getHealthPoint() <= 0) + if (health && health->getHealthPoint() <= 0) return; movable.addForce(Vector3f(move.x, 0, move.y)); }