public void LoadPrefabsFromFile(ContentFile configFile) { var particleElements = new Dictionary <string, XElement>(); XDocument doc = XMLExtensions.TryLoadXml(configFile.Path); if (doc == null) { return; } bool allowOverriding = false; var mainElement = doc.Root; if (doc.Root.IsOverride()) { mainElement = doc.Root.FirstElement(); allowOverriding = true; } foreach (XElement sourceElement in mainElement.Elements()) { var element = sourceElement.IsOverride() ? sourceElement.FirstElement() : sourceElement; string name = element.Name.ToString().ToLowerInvariant(); if (Prefabs.ContainsKey(name) || particleElements.ContainsKey(name)) { if (allowOverriding || sourceElement.IsOverride()) { DebugConsole.NewMessage($"Overriding the existing particle prefab '{name}' using the file '{configFile.Path}'", Color.Yellow); } else { DebugConsole.ThrowError($"Error in '{configFile.Path}': Duplicate particle prefab '{name}' found in '{configFile.Path}'! Each particle prefab must have a unique name. " + "Use <override></override> tags to override prefabs."); continue; } } particleElements.Add(name, element); } foreach (var kvp in particleElements) { Prefabs.Add(new ParticlePrefab(kvp.Value, configFile), allowOverriding); } }