2016-10-16 20:39:05 +01:00
|
|
|
#ifndef RWGAME_RWGAME_HPP
|
|
|
|
#define RWGAME_RWGAME_HPP
|
2015-03-30 02:45:58 +01:00
|
|
|
|
2018-12-12 18:51:04 +01:00
|
|
|
#include "GameBase.hpp"
|
|
|
|
#include "HUDDrawer.hpp"
|
2018-12-20 20:31:14 +01:00
|
|
|
#include "RWConfig.hpp"
|
|
|
|
#include "RWImGui.hpp"
|
2018-12-18 22:43:49 +01:00
|
|
|
#include "StateManager.hpp"
|
2018-12-09 22:43:42 +01:00
|
|
|
#include "game.hpp"
|
2017-11-01 03:13:07 +01:00
|
|
|
|
2015-04-18 01:11:17 +01:00
|
|
|
#include <engine/GameData.hpp>
|
2016-10-20 00:01:18 +01:00
|
|
|
#include <engine/GameState.hpp>
|
2014-09-16 19:22:43 +01:00
|
|
|
#include <engine/GameWorld.hpp>
|
2016-10-16 20:37:07 +01:00
|
|
|
#include <render/DebugDraw.hpp>
|
2016-10-20 00:01:18 +01:00
|
|
|
#include <render/GameRenderer.hpp>
|
2018-08-25 17:51:48 +02:00
|
|
|
#include <script/SCMFile.hpp>
|
2015-04-04 03:12:28 +01:00
|
|
|
#include <script/ScriptMachine.hpp>
|
2016-10-20 23:10:52 +01:00
|
|
|
#include <script/modules/GTA3Module.hpp>
|
2014-09-16 19:22:43 +01:00
|
|
|
|
2018-12-09 22:43:42 +01:00
|
|
|
#include <SDL_events.h>
|
|
|
|
|
2018-12-12 18:51:04 +01:00
|
|
|
#include <chrono>
|
2014-09-16 19:22:43 +01:00
|
|
|
|
2018-07-07 22:55:10 +02:00
|
|
|
class RWGame final : public GameBase {
|
2019-05-21 20:04:55 +01:00
|
|
|
public:
|
|
|
|
enum class DebugViewMode {
|
|
|
|
Disabled,
|
|
|
|
General,
|
|
|
|
Physics,
|
|
|
|
Navigation,
|
|
|
|
Objects
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
2016-10-16 20:37:07 +01:00
|
|
|
GameData data;
|
|
|
|
GameRenderer renderer;
|
2018-12-20 20:31:14 +01:00
|
|
|
RWImGui imgui;
|
2016-10-16 20:37:07 +01:00
|
|
|
DebugDraw debug;
|
2016-10-20 00:01:18 +01:00
|
|
|
GameState state;
|
2018-10-29 16:54:13 +01:00
|
|
|
HUDDrawer hudDrawer{};
|
2016-10-16 20:37:07 +01:00
|
|
|
|
2016-10-20 00:49:15 +01:00
|
|
|
std::unique_ptr<GameWorld> world;
|
2016-10-20 23:10:52 +01:00
|
|
|
|
|
|
|
GTA3Module opcodes;
|
|
|
|
std::unique_ptr<ScriptMachine> vm;
|
2018-08-25 17:51:48 +02:00
|
|
|
SCMFile script;
|
2016-10-20 23:10:52 +01:00
|
|
|
|
2018-12-18 22:43:49 +01:00
|
|
|
StateManager stateManager;
|
|
|
|
|
2016-09-09 21:13:20 +01:00
|
|
|
bool inFocus = true;
|
2016-11-29 23:28:53 +00:00
|
|
|
ViewCamera currentCam;
|
2016-10-12 00:29:24 +01:00
|
|
|
|
|
|
|
DebugViewMode debugview_ = DebugViewMode::Disabled;
|
2018-05-19 23:55:27 +02:00
|
|
|
int lastDraws{0}; /// Number of draws issued for the last frame.
|
2014-09-16 19:22:43 +01:00
|
|
|
|
2016-09-09 21:13:20 +01:00
|
|
|
std::string cheatInputWindow = std::string(32, ' ');
|
|
|
|
|
|
|
|
public:
|
2018-12-12 18:51:04 +01:00
|
|
|
RWGame(Logger& log, const std::optional<RWArgConfigLayer> &args);
|
2018-01-01 04:21:58 +01:00
|
|
|
~RWGame() override;
|
2016-09-09 21:13:20 +01:00
|
|
|
|
|
|
|
int run();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initalizes a new game
|
|
|
|
*/
|
|
|
|
void newGame();
|
|
|
|
|
2018-12-18 22:43:49 +01:00
|
|
|
StateManager& getStateManager() {
|
|
|
|
return stateManager;
|
|
|
|
}
|
|
|
|
|
2016-10-20 00:01:18 +01:00
|
|
|
GameState* getState() {
|
|
|
|
return &state;
|
2016-09-09 21:13:20 +01:00
|
|
|
}
|
|
|
|
|
2016-10-20 00:49:15 +01:00
|
|
|
GameWorld* getWorld() {
|
|
|
|
return world.get();
|
2016-09-09 21:13:20 +01:00
|
|
|
}
|
|
|
|
|
2016-10-16 20:37:07 +01:00
|
|
|
const GameData& getGameData() const {
|
2016-09-09 21:13:20 +01:00
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
2016-10-16 20:37:07 +01:00
|
|
|
GameRenderer& getRenderer() {
|
2016-09-09 21:13:20 +01:00
|
|
|
return renderer;
|
|
|
|
}
|
|
|
|
|
2018-05-21 13:13:09 +03:00
|
|
|
ScriptMachine* getScriptVM() const {
|
2016-10-20 23:10:52 +01:00
|
|
|
return vm.get();
|
2016-09-09 21:13:20 +01:00
|
|
|
}
|
|
|
|
|
2018-10-29 14:52:18 +01:00
|
|
|
HUDDrawer& getHUDDrawer() {
|
|
|
|
return hudDrawer;
|
|
|
|
}
|
|
|
|
|
2019-05-21 20:04:55 +01:00
|
|
|
DebugViewMode getDebugViewMode() const {
|
|
|
|
return debugview_;
|
|
|
|
}
|
|
|
|
|
2016-09-09 21:13:20 +01:00
|
|
|
bool hitWorldRay(glm::vec3& hit, glm::vec3& normal,
|
2018-12-09 22:43:42 +01:00
|
|
|
GameObject** object = nullptr);
|
2016-09-09 21:13:20 +01:00
|
|
|
|
|
|
|
bool hitWorldRay(const glm::vec3& start, const glm::vec3& direction,
|
|
|
|
glm::vec3& hit, glm::vec3& normal,
|
2018-12-09 22:43:42 +01:00
|
|
|
GameObject** object = nullptr);
|
2016-09-09 21:13:20 +01:00
|
|
|
|
|
|
|
void startScript(const std::string& name);
|
|
|
|
|
|
|
|
bool hasFocus() const {
|
|
|
|
return inFocus;
|
|
|
|
}
|
|
|
|
|
|
|
|
void saveGame(const std::string& savename);
|
|
|
|
void loadGame(const std::string& savename);
|
|
|
|
|
2014-09-16 19:22:43 +01:00
|
|
|
private:
|
2016-09-09 21:13:20 +01:00
|
|
|
void tick(float dt);
|
|
|
|
void render(float alpha, float dt);
|
|
|
|
|
2019-05-21 20:04:55 +01:00
|
|
|
void renderDebugPaths();
|
2014-09-16 19:22:43 +01:00
|
|
|
|
2016-09-09 21:13:20 +01:00
|
|
|
void handleCheatInput(char symbol);
|
2016-09-01 23:14:15 +02:00
|
|
|
|
2016-09-09 21:13:20 +01:00
|
|
|
void globalKeyEvent(const SDL_Event& event);
|
2018-08-28 19:35:49 +01:00
|
|
|
|
|
|
|
bool updateInput();
|
|
|
|
|
|
|
|
float tickWorld(const float deltaTime, float accumulatedTime);
|
|
|
|
|
2019-05-21 20:04:55 +01:00
|
|
|
void renderDebugView();
|
2018-08-31 20:01:50 +01:00
|
|
|
|
|
|
|
void tickObjects(float dt) const;
|
2014-09-16 19:22:43 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|