Ejemplo n.º 1
0
        protected virtual TMobile[] AcquireTargets <TMobile>(
            BaseAspect aspect, Point3D p, int range, bool cache = true, Func <TMobile, bool> filter = null) where TMobile : Mobile
        {
            if (aspect == null || aspect.Deleted || aspect.Map == null || aspect.Map == Map.Internal)
            {
                return(new TMobile[0]);
            }

            var targets =
                p.GetMobilesInRange(aspect.Map, range)
                .OfType <TMobile>()
                .Where(m => m != null && !m.Deleted && m != aspect && m.AccessLevel <= aspect.AccessLevel && m.Alive)
                .Where(m => aspect.CanBeHarmful(m, false, true) && SpellHelper.ValidIndirectTarget(aspect, m))
                .Where(m => m.Party == null || m.Party != aspect.Party)
                .Where(
                    m =>
                    m.Player || aspect.Combatant == m || aspect.FocusMob == m ||
                    (m is BaseCreature && (m as BaseCreature).GetMaster <PlayerMobile>() != null))
                .ToArray();

            if (cache && Duration > TimeSpan.Zero)
            {
                foreach (var t in targets)
                {
                    SetTargetState(aspect, t, Duration);
                }
            }

            return(targets);
        }