Waypoint generation fix (submarine collider is ignored when doing visibility checks), regenerated waypoints in vanilla subs
This commit is contained in:
@@ -477,7 +477,7 @@ namespace Barotrauma
|
|||||||
/// check visibility between two points (in sim units)
|
/// check visibility between two points (in sim units)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>a physics body that was between the points (or null)</returns>
|
/// <returns>a physics body that was between the points (or null)</returns>
|
||||||
public static Body CheckVisibility(Vector2 rayStart, Vector2 rayEnd, bool ignoreLevel = false)
|
public static Body CheckVisibility(Vector2 rayStart, Vector2 rayEnd, bool ignoreLevel = false, bool ignoreSubs = false)
|
||||||
{
|
{
|
||||||
Body closestBody = null;
|
Body closestBody = null;
|
||||||
float closestFraction = 1.0f;
|
float closestFraction = 1.0f;
|
||||||
@@ -494,6 +494,7 @@ namespace Barotrauma
|
|||||||
(!fixture.CollisionCategories.HasFlag(Physics.CollisionWall) && !fixture.CollisionCategories.HasFlag(Physics.CollisionLevel))) return -1;
|
(!fixture.CollisionCategories.HasFlag(Physics.CollisionWall) && !fixture.CollisionCategories.HasFlag(Physics.CollisionLevel))) return -1;
|
||||||
|
|
||||||
if (ignoreLevel && fixture.CollisionCategories == Physics.CollisionLevel) return -1;
|
if (ignoreLevel && fixture.CollisionCategories == Physics.CollisionLevel) return -1;
|
||||||
|
if (ignoreSubs && fixture.Body.UserData is Submarine) return -1;
|
||||||
|
|
||||||
Structure structure = fixture.Body.UserData as Structure;
|
Structure structure = fixture.Body.UserData as Structure;
|
||||||
if (structure != null)
|
if (structure != null)
|
||||||
|
|||||||
@@ -465,10 +465,8 @@ namespace Barotrauma
|
|||||||
WayPoint[] ladderPoints = new WayPoint[2];
|
WayPoint[] ladderPoints = new WayPoint[2];
|
||||||
|
|
||||||
ladderPoints[0] = new WayPoint(new Vector2(item.Rect.Center.X, item.Rect.Y - item.Rect.Height + heightFromFloor), SpawnType.Path, submarine);
|
ladderPoints[0] = new WayPoint(new Vector2(item.Rect.Center.X, item.Rect.Y - item.Rect.Height + heightFromFloor), SpawnType.Path, submarine);
|
||||||
|
|
||||||
ladderPoints[1] = new WayPoint(new Vector2(item.Rect.Center.X, item.Rect.Y-1.0f), SpawnType.Path, submarine);
|
ladderPoints[1] = new WayPoint(new Vector2(item.Rect.Center.X, item.Rect.Y-1.0f), SpawnType.Path, submarine);
|
||||||
|
|
||||||
|
|
||||||
WayPoint prevPoint = ladderPoints[0];
|
WayPoint prevPoint = ladderPoints[0];
|
||||||
Vector2 prevPos = prevPoint.SimPosition;
|
Vector2 prevPos = prevPoint.SimPosition;
|
||||||
|
|
||||||
@@ -619,7 +617,7 @@ namespace Barotrauma
|
|||||||
float dist = Vector2.Distance(wp.Position, Position);
|
float dist = Vector2.Distance(wp.Position, Position);
|
||||||
if (closest == null || dist < closestDist)
|
if (closest == null || dist < closestDist)
|
||||||
{
|
{
|
||||||
var body = Submarine.CheckVisibility(SimPosition, wp.SimPosition, true);
|
var body = Submarine.CheckVisibility(SimPosition, wp.SimPosition, true, true);
|
||||||
if (body != null && body != ignoredBody && !(body.UserData is Submarine))
|
if (body != null && body != ignoredBody && !(body.UserData is Submarine))
|
||||||
{
|
{
|
||||||
if (body.UserData is Structure || body.FixtureList[0].CollisionCategories.HasFlag(Physics.CollisionWall)) continue;
|
if (body.UserData is Structure || body.FixtureList[0].CollisionCategories.HasFlag(Physics.CollisionWall)) continue;
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user