Manager.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * Copyright (C) 2022 The V-Gears Team
  3. *
  4. * This file is part of V-Gears
  5. *
  6. * V-Gears is free software: you can redistribute it and/or modify it under
  7. * terms of the GNU General Public License as published by the Free Software
  8. * Foundation, version 3.0 (GPLv3) of the License.
  9. *
  10. * V-Gears is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #include <iostream>
  16. #include <OgreRoot.h>
  17. #include "Manager.h"
  18. #include "common/Logger.h"
  19. Manager::Manager(): module_(Module::FIELD), prev_module_(Module::FIELD), paused_(false){}
  20. Manager::~Manager(){}
  21. Manager::Module Manager::GetModule() const{return module_;}
  22. bool Manager::IsFieldModule() const{return (module_ == Module::FIELD);}
  23. bool Manager::IsBattleModule() const{return (module_ == Module::BATTLE);}
  24. bool Manager::IsWorldModule() const{return (module_ == Module::WORLD);}
  25. void Manager::SetModule(const Module module){
  26. if (module == Module::FIELD){
  27. ClearBattle();
  28. ClearWorld();
  29. }
  30. else if (module == Module::WORLD){
  31. ClearBattle();
  32. ClearField();
  33. }
  34. else if (module == Module::BATTLE){
  35. prev_module_ = module_;
  36. }
  37. module_ = module;
  38. }
  39. void Manager::SetFieldModule(){SetModule(Module::FIELD);}
  40. void Manager::SetBattleModule(){SetModule(Module::BATTLE);}
  41. void Manager::SetWorldModule(){SetModule(Module::WORLD);}
  42. void Manager::SetPreviousModule(){
  43. if (module_ != Module::BATTLE){
  44. LOG_WARNING(
  45. std::string("Called Manager::SetPreviousModule without battle module active. ")
  46. + "Doing nothing. Current module is " + std::to_string(module_)
  47. );
  48. return;
  49. }
  50. if (prev_module_ == Module::BATTLE){
  51. LOG_WARNING(
  52. "Called Manager::SetPreviousModule but there is no previous module. Doing nothing."
  53. );
  54. return;
  55. }
  56. module_ = prev_module_;
  57. }
  58. void Manager::Update(){
  59. UpdateDebug();
  60. if (paused_ == true) return;
  61. Update(module_);
  62. }
  63. void Manager::Update(const Module module){
  64. switch (module){
  65. case Module::FIELD:
  66. UpdateField();
  67. break;
  68. case Module::BATTLE:
  69. UpdateBattle();
  70. break;
  71. case Module::WORLD:
  72. UpdateWorld();
  73. break;
  74. }
  75. }
  76. void Manager::Clear(){Clear(module_);}
  77. void Manager::Clear(const Module module){
  78. switch (module){
  79. case Module::FIELD:
  80. ClearField();
  81. break;
  82. case Module::BATTLE:
  83. ClearBattle();
  84. break;
  85. case Module::WORLD:
  86. ClearWorld();
  87. break;
  88. }
  89. }
  90. void Manager::ScriptSetPaused(const bool paused){paused_ = paused;}