public static RemoveEntityPacket CreateRemoveEntityPacket(IEnumerable <Element> elements)
    {
        var packet = new RemoveEntityPacket();

        foreach (var element in elements)
        {
            packet.AddEntity(element.Id);
        }

        return(packet);
    }
    private void RelayElementDestroy(Element element)
    {
        if (!(element is Player))
        {
            var packet = new RemoveEntityPacket();
            packet.AddEntity(element.Id);

            var players = this.elementCollection
                          .GetByType <Player>(ElementType.Player)
                          .Where(p => p != element);
            packet.SendTo(players);
        }
    }
示例#3
0
        private void SetupTestEntities(Client client)
        {
            var entitypacket = new AddEntityPacket();

            entitypacket.AddWater(667, (byte)ElementType.Water, null, 0, 0,
                                  null, true, true, new CustomData(), "Test water",
                                  0, new Vector3[] {
                new Vector3(-6, 0, 4), new Vector3(-3, 0, 4),
                new Vector3(-6, 3, 4), new Vector3(-3, 3, 4)
            }, false);
            entitypacket.AddObject(
                668, (byte)ElementType.Object, null, 0, 0,
                null, true, false, new CustomData(), "Test object",
                0, new Vector3(0, -5, 3), Vector3.Zero, 321,
                255, false, null, true, true, null, Vector3.One * 3,
                false, 1000f
                );
            entitypacket.AddBlip(669, (byte)ElementType.Blip, null, 0, 0,
                                 null, true, true, new CustomData(), "Test blip",
                                 0, new Vector3(20, 0, 0), 0, 2500, 56, 1, Color.White);
            entitypacket.AddRadarArea(670, (byte)ElementType.RadarArea, null, 0, 0,
                                      null, true, true, new CustomData(), "Test radar area",
                                      0, new Vector2(0, 0), new Vector2(250, 250), Color.FromArgb(100, Color.DarkGoldenrod), true);
            entitypacket.AddMarker(671, (byte)ElementType.Marker, null, 0, 0,
                                   null, true, true, new CustomData(), "Test marker",
                                   0, new Vector3(5, 0, 2), (byte)MarkerType.Cylinder, 2, Color.FromArgb(100, Color.DarkCyan), null);
            entitypacket.AddPickup(672, (byte)ElementType.Pickup, null, 0, 0,
                                   null, true, true, new CustomData(), "Test pickup",
                                   0, new Vector3(0, 5, 3), 349, true, (byte)PickupType.Weapon, null, null, 25, 0);
            entitypacket.AddPed(673, (byte)ElementType.Ped, null, 0, 0,
                                null, true, true, new CustomData(), "Test ped",
                                0, new Vector3(10, 0, 3), 181, 45, 100, 50, null, null,
                                true, true, true, false, 200, 0, new PedClothing[0], new PedWeapon[0], 0);
            entitypacket.AddWeapon(674, (byte)ElementType.Weapon, null, 0, 0,
                                   null, true, true, new CustomData(), "Test weapon",
                                   0, new Vector3(5, 5, 5), Vector3.Zero, 355, 255, false, null,
                                   true, true, null, Vector3.One, false, 100, (byte)WeaponTargetType.Vector,
                                   null, null, null, new Vector3(10, 10, 5), true, 10, 1, 100, 200,
                                   false, false, true, true, true, true, true, true, true, true,
                                   true, true, true, (byte)WeaponState.Ready, 1000, 50, 666);
            entitypacket.AddVehicle(675, (byte)ElementType.Vehicle, null, 0, 0,
                                    null, true, true, new CustomData(), "Test vehicle",
                                    0, new Vector3(-10, 5, 3), Vector3.Zero, 602, 1000, new Color[] {
                Color.Red, Color.Blue
            }, 0, new VehicleDamage()
            {
                Doors  = new byte[] { 0, 0, 0, 0, 0, 0 },
                Wheels = new byte[] { 0, 0, 0, 0 },
                Panels = new byte[] { 0, 0, 0, 0, 0, 0, 0 },
                Lights = new byte[] { 0, 0, 0, 0 }
            }, 0, 0, null, null, new float[] {
                0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f
            }, new byte[0], "SLIPE", 0, true, false, false, false, false,
                                    false, false, false, false, false, false, true, 200, Color.MediumPurple, null, null);


            entitypacket.AddObject(
                676, (byte)ElementType.Object, null, 0, 0,
                null, true, false, new CustomData(), "Moving test object",
                0, new Vector3(0, -5, 3), Vector3.Zero, 321,
                255, false, null, true, true, new PositionRotationAnimation()
            {
                SourcePosition    = new Vector3(0, -5, 3),
                SourceRotation    = new Vector3(0, 0, 0),
                TargetPosition    = new Vector3(0, 45, 3),
                TargetRotation    = new Vector3(0, 0, 360),
                DeltaRotationMode = true,
                DeltaRotation     = new Vector3(0, 0, 360),
                StartTime         = DateTime.UtcNow,
                EndTime           = DateTime.UtcNow + TimeSpan.FromSeconds(10),
                EasingType        = "Linear"
            }, Vector3.One * 3,
                false, 1000f
                );
            client.SendPacket(entitypacket);

            _ = Task.Run(async() =>
            {
                await Task.Delay(10000);
                var packet = new RemoveEntityPacket();
                packet.AddEntity(676);
                client.SendPacket(packet);
            });
        }