Exemplo n.º 1
0
            bool CanTargetLocation(Actor self, CPos location, List <Actor> actorsAtLocation, TargetModifiers modifiers, ref string cursor)
            {
                if (!self.World.Map.Contains(location))
                {
                    return(false);
                }

                IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);

                cursor = ab.Info.Cursor;

                if (negativeDamage)
                {
                    return(false);
                }

                if (!ab.HasAnyValidWeapons(Target.FromCell(self.World, location)))
                {
                    return(false);
                }

                if (modifiers.HasModifier(TargetModifiers.ForceAttack))
                {
                    var maxRange    = ab.GetMaximumRange().Range;
                    var targetRange = (self.World.Map.CenterOfCell(location) - self.CenterPosition).HorizontalLengthSquared;
                    if (targetRange > maxRange * maxRange)
                    {
                        cursor = ab.Info.OutsideRangeCursor;
                    }

                    return(true);
                }

                return(false);
            }
Exemplo n.º 2
0
        public Actor ScanForTarget(Actor self, Actor currentTarget)
        {
            if (nextScanTime <= 0)
            {
                var range = info.ScanRadius > 0 ? WDist.FromCells(info.ScanRadius) : attack.GetMaximumRange();
                if (self.IsIdle || currentTarget == null || !Target.FromActor(currentTarget).IsInRange(self.CenterPosition, range))
                {
                    return(ChooseTarget(self, range));
                }
            }

            return(currentTarget);
        }
Exemplo n.º 3
0
        public Actor ScanForTarget(Actor self, Actor currentTarget, bool allowMove)
        {
            if (nextScanTime <= 0)
            {
                var range = info.ScanRadius > 0 ? WDist.FromCells(info.ScanRadius) : attack.GetMaximumRange();
                if (self.IsIdle || currentTarget == null || !Target.FromActor(currentTarget).IsInRange(self.CenterPosition, range))
                {
                    nextScanTime = self.World.SharedRandom.Next(info.MinimumScanTimeInterval, info.MaximumScanTimeInterval);
                    return(ChooseTarget(self, range, allowMove));
                }
            }

            return(currentTarget);
        }
Exemplo n.º 4
0
        public IEnumerable <IRenderable> RenderAfterWorld(WorldRenderer wr)
        {
            if (self.Owner != self.World.LocalPlayer)
            {
                yield break;
            }

            var range = attack.GetMaximumRange();

            if (range == WRange.Zero)
            {
                yield break;
            }

            yield return(new RangeCircleRenderable(
                             self.CenterPosition,
                             range,
                             0,
                             Color.FromArgb(128, Color.Yellow),
                             Color.FromArgb(96, Color.Black)));
        }
Exemplo n.º 5
0
        public Actor ScanForTarget(Actor self, bool allowMove)
        {
            if (nextScanTime <= 0)
            {
                nextScanTime = self.World.SharedRandom.Next(info.MinimumScanTimeInterval, info.MaximumScanTimeInterval);

                // If we can't attack right now, there's no need to try and find a target.
                var attackStances = attack.UnforcedAttackTargetStances();
                if (attackStances != OpenRA.Traits.Stance.None)
                {
                    var range = info.ScanRadius > 0 ? WDist.FromCells(info.ScanRadius) : attack.GetMaximumRange();
                    return(ChooseTarget(self, attackStances, range, allowMove));
                }
            }

            return(null);
        }