添加道具获取通知
This commit is contained in:
parent
0853244c99
commit
79c355239c
@ -2243,6 +2243,13 @@ void Human::AddItem(int item_id, int item_num)
|
|||||||
#if 0
|
#if 0
|
||||||
room->frame_event.AddItemChg(GetWeakPtrRef(), item_id, items_[item_id]);
|
room->frame_event.AddItemChg(GetWeakPtrRef(), item_id, items_[item_id]);
|
||||||
#endif
|
#endif
|
||||||
|
if (IsPlayer()) {
|
||||||
|
cs::SMGetItemNotify notify_msg;
|
||||||
|
auto pair = notify_msg.add_items();
|
||||||
|
pair->set_key(item_id);
|
||||||
|
pair->set_value(item_num);
|
||||||
|
SendNotifyMsg(notify_msg);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (item_num <= 0) {
|
if (item_num <= 0) {
|
||||||
battling_items_.insert(item_id);
|
battling_items_.insert(item_id);
|
||||||
|
@ -481,6 +481,7 @@ void Player::ProcInteraction()
|
|||||||
if (HasBuffEffect(kBET_Jump)) {
|
if (HasBuffEffect(kBET_Jump)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
cs::SMGetItemNotify notify_msg;
|
||||||
for (auto obj_id : interaction_objids) {
|
for (auto obj_id : interaction_objids) {
|
||||||
Entity* entity = room->GetEntityByUniId(obj_id);
|
Entity* entity = room->GetEntityByUniId(obj_id);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -504,7 +505,26 @@ void Player::ProcInteraction()
|
|||||||
if (entity->GetPos().Distance(GetPos()) > 150) {
|
if (entity->GetPos().Distance(GetPos()) > 150) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
LootInteraction((Loot*)entity);
|
Loot* loot = (Loot*)entity;
|
||||||
|
int old_count = loot->count;
|
||||||
|
LootInteraction(loot);
|
||||||
|
if (loot->pickuped || loot->count < old_count) {
|
||||||
|
bool real_get_count = loot->count < old_count ? old_count - loot->count : loot->count;
|
||||||
|
bool found = false;
|
||||||
|
for (int i = 0; i < notify_msg.items().size(); ++i) {
|
||||||
|
auto pair = notify_msg.mutable_items(i);
|
||||||
|
if (pair->key() == loot->item_id) {
|
||||||
|
pair->set_value(pair->value() + real_get_count);
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
auto pair = notify_msg.add_items();
|
||||||
|
pair->set_key(loot->item_id);
|
||||||
|
pair->set_value(real_get_count);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ET_Player:
|
case ET_Player:
|
||||||
@ -524,6 +544,9 @@ void Player::ProcInteraction()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
interaction_objids.Clear();
|
interaction_objids.Clear();
|
||||||
|
if (notify_msg.items().size() > 0) {
|
||||||
|
SendNotifyMsg(notify_msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::ObstacleInteraction(Obstacle* entity)
|
void Player::ObstacleInteraction(Obstacle* entity)
|
||||||
|
@ -55,4 +55,5 @@ enum SMMessageId_e
|
|||||||
_SMShowCountdown = 1015;
|
_SMShowCountdown = 1015;
|
||||||
_SMShowTeamUI = 1016;
|
_SMShowTeamUI = 1016;
|
||||||
_SMUpdateMatchInfo = 1017;
|
_SMUpdateMatchInfo = 1017;
|
||||||
|
_SMGetItemNotify = 1018;
|
||||||
}
|
}
|
||||||
|
@ -1336,3 +1336,9 @@ message SMUpdateMatchInfo
|
|||||||
{
|
{
|
||||||
optional MFMatchInfo info = 1; //匹配信息
|
optional MFMatchInfo info = 1; //匹配信息
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//获得物品
|
||||||
|
message SMGetItemNotify
|
||||||
|
{
|
||||||
|
repeated MFPair items = 8; //key:道具id value:数量
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user