Handle situation when entity already has a component

This commit is contained in:
NukeBird 2025-02-23 00:21:36 +03:00
parent 93d6d14e70
commit 36c0b797be

View file

@ -250,6 +250,12 @@ namespace zecsy
template<Component T> template<Component T>
inline void world::set(entity_id e, const T& comp) inline void world::set(entity_id e, const T& comp)
{ {
if(has<T>(e))
{
get<T>(e) = comp;
return;
}
auto id = get_component_id<T>(); auto id = get_component_id<T>();
auto& pool = pools[id]; auto& pool = pools[id];