示例#1
0
 public static SayItemPacket GenerateSayItemPacket(this IPlayerEntity player, string prefix, string message, ItemInstanceDto item)
 {
     return(new SayItemPacket
     {
         CharacterName = player.Character.Name,
         GlobalPrefix = prefix,     // todo i18n
         ItemName = item.Item.Name, // todo i18n
         OratorSlot = 0,            // looks like bullshit and useless
         VisualId = player.Id,
         VisualType = player.Type,
         Message = message.Replace(' ', '^'),
         ItemData = new SayItemPacket.SayItemSubPacket
         {
             IconId = item.Item.Type == InventoryType.Equipment ? (long?)null : item.ItemId,
             EquipmentInfo = item.Item.Type == InventoryType.Equipment ? item.GenerateEInfoPacket() : null
         },
     });
 }
示例#2
0
        protected override async Task Handle(InventoryEqInfoEvent eqInfo, CancellationToken cancellation)
        {
            if (!(eqInfo.Sender is IPlayerEntity playerEntity))
            {
                return;
            }

            InventoryComponent inventory = playerEntity.Inventory;

            ItemInstanceDto[] subInv;
            ItemInstanceDto   itemInstance = null;

            switch (eqInfo.Type)
            {
            case 0:
                subInv = inventory.GetSubInvFromInventoryType(InventoryType.Wear);
                if (eqInfo.Slot > subInv.Length)
                {
                    return;
                }

                itemInstance = subInv[eqInfo.Slot];
                break;

            case 1:
                subInv = inventory.GetSubInvFromInventoryType(InventoryType.Equipment);
                if (eqInfo.Slot > subInv.Length)
                {
                    return;
                }

                itemInstance = subInv[eqInfo.Slot];
                break;

            case 7:
            case 10:
                subInv = inventory.GetSubInvFromInventoryType(InventoryType.Specialist);
                if (eqInfo.Slot > subInv.Length)
                {
                    return;
                }

                itemInstance = subInv[eqInfo.Slot];
                break;

            case 11:
                subInv = inventory.GetSubInvFromInventoryType(InventoryType.Costume);
                if (eqInfo.Slot > subInv.Length)
                {
                    return;
                }

                break;
            }

            if (itemInstance == null)
            {
                return;
            }

            if (itemInstance.Item.ItemType == ItemType.Specialist)
            {
                await playerEntity.SendPacketAsync(itemInstance.GenerateSlInfoPacket());

                return;
            }

            await playerEntity.SendPacketAsync(itemInstance.GenerateEInfoPacket());
        }