VIPRA Documentation
Loading...
Searching...
No Matches
target_modifier.hpp
1#pragma once
2
3#include "vipra/vipra_behaviors/definitions/sim_pack.hpp"
4
5namespace VIPRA::Behaviors {
6
11using Modifier = std::function<bool(Simpack, VIPRA::idx, VIPRA::idx)>;
12
18 DEFAULT_CONSTRUCTIBLE(TargetModifier)
19 COPYABLE(TargetModifier)
20 MOVEABLE(TargetModifier)
21
22 public:
32 [[nodiscard]] auto check(Simpack pack, VIPRA::idx self, VIPRA::idx target) const -> bool
33 {
34 return std::all_of(_checks.begin(), _checks.end(), [&](Modifier const& modifier) {
35 return modifier(pack, target, self);
36 });
37 }
38
44 void add_check(Modifier&& check) { _checks.emplace_back(check); }
45
46 private:
47 std::vector<Modifier> _checks;
48};
49} // namespace VIPRA::Behaviors
Modifies who can be a target for an action, by distance, direction, etc.
Definition target_modifier.hpp:17
auto check(Simpack pack, VIPRA::idx self, VIPRA::idx target) const -> bool
Checks that a pedestrian passes all modifier checks.
Definition target_modifier.hpp:32
void add_check(Modifier &&check)
Adds another modifier check to the target modifier.
Definition target_modifier.hpp:44
Holds references to commonly used parameters for simpler passing.
Definition sim_pack.hpp:23