This commit is contained in:
aozhiwei 2022-10-26 14:37:03 +08:00
parent 7cd149d7a7
commit a2dd2d675e
5 changed files with 41 additions and 1 deletions

View File

@ -161,6 +161,9 @@ void Room::Update(int delta_time)
for (auto& pair : moveable_hash_) {
pair.second->Update(50);
}
for (auto& pair : task_hash_) {
pair.second->Update(50);
}
#ifdef DEBUG1
end_tick = a8::XGetTickCount();
if (a8::XGetTickCount() - begin_tick > 1000) {
@ -4142,3 +4145,16 @@ bool Room::IsAllRealDead()
);
return is_all_dead;
}
void Room::AddTask(int task_uniid, ITask* task)
{
if (task_hash_.find(task_uniid) != task_hash_.end()) {
abort();
}
task_hash_[task_uniid] = task;
}
void Room::RemoveTask(int task_uniid)
{
task_hash_.erase(task_uniid);
}

View File

@ -326,6 +326,8 @@ private:
void InternalRemoveObjectLater(Entity* entity, a8::XTimerAttacher& entity_xtimer_attacher);
void OnBattleStart();
void ClearPostBattleAutoFreeList();
void AddTask(int task_uniid, ITask* task);
void RemoveTask(int task_uniid);
#ifdef DEBUG
void InitDebugInfo();
@ -390,6 +392,7 @@ private:
std::map<int, Human*> alive_player_hash_;
std::map<int, Human*> last_human_hash_;
std::map<int, BornPoint> born_point_hash_;
std::map<int, ITask*> task_hash_;
std::map<int, CarObject> car_hash_;
std::map<int, Human*> removed_robot_hash_;

View File

@ -39,3 +39,10 @@ class IBullet
virtual bool IsPreBattleBullet() = 0;
virtual Room* GetRoom() = 0;
};
class ITask
{
public:
virtual void Update(int delta_time) = 0;
virtual bool IsDone() = 0;
};

View File

@ -50,3 +50,13 @@ Room* VirtualBullet::GetRoom()
{
return room;
}
void VirtualBullet::Update(int delta_time)
{
}
bool VirtualBullet::IsDone()
{
return false;
}

View File

@ -7,7 +7,7 @@ namespace MetaData
}
class Room;
class VirtualBullet : public IBullet
class VirtualBullet : public IBullet, public ITask
{
public:
long long weapon_uniid = 0;
@ -29,4 +29,8 @@ class VirtualBullet : public IBullet
virtual bool IsBomb() override;
virtual bool IsPreBattleBullet() override;
virtual Room* GetRoom() override;
virtual void Update(int delta_time) override;
virtual bool IsDone() override;
};