1
This commit is contained in:
parent
01c792509c
commit
29c46c5e27
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -190,17 +190,19 @@ void Player::UpdateShot()
|
||||
if (HasBuffEffect(kBET_Vertigo)) {
|
||||
return;
|
||||
}
|
||||
if (GetCar() && GetCar()->IsDriver(this)) {
|
||||
bool shot_ok = false;
|
||||
a8::Vec2 target_dir = GetAttackDir();
|
||||
a8::Vec2 old_car_shoot_offset = GetCar()->shoot_offset;
|
||||
GetCar()->shoot_offset = shoot_offset;
|
||||
GetCar()->SetAttackDir(GetAttackDir());
|
||||
GetCar()->Shot(target_dir, shot_ok, fly_distance);
|
||||
if (!moving) {
|
||||
GetCar()->SetMoveDir(GetAttackDir());
|
||||
if (GetCar()) {
|
||||
if (GetCar()->CanShot(this)) {
|
||||
bool shot_ok = false;
|
||||
a8::Vec2 target_dir = GetAttackDir();
|
||||
a8::Vec2 old_car_shoot_offset = GetCar()->shoot_offset;
|
||||
GetCar()->shoot_offset = shoot_offset;
|
||||
GetCar()->SetAttackDir(GetAttackDir());
|
||||
GetCar()->Shot(target_dir, shot_ok, fly_distance);
|
||||
if (!moving) {
|
||||
GetCar()->SetMoveDir(GetAttackDir());
|
||||
}
|
||||
GetCar()->shoot_offset = old_car_shoot_offset;
|
||||
}
|
||||
GetCar()->shoot_offset = old_car_shoot_offset;
|
||||
shot_start = false;
|
||||
return;
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user