public static Module GetRandomBuilding(BuildProperties buildProps) { List <Module> tempList = buildings.FindAll(b => b.buildProperties.Match(buildProps)); if (tempList.Count <= 0) { Debug.LogError("Building list is empty for this filters combination : " + buildProps.ToString()); return(null); } else { int r = Random.Range(0, tempList.Count); return(tempList[r]); } }