VIPRA Documentation
Loading...
Searching...
No Matches
subcondition_event.hpp
1#pragma once
2
3#include "vipra/vipra_behaviors/conditions/sub_condition.hpp"
4#include "vipra/vipra_behaviors/definitions/behavior_context.hpp"
5#include "vipra/vipra_behaviors/definitions/sim_pack.hpp"
6#include "vipra/vipra_behaviors/events/event.hpp"
7#include "vipra/vipra_behaviors/util/class_types.hpp"
8
9namespace VIPRA::Behaviors {
10
15class SubConditionEventOccurred {
16 NON_DEFAULT_CONSTRUCTIBLE(SubConditionEventOccurred)
17 COPYABLE(SubConditionEventOccurred)
18 MOVEABLE(SubConditionEventOccurred)
19 public:
20 explicit SubConditionEventOccurred(VIPRA::idx event, bool negate)
21 : _event(event), _negate(negate)
22 {
23 }
24
25 void operator()(Simpack pack, const VIPRA::idxVec& /*unused*/,
26 std::vector<Target> const& /*unused*/, std::vector<bool>& met,
27 std::vector<bool> const& /*unused*/, BoolOp /*unused*/) const
28 {
29 if ( _negate ) {
30 std::fill(met.begin(), met.end(), ! pack.context.events[_event].has_occurred());
31 }
32 else {
33 std::fill(met.begin(), met.end(), pack.context.events[_event].has_occurred());
34 }
35 }
36
37 private:
38 VIPRA::idx _event;
39 bool _negate{false};
40};
41
42} // namespace VIPRA::Behaviors
Holds references to commonly used parameters for simpler passing.
Definition sim_pack.hpp:23