Peoplemon  0.1.0
Peoplemon 3 game source documentation
Flight.hpp
Go to the documentation of this file.
1 #ifndef CORE_SYSTEMS_FLIGHT_HPP
2 #define CORE_SYSTEMS_FLIGHT_HPP
3 
4 #include <BLIB/Cameras/2D/Affectors/CameraShake.hpp>
5 #include <BLIB/Engine/System.hpp>
6 #include <BLIB/Tilemap/Position.hpp>
8 
9 namespace core
10 {
11 namespace system
12 {
13 class Systems;
14 
21 class Flight : public bl::engine::System {
22 public:
28  Flight(Systems& systems);
29 
33  virtual ~Flight() = default;
34 
39  bool flying() const;
40 
47  bool startFlight(unsigned int destSpawn);
48 
49 private:
50  enum struct State {
51  Idle,
52  Rising,
53  Rotating,
54  Accelerating,
55  Flying,
56  Deccelerating,
57  UnRotating,
58  Descending,
59  Holding
60  };
61 
62  struct RiseState {
63  float height;
64  float startY;
65  };
66 
67  struct RotateState {
68  float angle;
69  float targetAngle;
70  float rotateRate;
71  };
72 
73  struct FlyState {
74  float velocity;
75  float angle;
76  float ogDistSqrd;
77  float maxSpeed;
78  };
79 
80  struct HoldState {
81  float lookTime;
82  };
83 
84  Systems& owner;
85  State state;
86  bl::cam::c2d::CameraShake* cameraShake;
87  bl::tmap::Position startPos;
88  bl::tmap::Position* playerPos;
89  component::Renderable* playerAnim;
90  bl::tmap::Position destination;
91  glm::vec2 flightDest;
92  glm::vec2 unitVelocity;
93  union {
94  RiseState riseState;
95  RotateState rotateState;
96  FlyState flyState;
97  HoldState holdState;
98  };
99 
100  void movePlayer(float dt);
101  void rotatePlayer(bl::tmap::Direction dir);
102 
103  virtual void init(bl::engine::Engine&) override;
104  virtual void update(std::mutex&, float dt, float, float, float) override;
105 };
106 
107 } // namespace system
108 } // namespace core
109 
110 #endif
Core classes and functionality for both the editor and game.
Special system to manage player flight between their current location and a town.
Definition: Flight.hpp:21
bool startFlight(unsigned int destSpawn)
Starts flight to the given spawn.
Definition: Flight.cpp:50
Flight(Systems &systems)
Construct a new Flight system.
Definition: Flight.cpp:39
bool flying() const
Returns whether or not the player is currently flying.
Definition: Flight.cpp:48
FlyState flyState
Definition: Flight.hpp:96
RiseState riseState
Definition: Flight.hpp:94
HoldState holdState
Definition: Flight.hpp:97
virtual ~Flight()=default
Destroys the system.
RotateState rotateState
Definition: Flight.hpp:95
Owns all primary systems and a reference to the engine.
Definition: Systems.hpp:47