1
This commit is contained in:
parent
cb9f7905e9
commit
b48122e8e9
@ -1,6 +1,8 @@
|
|||||||
#include "precompile.h"
|
#include "precompile.h"
|
||||||
|
|
||||||
#include "bag.h"
|
#include "bag.h"
|
||||||
|
#include "human.h"
|
||||||
|
#include "room.h"
|
||||||
|
|
||||||
#include "mt/Equip.h"
|
#include "mt/Equip.h"
|
||||||
|
|
||||||
@ -8,7 +10,7 @@ const static int TEST_CD_TIME = 5;
|
|||||||
|
|
||||||
int BagItem::GetCdTime(Human* hum)
|
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)
|
void Bag::Parse(const std::list<int>& items)
|
||||||
|
@ -26,6 +26,10 @@ class Bag
|
|||||||
std::shared_ptr<BagItem> GetItemById(int equip_id);
|
std::shared_ptr<BagItem> GetItemById(int equip_id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void InternalPushBagInfo();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
Human* owner_ = nullptr;
|
Human* owner_ = nullptr;
|
||||||
std::map<int, std::shared_ptr<BagItem>> items_;
|
std::map<int, std::shared_ptr<BagItem>> items_;
|
||||||
};
|
};
|
||||||
|
@ -2961,6 +2961,19 @@ void Bag::UseItem(int equip_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Bag::PushBagInfo()
|
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;
|
cs::SMPushBag notify_msg;
|
||||||
for (auto& pair : items_) {
|
for (auto& pair : items_) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user