summaryrefslogtreecommitdiff
path: root/include/s/s_Phase.hpp
blob: 596484b69d4264f3f7fb76f52d8a36552e600855 (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
32
33
34
35
36
37
38
39
40
#ifndef S_PHASE_H
#define S_PHASE_H

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

/// @brief A phase is a list of methods to be called in order.
/// @ingroup slib dol
class sPhase_c {
public:
    /// @brief Return value of a phase method and ::callMethod.
    /// @unofficial
    enum METHOD_RESULT_e {
        WAIT, ///< Do not proceed to the next method in the phase.
        OK, ///< Proceed to the next method in the phase.
        DONE ///< The phase is done.
    };
    typedef METHOD_RESULT_e (phaseMethod)(void *);

    /**
     * @brief Constructs a new phase with a given method list.
     *
     * @param methodList The list of methods in the phase.
     * @param count The length of the method list.
     */
    sPhase_c(phaseMethod **methodList, int count);
    /**
     * @brief Executes the phase until the end is reached or a method returns METHOD_RESULT_e::WAIT.
     *
     * @param thisPtr A pointer to the owner.
     * @return METHOD_RESULT_e::WAIT if the phase is not done yet, and METHOD_RESULT_e::DONE if the phase is finished.
     */
    METHOD_RESULT_e callMethod(void *thisPtr);

    phaseMethod **mpMethodList; ///< The method list.
    unsigned short mPhaseLength; ///< The length of the method list.
    unsigned short mCurrMethod; ///< The index of the method to execute.
};

#endif