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

#include "d/d_attention.h"
#include "f_op/f_op_actor_mng.h"
#include "d/d_com_inf_game.h"

/* 8009D220-8009D268       .text __ct__11dAttParam_cFl */
dAttParam_c::dAttParam_c(long) {
    /* Nonmatching */
}

/* 8009D268-8009D2B0       .text __dt__11dAttParam_cFv */
dAttParam_c::~dAttParam_c() {
    /* Nonmatching */
}

/* 8009D2B0-8009D2E0       .text execute__19dAttDraw_CallBack_cFUsP16J3DTransformInfo */
void dAttDraw_CallBack_c::execute(unsigned short, J3DTransformInfo*) {
    /* Nonmatching */
}

/* 8009D2E0-8009D654       .text __ct__12dAttention_cFP10fopAc_ac_cUl */
dAttention_c::dAttention_c(fopAc_ac_c*, unsigned long) {
    /* Nonmatching */
}

/* 8009D654-8009D6EC       .text __dt__12dAttention_cFv */
dAttention_c::~dAttention_c() {
    /* Nonmatching */
}

/* 8009D6EC-8009D728       .text GetActionList__12dAttention_cFl */
dAttList_c* dAttention_c::GetActionList(long idx) {
    if (mActionNum != 0)
        return &mActionList[(mActionOffs + idx) % mActionNum];
    else
        return NULL;
}

/* 8009D728-8009D764       .text GetLockonList__12dAttention_cFl */
dAttList_c* dAttention_c::GetLockonList(long idx) {
    if (mLockOnNum != 0)
        return &mLockOnList[(mLockOnOffs + idx) % mLockOnNum];
    else
        return NULL;
}

/* 8009D764-8009D858       .text getActionBtnB__12dAttention_cFv */
dAttList_c* dAttention_c::getActionBtnB() {
    /* Nonmatching */
}

/* 8009D858-8009D9A8       .text getActionBtnXYZ_local__12dAttention_cFi */
dAttList_c* dAttention_c::getActionBtnXYZ_local(int) {
    /* Nonmatching */
}

/* 8009D9A8-8009D9FC       .text getActionBtnX__12dAttention_cFv */
dAttList_c* dAttention_c::getActionBtnX() {
    if (!dComIfGs_checkGetItemNum(g_dComIfG_gameInfo.play.mEquippedItems[0]))
        return NULL;

    return getActionBtnXYZ_local(0);
}

/* 8009D9FC-8009DA50       .text getActionBtnY__12dAttention_cFv */
dAttList_c* dAttention_c::getActionBtnY() {
    if (!dComIfGs_checkGetItemNum(g_dComIfG_gameInfo.play.mEquippedItems[1]))
        return NULL;

    return getActionBtnXYZ_local(1);
}

/* 8009DA50-8009DAA4       .text getActionBtnZ__12dAttention_cFv */
dAttList_c* dAttention_c::getActionBtnZ() {
    if (!dComIfGs_checkGetItemNum(g_dComIfG_gameInfo.play.mEquippedItems[2]))
        return NULL;

    return getActionBtnXYZ_local(2);
}

/* 8009DAA4-8009DAF4       .text chkAttMask__12dAttention_cFUlUl */
void dAttention_c::chkAttMask(unsigned long, unsigned long) {
    /* Nonmatching */
}

/* 8009DAF4-8009DB60       .text check_event_condition__FUlUs */
void check_event_condition(unsigned long, unsigned short) {
    /* Nonmatching */
}

/* 8009DB60-8009DC28       .text check_flontofplayer__FUlss */
void check_flontofplayer(unsigned long, short, short) {
    /* Nonmatching */
}

/* 8009DC28-8009DC74       .text distace_weight__Ffsf */
void distace_weight(float, short, float) {
    /* Nonmatching */
}

/* 8009DC74-8009DCD4       .text distace_angle_adjust__Ffsf */
void distace_angle_adjust(float, short, float) {
    /* Nonmatching */
}

/* 8009DCD4-8009DE44       .text check_distace__FP4cXyzsP4cXyzffff */
void check_distace(cXyz*, short, cXyz*, float, float, float, float) {
    /* Nonmatching */
}

/* 8009DE44-8009E03C       .text calcWeight__12dAttention_cFiP10fopAc_ac_cfssPUl */
void dAttention_c::calcWeight(int, fopAc_ac_c*, float, short, short, unsigned long*) {
    /* Nonmatching */
}

