diff options
Diffstat (limited to 'src/components/ponderable.h')
-rw-r--r-- | src/components/ponderable.h | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/src/components/ponderable.h b/src/components/ponderable.h new file mode 100644 index 0000000..221d267 --- /dev/null +++ b/src/components/ponderable.h | |||
@@ -0,0 +1,131 @@ | |||
1 | #ifndef TANGIBLE_H_746DB3EE | ||
2 | #define TANGIBLE_H_746DB3EE | ||
3 | |||
4 | #include <set> | ||
5 | #include "component.h" | ||
6 | #include "entity_manager.h" | ||
7 | #include "vector.h" | ||
8 | #include "direction.h" | ||
9 | |||
10 | class PonderableComponent : public Component { | ||
11 | public: | ||
12 | |||
13 | using id_type = EntityManager::id_type; | ||
14 | |||
15 | /** | ||
16 | * List of different types of physical bodies. | ||
17 | * | ||
18 | * vacuumed - Default. | ||
19 | * freefalling - The body will be treated as if there were a downward force | ||
20 | * of gravity being exerted onto it. The body will also exhibit | ||
21 | * terminal velocity (that is, its downward velocity will be | ||
22 | * capped at a constant value). | ||
23 | */ | ||
24 | enum class Type { | ||
25 | vacuumed, | ||
26 | freefalling | ||
27 | }; | ||
28 | |||
29 | /** | ||
30 | * List of different types of collidable surfaces. | ||
31 | */ | ||
32 | enum class Collision { | ||
33 | wall, | ||
34 | platform, | ||
35 | adjacency, | ||
36 | warp, | ||
37 | danger, | ||
38 | event | ||
39 | }; | ||
40 | |||
41 | /** | ||
42 | * Constructor for initializing the body type, which is a constant. | ||
43 | */ | ||
44 | PonderableComponent(Type type) : type(type) | ||
45 | { | ||
46 | } | ||
47 | |||
48 | /** | ||
49 | * The velocity of the body. | ||
50 | */ | ||
51 | vec2d vel = { 0.0, 0.0 }; | ||
52 | |||
53 | /** | ||
54 | * The acceleration of the body. | ||
55 | */ | ||
56 | vec2d accel = { 0.0, 0.0 }; | ||
57 | |||
58 | /** | ||
59 | * The type of physical body that the entity is meant to assume. The body will | ||
60 | * be acted upon differently based on this. See the enumeration above for more | ||
61 | * details. | ||
62 | * | ||
63 | * @managed_by PonderingSystem | ||
64 | */ | ||
65 | const Type type; | ||
66 | |||
67 | /** | ||
68 | * Whether or not a freefalling body is in contact with the ground. | ||
69 | * | ||
70 | * @managed_by PonderingSystem | ||
71 | */ | ||
72 | bool grounded = false; | ||
73 | |||
74 | /** | ||
75 | * Whether or not a freefalling body is being ferried by another body. | ||
76 | * | ||
77 | * @managed_by PonderingSystem | ||
78 | */ | ||
79 | bool ferried = false; | ||
80 | |||
81 | /** | ||
82 | * The entity that is ferrying this body, if there is one. | ||
83 | * | ||
84 | * @managed_by PonderingSystem | ||
85 | */ | ||
86 | id_type ferry; | ||
87 | |||
88 | /** | ||
89 | * The side of the ferry that the body is resting on, if there is one. | ||
90 | * | ||
91 | * @managed_by PonderingSystem | ||
92 | */ | ||
93 | Direction ferrySide; | ||
94 | |||
95 | /** | ||
96 | * The bodies that are being ferried by this body. | ||
97 | * | ||
98 | * @managed_by PonderingSystem | ||
99 | */ | ||
100 | std::set<id_type> passengers; | ||
101 | |||
102 | /** | ||
103 | * If enabled, this will prevent the body from moving and accelerating. The | ||
104 | * velocity and position of the body can still be affected by sources external | ||
105 | * to the PonderingSystem. Enabling this will cause applicable bodies to | ||
106 | * become ungrounded and unferried. | ||
107 | */ | ||
108 | bool frozen = false; | ||
109 | |||
110 | /** | ||
111 | * If disabled, collision detection for this body will not be performed and | ||
112 | * other bodies will ignore it. Disabling this will cause applicable bodies to | ||
113 | * become ungrounded and unferried. | ||
114 | */ | ||
115 | bool collidable = true; | ||
116 | |||
117 | /** | ||
118 | * The effect that colliding with this body has. | ||
119 | */ | ||
120 | Collision colliderType = Collision::wall; | ||
121 | |||
122 | /** | ||
123 | * If this flag is disabled, the entity will be ignored by the pondering | ||
124 | * system. | ||
125 | * | ||
126 | * @managed_by RealizingSystem | ||
127 | */ | ||
128 | bool active = false; | ||
129 | }; | ||
130 | |||
131 | #endif /* end of include guard: TANGIBLE_H_746DB3EE */ | ||