slightly improved registry::replace (thanks to ColinH for pointing it out)
This commit is contained in:
1
AUTHORS
1
AUTHORS
@@ -7,6 +7,7 @@ skypjack
|
||||
BenediktConze
|
||||
bjadamson
|
||||
ceeac
|
||||
ColinH
|
||||
corystegel
|
||||
Croydon
|
||||
dbacchet
|
||||
|
||||
@@ -98,9 +98,7 @@ class basic_registry {
|
||||
Component & replace(const Entity entt, Args &&... args) {
|
||||
Component component{std::forward<Args>(args)...};
|
||||
on_replace.publish(*owner, entt, component);
|
||||
auto &other = sparse_set<Entity, Component>::get(entt);
|
||||
std::swap(other, component);
|
||||
return other;
|
||||
return (sparse_set<Entity, Component>::get(entt) = std::move(component));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user