summaryrefslogtreecommitdiff
path: root/src/d/actor/d_a_kaji.cpp
blob: bb9d1ee0b676a912fdc71b0963a0ba95d9811720 (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
/**
 * d_a_kaji.cpp
 * Object - Ship's wheel (Tetra's Ship)
 */

#include "d/dolzel_rel.h" // IWYU pragma: keep
#include "d/actor/d_a_kaji.h"
#include "res/Object/Kaji.h"
#include "f_op/f_op_actor_mng.h"
#include "JSystem/JUtility/JUTAssert.h"
#include "m_Do/m_Do_mtx.h"
#include "d/d_com_inf_game.h"
#include "d/d_s_play.h"
#include "d/actor/d_a_obj_pirateship.h"

static daObjPirateship::Act_c* l_p_ship;

const char daKaji_c::M_arcname[] = "Kaji";

/* 00000078-00000098       .text CheckCreateHeap__FP10fopAc_ac_c */
static BOOL CheckCreateHeap(fopAc_ac_c* i_this) {
    return ((daKaji_c*)i_this)->CreateHeap();
}

/* 00000098-000001F4       .text CreateHeap__8daKaji_cFv */
BOOL daKaji_c::CreateHeap() {
    J3DModelData* modelData = (J3DModelData*)dComIfG_getObjectRes(M_arcname, dRes_INDEX_KAJI_BDL_ASODA_e);
    JUT_ASSERT(0x55, modelData != NULL);
    
    mpMorf = new mDoExt_McaMorf(
        modelData,
        NULL, NULL,
        (J3DAnmTransformKey*)dComIfG_getObjectRes("Kaji", dRes_INDEX_KAJI_BCK_KJ_WAIT_e),
        J3DFrameCtrl::EMode_LOOP, 0.0f, 0, -1, 1,
        dComIfG_getObjectRes("Kaji", dRes_INDEX_KAJI_BAS_KJ_WAIT_e),
        0x00080000,
        0x11000002
    );
    
    return mpMorf && mpMorf->getModel();
}

cPhs_State daKaji_c::_create() {
    fopAcM_ct(this, daKaji_c);
    
    cPhs_State phase_state = dComIfG_resLoad(&mPhs, M_arcname);
    if (phase_state == cPhs_COMPLEATE_e) {
        if (fopAcM_entrySolidHeap(this, CheckCreateHeap, 0x660)) {
            mDoMtx_stack_c::transS(current.pos);
            mDoMtx_stack_c::YrotM(shape_angle.y);
            mDoMtx_stack_c::scaleM(scale);
            MTXCopy(mDoMtx_stack_c::get(), mMtx);
            
            l_p_ship = (daObjPirateship::Act_c*)fopAcM_SearchByID(parentActorID);
        } else {
            return cPhs_ERROR_e;
        }
        
        fopAcM_SetMtx(this, mpMorf->getModel()->getBaseTRMtx());
        fopAcM_setCullSizeBox(this, -80.0f, -80.0f, -20.0f, 80.0f, 80.0f, 20.0f);
        
        MTXCopy(mpMorf->getModel()->getBaseTRMtx(), mMtx);
    }
    
    return phase_state;
}

bool daKaji_c::_delete() {
    dComIfG_resDelete(&mPhs, M_arcname);
    return TRUE;
}

bool daKaji_c::_execute() {
    // Copy the ship's transform (plus an offset) to the helm.
    cXyz offset(0.0f, 740.0f, -858.0f);
    offset.y += REG10_F(10);
    offset.z += REG10_F(11);
    cMtx_multVec(l_p_ship->mModel->getBaseTRMtx(), &offset, &current.pos);
    
    daObjPirateship::Act_c* ship = l_p_ship;
    shape_angle = ship->shape_angle;
    current.angle = shape_angle;
    
    mpMorf->play(NULL, 0, 0);
    
    set_mtx();
    
    return FALSE;
}

bool daKaji_c::_draw() {
    if (!l_p_ship->m2CC) {
        return true;
    }
    g_env_light.settingTevStruct(TEV_TYPE_ACTOR, &current.pos, &tevStr);
    g_env_light.setLightTevColorType(mpMorf->getModel(), &tevStr);
    mpMorf->update();
    return true;
}

/* 000001F4-00000344       .text daKajiCreate__FPv */
static cPhs_State daKajiCreate(void* i_this) {
    return ((daKaji_c*)i_this)->_create();
}

/* 00000344-00000374       .text daKajiDelete__FPv */
static BOOL daKajiDelete(void* i_this) {
    return ((daKaji_c*)i_this)->_delete();
}

/* 00000374-000004D4       .text daKajiExecute__FPv */
static BOOL daKajiExecute(void* i_this) {
    return ((daKaji_c*)i_this)->_execute();
}

/* 000004D4-00000568       .text daKajiDraw__FPv */
static BOOL daKajiDraw(void* i_this) {
    return ((daKaji_c*)i_this)->_draw();
}

/* 00000568-00000570       .text daKajiIsDelete__FPv */
static BOOL daKajiIsDelete(void* i_this) {
    return TRUE;
}

static actor_method_class daKajiMethodTable = {
    (process_method_func)daKajiCreate,
    (process_method_func)daKajiDelete,
    (process_method_func)daKajiExecute,
    (process_method_func)daKajiIsDelete,
    (process_method_func)daKajiDraw,
};

actor_process_profile_definition g_profile_Kaji = {
    /* Layer ID     */ fpcLy_CURRENT_e,
    /* List ID      */ 0x0003,
    /* List Prio    */ fpcPi_CURRENT_e,
    /* Proc Name    */ fpcNm_Kaji_e,
    /* Proc SubMtd  */ &g_fpcLf_Method.base,
    /* Size         */ sizeof(daKaji_c),
    /* Size Other   */ 0,
    /* Parameters   */ 0,
    /* Leaf SubMtd  */ &g_fopAc_Method.base,
    /* Draw Prio    */ fpcDwPi_Kaji_e,
    /* Actor SubMtd */ &daKajiMethodTable,
    /* Status       */ fopAcStts_CULL_e | fopAcStts_UNK40000_e,
    /* Group        */ fopAc_ACTOR_e,
    /* Cull Type    */ fopAc_CULLBOX_CUSTOM_e,
};