1
This commit is contained in:
parent
b348bba463
commit
d665f43a8d
@ -32,7 +32,11 @@ void Bullet::Initialize()
|
|||||||
|
|
||||||
void Bullet::Update(int delta_time)
|
void Bullet::Update(int delta_time)
|
||||||
{
|
{
|
||||||
|
#if MAP_SERVICE
|
||||||
|
MapServiceUpdate();
|
||||||
|
#else
|
||||||
RayDetectionUpdate();
|
RayDetectionUpdate();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bullet::RecalcSelfCollider()
|
void Bullet::RecalcSelfCollider()
|
||||||
@ -221,3 +225,66 @@ void Bullet::RayDetectionUpdate()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Bullet::MapServiceUpdate()
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}//end for
|
||||||
|
#if 1
|
||||||
|
{
|
||||||
|
std::set<ColliderComponent*> colliders;
|
||||||
|
room->map_service.GetColliders(pos.x, pos.y, colliders);
|
||||||
|
for (ColliderComponent* collider : colliders) {
|
||||||
|
if (TestCollision(collider)) {
|
||||||
|
objects.insert(collider->owner);
|
||||||
|
#if 0
|
||||||
|
a8::XPrintf("%d,%d collider:%d,%d \n",
|
||||||
|
{
|
||||||
|
pos.x,
|
||||||
|
pos.y,
|
||||||
|
collider->owner->pos.x,
|
||||||
|
collider->owner->pos.y
|
||||||
|
});
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
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,6 +38,7 @@ class Bullet : public Entity
|
|||||||
void ProcBomb();
|
void ProcBomb();
|
||||||
bool IsBomb();
|
bool IsBomb();
|
||||||
void RayDetectionUpdate();
|
void RayDetectionUpdate();
|
||||||
|
void MapServiceUpdate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CircleCollider* self_collider_ = nullptr;
|
CircleCollider* self_collider_ = nullptr;
|
||||||
|
@ -608,7 +608,10 @@ void Room::CreateBullet(Human* hum, Weapon* weapon,
|
|||||||
bullet->Initialize();
|
bullet->Initialize();
|
||||||
AddObjectLater(bullet);
|
AddObjectLater(bullet);
|
||||||
grid_service.AddBullet(bullet);
|
grid_service.AddBullet(bullet);
|
||||||
|
#if MAP_SERVICE
|
||||||
|
#else
|
||||||
bullet->movement->RayDetection();
|
bullet->movement->RayDetection();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Room::RemoveObjectLater(Entity* entity)
|
void Room::RemoveObjectLater(Entity* entity)
|
||||||
@ -844,8 +847,13 @@ void Room::UpdateGas()
|
|||||||
switch (gas_data.gas_mode) {
|
switch (gas_data.gas_mode) {
|
||||||
case GasInactive:
|
case GasInactive:
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
|
if (frame_no - gas_data.gas_start_frameno >=
|
||||||
|
3 * SERVER_FRAME_RATE) {
|
||||||
|
#else
|
||||||
if (frame_no - gas_data.gas_start_frameno >=
|
if (frame_no - gas_data.gas_start_frameno >=
|
||||||
MetaMgr::Instance()->gas_inactive_time * SERVER_FRAME_RATE) {
|
MetaMgr::Instance()->gas_inactive_time * SERVER_FRAME_RATE) {
|
||||||
|
#endif
|
||||||
gas_data.gas_mode = GasJump;
|
gas_data.gas_mode = GasJump;
|
||||||
gas_data.gas_start_frameno = frame_no;
|
gas_data.gas_start_frameno = frame_no;
|
||||||
if (human_hash_.size() < ROOM_MAX_PLAYER_NUM) {
|
if (human_hash_.size() < ROOM_MAX_PLAYER_NUM) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user