range stomp is now named stomp_each for consistency

This commit is contained in:
Michele Caini
2019-10-30 00:03:42 +01:00
parent e2bf903c49
commit c380da7214
4 changed files with 12 additions and 13 deletions

1
TODO
View File

@@ -38,6 +38,5 @@
* meta: are fake types not backed by actual types possible?
* named types: almost-stable index optimization for direct access to pools, no more linear searches
* multi component registry::remove and some others?
- range stomp -> stomp_each
- remove create overload for spwaning
- clean up stomp functions

View File

@@ -688,13 +688,13 @@ nothing more than a container and different optimizations and strategies can be
applied to different containers.
Once there are multiple registries available, however, one or more methods are
needed to transfer information from one container to another and this results in
the `stomp` member function and a couple of overloads of the `create` member
function for the `registry` class .<br/>
The `stomp` function allows to take one entity from a registry and use it to
_stomp_ one or more entities in another registry (or even the same, actually
making local copies). On the other hand, the overloads of the `create` member
function can be used to spawn new entities from a prototype.
needed to transfer information from one container to another. This results in
the `stomp` and `stomp_each` member functions, other than a couple of overloads
of the `create` member function for the `registry` class .<br/>
These functions allow to take one entity from a registry and use it to _stomp_
one or more entities in another registry (or even the same, actually making
local copies). On the other hand, the overloads of the `create` member function
can be used to spawn new entities from a prototype.
These features open definitely the doors to a lot of interesting features like
migrating entities between registries, prototypes, shadow registry, prefabs,

View File

@@ -650,7 +650,7 @@ public:
create(first, last);
if constexpr(sizeof...(Component) == 0) {
stomp<Component...>(first, last, src, other, exclude<Exclude...>);
stomp_each<Component...>(first, last, src, other, exclude<Exclude...>);
} else {
static_assert(sizeof...(Exclude) == 0);
(assure<Component>()->batch(*this, first, last, other.get<Component>(src)), ...);
@@ -1639,7 +1639,7 @@ public:
template<typename... Component, typename... Exclude>
void stomp(const entity_type dst, const entity_type src, const basic_registry &other, exclude_t<Exclude...> = {}) {
const entity_type entt[1]{dst};
stomp<Component...>(std::begin(entt), std::end(entt), src, other, exclude<Exclude...>);
stomp_each<Component...>(std::begin(entt), std::end(entt), src, other, exclude<Exclude...>);
}
/**
@@ -1656,7 +1656,7 @@ public:
* @param other The registry that owns the source entity.
*/
template<typename... Component, typename It, typename... Exclude>
void stomp(It first, It last, const entity_type src, const basic_registry &other, exclude_t<Exclude...> = {}) {
void stomp_each(It first, It last, const entity_type src, const basic_registry &other, exclude_t<Exclude...> = {}) {
static_assert(sizeof...(Component) == 0 || sizeof...(Exclude) == 0);
for(auto pos = other.pools.size(); pos; --pos) {

View File

@@ -1571,7 +1571,7 @@ TEST(Registry, StompMulti) {
entt::entity entities[2];
registry.create(std::begin(entities), std::end(entities));
registry.stomp<int, char, double>(std::begin(entities), std::end(entities), prototype, registry);
registry.stomp_each<int, char, double>(std::begin(entities), std::end(entities), prototype, registry);
ASSERT_TRUE((registry.has<int, char>(entities[0])));
ASSERT_TRUE((registry.has<int, char>(entities[1])));
@@ -1588,7 +1588,7 @@ TEST(Registry, StompExcludeMulti) {
entt::entity entities[2];
registry.create(std::begin(entities), std::end(entities));
registry.stomp(std::begin(entities), std::end(entities), prototype, registry, entt::exclude<char>);
registry.stomp_each(std::begin(entities), std::end(entities), prototype, registry, entt::exclude<char>);
ASSERT_TRUE((registry.has<int>(entities[0])));
ASSERT_TRUE((registry.has<int>(entities[1])));