Inheritance: BioCodexEntry
            public BioCodexSection ReadCodexSection()
            {
                var section = new BioCodexSection();

                ReadCodexEntry(section);

                section.IsPrimary = ReadInt32().ToBoolean();

                return(section);
            }
		public static BioCodexMap Load( string path)
		{
			if (path.IsNullOrEmpty())
			{
				throw new ArgumentNullException(nameof(path));
			}

			var map = new BioCodexMap();

			if (!File.Exists(path))
			{
				return map;
			}

			var doc = XDocument.Load(path);
			var root = doc.Root;

			if (root == null)
			{
				return map;
			}

			var pagesElement = root.Element("CodexPages");

			if (pagesElement != null)
			{
				var xCodexPages = from el in pagesElement.Elements("Page") select el;

				foreach (var xCodexPage in xCodexPages)
				{
					var id = (int?) xCodexPage.Attribute("Id");

					if (id == null)
					{
						continue;
					}

					var codexPage = new BioCodexPage
					{
						CodexSound = (int?) xCodexPage.Attribute("CodexSound") ?? BioCodexEntry.DefaultCodexSound,
						Description = (int?) xCodexPage.Attribute("Description") ?? BioCodexEntry.DefaultDescription,
						InstanceVersion = (int?) xCodexPage.Attribute("InstanceVersion") ?? BioCodexEntry.DefaultInstanceVersion,
						Priority = (int?) xCodexPage.Attribute("Priority") ?? BioCodexEntry.DefaultPriority,
						Section = (int?) xCodexPage.Attribute("Section") ?? BioCodexPage.DefaultSection,
						TextureIndex = (int?) xCodexPage.Attribute("TextureIndex") ?? BioCodexEntry.DefaultTextureIndex,
						Title = (int?) xCodexPage.Attribute("Title") ?? BioCodexEntry.DefaultTitle
					};

					map.Pages.Add((int) id, codexPage);
				}
			}

			var sectionsElement = root.Element("CodexSections");

			if (sectionsElement != null)
			{
				var xCodexSections = from el in sectionsElement.Elements("Section") select el;

				foreach (var xCodexSection in xCodexSections)
				{
					var id = (int?) xCodexSection.Attribute("Id");

					if (id == null)
					{
						continue;
					}

					var codexSection = new BioCodexSection
					{
						CodexSound = (int?) xCodexSection.Attribute("CodexSound") ?? BioCodexEntry.DefaultCodexSound,
						Description = (int?) xCodexSection.Attribute("Description") ?? BioCodexEntry.DefaultDescription,
						InstanceVersion = (int?) xCodexSection.Attribute("InstanceVersion") ?? BioCodexEntry.DefaultInstanceVersion,
						IsPrimary = (bool?) xCodexSection.Attribute("IsPrimary") ?? BioCodexSection.DefaultIsPrimary,
						Priority = (int?) xCodexSection.Attribute("Priority") ?? BioCodexEntry.DefaultPriority,
						TextureIndex = (int?) xCodexSection.Attribute("TextureIndex") ?? BioCodexEntry.DefaultTextureIndex,
						Title = (int?) xCodexSection.Attribute("Title") ?? BioCodexEntry.DefaultTitle
					};

					map.Sections.Add((int) id, codexSection);
				}
			}

			return map;
		}
            public void Write(BioCodexSection section)
            {
                WriteCodexEntry(section);

                Write(section.IsPrimary.ToInt32());
            }
			public void Write(BioCodexSection section)
			{
				WriteCodexEntry(section);

				Write(section.IsPrimary.ToInt32());
			}
			public BioCodexSection ReadCodexSection()
			{
				var section = new BioCodexSection();

				ReadCodexEntry(section);

				section.IsPrimary = ReadInt32().ToBoolean();

				return section;
			}
Exemple #6
0
        public static BioCodexMap Load(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException(nameof(path));
            }

            var map = new BioCodexMap();

            if (!File.Exists(path))
            {
                return(map);
            }

            var doc  = XDocument.Load(path);
            var root = doc.Root;

            if (root == null)
            {
                return(map);
            }

            var pagesElement = root.Element("CodexPages");

            if (pagesElement != null)
            {
                var xCodexPages = from el in pagesElement.Elements("Page") select el;

                foreach (var xCodexPage in xCodexPages)
                {
                    var id = (int?)xCodexPage.Attribute("Id");

                    if (id == null)
                    {
                        continue;
                    }

                    var codexPage = new BioCodexPage
                    {
                        CodexSound       = (int?)xCodexPage.Attribute("CodexSound") ?? BioCodexEntry.DefaultCodexSound,
                        CodexSoundString = (string)xCodexPage.Attribute("CodexSoundString") ?? BioCodexEntry.DefaultCodexSoundString,
                        Description      = (int?)xCodexPage.Attribute("Description") ?? BioCodexEntry.DefaultDescription,
                        InstanceVersion  = (int?)xCodexPage.Attribute("InstanceVersion") ?? BioCodexEntry.DefaultInstanceVersion,
                        Priority         = (int?)xCodexPage.Attribute("Priority") ?? BioCodexEntry.DefaultPriority,
                        Section          = (int?)xCodexPage.Attribute("Section") ?? BioCodexPage.DefaultSection,
                        TextureIndex     = (int?)xCodexPage.Attribute("TextureIndex") ?? BioCodexEntry.DefaultTextureIndex,
                        Title            = (int?)xCodexPage.Attribute("Title") ?? BioCodexEntry.DefaultTitle
                    };

                    map.Pages.Add((int)id, codexPage);
                }
            }

            var sectionsElement = root.Element("CodexSections");

            if (sectionsElement != null)
            {
                var xCodexSections = from el in sectionsElement.Elements("Section") select el;

                foreach (var xCodexSection in xCodexSections)
                {
                    var id = (int?)xCodexSection.Attribute("Id");

                    if (id == null)
                    {
                        continue;
                    }

                    var codexSection = new BioCodexSection
                    {
                        CodexSound       = (int?)xCodexSection.Attribute("CodexSound") ?? BioCodexEntry.DefaultCodexSound,
                        CodexSoundString = (string)xCodexSection.Attribute("CodexSoundString") ?? BioCodexEntry.DefaultCodexSoundString,
                        Description      = (int?)xCodexSection.Attribute("Description") ?? BioCodexEntry.DefaultDescription,
                        InstanceVersion  = (int?)xCodexSection.Attribute("InstanceVersion") ?? BioCodexEntry.DefaultInstanceVersion,
                        IsPrimary        = (bool?)xCodexSection.Attribute("IsPrimary") ?? BioCodexSection.DefaultIsPrimary,
                        Priority         = (int?)xCodexSection.Attribute("Priority") ?? BioCodexEntry.DefaultPriority,
                        TextureIndex     = (int?)xCodexSection.Attribute("TextureIndex") ?? BioCodexEntry.DefaultTextureIndex,
                        Title            = (int?)xCodexSection.Attribute("Title") ?? BioCodexEntry.DefaultTitle
                    };

                    map.Sections.Add((int)id, codexSection);
                }
            }

            return(map);
        }