//
// Generated by dtk
// Translation Unit: d_a_obj_xfuta.cpp
//

#include "d/dolzel_rel.h" // IWYU pragma: keep
#include "d/actor/d_a_obj_xfuta.h"
#include "d/d_com_inf_game.h"
#include "res/Object/X_futa.h"
#include "dolphin/types.h"

namespace daObjXfuta {
    
const char Act_c::M_arcname[] = "X_futa";

static int tev_mode[] = {
    TEV_TYPE_ACTOR,
    TEV_TYPE_BG0,
    TEV_TYPE_BG1,
    TEV_TYPE_BG2,
    TEV_TYPE_BG3,
    TEV_TYPE_BG0_FULL,
    TEV_TYPE_BG1_FULL,
    TEV_TYPE_BG2_FULL,
    TEV_TYPE_BG3_FULL,
    TEV_TYPE_PLAYER,
    TEV_TYPE_BG0_PLIGHT,
    TEV_TYPE_BG1_PLIGHT,
    TEV_TYPE_BG2_PLIGHT,
    TEV_TYPE_ACTOR_NOLIGHT
};

/* 00000078-0000009C       .text solidHeapCB__Q210daObjXfuta5Act_cFP10fopAc_ac_c */
BOOL Act_c::solidHeapCB(fopAc_ac_c* i_this) {
    return ((Act_c*)i_this)->create_heap();
}

/* 0000009C-0000015C       .text create_heap__Q210daObjXfuta5Act_cFv */
bool Act_c::create_heap() {
    J3DModelData* mdl_data;

    mdl_data = (J3DModelData*)(dComIfG_getObjectRes(M_arcname, dRes_INDEX_X_FUTA_BDL_X_FUTA_e));

    JUT_ASSERT(0x105, mdl_data != NULL);

    mpModel = mDoExt_J3DModel__create(mdl_data, 0, 0x11000002);

    #if VERSION == VERSION_DEMO
    return mdl_data != NULL ? TRUE : FALSE;
    #else
    bool ret = FALSE;
    if (mdl_data != NULL && this->mpModel != NULL) {
        ret = TRUE;
    }
    return ret;
    #endif
}

/* 0000015C-00000214       .text _create__Q210daObjXfuta5Act_cFv */
cPhs_State Act_c::_create() {
    fopAcM_ct(this, Act_c);
    cPhs_State phase_state = dComIfG_resLoad(&mPhs, M_arcname);
    if (phase_state == cPhs_COMPLEATE_e) {
        if (fopAcM_entrySolidHeap(this, solidHeapCB, 0x0)) {
            set_mtx();
            fopAcM_SetMtx(this, mpModel->getBaseTRMtx());
        } else {
            phase_state = cPhs_ERROR_e;
        }
    }
    return phase_state;
}

/* 00000214-00000244       .text _delete__Q210daObjXfuta5Act_cFv */
bool Act_c::_delete() {
    dComIfG_resDelete(&mPhs, M_arcname);
    return true;
}

/* 00000244-000002F0       .text set_mtx__Q210daObjXfuta5Act_cFv */
void Act_c::set_mtx() {
    mpModel->setBaseScale(scale);
    mDoMtx_stack_c::transS(current.pos);
    mDoMtx_stack_c::ZXYrotM(shape_angle);
    mpModel->setBaseTRMtx(mDoMtx_stack_c::get());
    MTXCopy(mDoMtx_stack_c::get(), mMtx);
    mpModel->calc();
}

/* 000002F0-00000338       .text _execute__Q210daObjXfuta5Act_cFv */
bool Act_c::_execute() {
    current.pos = cXyz(home.pos.x, home.pos.y, home.pos.z);
    set_mtx();
    return TRUE;
}

/* 00000338-0000040C       .text _draw__Q210daObjXfuta5Act_cFv */
bool Act_c::_draw() {
    if (dComIfGp_demo_mode() != 1) {
        cXyz pos(0.0f, 0.0f, 0.0f);
        g_env_light.settingTevStruct(tev_mode[1], &pos, &tevStr);
        dComIfGd_setListBG();
        g_env_light.setLightTevColorType(mpModel, &tevStr);
        mDoExt_modelUpdateDL(mpModel);
        dComIfGd_setList();
    }
    return TRUE;
}

namespace {

cPhs_State Mthd_Create(void* i_this) {
    return static_cast<Act_c*>(i_this)->_create();
}

BOOL Mthd_Delete(void* i_this) {
    return static_cast<Act_c*>(i_this)->_delete();
}

BOOL Mthd_Execute(void* i_this) {
    return static_cast<Act_c*>(i_this)->_execute();
}

BOOL Mthd_Draw(void* i_this) {
    return static_cast<Act_c*>(i_this)->_draw();
}

BOOL Mthd_IsDelete(void* i_this) {
    UNUSED(i_this);
    return TRUE;
}

static actor_method_class Mthd_Table = {
    (process_method_func)Mthd_Create,  (process_method_func)Mthd_Delete,
    (process_method_func)Mthd_Execute, (process_method_func)Mthd_IsDelete,
    (process_method_func)Mthd_Draw,
};

}  // namespace
}  // namespace daObjXfuta

actor_process_profile_definition g_profile_Obj_Xfuta = {
    /* Layer ID     */ fpcLy_CURRENT_e,
    /* List ID      */ 0x0003,
    /* List Prio    */ fpcPi_CURRENT_e,
    /* Proc Name    */ fpcNm_Obj_Xfuta_e,
    /* Proc SubMtd  */ &g_fpcLf_Method.base,
    /* Size         */ sizeof(daObjXfuta::Act_c),
    /* Size Other   */ 0,
    /* Parameters   */ 0,
    /* Leaf SubMtd  */ &g_fopAc_Method.base,
    /* Draw Prio    */ fpcDwPi_Obj_Xfuta_e,
    /* Actor SubMtd */ &daObjXfuta::Mthd_Table,
    /* Status       */ fopAcStts_UNK40000_e,
    /* Group        */ fopAc_ACTOR_e,
    /* Cull Type    */ fopAc_CULLBOX_0_e,
};
