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

#include "d/dolzel_rel.h" // IWYU pragma: keep
#include "d/actor/d_a_kytag07.h"
#include "d/d_com_inf_game.h"

/* 00000078-00000080       .text daKytag07_Draw__FP13kytag07_class */
static BOOL daKytag07_Draw(kytag07_class* i_this) {
    return TRUE;
}

/* 00000080-000002A8       .text daKytag07_Execute__FP13kytag07_class */
static BOOL daKytag07_Execute(kytag07_class* i_this) {
    dScnKy_env_light_c& envLight = dKy_getEnvlight();
    if (strcmp(dComIfGp_getStartStageName(), "GTower") != 0) {
        f32 time = dComIfGs_getTime();
        u16 date = dComIfGs_getDate();
        if (time >= 60.0f && time < 315.0f)
            time += 0.4f;
        dComIfGs_setTime(time);
        dComIfGs_setDate(date);
    } else {
        u8 mode = fopAcM_GetParam(i_this) & 0xFF;
        if (mode != 1) {
            if (dComIfGp_event_runCheck() != FALSE && dComIfGp_evmng_startCheck("g2before") && dComIfGp_demo_get() != NULL && dComIfGp_demo_get()->getFrameNoMsg() >= 4719) {
                if (dComIfGp_demo_get()->getFrameNoMsg() == 4719)
                    dKy_change_colpat(1);
                if (envLight.mRainCount < 250)
                    envLight.mRainCount++;
                if (dKy_getEnvlight().mMoyaCount < 100) {
                    dKy_getEnvlight().mMoyaMode = 0;
                    dKy_getEnvlight().mMoyaCount++;
                }
                if (dKy_getEnvlight().mThunderEff.mMode == 0)
                    dKy_getEnvlight().mThunderEff.mMode = 2;
            }
        } else {
            if (dComIfGp_event_runCheck() != FALSE) {
                dDemo_manager_c* demo = dComIfGp_demo_get();
                dKy_getEnvlight().mMoyaMode = 0;
                if (demo != NULL) {
                    if (demo->getFrameNoMsg() >= 2602) {
                        envLight.mRainCount = 0;
                        envLight.mMoyaCount = 0;
                        dKy_getEnvlight().mThunderEff.mMode = 0;
                    } else {
                        envLight.mRainCount = 250;
                        envLight.mMoyaCount = 100;
                        if (dKy_getEnvlight().mThunderEff.mMode == 0)
                            dKy_getEnvlight().mThunderEff.mMode = 2;
                    }

                    f32 blend = 0.0f;
                    if (demo->getFrameNoMsg() >= 2601) {
                        blend = (demo->getFrameNoMsg() - 2601) / 200.0f;
                        if (blend > 1.0f)
                            blend = 1.0f;
                    }
                    dKy_custom_colset(1, 2, blend);
                }
            }
        }
    }
    return TRUE;
}

/* 000002A8-000002B0       .text daKytag07_IsDelete__FP13kytag07_class */
static BOOL daKytag07_IsDelete(kytag07_class*) {
    return TRUE;
}

/* 000002B0-000002C8       .text daKytag07_Delete__FP13kytag07_class */
static BOOL daKytag07_Delete(kytag07_class*) {
    dScnKy_env_light_c& env_light = dKy_getEnvlight();
    env_light.mbDayNightTactStop = false;
    return TRUE;
}

/* 000002C8-00000350       .text daKytag07_Create__FP10fopAc_ac_c */
static cPhs_State daKytag07_Create(fopAc_ac_c* i_this) {
    kytag07_class* a_this = (kytag07_class*)i_this;
    dScnKy_env_light_c& env_light = dKy_getEnvlight();

    fopAcM_ct_Retail(i_this, kytag07_class);

    if (strcmp(dComIfGp_getStartStageName(), "GTower") != 0)
        env_light.mbDayNightTactStop = true;

    fopAcM_ct_Demo(i_this, kytag07_class);

    return cPhs_COMPLEATE_e;
}

static actor_method_class l_daKytag07_Method = {
    (process_method_func)daKytag07_Create,
    (process_method_func)daKytag07_Delete,
    (process_method_func)daKytag07_Execute,
    (process_method_func)daKytag07_IsDelete,
    (process_method_func)daKytag07_Draw,
};

actor_process_profile_definition g_profile_KYTAG07 = {
    /* Layer ID     */ fpcLy_CURRENT_e,
    /* List ID      */ 0x0007,
    /* List Prio    */ fpcPi_CURRENT_e,
    /* Proc Name    */ fpcNm_KYTAG07_e,
    /* Proc SubMtd  */ &g_fpcLf_Method.base,
    /* Size         */ sizeof(kytag07_class),
    /* Size Other   */ 0,
    /* Parameters   */ 0,
    /* Leaf SubMtd  */ &g_fopAc_Method.base,
    /* Draw Prio    */ fpcDwPi_KYTAG07_e,
    /* Actor SubMtd */ &l_daKytag07_Method,
    /* Status       */ fopAcStts_UNK4000_e | fopAcStts_UNK40000_e,
    /* Group        */ fopAc_ACTOR_e,
    /* Cull Type    */ fopAc_CULLBOX_0_e,
};
