1
This commit is contained in:
parent
1dec36bca0
commit
24d95c8578
@ -32,11 +32,7 @@ void Bullet::Initialize()
|
||||
|
||||
void Bullet::Update(int delta_time)
|
||||
{
|
||||
#ifdef RAY_DETECTION
|
||||
RayDetectionUpdate();
|
||||
#else
|
||||
FrameDetectionUpdate();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Bullet::RecalcSelfCollider()
|
||||
@ -225,62 +221,3 @@ void Bullet::RayDetectionUpdate()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Bullet::FrameDetectionUpdate()
|
||||
{
|
||||
pos = pos + dir * gun_meta->i->bullet_speed() / (float)SERVER_FRAME_RATE;
|
||||
float distance = (pos - born_pos).Norm();
|
||||
if (room->OverBorder(pos, gun_meta->i->bullet_rad())) {
|
||||
if (IsBomb()) {
|
||||
ProcBomb();
|
||||
} else {
|
||||
room->RemoveObjectLater(this);
|
||||
}
|
||||
} else {
|
||||
room->grid_service.MoveBullet(this);
|
||||
std::set<Entity*> objects;
|
||||
for (auto& grid : grid_list) {
|
||||
for (Human* hum: grid->human_list) {
|
||||
if (hum != player && !hum->dead &&
|
||||
(hum->team_id == 0 || player->team_id != hum->team_id)) {
|
||||
if (TestCollision(hum)) {
|
||||
objects.insert(hum);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Entity* entity : grid->entity_list) {
|
||||
switch (entity->entity_type) {
|
||||
case ET_Obstacle:
|
||||
case ET_Building:
|
||||
{
|
||||
if (TestCollision(entity)) {
|
||||
objects.insert(entity);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}//end for
|
||||
float bullet_range = gun_meta->i->range();
|
||||
if (gun_upgrade_meta && gun_upgrade_meta->attr[EA_ShotRange] > 0) {
|
||||
bullet_range += gun_upgrade_meta->attr[EA_ShotRange];
|
||||
}
|
||||
if (!objects.empty() || distance > bullet_range ||
|
||||
(IsBomb() && meta->i->_inventory_slot() != 4 && distance >= fly_distance)
|
||||
) {
|
||||
if (IsBomb()) {
|
||||
ProcBomb();
|
||||
} else {
|
||||
deleted = true;
|
||||
if (!objects.empty()) {
|
||||
OnHit(objects);
|
||||
}
|
||||
room->RemoveObjectLater(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,6 @@ class Bullet : public Entity
|
||||
void ProcBomb();
|
||||
bool IsBomb();
|
||||
void RayDetectionUpdate();
|
||||
void FrameDetectionUpdate();
|
||||
|
||||
private:
|
||||
CircleCollider* self_collider_ = nullptr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user