-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added cheat console (desktop only) (#147)
- Loading branch information
Showing
47 changed files
with
1,250 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#pragma once | ||
|
||
#include <functional> | ||
|
||
struct ImguiComponent | ||
{ | ||
std::function<void()> render_callback; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#pragma once | ||
|
||
#include <vector> | ||
#include <string> | ||
#include <functional> | ||
#include <map> | ||
|
||
#include "other/ItemType.hpp" | ||
#include "other/NpcType.hpp" | ||
#include "game-loop/GameLoopState.hpp" | ||
#include "LootType.hpp" | ||
|
||
class CheatConsoleInterpreter | ||
{ | ||
public: | ||
using Command = std::vector<std::string>; | ||
using CommandHandlerResult = std::pair<bool, std::string>; | ||
using CommandHandler = std::function<CommandHandlerResult(const Command&)>; | ||
CheatConsoleInterpreter(); | ||
|
||
const CommandHandler& get_spawn_command_handler() const; | ||
const CommandHandler& get_enter_command_handler() const; | ||
private: | ||
std::map<std::string, ItemType> _string_to_item_type_map; | ||
std::map<std::string, NpcType> _string_to_npc_type_map; | ||
std::map<std::string, LootType> _string_to_loot_type_map; | ||
std::map<std::string, GameLoopState> _string_to_game_loop_state_map; | ||
|
||
CommandHandler _spawn_command_handler; | ||
CommandHandler _enter_command_handler; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#pragma once | ||
|
||
#include "other/ItemType.hpp" | ||
#include <entt/entt.hpp> | ||
|
||
class ItemFactory { | ||
public: | ||
static entt::entity make(ItemType); | ||
static entt::entity make(ItemType, float pos_x, float pos_y); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#pragma once | ||
|
||
#include <entt/entt.hpp> | ||
#include "LootType.hpp" | ||
|
||
class LootFactory { | ||
public: | ||
static entt::entity make(LootType); | ||
static entt::entity make(LootType, float pos_x, float pos_y); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#pragma once | ||
|
||
#include "other/NpcType.hpp" | ||
#include <entt/entt.hpp> | ||
|
||
class NpcFactory { | ||
public: | ||
static entt::entity make(NpcType); | ||
static entt::entity make(NpcType, float pos_x, float pos_y); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#pragma once | ||
|
||
#include "entt/entt.hpp" | ||
#include "viewport/Viewport.hpp" | ||
#include "game-loop/GameLoop.hpp" | ||
|
||
#include <vector> | ||
#include <functional> | ||
|
||
namespace prefabs | ||
{ | ||
class CheatConsoleComponent | ||
{ | ||
public: | ||
bool is_state_change_requested() const { return _state_change_requested; } | ||
void request_state_change(GameLoopState requested_state) { _requested_state = requested_state; _state_change_requested = true; } | ||
GameLoopState get_requested_state() const { return _requested_state;} | ||
private: | ||
bool _state_change_requested = false; | ||
GameLoopState _requested_state{GameLoopState::CURRENT}; | ||
}; | ||
|
||
struct CheatConsole | ||
{ | ||
static entt::entity create(const std::shared_ptr<Viewport>& viewport); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/game-loop/interface/game-loop/GameLoopSandboxState.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
|
||
#include <memory> | ||
#include <entt/entt.hpp> | ||
#include "game-loop/GameLoopBaseState.hpp" | ||
|
||
class GameLoop; | ||
class PauseOverlayComponent; | ||
class ScoresOverlayComponent; | ||
|
||
class GameLoopSandboxState : public GameLoopBaseState | ||
{ | ||
public: | ||
GameLoopBaseState* update(GameLoop&, uint32_t delta_time_ms) override; | ||
void enter(GameLoop&) override; | ||
void exit(GameLoop&) override; | ||
private: | ||
entt::entity _main_dude = entt::null; | ||
entt::entity _pause_overlay = entt::null; | ||
entt::entity _death_overlay = entt::null; | ||
entt::entity _cheat_console = entt::null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#pragma once | ||
|
||
#include <cstdint> | ||
|
||
using GameLoopState_t = std::uint16_t; | ||
enum class GameLoopState : GameLoopState_t | ||
{ | ||
MAIN_MENU = 0, | ||
PLAYING, | ||
STARTED, | ||
LEVEL_SUMMARY, | ||
SCORES, | ||
SANDBOX, | ||
CURRENT, | ||
_SIZE | ||
}; | ||
|
||
const char* to_string(GameLoopState); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.