/* 8009E03C-8009E128       .text setLList__12dAttention_cFP10fopAc_ac_cffUl */
void dAttention_c::setLList(fopAc_ac_c* i_actor, float weight, float distance, unsigned long type) {
    float bestWeight = 0.0f;

    if (weight > 0.0f) {
        int bestIdx;
        if (mLockOnNum < (s32)ARRAY_SIZE(mLockOnList)) {
            bestIdx = mLockOnNum++;
        } else {
            for (int i = (s32)ARRAY_SIZE(mLockOnList); i >= 0; i--) {
                if (weight > bestWeight) {
                    bestIdx = i;
                    bestWeight = weight;
                }
            }
        }

        if (weight < mLockOnList[bestIdx].mWeight) {
            mLockOnList[bestIdx].setActor(i_actor);
            mLockOnList[bestIdx].mWeight = weight;
            mLockOnList[bestIdx].mDistance = distance;
            mLockOnList[bestIdx].mType = type;
        }
    }
}

/* 8009E128-8009E214       .text setAList__12dAttention_cFP10fopAc_ac_cffUl */
void dAttention_c::setAList(fopAc_ac_c* i_actor, float weight, float distance, unsigned long type) {
    float bestWeight = 0.0f;

    if (weight > 0.0f) {
        int bestIdx;
        if (mActionNum < (s32)ARRAY_SIZE(mActionList)) {
            bestIdx = mActionNum++;
        } else {
            for (int i = (s32)ARRAY_SIZE(mActionList); i >= 0; i--) {
                if (weight > bestWeight) {
                    bestIdx = i;
                    bestWeight = weight;
                }
            }
        }

        if (weight < mActionList[bestIdx].mWeight) {
            mActionList[bestIdx].setActor(i_actor);
            mActionList[bestIdx].mWeight = weight;
            mActionList[bestIdx].mDistance = distance;
            mActionList[bestIdx].mType = type;
        }
    }
}

/* 8009E214-8009E2CC       .text initList__12dAttention_cFUl */
void dAttention_c::initList(unsigned long flagMask) {
    int i;

    mFlagMask = flagMask;

    for (i = 0; i < (s32)ARRAY_SIZE(mLockOnList); i++) {
        mLockOnList[i].setActor(NULL);
        mLockOnList[i].mWeight = 3.4028235E38f;
    }
    mLockOnOffs = 0;
    mLockOnNum = 0;

    for (i = 0; i < (s32)ARRAY_SIZE(mActionList); i++) {
        mActionList[i].setActor(NULL);
        mActionList[i].mWeight = 3.4028235E38f;
    }
    mActionOffs = 0;
    mActionNum = 0;
}

/* 8009E2CC-8009E2F8       .text select_attention__FP10fopAc_ac_cPv */
void select_attention(fopAc_ac_c* pActor, void* i_attention) {
    dAttention_c * pAttention = (dAttention_c*)i_attention;
    pAttention->SelectAttention(pActor);
}

/* 8009E2F8-8009E33C       .text makeList__12dAttention_cFv */
s32 dAttention_c::makeList() {
    /* Nonmatching */
}

/* 8009E33C-8009E474       .text SelectAttention__12dAttention_cFP10fopAc_ac_c */
void dAttention_c::SelectAttention(fopAc_ac_c*) {
    /* Nonmatching */
}

/* 8009E474-8009E5C4       .text sortList__12dAttention_cFv */
void dAttention_c::sortList() {
    /* Nonmatching */
}

/* 8009E5C4-8009E684       .text stockAttention__12dAttention_cFUl */
void dAttention_c::stockAttention(unsigned long interactMask) {
    fopAc_ac_c * pTarget = LockonTarget(0);
    initList(interactMask);
    if (makeList())
        sortList();

    if (pTarget != mLockOnList[0].getActor()) {
        if (pTarget != NULL) {
            if (mLockOnList[0].getActor() != NULL)
                mFlags |= 2;
        } else {
            mFlags |= 1;
        }

        mFlags |= 4;
    }

    LockonTarget(0);
}

/* 8009E684-8009E728       .text nextAttention__12dAttention_cFUl */
void dAttention_c::nextAttention(unsigned long interactMask) {
    fopAc_ac_c * pTarget = fopAcM_SearchByID(mLockOnTargetBsPcID);
    initList(interactMask);
    if (makeList())
        sortList();

    if (pTarget == mLockOnList[0].getActor() && mLockOnNum > 1)
        mLockOnOffs = 1;

    LockonTarget(0);
}

