Esempio n. 1
0
        /// <summary>
        /// Loads prop data from given XML file.
        /// </summary>
        /// <param name="filePath"></param>
        public static void Load(Stream stream)
        {
            using (var sr = new StreamReader(stream, true))
                using (var xmlReader = new XmlTextReader(sr))
                {
                    while (xmlReader.ReadToFollowing("PropClass"))
                    {
                        var entry = new PropDbEntry();

                        entry.ClassID             = int.Parse(xmlReader.GetAttribute("ClassID"));
                        entry.ClassName           = xmlReader.GetAttribute("ClassName");
                        entry.ClassPath           = xmlReader.GetAttribute("ClassPath");
                        entry.ColorType           = int.Parse(xmlReader.GetAttribute("ColorType"));
                        entry.IsTerrainBlock      = (xmlReader.GetAttribute("IsTerrainBlock") == "true");
                        entry.ExtraXML            = xmlReader.GetAttribute("ExtraXML");
                        entry.Events              = xmlReader.GetAttribute("Events");
                        entry.Actions             = xmlReader.GetAttribute("Actions");
                        entry.HasState            = (xmlReader.GetAttribute("HasState") == "true");
                        entry.Name                = xmlReader.GetAttribute("Name");
                        entry.ShowName            = (xmlReader.GetAttribute("ShowName") == "true");
                        entry.IsHugeProp          = (xmlReader.GetAttribute("IsHugeProp") == "true");
                        entry.UsedServer          = (xmlReader.GetAttribute("UsedServer") == "true");
                        entry.NonTrivialAnimation = (xmlReader.GetAttribute("NonTrivialAnimation") == "true");
                        entry.PickRestrict        = (xmlReader.GetAttribute("PickRestrict") == "true");
                        entry.StringID            = xmlReader.GetAttribute("StringID") ?? "";

                        var soundDescIDs = xmlReader.GetAttribute("SoundDescIDs");
                        if (soundDescIDs != null)
                        {
                            var split = soundDescIDs.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                            var ids   = new int[split.Length];

                            for (var i = 0; i < split.Length; ++i)
                            {
                                ids[i] = int.Parse(split[i]);
                            }

                            entry.SoundDescIDs = ids;
                        }

                        if (entry.ExtraXML != null)
                        {
                            entry.ExtraXML = FixXml(entry.ExtraXML);
                            entry.Feature  = GetFeatureFromExtraXml(entry.ExtraXML);

                            //System.Xml.Linq.XDocument.Parse(entry.ExtraXML);
                        }

                        _entries[entry.ClassID] = entry;
                    }
                }
        }
Esempio n. 2
0
 /// <summary>
 /// Returns entry with given class id via out if it exists, or null
 /// if it doesn't.
 /// </summary>
 /// <param name="classId"></param>
 /// <param name="entry"></param>
 public static bool TryGetEntry(int classId, out PropDbEntry entry)
 {
     return(_entries.TryGetValue(classId, out entry));
 }