Sonar tweaking
This commit is contained in:
@@ -554,6 +554,9 @@
|
||||
<Content Include="Content\Items\Door\dockingport2.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Items\Engine\radarBlip.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Items\Jobgear\captainLegs.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
||||
@@ -80,6 +80,7 @@
|
||||
<GuiFrame rect="0,0,0.5,0.5" alignment="Center" style="ItemUI" color="0.0,0.0,0.0,0.0"/>
|
||||
<PingCircle texture="Content/Items/Engine/pingCircle.png" origin="0.5,0.5"/>
|
||||
<ScreenOverlay texture="Content/Items/Engine/radarOverlay.png" origin="0.5,0.5"/>
|
||||
<Blip texture="Content/Items/Engine/radarBlip.png" origin="0.5,0.5"/>
|
||||
</Radar>
|
||||
|
||||
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
|
||||
@@ -110,6 +111,7 @@
|
||||
<GuiFrame rect="0,0,0.5,0.5" alignment="Center" style="ItemUI"/>
|
||||
<PingCircle texture="Content/Items/Engine/pingCircle.png" origin="0.5,0.5"/>
|
||||
<ScreenOverlay texture="Content/Items/Engine/radarOverlay.png" origin="0.5,0.5"/>
|
||||
<Blip texture="Content/Items/Engine/radarBlip.png" origin="0.5,0.5"/>
|
||||
</Radar>
|
||||
|
||||
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
|
||||
|
||||
BIN
Subsurface/Content/Items/Engine/radarBlip.png
Normal file
BIN
Subsurface/Content/Items/Engine/radarBlip.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
@@ -204,6 +204,7 @@
|
||||
<GuiFrame rect="0,0,0.5,0.5" alignment="Center" style="ItemUI"/>
|
||||
<PingCircle texture="Content/Items/Engine/pingCircle.png" origin="0.5,0.5"/>
|
||||
<ScreenOverlay texture="Content/Items/Engine/radarOverlay.png" origin="0.5,0.5"/>
|
||||
<Blip texture="Content/Items/Engine/radarBlip.png" origin="0.5,0.5"/>
|
||||
</Radar>
|
||||
|
||||
<ItemContainer capacity="1" hideitems="true">
|
||||
|
||||
@@ -16,6 +16,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private readonly Sprite pingCircle, screenOverlay;
|
||||
|
||||
private readonly Sprite radarBlip;
|
||||
|
||||
private GUITickBox isActiveTickBox;
|
||||
|
||||
private List<RadarBlip> 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)
|
||||
|
||||
Reference in New Issue
Block a user