This commit is contained in:
aozhiwei 2021-03-05 17:30:43 +08:00
parent 2bf334dbfd
commit 4387cece7b
3 changed files with 19 additions and 0 deletions

View File

@ -158,3 +158,18 @@ int Car::AllocSeat()
}
return seat;
}
void Car::SyncPos()
{
if (driver_) {
SetPos(driver_->GetPos());
move_dir = driver_->move_dir;
for (auto hum : passengers_) {
if (hum != driver_) {
hum->SetPos(GetPos());
hum->move_dir = move_dir;
room->grid_service->MoveHuman(hum);
}
}
}
}

View File

@ -27,6 +27,7 @@ class Car : public MoveableEntity
bool IsDriver(Human* hum) { return driver_ == hum && driver_; }
void GetDown(Human* passenger);
void GetOn(Human* passenger);
void SyncPos();
private:
int AllocSeat();

View File

@ -148,6 +148,9 @@ void Player::UpdateMove()
if (GetLastCollisionDoor() && !TestCollision(room, GetLastCollisionDoor())) {
SetLastCollisionDoor(nullptr);
}
if (GetCar() && GetCar()->IsDriver(this)) {
GetCar()->SyncPos();
}
#ifdef DEBUG
room->CheckPartObjects();
#endif