修复子弹地图边界问题
This commit is contained in:
parent
abf4d4ef70
commit
79be580f3d
@ -209,48 +209,17 @@ void Bullet::MapServiceUpdate()
|
|||||||
if (IsBomb()) {
|
if (IsBomb()) {
|
||||||
ProcBomb();
|
ProcBomb();
|
||||||
} else {
|
} else {
|
||||||
room->RemoveObjectLater(this);
|
Check(distance);
|
||||||
}
|
if (!later_removed_) {
|
||||||
} else {
|
|
||||||
room->grid_service->MoveBullet(this);
|
|
||||||
std::set<Entity*> objects;
|
|
||||||
TouchAllLayerHumanList
|
|
||||||
(
|
|
||||||
[this, &objects] (Human* hum, bool& stop)
|
|
||||||
{
|
|
||||||
if (hum != player && !hum->dead && TestCollision(room, hum)) {
|
|
||||||
objects.insert(hum);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
{
|
|
||||||
std::set<ColliderComponent*> colliders;
|
|
||||||
room->map_service->GetColliders(room, GetX(), GetY(), colliders);
|
|
||||||
for (ColliderComponent* collider : colliders) {
|
|
||||||
if (TestCollision(room, collider) && !a8::HasBitFlag(collider->tag, kHalfWallTag)) {
|
|
||||||
objects.insert(collider->owner);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
float bullet_range = gun_meta->i->range();
|
|
||||||
if (gun_upgrade_meta && gun_upgrade_meta->GetAttrValue(gun_lv, kHAT_ShotRange) > 0) {
|
|
||||||
bullet_range += gun_upgrade_meta->GetAttrValue(gun_lv, kHAT_ShotRange);
|
|
||||||
}
|
|
||||||
if (!objects.empty() || distance > bullet_range ||
|
|
||||||
(IsBomb() && meta->i->_inventory_slot() != 4 && distance >= fly_distance)
|
|
||||||
) {
|
|
||||||
if (IsBomb()) {
|
|
||||||
ProcBomb();
|
|
||||||
} else {
|
|
||||||
if (!objects.empty()) {
|
|
||||||
OnHit(objects);
|
|
||||||
}
|
|
||||||
room->RemoveObjectLater(this);
|
room->RemoveObjectLater(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
room->grid_service->MoveBullet(this);
|
||||||
|
Check(distance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float Bullet::GetAtk()
|
float Bullet::GetAtk()
|
||||||
{
|
{
|
||||||
float atk = gun_meta->i->atk() +
|
float atk = gun_meta->i->atk() +
|
||||||
@ -261,3 +230,42 @@ float Bullet::GetAtk()
|
|||||||
}
|
}
|
||||||
return atk;
|
return atk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Bullet::Check(float distance)
|
||||||
|
{
|
||||||
|
std::set<Entity*> objects;
|
||||||
|
TouchAllLayerHumanList
|
||||||
|
(
|
||||||
|
[this, &objects] (Human* hum, bool& stop)
|
||||||
|
{
|
||||||
|
if (hum != player && !hum->dead && TestCollision(room, hum)) {
|
||||||
|
objects.insert(hum);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
{
|
||||||
|
std::set<ColliderComponent*> colliders;
|
||||||
|
room->map_service->GetColliders(room, GetX(), GetY(), colliders);
|
||||||
|
for (ColliderComponent* collider : colliders) {
|
||||||
|
if (TestCollision(room, collider) && !a8::HasBitFlag(collider->tag, kHalfWallTag)) {
|
||||||
|
objects.insert(collider->owner);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
float bullet_range = gun_meta->i->range();
|
||||||
|
if (gun_upgrade_meta && gun_upgrade_meta->GetAttrValue(gun_lv, kHAT_ShotRange) > 0) {
|
||||||
|
bullet_range += gun_upgrade_meta->GetAttrValue(gun_lv, kHAT_ShotRange);
|
||||||
|
}
|
||||||
|
if (!objects.empty() || distance > bullet_range ||
|
||||||
|
(IsBomb() && meta->i->_inventory_slot() != 4 && distance >= fly_distance)
|
||||||
|
) {
|
||||||
|
if (IsBomb()) {
|
||||||
|
ProcBomb();
|
||||||
|
} else {
|
||||||
|
if (!objects.empty()) {
|
||||||
|
OnHit(objects);
|
||||||
|
}
|
||||||
|
room->RemoveObjectLater(this);
|
||||||
|
later_removed_ = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -43,9 +43,11 @@ protected:
|
|||||||
bool IsBomb();
|
bool IsBomb();
|
||||||
inline void MapServiceUpdate();
|
inline void MapServiceUpdate();
|
||||||
float GetAtk();
|
float GetAtk();
|
||||||
|
void Check(float distance);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CircleCollider* self_collider_ = nullptr;
|
CircleCollider* self_collider_ = nullptr;
|
||||||
|
bool later_removed_ = false;
|
||||||
|
|
||||||
friend class EntityFactory;
|
friend class EntityFactory;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user