public static bool LoadFiles(List <YamlIO.Error> errors) { if (worlds.worldCache.Count > 0) { return(false); } worlds.LoadFiles(GetPath(), errors); List <FileHandle> list = new List <FileHandle>(); FileSystem.GetFiles(FileSystem.Normalize(System.IO.Path.Combine(path, "traits")), "*.yaml", list); foreach (FileHandle item in list) { FileHandle trait_file = item; WorldTrait worldTrait = YamlIO.LoadFile <WorldTrait>(trait_file.full_path, delegate(YamlIO.Error error, bool force_log_as_warning) { error.file = trait_file; errors.Add(error); }, null); int num = FirstUncommonCharacter(path, trait_file.full_path); string text = (num <= -1) ? trait_file.full_path : trait_file.full_path.Substring(num); text = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(text), System.IO.Path.GetFileNameWithoutExtension(text)); if (worldTrait == null) { DebugUtil.LogWarningArgs("Failed to load trait: ", text); } else { traits[text] = worldTrait; } } foreach (KeyValuePair <string, World> item2 in worlds.worldCache) { LoadFeatures(item2.Value.globalFeatures, errors); LoadSubworlds(item2.Value.subworldFiles, errors); } foreach (KeyValuePair <string, WorldTrait> trait in traits) { LoadFeatures(trait.Value.globalFeatureMods, errors); LoadSubworlds(trait.Value.additionalSubworldFiles, errors); } layers = MergeLoad <LevelLayerSettings>(GetPath() + "layers.yaml", errors); layers.LevelLayers.ConvertBandSizeToMaxSize(); rivers = MergeLoad <ComposableDictionary <string, River> >(GetPath() + "rivers.yaml", errors); rooms = MergeLoad <ComposableDictionary <string, Room> >(path + "rooms.yaml", errors); foreach (KeyValuePair <string, Room> room in rooms) { room.Value.name = room.Key; } temperatures = MergeLoad <ComposableDictionary <Temperature.Range, Temperature> >(GetPath() + "temperatures.yaml", errors); borders = MergeLoad <ComposableDictionary <string, List <WeightedSimHash> > >(GetPath() + "borders.yaml", errors); defaults = YamlIO.LoadFile <DefaultSettings>(GetPath() + "defaults.yaml", null, null); mobs = MergeLoad <MobSettings>(GetPath() + "mobs.yaml", errors); foreach (KeyValuePair <string, Mob> item3 in mobs.MobLookupTable) { item3.Value.name = item3.Key; } DebugUtil.LogArgs("World settings reload complete!"); return(true); }
private void ApplyTrait(WorldTrait trait) { world.ModStartLocation(trait.startingBasePositionHorizontalMod, trait.startingBasePositionVerticalMod); foreach (WeightedName additionalSubworldFile in trait.additionalSubworldFiles) { world.subworldFiles.Add(additionalSubworldFile); } foreach (World.AllowedCellsFilter additionalUnknownCellFilter in trait.additionalUnknownCellFilters) { world.unknownCellsAllowedSubworlds.Add(additionalUnknownCellFilter); } foreach (KeyValuePair <string, int> globalFeatureTemplateMod in trait.globalFeatureTemplateMods) { if (!world.globalFeatureTemplates.ContainsKey(globalFeatureTemplateMod.Key)) { world.globalFeatureTemplates[globalFeatureTemplateMod.Key] = 0; } Dictionary <string, int> globalFeatureTemplates; string key; (globalFeatureTemplates = world.globalFeatureTemplates)[key = globalFeatureTemplateMod.Key] = globalFeatureTemplates[key] + globalFeatureTemplateMod.Value; } foreach (KeyValuePair <string, int> globalFeatureMod in trait.globalFeatureMods) { if (!world.globalFeatures.ContainsKey(globalFeatureMod.Key)) { world.globalFeatures[globalFeatureMod.Key] = 0; } Dictionary <string, int> globalFeatureTemplates; string key2; (globalFeatureTemplates = world.globalFeatures)[key2 = globalFeatureMod.Key] = globalFeatureTemplates[key2] + globalFeatureMod.Value; } foreach (KeyValuePair <string, ElementBandConfiguration> biomeBackgroundElementBandConfiguration in biomes.BiomeBackgroundElementBandConfigurations) { foreach (ElementGradient item in biomeBackgroundElementBandConfiguration.Value) { foreach (WorldTrait.ElementBandModifier elementBandModifier in trait.elementBandModifiers) { if (elementBandModifier.element == item.content) { item.Mod(elementBandModifier); } } } } }