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 2fc5c46 commit dc9ee74
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
4 changes: 4 additions & 0 deletions Re-Abyss/app/components/Actor/Common/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@ namespace abyss::Actor
return this->getOffsetedPos() - Vec2{ 0, m_size.y / 2.0 };
} else if (m_anchor == BodyAnchor::TopCenter) {
return this->getOffsetedPos() + Vec2{ 0, m_size.y / 2.0 };
} else if (m_anchor == BodyAnchor::CenterLeft) {
return this->getOffsetedPos() + Vec2{ m_size.x / 2.0, 0 };
} else if (m_anchor == BodyAnchor::CenterRight) {
return this->getOffsetedPos() - Vec2{ m_size.x / 2.0, 0 };
} else {
return this->getOffsetedPos();
}
Expand Down
3 changes: 1 addition & 2 deletions Re-Abyss/app/components/Actor/Enemy/BazookaKun/Builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ namespace abyss::Actor::Enemy::BazookaKun
{
// 共通ビルド
CommonBuilder::Build(pActor, BuildOption{}
.setInitPos(entity.footPos)
.setBodyAnchor(entity.pos, entity.footPos)
.setInitPosAnchorSize(entity.pos, entity.footPos, entity.size)
.setForward(entity.forward)
.setInitHp(Param::Base::Hp)
.setCollider<MainCollider>(pActor)
Expand Down
22 changes: 16 additions & 6 deletions Re-Abyss/app/components/Actor/Enemy/CommonBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,31 @@ namespace abyss::Actor::Enemy
this->bodyAnchor = anchor;
return *this;
}
BuildOption& setBodyAnchor(const s3d::Vec2& centerPos, const s3d::Vec2& footPos, double e = 0.1)
BuildOption& setInitPosAnchorSize(const s3d::Vec2& centerPos, const s3d::Vec2& footPos, const s3d::Vec2& size, double e = 0.1)
{
if (centerPos.x + e < footPos.x) {
return this->setBodyAnchor(BodyAnchor::CenterRight);
return this->setInitPos(footPos)
.setBodyAnchor(BodyAnchor::CenterRight)
.setBodySize(Vec2{ size.y, size.x });
}
if (centerPos.x - e > footPos.x) {
return this->setBodyAnchor(BodyAnchor::CenterLeft);
return this->setInitPos(footPos)
.setBodyAnchor(BodyAnchor::CenterLeft)
.setBodySize(Vec2{ size.y, size.x });
}
if (centerPos.y + e < footPos.y) {
return this->setBodyAnchor(BodyAnchor::BottomCenter);
return this->setInitPos(footPos)
.setBodyAnchor(BodyAnchor::BottomCenter)
.setBodySize(size);
}
if (centerPos.y - e > footPos.y) {
return this->setBodyAnchor(BodyAnchor::TopCenter);
return this->setInitPos(footPos)
.setBodyAnchor(BodyAnchor::TopCenter)
.setBodySize(size);
}
return this->setBodyAnchor(BodyAnchor::Center);
return this->setInitPos(footPos)
.setBodyAnchor(BodyAnchor::Center)
.setBodySize(size);
}
BuildOption& setForward(Forward _forward)
{
Expand Down
2 changes: 2 additions & 0 deletions Re-Abyss/app/datastores/Actor/Enemy/parser/TmxEnemyParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ namespace
Vec2 size = obj.toRectF().size;
entity->pos = obj.pos + Vec2{ size.x / 2, -size.y / 2 };
entity->footPos = obj.pos + Vec2{ size.x / 2, 0 };
entity->size = size;
entity->forward = obj.isMirrored ? Forward::Right() : Forward::Left();
}
return entity;
Expand Down Expand Up @@ -69,6 +70,7 @@ namespace
it->pos = rect.center().rotatedAt(rect.bl(), s3d::ToRadians(obj.rotation));
Vec2 footBase = it->isFlipped ? rect.topCenter() : rect.bottomCenter();
it->footPos = footBase.rotatedAt(rect.bl(), s3d::ToRadians(obj.rotation));
it->size = size;
it->isFixBazooka = obj.getProperty(U"fix_bazooka").value_or(false);
it->bazookaRotate = obj.getProperty(U"bazooka_rotate").value_or(0.0);
return it;
Expand Down
1 change: 1 addition & 0 deletions Re-Abyss/app/entities/Actor/Enemy/EnemyEntity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ namespace abyss::Actor::Enemy
EnemyType type;
s3d::Vec2 pos;
s3d::Vec2 footPos;
s3d::Vec2 size;
Forward forward;
};
}

0 comments on commit dc9ee74

Please sign in to comment.