添加子弹数量流量优化
This commit is contained in:
parent
9accc9a0ee
commit
79a54df690
@ -169,7 +169,8 @@ enum PropertyType_e
|
||||
kPropHp = 1,
|
||||
kPropMaxHp = 2,
|
||||
kPropTankBulletNum = 6,
|
||||
kPropTankOil = 7
|
||||
kPropTankOil = 7,
|
||||
kPropBulletNum = 8
|
||||
};
|
||||
|
||||
enum MapObjectType_e
|
||||
|
@ -138,6 +138,13 @@ void FrameEvent::AddExplosionEx(Human* sender, int item_id, a8::Vec2 bomb_pos, i
|
||||
}
|
||||
}
|
||||
|
||||
void FrameEvent::AddBulletNumChg(Human* hum)
|
||||
{
|
||||
chged_bullet_nums_.push_back(hum);
|
||||
int idx = chged_bullet_nums_.size() - 1;
|
||||
hum->chged_bullet_nums_.push_back(idx);
|
||||
}
|
||||
|
||||
void FrameEvent::AddTankBulletNumChg(Human* hum)
|
||||
{
|
||||
chged_tank_bullet_nums_.push_back(hum);
|
||||
@ -211,6 +218,9 @@ void FrameEvent::Clear()
|
||||
if (airdrops_.size() > 0) {
|
||||
airdrops_.Clear();
|
||||
}
|
||||
if (!chged_bullet_nums_.empty()) {
|
||||
chged_bullet_nums_.clear();
|
||||
}
|
||||
if (!chged_tank_bullet_nums_.empty()) {
|
||||
chged_tank_bullet_nums_.clear();
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ public:
|
||||
void AddExplosion(Bullet* bullet, int item_id, a8::Vec2 bomb_pos);
|
||||
void AddSmoke(Bullet* bullet, int item_id, a8::Vec2 pos);
|
||||
void AddExplosionEx(Human* sender, int item_id, a8::Vec2 bomb_pos, int effect);
|
||||
void AddBulletNumChg(Human* hum);
|
||||
void AddTankBulletNumChg(Human* hum);
|
||||
void AddTankOilValueChg(Human* hum);
|
||||
void AddTankOilMaxChg(Human* hum);
|
||||
@ -27,6 +28,7 @@ private:
|
||||
std::vector<std::tuple<Human*, ::cs::MFExplosion>> explosions_;
|
||||
std::vector<std::tuple<Human*, ::cs::MFSmoke>> smokes_;
|
||||
std::vector<std::tuple<Human*, ::cs::MFEmote>> emotes_;
|
||||
std::vector<Human*> chged_bullet_nums_;
|
||||
std::vector<Human*> chged_tank_bullet_nums_;
|
||||
std::vector<Human*> chged_tank_oil_value_;
|
||||
std::vector<Human*> chged_tank_oil_max_;
|
||||
|
@ -83,6 +83,17 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(const Human* hum)
|
||||
}
|
||||
}
|
||||
}
|
||||
for (size_t idx : hum->chged_bullet_nums_) {
|
||||
if (idx < room->frame_event.chged_bullet_nums_.size()) {
|
||||
Human* target = room->frame_event.chged_bullet_nums_[idx];
|
||||
if (target->curr_weapon) {
|
||||
auto p = msg->add_chged_property_list();
|
||||
p->set_obj_id(target->entity_uniid);
|
||||
p->set_property_type(kPropBulletNum);
|
||||
p->set_value(target->curr_weapon->ammo);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (size_t idx : hum->chged_tank_bullet_nums_) {
|
||||
if (idx < room->frame_event.chged_tank_bullet_nums_.size()) {
|
||||
Human* target = room->frame_event.chged_tank_bullet_nums_[idx];
|
||||
|
@ -320,7 +320,9 @@ void Human::Shot(a8::Vec2& target_dir)
|
||||
break;
|
||||
}
|
||||
last_shot_frameno_ = room->frame_no;
|
||||
need_sync_active_player = true;
|
||||
if (!need_sync_active_player) {
|
||||
room->frame_event.AddBulletNumChg(this);
|
||||
}
|
||||
}
|
||||
|
||||
void Human::TankShot(a8::Vec2& target_dir)
|
||||
@ -2000,6 +2002,9 @@ void Human::ClearFrameData()
|
||||
if (!emotes_.empty()) {
|
||||
emotes_.clear();
|
||||
}
|
||||
if (!chged_bullet_nums_.empty()) {
|
||||
chged_bullet_nums_.clear();
|
||||
}
|
||||
if (!chged_tank_bullet_nums_.empty()) {
|
||||
chged_tank_bullet_nums_.clear();
|
||||
}
|
||||
|
@ -256,6 +256,7 @@ protected:
|
||||
std::vector<int> smokes_;
|
||||
std::vector<int> explosions_;
|
||||
std::set<Human*> observers_;
|
||||
std::vector<int> chged_bullet_nums_;
|
||||
std::vector<int> chged_tank_bullet_nums_;
|
||||
std::vector<int> chged_tank_oil_value_;
|
||||
std::vector<int> chged_tank_oil_max_;
|
||||
|
@ -54,9 +54,6 @@ void Player::Update(int delta_time)
|
||||
UpdateMove();
|
||||
}
|
||||
if (room->frame_no % 2 == 0) {
|
||||
if (shot_start || shot_hold) {
|
||||
UpdateShot();
|
||||
}
|
||||
if (drop_weapon) {
|
||||
UpdateDropWeapon();
|
||||
}
|
||||
@ -99,6 +96,9 @@ void Player::Update(int delta_time)
|
||||
if (get_down) {
|
||||
UpdateGetDown();
|
||||
}
|
||||
if (shot_start || shot_hold) {
|
||||
UpdateShot();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,6 +105,7 @@ message MFVector2D
|
||||
property_type: 6 载具剩余子弹数
|
||||
property_type: 7 载具油量
|
||||
property_subtype: 0(当前油量)1(总油量)) 在同步当前油量前必然同步过总油量!
|
||||
property_type: 8 当前武器的子弹剩余数量
|
||||
*/
|
||||
message MFPropertyChg
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user