示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="system"></param>
        /// <param name="maxInclusiveNumberOfJumps">The maximum, inclusive, number of jumps.</param>
        /// <returns></returns>
        internal static List <SolarSystemRange> GetSystemRangesFrom(SolarSystem system, int maxInclusiveNumberOfJumps)
        {
            var collectedSystems = new Dictionary <long, SolarSystem>();
            var ranges           = new List <SolarSystemRange>();
            var lastRange        = new SolarSystemRange(system, 0);

            collectedSystems.Add(system.ID, system);
            lastRange.m_items.Add(system);

            for (int i = 1; i <= maxInclusiveNumberOfJumps; i++)
            {
                lastRange = lastRange.GetNextRange(collectedSystems);
                ranges.Add(lastRange);
            }

            return(ranges);
        }
示例#2
0
        /// <summary>
        /// gets the next
        /// </summary>
        /// <returns></returns>
        private SolarSystemRange GetNextRange(Dictionary <long, SolarSystem> collectedSystems)
        {
            SolarSystemRange nextRange = new SolarSystemRange(m_source, m_range + 1);

            foreach (var system in m_items)
            {
                foreach (var child in system.Neighbors)
                {
                    if (!collectedSystems.ContainsKey(child.ID))
                    {
                        collectedSystems.Add(child.ID, child);
                        nextRange.m_items.Add(child);
                    }
                }
            }

            return(nextRange);
        }
示例#3
0
 /// <summary>
 /// Gets the solar systems within the given range.
 /// </summary>
 /// <param name="maxInclusiveNumberOfJumps">The maximum, inclusive, number of jumps from this system.</param>
 /// <returns></returns>
 public List <SolarSystemRange> GetSystemsWithinRange(int maxInclusiveNumberOfJumps)
 {
     return(SolarSystemRange.GetSystemRangesFrom(this, maxInclusiveNumberOfJumps));
 }