using MongoDB.Bson.Serialization.IdGenerators; using System; namespace ET { [ActorMessageHandler] public class C2M_UseGoodsHandler : AMActorLocationRpcHandler { protected override async ETTask Run(Unit unit, C2M_UseGoods request, M2C_UseGoods response, Action reply) { int index = request.Index; (string, int) ret =await ItemComponent.Instance.UseGoods(unit,index: index); if (ret.Item1 != null) { response.Message = ret.Item1; reply(); return; } UserSetting userSetting = unit.GetComponent(); foreach (MainUISlot 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; } } }