/// <summary>
        /// Abilities inherited from ancestor objects.
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="includeShared"></param>
        /// <returns></returns>
        public static IEnumerable <Ability> AncestorAbilities(this IAbilityObject obj, Func <IAbilityObject, bool> sourceFilter = null)
        {
            var abils = new List <Ability>();

            foreach (var p in obj.Ancestors(sourceFilter).ExceptSingle(null))
            {
                abils.AddRange(p.IntrinsicAbilities);
            }
            return(abils.Where(a => a.Rule == null || a.Rule.CanTarget(obj.AbilityTarget)));
        }
        /// <summary>
        /// Finds empire-common abilities inherited by an object (e.g. empire abilities of a sector in which a ship resides).
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="sourceFilter"></param>
        /// <returns></returns>
        public static IEnumerable <Ability> EmpireCommonAbilities(this IAbilityObject obj, Func <IAbilityObject, bool> sourceFilter = null)
        {
            // Unowned objects cannot empire common abilities.
            var ownable = obj as IOwnableAbilityObject;

            if (ownable == null || ownable.Owner == null)
            {
                yield break;
            }

            // Where are these abilities coming from?
            // Right now they can only come from ancestors, since sectors and star systems are the only common ability objects.
            // TODO - Would it make sense for them to come from descendants? What kind of common ability object could be used as a descendant of an owned object?
            var ancestors = obj.Ancestors(sourceFilter).OfType <ICommonAbilityObject>();

            // What abilities do we have?
            foreach (var ancestor in ancestors)
            {
                foreach (var abil in ancestor.EmpireAbilities(ownable.Owner, sourceFilter))
                {
                    yield return(abil);
                }
            }
        }