summary refs log tree commit diff stats
path: root/src/components/orientable.h
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-02-12 16:39:49 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-02-12 16:39:49 -0500
commit5cc80ec58ea5bd66456f6f5286fa5f26d3fe702b (patch)
tree283cef0e95f237e70892e8b90c841f971cb61fd9 /src/components/orientable.h
parent77be863f4f15d2481a64e4e8dadb4060a6e4e590 (diff)
downloadtherapy-5cc80ec58ea5bd66456f6f5286fa5f26d3fe702b.tar.gz
therapy-5cc80ec58ea5bd66456f6f5286fa5f26d3fe702b.tar.bz2
therapy-5cc80ec58ea5bd66456f6f5286fa5f26d3fe702b.zip
Abstracted behavior related to "orientable" entities
A lot of the stuff that ControllingSystem did to control the player character was moved into the new OrientingSystem. This is so that the player, or any player-like entities, can also be controlled by AI, with the underlying behavior being delegated in the same way as if the player were being controlled by the user.

Fixed the issue where, if the player were blocked while moving horizontally, they would remain blocked even if vertical movement were to remove the collision.

Fixed cases of the player animating incorrectly after performing certain movements.
Diffstat (limited to 'src/components/orientable.h')
-rw-r--r--src/components/orientable.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/components/orientable.h b/src/components/orientable.h index 8f56912..e356b78 100644 --- a/src/components/orientable.h +++ b/src/components/orientable.h
@@ -6,6 +6,18 @@
6class OrientableComponent : public Component { 6class OrientableComponent : public Component {
7public: 7public:
8 8
9 enum class WalkState {
10 still,
11 left,
12 right
13 };
14
15 enum class DropState {
16 none,
17 ready,
18 active
19 };
20
9 inline bool isFacingRight() const 21 inline bool isFacingRight() const
10 { 22 {
11 return facingRight_; 23 return facingRight_;
@@ -16,9 +28,42 @@ public:
16 facingRight_ = v; 28 facingRight_ = v;
17 } 29 }
18 30
31 inline WalkState getWalkState() const
32 {
33 return walkState_;
34 }
35
36 inline void setWalkState(WalkState v)
37 {
38 walkState_ = v;
39 }
40
41 inline bool isJumping() const
42 {
43 return jumping_;
44 }
45
46 inline void setJumping(bool v)
47 {
48 jumping_ = v;
49 }
50
51 inline DropState getDropState() const
52 {
53 return dropState_;
54 }
55
56 inline void setDropState(DropState v)
57 {
58 dropState_ = v;
59 }
60
19private: 61private:
20 62
21 bool facingRight_ = false; 63 bool facingRight_ = false;
64 WalkState walkState_ = WalkState::still;
65 bool jumping_ = false;
66 DropState dropState_ = DropState::none;
22}; 67};
23 68
24#endif /* end of include guard: ORIENTABLE_H_EDB6C4A1 */ 69#endif /* end of include guard: ORIENTABLE_H_EDB6C4A1 */