Open Source Tomb Raider Engine
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

CommandGame.cpp 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*!
  2. * \file src/commands/CommandGame.cpp
  3. * \brief Game meta-commands
  4. *
  5. * \author xythobuz
  6. */
  7. #include "global.h"
  8. #include "Console.h"
  9. #include "Game.h"
  10. #include "OpenRaider.h"
  11. #include "World.h"
  12. #include "commands/CommandGame.h"
  13. std::string CommandPos::name() {
  14. return "pos";
  15. }
  16. std::string CommandPos::brief() {
  17. return "Print position info";
  18. }
  19. int CommandPos::execute(std::istream& args) {
  20. if ((!getOpenRaider().mRunning) || (!getGame().isLoaded())) {
  21. getConsole() << "Use pos command interactively!" << Console::endl;
  22. return -1;
  23. }
  24. getGame().getLara().print();
  25. return 0;
  26. }
  27. // --------------------------------------
  28. std::string CommandViewmodel::name() {
  29. return "viewmodel";
  30. }
  31. std::string CommandViewmodel::brief() {
  32. return "INT - Change Laras model";
  33. }
  34. int CommandViewmodel::execute(std::istream& args) {
  35. if ((!getOpenRaider().mRunning) || (!getGame().isLoaded())) {
  36. getConsole() << "Use viewmodel command interactively!" << Console::endl;
  37. return -1;
  38. }
  39. //! \fixme Validate input
  40. std::string s;
  41. args >> s;
  42. unsigned int n = atoi(s.c_str());
  43. if (n < getWorld().sizeSkeletalModel()) {
  44. getGame().getLara().setSkeletalModel(n);
  45. return 0;
  46. } else {
  47. getConsole() << "Invalid SkeletalModel index!" << Console::endl;
  48. return -2;
  49. }
  50. }
  51. // --------------------------------------
  52. std::string CommandPigtail::name() {
  53. return "pigtail";
  54. }
  55. std::string CommandPigtail::brief() {
  56. return "BOOL";
  57. }
  58. int CommandPigtail::execute(std::istream& args) {
  59. if ((!getOpenRaider().mRunning) || (!getGame().isLoaded())) {
  60. getConsole() << "Use pigtail command interactively!" << Console::endl;
  61. return -1;
  62. }
  63. bool b;
  64. args >> b;
  65. if (!args) {
  66. getConsole() << "Pass BOOL to pigtail command!" << Console::endl;
  67. return -2;
  68. }
  69. getGame().getLara().getModel().setPigTail(b);
  70. getConsole() << "Pigtail is now " << (b ? "on" : "off") << Console::endl;
  71. return 0;
  72. }
  73. // --------------------------------------
  74. std::string CommandPonypos::name() {
  75. return "ponypos";
  76. }
  77. std::string CommandPonypos::brief() {
  78. return "FLOAT FLOAT FLOAT FLOAT - x y z angle";
  79. }
  80. int CommandPonypos::execute(std::istream& args) {
  81. if ((!getOpenRaider().mRunning) || (!getGame().isLoaded())) {
  82. getConsole() << "Use ponypos command interactively!" << Console::endl;
  83. return -1;
  84. }
  85. float a, b, c, d;
  86. args >> a >> b >> c >> d;
  87. if (!args) {
  88. getConsole() << "Pass four FLOATs to ponypos command!" << Console::endl;
  89. return -2;
  90. }
  91. getGame().getLara().getModel().setPonyPos(a, b, c, d);
  92. return 0;
  93. }