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.h81
1 files changed, 5 insertions, 76 deletions
diff --git a/src/components/automatable.h b/src/components/automatable.h index c1fd1a3..d30340a 100644 --- a/src/components/automatable.h +++ b/src/components/automatable.h
@@ -2,87 +2,16 @@
2#define AUTOMATABLE_H_3D519131 2#define AUTOMATABLE_H_3D519131
3 3
4#include "component.h" 4#include "component.h"
5#include <vector> 5#include <sol.hpp>
6#include <random> 6#include <memory>
7#include "vector.h"
8 7
9class AutomatableComponent : public Component { 8class AutomatableComponent : public Component {
10public: 9public:
11 10
12 /** 11 std::unique_ptr<sol::thread> runner;
13 * Helper class that defines an automatable action. 12 std::unique_ptr<sol::coroutine> behavior;
14 */
15 class Action {
16 public:
17
18 /**
19 * The horizontal and vertical speed, in pixels/sec, that the entity should
20 * move at.
21 */
22 vec2d speed;
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 13
72 /** 14 sol::environment origBehavior;
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 15
87 /** 16 /**
88 * If this flag is disabled, the entity will be ignored by the automating 17 * If this flag is disabled, the entity will be ignored by the automating