summaryrefslogtreecommitdiff
path: root/src/s/s_StateMethodUsr_FI.cpp
blob: b11ef0ccff7f4a2b770857970bbdef8c1af537e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "s/s_StateMethodUsr_FI.hpp"

#include "common.h"


// Note: Ported from https://github.com/NSMBW-Community/NSMBW-Decomp/tree/master/include/dol/sLib
// See include/s/README.txt for changes made

sStateMethodUsr_FI_c::sStateMethodUsr_FI_c(sStateIDChkIf_c &check, sStateFctIf_c &factory, const sStateIDIf_c &state)
    : sStateMethod_c(check, factory, state) {}

int sStateMethodUsr_FI_c::initializeStateLocalMethod() {
    mpState = mpStateFct.build(*getNewStateID()); // Create new state holder with the next state ID
    mpState->initialize();
    return 1;
}

void sStateMethodUsr_FI_c::executeStateLocalMethod() {
    initializeStateMethod(); // Ensure we are in a valid state (this only actually initializes the state if !mIsValid)
    mpState->execute();
}

void sStateMethodUsr_FI_c::finalizeStateLocalMethod() {
    mpState->finalize();
    mpStateFct.dispose(mpState);
}

void sStateMethodUsr_FI_c::changeStateLocalMethod(const sStateIDIf_c &newID) {
    finalizeStateMethod();   // Terminate the current state
    initializeStateMethod(); // Initialize the new state
}