This commit is contained in:
aozhiwei 2023-05-06 14:03:58 +08:00
parent faa6633869
commit f810b71997
6 changed files with 17 additions and 20 deletions

View File

@ -325,7 +325,7 @@ void Buff::ProcSputteringFunc(Bullet* bullet)
0, 0,
0, 0,
nullptr); nullptr);
VirtualBullet* p = new VirtualBullet(); std::shared_ptr<VirtualBullet> p = std::make_shared<VirtualBullet>();
p->bullet_uniid = bullet_uniid; p->bullet_uniid = bullet_uniid;
p->weapon_uniid = bullet->weapon_uniid; p->weapon_uniid = bullet->weapon_uniid;
p->skill_meta = bullet->skill_meta; p->skill_meta = bullet->skill_meta;
@ -339,7 +339,12 @@ void Buff::ProcSputteringFunc(Bullet* bullet)
p->born_pos = bullet_born_pos; p->born_pos = bullet_born_pos;
p->born_dir = bullet_dir; p->born_dir = bullet_dir;
p->Init(); p->Init();
owner->room->AddTask(bullet_uniid, p); owner->room->AddTask(bullet_uniid, std::make_shared<a8::CommonCbProcEx>
(
[p] (const a8::Args* args)
{
p->Update(50);
}));
} }
} }

View File

@ -162,6 +162,7 @@ void Room::UnInit()
delete pair.second; delete pair.second;
} }
discard_team_hash_.clear(); discard_team_hash_.clear();
task_hash_.clear();
A8_SAFE_DELETE(frame_event_data); A8_SAFE_DELETE(frame_event_data);
PerfMonitor::Instance()->alive_count -= alive_count_; PerfMonitor::Instance()->alive_count -= alive_count_;
} }
@ -194,9 +195,7 @@ void Room::Update(int delta_time)
pair.second->Update(50); pair.second->Update(50);
} }
for (auto& pair : task_hash_) { for (auto& pair : task_hash_) {
if (!pair.second->IsDone()) { (*pair.second)(nullptr);
pair.second->Update(50);
}
} }
#ifdef DEBUG1 #ifdef DEBUG1
end_tick = a8::XGetTickCount(); end_tick = a8::XGetTickCount();
@ -3488,12 +3487,12 @@ bool Room::IsAllRealDead()
return is_all_dead; return is_all_dead;
} }
void Room::AddTask(int task_uniid, ITask* task) void Room::AddTask(int task_uniid, std::shared_ptr<a8::CommonCbProcEx> cb)
{ {
if (task_hash_.find(task_uniid) != task_hash_.end()) { if (task_hash_.find(task_uniid) != task_hash_.end()) {
abort(); abort();
} }
task_hash_[task_uniid] = task; task_hash_[task_uniid] = cb;
} }
void Room::RemoveTask(int task_uniid) void Room::RemoveTask(int task_uniid)

View File

@ -223,7 +223,7 @@ public:
bool IsInfiniteBulletMode() { return infinite_bullet_mode_; }; bool IsInfiniteBulletMode() { return infinite_bullet_mode_; };
void AddToPostBattleAutoFreeList(a8::XTimerWp timer); void AddToPostBattleAutoFreeList(a8::XTimerWp timer);
bool CanAddObstacle(const glm::vec3& pos, int obstacle_id); bool CanAddObstacle(const glm::vec3& pos, int obstacle_id);
void AddTask(int task_uniid, ITask* task); void AddTask(int task_uniid, std::shared_ptr<a8::CommonCbProcEx> cb);
void RemoveTask(int task_uniid); void RemoveTask(int task_uniid);
const mt::AirLine* GetAirLine() { return airline_; } const mt::AirLine* GetAirLine() { return airline_; }
int GetPolyExtFlag(int poly_idx); int GetPolyExtFlag(int poly_idx);
@ -373,7 +373,7 @@ private:
std::map<int, Human*> alive_player_hash_; std::map<int, Human*> alive_player_hash_;
std::map<int, Human*> last_human_hash_; std::map<int, Human*> last_human_hash_;
std::map<int, std::shared_ptr<BornPoint>> born_point_hash_; std::map<int, std::shared_ptr<BornPoint>> born_point_hash_;
std::map<int, ITask*> task_hash_; std::map<int, std::shared_ptr<a8::CommonCbProcEx>> task_hash_;
std::map<int, CarObject> car_hash_; std::map<int, CarObject> car_hash_;
std::map<int, Human*> removed_robot_hash_; std::map<int, Human*> removed_robot_hash_;

View File

@ -37,13 +37,6 @@ struct BulletCheckResult
std::set<Entity*> objects; std::set<Entity*> objects;
}; };
class ITask
{
public:
virtual void Update(int delta_time) = 0;
virtual bool IsDone() = 0;
};
class DelayAddBuffHandle class DelayAddBuffHandle
{ {
public: public:

View File

@ -4,7 +4,7 @@ struct GridCell;
class Entity; class Entity;
class Room; class Room;
class Obstacle; class Obstacle;
class VirtualBullet : public IBullet, public ITask class VirtualBullet : public IBullet
{ {
public: public:
int bullet_uniid = 0; int bullet_uniid = 0;
@ -35,8 +35,8 @@ class VirtualBullet : public IBullet, public ITask
virtual float GetHitRadius() override; virtual float GetHitRadius() override;
virtual void ProcRequestBulletDmg(int shield_hit, int strength_wall_uniid, int target_uniid, const glm::vec3& pos) override; virtual void ProcRequestBulletDmg(int shield_hit, int strength_wall_uniid, int target_uniid, const glm::vec3& pos) override;
virtual void Update(int delta_time) override; virtual void Update(int delta_time);
virtual bool IsDone() override; virtual bool IsDone();
void Init(); void Init();
void SetPos(Position pos) { pos_ = pos; }; void SetPos(Position pos) { pos_ = pos; };

2
third_party/a8 vendored

@ -1 +1 @@
Subproject commit 54fe50edf11dda774dcd6fc480134c9e4ce449cd Subproject commit 140a61cc7f6c23602d05963ab868fe9f5d36cc44