summaryrefslogtreecommitdiff
path: root/src/d/actor/d_a_vrbox.cpp
blob: c3d2aba7e1b9d2e5679f08a5cea342463478beee (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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
//
// Generated by dtk
// Translation Unit: d_a_vrbox.cpp
//

#include "d/dolzel.h" // IWYU pragma: keep
#include "d/actor/d_a_vrbox.h"
#include "JSystem/J3DGraphBase/J3DMatBlock.h"
#include "d/d_com_inf_game.h"
#include "m_Do/m_Do_mtx.h"
#include "d/d_kankyo_wether.h"

static BOOL daVrbox_color_set(vrbox_class* i_this);

/* 8015E3F0-8015E530       .text daVrbox_Draw__FP11vrbox_class */
static BOOL daVrbox_Draw(vrbox_class* i_this) {
    J3DModel* model = i_this->mpModel;
    f32 y_origin = 0.0f;
    dStage_FileList_dt_c* fili = NULL;

    daVrbox_color_set(i_this);

    if (g_env_light.mbVrboxInvisible != 0) {
        return TRUE;
    }

    s32 roomNo = dComIfGp_roomControl_getStayNo();
    if (roomNo >= 0) {
        fili = dComIfGp_roomControl_getStatusRoomDt(roomNo)->getFileListInfo();
    }

    if (fili) {
        y_origin = fili->mSeaLevel;
    }

    f32 y_offset;
    if (dComIfGd_getView()) {
        y_offset = (dComIfGd_getView()->mInvViewMtx[1][3] - y_origin) * 0.09f;
    } else {
        y_offset = 0.0f;
    }

    mDoMtx_stack_c::transS(
        dComIfGd_getView()->mInvViewMtx[0][3],
        dComIfGd_getView()->mInvViewMtx[1][3] - y_offset,
        dComIfGd_getView()->mInvViewMtx[2][3]
    );

    model->setBaseTRMtx(mDoMtx_stack_c::get());

    dComIfGd_setListSky();
    mDoExt_modelUpdateDL(model);
    dComIfGd_setList();

    return TRUE;
}

/* 8015E530-8015E6B0       .text daVrbox_color_set__FP11vrbox_class */
static BOOL daVrbox_color_set(vrbox_class* i_this) {
    if (g_env_light.mVrKasumiMaeColor.r + g_env_light.mVrKasumiMaeColor.g + g_env_light.mVrKasumiMaeColor.b +
        g_env_light.mVrSkyColor.r + g_env_light.mVrSkyColor.g + g_env_light.mVrSkyColor.b +
        g_env_light.mVrkumoColor.r + g_env_light.mVrkumoColor.g + g_env_light.mVrkumoColor.b == 0)
    {
        g_env_light.mbVrboxInvisible = 1;
        return TRUE;
    }

    g_env_light.mbVrboxInvisible = 0;

    J3DModelData* modelData = i_this->mpModel->getModelData();
    J3DMaterial* mat = modelData->getMaterialNodePointer(0);
    J3DGXColor color;

    mat->setCullMode(GX_CULL_NONE);
    mat->change();
    color.mColor.r = g_env_light.mVrKasumiMaeColor.r;
    color.mColor.g = g_env_light.mVrKasumiMaeColor.g;
    color.mColor.b = g_env_light.mVrKasumiMaeColor.b;
    color.mColor.a = 0xFF;
    mat->setTevKColor(0, &color);

    mat = modelData->getMaterialNodePointer(1);
    mat->setCullMode(GX_CULL_NONE);
    mat->change();
    color.mColor.r = g_env_light.mVrSkyColor.r;
    color.mColor.g = g_env_light.mVrSkyColor.g;
    color.mColor.b = g_env_light.mVrSkyColor.b;
    color.mColor.a = 0xFF;
    mat->setTevKColor(0, &color);

    return TRUE;
}

/* 8015E6B8-8015E864       .text dungeon_rain_proc__Fv */
static void dungeon_rain_proc() {
    dScnKy_env_light_c* env_light = &g_env_light; // Probably a fakematch
    u8 mode = 0;
    int roomNo = dComIfGp_roomControl_getStayNo();

    if (!dKy_checkEventNightStop()) {
        return;
    }

    bool inDungeon = true;
    if (strcmp(dComIfGp_getStartStageName(), "M_NewD2") == 0) {
        if (roomNo == 3) {
            mode = 1;
        }
    } else if (strcmp(dComIfGp_getStartStageName(), "M_Dra09") == 0) {
        mode = 1;
    } else if (strcmp(dComIfGp_getStartStageName(), "kinMB") == 0) {
        mode = 1;
    } else if (strcmp(dComIfGp_getStartStageName(), "kindan") == 0) {
        if (roomNo == 2 || roomNo == 13) {
            mode = 1;
        } else if (roomNo == 4) {
            mode = 2;
        }
    } else {
        inDungeon = false;
    }

    if (inDungeon) {
        if (mode == 1) { // Rain and thunder
            if (env_light->mRainCountOrig != 250) {
                dKy_change_colpat(1);
                dKyw_rain_set(250);
                env_light = &g_env_light;
                env_light->mThunderEff.mMode = 1;
            }
        } else if (mode == 2) { // Thunder, but no rain
            env_light = &g_env_light;
            if (env_light->mThunderEff.mMode == 0) {
                dKy_change_colpat(1);
                env_light->mThunderEff.mMode = 0xA;
            }
        } else { // No rain or thunder
            env_light = &g_env_light;
            if (env_light->mThunderEff.mMode != 0) {
                dKyw_rain_set(0);
                env_light->mThunderEff.mMode = 0;
            }
        }
    }
}

/* 8015E864-8015E888       .text daVrbox_Execute__FP11vrbox_class */
static BOOL daVrbox_Execute(vrbox_class* i_this) {
    dungeon_rain_proc();
    return TRUE;
}

/* 8015E888-8015E890       .text daVrbox_IsDelete__FP11vrbox_class */
static BOOL daVrbox_IsDelete(vrbox_class* i_this) {
    return TRUE;
}

/* 8015E890-8015E898       .text daVrbox_Delete__FP11vrbox_class */
static BOOL daVrbox_Delete(vrbox_class* i_this) {
    return TRUE;
}

/* 8015E898-8015E968       .text daVrbox_solidHeapCB__FP10fopAc_ac_c */
static BOOL daVrbox_solidHeapCB(fopAc_ac_c* i_actor) {
    vrbox_class* i_this = static_cast<vrbox_class*>(i_actor);

    J3DModelData* modelData = (J3DModelData*)dComIfG_getStageRes("Stage", "vr_sky.bdl");
    JUT_ASSERT(469, modelData != NULL);

    i_this->mpModel = mDoExt_J3DModel__create(modelData, 0x80000, 0x11020202);

    bool success = FALSE;
    if (modelData && i_this->mpModel) {
        success = TRUE;
    }
    return success;
}

/* 8015E968-8015EA14       .text daVrbox_Create__FP10fopAc_ac_c */
static cPhs_State daVrbox_Create(fopAc_ac_c* i_actor) {
    fopAcM_ct(i_actor, vrbox_class);
    vrbox_class* i_this = static_cast<vrbox_class*>(i_actor);

    i_this->m29C = 0;

    cPhs_State phase_state = cPhs_COMPLEATE_e;
    if (fopAcM_entrySolidHeap(i_this, daVrbox_solidHeapCB, 0xC60)) {
        dComIfGp_onStatus(1);
        g_env_light.mbVrboxInvisible = 0;
    } else {
        phase_state = cPhs_ERROR_e;
    }

    return phase_state;
}

static actor_method_class l_daVrbox_Method = {
    (process_method_func)daVrbox_Create,
    (process_method_func)daVrbox_Delete,
    (process_method_func)daVrbox_Execute,
    (process_method_func)daVrbox_IsDelete,
    (process_method_func)daVrbox_Draw,
};

actor_process_profile_definition g_profile_VRBOX = {
    /* Layer ID     */ fpcLy_CURRENT_e,
    /* List ID      */ 0x0007,
    /* List Prio    */ fpcPi_CURRENT_e,
    /* Proc Name    */ fpcNm_VRBOX_e,
    /* Proc SubMtd  */ &g_fpcLf_Method.base,
    /* Size         */ sizeof(vrbox_class),
    /* Size Other   */ 0,
    /* Parameters   */ 0,
    /* Leaf SubMtd  */ &g_fopAc_Method.base,
    /* Draw Prio    */ fpcDwPi_VRBOX_e,
    /* Actor SubMtd */ &l_daVrbox_Method,
    /* Status       */ fopAcStts_UNK4000_e | fopAcStts_UNK40000_e,
    /* Group        */ fopAc_ACTOR_e,
    /* Cull Type    */ fopAc_CULLBOX_0_e,
};