Faction Test 100.10.0.0
This commit is contained in:
@@ -474,6 +474,7 @@ namespace Barotrauma.Items.Components
|
||||
item.WorldPosition,
|
||||
sound.Volume,
|
||||
sound.Range,
|
||||
freqMult: sound.GetRandomFrequencyMultiplier(),
|
||||
hullGuess: item.CurrentHull);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,6 @@ namespace Barotrauma.Items.Components
|
||||
private float displayBorderSize;
|
||||
|
||||
private List<SonarBlip> sonarBlips;
|
||||
private readonly HashSet<SonarBlip> prevBlips = new HashSet<SonarBlip>();
|
||||
|
||||
private float prevPassivePingRadius;
|
||||
|
||||
@@ -820,27 +819,9 @@ namespace Barotrauma.Items.Components
|
||||
float dist = (float)Math.Sqrt(distSqr);
|
||||
if (dist > prevPassivePingRadius * Range && dist <= passivePingRadius * Range && Rand.Int(sonarBlips.Count) < 500)
|
||||
{
|
||||
prevBlips.Clear();
|
||||
foreach (var blip in sonarBlips)
|
||||
{
|
||||
prevBlips.Add(blip);
|
||||
}
|
||||
|
||||
Ping(t.WorldPosition, transducerCenter,
|
||||
t.SoundRange * displayScale, 0, displayScale, range,
|
||||
passive: true, pingStrength: 0.5f);
|
||||
//remove blips that weren't in the AITarget's sector
|
||||
if (t.HasSector())
|
||||
{
|
||||
for (int i = sonarBlips.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (prevBlips.Contains(sonarBlips[i])) { continue; }
|
||||
if (!t.IsWithinSector(sonarBlips[i].Position))
|
||||
{
|
||||
sonarBlips.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
passive: true, pingStrength: 0.5f, needsToBeInSector: t);
|
||||
if (t.IsWithinSector(transducerCenter))
|
||||
{
|
||||
sonarBlips.Add(new SonarBlip(t.WorldPosition, fadeTimer: 1.0f, scale: MathHelper.Clamp(t.SoundRange / 2000, 1.0f, 5.0f)));
|
||||
@@ -1405,7 +1386,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
|
||||
private void Ping(Vector2 pingSource, Vector2 transducerPos, float pingRadius, float prevPingRadius, float displayScale, float range, bool passive,
|
||||
float pingStrength = 1.0f)
|
||||
float pingStrength = 1.0f, AITarget needsToBeInSector = null)
|
||||
{
|
||||
float prevPingRadiusSqr = prevPingRadius * prevPingRadius;
|
||||
float pingRadiusSqr = pingRadius * pingRadius;
|
||||
@@ -1417,25 +1398,25 @@ namespace Barotrauma.Items.Components
|
||||
new Vector2(item.CurrentHull.WorldRect.X, item.CurrentHull.WorldRect.Y),
|
||||
new Vector2(item.CurrentHull.WorldRect.Right, item.CurrentHull.WorldRect.Y),
|
||||
pingSource, transducerPos,
|
||||
pingRadius, prevPingRadius, 50.0f, 5.0f, range, 2.0f, passive);
|
||||
pingRadius, prevPingRadius, 50.0f, 5.0f, range, 2.0f, passive, needsToBeInSector: needsToBeInSector);
|
||||
|
||||
CreateBlipsForLine(
|
||||
new Vector2(item.CurrentHull.WorldRect.X, item.CurrentHull.WorldRect.Y - item.CurrentHull.Rect.Height),
|
||||
new Vector2(item.CurrentHull.WorldRect.Right, item.CurrentHull.WorldRect.Y - item.CurrentHull.Rect.Height),
|
||||
pingSource, transducerPos,
|
||||
pingRadius, prevPingRadius, 50.0f, 5.0f, range, 2.0f, passive);
|
||||
pingRadius, prevPingRadius, 50.0f, 5.0f, range, 2.0f, passive, needsToBeInSector: needsToBeInSector);
|
||||
|
||||
CreateBlipsForLine(
|
||||
new Vector2(item.CurrentHull.WorldRect.X, item.CurrentHull.WorldRect.Y),
|
||||
new Vector2(item.CurrentHull.WorldRect.X, item.CurrentHull.WorldRect.Y - item.CurrentHull.Rect.Height),
|
||||
pingSource, transducerPos,
|
||||
pingRadius, prevPingRadius, 50.0f, 5.0f, range, 2.0f, passive);
|
||||
pingRadius, prevPingRadius, 50.0f, 5.0f, range, 2.0f, passive, needsToBeInSector: needsToBeInSector);
|
||||
|
||||
CreateBlipsForLine(
|
||||
new Vector2(item.CurrentHull.WorldRect.Right, item.CurrentHull.WorldRect.Y),
|
||||
new Vector2(item.CurrentHull.WorldRect.Right, item.CurrentHull.WorldRect.Y - item.CurrentHull.Rect.Height),
|
||||
pingSource, transducerPos,
|
||||
pingRadius, prevPingRadius, 50.0f, 5.0f, range, 2.0f, passive);
|
||||
pingRadius, prevPingRadius, 50.0f, 5.0f, range, 2.0f, passive, needsToBeInSector: needsToBeInSector);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -1472,7 +1453,8 @@ namespace Barotrauma.Items.Components
|
||||
end + submarine.WorldPosition,
|
||||
pingSource, transducerPos,
|
||||
pingRadius, prevPingRadius,
|
||||
200.0f, 2.0f, range, 1.0f, passive);
|
||||
200.0f, 2.0f, range, 1.0f, passive,
|
||||
needsToBeInSector: needsToBeInSector);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1485,7 +1467,8 @@ namespace Barotrauma.Items.Components
|
||||
new Vector2(pingSource.X + range, Level.Loaded.Size.Y),
|
||||
pingSource, transducerPos,
|
||||
pingRadius, prevPingRadius,
|
||||
250.0f, 150.0f, range, pingStrength, passive);
|
||||
250.0f, 150.0f, range, pingStrength, passive,
|
||||
needsToBeInSector: needsToBeInSector);
|
||||
}
|
||||
if (pingSource.Y - Level.Loaded.BottomPos < range)
|
||||
{
|
||||
@@ -1494,7 +1477,8 @@ namespace Barotrauma.Items.Components
|
||||
new Vector2(pingSource.X + range, Level.Loaded.BottomPos),
|
||||
pingSource, transducerPos,
|
||||
pingRadius, prevPingRadius,
|
||||
250.0f, 150.0f, range, pingStrength, passive);
|
||||
250.0f, 150.0f, range, pingStrength, passive,
|
||||
needsToBeInSector: needsToBeInSector);
|
||||
}
|
||||
|
||||
List<Voronoi2.VoronoiCell> cells = Level.Loaded.GetCells(pingSource, 7);
|
||||
@@ -1516,7 +1500,8 @@ namespace Barotrauma.Items.Components
|
||||
pingSource, transducerPos,
|
||||
pingRadius, prevPingRadius,
|
||||
350.0f, 3.0f * (Math.Abs(facingDot) + 1.0f), range, pingStrength, passive,
|
||||
blipType : cell.IsDestructible ? BlipType.Destructible : BlipType.Default);
|
||||
blipType : cell.IsDestructible ? BlipType.Destructible : BlipType.Default,
|
||||
needsToBeInSector: needsToBeInSector);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1526,14 +1511,13 @@ namespace Barotrauma.Items.Components
|
||||
if (item.CurrentHull == null && item.Prefab.SonarSize > 0.0f)
|
||||
{
|
||||
float pointDist = ((item.WorldPosition - pingSource) * displayScale).LengthSquared();
|
||||
|
||||
if (pointDist > prevPingRadiusSqr && pointDist < pingRadiusSqr)
|
||||
{
|
||||
var blip = new SonarBlip(
|
||||
item.WorldPosition + Rand.Vector(item.Prefab.SonarSize),
|
||||
MathHelper.Clamp(item.Prefab.SonarSize, 0.1f, pingStrength),
|
||||
MathHelper.Clamp(item.Prefab.SonarSize * 0.1f, 0.1f, 10.0f));
|
||||
if (!passive && !CheckBlipVisibility(blip, transducerPos)) continue;
|
||||
if (!IsVisible(blip)) { continue; }
|
||||
sonarBlips.Add(blip);
|
||||
}
|
||||
}
|
||||
@@ -1556,7 +1540,7 @@ namespace Barotrauma.Items.Components
|
||||
c.WorldPosition,
|
||||
MathHelper.Clamp(c.Mass, 0.1f, pingStrength),
|
||||
MathHelper.Clamp(c.Mass * 0.03f, 0.1f, 2.0f));
|
||||
if (!passive && !CheckBlipVisibility(blip, transducerPos)) { continue; }
|
||||
if (!IsVisible(blip)) { continue; }
|
||||
sonarBlips.Add(blip);
|
||||
HintManager.OnSonarSpottedCharacter(Item, c);
|
||||
}
|
||||
@@ -1573,19 +1557,29 @@ namespace Barotrauma.Items.Components
|
||||
if (pointDist > prevPingRadiusSqr && pointDist < pingRadiusSqr)
|
||||
{
|
||||
var blip = new SonarBlip(
|
||||
limb.WorldPosition + Rand.Vector(limb.Mass / 10.0f),
|
||||
MathHelper.Clamp(limb.Mass, 0.1f, pingStrength),
|
||||
limb.WorldPosition + Rand.Vector(limb.Mass / 10.0f),
|
||||
MathHelper.Clamp(limb.Mass, 0.1f, pingStrength),
|
||||
MathHelper.Clamp(limb.Mass * 0.1f, 0.1f, 2.0f));
|
||||
if (!passive && !CheckBlipVisibility(blip, transducerPos)) { continue; }
|
||||
if (!IsVisible(blip)) { continue; }
|
||||
sonarBlips.Add(blip);
|
||||
HintManager.OnSonarSpottedCharacter(Item, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool IsVisible(SonarBlip blip)
|
||||
{
|
||||
if (!passive && !CheckBlipVisibility(blip, transducerPos)) { return false; }
|
||||
if (needsToBeInSector != null)
|
||||
{
|
||||
if (!needsToBeInSector.IsWithinSector(blip.Position)) { return false; }
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void CreateBlipsForLine(Vector2 point1, Vector2 point2, Vector2 pingSource, Vector2 transducerPos, float pingRadius, float prevPingRadius,
|
||||
float lineStep, float zStep, float range, float pingStrength, bool passive, BlipType blipType = BlipType.Default)
|
||||
float lineStep, float zStep, float range, float pingStrength, bool passive, BlipType blipType = BlipType.Default, AITarget needsToBeInSector = null)
|
||||
{
|
||||
lineStep /= zoom;
|
||||
zStep /= zoom;
|
||||
@@ -1631,12 +1625,17 @@ namespace Barotrauma.Items.Components
|
||||
Vector2 pos = point + Rand.Vector(150.0f / zoom) + pingDirection * z / displayScale;
|
||||
float fadeTimer = alpha * (1.0f - displayPointDist / range);
|
||||
|
||||
int minDist = (int)(200 / zoom);
|
||||
sonarBlips.RemoveAll(b => b.FadeTimer < fadeTimer && Math.Abs(pos.X - b.Position.X) < minDist && Math.Abs(pos.Y - b.Position.Y) < minDist);
|
||||
if (needsToBeInSector != null)
|
||||
{
|
||||
if (!needsToBeInSector.IsWithinSector(pos)) { continue; }
|
||||
}
|
||||
|
||||
var blip = new SonarBlip(pos, fadeTimer, 1.0f + ((displayPointDist + z) / DisplayRadius), blipType);
|
||||
if (!passive && !CheckBlipVisibility(blip, transducerPos)) { continue; }
|
||||
|
||||
int minDist = (int)(200 / zoom);
|
||||
sonarBlips.RemoveAll(b => b.FadeTimer < fadeTimer && Math.Abs(pos.X - b.Position.X) < minDist && Math.Abs(pos.Y - b.Position.Y) < minDist);
|
||||
|
||||
sonarBlips.Add(blip);
|
||||
zStep += 0.5f / zoom;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user