11#include " ../../Client/Module.hpp"
2- #include < Geode/modify/GJBaseGameLayer.hpp>
2+ #include < Geode/modify/PlayerObject.hpp>
3+ #include < VisitHook.hpp>
34
45using namespace geode ::prelude;
56
@@ -125,62 +126,87 @@ SUBMIT_OPTION(NoPlayerRotation, NoRotRobot);
125126SUBMIT_OPTION (NoPlayerRotation, NoRotSpider);
126127SUBMIT_OPTION (NoPlayerRotation, NoRotSwing);
127128
128- class $modify (GJBaseGameLayer)
129+ namespace qolmod
129130{
130- bool noRotateEnabled (PlayerObject* po)
131+ class PlayerObjectVisitHook : public qolmod ::VisitHook
131132 {
132- if (po->m_isShip )
133- {
134- if (po->m_isPlatformer )
135- return NoRotJetpack::get ()->getRealEnabled ();
136- else
137- return NoRotShip::get ()->getRealEnabled ();
138- }
139- else if (po->m_isBall )
140- {
141- return NoRotBall::get ()->getRealEnabled ();
142- }
143- else if (po->m_isBird )
144- {
145- return NoRotUfo::get ()->getRealEnabled ();
146- }
147- else if (po->m_isDart )
148- {
149- return NoRotWave::get ()->getRealEnabled ();
150- }
151- else if (po->m_isRobot )
152- {
153- return NoRotRobot::get ()->getRealEnabled ();
154- }
155- else if (po->m_isSpider )
156- {
157- return NoRotSpider::get ()->getRealEnabled ();
158- }
159- else if (po->m_isSwing )
160- {
161- return NoRotSwing::get ()->getRealEnabled ();
162- }
133+ public:
134+ CREATE_FUNC (PlayerObjectVisitHook)
135+ PlayerObject* player = nullptr ;
136+ float rot = 0 ;
137+ float rot2 = 0 ;
163138
164- return NoRotCube::get ()->getRealEnabled ();
165- }
166-
167- virtual void update (float dt)
168- {
169- GJBaseGameLayer::update (dt);
139+ bool noRotateEnabled (PlayerObject* po)
140+ {
141+ if (!NoPlayerRotation::get ()->getRealEnabled ())
142+ return false ;
143+
144+ if (po->m_isShip )
145+ {
146+ if (po->m_isPlatformer )
147+ return NoRotJetpack::get ()->getRealEnabled ();
148+ else
149+ return NoRotShip::get ()->getRealEnabled ();
150+ }
151+ else if (po->m_isBall )
152+ {
153+ return NoRotBall::get ()->getRealEnabled ();
154+ }
155+ else if (po->m_isBird )
156+ {
157+ return NoRotUfo::get ()->getRealEnabled ();
158+ }
159+ else if (po->m_isDart )
160+ {
161+ return NoRotWave::get ()->getRealEnabled ();
162+ }
163+ else if (po->m_isRobot )
164+ {
165+ return NoRotRobot::get ()->getRealEnabled ();
166+ }
167+ else if (po->m_isSpider )
168+ {
169+ return NoRotSpider::get ()->getRealEnabled ();
170+ }
171+ else if (po->m_isSwing )
172+ {
173+ return NoRotSwing::get ()->getRealEnabled ();
174+ }
175+
176+ return NoRotCube::get ()->getRealEnabled ();
177+ }
170178
171- if (NoPlayerRotation::get ()->getRealEnabled ())
172- {
173- if (m_player1 && noRotateEnabled (m_player1))
179+ virtual void preVisit ()
174180 {
175- m_player1->setRotation (0 );
176- m_player1->m_iconSprite ->setRotation (0 );
181+ rot = player->getRotation ();
182+ rot2 = player->m_iconSprite ->getRotation ();
183+
184+ if (noRotateEnabled (player))
185+ {
186+ player->setRotation (0 );
187+ player->m_iconSprite ->setRotation (0 );
188+ }
177189 }
178190
179- if (m_player2 && noRotateEnabled (m_player1) )
191+ virtual void postVisit (cocos2d::CCNode* node )
180192 {
181- m_player2 ->setRotation (0 );
182- m_player2 ->m_iconSprite ->setRotation (0 );
193+ player ->setRotation (rot );
194+ player ->m_iconSprite ->setRotation (rot2 );
183195 }
184- }
196+ };
197+ };
198+
199+ class $modify (PlayerObject)
200+ {
201+ bool init (int player, int ship, GJBaseGameLayer* gameLayer, cocos2d::CCLayer* layer, bool playLayer)
202+ {
203+ if (!PlayerObject::init (player, ship, gameLayer, layer, playLayer))
204+ return false ;
205+
206+ auto vh = qolmod::PlayerObjectVisitHook::create ();
207+ vh->player = this ;
208+
209+ this ->setGrid (vh);
210+ return true ;
185211 }
186212};
0 commit comments