using System; namespace ET { [ActorMessageHandler] public class C2M_DropItemHandler : AMActorLocationRpcHandler { protected override async ETTask Run(Unit unit, C2M_DropItem request, M2C_DropItem response, Action reply) { if (unit.teamState == TeamState.Fight) { response.Message = "战斗中..."; reply(); return; } UserSetting setting = unit.GetComponent(); if (setting == null) { Log.Error("setting == null"); response.Message = "系统错误"; reply(); return; } int slotIndex = request.SlotId; int bagIndex = request.BagIndex; if (!(setting.GetMainUISlot(slotIndex) is MainUISlot mainUISlot)) { mainUISlot = EntityFactory.CreateWithParent(setting); setting.UpdateMainUISlot(slotIndex, mainUISlot); } if (bagIndex == -1) { mainUISlot.MainUIType = MainUIType.NoneSlot; MainUIHelper.GetMainUISlotInfo(setting, response.MainUISlotList); reply(); return; } Bag bag = unit.GetComponent(); if (!bag.ItemDic.TryGetValueByKey1(bagIndex, out Item item)) { Log.Error($"玩家Id={unit.Id}想要获取Index={bagIndex}的背包信息,存在错误"); response.Message = "系统错误!"; reply(); return; } if (item.ItemType != ItemType.GoodsItem) { Log.Error($"玩家Id={unit.Id}想要将Index={bagIndex}的背包物品ItemId = {item.ItemId}类型={item.ItemType}拖入主UI,存在错误"); response.Message = "系统错误!"; reply(); return; } mainUISlot.RealId = item.ItemId; //mainUISlot.BagIndex = bagIndex; mainUISlot.Count = item.Count; mainUISlot.MainUIType = MainUIType.ItemSlot; MainUIHelper.GetMainUISlotInfo(setting, response.MainUISlotList); reply(); await ETTask.CompletedTask; } } }