예제 #1
0
        // Singleton initialization
        private SectorMap(IEnumerable <SectorMetafileEntry> metafiles, ResourceManager resourceManager)
        {
            // Load all sectors from all metafiles.
            foreach (var metafile in metafiles)
            {
                SectorCollection collection = resourceManager.GetXmlFileObject(metafile.filename, typeof(SectorCollection), cache: false) as SectorCollection;
                foreach (var sector in collection.Sectors)
                {
                    sector.Tags.AddRange(metafile.tags);
                    sector.AdjustRelativePaths(metafile.filename);
                }
                sectors.Merge(collection);
            }

            // Create/populate individual milieu maps.
            foreach (var sector in sectors.Sectors)
            {
                if (sector.MetadataFile != null)
                {
                    Sector metadata = resourceManager.GetXmlFileObject(sector.MetadataFile, typeof(Sector), cache: false) as Sector;
                    metadata.AdjustRelativePaths(sector.MetadataFile);
                    sector.Merge(metadata);
                }

                GetMilieuMap(sector.CanonicalMilieu).TryAdd(sector);
            }
        }
예제 #2
0
        private SectorMap(List <SectorMetafileEntry> metafiles, ResourceManager resourceManager)
        {
            foreach (var metafile in metafiles)
            {
                SectorCollection collection = resourceManager.GetXmlFileObject(metafile.filename, typeof(SectorCollection), cache: false) as SectorCollection;
                foreach (var sector in collection.Sectors)
                {
                    sector.Tags.AddRange(metafile.tags);
                }

                if (sectors == null)
                {
                    sectors = collection;
                }
                else
                {
                    sectors.Merge(collection);
                }
            }

            milieux.Clear();

            foreach (var sector in sectors.Sectors)
            {
                if (sector.MetadataFile != null)
                {
                    Sector metadata = resourceManager.GetXmlFileObject(@"~/res/Sectors/" + sector.MetadataFile, typeof(Sector), cache: false) as Sector;
                    sector.Merge(metadata);
                }

                string milieu = sector.Milieu ?? sector.DataFile?.Milieu ?? DEFAULT_MILIEU;
                if (!milieux.ContainsKey(milieu))
                {
                    milieux.Add(milieu, new MilieuMap());
                }

                MilieuMap m = milieux[milieu];
                m.locationMap.Add(sector.Location, sector);

                foreach (var name in sector.Names)
                {
                    if (!m.nameMap.ContainsKey(name.Text))
                    {
                        m.nameMap.Add(name.Text, sector);
                    }

                    // Automatically alias "SpinwardMarches"
                    string spaceless = name.Text.Replace(" ", "");
                    if (spaceless != name.Text && !m.nameMap.ContainsKey(spaceless))
                    {
                        m.nameMap.Add(spaceless, sector);
                    }
                }

                if (!string.IsNullOrEmpty(sector.Abbreviation) && !m.nameMap.ContainsKey(sector.Abbreviation))
                {
                    m.nameMap.Add(sector.Abbreviation, sector);
                }
            }
        }
예제 #3
0
        public void Merge(SectorCollection otherCollection)
        {
            if (otherCollection == null)
                throw new ArgumentNullException("otherCollection");

            if (otherCollection.Sectors != null)
                Sectors.AddRange(otherCollection.Sectors);
        }
예제 #4
0
        public void Merge(SectorCollection otherCollection)
        {
            if (otherCollection == null)
            {
                throw new ArgumentNullException(nameof(otherCollection));
            }

            if (otherCollection.Sectors != null)
            {
                Sectors.AddRange(otherCollection.Sectors);
            }
        }
예제 #5
0
        // TODO: Add Dictionary<Pair<x,y>, Sector> for FromLocation lookups

        private SectorMap(List <SectorMetafileEntry> metafiles, ResourceManager resourceManager)
        {
            foreach (var metafile in metafiles)
            {
                SectorCollection collection = resourceManager.GetXmlFileObject(metafile.filename, typeof(SectorCollection), cache: false) as SectorCollection;
                foreach (var sector in collection.Sectors)
                {
                    sector.Tags.AddRange(metafile.tags);
                }
                if (m_sectors == null)
                {
                    m_sectors = collection;
                }
                else
                {
                    m_sectors.Merge(collection);
                }
            }

            m_nameMap.Clear();

            foreach (var sector in m_sectors.Sectors)
            {
                if (sector.MetadataFile != null)
                {
                    Sector metadata = resourceManager.GetXmlFileObject(@"~/res/Sectors/" + sector.MetadataFile, typeof(Sector), cache: false) as Sector;
                    sector.Merge(metadata);
                }

                foreach (var name in sector.Names)
                {
                    try
                    {
                        m_nameMap.Add(name.Text, sector);
                    }
                    catch (ArgumentException)
                    {
                        // If it's already in there, ignore it
                        // FUTURE: Return a list of candidates
                    }
                }

                if (!String.IsNullOrEmpty(sector.Abbreviation) && !m_nameMap.ContainsKey(sector.Abbreviation))
                {
                    m_nameMap.Add(sector.Abbreviation, sector);
                }
            }
        }
예제 #6
0
        public void Merge(SectorCollection otherCollection)
        {
            if (otherCollection == null)
            {
                throw new ArgumentNullException("otherCollection");
            }

            if (Sectors == null)
            {
                Sectors = otherCollection.Sectors;
            }
            else if (otherCollection.Sectors != null)
            {
                Sectors.AddRange(otherCollection.Sectors);
            }
        }
예제 #7
0
        private SectorMap(List<SectorMetafileEntry> metafiles, ResourceManager resourceManager)
        {
            foreach (var metafile in metafiles)
            {
                SectorCollection collection = resourceManager.GetXmlFileObject(metafile.filename, typeof(SectorCollection), cache: false) as SectorCollection;
                foreach (var sector in collection.Sectors)
                    sector.Tags.AddRange(metafile.tags);

                if (sectors == null)
                    sectors = collection;
                else
                    sectors.Merge(collection);
            }

            milieux.Clear();

            foreach (var sector in sectors.Sectors)
            {
                if (sector.MetadataFile != null)
                {
                    Sector metadata = resourceManager.GetXmlFileObject(@"~/res/Sectors/" + sector.MetadataFile, typeof(Sector), cache: false) as Sector;
                    sector.Merge(metadata);
                }

                string milieu = sector.Era ?? sector.DataFile?.Era ?? DEFAULT_MILIEU;
                if (!milieux.ContainsKey(milieu))
                    milieux.Add(milieu, new MilieuMap());

                MilieuMap m = milieux[milieu];
                m.locationMap.Add(sector.Location, sector);

                foreach (var name in sector.Names)
                {
                    if (!m.nameMap.ContainsKey(name.Text))
                        m.nameMap.Add(name.Text, sector);

                    // Automatically alias "SpinwardMarches"
                    string spaceless = name.Text.Replace(" ", "");
                    if (spaceless != name.Text && !m.nameMap.ContainsKey(spaceless))
                        m.nameMap.Add(spaceless, sector);
                }

                if (!string.IsNullOrEmpty(sector.Abbreviation) && !m.nameMap.ContainsKey(sector.Abbreviation))
                    m.nameMap.Add(sector.Abbreviation, sector);
            }
        }