public static IDictionary <string, TerrainEffect> BuildDictionary(TerrainEffectsConfig config) { IDictionary <string, TerrainEffect> terrainEffects = new Dictionary <string, TerrainEffect>(); foreach (IList <object> row in config.Query.Data) { try { IList <string> effect = row.Select(r => r.ToString()).ToList(); string name = ParseHelper.SafeStringParse(effect, config.Name, "Name", false); if (string.IsNullOrEmpty(name)) { continue; } if (!terrainEffects.TryAdd(name, new TerrainEffect(config, effect))) { throw new NonUniqueObjectNameException("terrain effect"); } } catch (Exception ex) { throw new TerrainEffectProcessingException((row.ElementAtOrDefault(config.Name) ?? string.Empty).ToString(), ex); } } return(terrainEffects); }
public TerrainEffect(TerrainEffectsConfig config, IList <string> data) { this.Matched = false; this.Name = ParseHelper.SafeStringParse(data, config.Name, "Name", true); this.SpriteURL = ParseHelper.SafeURLParse(data, config.SpriteURL, "Sprite URL", true); this.Size = ParseHelper.OptionalInt_NonZeroPositive(data, config.Size, "Size"); this.Layer = GetTerrainEffectLayerEnum(data.ElementAtOrDefault <string>(config.Layer)); this.TextFields = ParseHelper.StringListParse(data, config.TextFields); this.HPModifier = ParseHelper.OptionalInt_Any(data, config.HPModifier, "HP Modifier"); this.CombatStatModifiers = new Dictionary <string, int>(); foreach (NamedStatConfig stat in config.CombatStatModifiers) { int val = ParseHelper.Int_Any(data, stat.Value, stat.SourceName + " Modifier"); if (val == 0) { continue; } this.CombatStatModifiers.Add(stat.SourceName, val); } this.StatModifiers = new Dictionary <string, int>(); foreach (NamedStatConfig stat in config.StatModifiers) { int val = ParseHelper.Int_Any(data, stat.Value, stat.SourceName + " Modifier"); if (val == 0) { continue; } this.StatModifiers.Add(stat.SourceName, val); } }