Open Source Tomb Raider Engine
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*!
  2. * \file src/commands/CommandGame.cpp
  3. * \brief Game meta-commands
  4. *
  5. * \author xythobuz
  6. */
  7. #include "global.h"
  8. #include "Game.h"
  9. #include "Log.h"
  10. #include "RunTime.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 ((!getRunTime().isRunning()) || (!getGame().isLoaded())) {
  21. getLog() << "Use pos command interactively!" << Log::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 ((!getRunTime().isRunning()) || (!getGame().isLoaded())) {
  36. getLog() << "Use viewmodel command interactively!" << Log::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. getLog() << "Invalid SkeletalModel index!" << Log::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 ((!getRunTime().isRunning()) || (!getGame().isLoaded())) {
  60. getLog() << "Use pigtail command interactively!" << Log::endl;
  61. return -1;
  62. }
  63. bool b;
  64. args >> b;
  65. if (!args) {
  66. getLog() << "Pass BOOL to pigtail command!" << Log::endl;
  67. return -2;
  68. }
  69. getGame().getLara().getModel().setPigTail(b);
  70. getLog() << "Pigtail is now " << (b ? "on" : "off") << Log::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 ((!getRunTime().isRunning()) || (!getGame().isLoaded())) {
  82. getLog() << "Use ponypos command interactively!" << Log::endl;
  83. return -1;
  84. }
  85. float a, b, c, d;
  86. args >> a >> b >> c >> d;
  87. if (!args) {
  88. getLog() << "Pass four FLOATs to ponypos command!" << Log::endl;
  89. return -2;
  90. }
  91. getGame().getLara().getModel().setPonyPos(a, b, c, d);
  92. return 0;
  93. }