1
This commit is contained in:
parent
831dc77165
commit
8800fffed3
@ -326,7 +326,7 @@ void Buff::ProcSputteringFunc(Bullet* bullet)
|
||||
0,
|
||||
0,
|
||||
nullptr);
|
||||
VirtualBullet* p = new VirtualBullet();
|
||||
auto p = std::make_shared<VirtualBullet>();
|
||||
p->bullet_uniid = bullet_uniid;
|
||||
p->weapon_uniid = bullet->weapon_uniid;
|
||||
p->skill_meta = bullet->skill_meta;
|
||||
@ -340,7 +340,14 @@ void Buff::ProcSputteringFunc(Bullet* bullet)
|
||||
p->born_pos = bullet_born_pos;
|
||||
p->born_dir = bullet_dir;
|
||||
p->Init();
|
||||
owner->room->AddTask(bullet_uniid, p);
|
||||
owner->room->AddTask(bullet_uniid, std::make_shared<a8::CommonCbProcEx>
|
||||
(
|
||||
[p] (const a8::Args* args)
|
||||
{
|
||||
if (!p->IsDone()) {
|
||||
p->Update(50);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -230,9 +230,7 @@ void Room::Update(int delta_time)
|
||||
pair.second->Update(50);
|
||||
}
|
||||
for (auto& pair : task_hash_) {
|
||||
if (!pair.second->IsDone()) {
|
||||
pair.second->Update(50);
|
||||
}
|
||||
(*pair.second)(nullptr);
|
||||
}
|
||||
#ifdef DEBUG1
|
||||
end_tick = a8::XGetTickCount();
|
||||
@ -3194,12 +3192,12 @@ bool Room::IsAllRealDead()
|
||||
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()) {
|
||||
abort();
|
||||
}
|
||||
task_hash_[task_uniid] = task;
|
||||
task_hash_[task_uniid] = cb;
|
||||
}
|
||||
|
||||
void Room::RemoveTask(int task_uniid)
|
||||
|
@ -241,7 +241,7 @@ public:
|
||||
bool IsInfiniteBulletMode() { return infinite_bullet_mode_; };
|
||||
void AddToPostBattleAutoFreeList(a8::XTimerWp timer);
|
||||
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);
|
||||
const mt::AirLine* GetAirLine() { return airline_; }
|
||||
int GetPolyExtFlag(int poly_idx);
|
||||
@ -401,7 +401,7 @@ private:
|
||||
std::map<int, Human*> alive_player_hash_;
|
||||
std::map<int, Human*> last_human_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, Human*> removed_robot_hash_;
|
||||
|
@ -103,3 +103,9 @@ typedef std::weak_ptr<struct AttrRuducePtr> AttrRuduceHandle;
|
||||
typedef std::weak_ptr<struct AttrAbsPtr> AttrAbsHandle;
|
||||
typedef std::weak_ptr<struct AttrRatePtr> AttrRateHandle;
|
||||
typedef std::weak_ptr<struct AttrDirectPtr> AttrDirectHandle;
|
||||
|
||||
namespace a8
|
||||
{
|
||||
class Args;
|
||||
typedef std::function<void(const a8::Args*)> CommonCbProcEx;
|
||||
}
|
||||
|
@ -124,6 +124,17 @@ void VirtualBullet::ForceRemove()
|
||||
{
|
||||
if (!later_removed_) {
|
||||
later_removed_ = true;
|
||||
room->xtimer.SetTimeoutEx
|
||||
(
|
||||
1,
|
||||
[room = room, task_uniid = bullet_uniid] (int event, const a8::Args* args)
|
||||
{
|
||||
if (a8::TIMER_EXEC_EVENT == event) {
|
||||
room->RemoveTask(task_uniid);
|
||||
}
|
||||
},
|
||||
&room->xtimer_attacher_
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ struct GridCell;
|
||||
class Entity;
|
||||
class Room;
|
||||
class Obstacle;
|
||||
class VirtualBullet : public IBullet, public ITask
|
||||
class VirtualBullet : public IBullet
|
||||
{
|
||||
public:
|
||||
int bullet_uniid = 0;
|
||||
@ -36,8 +36,8 @@ class VirtualBullet : public IBullet, public ITask
|
||||
virtual void ProcRequestBulletDmg(int shield_hit, int strength_wall_uniid, int target_uniid, const glm::vec3& pos) override;
|
||||
virtual bool NoAdjustPos() override;
|
||||
|
||||
virtual void Update(int delta_time) override;
|
||||
virtual bool IsDone() override;
|
||||
virtual void Update(int delta_time);
|
||||
virtual bool IsDone();
|
||||
|
||||
void Init();
|
||||
void SetPos(Position pos) { pos_ = pos; };
|
||||
|
Loading…
x
Reference in New Issue
Block a user