diff --git a/Subsurface/Barotrauma.csproj b/Subsurface/Barotrauma.csproj
index 7789088ff..da1beacb0 100644
--- a/Subsurface/Barotrauma.csproj
+++ b/Subsurface/Barotrauma.csproj
@@ -554,6 +554,9 @@
PreserveNewest
+
+ PreserveNewest
+
PreserveNewest
diff --git a/Subsurface/Content/Items/Engine/engine.xml b/Subsurface/Content/Items/Engine/engine.xml
index 3d3ff81b5..00f9ef996 100644
--- a/Subsurface/Content/Items/Engine/engine.xml
+++ b/Subsurface/Content/Items/Engine/engine.xml
@@ -80,6 +80,7 @@
+
@@ -110,6 +111,7 @@
+
diff --git a/Subsurface/Content/Items/Engine/radarBlip.png b/Subsurface/Content/Items/Engine/radarBlip.png
new file mode 100644
index 000000000..5c2d7c602
Binary files /dev/null and b/Subsurface/Content/Items/Engine/radarBlip.png differ
diff --git a/Subsurface/Content/Items/Tools/tools.xml b/Subsurface/Content/Items/Tools/tools.xml
index e8ae3ced0..4b7c47691 100644
--- a/Subsurface/Content/Items/Tools/tools.xml
+++ b/Subsurface/Content/Items/Tools/tools.xml
@@ -204,6 +204,7 @@
+
diff --git a/Subsurface/Source/Items/Components/Machines/Radar.cs b/Subsurface/Source/Items/Components/Machines/Radar.cs
index 399407f68..97475e616 100644
--- a/Subsurface/Source/Items/Components/Machines/Radar.cs
+++ b/Subsurface/Source/Items/Components/Machines/Radar.cs
@@ -16,6 +16,8 @@ namespace Barotrauma.Items.Components
private readonly Sprite pingCircle, screenOverlay;
+ private readonly Sprite radarBlip;
+
private GUITickBox isActiveTickBox;
private List radarBlips;
@@ -70,6 +72,9 @@ namespace Barotrauma.Items.Components
case "screenoverlay":
screenOverlay = new Sprite(subElement);
break;
+ case "blip":
+ radarBlip = new Sprite(subElement);
+ break;
}
}
@@ -162,9 +167,15 @@ namespace Barotrauma.Items.Components
public override void DrawHUD(SpriteBatch spriteBatch, Character character)
{
GuiFrame.Draw(spriteBatch);
-
+
+ spriteBatch.End();
+ spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive);
+
int radius = GuiFrame.Rect.Height / 2 - 30;
DrawRadar(spriteBatch, new Rectangle((int)GuiFrame.Center.X - radius, (int)GuiFrame.Center.Y - radius, radius * 2, radius * 2));
+
+ spriteBatch.End();
+ spriteBatch.Begin(SpriteSortMode.Immediate, null, null, null, GameMain.ScissorTestEnable);
}
private void DrawRadar(SpriteBatch spriteBatch, Rectangle rect)
@@ -205,6 +216,11 @@ namespace Barotrauma.Items.Components
DrawBlip(spriteBatch, radarBlip, center, radarBlip.FadeTimer / 2.0f);
}
+ if (GameMain.DebugDraw)
+ {
+ GUI.DrawString(spriteBatch, rect.Location.ToVector2(), radarBlips.Count.ToString(), Color.White);
+ }
+
if (screenOverlay != null)
{
screenOverlay.Draw(spriteBatch, center, 0.0f, rect.Width / screenOverlay.size.X);
@@ -393,13 +409,26 @@ namespace Barotrauma.Items.Components
float alpha = pingStrength * Rand.Range(1.5f, 2.0f);
for (float z = 0; z < displayRadius - pointDist * displayScale; z += zStep)
{
- var blip = new RadarBlip(
- point + Rand.Vector(150.0f) + Vector2.Normalize(point - item.WorldPosition) * z / displayScale,
- alpha * (1.0f - pointDist/range));
+ Vector2 pos = point + Rand.Vector(150.0f) + Vector2.Normalize(point - item.WorldPosition) * z / displayScale;
+ float fadeTimer = alpha * (1.0f - pointDist / range);
+
+ int minDist = 200;
+ radarBlips.RemoveAll(b => b.FadeTimer < fadeTimer && Math.Abs(pos.X - b.Position.X) < minDist && Math.Abs(pos.Y - b.Position.Y) < minDist);
+
+ var blip = new RadarBlip(pos, fadeTimer);
radarBlips.Add(blip);
zStep += 0.5f;
- alpha -= (z == 0) ? 0.5f : 0.1f;
+
+ if (z == 0)
+ {
+ alpha = Math.Min(alpha - 0.5f, 1.5f);
+ }
+ else
+ {
+ alpha -= 0.1f;
+ }
+
if (alpha < 0) break;
}
@@ -418,7 +447,7 @@ namespace Barotrauma.Items.Components
new Color(255, 255, 255) };
float scaledT = strength * (colors.Length - 1);
- Color color = Color.Lerp(colors[(int)scaledT], colors[(int)scaledT], (scaledT - (int)scaledT));
+ Color color = Color.Lerp(colors[(int)scaledT], colors[(int)Math.Min(scaledT+1, colors.Length-1)], (scaledT - (int)scaledT));
Vector2 pos = (blip.Position - item.WorldPosition) * displayScale;
pos.Y = -pos.Y;
@@ -428,21 +457,28 @@ namespace Barotrauma.Items.Components
blip.FadeTimer = 0.0f;
return;
}
-
- /*pos.X = MathUtils.Round(pos.X, 4);
- pos.Y = MathUtils.Round(pos.Y, 2);*/
-
-
+
float posDist = pos.Length();
Vector2 dir = pos / posDist;
float distFactor = (posDist / displayRadius);
- Vector2 normal = new Vector2(dir.Y, -dir.X) * (strength + 1.0f) * distFactor * 5.0f;
-
- GUI.DrawLine(spriteBatch, center + pos - normal, center + pos + normal, color * (1.0f - distFactor), 0, 2);
+ Vector2 normal = new Vector2(dir.Y, -dir.X);
- pos += Rand.Range(0.0f, 1.0f) * dir + Rand.Range(-1.0f, 1.0f) * normal;
- GUI.DrawLine(spriteBatch, center + pos - normal, center + pos + normal, color * 0.2f, 0, 3);
+ float scale = (strength + 3.0f) * Math.Max(distFactor * 3.0f, 1.0f);
+
+ if (radarBlip == null)
+ {
+ GUI.DrawRectangle(spriteBatch, center + pos, Vector2.One * 4, Color.Magenta, true);
+ return;
+ }
+
+ radarBlip.Draw(spriteBatch, center + pos, color, radarBlip.Origin, MathUtils.VectorToAngle(pos),
+ new Vector2(scale * 0.3f, scale) * 0.04f, SpriteEffects.None, 0);
+
+ pos += Rand.Range(0.0f, 1.0f) * dir + Rand.Range(-scale, scale) * normal;
+
+ radarBlip.Draw(spriteBatch, center + pos, color * 0.5f, radarBlip.Origin, MathUtils.VectorToAngle(pos),
+ new Vector2(scale * 0.3f, scale) * 0.08f, SpriteEffects.None, 0);
}
private void DrawMarker(SpriteBatch spriteBatch, string label, Vector2 position, float scale, Vector2 center, float radius)
@@ -483,7 +519,7 @@ namespace Barotrauma.Items.Components
{
if (pingCircle!=null) pingCircle.Remove();
if (screenOverlay != null) screenOverlay.Remove();
-
+ if (radarBlip != null) radarBlip.Remove();
}
public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)