This commit is contained in:
aozhiwei 2019-08-29 10:49:55 +08:00
parent 69f984200d
commit efa1bfc6d1
4 changed files with 28 additions and 7 deletions

View File

@ -1207,7 +1207,10 @@ void Human::DoGetDown()
if (loot_entity && loot_entity->entity_type == ET_Loot) {
((Loot*)loot_entity)->bullet_num = tank_weapon.ammo;
}
room->UpdateCarObject(skin_tank.tank_uniid, entity_uniid, pos);
room->TakeOffCarObject(entity_uniid, pos);
skin_tank = Skin();
skin_tank_meta = nullptr;
tank_weapon = Weapon();
RecalcSelfCollider();
SyncAroundPlayers();
@ -2326,7 +2329,7 @@ void Human::ProcLootSkin(Loot* entity, MetaData::Equip* item_meta)
Entity* loot_entity = room->GetEntityByUniId(entity_uniid);
if (loot_entity && loot_entity->entity_type == ET_Loot) {
((Loot*)loot_entity)->bullet_num = tank_weapon.ammo;
room->UpdateCarObject(skin_tank.tank_uniid, entity_uniid);
room->UpdateCarObject(skin_tank.tank_uniid, loot_entity->entity_uniid, loot_entity->pos);
}
}
skin_tank.tank_uniid = entity->entity_uniid;
@ -2346,6 +2349,7 @@ void Human::ProcLootSkin(Loot* entity, MetaData::Equip* item_meta)
RecalcSelfCollider();
RecalcBuff();
SyncAroundPlayers();
room->TakeOnCarObject(skin_tank.tank_uniid);
room->NotifyUiUpdate();
room->frame_event.AddTankBulletNumChg(this);
} else {

View File

@ -358,10 +358,9 @@ void Room::CreateThings()
if (loot_entity && loot_entity->entity_type == ET_Loot) {
((Loot*)loot_entity)->bullet_num = equip_meta->i->clip_volume();
CarObject car;
car.car_uniid = loot_entity->entity_uniid;
car.car_id = equip_meta->i->id();
car.pos = loot_entity->pos;
car_hash_[car.car_uniid] = car;
car_hash_[loot_entity->entity_uniid] = car;
}
}
}
@ -1402,17 +1401,34 @@ void Room::NotifyUiUpdate()
&xtimer_attacher.timer_list_);
}
void Room::UpdateCarObject(int old_uniid, int new_uniid)
void Room::UpdateCarObject(int old_uniid, int new_uniid, a8::Vec2 pos)
{
auto itr = car_hash_.find(old_uniid);
if (itr != car_hash_.end()) {
CarObject new_obj = itr->second;
new_obj.car_uniid = new_uniid;
new_obj.pos = pos;
car_hash_[new_uniid] = new_obj;
car_hash_.erase(old_uniid);
}
}
void Room::TakeOnCarObject(int car_uniid)
{
auto itr = car_hash_.find(car_uniid);
if (itr != car_hash_.end()) {
itr->second.taken = true;
}
}
void Room::TakeOffCarObject(int car_uniid, a8::Vec2 pos)
{
auto itr = car_hash_.find(car_uniid);
if (itr != car_hash_.end()) {
itr->second.pos = pos;
itr->second.taken = false;
}
}
void Room::NotifyWxVoip()
{
xtimer.AddDeadLineTimerAndAttach(0,

View File

@ -93,7 +93,9 @@ public:
float& new_x, float& new_y);
void FillSMUiUpdate(cs::SMUiUpdate& msg);
void NotifyUiUpdate();
void UpdateCarObject(int old_uniid, int new_uniid);
void UpdateCarObject(int old_uniid, int new_uniid, a8::Vec2 pos);
void TakeOnCarObject(int car_uniid);
void TakeOffCarObject(int car_uniid, a8::Vec2 pos);
private:
int AllocUniid();

View File

@ -113,7 +113,6 @@ struct HumanAbility
struct CarObject
{
int car_uniid = 0;
int car_id = 0;
a8::Vec2 pos;
bool taken = false;