2021-04-08 20:09:59 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace ET
|
|
|
|
|
{
|
|
|
|
|
[ActorMessageHandler]
|
|
|
|
|
public class C2M_DropItemHandler : AMActorLocationRpcHandler<Unit, C2M_DropItem, M2C_DropItem>
|
|
|
|
|
{
|
|
|
|
|
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<UserSetting>();
|
|
|
|
|
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<MainUISlot>(setting);
|
|
|
|
|
setting.UpdateMainUISlot(slotIndex, mainUISlot);
|
|
|
|
|
}
|
|
|
|
|
if (bagIndex == -1)
|
|
|
|
|
{
|
|
|
|
|
mainUISlot.MainUIType = MainUIType.NoneSlot;
|
|
|
|
|
MainUIHelper.GetMainUISlotInfo(setting, response.MainUISlotList);
|
|
|
|
|
reply();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Bag bag = unit.GetComponent<Bag>();
|
2021-04-11 19:50:39 +08:00
|
|
|
|
if (!bag.ItemDic.TryGetValueByKey1(bagIndex, out Item item))
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|