Client LuaCsForBarotrauma
BarotraumaClient/ClientSource/Characters/AI/AITarget.cs
1 using Microsoft.Xna.Framework;
2 using Microsoft.Xna.Framework.Graphics;
3 
4 namespace Barotrauma
5 {
6  partial class AITarget
7  {
8  public static bool ShowAITargets;
9 
10  public void Draw(SpriteBatch spriteBatch)
11  {
12  if (!ShowAITargets) { return; }
13  var pos = new Vector2(WorldPosition.X, -WorldPosition.Y);
14  float thickness = 1 / Screen.Selected.Cam.Zoom;
15 
16  float offset = MathUtils.VectorToAngle(new Vector2(sectorDir.X, -sectorDir.Y)) - (sectorRad / 2f);
17  if (soundRange > 0.0f)
18  {
19  Color color;
20  if (Entity is Character)
21  {
22  color = Color.Yellow;
23  }
24  else if (Entity is Item)
25  {
26  color = Color.Orange;
27  }
28  else
29  {
30  color = Color.OrangeRed;
31  }
32 
33  if (sectorRad < MathHelper.TwoPi)
34  {
35  spriteBatch.DrawSector(pos, SoundRange, sectorRad, 100, color, offset: offset, thickness: thickness);
36  }
37  else
38  {
39  spriteBatch.DrawCircle(pos, SoundRange, 100, color, thickness: thickness);
40  }
41  spriteBatch.DrawCircle(pos, 3, 8, color, thickness: 2 / Screen.Selected.Cam.Zoom);
42  GUI.DrawLine(spriteBatch, pos, pos + Vector2.UnitY * SoundRange, color, width: (int)(1 / Screen.Selected.Cam.Zoom) + 1);
43  }
44  if (sightRange > 0.0f)
45  {
46  Color color;
47  if (Entity is Character)
48  {
49  color = Color.CornflowerBlue;
50  }
51  else if (Entity is Item i)
52  {
53  if (i.Submarine != null && i.Container != null)
54  {
55  // Don't show contained items that are inside the submarine, because they shouldn't attract monsters.
56  return;
57  }
58  color = Color.CadetBlue;
59  }
60  else
61  {
62  //color = Color.WhiteSmoke;
63  // disable the indicators for structures and hulls, because they clutter the debug view
64  return;
65  }
66  if (sectorRad < MathHelper.TwoPi)
67  {
68  spriteBatch.DrawSector(pos, SightRange, sectorRad, 100, color, offset: offset, thickness: thickness);
69  }
70  else
71  {
72  spriteBatch.DrawCircle(pos, SightRange, 100, color, thickness: thickness);
73  }
74  ShapeExtensions.DrawCircle(spriteBatch, pos, 6, 8, color, thickness: 2 / Screen.Selected.Cam.Zoom);
75  GUI.DrawLine(spriteBatch, pos, pos + Vector2.UnitY * SightRange, color, width: (int)(1 / Screen.Selected.Cam.Zoom) + 1);
76  }
77  }
78  }
79 }
float? Zoom
Definition: Camera.cs:78