added missing changes.
This commit is contained in:
parent
b6f99e6498
commit
b5efac002e
4 changed files with 70 additions and 5 deletions
|
@ -76,6 +76,33 @@ namespace game {
|
|||
}
|
||||
}
|
||||
|
||||
void DeveloperCommand::apply(Player *player, State *state) const
|
||||
{
|
||||
if (!state->developerMode()) {
|
||||
std::cout<<"ignoring dev command while not in developer mode: '"
|
||||
<< m_payload << "'" << std::endl;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: give developer mode to game
|
||||
// TODO: forward to application in some way
|
||||
|
||||
std::cout << "got developer command: '" << m_payload << "'" << std::endl;
|
||||
|
||||
if (m_payload == "reload shader") {
|
||||
// TODO: really do that ;)
|
||||
} else if (m_payload == "reload models") {
|
||||
}
|
||||
}
|
||||
|
||||
void SetDeveloperModeCommand::apply(Player *player, State *state) const
|
||||
{
|
||||
// TODO: check if player is admin
|
||||
|
||||
state->setDeveloperMode(m_enable);
|
||||
}
|
||||
|
||||
#if 0
|
||||
bool TakeOverPlayerCommand::ready(const Player *player, const State *state) const
|
||||
{
|
||||
|
|
|
@ -79,7 +79,6 @@ namespace game {
|
|||
}
|
||||
|
||||
std::string name() const { return "<change name>"; }
|
||||
|
||||
void apply(Player *player, State *state) const;
|
||||
|
||||
private:
|
||||
|
@ -96,7 +95,6 @@ namespace game {
|
|||
}
|
||||
|
||||
std::string name() const { return "<clear traces>"; }
|
||||
|
||||
void apply(Player *player, State *state) const;
|
||||
};
|
||||
|
||||
|
@ -110,13 +108,40 @@ namespace game {
|
|||
}
|
||||
|
||||
std::string name() const { return "<set speed>"; }
|
||||
|
||||
void apply(Player *player, State *state) const;
|
||||
|
||||
private:
|
||||
float m_speed;
|
||||
};
|
||||
|
||||
/**
|
||||
* Developer command.
|
||||
*/
|
||||
class DeveloperCommand : public Command {
|
||||
public:
|
||||
DeveloperCommand(const std::string &payload) : m_payload(payload)
|
||||
{
|
||||
}
|
||||
|
||||
std::string name() const { return "<dev command>"; }
|
||||
void apply(Player *player, State *state) const;
|
||||
|
||||
private:
|
||||
std::string m_payload;
|
||||
};
|
||||
|
||||
class SetDeveloperModeCommand : public Command {
|
||||
public: SetDeveloperModeCommand(bool enable) : m_enable(enable)
|
||||
{
|
||||
}
|
||||
|
||||
std::string name() const { return "<set dev. mode>"; }
|
||||
void apply(Player *player, State *state) const;
|
||||
|
||||
private:
|
||||
bool m_enable;
|
||||
};
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* Take over a session for a player that left.
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "util.hpp"
|
||||
|
||||
namespace game {
|
||||
void State::init()
|
||||
void State::init(bool devMode)
|
||||
{
|
||||
m_nextId = 0;
|
||||
m_time = 0.0;
|
||||
|
@ -28,6 +28,7 @@ namespace game {
|
|||
m_playerRespawnTime = 2.0;
|
||||
m_defaultEnergy = 10.0;
|
||||
m_maxNumTraces = 10;
|
||||
m_developerMode = devMode;
|
||||
|
||||
bool planetsOnCircle = false;
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace game {
|
|||
|
||||
// called to setup the state (randomize planets, kill
|
||||
// traces/missiles/ships etc.)
|
||||
void init();
|
||||
void init(bool devMode=false);
|
||||
|
||||
// main method to advance the simulation by the given timestamp in
|
||||
// seconds.
|
||||
|
@ -80,6 +80,17 @@ namespace game {
|
|||
// get the current time
|
||||
float timestamp() const { return m_time; }
|
||||
|
||||
// check if game is in dev. mode.
|
||||
// custom commands will then work etc.
|
||||
bool developerMode() const { return m_developerMode; }
|
||||
|
||||
// change the mode.
|
||||
void setDeveloperMode(bool on)
|
||||
{
|
||||
std::cout<<"[state] developer mode is: " << (on ? "on" : "off") << std::endl;
|
||||
m_developerMode = on;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
/* Rendering */
|
||||
/*************************************************************************/
|
||||
|
@ -122,5 +133,6 @@ namespace game {
|
|||
int m_nextId;
|
||||
int m_maxNumTraces;
|
||||
float m_time;
|
||||
bool m_developerMode;
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue