public static void FindConnectedLocations(GameLocation location, Vector2 startPosition, List <ConnectedTile> processedLocations, bool allowDiagonals) { var adjecantTiles = GetAdjecantTiles(location, startPosition, allowDiagonals); foreach (var adjecantTile in adjecantTiles.Where(t => processedLocations.All(l => l.Location != t))) { if (location.objects.ContainsKey(adjecantTile) && (location.objects[adjecantTile] is Chest || ConnectorItems.Contains(location.objects[adjecantTile].Name))) { var connectedTile = new ConnectedTile { Location = adjecantTile, }; var chest = location.objects[adjecantTile] as Chest; if (chest != null) { connectedTile.Chest = chest; } else { connectedTile.Object = location.objects[adjecantTile]; } processedLocations.Add(connectedTile); FindConnectedLocations(location, adjecantTile, processedLocations, allowDiagonals); } else if (location.terrainFeatures.ContainsKey(adjecantTile)) { var feature = location.terrainFeatures[adjecantTile] as Flooring; if (feature == null) { continue; } if (ConnectorFloorings.Contains(feature.whichFloor)) { processedLocations.Add(new ConnectedTile { Location = adjecantTile }); FindConnectedLocations(location, adjecantTile, processedLocations, allowDiagonals); } } } }
public bool Equals(ConnectedTile obj) { return(Location.Equals(obj?.Location)); }