Browse Source

Lesson 11.9

Godzil 3 years ago
parent
commit
e30ed08885
3 changed files with 4 additions and 2 deletions
  1. 1 1
      source/Game.cpp
  2. 1 1
      source/include/Components/RigidBody.h
  3. 2 0
      source/include/ECS.h

+ 1 - 1
source/Game.cpp

@@ -103,7 +103,7 @@ void Game::Setup()
 
     tank.addComponent<TransformComponent>(glm::vec2(10, 30), glm::vec2(1, 1), 0);
     tank.addComponent<RigidBodyComponent>(glm::vec2(50, 0));
-
+    tank.removeComponent<TransformComponent>();
 }
 
 void Game::Update()

+ 1 - 1
source/include/Components/RigidBody.h

@@ -16,7 +16,7 @@ struct RigidBodyComponent
 {
     glm::vec2 velocity;
 
-    explicit RigidBodyComponent(glm::vec2 velocity = glm::vec2(0, 0),):velocity(velocity) {};
+    explicit RigidBodyComponent(glm::vec2 velocity = glm::vec2(0, 0)):velocity(velocity) {};
 };
 
 

+ 2 - 0
source/include/ECS.h

@@ -166,6 +166,8 @@ template <typename T> void Registry::removeComponent(Entity entity)
     const auto entityId = entity.getId();
 
     this->entityComponentSignatures[entityId].set(componentId, false);
+
+    Logger::Debug("Component id#%d was removed to entity id#%d", componentId, entityId);
 }
 
 template <typename T> bool Registry::hasComponent(Entity entity)