OatmealDome

MultiMarioCameraInput a685e721

Mar 3rd, 2022
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.81 KB | None | 0 0
  1. // ICameraInput.h
  2.  
  3. #pragma once
  4.  
  5. #include "sead/math/seadVector.h"
  6.  
  7. namespace al
  8. {
  9. class ICameraInput
  10. {
  11. public:
  12. virtual void calcInputStick(sead::Vector2f* out) const
  13. {
  14. out->x = 0.0f;
  15. out->y = 0.0f;
  16. }
  17. virtual bool isTriggerReset() const { return false; }
  18. virtual bool isHoldZoom() const { return false; }
  19. virtual bool tryCalcSnapShotMoveStick(sead::Vector2f*) const { return false; }
  20. virtual bool isHoldSnapShotZoomIn() const { return false; }
  21. virtual bool isHoldSnapShotZoomOut() const { return false; }
  22. virtual bool isHoldSnapShotRollLeft() const { return false; }
  23. virtual bool isHoldSnapShotRollRight() const { return false; }
  24. virtual void calcGyroPose(sead::Vector3f* one, sead::Vector3f* two, sead::Vector3f* three) const
  25. {
  26. // Better way to do this?
  27. one->x = 0.0f;
  28. one->y = 0.0f;
  29. one->z = 0.0f;
  30. two->x = 0.0f;
  31. two->y = 0.0f;
  32. two->z = 0.0f;
  33. three->x = 0.0f;
  34. three->y = 0.0f;
  35. three->z = 0.0f;
  36. }
  37. };
  38. }
  39.  
  40. // MultiMarioCameraInput.h
  41.  
  42. #pragma once
  43.  
  44. #include "al/camera/ICameraInput.h"
  45.  
  46. namespace rsm
  47. {
  48. namespace mechanic
  49. {
  50. namespace camera
  51. {
  52. class MultiMarioCameraInput : public al::ICameraInput
  53. {
  54. public:
  55. MultiMarioCameraInput();
  56.  
  57. virtual void calcInputStick(sead::Vector2f*) const;
  58. virtual bool isTriggerReset() const;
  59. virtual bool isHoldZoom() const;
  60. virtual bool tryCalcSnapShotMoveStick(sead::Vector2f*) const;
  61. virtual bool isHoldSnapShotZoomIn() const;
  62. virtual bool isHoldSnapShotZoomOut() const;
  63. virtual bool isHoldSnapShotRollLeft() const;
  64. virtual bool isHoldSnapShotRollRight() const;
  65. virtual void calcGyroPose(sead::Vector3f*, sead::Vector3f*, sead::Vector3f*) const;
  66.  
  67. void setPassthroughInput(al::ICameraInput*);
  68.  
  69. protected:
  70. al::ICameraInput* passthroughInput;
  71. };
  72. }
  73. }
  74. }
  75.  
  76. // MultiMarioCamera.cpp
  77.  
  78. #include "rsm/mechanic/camera/MultiMarioCameraInput.hpp"
  79.  
  80. #include "al/util.hpp"
  81.  
  82. #include "game/Player/PlayerFunction.h"
  83.  
  84. #include "rsm/manager/PlayerManager.hpp"
  85.  
  86. rsm::mechanic::camera::MultiMarioCameraInput::MultiMarioCameraInput()
  87. {
  88. passthroughInput = nullptr;
  89. }
  90.  
  91. void rsm::mechanic::camera::MultiMarioCameraInput::calcInputStick(sead::Vector2f* out) const
  92. {
  93. sead::Vector2f sticks;
  94. int stickCount = 0;
  95.  
  96. sticks.x = 0.0f;
  97. sticks.y = 0.0f;
  98.  
  99. rsm::manager::PlayerManager* manager = rsm::manager::PlayerManager::instance();
  100.  
  101. for (int i = 0; i < manager->getPlayerNum(); i++)
  102. {
  103. PlayerActorBase* player = manager->getPlayer(i);
  104. int port = PlayerFunction::getPlayerInputPort(player);
  105.  
  106. sead::Vector2f* playerStick = al::getRightStick(port);
  107. if (!al::isNearZero(*playerStick, 0.001f))
  108. {
  109. sticks += *playerStick;
  110. stickCount++;
  111. }
  112. }
  113.  
  114. if (stickCount > 0)
  115. {
  116. out->x = sticks.x / (float)stickCount;
  117. out->y = sticks.y / (float)stickCount;
  118. }
  119. else
  120. {
  121. out->x = 0.0f;
  122. out->y = 0.0f;
  123. }
  124. }
  125.  
  126. bool rsm::mechanic::camera::MultiMarioCameraInput::isTriggerReset() const
  127. {
  128. // This might interfere with the bubble.
  129. // TODO: Implementation that doesn't.
  130. return false;
  131. }
  132.  
  133. bool rsm::mechanic::camera::MultiMarioCameraInput::isHoldZoom() const
  134. {
  135. return passthroughInput->isHoldZoom();
  136. }
  137.  
  138. bool rsm::mechanic::camera::MultiMarioCameraInput::tryCalcSnapShotMoveStick(sead::Vector2f* out) const
  139. {
  140. return passthroughInput->tryCalcSnapShotMoveStick(out);
  141. }
  142.  
  143. bool rsm::mechanic::camera::MultiMarioCameraInput::isHoldSnapShotZoomIn() const
  144. {
  145. return passthroughInput->isHoldSnapShotZoomIn();
  146. }
  147.  
  148. bool rsm::mechanic::camera::MultiMarioCameraInput::isHoldSnapShotZoomOut() const
  149. {
  150. return passthroughInput->isHoldSnapShotZoomOut();
  151. }
  152.  
  153. bool rsm::mechanic::camera::MultiMarioCameraInput::isHoldSnapShotRollLeft() const
  154. {
  155. return passthroughInput->isHoldSnapShotRollLeft();
  156. }
  157.  
  158. bool rsm::mechanic::camera::MultiMarioCameraInput::isHoldSnapShotRollRight() const
  159. {
  160. return passthroughInput->isHoldSnapShotRollRight();
  161. }
  162.  
  163. void rsm::mechanic::camera::MultiMarioCameraInput::calcGyroPose(sead::Vector3f* one, sead::Vector3f* two, sead::Vector3f* three) const
  164. {
  165. passthroughInput->calcGyroPose(one, two, three);
  166. }
  167.  
  168. void rsm::mechanic::camera::MultiMarioCameraInput::setPassthroughInput(ICameraInput* input)
  169. {
  170. passthroughInput = input;
  171. }
  172.  
Advertisement
Add Comment
Please, Sign In to add comment