public static WorldToScreen ( Vector3 world ) : System.Vector2 | ||
world | Vector3 | |
return | System.Vector2 |
/// <summary> /// Draw a 2D overlay of the 3D rectangle debug /// </summary> /// <param name="c">The color of the debug overlay</param> /// <returns>The current rectangle instance</returns> public Rectangle3D DrawDebug(Color c) { foreach (var v in Corners) { var w = GTAFuncs.WorldToScreen(v.Value); new UIText(v.Key, new Point((int)w.X, (int)w.Y), .15f, c).Draw(); } return(this); }
/// <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); }