1
This commit is contained in:
parent
e1a15cec09
commit
e96243a29a
@ -36,18 +36,18 @@ void Car::GetDown(Human* passenger)
|
||||
if (later_removed_) {
|
||||
return;
|
||||
}
|
||||
if (passengers.find(passenger) == passengers.end()) {
|
||||
if (passengers_.find(passenger) == passengers_.end()) {
|
||||
return;
|
||||
}
|
||||
if (driver == passenger) {
|
||||
driver = nullptr;
|
||||
if (driver_ == passenger) {
|
||||
driver_ = nullptr;
|
||||
}
|
||||
if (meta->i->buffid()) {
|
||||
passenger->RemoveBuffById(meta->i->buffid());
|
||||
passenger->RecalcSelfCollider();
|
||||
}
|
||||
passengers.erase(passenger);
|
||||
if (passengers.empty()) {
|
||||
passengers_.erase(passenger);
|
||||
if (passengers_.empty()) {
|
||||
int loot_uniid = room->CreateLoot(meta->i->id(), GetPos(), 1, 1);
|
||||
Entity* loot_entity = room->GetEntityByUniId(loot_uniid);
|
||||
if (loot_entity && loot_entity->IsEntityType(ET_Loot)) {
|
||||
@ -72,3 +72,11 @@ void Car::GetDown(Human* passenger)
|
||||
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
||||
room->NotifyUiUpdate();
|
||||
}
|
||||
|
||||
void Car::GetOn(Human* passenger)
|
||||
{
|
||||
if (later_removed_) {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,8 +16,6 @@ class Car : public MoveableEntity
|
||||
public:
|
||||
int car_uniid = 0;
|
||||
MetaData::Equip* meta = nullptr;
|
||||
Human* driver = nullptr;
|
||||
std::set<Human*> passengers;
|
||||
|
||||
Car();
|
||||
virtual ~Car() override;
|
||||
@ -26,7 +24,11 @@ class Car : public MoveableEntity
|
||||
virtual void FillMFObjectFull(Room* room, Human* hum, cs::MFObjectFull* full_data) override;
|
||||
|
||||
void GetDown(Human* passenger);
|
||||
void GetOn(Human* passenger);
|
||||
|
||||
private:
|
||||
bool later_removed_ = false;
|
||||
Human* driver_ = nullptr;
|
||||
std::set<Human*> passengers_;
|
||||
|
||||
};
|
||||
|
@ -1368,9 +1368,9 @@ void Human::DoGetOn(int obj_uniid)
|
||||
DoGetOnWithLoot((Loot*)entity);
|
||||
}
|
||||
break;
|
||||
case ET_Player:
|
||||
case ET_Car:
|
||||
{
|
||||
DoGetOnWithTeammate((Human*)entity);
|
||||
DoGetOnWithCar((Car*)entity);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -4241,6 +4241,9 @@ void Human::DoGetOnWithLoot(Loot* entity)
|
||||
item_meta,
|
||||
GetPos()
|
||||
);
|
||||
car_->GetOn(this);
|
||||
room->NotifyUiUpdate();
|
||||
#if 0
|
||||
SetCar(car_);
|
||||
SetSeat(0);
|
||||
SetPos(entity->GetPos());
|
||||
@ -4259,11 +4262,13 @@ void Human::DoGetOnWithLoot(Loot* entity)
|
||||
CancelAction();
|
||||
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
||||
room->TakeOnCarObject(car_->car_uniid);
|
||||
room->NotifyUiUpdate();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Human::DoGetOnWithTeammate(Human* teammate)
|
||||
void Human::DoGetOnWithCar(Car* car)
|
||||
{
|
||||
car->GetOn(this);
|
||||
#if 0
|
||||
if (teammate->team_id != team_id) {
|
||||
return;
|
||||
}
|
||||
@ -4276,16 +4281,15 @@ void Human::DoGetOnWithTeammate(Human* teammate)
|
||||
if (!teammate->HasBuffEffect(kBET_Driver)) {
|
||||
return;
|
||||
}
|
||||
if (HasBuffEffect(kBET_Driver)) {
|
||||
if (GetCar()) {
|
||||
return;
|
||||
}
|
||||
if (HasBuffEffect(kBET_Passenger)) {
|
||||
if (!teammate->GetCar()) {
|
||||
return;
|
||||
}
|
||||
teammate->GetCar()->PassengerGetOn(this);
|
||||
|
||||
#if 0
|
||||
teammate->GetCar().passengers.insert(this);
|
||||
#endif
|
||||
SetCar(teammate->GetCar());
|
||||
SetPos(teammate->GetPos());
|
||||
{
|
||||
MetaData::Buff* buff_meta = MetaMgr::Instance()->GetBuff(PASSENGER_BUFFID);
|
||||
@ -4293,6 +4297,13 @@ void Human::DoGetOnWithTeammate(Human* teammate)
|
||||
AddBuff(this, buff_meta, 1);
|
||||
}
|
||||
}
|
||||
{
|
||||
MetaData::Buff* buff_meta = MetaMgr::Instance()->GetBuff(car_->meta->i->buffid());
|
||||
if (buff_meta) {
|
||||
AddBuff(this, buff_meta, 1);
|
||||
}
|
||||
}
|
||||
CancelAction();
|
||||
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
||||
#endif
|
||||
}
|
||||
|
@ -353,7 +353,7 @@ private:
|
||||
void OnLand();
|
||||
void NextReload(int prev_weapon_id, int prev_weapon_idx);
|
||||
void DoGetOnWithLoot(Loot* loot_entity);
|
||||
void DoGetOnWithTeammate(Human* teammate);
|
||||
void DoGetOnWithCar(Car* car);
|
||||
|
||||
protected:
|
||||
int level_ = 0;
|
||||
|
@ -802,8 +802,7 @@ void Player::ProcPrepareItems(const ::google::protobuf::RepeatedField< ::google:
|
||||
item_meta,
|
||||
GetPos()
|
||||
);
|
||||
SetCar(car);
|
||||
SetSeat(0);
|
||||
car->GetOn(this);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user