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

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

/* 00000078-00000180       .text daSwc00_Execute__FP11swc00_class */
static BOOL daSwc00_Execute(swc00_class* i_this) {
    fopAc_ac_c* actor = i_this;
    int enable_sw = daSwc00_getSw2No(i_this);
    if(enable_sw == 0xFF || dComIfGs_isSwitch(enable_sw, fopAcM_GetRoomNo(actor))) {
        int swBit = daSwc00_getSw1No(i_this);

        f32 xz_dist2 = fopAcM_searchPlayerDistanceXZ2(actor);
        f32 y_diff = fopAcM_searchPlayerDistanceY(actor);
        if(xz_dist2 < actor->scale.x && (-100.0f < y_diff && y_diff < actor->scale.y)) {
            dComIfGs_onSwitch(swBit, fopAcM_GetRoomNo(actor));

            if(daSwc00_getType(i_this) != 0) {
                fopAcM_delete(i_this);
            }
        }
        else if(daSwc00_getType(i_this) == 0) {
            dComIfGs_offSwitch(swBit, fopAcM_GetRoomNo(actor));
        }
    }

    return TRUE;
}

/* 00000180-00000188       .text daSwc00_IsDelete__FP11swc00_class */
static BOOL daSwc00_IsDelete(swc00_class* i_this) {
    UNUSED(i_this);
    return TRUE;
}

/* 00000188-00000190       .text daSwc00_Delete__FP11swc00_class */
static BOOL daSwc00_Delete(swc00_class* i_this) {
    return TRUE;
}

/* 00000190-00000274       .text daSwc00_Create__FP10fopAc_ac_c */
static cPhs_State daSwc00_Create(fopAc_ac_c* i_this) {
    fopAcM_ct_Retail(i_this, swc00_class);

    swc00_class* a_this = (swc00_class*)i_this;

    u8 swBit = daSwc00_getSw1No(a_this);
    if(dComIfGs_isSwitch(swBit, fopAcM_GetRoomNo(i_this))) {
        if(daSwc00_getType(a_this) == 0) {
            dComIfGs_offSwitch(daSwc00_getSw1No(a_this), fopAcM_GetRoomNo(i_this));
        }
        else {
            return cPhs_ERROR_e;
        }
    }

    fopAcM_ct_Demo(i_this, swc00_class);

    i_this->scale.x *= 100.0f;
    i_this->scale.x += 30.0f;
    i_this->scale.x = SQUARE(i_this->scale.x);
    i_this->scale.y *= 100.0f;

    return cPhs_COMPLEATE_e;
}

static actor_method_class l_daSwc00_Method = {
    (process_method_func)daSwc00_Create,
    (process_method_func)daSwc00_Delete,
    (process_method_func)daSwc00_Execute,
    (process_method_func)daSwc00_IsDelete,
    (process_method_func)NULL,
};

actor_process_profile_definition g_profile_SWC00 = {
    /* Layer ID     */ fpcLy_CURRENT_e,
    /* List ID      */ 0x0007,
    /* List Prio    */ fpcPi_CURRENT_e,
    /* Proc Name    */ fpcNm_SWC00_e,
    /* Proc SubMtd  */ &g_fpcLf_Method.base,
    /* Size         */ sizeof(swc00_class),
    /* Size Other   */ 0,
    /* Parameters   */ 0,
    /* Leaf SubMtd  */ &g_fopAc_Method.base,
    /* Draw Prio    */ fpcDwPi_SWC00_e,
    /* Actor SubMtd */ &l_daSwc00_Method,
    /* Status       */ fopAcStts_UNK40000_e,
    /* Group        */ fopAc_ACTOR_e,
    /* Cull Type    */ fopAc_CULLBOX_0_e,
};
