11 #define FILTER_NAME "Filter"
27 auto copy = entity->_filteredEntities;
28 for (
const FilterPtr& filter : _filters) {
31 s << filter->getName() <<
"{" << filter->getParameters() <<
"}[";
32 entity->_filteredEntities.clear();
33 filter->filter(entity);
36 for (CharacterId
id : entity->_filteredEntities) {
50 entity->_filteredEntities = copy;
57 explicit
Filter (const Filters& filters) :
58 ICondition(FILTER_NAME, ""), _filters(filters) {
67 entity->_filteredEntities.clear();
68 for (
const FilterPtr filter : _filters) {
69 filter->filter(entity);
71 return !entity->_filteredEntities.empty();
75 inline ConditionPtr Filter::Factory::create(
const ConditionFactoryContext *ctx)
const {
76 return std::make_shared<Filter>(ctx->filters);
A condition can be placed on a TreeNode to decide which node is going to get executed. In general they are stateless. If they are not, it should explicitly get noted.
Definition: ICondition.h:124
void getConditionNameWithValue(std::stringstream &s, const AIPtr &entity) override
Override this method to get a more detailed result in getNameWithConditions()
Definition: Filter.h:24
bool evaluate(const AIPtr &entity) override
Executes the attached filters and wiped the last filter results for the given AI entity.
Definition: Filter.h:66
#define CONDITION_FACTORY_NO_IMPL(ConditionName)
A condition factory macro to ease and unify the registration at AIRegistry. You still have to impleme...
Definition: ICondition.h:41
The filter condition executes some selection filters (IFilter) and evaluates to true if the resulting...
Definition: Filter.h:20