SMG-Decomp
A decompilation of Super Mario Galaxy 1
Loading...
Searching...
No Matches
ActorStateKeeper.cpp
1#include "Game/LiveActor/ActorStateKeeper.hpp"
2#include "Game/LiveActor/Nerve.hpp"
3
4ActorStateKeeper::ActorStateKeeper(int capacity)
5 : mStatesCapacity(capacity), mLength(0), mStates(NULL), mCurrentState(NULL) {
6 mStates = new State [capacity];
7 for(s32 i = 0; i < mStatesCapacity; i++) {
8 State& e = mStates[i];
9 e.mInterface = NULL;
10 e.mNerve = NULL;
11 e.mName = NULL;
12 }
13}
14
15bool ActorStateKeeper::updateCurrentState() {
16 return (!mCurrentState) ? false : (mCurrentState->mInterface)->update();
17}
18
19void ActorStateKeeper::startState(const Nerve *pNerve) {
20 mCurrentState = findStateInfo(pNerve);
21
22 if (mCurrentState) {
23 ActorStateBaseInterface* interface = mCurrentState->mInterface;
24 interface->appear();
25 }
26}
27
28void ActorStateKeeper::endState(const Nerve *pNerve) {
29 mCurrentState = findStateInfo(pNerve);
30
31 if (mCurrentState) {
32 ActorStateBaseInterface* interface = mCurrentState->mInterface;
33 if (!interface->mIsDead) {
34 interface->kill();
35 }
36 }
37}
38
39void ActorStateKeeper::addState(ActorStateBaseInterface* pInterface, const Nerve* pNerve, const char* pName) {
40 State& e = mStates[mLength];
41 e.mInterface = pInterface;
42 e.mNerve = pNerve;
43 e.mName = pName;
44 mLength += 1;
45}
46
47ActorStateKeeper::State* ActorStateKeeper::findStateInfo(const Nerve *pNerve) {
48 for(int i = 0; i < mLength; i++) {
49 if(mStates[i].mNerve == pNerve) return &mStates[i];
50 }
51 return NULL;
52}
Used for executing states of a LiveActor.
Definition Nerve.hpp:6