Skip to content

Commit

Permalink
Fix when adding duplicate component
Browse files Browse the repository at this point in the history
  • Loading branch information
varunthomas committed Jun 9, 2023
1 parent 87cd470 commit 15ddb49
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions TurboGE/src/TurboGE/Scene/EntityWrapper.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once
#include"entt.hpp"
#include"Scene.h"
#include"TurboGE/Logger.h"

class b2Body;
namespace TurboGE
Expand Down Expand Up @@ -31,6 +32,11 @@ namespace TurboGE
template<typename T, typename... Args>
T& AddComponent(Args&&... args)
{
if (T* component = HasComponent<T>(); component != nullptr)
{
TURBO_CLIENT_ERR("Component already exists");
return *component;
}
T& component = m_Scene->m_registry.emplace<T>(entityID, std::forward<Args>(args)...);
m_Scene->OnComponentAdded<T>(component);
return component;
Expand Down

0 comments on commit 15ddb49

Please sign in to comment.