Sonar tweaking
This commit is contained in:
@@ -554,6 +554,9 @@
|
|||||||
<Content Include="Content\Items\Door\dockingport2.png">
|
<Content Include="Content\Items\Door\dockingport2.png">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="Content\Items\Engine\radarBlip.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="Content\Items\Jobgear\captainLegs.png">
|
<Content Include="Content\Items\Jobgear\captainLegs.png">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</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"/>
|
<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"/>
|
<PingCircle texture="Content/Items/Engine/pingCircle.png" origin="0.5,0.5"/>
|
||||||
<ScreenOverlay texture="Content/Items/Engine/radarOverlay.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>
|
</Radar>
|
||||||
|
|
||||||
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
|
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
|
||||||
@@ -110,6 +111,7 @@
|
|||||||
<GuiFrame rect="0,0,0.5,0.5" alignment="Center" style="ItemUI"/>
|
<GuiFrame rect="0,0,0.5,0.5" alignment="Center" style="ItemUI"/>
|
||||||
<PingCircle texture="Content/Items/Engine/pingCircle.png" origin="0.5,0.5"/>
|
<PingCircle texture="Content/Items/Engine/pingCircle.png" origin="0.5,0.5"/>
|
||||||
<ScreenOverlay texture="Content/Items/Engine/radarOverlay.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>
|
</Radar>
|
||||||
|
|
||||||
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
|
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
|
||||||
|
|||||||
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"/>
|
<GuiFrame rect="0,0,0.5,0.5" alignment="Center" style="ItemUI"/>
|
||||||
<PingCircle texture="Content/Items/Engine/pingCircle.png" origin="0.5,0.5"/>
|
<PingCircle texture="Content/Items/Engine/pingCircle.png" origin="0.5,0.5"/>
|
||||||
<ScreenOverlay texture="Content/Items/Engine/radarOverlay.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>
|
</Radar>
|
||||||
|
|
||||||
<ItemContainer capacity="1" hideitems="true">
|
<ItemContainer capacity="1" hideitems="true">
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
private readonly Sprite pingCircle, screenOverlay;
|
private readonly Sprite pingCircle, screenOverlay;
|
||||||
|
|
||||||
|
private readonly Sprite radarBlip;
|
||||||
|
|
||||||
private GUITickBox isActiveTickBox;
|
private GUITickBox isActiveTickBox;
|
||||||
|
|
||||||
private List<RadarBlip> radarBlips;
|
private List<RadarBlip> radarBlips;
|
||||||
@@ -70,6 +72,9 @@ namespace Barotrauma.Items.Components
|
|||||||
case "screenoverlay":
|
case "screenoverlay":
|
||||||
screenOverlay = new Sprite(subElement);
|
screenOverlay = new Sprite(subElement);
|
||||||
break;
|
break;
|
||||||
|
case "blip":
|
||||||
|
radarBlip = new Sprite(subElement);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,8 +168,14 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
GuiFrame.Draw(spriteBatch);
|
GuiFrame.Draw(spriteBatch);
|
||||||
|
|
||||||
|
spriteBatch.End();
|
||||||
|
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive);
|
||||||
|
|
||||||
int radius = GuiFrame.Rect.Height / 2 - 30;
|
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));
|
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)
|
private void DrawRadar(SpriteBatch spriteBatch, Rectangle rect)
|
||||||
@@ -205,6 +216,11 @@ namespace Barotrauma.Items.Components
|
|||||||
DrawBlip(spriteBatch, radarBlip, center, radarBlip.FadeTimer / 2.0f);
|
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)
|
if (screenOverlay != null)
|
||||||
{
|
{
|
||||||
screenOverlay.Draw(spriteBatch, center, 0.0f, rect.Width / screenOverlay.size.X);
|
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);
|
float alpha = pingStrength * Rand.Range(1.5f, 2.0f);
|
||||||
for (float z = 0; z < displayRadius - pointDist * displayScale; z += zStep)
|
for (float z = 0; z < displayRadius - pointDist * displayScale; z += zStep)
|
||||||
{
|
{
|
||||||
var blip = new RadarBlip(
|
Vector2 pos = point + Rand.Vector(150.0f) + Vector2.Normalize(point - item.WorldPosition) * z / displayScale;
|
||||||
point + Rand.Vector(150.0f) + Vector2.Normalize(point - item.WorldPosition) * z / displayScale,
|
float fadeTimer = alpha * (1.0f - pointDist / range);
|
||||||
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);
|
radarBlips.Add(blip);
|
||||||
zStep += 0.5f;
|
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;
|
if (alpha < 0) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -418,7 +447,7 @@ namespace Barotrauma.Items.Components
|
|||||||
new Color(255, 255, 255) };
|
new Color(255, 255, 255) };
|
||||||
|
|
||||||
float scaledT = strength * (colors.Length - 1);
|
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;
|
Vector2 pos = (blip.Position - item.WorldPosition) * displayScale;
|
||||||
pos.Y = -pos.Y;
|
pos.Y = -pos.Y;
|
||||||
@@ -429,20 +458,27 @@ namespace Barotrauma.Items.Components
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*pos.X = MathUtils.Round(pos.X, 4);
|
|
||||||
pos.Y = MathUtils.Round(pos.Y, 2);*/
|
|
||||||
|
|
||||||
|
|
||||||
float posDist = pos.Length();
|
float posDist = pos.Length();
|
||||||
Vector2 dir = pos / posDist;
|
Vector2 dir = pos / posDist;
|
||||||
float distFactor = (posDist / displayRadius);
|
float distFactor = (posDist / displayRadius);
|
||||||
|
|
||||||
Vector2 normal = new Vector2(dir.Y, -dir.X) * (strength + 1.0f) * distFactor * 5.0f;
|
Vector2 normal = new Vector2(dir.Y, -dir.X);
|
||||||
|
|
||||||
GUI.DrawLine(spriteBatch, center + pos - normal, center + pos + normal, color * (1.0f - distFactor), 0, 2);
|
float scale = (strength + 3.0f) * Math.Max(distFactor * 3.0f, 1.0f);
|
||||||
|
|
||||||
pos += Rand.Range(0.0f, 1.0f) * dir + Rand.Range(-1.0f, 1.0f) * normal;
|
if (radarBlip == null)
|
||||||
GUI.DrawLine(spriteBatch, center + pos - normal, center + pos + normal, color * 0.2f, 0, 3);
|
{
|
||||||
|
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)
|
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 (pingCircle!=null) pingCircle.Remove();
|
||||||
if (screenOverlay != null) screenOverlay.Remove();
|
if (screenOverlay != null) screenOverlay.Remove();
|
||||||
|
if (radarBlip != null) radarBlip.Remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
||||||
|
|||||||
Reference in New Issue
Block a user