/* 8009E728-8009E764       .text freeAttention__12dAttention_cFv */
s32 dAttention_c::freeAttention() {
    mLockOnOffs = 0;
    mLockOnNum = 0;
    mActionOffs = 0;
    mActionNum = 0;
    initList(0xFFFFFFFF);
    return 0;
}

/* 8009E764-8009E978       .text chaseAttention__12dAttention_cFv */
void dAttention_c::chaseAttention() {
    /* Nonmatching */
}

/* 8009E978-8009EA24       .text EnemyDistance__12dAttention_cFP10fopAc_ac_c */
void dAttention_c::EnemyDistance(fopAc_ac_c*) {
    /* Nonmatching */
}

/* 8009EA24-8009EAA4       .text sound_attention__FP10fopAc_ac_cPv */
void sound_attention(fopAc_ac_c*, void*) {
    /* Nonmatching */
}

/* 8009EAA4-8009EB38       .text runSoundProc__12dAttention_cFv */
void dAttention_c::runSoundProc() {
    /* Nonmatching */
}

/* 8009EB38-8009EDB8       .text runDrawProc__12dAttention_cFv */
void dAttention_c::runDrawProc() {
    /* Nonmatching */
}

/* 8009EDB8-8009EDBC       .text runDebugDisp0__12dAttention_cFv */
void dAttention_c::runDebugDisp0() {
    /* Nonmatching */
}

/* 8009EDBC-8009EDC0       .text runDebugDisp__12dAttention_cFv */
void dAttention_c::runDebugDisp() {
    /* Nonmatching */
}

/* 8009EDC0-8009EE90       .text judgementButton__12dAttention_cFv */
void dAttention_c::judgementButton() {
    /* Nonmatching */
}

/* 8009EE90-8009EED8       .text judgementTriggerProc__12dAttention_cFv */
void dAttention_c::judgementTriggerProc() {
    /* Nonmatching */
}

/* 8009EED8-8009EF40       .text judgementLostCheck__12dAttention_cFv */
void dAttention_c::judgementLostCheck() {
    /* Nonmatching */
}

/* 8009EF40-8009F0A4       .text judgementStatusSw__12dAttention_cFUl */
void dAttention_c::judgementStatusSw(unsigned long) {
    /* Nonmatching */
}

/* 8009F0A4-8009F1D4       .text judgementStatusHd__12dAttention_cFUl */
void dAttention_c::judgementStatusHd(unsigned long) {
    /* Nonmatching */
}

/* 8009F1D4-8009F460       .text Run__12dAttention_cFUl */
void dAttention_c::Run(unsigned long) {
    /* Nonmatching */
}

/* 8009F460-8009F5FC       .text Draw__12dAttention_cFv */
void dAttention_c::Draw() {
    /* Nonmatching */
}

/* 8009F5FC-8009F6B4       .text setAnm__10dAttDraw_cFiii */
void dAttDraw_c::setAnm(int, int, int) {
    /* Nonmatching */
}

/* 8009F6B4-8009F834       .text draw__10dAttDraw_cFR4cXyzPA4_f */
void dAttDraw_c::draw(cXyz&, float(*)[4]) {
    /* Nonmatching */
}

/* 8009F834-8009F88C       .text LockonTarget__12dAttention_cFl */
fopAc_ac_c* dAttention_c::LockonTarget(s32 idx) {
    if (idx >= mLockOnNum)
        return NULL;

    s32 listIdx = mLockOnOffs + idx;
    if (listIdx >= mLockOnNum)
        listIdx -= mLockOnNum;

    return mLockOnList[listIdx].getActor();
}

/* 8009F88C-8009F980       .text LockonReleaseDistanse__12dAttention_cFv */
void dAttention_c::LockonReleaseDistanse() {
    /* Nonmatching */
}

/* 8009F980-8009F9B8       .text LockonTargetPId__12dAttention_cFl */
unsigned int dAttention_c::LockonTargetPId(s32 idx) {
    if (idx >= mLockOnNum)
        return NULL;

    s32 listIdx = mLockOnOffs + idx;
    if (listIdx >= mLockOnNum)
        listIdx -= mLockOnNum;

    return mLockOnList[listIdx].getPid();
}

