public static bool HaveConnectorsInInventoryChanged(EventArgsInventoryChanged inventoryChange) { var changes = inventoryChange.Added.Concat(inventoryChange.QuantityChanged).Concat(inventoryChange.Removed); if (changes.Any(i => ConnectorItems.Contains(i.Item.Name) || i.Item is Chest || i.Item.category == Object.furnitureCategory)) { return(true); } return(false); }
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); } } } }