#include "EffectCondensation001.h"

#include "jp/ggaf/dxcore/actor/supporter/GgafDxKuroko.h"
#include "jp/ggaf/dxcore/actor/supporter/GgafDxScaler.h"
#include "jp/ggaf/dxcore/actor/supporter/GgafDxUvFlipper.h"
#include "jp/gecchi/VioletVreath/util/MyStgUtil.h"

using namespace GgafCore;
using namespace GgafDxCore;
using namespace GgafLib;
using namespace VioletVreath;

EffectCondensation001::EffectCondensation001(const char* prm_name) :
        DefaultSpriteSetActor(prm_name, "8/Lockon001", nullptr) {
    _class_name = "EffectCondensation001";
    pScaler_ = NEW GgafDxScaler(this);
    inactivate();
    effectBlendOne(); //壛嶼崌惉
    defineRotMvWorldMatrix(UTIL::setWorldMatrix_RzBxyzMv); //價儖儃乕僪Rz夞揮
    setHitAble(false); //摉偨傝敾掕柍偟
}

void EffectCondensation001::initialize() {
    GgafDxUvFlipper* pUvFlipper = getUvFlipper();
    pUvFlipper->setFlipPtnRange(0, 3);   //傾僯儊斖埻傪侽乣侾俆
    pUvFlipper->exec(FLIP_ORDER_LOOP, 5); //傾僯儊弴彉
}

void EffectCondensation001::onActive() {
    getUvFlipper()->setActivePtnToTop();
    setAlpha(0.01);
    pScaler_->forceRange(30000, 1000); //僗働乕儕儞僌丒斖埻
    setScale(30000);
    pScaler_->transitionLinerUntil(1000, 30);//僗働乕儕儞僌丒60F旓傗偟偰1000偵弅彫
    getKuroko()->setFaceAngVelo(AXIS_Z, 1000);        //夞揮
}

void EffectCondensation001::processBehavior() {
    if (getAlpha() < 1.0) {
        addAlpha(0.05);
    }

    if (!pScaler_->isTransitioning()) {
        //弅彫姰椆屻丄Beat
        pScaler_->forceRange(1000, 2000);
        pScaler_->beat(30, 2, 0, 26, -1); //柍尷儖乕僾
    }
    getUvFlipper()->behave();
    getKuroko()->behave();
    pScaler_->behave();
}

void EffectCondensation001::processJudgement() {
//    if (_alpha < 0) {
//        sayonara();
//    }
}

void EffectCondensation001::onInactive() {
}

EffectCondensation001::~EffectCondensation001() {
    GGAF_DELETE(pScaler_);
}

