SMG-Decomp
A decompilation of Super Mario Galaxy 1
Loading...
Searching...
No Matches
Spine.cpp
1#include "Game/LiveActor/Spine.hpp"
2#include "Game/LiveActor/ActorStateKeeper.hpp"
3
4Spine::Spine(void *pExecutor, const Nerve *pNerve) {
5 mExecutor = pExecutor;
6 mCurNerve = pNerve;
7 mNextNerve = nullptr;
8 mStep = 0;
9 mStateKeeper = 0;
10}
11
12void Spine::update() {
13 changeNerve();
14 mCurNerve->execute(this);
15 mStep++;
16 changeNerve();
17}
18
19void Spine::setNerve(const Nerve *pNerve) {
20 if (mStep > 0) {
21 mCurNerve->executeOnEnd(this);
22 }
23
24 mNextNerve = pNerve;
25 mStep = -1;
26}
27
28const Nerve* Spine::getCurrentNerve() const{
29 if (mNextNerve) {
30 return mNextNerve;
31 }
32 return mCurNerve;
33}
34
35void Spine::changeNerve() {
36 if (mNextNerve == nullptr) {
37 return;
38 }
39
40 if (mStateKeeper != 0) {
41 mStateKeeper->endState(mCurNerve);
42 mStateKeeper->startState(mNextNerve);
43 }
44
45 const Nerve* pNextState = mNextNerve;
46 mStep = 0;
47 mCurNerve = pNextState;
48 mNextNerve = nullptr;
49}
50
51void Spine::initStateKeeper(int a2) {
52 mStateKeeper = new ActorStateKeeper(a2);
53}
Used for executing states of a LiveActor.
Definition Nerve.hpp:6
virtual void execute(Spine *pSpine) const =0
Executes a state based on the host actor.
virtual void executeOnEnd(Spine *pSpine) const
Executes after the last iteration of a state before it executes another state.
Definition Nerve.cpp:3