14 class Last:
public IFilter {
18 Last(
const std::string& parameters,
const Filters& filters) :
19 IFilter(
"Last", parameters), _filters(filters) {
20 ai_assert(filters.size() == 1,
"Last must have one child");
22 FILTER_ACTION_FACTORY(
Last)
24 void filter (
const AIPtr& entity)
override;
27 inline void Last::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).back();
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 last entry of other filters.
Definition: Last.h:14