(a410fd46c) Trying to help the merge script through a jungle of merges
This commit is contained in:
@@ -1366,6 +1366,11 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
List<InterestingPosition> suitablePositions = positionsOfInterest.FindAll(p => positionType.HasFlag(p.PositionType));
|
||||
//avoid floating ice chunks on the main path
|
||||
if (positionType == PositionType.MainPath)
|
||||
{
|
||||
suitablePositions.RemoveAll(p => extraWalls.Any(w => w.Cells.Any(c => c.IsPointInside(p.Position.ToVector2()))));
|
||||
}
|
||||
if (!suitablePositions.Any())
|
||||
{
|
||||
string errorMsg = "Could not find a suitable position of interest. (PositionType: " + positionType + ", minDistFromSubs: " + minDistFromSubs + ")\n" + Environment.StackTrace;
|
||||
|
||||
@@ -1433,7 +1433,7 @@ namespace Barotrauma
|
||||
|
||||
Submarine sub = new Submarine(path);
|
||||
sub.Load(unloadPrevious);
|
||||
|
||||
|
||||
return sub;
|
||||
}
|
||||
|
||||
@@ -1564,6 +1564,94 @@ namespace Barotrauma
|
||||
PreviewImage = null;
|
||||
#endif
|
||||
}
|
||||
|
||||
private List<PathNode> outdoorNodes;
|
||||
private List<PathNode> OutdoorNodes
|
||||
{
|
||||
get
|
||||
{
|
||||
if (outdoorNodes == null)
|
||||
{
|
||||
outdoorNodes = PathNode.GenerateNodes(WayPoint.WayPointList.FindAll(wp => wp.SpawnType == SpawnType.Path && wp.Submarine == this && wp.CurrentHull == null));
|
||||
}
|
||||
return outdoorNodes;
|
||||
}
|
||||
}
|
||||
private HashSet<PathNode> obstructedNodes = new HashSet<PathNode>();
|
||||
|
||||
/// <summary>
|
||||
/// Permanently disables obstructed waypoints obstructed by the level.
|
||||
/// </summary>
|
||||
public void DisableObstructedWayPoints()
|
||||
{
|
||||
// Check collisions to level
|
||||
foreach (var node in OutdoorNodes)
|
||||
{
|
||||
if (node == null || node.Waypoint == null) { continue; }
|
||||
var wp = node.Waypoint;
|
||||
if (wp.isObstructed) { continue; }
|
||||
foreach (var connection in node.connections)
|
||||
{
|
||||
bool isObstructed = false;
|
||||
var connectedWp = connection.Waypoint;
|
||||
if (connectedWp.isObstructed) { continue; }
|
||||
Vector2 start = ConvertUnits.ToSimUnits(wp.WorldPosition);
|
||||
Vector2 end = ConvertUnits.ToSimUnits(connectedWp.WorldPosition);
|
||||
var body = Submarine.PickBody(start, end, null, Physics.CollisionLevel, allowInsideFixture: false);
|
||||
if (body != null)
|
||||
{
|
||||
connectedWp.isObstructed = true;
|
||||
wp.isObstructed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Temporarily disables waypoints obstructed by the other sub.
|
||||
/// </summary>
|
||||
public void DisableObstructedWayPoints(Submarine otherSub)
|
||||
{
|
||||
if (otherSub == null) { return; }
|
||||
if (otherSub == this) { return; }
|
||||
// Check collisions to other subs. Currently only walls are taken into account.
|
||||
foreach (var node in OutdoorNodes)
|
||||
{
|
||||
if (node == null || node.Waypoint == null) { continue; }
|
||||
var wp = node.Waypoint;
|
||||
if (wp.isObstructed) { continue; }
|
||||
foreach (var connection in node.connections)
|
||||
{
|
||||
bool isObstructed = false;
|
||||
var connectedWp = connection.Waypoint;
|
||||
if (connectedWp.isObstructed) { continue; }
|
||||
Vector2 start = ConvertUnits.ToSimUnits(wp.WorldPosition) - otherSub.SimPosition;
|
||||
Vector2 end = ConvertUnits.ToSimUnits(connectedWp.WorldPosition) - otherSub.SimPosition;
|
||||
var body = Submarine.PickBody(start, end, null, Physics.CollisionWall, allowInsideFixture: false);
|
||||
if (body != null && body.UserData is Structure && !((Structure)body.UserData).IsPlatform)
|
||||
{
|
||||
connectedWp.isObstructed = true;
|
||||
wp.isObstructed = true;
|
||||
obstructedNodes.Add(node);
|
||||
obstructedNodes.Add(connection);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Only affects temporarily disabled waypoints.
|
||||
/// </summary>
|
||||
public void EnableObstructedWaypoints()
|
||||
{
|
||||
foreach (var node in obstructedNodes)
|
||||
{
|
||||
node.Waypoint.isObstructed = false;
|
||||
}
|
||||
obstructedNodes.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,6 +32,8 @@ namespace Barotrauma
|
||||
public Ladder Ladders;
|
||||
public Structure Stairs;
|
||||
|
||||
public bool isObstructed;
|
||||
|
||||
private ushort gapId;
|
||||
public Gap ConnectedGap
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user