summary refs log tree commit diff stats
path: root/src/components/automatable.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/automatable.h')
-rw-r--r--src/components/automatable.h96
1 files changed, 96 insertions, 0 deletions
diff --git a/src/components/automatable.h b/src/components/automatable.h new file mode 100644 index 0000000..b37945f --- /dev/null +++ b/src/components/automatable.h
@@ -0,0 +1,96 @@
1#ifndef AUTOMATABLE_H_3D519131
2#define AUTOMATABLE_H_3D519131
3
4#include "component.h"
5#include <vector>
6#include <random>
7
8class AutomatableComponent : public Component {
9public:
10
11 /**
12 * Helper class that defines an automatable action.
13 */
14 class Action {
15 public:
16
17 /**
18 * The horizontal and vertical speed, in pixels/sec, that the entity should
19 * move at.
20 */
21 double speedX;
22 double speedY;
23
24 /**
25 * The duration of the action in seconds.
26 */
27 double dur;
28 };
29
30 /**
31 * Helper type that defines a behavior that an entity can exhibit, which is a
32 * list of actions that are stepped through in sequence.
33 */
34 using Behavior = std::vector<Action>;
35
36 /**
37 * A group of behaviors that the entity can exhibit, which are picked at
38 * random at the start of automation and whenever a behavior completes.
39 *
40 * @managed_by RealizingSystem
41 */
42 std::vector<Behavior> behaviors;
43
44 /**
45 * A random distribution over the above behaviors.
46 *
47 * @managed_by RealizingSystem
48 */
49 std::discrete_distribution<size_t> behaviorDist;
50
51 /**
52 * A flag indicating whether a behavior is currently executing.
53 *
54 * @managed_by AutomatingSystem
55 */
56 bool behaviorRunning = false;
57
58 /**
59 * A flag indicating whether an action is currently executing.
60 *
61 * @managed_by AutomatingSystem
62 */
63 bool actionRunning = false;
64
65 /**
66 * The index of the currently executing behavior, if there is one.
67 *
68 * @managed_by AutomatingSystem
69 */
70 size_t currentBehavior;
71
72 /**
73 * The index of the currently executing action, if there is one.
74 *
75 * @managed_by AutomatingSystem
76 */
77 size_t currentAction;
78
79 /**
80 * The amount of time remaining, in seconds, of the currently executing
81 * action.
82 *
83 * @managed_by AutomatingSystem
84 */
85 double remaining;
86
87 /**
88 * If this flag is disabled, the entity will be ignored by the automating
89 * system.
90 *
91 * @managed_by RealizingSystem
92 */
93 bool active = false;
94};
95
96#endif /* end of include guard: AUTOMATABLE_H_3D519131 */