diff options
| author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-05-17 15:55:37 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-05-17 15:55:37 -0400 |
| commit | 90aadf3844386824140a20d7fbb847bc16009a94 (patch) | |
| tree | 6f83fce90e71abb22b1a8f3e09c79963b2a34d5d /src/systems/pondering.h | |
| parent | bc63fa57ced1c7329f7fdcfd168eaf7e290158bc (diff) | |
| parent | 86f0106d0523825549f1e74b835688c78a10cf6c (diff) | |
| download | therapy-90aadf3844386824140a20d7fbb847bc16009a94.tar.gz therapy-90aadf3844386824140a20d7fbb847bc16009a94.tar.bz2 therapy-90aadf3844386824140a20d7fbb847bc16009a94.zip | |
Merge pull request #7 from hatkirby/es-rewrite
The ECS rewrite exceeds the original branch in functionality, so it is time to merge it in.
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 */ | ||
