Skip to content

Commit

Permalink
update body
Browse files Browse the repository at this point in the history
  • Loading branch information
tyanmahou committed Dec 26, 2024
1 parent 7f88042 commit 2fc5c46
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
14 changes: 6 additions & 8 deletions Re-Abyss/app/components/Actor/Enemy/BazookaKun/Builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<MainCollider>(pActor)
.setIsEnableMapCollider(false)
.setInitState<WaitState>()
.setVModelPresenter<Presenter>(pActor, entity.footPos)
.setVModelPresenter<Presenter>(pActor)
.setIsEnableBreathing(false)
);
// Body調整
Expand Down Expand Up @@ -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())
Expand All @@ -75,10 +76,9 @@ namespace
m_motion = m_pActor->find<MotionCtrl>();
}
public:
Presenter(ActorObj* pActor, Vec2 footPos) :
Presenter(ActorObj* pActor) :
m_pActor(pActor),
m_view(std::make_unique<BazookaKunVM>()),
m_footPos(footPos)
m_view(std::make_unique<BazookaKunVM>())
{}
private:
ActorObj* m_pActor = nullptr;
Expand All @@ -88,8 +88,6 @@ namespace
Ref<MotionCtrl> m_motion;

std::unique_ptr<BazookaKunVM> m_view;

Vec2 m_footPos;
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <abyss/components/Actor/Enemy/BazookaKun/MainCollider.hpp>
#include <abyss/components/Actor/Enemy/BazookaKun/MainCollider.hpp>
#include <abyss/modules/Actor/base/ActorObj.hpp>
#include <abyss/components/Actor/Common/Body.hpp>
#include <abyss/params/Actor/Enemy/BazookaKun/Param.hpp>
Expand All @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions Re-Abyss/app/components/Actor/Enemy/BazookaKun/TargetCtrl.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <abyss/components/Actor/Enemy/BazookaKun/TargetCtrl.hpp>
#include <abyss/components/Actor/Enemy/BazookaKun/TargetCtrl.hpp>
#include <abyss/modules/Actor/base/ActorObj.hpp>
#include <abyss/components/Actor/utils/ActorUtils.hpp>
#include <abyss/params/Actor/Enemy/BazookaKun/Param.hpp>
Expand All @@ -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));
Expand Down Expand Up @@ -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 };
Expand Down
16 changes: 16 additions & 0 deletions Re-Abyss/app/components/Actor/Enemy/CommonBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2fc5c46

Please sign in to comment.