添加穿透处理
This commit is contained in:
parent
631375cdac
commit
bf1a2b7ff5
@ -45,11 +45,20 @@ void Bullet::Update(int delta_time)
|
|||||||
if (hum != master && !hum->dead &&
|
if (hum != master && !hum->dead &&
|
||||||
(hum->team_id == 0 || master->team_id != hum->team_id)) {
|
(hum->team_id == 0 || master->team_id != hum->team_id)) {
|
||||||
if (hum->TestCollision(&bullet_collider)) {
|
if (hum->TestCollision(&bullet_collider)) {
|
||||||
objects.insert(hum);
|
if (meta->i->is_through()) {
|
||||||
|
//可穿透
|
||||||
|
if (hited_humans_.find(hum) == hited_humans_.end()) {
|
||||||
|
hited_humans_.insert(hum);
|
||||||
|
objects.insert(hum);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
objects.insert(hum);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}//end for
|
}//end for
|
||||||
|
float bullet_range = meta->i->range() + master->ability.shot_range + master->BuffAttrAbs(kHAT_ShotRange);
|
||||||
if (!meta->i->is_through()) {
|
if (!meta->i->is_through()) {
|
||||||
std::set<ColliderComponent*> colliders;
|
std::set<ColliderComponent*> colliders;
|
||||||
room->map_service.GetColliders(pos.x, pos.y, colliders);
|
room->map_service.GetColliders(pos.x, pos.y, colliders);
|
||||||
@ -58,15 +67,23 @@ void Bullet::Update(int delta_time)
|
|||||||
objects.insert(collider->owner);
|
objects.insert(collider->owner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (!objects.empty() || distance > bullet_range ) {
|
||||||
float bullet_range = meta->i->range() + master->ability.shot_range + master->BuffAttrAbs(kHAT_ShotRange);
|
deleted = true;
|
||||||
if (!objects.empty() || distance > bullet_range ) {
|
if (!objects.empty()) {
|
||||||
deleted = true;
|
OnHit(objects);
|
||||||
|
}
|
||||||
|
PostAttack();
|
||||||
|
room->RemoveObjectLater(this);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (!objects.empty()) {
|
if (!objects.empty()) {
|
||||||
OnHit(objects);
|
OnHit(objects);
|
||||||
}
|
}
|
||||||
PostAttack();
|
if (distance > bullet_range ) {
|
||||||
room->RemoveObjectLater(this);
|
deleted = true;
|
||||||
|
PostAttack();
|
||||||
|
room->RemoveObjectLater(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,4 +30,7 @@ class Bullet : public Entity
|
|||||||
|
|
||||||
void OnHit(std::set<Entity*>& objects);
|
void OnHit(std::set<Entity*>& objects);
|
||||||
void PostAttack();
|
void PostAttack();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::set<Human*> hited_humans_;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user