2021-04-08 20:09:59 +08:00
|
|
|
|
using MongoDB.Bson.Serialization.IdGenerators;
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace ET
|
|
|
|
|
{
|
|
|
|
|
[ActorMessageHandler]
|
|
|
|
|
public class C2M_UseGoodsHandler : AMActorLocationRpcHandler<Unit, C2M_UseGoods, M2C_UseGoods>
|
|
|
|
|
{
|
|
|
|
|
protected override async ETTask Run(Unit unit, C2M_UseGoods request, M2C_UseGoods response, Action reply)
|
|
|
|
|
{
|
|
|
|
|
int index = request.Index;
|
2021-04-11 19:50:39 +08:00
|
|
|
|
(string, int) ret =await ItemComponent.Instance.UseGoods(unit,index: index);
|
2021-04-08 20:09:59 +08:00
|
|
|
|
if (ret.Item1 != null)
|
|
|
|
|
{
|
|
|
|
|
response.Message = ret.Item1;
|
|
|
|
|
reply();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
UserSetting userSetting = unit.GetComponent<UserSetting>();
|
2021-04-11 19:50:39 +08:00
|
|
|
|
foreach (MainUISlot mainUISlot in userSetting.GetMainUISlots())
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
if (mainUISlot?.RealId == ret.Item2)
|
|
|
|
|
{
|
|
|
|
|
mainUISlot.Count--;
|
|
|
|
|
if (mainUISlot.Count <= 0)
|
|
|
|
|
{
|
|
|
|
|
mainUISlot.RealId = 0;
|
|
|
|
|
mainUISlot.MainUIType = MainUIType.NoneSlot;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
BagHelper.GetBagInfo(unit, response.BagMapList);
|
|
|
|
|
MainUIHelper.GetMainUISlotInfo(userSetting, response.MainUISlotList);
|
|
|
|
|
reply();
|
|
|
|
|
await ETTask.CompletedTask;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|