Fixed opened and broken doors being ignored during waypoint generation, causing waypoint connections to go through the doors and preventing AI characters from opening them. + Updated waypoints in Aegir Mark III
This commit is contained in:
@@ -150,6 +150,20 @@ namespace Barotrauma
|
||||
wayPoint.Remove();
|
||||
}
|
||||
|
||||
//find all open doors and temporarily activate their bodies to prevent visibility checks
|
||||
//from ignoring the doors and generating waypoint connections that go straight through the door
|
||||
List<Door> openDoors = new List<Door>();
|
||||
foreach (Item item in Item.ItemList)
|
||||
{
|
||||
var door = item.GetComponent<Door>();
|
||||
if (door != null && !door.Body.Enabled)
|
||||
{
|
||||
openDoors.Add(door);
|
||||
door.Body.Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
float minDist = 150.0f;
|
||||
float heightFromFloor = 110.0f;
|
||||
|
||||
@@ -201,15 +215,15 @@ namespace Barotrauma
|
||||
|
||||
borders.Height += inflateAmount;
|
||||
}
|
||||
|
||||
WayPoint[,] cornerWaypoint = new WayPoint[2,2];
|
||||
|
||||
for (int i = 0; i<2; i++)
|
||||
WayPoint[,] cornerWaypoint = new WayPoint[2, 2];
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
for (float x = borders.X + outSideWaypointInterval; x < borders.Right - outSideWaypointInterval; x += outSideWaypointInterval)
|
||||
{
|
||||
var wayPoint = new WayPoint(
|
||||
new Vector2(x, borders.Y - borders.Height * i) + submarine.HiddenSubPosition,
|
||||
new Vector2(x, borders.Y - borders.Height * i) + submarine.HiddenSubPosition,
|
||||
SpawnType.Path, submarine);
|
||||
|
||||
if (x == borders.X + outSideWaypointInterval)
|
||||
@@ -218,13 +232,13 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
wayPoint.ConnectTo(WayPoint.WayPointList[WayPointList.Count-2]);
|
||||
wayPoint.ConnectTo(WayPointList[WayPointList.Count - 2]);
|
||||
}
|
||||
}
|
||||
|
||||
cornerWaypoint[i, 1] = WayPoint.WayPointList[WayPointList.Count - 1];
|
||||
cornerWaypoint[i, 1] = WayPointList[WayPointList.Count - 1];
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
WayPoint wayPoint = null;
|
||||
@@ -300,7 +314,7 @@ namespace Barotrauma
|
||||
|
||||
while (prevPoint != ladderPoints[1])
|
||||
{
|
||||
var pickedBody = Submarine.PickBody(prevPos, ladderPoints[1].SimPosition, ignoredBodies);
|
||||
var pickedBody = Submarine.PickBody(prevPos, ladderPoints[1].SimPosition, ignoredBodies, null, false);
|
||||
|
||||
if (pickedBody == null) break;
|
||||
|
||||
@@ -333,19 +347,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
prevPoint.ConnectTo(ladderPoints[1]);
|
||||
|
||||
|
||||
|
||||
//for (float y = ladderPoints[0].Position.Y+100.0f; y < ladderPoints[1].Position.Y; y+=100.0f )
|
||||
//{
|
||||
// var midPoint = new WayPoint(new Vector2(item.Rect.Center.X, y), SpawnType.Path, Submarine.Loaded);
|
||||
// midPoint.Ladders = ladders;
|
||||
|
||||
// midPoint.ConnectTo(prevPoint);
|
||||
// prevPoint = midPoint;
|
||||
//}
|
||||
//ladderPoints[1].ConnectTo(prevPoint);
|
||||
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
ladderPoints[i].Ladders = ladders;
|
||||
@@ -357,8 +359,6 @@ namespace Barotrauma
|
||||
ladderPoints[i].ConnectTo(closest);
|
||||
}
|
||||
}
|
||||
|
||||
//ladderPoints[0].ConnectTo(ladderPoints[1]);
|
||||
}
|
||||
|
||||
foreach (Gap gap in Gap.GapList)
|
||||
@@ -394,7 +394,7 @@ namespace Barotrauma
|
||||
if (gap.Rect.Width < 100.0f) continue;
|
||||
|
||||
var wayPoint = new WayPoint(
|
||||
new Vector2(gap.Rect.Center.X, gap.Rect.Y - gap.Rect.Height/2), SpawnType.Path, submarine, gap);
|
||||
new Vector2(gap.Rect.Center.X, gap.Rect.Y - gap.Rect.Height / 2), SpawnType.Path, submarine, gap);
|
||||
|
||||
for (int dir = -1; dir <= 1; dir += 2)
|
||||
{
|
||||
@@ -410,6 +410,12 @@ namespace Barotrauma
|
||||
{
|
||||
wp.Remove();
|
||||
}
|
||||
|
||||
//re-disable the bodies of the doors that are supposed to be open
|
||||
foreach (Door door in openDoors)
|
||||
{
|
||||
door.Body.Enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
private WayPoint FindClosest(int dir, bool horizontalSearch, Vector2 tolerance, Body ignoredBody = null)
|
||||
@@ -443,7 +449,7 @@ namespace Barotrauma
|
||||
float dist = Vector2.Distance(wp.Position, Position);
|
||||
if (closest == null || dist < closestDist)
|
||||
{
|
||||
var body = Submarine.CheckVisibility(SimPosition, wp.SimPosition, true, true);
|
||||
var body = Submarine.CheckVisibility(SimPosition, wp.SimPosition, true, true, false);
|
||||
if (body != null && body != ignoredBody && !(body.UserData is Submarine))
|
||||
{
|
||||
if (body.UserData is Structure || body.FixtureList[0].CollisionCategories.HasFlag(Physics.CollisionWall)) continue;
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user