observer: when -> where (close #265)
This commit is contained in:
@@ -512,10 +512,10 @@ last time one asked.<br/>
|
||||
Note that, for a grouping matcher, if an entity already has all the components
|
||||
except one and the missing type is assigned to it, it is intercepted.
|
||||
|
||||
In addition, a matcher can be filtered with a `when` clause:
|
||||
In addition, a matcher can be filtered with a `where` clause:
|
||||
|
||||
```cpp
|
||||
entt::collector.replace<sprite>().when<position>(entt::exclude<velocity>);
|
||||
entt::collector.replace<sprite>().where<position>(entt::exclude<velocity>);
|
||||
```
|
||||
|
||||
This clause introduces a way to intercept entities if and only if they are
|
||||
@@ -526,7 +526,7 @@ the observer probes the entity itself to verify that it has at least `position`
|
||||
and has not `velocity` before to store it aside. If one of the two conditions of
|
||||
the filter isn't respected, the entity is discared, no matter what.
|
||||
|
||||
A `when` clause accepts a theoretically unlimited number of types as well as
|
||||
A `where` clause accepts a theoretically unlimited number of types as well as
|
||||
multiple elements in the exclusion list. Moreover, every matcher can have it's
|
||||
own clause and multiple clauses for the same matcher are combined in a single
|
||||
one.
|
||||
|
||||
@@ -104,7 +104,7 @@ struct basic_collector<matcher<matcher<type_list<Reject...>, type_list<Require..
|
||||
* @return The updated collector.
|
||||
*/
|
||||
template<typename... AllOf, typename... NoneOf>
|
||||
static constexpr auto when(exclude_t<NoneOf...> = {}) ENTT_NOEXCEPT {
|
||||
static constexpr auto where(exclude_t<NoneOf...> = {}) ENTT_NOEXCEPT {
|
||||
return basic_collector<matcher<matcher<type_list<Reject..., NoneOf...>, type_list<Require..., AllOf...>>, Rule...>, Other...>{};
|
||||
}
|
||||
};
|
||||
@@ -135,8 +135,8 @@ constexpr basic_collector<> collector{};
|
||||
* If an entity respects the requirements of multiple matchers, it will be
|
||||
* returned once and only once by the observer in any case.
|
||||
*
|
||||
* Matchers support also filtering by means of a _when_ clause that accepts both
|
||||
* a list of types and an exclusion list.<br/>
|
||||
* Matchers support also filtering by means of a _where_ clause that accepts
|
||||
* both a list of types and an exclusion list.<br/>
|
||||
* Whenever a matcher finds that an entity matches its requirements, the
|
||||
* condition of the filter is verified before to register the entity itself.
|
||||
* Moreover, a registered entity isn't returned by the observer if the condition
|
||||
|
||||
@@ -86,7 +86,7 @@ TEST(Observer, AllOf) {
|
||||
|
||||
TEST(Observer, AllOfFiltered) {
|
||||
constexpr auto collector = entt::collector
|
||||
.group<int>().when<char>(entt::exclude<double>);
|
||||
.group<int>().where<char>(entt::exclude<double>);
|
||||
|
||||
entt::registry registry;
|
||||
entt::observer observer{registry, collector};
|
||||
@@ -160,7 +160,7 @@ TEST(Observer, Observe) {
|
||||
|
||||
TEST(Observer, ObserveFiltered) {
|
||||
constexpr auto collector = entt::collector
|
||||
.replace<int>().when<char>(entt::exclude<double>);
|
||||
.replace<int>().where<char>(entt::exclude<double>);
|
||||
|
||||
entt::registry registry;
|
||||
entt::observer observer{registry, collector};
|
||||
|
||||
Reference in New Issue
Block a user