summaryrefslogtreecommitdiff
path: root/src/d/actor/d_a_obj_mirror_6pole.cpp
blob: 9c17d8a94c99925148392c4ea8875760f797a4f5 (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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/**
 * d_a_obj_mirror_6pole.cpp
 * Mirror Chamber Sage Poles
 */

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

#include "d/actor/d_a_obj_mirror_6pole.h"
#include "f_pc/f_pc_name.h"
#include "f_op/f_op_actor_mng.h"

static char* l_arcName = "MR-6Pole";

const actionFunc daObjMirror6Pole_c::ActionTable[][2] = {
    {&daObjMirror6Pole_c::initWait, &daObjMirror6Pole_c::executeWait},
    {&daObjMirror6Pole_c::initDemo, &daObjMirror6Pole_c::executeDemo},
};

void daObjMirror6Pole_c::setAction(Mode_e i_action) {
    JUT_ASSERT(89, i_action < MODE_MAX_e);
    Mode_e oldMode = mMode;
    mMode = i_action;
    mAction = (actionFunc*)ActionTable[mMode];

    callInit();
}

void daObjMirror6Pole_c::callInit() {
    JUT_ASSERT(123, mAction != NULL);
    (this->*mAction[0])();
}

void daObjMirror6Pole_c::callExecute() {
    JUT_ASSERT(136, mAction != NULL);
    (this->*mAction[1])();
}

void daObjMirror6Pole_c::initWait() {
    mpBck->setPlaySpeed(0.0f);
}

void daObjMirror6Pole_c::executeWait() {
    if (dComIfGp_event_runCheck()) {
        setAction(MODE_DEMO_e);
    }
}

void daObjMirror6Pole_c::initDemo() {}

void daObjMirror6Pole_c::executeDemo() {
    if (!dComIfGp_event_runCheck()) {
        setAction(MODE_WAIT_e);
    }

    setBaseMtx();
}

void daObjMirror6Pole_c::setBaseMtx() {
    mDoMtx_stack_c::transS(current.pos);
    mDoMtx_stack_c::YrotM(shape_angle.y);

    mpModel->setBaseTRMtx(mDoMtx_stack_c::get());
}

void daObjMirror6Pole_c::initBaseMtx() {
    fopAcM_SetMtx(this, mpModel->getBaseTRMtx());
    setBaseMtx();
}

void daObjMirror6Pole_c::create_init() {
    initBaseMtx();
    attention_info.flags = 0;
    setAction(MODE_WAIT_e);
}

int daObjMirror6Pole_c::createHeapCallBack(fopAc_ac_c* i_this) {
    daObjMirror6Pole_c* a_this = (daObjMirror6Pole_c*)i_this;
    return a_this->CreateHeap();
}

int daObjMirror6Pole_c::CreateHeap() {
    BOOL r26 = FALSE;
    J3DModelData* modelData = (J3DModelData*)dComIfG_getObjectRes(l_arcName, 7);
    JUT_ASSERT(318, modelData != NULL);
    mpModel = mDoExt_J3DModel__create(modelData, 0x80000, 0x11000084);
    if (mpModel == NULL) {
        return 0;
    }

    J3DAnmTransform* bck = (J3DAnmTransform*)dComIfG_getObjectRes(l_arcName, 4);
    JUT_ASSERT(327, bck != NULL);
    mpBck = new mDoExt_bckAnm();

    f32 speed = isSwitch() ? 1.0f : 0.0f;

    if (mpBck == NULL || !mpBck->init(bck, FALSE, J3DFrameCtrl::EMode_NONE, speed, 0, -1, false)) {
        return 0;
    }

    if (isSwitch()) {
        mpBck->setFrame(bck->getFrameMax());
    }

    return 1;
}

int daObjMirror6Pole_c::create() {
    fopAcM_ct(this, daObjMirror6Pole_c);

    int phase = dComIfG_resLoad(&mPhase, l_arcName);
    if (phase == cPhs_COMPLEATE_e) {
        if (!fopAcM_entrySolidHeap(this, createHeapCallBack, 0x1C00)) {
            return cPhs_ERROR_e;
        }

        create_init();
    }

    return phase;
}

static int daObjMirror6Pole_Create(fopAc_ac_c* i_this) {
    daObjMirror6Pole_c* a_this = (daObjMirror6Pole_c*)i_this;
    fopAcM_RegisterCreateID(i_this, "Obj_Mirror6Pole");
    return a_this->create();
}

daObjMirror6Pole_c::~daObjMirror6Pole_c() {
    dComIfG_resDelete(&mPhase, l_arcName);
}

static int daObjMirror6Pole_Delete(daObjMirror6Pole_c* i_this) {
    fopAcM_RegisterDeleteID(i_this, "Obj_Mirror6Pole");
    i_this->~daObjMirror6Pole_c();
    return 1;
}

int daObjMirror6Pole_c::execute() {
    callExecute();
    mpBck->play();
    return 1;
}

static int daObjMirror6Pole_Execute(daObjMirror6Pole_c* i_this) {
    return i_this->execute();
}

int daObjMirror6Pole_c::draw() {
    g_env_light.settingTevStruct(0x10, &current.pos, &tevStr);
    g_env_light.setLightTevColorType_MAJI(mpModel, &tevStr);

    mpBck->entry(mpModel->getModelData());

    dComIfGd_setListBG();
    mDoExt_modelUpdateDL(mpModel);
    dComIfGd_setList();

    mpBck->remove(mpModel->getModelData());
    return 1;
}

static int daObjMirror6Pole_Draw(daObjMirror6Pole_c* i_this) {
    return i_this->draw();
}

static int daObjMirror6Pole_IsDelete(daObjMirror6Pole_c* i_this) {
    return 1;
}

static actor_method_class l_daObjMirror6Pole_Method = {
    (process_method_func)daObjMirror6Pole_Create,  (process_method_func)daObjMirror6Pole_Delete,
    (process_method_func)daObjMirror6Pole_Execute, (process_method_func)daObjMirror6Pole_IsDelete,
    (process_method_func)daObjMirror6Pole_Draw,
};

actor_process_profile_definition g_profile_Obj_Mirror6Pole = {
    /* Layer ID     */ fpcLy_CURRENT_e,
    /* List ID      */ 3,
    /* List Prio    */ fpcPi_CURRENT_e,
    /* Proc Name    */ fpcNm_Obj_Mirror6Pole_e,
    /* Proc SubMtd  */ &g_fpcLf_Method.base,
    /* Size         */ sizeof(daObjMirror6Pole_c),
    /* Size Other   */ 0,
    /* Parameters   */ 0,
    /* Leaf SubMtd  */ &g_fopAc_Method.base,
    /* Draw Prio    */ fpcDwPi_Obj_Mirror6Pole_e,
    /* Actor SubMtd */ &l_daObjMirror6Pole_Method,
    /* Status       */ fopAcStts_UNK_0x40000_e,
    /* Group        */ fopAc_ACTOR_e,
    /* Cull Type    */ fopAc_CULLBOX_CUSTOM_e,
};