registry: stomp -> stamp
This commit is contained in:
3
TODO
3
TODO
@@ -12,8 +12,7 @@
|
||||
* add examples (and credits) from @alanjfs :)
|
||||
* static reflection, hint: template<> meta_type_t<Type>: meta_descriptor<name, func..., props..., etc...>
|
||||
* add meta support to registry (eg entity for each component and opaque get)
|
||||
* stomp -> merge (naming is hard as heck, it's known thing)
|
||||
- allow for custom stomp functions
|
||||
* allow for custom stamp functions
|
||||
* observer: user defined filters (eg .replace<T, &function> or .group<T, U, &func>)
|
||||
* any-of rule for views/groups (eg entity has A and any of B/C/D)
|
||||
- get -> all, exclude -> none
|
||||
|
||||
@@ -111,7 +111,7 @@ class basic_registry {
|
||||
std::unique_ptr<sparse_set<Entity>> pool;
|
||||
void(* assure)(basic_registry &, const sparse_set<Entity> &);
|
||||
void(* remove)(sparse_set<Entity> &, basic_registry &, const Entity);
|
||||
void(* stomp)(basic_registry &, const Entity, const sparse_set<Entity> &, const Entity);
|
||||
void(* stamp)(basic_registry &, const Entity, const sparse_set<Entity> &, const Entity);
|
||||
};
|
||||
|
||||
struct group_data {
|
||||
@@ -258,7 +258,7 @@ class basic_registry {
|
||||
other.assure<Component>(static_cast<const pool_type<Component> &>(cpool));
|
||||
};
|
||||
|
||||
pdata.stomp = [](basic_registry &other, const Entity dst, const sparse_set<Entity> &cpool, const Entity src) {
|
||||
pdata.stamp = [](basic_registry &other, const Entity dst, const sparse_set<Entity> &cpool, const Entity src) {
|
||||
other.assign_or_replace<Component>(dst, static_cast<const pool_type<Component> &>(cpool).get(src));
|
||||
};
|
||||
}
|
||||
@@ -1504,7 +1504,7 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Stomps an entity and its components.
|
||||
* @brief Stamps an entity onto another entity.
|
||||
*
|
||||
* The components must be copyable for obvious reasons. The entities
|
||||
* must be both valid.<br/>
|
||||
@@ -1534,11 +1534,11 @@ public:
|
||||
* @param src A valid entity identifier to be copied.
|
||||
*/
|
||||
template<typename... Component, typename... Exclude>
|
||||
void stomp(const entity_type dst, const basic_registry &other, const entity_type src, exclude_t<Exclude...> = {}) {
|
||||
void stamp(const entity_type dst, const basic_registry &other, const entity_type src, exclude_t<Exclude...> = {}) {
|
||||
if constexpr(sizeof...(Component) == 0) {
|
||||
for(size_type pos{}; pos < other.pools.size(); ++pos) {
|
||||
if(const auto &pdata = other.pools[pos]; pdata.stomp && ((pdata.type_id != type_info<Exclude>::id()) && ...) && pdata.pool->has(src)) {
|
||||
pdata.stomp(*this, dst, *pdata.pool, src);
|
||||
if(const auto &pdata = other.pools[pos]; pdata.stamp && ((pdata.type_id != type_info<Exclude>::id()) && ...) && pdata.pool->has(src)) {
|
||||
pdata.stamp(*this, dst, *pdata.pool, src);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -1457,7 +1457,7 @@ TEST(Registry, CloneMoveOnlyComponent) {
|
||||
ASSERT_FALSE(other.has<std::unique_ptr<int>>(entity));
|
||||
}
|
||||
|
||||
TEST(Registry, Stomp) {
|
||||
TEST(Registry, Stamp) {
|
||||
entt::registry registry;
|
||||
|
||||
const auto prototype = registry.create();
|
||||
@@ -1465,7 +1465,7 @@ TEST(Registry, Stomp) {
|
||||
registry.assign<char>(prototype, 'c');
|
||||
|
||||
auto entity = registry.create();
|
||||
registry.stomp<int, char>(entity, registry, prototype);
|
||||
registry.stamp<int, char>(entity, registry, prototype);
|
||||
|
||||
ASSERT_TRUE((registry.has<int, char>(entity)));
|
||||
ASSERT_EQ(registry.get<int>(entity), 3);
|
||||
@@ -1473,13 +1473,13 @@ TEST(Registry, Stomp) {
|
||||
|
||||
registry.replace<int>(prototype, 42);
|
||||
registry.replace<char>(prototype, 'a');
|
||||
registry.stomp<int>(entity, registry, prototype);
|
||||
registry.stamp<int>(entity, registry, prototype);
|
||||
|
||||
ASSERT_EQ(registry.get<int>(entity), 42);
|
||||
ASSERT_EQ(registry.get<char>(entity), 'c');
|
||||
}
|
||||
|
||||
TEST(Registry, StompExclude) {
|
||||
TEST(Registry, StampExclude) {
|
||||
entt::registry registry;
|
||||
|
||||
const auto prototype = registry.create();
|
||||
@@ -1488,26 +1488,26 @@ TEST(Registry, StompExclude) {
|
||||
registry.assign<empty_type>(prototype);
|
||||
|
||||
const auto entity = registry.create();
|
||||
registry.stomp(entity, registry, prototype, entt::exclude<char>);
|
||||
registry.stamp(entity, registry, prototype, entt::exclude<char>);
|
||||
|
||||
ASSERT_TRUE((registry.has<int, empty_type>(entity)));
|
||||
ASSERT_FALSE(registry.has<char>(entity));
|
||||
ASSERT_EQ(registry.get<int>(entity), 3);
|
||||
|
||||
registry.replace<int>(prototype, 42);
|
||||
registry.stomp(entity, registry, prototype, entt::exclude<int>);
|
||||
registry.stamp(entity, registry, prototype, entt::exclude<int>);
|
||||
|
||||
ASSERT_TRUE((registry.has<int, char, empty_type>(entity)));
|
||||
ASSERT_EQ(registry.get<int>(entity), 3);
|
||||
ASSERT_EQ(registry.get<char>(entity), 'c');
|
||||
|
||||
registry.remove<int, char, empty_type>(entity);
|
||||
registry.stomp(entity, registry, prototype, entt::exclude<int, char, empty_type>);
|
||||
registry.stamp(entity, registry, prototype, entt::exclude<int, char, empty_type>);
|
||||
|
||||
ASSERT_TRUE(registry.orphan(entity));
|
||||
}
|
||||
|
||||
TEST(Registry, StompMoveOnlyComponent) {
|
||||
TEST(Registry, StampMoveOnlyComponent) {
|
||||
entt::registry registry;
|
||||
|
||||
const auto prototype = registry.create();
|
||||
@@ -1515,7 +1515,7 @@ TEST(Registry, StompMoveOnlyComponent) {
|
||||
registry.assign<char>(prototype);
|
||||
|
||||
const auto entity = registry.create();
|
||||
registry.stomp(entity, registry, prototype);
|
||||
registry.stamp(entity, registry, prototype);
|
||||
|
||||
ASSERT_TRUE(registry.has<char>(entity));
|
||||
ASSERT_FALSE(registry.has<std::unique_ptr<int>>(entity));
|
||||
|
||||
Reference in New Issue
Block a user