Tons of AI + pathfinding bugfixes:

- waypoints are created between docked subs and removed when they undock
- fixed start waypoint being left out of steering paths
- NPCs won't close doors/hatches on themselves
- NPCs won't let go of ladders until their feet are above the lower edge of the hull
- fixed FindDivingGear "loops": need to find a suit -> need to get to a suit -> need a suit to get to the suit -> need to find a suit...
- fixed characters constantly turning from side to side in small rooms
- recursive function for finding the button which opens a door (so a button doesn't have to be connected straight to a door for an NPC to be able to open it)
- AIObjectiveGetItem keeps searching for more suitable items even if a path to a matching item has been found
This commit is contained in:
Regalis
2016-07-08 20:53:11 +03:00
parent c8dae18135
commit a5111d33df
17 changed files with 397 additions and 125 deletions
+41 -4
View File
@@ -1060,13 +1060,22 @@ namespace Barotrauma
}
}
public List<T> GetConnectedComponents<T>()
public List<T> GetConnectedComponents<T>(bool recursive = false)
{
ConnectionPanel connectionPanel = GetComponent<ConnectionPanel>();
if (connectionPanel == null) return new List<T>();
List<T> connectedComponents = new List<T>();
if (recursive)
{
List<Item> alreadySearched = new List<Item>() {this};
GetConnectedComponentsRecursive<T>(alreadySearched, connectedComponents);
return connectedComponents;
}
ConnectionPanel connectionPanel = GetComponent<ConnectionPanel>();
if (connectionPanel == null) return connectedComponents;
foreach (Connection c in connectionPanel.Connections)
{
var recipients = c.Recipients;
@@ -1080,6 +1089,34 @@ namespace Barotrauma
return connectedComponents;
}
private void GetConnectedComponentsRecursive<T>(List<Item> alreadySearched, List<T> connectedComponents)
{
alreadySearched.Add(this);
ConnectionPanel connectionPanel = GetComponent<ConnectionPanel>();
if (connectionPanel == null) return;
foreach (Connection c in connectionPanel.Connections)
{
var recipients = c.Recipients;
foreach (Connection recipient in recipients)
{
if (alreadySearched.Contains(recipient.Item)) continue;
var component = recipient.Item.GetComponent<T>();
if (component != null)
{
connectedComponents.Add(component);
}
recipient.Item.GetConnectedComponentsRecursive<T>(alreadySearched, connectedComponents);
}
}
}
public void SendSignal(int stepsTaken, string signal, string connectionName, float power = 0.0f)
{
stepsTaken++;