Open Source Tomb Raider Engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CommandMove.cpp 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*!
  2. * \file src/commands/CommandMove.cpp
  3. * \brief Move command
  4. *
  5. * \author xythobuz
  6. */
  7. #include "global.h"
  8. #include "Game.h"
  9. #include "Log.h"
  10. #include "RunTime.h"
  11. #include "commands/CommandMove.h"
  12. std::string CommandMove::name() {
  13. return "move";
  14. }
  15. std::string CommandMove::brief() {
  16. return "[walk|fly|noclip]";
  17. }
  18. void CommandMove::printHelp() {
  19. Log::get(LOG_USER) << "move-Command Usage:" << Log::endl;
  20. Log::get(LOG_USER) << " move COMMAND" << Log::endl;
  21. Log::get(LOG_USER) << "Where COMMAND is one of the following:" << Log::endl;
  22. Log::get(LOG_USER) << " walk" << Log::endl;
  23. Log::get(LOG_USER) << " fly" << Log::endl;
  24. Log::get(LOG_USER) << " noclip" << Log::endl;
  25. }
  26. int CommandMove::execute(std::istream& args) {
  27. if ((!RunTime::isRunning()) || (!Game::isLoaded())) {
  28. Log::get(LOG_USER) << "Use move command interactively!" << Log::endl;
  29. return -1;
  30. }
  31. std::string s;
  32. args >> s;
  33. if (s.compare("walk") == 0) {
  34. Game::getLara().setMoveType(Entity::MoveTypeWalk);
  35. } else if (s.compare("fly") == 0) {
  36. Game::getLara().setMoveType(Entity::MoveTypeFly);
  37. } else if (s.compare("noclip") == 0) {
  38. Game::getLara().setMoveType(Entity::MoveTypeNoClipping);
  39. } else {
  40. Log::get(LOG_USER) << "Invalid use of move command (" << s << ")!" << Log::endl;
  41. return -2;
  42. }
  43. Log::get(LOG_USER) << s << "ing" << Log::endl;
  44. return 0;
  45. }