Peoplemon  0.1.0
Peoplemon 3 game source documentation
Movable.hpp
Go to the documentation of this file.
1 #ifndef CORE_COMPONENTS_MOVABLE_HPP
2 #define CORE_COMPONENTS_MOVABLE_HPP
3 
4 #include <BLIB/Engine/Engine.hpp>
5 #include <BLIB/Events.hpp>
6 #include <BLIB/Tilemap/Position.hpp>
7 #include <SFML/System/Vector2.hpp>
8 
9 namespace core
10 {
11 namespace system
12 {
13 class Movement;
14 class Systems;
15 } // namespace system
16 namespace component
17 {
18 class Renderable;
19 
26 class Movable {
27 public:
35  Movable(bl::tmap::Position& pos, float speed, float fastSpeed);
36 
41  bool moving() const;
42 
47  bool goingFast() const;
48 
58  void move(bl::tmap::Direction dir, bool fast, bool isLedgeHop);
59 
67  void update(bl::ecs::Entity owner, system::Systems& systems, float dt);
68 
69 private:
70  enum struct MoveState : std::uint8_t { Still, Moving, MovingFast, LedgeHopping };
71 
72  bl::tmap::Position& position;
73  float movementSpeed;
74  float fastMovementSpeed;
75  float interpRemaining;
76  bl::tmap::Direction moveDir;
77  MoveState state;
78 
79  friend class system::Movement;
80 };
81 
82 } // namespace component
83 } // namespace core
84 
85 #endif
Core classes and functionality for both the editor and game.
Adding this component to an entity will allow it to move.
Definition: Movable.hpp:26
bool goingFast() const
Returns whether or not the entity is going fast.
Definition: Movable.cpp:45
bool moving() const
Returns whether or not the entity is moving.
Definition: Movable.cpp:43
void update(bl::ecs::Entity owner, system::Systems &systems, float dt)
Updates the interpolation of the entity if moving.
Definition: Movable.cpp:53
Movable(bl::tmap::Position &pos, float speed, float fastSpeed)
Construct a new Movable component.
Definition: Movable.cpp:37
void move(bl::tmap::Direction dir, bool fast, bool isLedgeHop)
Starts the entity moving in the given direction. Only updates the interpolated position,...
Definition: Movable.cpp:47
Primary System for managing entity movement and interpolation.
Definition: Movement.hpp:21
Owns all primary systems and a reference to the engine.
Definition: Systems.hpp:47