/* 8009F9B8-8009FA10       .text ActionTarget__12dAttention_cFl */
fopAc_ac_c* dAttention_c::ActionTarget(s32 idx) {
    if (idx >= mActionNum)
        return NULL;

    s32 listIdx = mActionOffs + idx;
    if (listIdx >= mActionNum)
        listIdx -= mActionNum;

    return mActionList[listIdx].getActor();
}

/* 8009FA10-8009FA64       .text LockonTruth__12dAttention_cFv */
bool dAttention_c::LockonTruth() {
    return mLockOnState == 1 || (mLockOnState == 2 && LockonTarget(0));
}

/* 8009FA64-8009FA98       .text getActor__10dAttList_cFv */
fopAc_ac_c* dAttList_c::getActor() {
    return fopAcM_SearchByID(mActorID);
}

/* 8009FA98-8009FAB4       .text setActor__10dAttList_cFP10fopAc_ac_c */
void dAttList_c::setActor(fopAc_ac_c* i_actor) {
    mActorID = fpcM_GetID(i_actor);
}

/* 8009FAB4-8009FACC       .text getPId__10dAttHint_cFPv */
u32 dAttHint_c::getPId(void* i_proc) {
    return fpcM_GetID(i_proc);
}

/* 8009FACC-8009FAFC       .text convPId__10dAttHint_cFUi */
fopAc_ac_c* dAttHint_c::convPId(unsigned int i_procID) {
    return fopAcM_SearchByID(i_procID);
}

/* 8009FAFC-8009FB58       .text request__10dAttHint_cFP10fopAc_ac_ci */
int dAttHint_c::request(fopAc_ac_c* i_actor, int priority) {
    if (priority < 0)
        priority = 0x1FF;

    if (priority <= mPriority) {
        mHintActorID = getPId(i_actor);
        mPriority = priority;
    }

    return TRUE;
}

/* 8009FB58-8009FB70       .text init__10dAttHint_cFv */
void dAttHint_c::init() {
    mHintActorID = -1;
    field_0x8 = -1;
    mPriority = 0x200;
}

/* 8009FB70-8009FB8C       .text proc__10dAttHint_cFv */
void dAttHint_c::proc() {
    field_0x8 = mHintActorID;
    mHintActorID = -1;
    mPriority = 0x200;
}

/* 8009FB8C-8009FBBC       .text convPId__11dAttCatch_cFUi */
fopAc_ac_c* dAttCatch_c::convPId(unsigned int i_procID) {
    return fopAcM_SearchByID(i_procID);
}

/* 8009FBBC-8009FBDC       .text init__11dAttCatch_cFv */
void dAttCatch_c::init() {
    field_0xc = 0x56;
    field_0x0 = -1;
    mCatghTargetID = -1;
    field_0x4 = 3;
}

/* 8009FBDC-8009FC08       .text proc__11dAttCatch_cFv */
void dAttCatch_c::proc() {
    mCatghTargetID = field_0x0;
    mChangeItem = field_0xc;
    field_0x0 = -1;
    field_0x4 = 3;
    field_0xc = 0x56;
}

/* 8009FC08-8009FE10       .text request__11dAttCatch_cFP10fopAc_ac_cUcfffsi */
void dAttCatch_c::request(fopAc_ac_c*, unsigned char, float, float, float, short, int) {
    /* Nonmatching */
}

/* 8009FE10-8009FE40       .text convPId__10dAttLook_cFUi */
fopAc_ac_c* dAttLook_c::convPId(unsigned int i_procID) {
    return fopAcM_SearchByID(i_procID);
}

/* 8009FE40-8009FE58       .text init__10dAttLook_cFv */
void dAttLook_c::init() {
    field_0x0 = -1;
    mLookTargetID = -1;
    field_0x4 = 3;
}

/* 8009FE58-8009FE74       .text proc__10dAttLook_cFv */
void dAttLook_c::proc() {
    mLookTargetID = field_0x0;
    field_0x0 = -1;
    field_0x4 = 3;
}

/* 8009FE74-800A009C       .text request__10dAttLook_cFP10fopAc_ac_cfffsi */
void dAttLook_c::request(fopAc_ac_c*, float, float, float, short, int) {
    /* Nonmatching */
}

/* 800A009C-800A0270       .text requestF__10dAttLook_cFP10fopAc_ac_csi */
void dAttLook_c::requestF(fopAc_ac_c*, short, int) {
    /* Nonmatching */
}

