From 6ead37804ba2aacbfdd5e590159987caab850290 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Wed, 6 Feb 2019 17:26:53 -0800 Subject: [PATCH] Add ability to remove items (WIP) --- Runtime/MP1/MP1.cpp | 18 ++++++++++++++++++ Runtime/MP1/MP1.hpp | 1 + 2 files changed, 19 insertions(+) diff --git a/Runtime/MP1/MP1.cpp b/Runtime/MP1/MP1.cpp index 185581c3c..c996e3a60 100644 --- a/Runtime/MP1/MP1.cpp +++ b/Runtime/MP1/MP1.cpp @@ -438,6 +438,21 @@ void CMain::Give(hecl::Console* console, const std::vector& args) { console->report(hecl::Console::Level::Info, "Cheater....., Greatly increasing Metroid encounters, have fun!"); } +void CMain::Remove(hecl::Console*, const std::vector& args) { + if (args.size() < 1 || (!g_GameState || !g_GameState->GetPlayerState())) + return; + + std::string type = args[0]; + athena::utility::tolower(type); + std::shared_ptr pState = g_GameState->GetPlayerState(); + CPlayerState::EItemType eType = CPlayerState::ItemNameToType(type); + if (eType != CPlayerState::EItemType::Invalid) { + pState->ReInitalizePowerUp(eType, 0); + if (g_StateManager) + g_StateManager->Player()->AsyncLoadSuit(*g_StateManager); + } +} + void CMain::God(hecl::Console* con, const std::vector&) { if (g_GameState && g_GameState->GetPlayerState()) { g_GameState->GetPlayerState()->SetCanTakeDamage(!g_GameState->GetPlayerState()->CanTakeDamage()); @@ -631,6 +646,9 @@ void CMain::Init(const hecl::Runtime::FileStoreManager& storeMgr, hecl::CVarMana m_console->registerCommand("Give"sv, "Gives the player the specified item, maxing it out"sv, ""sv, std::bind(&CMain::Give, this, std::placeholders::_1, std::placeholders::_2), hecl::SConsoleCommand::ECommandFlags::Cheat); + m_console->registerCommand("Remove"sv, "Removes the specified item from the player"sv, ""sv, + std::bind(&CMain::Remove, this, std::placeholders::_1, std::placeholders::_2), + hecl::SConsoleCommand::ECommandFlags::Cheat); m_console->registerCommand( "Teleport"sv, "Teleports the player to the specified coordinates in worldspace"sv, "x y z [dX dY dZ]"sv, std::bind(&CMain::Teleport, this, std::placeholders::_1, std::placeholders::_2), diff --git a/Runtime/MP1/MP1.hpp b/Runtime/MP1/MP1.hpp index f23b0006b..1cb1dc14d 100644 --- a/Runtime/MP1/MP1.hpp +++ b/Runtime/MP1/MP1.hpp @@ -303,6 +303,7 @@ public: size_t GetExpectedIdSize() const { return sizeof(u32); } void quit(hecl::Console*, const std::vector&) { m_doQuit = true; } void Give(hecl::Console*, const std::vector&); + void Remove(hecl::Console*, const std::vector&); void God(hecl::Console*, const std::vector&); void Teleport(hecl::Console*, const std::vector&); void ListWorlds(hecl::Console*, const std::vector&);