Command additions and minor fixes

This commit is contained in:
2025-03-31 16:38:12 -04:00
parent e748bf95ae
commit b10d1e30dc
2 changed files with 39 additions and 14 deletions

View File

@@ -180,7 +180,6 @@ namespace CaveGame::ClientApp {
{"give", {"q"}, [this](const CommandArgs& args) {}},
{"tp", {"q"}, [this](const CommandArgs& args) {}},
{"freecam", {"q"}, [this](const CommandArgs& args) {}},
{"noclip", {"q"}, [this](const CommandArgs& args) {}},
{"god", {"q"}, [this](const CommandArgs& args) {}},
{"fullbright", {"q"}, [this](const CommandArgs& args) {}},
{"connect", {"q"}, [this](const CommandArgs& args) {}},
@@ -190,14 +189,7 @@ namespace CaveGame::ClientApp {
{"crash", {"q"}, [this](const CommandArgs& args) {}},
{"time", {"q"}, [this](const CommandArgs& args) {}},
{"juidebug", {"q"}, [this](const CommandArgs& args) {}},
{"fpslimit", {"fps"}, [this](const CommandArgs& args) {
if (args.size() < 2)
return Log(std::format("Current FPS Limit: {}fps", max_fps));
int val = stoi(args[1]);
std::cout << val << std::endl;
max_fps = val;
}},
{"fpslimit", {"fps"}, [this](const CommandArgs& args) { return FpsLimitCmd(args); }},
{"grid", {}, [this](const CommandArgs& args) {
if (current_scene == game_ctx)
{
@@ -227,8 +219,8 @@ namespace CaveGame::ClientApp {
GameSession()->HUD()->Add(new ContainerWindow(GameSession()->HUD(), w, h, "Test Container"));
}
}}
}},
{"noclip", {}, [this](const CommandArgs& args) { return NoclipCmd(args); }}
};
Command InvalidCommand {
@@ -238,6 +230,8 @@ namespace CaveGame::ClientApp {
};
#pragma endregion
protected: // Complex class members.
Client::AssetService assets;
CaveGame::Client::Splash* splash_ctx = nullptr;
@@ -259,5 +253,9 @@ namespace CaveGame::ClientApp {
float max_fps = 60.f;
void OpenWorld(Client::SingleplayerSessionInfo info);
bool NoclipCmd(const CommandArgs &args);
bool FpsLimitCmd(const CommandArgs &args);
};
}

View File

@@ -577,11 +577,14 @@ namespace CaveGame::ClientApp {
void CaveGameWindow::MarkReadyToClose(bool close) { wanna_die = close;}
bool CaveGameWindow::TileListCmd(const CommandArgs &args) {
auto tile_list = Core::Tiles().GetTileList();
// TODO: Tile iterator that returns vector of **valid** tiles.
const auto& tile_list = Core::Tiles().GetTileArray();
for (const Core::Tile& tile : tile_list) {
if (tile.numeric_id == 0 && tile.mnemonic_id != "air")
continue; // Empty tile?
Log(std::format("ID: {}, Mnemonic: {}, DisplayName: {}", tile.numeric_id, tile.mnemonic_id, tile.display_name));
//if (tile != nullptr)
}
@@ -591,7 +594,7 @@ namespace CaveGame::ClientApp {
bool CaveGameWindow::ItemListCmd(const CommandArgs &args) {
auto item_list = Items().GetItemMap();
for (auto [name, item] : item_list) {
for (const auto& [name, item] : item_list) {
//if (item != nullptr)
Log(std::format("Mnemonic: {}", name));
}
@@ -599,6 +602,30 @@ namespace CaveGame::ClientApp {
return true;
}
bool CaveGameWindow::NoclipCmd(const CommandArgs& args) {
Log("Bet");
if (InGame()) {
auto plr = GameSession()->GetLocalPlayerEntity();
if (plr != nullptr)
plr->SetNoclip(!plr->IsNoclip());
}
return true;
}
bool CaveGameWindow::FpsLimitCmd(const CommandArgs& args) {
if (args.size() < 2) {
Log(std::format("Current FPS Limit: {}fps", max_fps));
return true;
}
int val = stoi(args[1]);
std::cout << val << std::endl;
max_fps = val;
return true;
}
}