public override void Initialise(params VirtualDirectory[] db) { DBFile[] anceffecttables = EsfLibraryExtension.getDBFiles(GameInfo.ancillary_to_effects_tables, db); foreach (var anceffecttable in anceffecttables) { Parallel.ForEach(anceffecttable.Entries, anceffect => { string id = anceffect["ancillary"].Value; string effectid = anceffect["effect"].Value; string scopeid = anceffect["effect_scope"].Value; string value = anceffect["value"].Value; GameItemsWithEffects ancillary; lock (this) if (ContainsKey(id)) { ancillary = this[id] as GameItemsWithEffects; } else { ancillary = new Ancillary() { name = id }; Add(id, ancillary); } ancillary.addEffect(effectid, value, scopeid); }); } }
protected void iterateDBs(Action <DBRow> process, string DBpath, params VirtualDirectory[] db) { DBFile[] dBFiles = EsfLibraryExtension.getDBFiles(DBpath, db); foreach (var dBFile in dBFiles) { foreach (var row in dBFile.Entries) { process(row); } } }
public override void Initialise(params VirtualDirectory[] db) { DBFile[] traitleveleffectstables = EsfLibraryExtension.getDBFiles(GameInfo.trait_level_effects_tables, db); DBFile[] traitleveltables = EsfLibraryExtension.getDBFiles(GameInfo.character_trait_levels_tables, db); int effectCount = 0; foreach (var traitleveleffectstable in traitleveleffectstables) { effectCount += (int)traitleveleffectstable.Header.EntryCount; } Dictionary <string, List <Effect> > temptraiteffects = new Dictionary <string, List <Effect> >(effectCount); foreach (var traitleveleffectstable in traitleveleffectstables) { foreach (var leveledtraitrow in traitleveleffectstable.Entries) { string rankkey = leveledtraitrow["trait_level"].Value; string effectid = leveledtraitrow["effect"].Value; string scope = leveledtraitrow["effect_scope"].Value; string value = leveledtraitrow["value"].Value; var new_effect = new Effect() { name = effectid, description = value, scope = scope }; List <Effect> effects; bool declared = temptraiteffects.TryGetValue(rankkey, out effects); if (declared) { effects.Add(new_effect); } else { temptraiteffects.Add(rankkey, new List <Effect>(3) { new_effect }); } } } foreach (var traitleveltable in traitleveltables) { Parallel.ForEach(traitleveltable.Entries, trait => { string key = trait["trait"].Value; int rank = int.Parse(trait["threshold_points"].Value); int level = int.Parse(trait["level"].Value); string rankkey = trait["key"].Value; List <Effect> effects; bool declared = temptraiteffects.TryGetValue(rankkey, out effects); if (declared) { Trait trait_entry; lock (this) if (ContainsKey(key)) { trait_entry = (Trait)this[key]; } else { trait_entry = new Trait() { name = key }; Add(key, trait_entry); } trait_entry.addRank(level, rank, rankkey, effects); } }); } }
public override void Initialise(params VirtualDirectory[] db) { Task[] tasks = new Task[2]; DBFile[] characterskilltables = EsfLibraryExtension.getDBFiles(GameInfo.character_skills_tables, db); foreach (var characterskilltable in characterskilltables) { foreach (var skill_entry in characterskilltable.Entries) { string id = skill_entry["key"].Value; var skill = new Skill() { name = id, background = skill_entry["is_background_skill"].Value.Equals(true.ToString()) }; Add(id, skill); } } tasks[0] = Task.Factory.StartNew(delegate { DBFile[] characterskillnodetables = EsfLibraryExtension.getDBFiles(GameInfo.character_skill_nodes_tables, db);//3 factions, 7 subcultures foreach (var characterskillnodetable in characterskillnodetables) { Parallel.ForEach(characterskillnodetable.Entries, characterskillnode => { string indent = characterskillnode["indent"].Value; string tier = characterskillnode["tier"].Value; string id = characterskillnode["character_skill_key"].Value; try { Skill skill = this[id] as Skill; skill.indent = indent; skill.tier = tier; } catch { Console.WriteLine("Cannot find skill " + id + " in " + GameInfo.character_skill_nodes_tables); } }); } }); tasks[1] = Task.Factory.StartNew(delegate { DBFile[] characterskilleffecttables = EsfLibraryExtension.getDBFiles(GameInfo.character_skill_level_to_effects_junctions_tables, db); foreach (var characterskilleffecttable in characterskilleffecttables) { Parallel.ForEach(characterskilleffecttable.Entries, characterskilleffect => { string id = characterskilleffect["character_skill_key"].Value; string effectid = characterskilleffect["effect_key"].Value; int rank = int.Parse(characterskilleffect["level"].Value); string value = characterskilleffect["value"].Value; string scope = characterskilleffect["effect_scope"].Value; try { var skill = this[id] as Skill; skill.addEffect(rank, effectid, value, scope); } catch { Console.WriteLine("Cannot find skill " + id + " in " + GameInfo.character_skill_level_to_effects_junctions_tables); } }); } }); Task.WaitAll(tasks); }