38 lines
1.3 KiB
C#
38 lines
1.3 KiB
C#
|
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;
|
|||
|
var ret =await ItemComponent.Instance.UseGoods(unit,index: index);
|
|||
|
if (ret.Item1 != null)
|
|||
|
{
|
|||
|
response.Message = ret.Item1;
|
|||
|
reply();
|
|||
|
return;
|
|||
|
}
|
|||
|
UserSetting userSetting = unit.GetComponent<UserSetting>();
|
|||
|
foreach (var mainUISlot in userSetting.GetMainUISlots())
|
|||
|
{
|
|||
|
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;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|