diff options
Diffstat (limited to 'src/systems/pondering.h')
-rw-r--r-- | src/systems/pondering.h | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/systems/pondering.h b/src/systems/pondering.h new file mode 100644 index 0000000..c79bbf6 --- /dev/null +++ b/src/systems/pondering.h | |||
@@ -0,0 +1,81 @@ | |||
1 | #ifndef PONDERING_H_F2530E0E | ||
2 | #define PONDERING_H_F2530E0E | ||
3 | |||
4 | #include "system.h" | ||
5 | #include "components/ponderable.h" | ||
6 | #include "direction.h" | ||
7 | #include "vector.h" | ||
8 | |||
9 | class PonderingSystem : public System { | ||
10 | public: | ||
11 | |||
12 | PonderingSystem(Game& game) : System(game) | ||
13 | { | ||
14 | } | ||
15 | |||
16 | void tick(double dt); | ||
17 | |||
18 | void initializeBody(id_type entity, PonderableComponent::Type type); | ||
19 | |||
20 | /** | ||
21 | * Initializes a ponderable map object from its prototype data. | ||
22 | * | ||
23 | * @requires entity is ponderable | ||
24 | * @requires entity is a map object | ||
25 | */ | ||
26 | void initPrototype(id_type prototype); | ||
27 | |||
28 | /** | ||
29 | * Unferries an entity if it is a passenger of another entity. Use before | ||
30 | * moving a ponderable entity outside the PonderingSystem. | ||
31 | * | ||
32 | * @requires entity is ponderable | ||
33 | */ | ||
34 | void unferry(id_type entity); | ||
35 | |||
36 | private: | ||
37 | |||
38 | struct CollisionResult | ||
39 | { | ||
40 | vec2d pos; | ||
41 | bool stopProcessing = false; | ||
42 | bool touchedWall = false; | ||
43 | bool blockedHoriz = false; | ||
44 | bool blockedVert = false; | ||
45 | bool adjacentlyWarping = false; | ||
46 | Direction adjWarpDir; | ||
47 | size_t adjWarpMapId; | ||
48 | bool grounded = false; | ||
49 | id_type groundEntity; | ||
50 | }; | ||
51 | |||
52 | void tickBody( | ||
53 | id_type entity, | ||
54 | double dt); | ||
55 | |||
56 | CollisionResult moveBody( | ||
57 | id_type entity, | ||
58 | vec2d newPos); | ||
59 | |||
60 | CollisionResult detectCollisions( | ||
61 | id_type entity, | ||
62 | vec2d newPos); | ||
63 | |||
64 | template <typename Param> | ||
65 | void detectCollisionsInDirection( | ||
66 | id_type entity, | ||
67 | CollisionResult& result); | ||
68 | |||
69 | void processCollision( | ||
70 | id_type entity, | ||
71 | id_type collider, | ||
72 | Direction dir, | ||
73 | PonderableComponent::Collision type, | ||
74 | double axis, | ||
75 | double lower, | ||
76 | double upper, | ||
77 | CollisionResult& result); | ||
78 | |||
79 | }; | ||
80 | |||
81 | #endif /* end of include guard: PONDERING_H_F2530E0E */ | ||