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

#include "d/dolzel_rel.h" // IWYU pragma: keep
#include "d/actor/d_a_swattack.h"
#include "f_op/f_op_actor_mng.h"
#include "d/d_cc_d.h"
#include "d/d_com_inf_game.h"

static dCcD_SrcCyl l_cyl_src = {
    // dCcD_SrcGObjInf
    {
        /* Flags             */ 0,
        /* SrcObjAt  Type    */ 0,
        /* SrcObjAt  Atp     */ 0,
        /* SrcObjAt  SPrm    */ 0,
        /* SrcObjTg  Type    */ AT_TYPE_ALL,
        /* SrcObjTg  SPrm    */ cCcD_TgSPrm_Set_e | cCcD_TgSPrm_IsOther_e,
        /* SrcObjCo  SPrm    */ 0,
        /* SrcGObjAt Se      */ 0,
        /* SrcGObjAt HitMark */ 0,
        /* SrcGObjAt Spl     */ 0,
        /* SrcGObjAt Mtrl    */ 0,
        /* SrcGObjAt SPrm    */ 0,
        /* SrcGObjTg Se      */ 0,
        /* SrcGObjTg HitMark */ 0,
        /* SrcGObjTg Spl     */ 0,
        /* SrcGObjTg Mtrl    */ 0,
        /* SrcGObjTg SPrm    */ 0,
        /* SrcGObjCo SPrm    */ 0,
    },
    // cM3dGCylS
    {{
        /* Center */ {0.0f, 0.0f, 0.0f},
        /* Radius */ 50.0f,
        /* Height */ 50.0f,
    }},
};

/* 00000078-00000080       .text _delete__8daSwAt_cFv */
bool daSwAt_c::_delete() {
    return true;
}

/* 00000080-00000120       .text CreateInit__8daSwAt_cFv */
void daSwAt_c::CreateInit() {
    mStts.Init(0xFF, 0xFF, this);
    mCyl.Set(l_cyl_src);
    mCyl.SetStts(&mStts);
    mCyl.SetR(scale.x * 25.0f);
    mCyl.SetH(scale.y * 50.0f);
    mAtType = daSwAt_prm::getAtType(this);
    mSwitchNo = daSwAt_prm::getSwitchNo(this);
    fopAcM_offDraw(this);
}

/* 00000120-0000020C       .text _create__8daSwAt_cFv */
cPhs_State daSwAt_c::_create() {
    fopAcM_ct(this, daSwAt_c);
    CreateInit();
    return cPhs_COMPLEATE_e;
}

/* 000003C4-0000055C       .text _execute__8daSwAt_cFv */
bool daSwAt_c::_execute() {
    bool triggered = false;
    if (mCyl.ChkTgHit()) {
        cCcD_Obj* obj = mCyl.GetTgHitObj();
        if(obj) {
            switch (mAtType) {
            case 0xFF:
                triggered = true;
                break;
            case 0:
                if (obj->ChkAtType(AT_TYPE_SWORD) || obj->ChkAtType(AT_TYPE_BOKO_STICK) ||
                    obj->ChkAtType(AT_TYPE_STALFOS_MACE) || obj->ChkAtType(AT_TYPE_MACHETE) ||
                    obj->ChkAtType(AT_TYPE_DARKNUT_SWORD))
                {
                    triggered = true;
                }
                break;
            case 1:
                if (obj->ChkAtType(AT_TYPE_BOMB)) {
                    triggered = true;
                }
                break;
            case 2:
                if (obj->ChkAtType(AT_TYPE_BOOMERANG)) {
                    triggered = true;
                }
                break;
            case 3:
                if (obj->ChkAtType(AT_TYPE_SKULL_HAMMER)) {
                    triggered = true;
                }
                break;
            case 4:
                if (obj->ChkAtType(AT_TYPE_FIRE_ARROW) || obj->ChkAtType(AT_TYPE_ICE_ARROW) ||
                    obj->ChkAtType(AT_TYPE_LIGHT_ARROW) || obj->ChkAtType(AT_TYPE_NORMAL_ARROW))
                {
                    triggered = true;
                }
                break;
            case 5:
                if (obj->ChkAtType(0x8000)) {
                    triggered = true;
                }
                break;
            }
        }
    }

    if (triggered) {
        fopAcM_onSwitch(this, mSwitchNo);
    }

    mCyl.SetC(current.pos);
    dComIfG_Ccsp()->Set(&mCyl);
    return true;
}

/* 0000055C-00000564       .text _draw__8daSwAt_cFv */
bool daSwAt_c::_draw() {
    return true;
}

/* 00000564-00000584       .text daSwAt_Create__FPv */
static cPhs_State daSwAt_Create(void* i_this) {
    return ((daSwAt_c*)i_this)->_create();
}

/* 00000584-000005A8       .text daSwAt_Delete__FPv */
static BOOL daSwAt_Delete(void* i_this) {
    return ((daSwAt_c*)i_this)->_delete();
}

/* 000005A8-000005CC       .text daSwAt_Draw__FPv */
static BOOL daSwAt_Draw(void* i_this) {
    return ((daSwAt_c*)i_this)->_draw();
}

/* 000005CC-000005F0       .text daSwAt_Execute__FPv */
static BOOL daSwAt_Execute(void* i_this) {
    return ((daSwAt_c*)i_this)->_execute();
}

/* 000005F0-000005F8       .text daSwAt_IsDelete__FPv */
static BOOL daSwAt_IsDelete(void* i_this) {
    UNUSED(i_this);
    return TRUE;
}

static actor_method_class daSwAtMethodTable = {
    (process_method_func)daSwAt_Create,
    (process_method_func)daSwAt_Delete,
    (process_method_func)daSwAt_Execute,
    (process_method_func)daSwAt_IsDelete,
    (process_method_func)daSwAt_Draw,
};

actor_process_profile_definition g_profile_SW_ATTACK = {
    /* Layer ID     */ fpcLy_CURRENT_e,
    /* List ID      */ 0x0007,
    /* List Prio    */ fpcPi_CURRENT_e,
    /* Proc Name    */ fpcNm_SW_ATTACK_e,
    /* Proc SubMtd  */ &g_fpcLf_Method.base,
    /* Size         */ sizeof(daSwAt_c),
    /* Size Other   */ 0,
    /* Parameters   */ 0,
    /* Leaf SubMtd  */ &g_fopAc_Method.base,
    /* Draw Prio    */ fpcDwPi_SW_ATTACK_e,
    /* Actor SubMtd */ &daSwAtMethodTable,
    /* Status       */ fopAcStts_CULL_e | fopAcStts_UNK40000_e,
    /* Group        */ fopAc_ACTOR_e,
    /* Cull Type    */ fopAc_CULLBOX_CUSTOM_e,
};
