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/entity.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/entity.h')
-rw-r--r-- | src/entity.h | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/src/entity.h b/src/entity.h deleted file mode 100644 index 7f09f2d..0000000 --- a/src/entity.h +++ /dev/null | |||
@@ -1,64 +0,0 @@ | |||
1 | #ifndef ENTITY_H | ||
2 | #define ENTITY_H | ||
3 | |||
4 | #include <list> | ||
5 | #include "renderer.h" | ||
6 | |||
7 | class Game; | ||
8 | class Map; | ||
9 | class Entity; | ||
10 | class Component; | ||
11 | |||
12 | class Message { | ||
13 | public: | ||
14 | enum class Type { | ||
15 | walkLeft, | ||
16 | walkRight, | ||
17 | stopWalking, | ||
18 | setHorizontalVelocity, | ||
19 | setVerticalVelocity, | ||
20 | collision, | ||
21 | jump, | ||
22 | stopJump, | ||
23 | drop, | ||
24 | canDrop, | ||
25 | cantDrop, | ||
26 | die, | ||
27 | stopDying, | ||
28 | hitTheGround | ||
29 | }; | ||
30 | |||
31 | Message(Type type) : type(type) {} | ||
32 | |||
33 | Type type; | ||
34 | Entity* collisionEntity; | ||
35 | int dropAxis; | ||
36 | double velocity; | ||
37 | }; | ||
38 | |||
39 | class Entity { | ||
40 | public: | ||
41 | void addComponent(std::shared_ptr<Component> c); | ||
42 | void send(Game& game, const Message& msg); | ||
43 | void tick(Game& game, double dt); | ||
44 | void input(Game& game, int key, int action); | ||
45 | void render(Game& game, Texture& buffer); | ||
46 | void detectCollision(Game& game, Entity& collider, std::pair<double, double> old_position); | ||
47 | |||
48 | std::pair<double, double> position; | ||
49 | std::pair<int, int> size; | ||
50 | |||
51 | private: | ||
52 | std::list<std::shared_ptr<Component>> components; | ||
53 | }; | ||
54 | |||
55 | class Component { | ||
56 | public: | ||
57 | virtual void receive(Game&, Entity&, const Message&) {} | ||
58 | virtual void render(Game&, Entity&, Texture&) {} | ||
59 | virtual void tick(Game&, Entity&, double) {} | ||
60 | virtual void input(Game&, Entity&, int, int) {} | ||
61 | virtual void detectCollision(Game&, Entity&, Entity&, std::pair<double, double>) {} | ||
62 | }; | ||
63 | |||
64 | #endif | ||