/// <summary> /// Combine the provided DefinitionCollections, replacing earlier copies /// of duplicate definitions with later ones. /// </summary> /// <param name="dictionaries">The dictionaries to combine.</param> /// <returns>A new DefinitionDictionary built from the input list, with /// every unique definition from each dictionary present and accounted /// for, but duplicate definitions represented by whichever copy is /// found in the dictionary with the highest index in the input list.</returns> public static DefinitionDictionary Stack(this List <DefinitionDictionary> dictionaries) { var stacked = new DefinitionDictionary(); foreach (var dictionary in dictionaries) { foreach (var definition in dictionary.Values) { var updated = new Definition(definition) { DefinitionCollection = stacked }; if (stacked.ContainsKey(definition.ClassName)) { stacked[definition.ClassName] = updated; } else { stacked.Add(definition.ClassName, updated); } } } return(stacked); }
public QuakeMapObject(Block block, DefinitionDictionary definitions, TextureDictionary textures) : base(block, definitions, textures) { QuakeBlock quakeBlock; if (block is QuakeBlock) { quakeBlock = block as QuakeBlock; } else { throw new ArgumentException("Provided Block isn't actually a QuakeBlock!"); } KeyVals = new Dictionary <string, Option>(quakeBlock.KeyVals); if (definitions.ContainsKey(KeyVals["classname"].Value)) { Definition = definitions[KeyVals["classname"].Value]; } else { Definition = new Definition(); } Saveability = Definition.Saveability; TextureCollection = textures; foreach (Block child in quakeBlock.Children) { if (child.KeyVals.Count > 0) { Children.Add(new QuakeMapObject(child, definitions, textures)); } else { ExtractRenderables(child); } } ExtractRenderables(quakeBlock); UpdateBounds(); Position = Aabb.Center; if (KeyVals.ContainsKey("origin")) { Position = KeyVals["origin"].Value.ToVector3(); } else if (Definition.ClassName == "worldspawn") { Position = new Vector3(0, 0, 0); } }