GetEntityType() public static method

public static GetEntityType ( System.Entity e ) : EntityType
e System.Entity
return EntityType
Example #1
0
        /// <summary>
        ///     Draw a specified entity
        /// </summary>
        /// <param name="e">The entity to draw</param>
        private void DrawEntity(Entity e)
        {
            if (!e.IsOnScreen || e.IsOccluded)
            {
                return;
            }

            var textScale = .25f;

            //Set text color
            var c = Color.FromArgb(150, Color.White);

            if (_selectedEntity != null && e.Equals(_selectedEntity))
            {
                c = Color.Red;
            }
            else
            {
                switch (GTAFuncs.GetEntityType(e))
                {
                case GTAFuncs.EntityType.Ped:
                    c = new Ped(e.Handle).IsPlayer
                            ? Color.FromArgb(150, Color.CornflowerBlue)
                            : Color.FromArgb(150, Color.Yellow);
                    break;

                case GTAFuncs.EntityType.Vehicle:
                    c = Color.FromArgb(150, Color.DeepPink);
                    break;

                case GTAFuncs.EntityType.Prop:
                    c = Color.FromArgb(150, Color.Green);
                    break;
                }
            }

            //Create entity info lines
            var lines = new List <string>();

            switch (GTAFuncs.GetEntityType(e))
            {
            case GTAFuncs.EntityType.Ped:
                Ped ped = new Ped(e.Handle);
                if (ped.IsPlayer)
                {
                    Player pl = GTAFuncs.GetPedPlayer(ped);
                    lines.Add(pl.Name);
                    lines.Add("Player #" + pl.Handle);
                    if (GTAFuncs.GetPlayerInvincible(pl))
                    {
                        lines.Add("INVINCIBLE");
                    }
                }
                lines.Add("Ped #" + ped.Handle);
                e = ped;
                break;

            case GTAFuncs.EntityType.Vehicle:
                Vehicle v = new Vehicle(e.Handle);
                lines.Add("Vehicle #" + v.Handle);
                lines.Add(v.FriendlyName);
                lines.Add(v.DisplayName);
                e = v;
                break;

            case GTAFuncs.EntityType.Prop:
                Prop prop = new Prop(e.Handle);
                lines.Add("Prop #" + prop.Handle);
                lines.Add("Model: " + prop.Model.Hash);
                e = prop;
                break;

            default:
                lines.Add("Entity #" + e.Handle);
                break;
            }

            Entities.Add(e.Handle, e);

            //Draw entity info
            var screenPos = GTAFuncs.WorldToScreen(e.Position);
            var contain   =
                new Rectangle(
                    new Point((int)screenPos.X,
                              (int)screenPos.Y + (GTAFuncs.GetEntityType(e) == GTAFuncs.EntityType.Ped && new Ped(e.Handle).IsInVehicle() ? lines.Count * -10 : 0)),
                    new Size(50, (lines.Count * 11) - 1));

            for (var i = 0; i < lines.Count; i++)
            {
                GTAFuncs.SetTextDropShadow(2, Color.FromArgb(255, 0, 0, 0));
                new UIText(lines[i], new Point(0, (i * 10)), textScale, Color.FromArgb(255, c), 0, true).Draw(
                    new Size(contain.Location));
                GTAFuncs.SetTextDropShadow(0, Color.Transparent);
            }

            EntityClickBoxes.Add(e, contain);
            DrawEntBox(e, c);
        }
        private void OnTick(object sender, EventArgs e)
        {
            if (Game.Player.Character.IsInVehicle() || Game.Player.Character.IsSittingInVehicle())
            {
                var v = Game.Player.Character.CurrentVehicle;
                if (_godEnabled)
                {
                    v = new Vehicle(GTAFuncs.RequestEntityControl(v).Handle);
                    if (v != null)
                    {
                        v.BodyHealth          = v.MaxHealth;
                        v.EngineHealth        = v.MaxHealth;
                        v.PetrolTankHealth    = v.MaxHealth;
                        v.Health              = v.MaxHealth;
                        v.CanBeVisiblyDamaged = false;
                    }
                    GTAFuncs.SetEntityInvinc(v, true);
                }
                else
                {
                    GTAFuncs.SetEntityInvinc(v, false);
                }
            }

            if (_godEnabled)
            {
                Game.Player.Character.Health = Game.Player.Character.MaxHealth;
            }

            GTAFuncs.SetInvincTime(_godEnabled ? 30000 : 0);
            GTAFuncs.SetSPInvinc(_player, _godEnabled);

            if (GTAFuncs.IsWaypointActive())
            {
                _lastWaypoint = new Blip(GTAFuncs.GetFirstBlipInfoID((int)BlipSprite.Waypoint));
            }

            if (_noClipEnabled)
            {
                Game.Player.Character.Rotation = GameplayCamera.Rotation;

                GTAFuncs.SetEntityGravity(Game.Player.Character, false);
                GTAFuncs.SetEntityLoadColissionFlag(Game.Player.Character, false);
                GTAFuncs.SetEntityRecordsCollisions(Game.Player.Character, false);
                GTAFuncs.SetEntityCollision(Game.Player.Character, false, false);
                GTAFuncs.DisableControlAction(Control.MoveUp, true);
                GTAFuncs.DisableControlAction(Control.MoveDown, true);
                GTAFuncs.DisableControlAction(Control.MoveLeft, true);
                GTAFuncs.DisableControlAction(Control.MoveRight, true);
                GTAFuncs.DisableControlAction(Control.Attack, true);
                GTAFuncs.DisableControlAction(Control.Aim, true);

                var v = new Vector3(0, 0, 0);

                if (Game.Player.Character.IsInVehicle() || Game.Player.Character.IsSittingInVehicle())
                {
                    Game.Player.Character.Position = Game.Player.Character.Position;
                }

                if (GTAFuncs.GetControlNormal(Control.MoveUp) != 0)
                {
                    v += Vector3.Multiply(Game.Player.Character.ForwardVector,
                                          -25 * GTAFuncs.GetControlNormal(Control.MoveUp));
                }
                if (GTAFuncs.GetControlNormal(Control.MoveRight) != 0)
                {
                    v += Vector3.Multiply(Game.Player.Character.RightVector,
                                          25 * GTAFuncs.GetControlNormal(Control.MoveRight));
                }
                if (GTAFuncs.IsControlPressed(Control.Attack))
                {
                    v += Vector3.Multiply(Game.Player.Character.UpVector, 15);
                }
                if (GTAFuncs.IsControlPressed(Control.Aim))
                {
                    v += Vector3.Multiply(Game.Player.Character.UpVector, -15);
                }

                Game.Player.Character.Velocity = v;
            }
            else
            {
                GTAFuncs.EnableControlAction(Control.MoveUp, true);
                GTAFuncs.EnableControlAction(Control.MoveDown, true);
                GTAFuncs.EnableControlAction(Control.MoveLeft, true);
                GTAFuncs.EnableControlAction(Control.MoveRight, true);
                GTAFuncs.EnableControlAction(Control.Attack, true);
                GTAFuncs.EnableControlAction(Control.Aim, true);
                GTAFuncs.SetEntityGravity(Game.Player.Character, true);
                GTAFuncs.SetEntityLoadColissionFlag(Game.Player.Character, true);
                GTAFuncs.SetEntityRecordsCollisions(Game.Player.Character, true);
                GTAFuncs.SetEntityCollision(Game.Player.Character, true, true);
            }

            if (_forceFieldEnabled)
            {
                GTAFuncs.ClearAreaOfObjects(Game.Player.Character.Position, 100);
                GTAFuncs.ClearAreaOfProjectiles(Game.Player.Character.Position, 100);

                foreach (var _ent in World.GetAllEntities())
                {
                    var ent = _ent;
                    if (ent.Handle == Game.Player.Character.Handle || GTAFuncs.GetPlayerEntity(Game.Player).Handle == ent.Handle)
                    {
                        continue;
                    }

                    if (ent.Position.DistanceTo(Game.Player.Character.Position) <= 100)
                    {
                        if (GTAFuncs.GetEntityType(ent) == GTAFuncs.EntityType.Ped && new Ped(ent.Handle).IsPlayer)
                        {
                            Player player = GTAFuncs.GetPedPlayer(new Ped(ent.Handle));
                            ent = GTAFuncs.RequestEntityControl(player, 1);
                            GTAFuncs.ActivateDamageTrackerOnNetworkId(GTAFuncs.GetNetworkID(player), true);
                        }
                        else
                        {
                            GTAFuncs.RequestEntityControl(ent, 1);
                        }

                        if (ent.IsAttached())
                        {
                            ent.Detach();
                            ent.Delete();
                        }
                        else
                        {
                            GTAFuncs.SetEntityInvinc(ent, false);
                            Vector3 vel = (Game.Player.Character.Position - ent.Position);
                            vel.Normalize();
                            vel         *= -1000;
                            ent.Velocity = vel + new Vector3(0, 0, 100);
                        }
                    }
                }
            }

            if (_developerConsole.Debug && ConsoleSettings.IsDevBuild)
            {
                GTAFuncs.AntiBan();
            }
        }