summaryrefslogtreecommitdiff
path: root/src/d/actor/d_a_scene_exit.cpp
blob: 88286a89c802c7f659291ff29afa7318c135a749 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/**
 * @file d_a_scene_exit.cpp
 * 
*/

#include "d/dolzel_rel.h" // IWYU pragma: keep

#include "d/actor/d_a_scene_exit.h"
#include "d/d_com_inf_game.h"
#include "d/actor/d_a_player.h"
#include "m_Do/m_Do_mtx.h"

int daScex_c::checkWork() {
    if (getArg1() == 0xFF || getArg1() == 0 || getArg1() == 3) {
        if (fopAcM_isSwitch(this, getSwNo())) {
            return 0;
        }
    } else if ((getArg1() == 1 || getArg1() == 2 || getArg1() == 4) && getSwNo() != 0xFF) {
        if (!fopAcM_isSwitch(this, getSwNo())) {
            return 0;
        }
    }

    u16 eventBit = getOffEventBit();
    if (eventBit != 0x0FFF && dComIfGs_isEventBit(dSv_event_flag_c::saveBitLabels[eventBit])) {
        return 0;
    }

    eventBit = getOnEventBit();
    if (eventBit != 0x0FFF && !dComIfGs_isEventBit(dSv_event_flag_c::saveBitLabels[eventBit])) {
        return 0;
    }

    return 1;
}

inline int daScex_c::create() {
    fopAcM_ct(this, daScex_c);

    mDoMtx_stack_c::transS(current.pos.x, current.pos.y, current.pos.z);
    mDoMtx_stack_c::YrotM(shape_angle.y);
    mDoMtx_inverse(mDoMtx_stack_c::get(), mMatrix);
    scale.x *= 75.0f;
    scale.z *= 75.0f;
    scale.y *= 150.0f;

    return cPhs_COMPLEATE_e;
}

static int daScex_Create(fopAc_ac_c* i_this) {
    daScex_c* scx = static_cast<daScex_c*>(i_this);
    return scx->create();
}

static int daScex_Execute(daScex_c* i_this) {
    return i_this->execute();
}

int daScex_c::execute() {
    daPy_py_c* player = daPy_getPlayerActorClass();
    cXyz spC;

    if (checkWork()) {
        mDoMtx_multVec(mMatrix, &player->current.pos, &spC);

        if (spC.y >= 0.0f && spC.y <= scale.y && fabsf(spC.x) <= scale.x && fabsf(spC.z) <= scale.z) {
            switch (getArg1()) {
            case 0xFF:
            case 1:
                player->onSceneChangeArea(getArg0(), getPathID(), this);
                break;
            case 2:
            case 0:
                player->onSceneChangeAreaJump(getArg0(), getPathID(), this);
                break;
            case 3:
            case 4:
                player->onSceneChangeAreaJump(getArg0(), getPathID(), this);
                break;
            }
        }
    }

    if (mSceneChangeOK && player->checkSceneChangeAreaStart()) {
        if ((getArg1() == 3 || getArg1() == 4) && field_0x598 == 0) {
            mDoAud_seStart(Z2SE_FORCE_BACK, NULL, 0, 0);
            player->voiceStart(Z2SE_WL_V_FALL_TO_RESTART);
            field_0x598 = 1;
        }

        if (getArg1() == 0xFF || getArg1() == 0 || getArg1() == 3) {
            if (getSwNo() != 0xFF) {
                fopAcM_onSwitch(this, getSwNo());
            }
        }
    }

    return 1;
}

static actor_method_class l_daScex_Method = {
    (process_method_func)daScex_Create,
    NULL,
    (process_method_func)daScex_Execute,
};

actor_process_profile_definition2 g_profile_SCENE_EXIT = {
    /* Layer ID     */ fpcLy_CURRENT_e,
    /* List ID      */ 10,
    /* List Prio    */ fpcPi_CURRENT_e,
    /* Proc Name    */ fpcNm_SCENE_EXIT_e,
    /* Proc SubMtd  */ &g_fpcLf_Method.base,
    /* Size         */ 0x0000059C,
    /* Size Other   */ 0,
    /* Parameters   */ 0,
    /* Leaf SubMtd  */ &g_fopAc_Method.base,
    /* Draw Prio    */ fpcDwPi_SCENE_EXIT_e,
    /* Actor SubMtd */ &l_daScex_Method,
    /* Status       */ fopAcStts_UNK_0x40000_e | fopAcStts_NOPAUSE_e,
    /* Group        */ fopAc_UNK_GROUP_5_e,
    /* Cull Type    */ fopAc_CULLBOX_0_e,
    /* Unknown      */ 0                      // field_0x30,
};