1#include "ObjectPakkunF.hh"
6ObjectPakkunF::ObjectPakkunF(
const System::MapdataGeoObj ¶ms)
7 : ObjectCollidable(params), m_attackFrames(0), m_currAttackFrame(0),
8 m_waitDuration(static_cast<s32>(m_mapObj->setting(0))) {}
11ObjectPakkunF::~ObjectPakkunF() =
default;
14void ObjectPakkunF::init() {
15 m_state = State::Wait;
16 m_waitFrames = m_waitDuration;
22void ObjectPakkunF::calc() {
34 calcCollisionTransform();
38void ObjectPakkunF::loadAnims() {
39 std::array<const char *, 3> names = {{
45 std::array<Render::AnmType, 3> types = {{
51 linkAnims(names, types);
55void ObjectPakkunF::calcCollisionTransform() {
56 constexpr EGG::Vector3f INIT_POS = EGG::Vector3f(0.0f, 620.0f, 70.0f);
57 constexpr EGG::Vector3f FINAL_POS = EGG::Vector3f(0.0f, 160.0f, 550.0f);
63 EGG::Vector3f posOffset;
65 if (m_state == State::Attack) {
66 if (m_currAttackFrame <= 10) {
67 posOffset = INIT_POS * m_scale.x;
68 }
else if (m_currAttackFrame <= 20) {
69 f32 fVar1 = 0.1f *
static_cast<f32
>(m_currAttackFrame - 10);
70 posOffset = FINAL_POS * m_scale.x * fVar1 + INIT_POS * m_scale.x * (1.0f - fVar1);
71 }
else if (m_currAttackFrame <= 30) {
72 f32 fVar1 = 0.1f *
static_cast<f32
>(m_currAttackFrame - 20);
73 posOffset = INIT_POS * m_scale.x * fVar1 + FINAL_POS * m_scale.x * (1.0f - fVar1);
75 posOffset = INIT_POS * m_scale.x;
78 posOffset = INIT_POS * m_scale.x;
81 EGG::Matrix34f rotMat;
85 EGG::Matrix34f damageRotMat = EGG::Matrix34f::ident;
86 damageRotMat.setAxisRotation(0.0f, EGG::Vector3f::ey);
88 EGG::Matrix34f transformMat;
89 transformMat.makeT(m_pos + rotMat.multiplyTo(damageRotMat).ps_multVector(posOffset));
91 m_collision->transform(transformMat, m_scale);
95void ObjectPakkunF::calcWait() {
96 if (--m_waitFrames == 0) {
102void ObjectPakkunF::calcAttack() {
105 if (--m_attackFrames == 0) {
106 m_state = State::Wait;
107 m_waitFrames = m_waitDuration;
112void ObjectPakkunF::enterAttack() {
113 constexpr s32 LINGERING_FRAMES = 60;
115 m_state = State::Attack;
116 auto *anmMgr = m_drawMdl->anmMgr();
117 anmMgr->playAnim(0.0f, 1.0f, 0);
118 m_currAttackFrame = 0;
119 auto *attackAnm = anmMgr->activeAnim(Render::AnmType::Chr);
120 m_attackFrames =
static_cast<s32
>(attackAnm->frameCount()) + LINGERING_FRAMES;