49 lines
1.4 KiB
C#
49 lines
1.4 KiB
C#
namespace ET.Server
|
|
{
|
|
[FriendOf(typeof(BagComponent))]
|
|
public static class BagNoticeHelper
|
|
{
|
|
public static void NotifyItemChange(Player player, ItemUnit unit)
|
|
{
|
|
Session session = player?.GetComponent<PlayerSessionComponent>()?.Session;
|
|
if (session == null || unit == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
Item_ItemInfo notice = Item_ItemInfo.Create();
|
|
notice.item = BagMapper.ToProto(unit);
|
|
session.Send(notice);
|
|
}
|
|
|
|
public static void NotifyItemRemove(Player player, long itemIndex)
|
|
{
|
|
Session session = player?.GetComponent<PlayerSessionComponent>()?.Session;
|
|
if (session == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
Item_RemoveItem notice = Item_RemoveItem.Create();
|
|
notice.itemIndex = itemIndex;
|
|
session.Send(notice);
|
|
}
|
|
|
|
public static void NotifyItemList(Session session, BagComponent bag)
|
|
{
|
|
if (session == null || bag == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
Item_ItemInfoList list = Item_ItemInfoList.Create();
|
|
foreach (EntityRef<ItemUnit> unitRef in bag.ItemMap.Values)
|
|
{
|
|
ItemUnit unit = unitRef;
|
|
list.items.Add(BagMapper.ToProto(unit));
|
|
}
|
|
session.Send(list);
|
|
}
|
|
}
|
|
}
|