8.驾驶员下车后,车上人员需要可以切换驾驶位
This commit is contained in:
parent
b068f7cb57
commit
b0347254a1
@ -72,6 +72,16 @@ void Car::FillMFObjectFull(Room* room, Human* hum, cs::MFObjectFull* full_data)
|
|||||||
FillBuffList(hum, p->mutable_buff_list());
|
FillBuffList(hum, p->mutable_buff_list());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Human* Car::GetPassengerBySeat(int seat)
|
||||||
|
{
|
||||||
|
for (auto hum : passengers_) {
|
||||||
|
if (hum->GetSeat() == seat) {
|
||||||
|
return hum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void Car::GetDown(Human* passenger)
|
void Car::GetDown(Human* passenger)
|
||||||
{
|
{
|
||||||
if (later_removed_) {
|
if (later_removed_) {
|
||||||
@ -169,6 +179,31 @@ void Car::GetOn(Human* passenger)
|
|||||||
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Car::SwitchSeat(Human* passenger, int seat)
|
||||||
|
{
|
||||||
|
if (seat != 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (driver_) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!IsPassenger(passenger)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (passenger->GetSeat() == seat) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (GetPassengerBySeat(seat)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!IsDriver(passenger)) {
|
||||||
|
passenger->SetSeat(seat);
|
||||||
|
driver_ = passenger;
|
||||||
|
room->frame_event.AddCarChg(passenger);
|
||||||
|
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool Car::CanShot(Human* passenger)
|
bool Car::CanShot(Human* passenger)
|
||||||
{
|
{
|
||||||
if (!IsPassenger(passenger)) {
|
if (!IsPassenger(passenger)) {
|
||||||
|
@ -28,8 +28,10 @@ class Car : public Creature
|
|||||||
virtual void GetAabbBox(AabbCollider& aabb_box) override;
|
virtual void GetAabbBox(AabbCollider& aabb_box) override;
|
||||||
|
|
||||||
bool IsDriver(Human* hum) { return driver_ == hum && driver_; }
|
bool IsDriver(Human* hum) { return driver_ == hum && driver_; }
|
||||||
|
Human* GetPassengerBySeat(int seat);
|
||||||
void GetDown(Human* passenger);
|
void GetDown(Human* passenger);
|
||||||
void GetOn(Human* passenger);
|
void GetOn(Human* passenger);
|
||||||
|
void SwitchSeat(Human* passenger, int seat);
|
||||||
bool CanShot(Human* passenger);
|
bool CanShot(Human* passenger);
|
||||||
void SyncPos();
|
void SyncPos();
|
||||||
virtual float GetRadius() override;
|
virtual float GetRadius() override;
|
||||||
|
@ -114,6 +114,9 @@ void Player::InternalUpdate(int delta_time)
|
|||||||
if (get_on) {
|
if (get_on) {
|
||||||
UpdateGetOn();
|
UpdateGetOn();
|
||||||
}
|
}
|
||||||
|
if (switch_seat) {
|
||||||
|
UpdateSwitchSeat();
|
||||||
|
}
|
||||||
if (shot_start || shot_hold) {
|
if (shot_start || shot_hold) {
|
||||||
UpdateShot();
|
UpdateShot();
|
||||||
}
|
}
|
||||||
@ -421,6 +424,14 @@ void Player::UpdateGetOn()
|
|||||||
get_on = 0;
|
get_on = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Player::UpdateSwitchSeat()
|
||||||
|
{
|
||||||
|
if (GetCar()) {
|
||||||
|
GetCar()->SwitchSeat(this, switch_seat - 1);
|
||||||
|
}
|
||||||
|
switch_seat = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void Player::UpdateUseSkill()
|
void Player::UpdateUseSkill()
|
||||||
{
|
{
|
||||||
if (HasBuffEffect(kBET_Vertigo)) {
|
if (HasBuffEffect(kBET_Vertigo)) {
|
||||||
@ -1114,6 +1125,9 @@ void Player::_CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg)
|
|||||||
if (msg.has_get_on()) {
|
if (msg.has_get_on()) {
|
||||||
get_on = msg.get_on();
|
get_on = msg.get_on();
|
||||||
}
|
}
|
||||||
|
if (msg.has_switch_seat()) {
|
||||||
|
switch_seat = msg.has_switch_seat();
|
||||||
|
}
|
||||||
if (msg.has_jump()) {
|
if (msg.has_jump()) {
|
||||||
jump = true;
|
jump = true;
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,7 @@ class Player : public Human
|
|||||||
|
|
||||||
bool get_down = false;
|
bool get_down = false;
|
||||||
int get_on = 0;
|
int get_on = 0;
|
||||||
|
int switch_seat = 0;
|
||||||
|
|
||||||
::google::protobuf::RepeatedField< ::google::protobuf::int32 > interaction_objids;
|
::google::protobuf::RepeatedField< ::google::protobuf::int32 > interaction_objids;
|
||||||
|
|
||||||
@ -85,6 +86,7 @@ class Player : public Human
|
|||||||
void UpdateJump();
|
void UpdateJump();
|
||||||
void UpdateGetDown();
|
void UpdateGetDown();
|
||||||
void UpdateGetOn();
|
void UpdateGetOn();
|
||||||
|
void UpdateSwitchSeat();
|
||||||
void UpdateUseSkill();
|
void UpdateUseSkill();
|
||||||
void UpdateAiming();
|
void UpdateAiming();
|
||||||
void Shot();
|
void Shot();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user