diff --git a/Re-Abyss/app/components/Actor/Enemy/BazookaKun/Builder.cpp b/Re-Abyss/app/components/Actor/Enemy/BazookaKun/Builder.cpp index 5f658151..2ddfa408 100644 --- a/Re-Abyss/app/components/Actor/Enemy/BazookaKun/Builder.cpp +++ b/Re-Abyss/app/components/Actor/Enemy/BazookaKun/Builder.cpp @@ -21,13 +21,14 @@ namespace abyss::Actor::Enemy::BazookaKun { // 共通ビルド CommonBuilder::Build(pActor, BuildOption{} - .setInitPos(entity.pos) + .setInitPos(entity.footPos) + .setBodyAnchor(entity.pos, entity.footPos) .setForward(entity.forward) .setInitHp(Param::Base::Hp) .setCollider(pActor) .setIsEnableMapCollider(false) .setInitState() - .setVModelPresenter(pActor, entity.footPos) + .setVModelPresenter(pActor) .setIsEnableBreathing(false) ); // Body調整 @@ -58,7 +59,7 @@ namespace BazookaKunVM* bind() const final { return &m_view->setTime(m_pActor->getTimeSec()) - .setPos(m_footPos /*m_body->getPos()*/) + .setPos(m_body->getPos()) .setIsMirrored(m_target->isMirrored()) .setIsFlipped(m_target->isFlipped()) .setRotate(m_target->rotate()) @@ -75,10 +76,9 @@ namespace m_motion = m_pActor->find(); } public: - Presenter(ActorObj* pActor, Vec2 footPos) : + Presenter(ActorObj* pActor) : m_pActor(pActor), - m_view(std::make_unique()), - m_footPos(footPos) + m_view(std::make_unique()) {} private: ActorObj* m_pActor = nullptr; @@ -88,8 +88,6 @@ namespace Ref m_motion; std::unique_ptr m_view; - - Vec2 m_footPos; }; } diff --git a/Re-Abyss/app/components/Actor/Enemy/BazookaKun/MainCollider.cpp b/Re-Abyss/app/components/Actor/Enemy/BazookaKun/MainCollider.cpp index bbdabfed..ae2947d4 100644 --- a/Re-Abyss/app/components/Actor/Enemy/BazookaKun/MainCollider.cpp +++ b/Re-Abyss/app/components/Actor/Enemy/BazookaKun/MainCollider.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -16,7 +16,7 @@ namespace abyss::Actor::Enemy::BazookaKun CShape MainCollider::getCollider() const { - const auto& pos = m_body->getPos(); + const auto& pos = m_body->getCenterPos(); // 基準点の計算 return RectF{ pos - Vec2{ Param::Base::BodySize.x / 2, diff --git a/Re-Abyss/app/components/Actor/Enemy/BazookaKun/TargetCtrl.cpp b/Re-Abyss/app/components/Actor/Enemy/BazookaKun/TargetCtrl.cpp index 43a9e2ff..7e869e8a 100644 --- a/Re-Abyss/app/components/Actor/Enemy/BazookaKun/TargetCtrl.cpp +++ b/Re-Abyss/app/components/Actor/Enemy/BazookaKun/TargetCtrl.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -22,7 +22,7 @@ namespace abyss::Actor::Enemy::BazookaKun bool TargetCtrl::isInAimRange(Vec2& outToPlayer) const { - const auto& pos = m_body->getPos(); + const auto& pos = m_body->getCenterPos(); // 基準点の計算 auto pivot = pos + Vec2{ m_isMirrored ? 3 : -3, m_isFlipped ? -15 : 15 }; pivot = pivot.rotateAt(pos, s3d::ToRadians(m_rotate)); @@ -63,7 +63,7 @@ namespace abyss::Actor::Enemy::BazookaKun s3d::Vec2 TargetCtrl::bazookaPos() const { - const auto& pos = m_body->getPos(); + const auto& pos = m_body->getCenterPos(); // 基準点の計算 auto pivot = pos + Vec2{ m_isMirrored ? -3 : 3, m_isFlipped ? -15 : 15 }; diff --git a/Re-Abyss/app/components/Actor/Enemy/CommonBuilder.hpp b/Re-Abyss/app/components/Actor/Enemy/CommonBuilder.hpp index 5e04734d..a6e740ff 100644 --- a/Re-Abyss/app/components/Actor/Enemy/CommonBuilder.hpp +++ b/Re-Abyss/app/components/Actor/Enemy/CommonBuilder.hpp @@ -49,6 +49,22 @@ namespace abyss::Actor::Enemy this->bodyAnchor = anchor; return *this; } + BuildOption& setBodyAnchor(const s3d::Vec2& centerPos, const s3d::Vec2& footPos, double e = 0.1) + { + if (centerPos.x + e < footPos.x) { + return this->setBodyAnchor(BodyAnchor::CenterRight); + } + if (centerPos.x - e > footPos.x) { + return this->setBodyAnchor(BodyAnchor::CenterLeft); + } + if (centerPos.y + e < footPos.y) { + return this->setBodyAnchor(BodyAnchor::BottomCenter); + } + if (centerPos.y - e > footPos.y) { + return this->setBodyAnchor(BodyAnchor::TopCenter); + } + return this->setBodyAnchor(BodyAnchor::Center); + } BuildOption& setForward(Forward _forward) { this->forward = _forward;