1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-25 11:52:40 +01:00
openrw/rwgame/State.hpp
Daniel Evans ddb62ed3cd Rewrite of camera and character look code
Make states responsible for interpolating camera transformation
Apply look direction to character orientation
2016-12-04 01:06:27 +00:00

76 lines
1.4 KiB
C++

#ifndef RWGAME_STATE_HPP
#define RWGAME_STATE_HPP
#include <render/ViewCamera.hpp>
#include "GameWindow.hpp"
#include "MenuSystem.hpp"
#include "SDL.h"
#include "SDL_events.h"
class RWGame;
class GameWorld;
class StateManager;
class State {
public:
std::shared_ptr<Menu> menu;
std::shared_ptr<Menu> nextMenu;
RWGame* game;
State(RWGame* game) : game(game) {
}
virtual void enter() = 0;
virtual void exit() = 0;
virtual void tick(float dt) = 0;
virtual void draw(GameRenderer* r) {
if (getCurrentMenu()) {
getCurrentMenu()->draw(r);
}
}
virtual ~State() {
}
void enterMenu(const std::shared_ptr<Menu>& menu) {
nextMenu = menu;
}
Menu* getCurrentMenu() {
if (nextMenu) {
menu = nextMenu;
nextMenu = nullptr;
}
return menu.get();
}
virtual void handleEvent(const SDL_Event& e);
virtual const ViewCamera& getCamera(float alpha);
/**
* Returns false if the game world should not should
* not update while this state is active
*/
virtual bool shouldWorldUpdate();
GameWorld* getWorld() const;
GameWindow& getWindow();
bool hasExited() const {
return hasexited_;
}
private:
bool hasexited_ = false;
protected:
void done() {
hasexited_ = true;
}
};
#endif