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/components/ai.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/components/ai.h')
| -rw-r--r-- | src/components/ai.h | 73 |
1 files changed, 0 insertions, 73 deletions
| diff --git a/src/components/ai.h b/src/components/ai.h deleted file mode 100644 index 840283b..0000000 --- a/src/components/ai.h +++ /dev/null | |||
| @@ -1,73 +0,0 @@ | |||
| 1 | #ifndef AI_H | ||
| 2 | #define AI_H | ||
| 3 | |||
| 4 | #include <list> | ||
| 5 | #include <map> | ||
| 6 | #include <string> | ||
| 7 | #include <memory> | ||
| 8 | |||
| 9 | #include "entity.h" | ||
| 10 | |||
| 11 | class AIAction { | ||
| 12 | public: | ||
| 13 | virtual void start(Game& game, Entity& entity) = 0; | ||
| 14 | virtual void perform(Game& game, Entity& entity, double dt) = 0; | ||
| 15 | virtual bool isDone() const = 0; | ||
| 16 | }; | ||
| 17 | |||
| 18 | class AIActionContainer { | ||
| 19 | public: | ||
| 20 | void addAction(std::shared_ptr<AIAction> action); | ||
| 21 | virtual void start(Game& game, Entity& entity); | ||
| 22 | virtual void perform(Game& game, Entity& entity, double dt); | ||
| 23 | virtual bool isDone() const; | ||
| 24 | |||
| 25 | private: | ||
| 26 | std::list<std::shared_ptr<AIAction>> actions; | ||
| 27 | std::list<std::shared_ptr<AIAction>>::iterator currentAction {end(actions)}; | ||
| 28 | }; | ||
| 29 | |||
| 30 | class AI : public AIActionContainer { | ||
| 31 | public: | ||
| 32 | AI(int chance); | ||
| 33 | |||
| 34 | int getChance() const; | ||
| 35 | |||
| 36 | private: | ||
| 37 | int chance; | ||
| 38 | }; | ||
| 39 | |||
| 40 | class AIComponent : public Component { | ||
| 41 | public: | ||
| 42 | AI& emplaceAI(int chance); | ||
| 43 | void tick(Game& game, Entity& entity, double dt); | ||
| 44 | |||
| 45 | private: | ||
| 46 | int maxChance = 0; | ||
| 47 | std::list<AI> ais; | ||
| 48 | AI* currentAI = nullptr; | ||
| 49 | }; | ||
| 50 | |||
| 51 | class MoveAIAction : public AIAction { | ||
| 52 | public: | ||
| 53 | enum class Direction { | ||
| 54 | Left, | ||
| 55 | Right, | ||
| 56 | Up, | ||
| 57 | Down | ||
| 58 | }; | ||
| 59 | |||
| 60 | MoveAIAction(Direction dir, int len, int speed); | ||
| 61 | |||
| 62 | void start(Game& game, Entity& entity); | ||
| 63 | void perform(Game& game, Entity& entity, double dt); | ||
| 64 | bool isDone() const; | ||
| 65 | |||
| 66 | private: | ||
| 67 | Direction dir; | ||
| 68 | int len; | ||
| 69 | int speed; | ||
| 70 | double remaining; | ||
| 71 | }; | ||
| 72 | |||
| 73 | #endif /* end of include guard: AI_H */ | ||
