summaryrefslogtreecommitdiff
path: root/src/d/actor/d_a_obj_nougu.cpp
blob: ae3ee5bba9d7dd6a7e5e298d3186dfaf175e38c8 (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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
/**
 * @file d_a_obj_nougu.cpp
 * 
*/

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

#include "d/actor/d_a_obj_nougu.h"
#include "d/actor/d_a_npc.h"
#include "SSystem/SComponent/c_counter.h"

dCcD_SrcSph daObj_Nougu_c::mCcDSph = {
    daNpcT_c::mCcDObjData,
    {
        {{0.0f, 0.0f, 0.0f}, 0.0f}
    },
};

static char* l_resName = "Jagar4";

const daObj_Nougu_HIOParam daObj_Nougu_Param_c::m = {
    0.0f,
    -3.0f,
    1.0f,
    200.0f
};

static OBJ_NOUGU_HIO_CLASS l_HIO;

#if DEBUG
daObj_Nougu_HIO_c::daObj_Nougu_HIO_c() {
    m = daObj_Nougu_Param_c::m;
}

void daObj_Nougu_HIO_c::listenPropertyEvent(const JORPropertyEvent*) {
    // NONMATCHING
}

void daObj_Nougu_HIO_c::genMessage(JORMContext*) {
    // NONMATCHING
}
#endif

daObj_Nougu_c::~daObj_Nougu_c() {
    OS_REPORT("|%06d:%x|daObj_Nougu_c -> デストラクト\n", g_Counter.mCounter0, this);

#if DEBUG
    if (mpHIO != NULL) {
        mpHIO->removeHIO();
    }
#endif

    dComIfG_resDelete(&mPhase, getResName());
}

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

    mType = getType();

    int phase_state = dComIfG_resLoad(&mPhase, getResName());
    if (phase_state == cPhs_COMPLEATE_e) {
        OS_REPORT("\t(%s:%d) <%08x> -> roomNo.%d", fopAcM_getProcNameString(this), getType(), fopAcM_GetParam(this), fopAcM_GetRoomNo(this));

        if (isDelete()) {
            OS_REPORT("===>isDelete:TRUE\n");
            return cPhs_ERROR_e;
        }

        OS_REPORT("\n");
        if (!fopAcM_entrySolidHeap(this, createHeapCallBack, 0x800)) {
            return cPhs_ERROR_e;
        }

        mpModel->getModelData();
        fopAcM_SetMtx(this, mpModel->getBaseTRMtx());
        fopAcM_setCullSizeBox(this, -75.0f, -50.0f, -100.0f, 75.0f, 50.0f, 100.0f);

#if DEBUG
        mpHIO = &l_HIO;
        mpHIO->entryHIO("農具");
#endif

        mAcch.Set(fopAcM_GetPosition_p(this), fopAcM_GetOldPosition_p(this), this, 1, &mAcchCir, fopAcM_GetSpeed_p(this), fopAcM_GetAngle_p(this), fopAcM_GetShapeAngle_p(this));

        mCcStts.Init(0xFF, 0, this);

        for (int i = 0; i < 5; i++) {
            mCcSph[i].Set(mCcDSph);
            mCcSph[i].SetStts(&mCcStts);
        }

        mAcch.CrrPos(dComIfG_Bgsp());
        mGndChk = mAcch.m_gnd;

        mGroundH = mAcch.GetGroundH();
        if (-G_CM3D_F_INF != mGroundH) {
            setEnvTevColor();
            setRoomNo();
        }

        Execute();
    }

    return phase_state;
}

int daObj_Nougu_c::CreateHeap() {
    J3DModelData* mdlData_p = (J3DModelData*)dComIfG_getObjectRes(getResName(), 3);
    if (mdlData_p == NULL) {
        return 0;
    }

    mpModel = mDoExt_J3DModel__create(mdlData_p, 0x80000, 0x11000084);
    if (mpModel == NULL) {
        return 0;
    }

    return 1;
}

int daObj_Nougu_c::Delete() {
    OS_REPORT("|%06d:%x|daObj_Nougu_c -> Delete\n", g_Counter.mCounter0, this);
    this->~daObj_Nougu_c();
    return 1;
}

