18 First(
const std::string& parameters,
const Filters& filters) :
19 IFilter(
"First", parameters), _filters(filters) {
20 ai_assert(filters.size() == 1,
"First must have one child");
22 FILTER_ACTION_FACTORY(
First)
24 void filter (
const AIPtr& entity)
override;
27 inline void First::filter (
const AIPtr& entity) {
28 FilteredEntities& filtered = getFilteredEntities(entity);
29 const FilteredEntities copy = filtered;
31 _filters.front()->filter(entity);
32 const auto& value = getFilteredEntities(entity).front();
34 for (
auto& e : copy) {
35 filtered.push_back(e);
37 filtered.push_back(value);
#define ai_assert(condition,...)
Provide your own assert - this is only executed in DEBUG mode.
Definition: Types.h:75
This filter will just preserve the first entry of other filters.
Definition: First.h:14