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
|
|
|
|
2017-11-01 04:36:52 +01:00
|
|
|
class GameObject;
|
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;
|
2018-02-06 20:47:31 +01:00
|
|
|
glm::vec3 cameraPosition{};
|
2016-09-09 22:13:20 +02:00
|
|
|
/** 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
|
2018-02-06 20:47:31 +01:00
|
|
|
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
|
|
|
|
2018-01-01 04:14:01 +01:00
|
|
|
void enter() override;
|
2014-05-26 06:34:49 +02:00
|
|
|
|
2018-01-01 04:14:01 +01:00
|
|
|
void exit() override;
|
2014-05-26 06:34:49 +02:00
|
|
|
|
2018-01-01 04:14:01 +01:00
|
|
|
void tick(float dt) override;
|
|
|
|
|
|
|
|
void draw(GameRenderer* r) override;
|
|
|
|
|
|
|
|
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
|
|
|
|
2018-01-01 04:14:01 +01:00
|
|
|
bool shouldWorldUpdate() override;
|
2014-08-12 22:15:26 +02:00
|
|
|
|
Fix some warnings
openrw/rwengine/src/engine/GameData.cpp:358:26: warning: moving a temporary object prevents copy elision [-Wpessimizing-move]
textureslots[slot] = std::move(loadTextureArchive(name));
^
openrw/rwengine/src/engine/GameData.cpp:358:26: note: remove std::move call here
textureslots[slot] = std::move(loadTextureArchive(name));
^~~~~~~~~~ ~
openrw/rwengine/src/objects/CharacterObject.cpp:16:18: warning: unused variable 'enter_offset' [-Wunused-variable]
static glm::vec3 enter_offset(0.81756252f, 0.34800607f, -0.486281008f);
^
In file included from openrw/rwgame/RWGame.cpp:5:
openrw/rwgame/states/BenchmarkState.hpp:33:23: warning: 'BenchmarkState::getCamera' hides overloaded virtual function
[-Woverloaded-virtual]
const ViewCamera& getCamera();
^
openrw/rwgame/State.hpp:51:31: note: hidden overloaded virtual function 'State::getCamera' declared here: different number of
parameters (1 vs 0)
virtual const ViewCamera& getCamera(float alpha);
^
In file included from openrw/rwgame/RWGame.cpp:6:
openrw/rwgame/states/IngameState.hpp:53:18: warning: 'draw' overrides a member function but is not marked 'override'
[-Winconsistent-missing-override]
virtual void draw(GameRenderer* r);
^
openrw/rwgame/State.hpp:28:18: note: overridden virtual function is here
virtual void draw(GameRenderer* r) {
^
In file included from openrw/rwgame/RWGame.cpp:6:
openrw/rwgame/states/IngameState.hpp:60:23: warning: 'getCamera' overrides a member function but is not marked 'override'
[-Winconsistent-missing-override]
const ViewCamera& getCamera(float alpha);
^
openrw/rwgame/State.hpp:51:31: note: overridden virtual function is here
virtual const ViewCamera& getCamera(float alpha);
^
openrw/rwgame/RWGame.cpp:242:22: warning: unused variable 'vehicleModel' [-Wunused-variable]
uint16_t vehicleModel = 110; // @todo Which cars are spawned?!
^
In file included from openrw/rwengine/src/script/modules/GTA3Module.cpp:1:
In file included from openrw/rwengine/src/engine/GameState.hpp:7:
openrw/rwengine/src/engine/ScreenText.hpp:140:63: warning: suggest braces around initialization of subobject [-Wmissing-braces]
const std::array<GameString, sizeof...(args)> vals = {args...};
^~~~
{ }
openrw/rwengine/src/script/modules/GTA3ModuleImpl.inl:5669:16: note: in instantiation of function template specialization
'ScreenText::format<std::__1::basic_string<unsigned short, std::__1::char_traits<unsigned short>, std::__1::allocator<unsigned short> > >'
requested here
ScreenText::format(
^
In file included from openrw/rwengine/src/script/modules/GTA3Module.cpp:1:
In file included from openrw/rwengine/src/engine/GameState.hpp:7:
openrw/rwengine/src/engine/ScreenText.hpp:140:63: warning: suggest braces around initialization of subobject [-Wmissing-braces]
const std::array<GameString, sizeof...(args)> vals = {args...};
^~~~
{ }
openrw/rwengine/src/script/modules/GTA3ModuleImpl.inl:10214:18: note: in instantiation of function template specialization
'ScreenText::format<std::__1::basic_string<unsigned short, std::__1::char_traits<unsigned short>, std::__1::allocator<unsigned short> >,
std::__1::basic_string<unsigned short, std::__1::char_traits<unsigned short>, std::__1::allocator<unsigned short> > >' requested here
ScreenText::format(script::gxt(args, gxtEntry),
^
openrw/rwgame/State.cpp:40:42: warning: unused parameter 'alpha' [-Wunused-parameter]
const ViewCamera& State::getCamera(float alpha) {
^
openrw/rwengine/src/render/ObjectRenderer.cpp:20:17: warning: unused variable 'kWorldDrawDistanceFactor'
[-Wunused-const-variable]
constexpr float kWorldDrawDistanceFactor = kDrawDistanceFactor;
^
2017-09-21 16:45:44 +02:00
|
|
|
const ViewCamera& getCamera(float alpha) override;
|
2016-11-30 00:28:53 +01:00
|
|
|
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
|