private Configuration.Theme AddImportedTheme(List <Configuration.Building> builtInBuildings, string themeName, string stylePackage)
        {
            var theme = Configuration.getTheme(themeName);

            if (theme == null)
            {
                theme = new Configuration.Theme
                {
                    name         = themeName,
                    stylePackage = stylePackage
                };
                Configuration.themes.Add(theme);
            }
            theme.isBuiltIn = true;
            if (builtInBuildings != null)
            {
                foreach (var builtInBuilding in builtInBuildings)
                {
                    var building = theme.getBuilding(builtInBuilding.name);
                    if (building == null)
                    {
                        building = new Configuration.Building(builtInBuilding);
                        theme.buildings.Add(building);
                    }
                    else if (building.builtInBuilding == null)
                    {
                        building.builtInBuilding = builtInBuilding;
                    }
                    building.fromStyle = builtInBuilding.fromStyle;
                }
            }

            return(theme);
        }
Пример #2
0
        private void AddModTheme(Configuration.Theme theme, string modName)
        {
            if (theme == null)
            {
                return;
            }

            var existingTheme = _configuration.getTheme(theme.name);

            if (existingTheme == null)
            {
                existingTheme = new Configuration.Theme(theme.name);
                _configuration.themes.Add(existingTheme);
            }

            existingTheme.isBuiltIn = true;

            foreach (var builtInBuilding in theme.buildings)
            {
                Configuration.Building existingBuilding = existingTheme.getBuilding(builtInBuilding.name);

                if (existingBuilding == null)
                {
                    var building = new Configuration.Building(builtInBuilding);
                    existingTheme.buildings.Add(building);
                }
                else if (existingBuilding.builtInBuilding == null)
                {
                    existingBuilding.builtInBuilding = builtInBuilding;
                }
            }

            Debugger.LogFormat("Building Themes: Theme {0} added by mod {1}", theme.name, modName);
        }
        private void AddModTheme(Configuration.Theme modTheme, string modName)
        {
            if (modTheme == null)
            {
                return;
            }
            var theme = AddImportedTheme(modTheme.buildings, modTheme.name, null);

            Debugger.LogFormat(
                "Imported theme from mod \"{0}\" as theme \"{1}\". Buildings in mod: {2}. Buildings in theme: {3} ",
                modTheme.buildings.Count,
                modName, theme.name, theme.buildings.Count);
        }
        public void DisableTheme(byte districtId, Configuration.Theme theme)
        {
            if (!IsThemeManagementEnabled(districtId))
            {
                return;
            }

            if (Debugger.Enabled)
            {
                Debugger.LogFormat("Building Themes: BuildingThemesManager. Disabling theme {0} for district {1}.", theme.name, districtId);
            }

            if (!districtThemeInfos[districtId].themes.Remove(theme))
            {
                if (Debugger.Enabled)
                {
                    Debugger.LogFormat("Building Themes: BuildingThemesManager. Theme {0} was already disabled for district {1}.", theme.name, districtId);
                }
                return;
            }

            CompileDistrictThemes(districtId);
        }