2014-05-26 06:34:49 +02:00
|
|
|
#ifndef INGAMESTATE_HPP
|
|
|
|
#define INGAMESTATE_HPP
|
|
|
|
|
2016-10-17 00:56:51 +02:00
|
|
|
#include "StateManager.hpp"
|
2014-05-26 06:34:49 +02:00
|
|
|
|
2014-08-12 22:15:26 +02:00
|
|
|
class PlayerController;
|
2014-05-26 06:34:49 +02:00
|
|
|
|
2016-09-09 22:13:20 +02:00
|
|
|
class IngameState : public State {
|
|
|
|
enum CameraMode {
|
|
|
|
CAMERA_CLOSE = 0,
|
|
|
|
CAMERA_NORMAL = 1,
|
|
|
|
CAMERA_FAR = 2,
|
|
|
|
CAMERA_TOPDOWN = 3,
|
|
|
|
/** Used for counting - not a valid camera mode */
|
|
|
|
CAMERA_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
bool started;
|
2015-07-03 03:52:43 +02:00
|
|
|
std::string save;
|
2016-09-09 22:13:20 +02:00
|
|
|
bool newgame;
|
|
|
|
ViewCamera _look;
|
|
|
|
glm::vec3 cameraPosition;
|
|
|
|
/** Timer to hold user camera position */
|
|
|
|
float autolookTimer;
|
|
|
|
CameraMode camMode;
|
|
|
|
|
2016-12-06 23:40:42 +01:00
|
|
|
/// Player camera input since the last update
|
|
|
|
glm::vec2 cameradelta_;
|
2016-09-09 22:13:20 +02:00
|
|
|
/// Invert Y axis movement
|
|
|
|
bool m_invertedY;
|
|
|
|
/// Free look in vehicles.
|
|
|
|
bool m_vehicleFreeLook;
|
|
|
|
|
2016-09-12 01:35:09 +02:00
|
|
|
float moneyTimer = 0.f; // Timer used to updated displayed money value
|
2016-11-30 00:28:53 +01:00
|
|
|
|
2014-05-26 06:34:49 +02:00
|
|
|
public:
|
2015-07-03 03:52:43 +02:00
|
|
|
/**
|
|
|
|
* @brief IngameState
|
|
|
|
* @param game
|
|
|
|
* @param newgame
|
|
|
|
* @param game An empty string, a save game to load, or the string "test".
|
|
|
|
*/
|
2016-09-09 22:13:20 +02:00
|
|
|
IngameState(RWGame* game, bool newgame = true,
|
|
|
|
const std::string& save = "");
|
2014-05-26 06:34:49 +02:00
|
|
|
|
2016-09-09 22:13:20 +02:00
|
|
|
void startTest();
|
|
|
|
void startGame();
|
2014-05-26 06:34:49 +02:00
|
|
|
|
2017-05-03 09:54:21 +02:00
|
|
|
virtual void enter() override;
|
|
|
|
virtual void exit() override;
|
2014-05-26 06:34:49 +02:00
|
|
|
|
2017-05-03 09:54:21 +02:00
|
|
|
virtual void tick(float dt) override;
|
2015-02-07 23:55:06 +01:00
|
|
|
virtual void draw(GameRenderer* r);
|
2014-05-26 06:34:49 +02:00
|
|
|
|
2017-05-03 09:54:21 +02:00
|
|
|
virtual void handleEvent(const SDL_Event& event) override;
|
2016-09-09 22:13:20 +02:00
|
|
|
virtual void handlePlayerInput(const SDL_Event& event);
|
2016-06-22 12:29:39 +02:00
|
|
|
|
2017-05-03 09:54:21 +02:00
|
|
|
virtual bool shouldWorldUpdate() override;
|
2014-08-12 22:15:26 +02:00
|
|
|
|
2016-11-30 00:28:53 +01:00
|
|
|
const ViewCamera& getCamera(float alpha);
|
|
|
|
private:
|
|
|
|
GameObject* getCameraTarget() const;
|
|
|
|
float getViewDistance() const;
|
2014-05-26 06:34:49 +02:00
|
|
|
};
|
|
|
|
|
2016-09-09 22:13:20 +02:00
|
|
|
#endif // INGAMESTATE_HPP
|