// BlockyFroggy
// Copyright © 2017 John Ryland.
// All rights reserved.
#pragma once
#ifndef BASE_GAME_STATE_H
#define BASE_GAME_STATE_H
#include <functional>
class GameGraphics;
namespace GameUi
{
class DrawItems;
class UpdateState;
} // namespace GameUi
enum TouchState { TouchUp, TouchDown, TouchMove };
class BaseGameState
{
public:
BaseGameState() {}
virtual ~BaseGameState() {}
virtual const char* getName() const { return "BaseGameState"; }
virtual void enter(GameGraphics&) {}
virtual void exit(GameGraphics&) {}
virtual void draw(GameGraphics&) {}
virtual float getTime() { return 0.0f; }
virtual void getPlayerPos(float pos[3]) { pos[0] = pos[1] = pos[2] = 0.0f; } // temp func - replace with getting camera
virtual void getCameras(float cameraParams[8], float lightParams[8], float debugCameraParams[8], float /*a_elapsed*/) { for (int i = 0; i < 8; i++) { cameraParams[i] = lightParams[i] = debugCameraParams[i] = 0.0f; } }
virtual bool update(GameUi::UpdateState& /*items*/, float /*elapsed*/) { return false; }
//virtual void UpdateVariables(std::map<std::string,std::string>& /*variables*/) {}
virtual bool touchesChanged(int /*x*/, int /*y*/, TouchState /*ts*/) { return false; }
virtual void getScriptCallableFunctions(const struct luaL_Reg* &, int &count) { count = 0; }
};
#include "Common.h"
//! @todo return shared_ptr instead of raw pointer
typedef BaseGameState* (*GameStateFactory)();
using GameStateFactoryItem = GenericFactoryItem<GameStateFactory>;
// This can go in the header or cpp file, doesn't matter
#define REGISTER_GAME_STATE(gameStateName) \
namespace details { \
static BaseGameState* createGameState_##gameStateName() { return new gameStateName; } \
GameStateFactoryItem g_register_##gameStateName(#gameStateName, createGameState_##gameStateName); \
}
// For debugging
void ListGameStates();
#endif // BASE_GAME_STATE_H