示例#1
0
        public bool IsValidFor(Actor targeter)
        {
            if (targeter == null || Type == TargetType.Invalid)
            {
                return(false);
            }

            if (targetable != null && !targetable.TargetableBy(actor, targeter))
            {
                return(false);
            }

            return(true);
        }
示例#2
0
        protected virtual Activity InnerTick(Actor self, AttackBase attack)
        {
            if (IsCanceled)
            {
                return(NextActivity);
            }

            if (!Target.IsValid)
            {
                return(NextActivity);
            }

            if (!self.Owner.HasFogVisibility() && Target.Actor != null && Target.Actor.HasTrait <Mobile>() && !self.Owner.Shroud.IsTargetable(Target.Actor))
            {
                return(NextActivity);
            }

            if (targetable != null && !targetable.TargetableBy(Target.Actor, self))
            {
                return(NextActivity);
            }

            if (!Combat.IsInRange(self.CenterLocation, Range, Target))
            {
                if (--nextPathTime > 0)
                {
                    return(this);
                }

                nextPathTime = self.World.SharedRandom.Next(delayBetweenPathingAttempts - delaySpread,
                                                            delayBetweenPathingAttempts + delaySpread);

                return((AllowMovement) ? Util.SequenceActivities(self.Trait <Mobile>().MoveWithinRange(Target, Range), this) : NextActivity);
            }

            var desiredFacing = Util.GetFacing(Target.CenterLocation - self.CenterLocation, 0);
            var facing        = self.Trait <IFacing>();

            if (facing.Facing != desiredFacing)
            {
                return(Util.SequenceActivities(new Turn(desiredFacing), this));
            }

            attack.DoAttack(self, Target);
            return(this);
        }