// Returns X, Y, NeedsRemoval public Tuple <int, int, bool> FindValidLocation(FarmObject cabin) { // First, check if the inital location has any overlaps var initialOverlaps = ObjectsList.Select(x => FindAllOverlaps(x, cabin)); if (!initialOverlaps.Any()) { // And if there aren't any, return the cabin's initial X,Y return(new Tuple <int, int, bool>(cabin.TileX, cabin.TileY, false)); } var optimalLocation = FindPossibleLocations(GenerateOptimalLocations(), cabin); if (optimalLocation != null) { return(optimalLocation); } // If no optimal location works, start looking everywhere var location = FindPossibleLocations(GenerateEntireMapLocations(), cabin); if (location != null) { return(location); } // If nowhere works, return nothing, no location is valid, inform the player. return(null); }