1
This commit is contained in:
parent
01c792509c
commit
29c46c5e27
@ -169,6 +169,15 @@ void Car::GetOn(Human* passenger)
|
|||||||
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
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 Car::AllocSeat()
|
||||||
{
|
{
|
||||||
int seat = -1;
|
int seat = -1;
|
||||||
@ -349,3 +358,8 @@ void Car::SendDebugMsg(const std::string& debug_msg)
|
|||||||
passenger->SendDebugMsg("载具debugmsg: " + 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_; }
|
bool IsDriver(Human* hum) { return driver_ == hum && driver_; }
|
||||||
void GetDown(Human* passenger);
|
void GetDown(Human* passenger);
|
||||||
void GetOn(Human* passenger);
|
void GetOn(Human* passenger);
|
||||||
|
bool CanShot(Human* passenger);
|
||||||
void SyncPos();
|
void SyncPos();
|
||||||
virtual float GetRadius() override;
|
virtual float GetRadius() override;
|
||||||
virtual float GetSpeed() override;
|
virtual float GetSpeed() override;
|
||||||
@ -40,6 +41,7 @@ class Car : public Creature
|
|||||||
int AllocSeat();
|
int AllocSeat();
|
||||||
void BeKill(int killer_id, const std::string& killer_name, int weapon_id);
|
void BeKill(int killer_id, const std::string& killer_name, int weapon_id);
|
||||||
void Explosion(int team_id);
|
void Explosion(int team_id);
|
||||||
|
bool IsPassenger(Human* hum);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
long long born_frameno_ = 0;
|
long long born_frameno_ = 0;
|
||||||
|
@ -190,7 +190,8 @@ void Player::UpdateShot()
|
|||||||
if (HasBuffEffect(kBET_Vertigo)) {
|
if (HasBuffEffect(kBET_Vertigo)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (GetCar() && GetCar()->IsDriver(this)) {
|
if (GetCar()) {
|
||||||
|
if (GetCar()->CanShot(this)) {
|
||||||
bool shot_ok = false;
|
bool shot_ok = false;
|
||||||
a8::Vec2 target_dir = GetAttackDir();
|
a8::Vec2 target_dir = GetAttackDir();
|
||||||
a8::Vec2 old_car_shoot_offset = GetCar()->shoot_offset;
|
a8::Vec2 old_car_shoot_offset = GetCar()->shoot_offset;
|
||||||
@ -201,6 +202,7 @@ void Player::UpdateShot()
|
|||||||
GetCar()->SetMoveDir(GetAttackDir());
|
GetCar()->SetMoveDir(GetAttackDir());
|
||||||
}
|
}
|
||||||
GetCar()->shoot_offset = old_car_shoot_offset;
|
GetCar()->shoot_offset = old_car_shoot_offset;
|
||||||
|
}
|
||||||
shot_start = false;
|
shot_start = false;
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user