This commit is contained in:
aozhiwei 2021-05-24 18:31:30 +08:00
parent 01c792509c
commit 29c46c5e27
3 changed files with 28 additions and 10 deletions

View File

@ -169,6 +169,15 @@ void Car::GetOn(Human* passenger)
SyncAroundPlayers(__FILE__, __LINE__, __func__);
}
bool Car::CanShot(Human* passenger)
{
if (!IsPassenger(passenger)) {
return false;
}
return passenger->GetSeat() < meta->shoot_offsets.size() &&
std::get<0>(meta->shoot_offsets[passenger->GetSeat()]);
}
int Car::AllocSeat()
{
int seat = -1;
@ -349,3 +358,8 @@ void Car::SendDebugMsg(const std::string& debug_msg)
passenger->SendDebugMsg("载具debugmsg: " + debug_msg);
}
}
bool Car::IsPassenger(Human* hum)
{
return passengers_.find(hum) != passengers_.end();
}

View File

@ -30,6 +30,7 @@ class Car : public Creature
bool IsDriver(Human* hum) { return driver_ == hum && driver_; }
void GetDown(Human* passenger);
void GetOn(Human* passenger);
bool CanShot(Human* passenger);
void SyncPos();
virtual float GetRadius() override;
virtual float GetSpeed() override;
@ -40,6 +41,7 @@ class Car : public Creature
int AllocSeat();
void BeKill(int killer_id, const std::string& killer_name, int weapon_id);
void Explosion(int team_id);
bool IsPassenger(Human* hum);
private:
long long born_frameno_ = 0;

View File

@ -190,7 +190,8 @@ void Player::UpdateShot()
if (HasBuffEffect(kBET_Vertigo)) {
return;
}
if (GetCar() && GetCar()->IsDriver(this)) {
if (GetCar()) {
if (GetCar()->CanShot(this)) {
bool shot_ok = false;
a8::Vec2 target_dir = GetAttackDir();
a8::Vec2 old_car_shoot_offset = GetCar()->shoot_offset;
@ -201,6 +202,7 @@ void Player::UpdateShot()
GetCar()->SetMoveDir(GetAttackDir());
}
GetCar()->shoot_offset = old_car_shoot_offset;
}
shot_start = false;
return;
} else {