public string ThemeValidityError(Configuration.Theme theme) { if (!m_themes.ContainsKey(theme)) { InitBuildingLists(); if (!m_themes.ContainsKey(theme)) { return("Theme not found"); } } List <BuildingItem> list = m_themes[theme]; ThemeValidity validity = ThemeValidity.Valid; int includedCount = 0; int l1Count = 0; foreach (BuildingItem item in list) { if (item.included) { includedCount++; if (item.level == 1) { l1Count++; } if (item.prefab == null) { validity |= ThemeValidity.BuildingNotLoaded; } } } if (includedCount == 0) { validity |= ThemeValidity.Empty; } if (l1Count == 0) { validity |= ThemeValidity.MissingL1; } if (validity == 0) { return(null); } StringBuilder errorMessage = new StringBuilder(); if ((validity & ThemeValidity.Empty) == ThemeValidity.Empty) { errorMessage.Append("No building included.\n"); } else if ((validity & ThemeValidity.MissingL1) == ThemeValidity.MissingL1) { errorMessage.Append("No level 1 building included.\n"); } if ((validity & ThemeValidity.BuildingNotLoaded) == ThemeValidity.BuildingNotLoaded) { errorMessage.Append("Not all buildings are loaded.\n"); } errorMessage.Length--; return(errorMessage.ToString());; }
public string ThemeValidityError(Configuration.Theme theme) { if (!m_themes.ContainsKey(theme)) { InitBuildingLists(); if (!m_themes.ContainsKey(theme)) { return("Theme not found"); } } List <BuildingItem> list = m_themes[theme]; ThemeValidity validity = ThemeValidity.Valid; int includedCount = 0; int l1Count = 0; foreach (BuildingItem item in list) { if (item.included) { includedCount++; if (item.prefab == null) { if (item.building != null) { if (item.building.dlc != null && !PlatformService.IsDlcInstalled(Convert.ToUInt32(item.building.dlc))) { continue; } if (item.building.environments != null && (item.building.environments.Contains("-" + SimulationManager.instance.m_metaData.m_environment) || !item.building.environments.Contains("+" + SimulationManager.instance.m_metaData.m_environment))) { continue; } } validity |= ThemeValidity.BuildingNotLoaded; } if (item.level == 1) { l1Count++; } } } if (includedCount == 0) { validity |= ThemeValidity.Empty; } if (l1Count == 0) { validity |= ThemeValidity.MissingL1; } if (validity == 0) { return(null); } StringBuilder errorMessage = new StringBuilder(); if ((validity & ThemeValidity.Empty) == ThemeValidity.Empty) { errorMessage.Append("No building included.\n"); } else if ((validity & ThemeValidity.MissingL1) == ThemeValidity.MissingL1) { errorMessage.Append("No level 1 building included.\n"); } if ((validity & ThemeValidity.BuildingNotLoaded) == ThemeValidity.BuildingNotLoaded) { errorMessage.Append("Not all buildings are loaded.\n"); } errorMessage.Length--; return(errorMessage.ToString());; }