Handle situation when entity already has a component
This commit is contained in:
parent
93d6d14e70
commit
36c0b797be
1 changed files with 6 additions and 0 deletions
|
@ -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];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue