(7e0adb991) Fixed legacy items failing to load if a sub is saved with a language other than English and the language then changed to something else.
This commit is contained in:
@@ -730,7 +730,15 @@ namespace Barotrauma
|
||||
return closestBody;
|
||||
}
|
||||
|
||||
public static List<Body> PickBodies(Vector2 rayStart, Vector2 rayEnd, IEnumerable<Body> ignoredBodies = null, Category? collisionCategory = null, bool ignoreSensors = true, Predicate<Fixture> customPredicate = null, bool allowInsideFixture = false)
|
||||
private static readonly Dictionary<Body, float> bodyDist = new Dictionary<Body, float>();
|
||||
private static readonly List<Body> bodies = new List<Body>();
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of physics bodies the ray intersects with, sorted according to distance (the closest body is at the beginning of the list).
|
||||
/// </summary>
|
||||
/// <param name="customPredicate">Can be used to filter the bodies based on some condition. If the predicate returns false, the body isignored.</param>
|
||||
/// <param name="allowInsideFixture">Should fixtures that the start of the ray is inside be returned</param>
|
||||
public static IEnumerable<Body> PickBodies(Vector2 rayStart, Vector2 rayEnd, IEnumerable<Body> ignoredBodies = null, Category? collisionCategory = null, bool ignoreSensors = true, Predicate<Fixture> customPredicate = null, bool allowInsideFixture = false)
|
||||
{
|
||||
if (Vector2.DistanceSquared(rayStart, rayEnd) < 0.00001f)
|
||||
{
|
||||
@@ -738,20 +746,25 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
float closestFraction = 1.0f;
|
||||
List<Body> bodies = new List<Body>();
|
||||
bodies.Clear();
|
||||
bodyDist.Clear();
|
||||
GameMain.World.RayCast((fixture, point, normal, fraction) =>
|
||||
{
|
||||
if (!CheckFixtureCollision(fixture, ignoredBodies, collisionCategory, ignoreSensors, customPredicate)) { return -1; }
|
||||
|
||||
if (fixture.Body != null) { bodies.Add(fixture.Body); }
|
||||
if (fixture.Body != null)
|
||||
{
|
||||
bodies.Add(fixture.Body);
|
||||
bodyDist[fixture.Body] = fraction;
|
||||
}
|
||||
if (fraction < closestFraction)
|
||||
{
|
||||
lastPickedPosition = rayStart + (rayEnd - rayStart) * fraction;
|
||||
lastPickedFraction = fraction;
|
||||
lastPickedNormal = normal;
|
||||
}
|
||||
|
||||
return fraction;
|
||||
//continue
|
||||
return -1;
|
||||
}, rayStart, rayEnd);
|
||||
|
||||
if (allowInsideFixture)
|
||||
@@ -770,10 +783,12 @@ namespace Barotrauma
|
||||
lastPickedFraction = 0.0f;
|
||||
lastPickedNormal = Vector2.Normalize(rayEnd - rayStart);
|
||||
bodies.Add(fixture.Body);
|
||||
bodyDist[fixture.Body] = 0.0f;
|
||||
return false;
|
||||
}, ref aabb);
|
||||
}
|
||||
|
||||
bodies.Sort((b1, b2) => { return bodyDist[b1].CompareTo(bodyDist[b2]); });
|
||||
return bodies;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user