int daObj_Nougu_c::Execute() {
    cXyz sp14;
    cXyz sp8;

    mAcch.CrrPos(dComIfG_Bgsp());
    mGndChk = mAcch.m_gnd;
    mGroundH = mAcch.GetGroundH();

    if (-G_CM3D_F_INF != mGroundH) {
        setEnvTevColor();
        setRoomNo();
    }

    setMtx();

    f32 var_f31 = 60.0f;
    for (int i = 0; i < 5; i++) {
        sp14.set(0.0f, 0.0f, var_f31);
        mDoMtx_stack_c::YrotS(shape_angle.y);
        mDoMtx_stack_c::multVec(&sp14, &sp14);
        sp14 += current.pos;

        mCcSph[i].SetC(sp14);
        mCcSph[i].SetR(30.0f);
        dComIfG_Ccsp()->Set(&mCcSph[i]);

        mCcSph[i].ClrCoHit();
        var_f31 -= 30.0f;
    }

    attention_info.position = current.pos;
    attention_info.position.y += mpHIO->m.attention_offset;
    eyePos = attention_info.position;
    attention_info.flags = 0;
    return 1;
}

int daObj_Nougu_c::Draw() {
    g_env_light.settingTevStruct(0, &current.pos, &tevStr);
    g_env_light.setLightTevColorType_MAJI(mpModel, &tevStr);
    mDoExt_modelUpdateDL(mpModel);

    if (-G_CM3D_F_INF != mGroundH) {
        mShadowId = dComIfGd_setShadow(mShadowId, 1, mpModel, &current.pos, mpHIO->m.shadow_size, 20.0f, current.pos.y, mGroundH, mGndChk, &tevStr, 0, 1.0f, dDlst_shadowControl_c::getSimpleTex());
    }

    return 1;
}

int daObj_Nougu_c::createHeapCallBack(fopAc_ac_c* i_this) {
    return ((daObj_Nougu_c*)i_this)->CreateHeap();
}

const char* daObj_Nougu_c::getResName() {
    return l_resName;
}

int daObj_Nougu_c::isDelete() {
    switch (mType) {
    case 0:
        return 0;
    }

    return 0;
}

void daObj_Nougu_c::setEnvTevColor() {
    tevStr.YukaCol = dComIfG_Bgsp().GetPolyColor(mGndChk);
    tevStr.room_no = dComIfG_Bgsp().GetRoomId(mGndChk);
}

void daObj_Nougu_c::setRoomNo() {
    fopAcM_SetRoomNo(this, dComIfG_Bgsp().GetRoomId(mGndChk));
}

void daObj_Nougu_c::setMtx() {
    mDoMtx_stack_c::transS(current.pos.x, current.pos.y, current.pos.z);
    mDoMtx_stack_c::ZXYrotM(shape_angle);
    mDoMtx_stack_c::scaleM(scale);
    mpModel->setBaseTRMtx(mDoMtx_stack_c::get());
}

static int daObj_Nougu_Create(void* i_this) {
    return ((daObj_Nougu_c*)i_this)->create();
}

static int daObj_Nougu_Delete(void* i_this) {
    return ((daObj_Nougu_c*)i_this)->Delete();
}

static int daObj_Nougu_Execute(void* i_this) {
    return ((daObj_Nougu_c*)i_this)->Execute();
}

static int daObj_Nougu_Draw(void* i_this) {
    return ((daObj_Nougu_c*)i_this)->Draw();
}

static int daObj_Nougu_IsDelete(void* i_this) {
    return 1;
}

static actor_method_class daObj_Nougu_MethodTable = {
    (process_method_func)daObj_Nougu_Create,
    (process_method_func)daObj_Nougu_Delete,
    (process_method_func)daObj_Nougu_Execute,
    (process_method_func)daObj_Nougu_IsDelete,
    (process_method_func)daObj_Nougu_Draw,
};

actor_process_profile_definition g_profile_OBJ_NOUGU = {
    /* Layer ID     */ fpcLy_CURRENT_e,
    /* List ID      */ 7,
    /* List Prio    */ fpcPi_CURRENT_e,
    /* Proc Name    */ fpcNm_OBJ_NOUGU_e,
    /* Proc SubMtd  */ &g_fpcLf_Method.base,
    /* Size         */ sizeof(daObj_Nougu_c),
    /* Size Other   */ 0,
    /* Parameters   */ 0,
    /* Leaf SubMtd  */ &g_fopAc_Method.base,
    /* Draw Prio    */ fpcDwPi_OBJ_NOUGU_e,
    /* Actor SubMtd */ &daObj_Nougu_MethodTable,
    /* Status       */ fopAcStts_UNK_0x40000_e | fopAcStts_UNK_0x4000_e | fopAcStts_CULL_e,
    /* Group        */ fopAc_ACTOR_e,
    /* Cull Type    */ fopAc_CULLBOX_CUSTOM_e,
};