public void Open(byte newContainerIndex, Item container, ItemStructure strucc, bool childContainer = true)
        {
            var builder = new PacketBuilder(Packets.SendToClient.OpenContainer);
            builder.AddU8(newContainerIndex); // container index
            builder.AddU16(container.Id); // container look id? the one identifying the container
            builder.AddString(strucc.Name);
            builder.AddU8(strucc.ContainerSize);
            builder.AddU8((byte)(childContainer ? 1 : 0)); // 0 == root container, 1 == child container
            var inside = container.Inside;
            if (inside == null)
            {
                builder.AddU8(0);
            }
            else
            {
                builder.AddU8((byte) inside.Count);
                for (int i = 0; i < inside.Count; i++)
                {
                    builder.AddItem(inside[i]);
                }
            }

            _player.OpenContainer(container);

            builder.Send(_player);
        }
Ejemplo n.º 2
0
        private static void NewMethod1(Player player, Item item, ItemStructure strucc)
        {
            var builder = new PacketBuilder(Packets.SendToClient.OpenContainer);

            builder.AddU8(0);        // container index
            builder.AddU16(item.Id); // container look id? the one identifying the container
            builder.AddString(strucc.Name);
            builder.AddU8(strucc.ContainerSize);
            builder.AddU8(0); // root container, 1 == child container
            var inside = player.Equipment.Backpack.Inside;

            if (inside == null)
            {
                builder.AddU8(0);
            }
            else
            {
                builder.AddU8((byte)inside.Count);
                for (int i = 0; i < inside.Count; i++)
                {
                    builder.AddItem(inside[i]);
                }
            }

            player.OpenContainer(player.Equipment.Backpack);

            builder.Send(player);
        }
Ejemplo n.º 3
0
        public void ItemAppear(Position pos, Item item)
        {
            var builder = new PacketBuilder();

            builder.AddPacketId(Packets.SendToClient.ItemOrCreatureAppearOnTile);
            builder.AddPosition(pos);
            builder.AddItem(item);
            builder.Send(_player);
        }
Ejemplo n.º 4
0
        public void Legs(Item item)
        {
            if (item.Id == 0)
            {
                return;
            }
            var builder = new PacketBuilder(Packets.SendToClient.FillEquipmentSlot);

            builder.AddU8((byte)EquipmentSlots.Legs);
            builder.AddItem(item);
            builder.Send(_player);
            _player.Equipment.Legs = item;
        }
Ejemplo n.º 5
0
        private void AddTileDescriptionToBuilder(PacketBuilder builder, Tile tile, bool isStep)
        {
            var count = 0;

            if (tile.Ground != null)
            {
                builder.AddItem(tile.Ground);
                count++;
            }

            if (tile.Items?.Count > 0)
            {
                for (int i = tile.Items.Count - 1; i > -1 && count < 10; i--)
                {
                    builder.AddItem(tile.Items[i]);
                    count++;
                }
            }

            var creatures = IoC.Game.GetCreaturesOnTile(tile.Position);

            if (creatures == null)
            {
                return;
            }
            for (int i = 0; i < creatures.Count && count < 10; i++)
            {
                if (creatures[i].Id == _player.Id && isStep)
                {
                    builder.AddPlayerMove(_player);
                }
                else
                {
                    builder.AddCreature(_player, creatures[i]);
                }
                count++;
            }
        }