1
This commit is contained in:
parent
22ef2e0301
commit
39e7f5f6f6
@ -343,21 +343,30 @@ float Bullet::GetExplosionRange()
|
|||||||
|
|
||||||
void Bullet::Check(float distance)
|
void Bullet::Check(float distance)
|
||||||
{
|
{
|
||||||
|
int c_hit_num = 0;
|
||||||
|
int t_hit_num = 0;
|
||||||
std::set<Entity*> objects;
|
std::set<Entity*> objects;
|
||||||
room->grid_service->TraverseCreatures
|
room->grid_service->TraverseCreatures
|
||||||
(room->GetRoomIdx(),
|
(room->GetRoomIdx(),
|
||||||
GetGridList(),
|
GetGridList(),
|
||||||
[this, &objects] (Creature* c, bool& stop)
|
[this, &objects, &c_hit_num] (Creature* c, bool& stop)
|
||||||
{
|
{
|
||||||
if (sender.Get()->IsProperTarget(c)) {
|
if (sender.Get()->IsProperTarget(c)) {
|
||||||
|
if (gun_meta->i->ispenetrate() &&
|
||||||
|
hit_objects_.find(c->GetUniId()) != hit_objects_.end()) {
|
||||||
|
//穿人
|
||||||
|
return;
|
||||||
|
}
|
||||||
AabbCollider aabb_box;
|
AabbCollider aabb_box;
|
||||||
c->GetHitAabbBox(aabb_box);
|
c->GetHitAabbBox(aabb_box);
|
||||||
if (c != sender.Get() && !c->dead && TestCollision(room, &aabb_box)) {
|
if (c != sender.Get() && !c->dead && TestCollision(room, &aabb_box)) {
|
||||||
if (meta->i->_inventory_slot() == IS_C4) {
|
if (meta->i->_inventory_slot() == IS_C4) {
|
||||||
if (!c->IsHuman()) {
|
if (!c->IsHuman()) {
|
||||||
|
++c_hit_num;
|
||||||
objects.insert(c);
|
objects.insert(c);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
++c_hit_num;
|
||||||
objects.insert(c);
|
objects.insert(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -369,8 +378,14 @@ void Bullet::Check(float distance)
|
|||||||
for (ColliderComponent* collider : colliders) {
|
for (ColliderComponent* collider : colliders) {
|
||||||
if (collider->owner->IsEntityType(ET_Obstacle)) {
|
if (collider->owner->IsEntityType(ET_Obstacle)) {
|
||||||
Obstacle* obstacle = (Obstacle*)collider->owner;
|
Obstacle* obstacle = (Obstacle*)collider->owner;
|
||||||
|
if (gun_meta->i->is_penetrate_thing() &&
|
||||||
|
hit_objects_.find(obstacle->GetUniId()) != hit_objects_.end()) {
|
||||||
|
//穿物件
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!obstacle->CanThroughable(this)) {
|
if (!obstacle->CanThroughable(this)) {
|
||||||
if (TestCollision(room, collider)) {
|
if (TestCollision(room, collider)) {
|
||||||
|
++t_hit_num;
|
||||||
objects.insert(collider->owner);
|
objects.insert(collider->owner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -390,8 +405,18 @@ void Bullet::Check(float distance)
|
|||||||
if (!objects.empty()) {
|
if (!objects.empty()) {
|
||||||
OnHit(objects);
|
OnHit(objects);
|
||||||
}
|
}
|
||||||
room->RemoveObjectLater(this);
|
bool need_remove = true;
|
||||||
later_removed_ = true;
|
if (distance < bullet_range) {
|
||||||
|
if (!gun_meta->i->is_penetrate_thing() && t_hit_num > 0 ||
|
||||||
|
!gun_meta->i->ispenetrate() && c_hit_num > 0) {
|
||||||
|
} else {
|
||||||
|
need_remove = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (need_remove) {
|
||||||
|
room->RemoveObjectLater(this);
|
||||||
|
later_removed_ = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,7 @@ private:
|
|||||||
bool later_removed_ = false;
|
bool later_removed_ = false;
|
||||||
std::shared_ptr<Ability> ability_;
|
std::shared_ptr<Ability> ability_;
|
||||||
bool is_curr_weapon = false;
|
bool is_curr_weapon = false;
|
||||||
|
std::set<int> hit_objects_;
|
||||||
|
|
||||||
friend class EntityFactory;
|
friend class EntityFactory;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user