This commit is contained in:
aozhiwei 2024-10-11 15:43:35 +08:00
parent cb9f7905e9
commit b48122e8e9
3 changed files with 20 additions and 1 deletions

View File

@ -1,6 +1,8 @@
#include "precompile.h"
#include "bag.h"
#include "human.h"
#include "room.h"
#include "mt/Equip.h"
@ -8,7 +10,7 @@ const static int TEST_CD_TIME = 5;
int BagItem::GetCdTime(Human* hum)
{
return std::max(0.0f, (TEST_CD_TIME * SERVER_FRAME_RATE - (hum->room->GetFrameNo() - last_use_tick)) * FRAME_RATE_MS);
}
void Bag::Parse(const std::list<int>& items)

View File

@ -26,6 +26,10 @@ class Bag
std::shared_ptr<BagItem> GetItemById(int equip_id);
private:
void InternalPushBagInfo();
private:
Human* owner_ = nullptr;
std::map<int, std::shared_ptr<BagItem>> items_;
};

View File

@ -2961,6 +2961,19 @@ void Bag::UseItem(int equip_id)
}
void Bag::PushBagInfo()
{
owner_->room->xtimer.SetTimeoutEx
(500 / FRAME_RATE_MS,
[this] (int event, const a8::Args* args)
{
if (a8::TIMER_EXEC_EVENT == event) {
owner_->GetBag()->InternalPushBagInfo();
}
},
&owner_->xtimer_attacher);
}
void Bag::InternalPushBagInfo()
{
cs::SMPushBag notify_msg;
for (auto& pair : items_) {