static SpawnGroup() { string path = Path.Combine(Core.BaseDirectory, "Data/SpawnDefinitions.xml"); if (!File.Exists(path)) { return; } try { XmlDocument doc = new XmlDocument(); doc.Load(path); XmlElement root = doc["spawnDefinitions"]; if (root == null) { return; } foreach (XmlElement xmlDef in root.SelectNodes("spawnGroup")) { string name = null; if (!Region.ReadString(xmlDef, "name", ref name)) { continue; } List <SpawnGroupElement> list = new List <SpawnGroupElement>(); foreach (XmlNode node in xmlDef.ChildNodes) { XmlElement el = node as XmlElement; if (el != null) { SpawnDefinition def = GetSpawnDefinition(el); if (def == null) { continue; } int weight = 1; Region.ReadInt32(el, "weight", ref weight, false); SpawnGroupElement groupElement = new SpawnGroupElement(def, weight); list.Add(groupElement); } } SpawnGroupElement[] elements = list.ToArray(); SpawnGroup group = new SpawnGroup(name, elements); Register(group); } } catch (Exception ex) { Console.WriteLine("Could not load SpawnDefinitions.xml: "); Diagnostics.ExceptionLogging.LogException(ex); } }
public static void Register( SpawnGroup group ) { if ( m_Table.Contains( group.Name ) ) Console.WriteLine( "Warning: Double SpawnGroup name '{0}'", group.Name ); else m_Table[group.Name] = group; }
public static void Register(SpawnGroup group) { if (Table.ContainsKey(group.Name)) { Console.WriteLine("Warning: Double SpawnGroup name '{0}'", group.Name); } else { Table[group.Name] = group; } }
static SpawnGroup() { string path = Path.Combine( Core.BaseDirectory, "Data/SpawnDefinitions.xml" ); if ( !File.Exists( path ) ) return; try { XmlDocument doc = new XmlDocument(); doc.Load( path ); XmlElement root = doc["spawnDefinitions"]; if ( root == null ) return; foreach ( XmlElement xmlDef in root.SelectNodes( "spawnGroup" ) ) { string name = null; if ( !Region.ReadString( xmlDef, "name", ref name ) ) continue; List<SpawnGroupElement> list = new List<SpawnGroupElement>(); foreach ( XmlNode node in xmlDef.ChildNodes ) { XmlElement el = node as XmlElement; if ( el != null ) { SpawnDefinition def = GetSpawnDefinition( el ); if ( def == null ) continue; int weight = 1; Region.ReadInt32( el, "weight", ref weight, false ); SpawnGroupElement groupElement = new SpawnGroupElement( def, weight ); list.Add( groupElement ); } } SpawnGroupElement[] elements = list.ToArray(); SpawnGroup group = new SpawnGroup( name, elements ); Register( group ); } } catch ( Exception ex ) { Console.WriteLine( "Could not load SpawnDefinitions.xml: " + ex.Message ); } }