Inheritance: OpenRA.Traits.AttackBase, ITick, INotifyOwnerChanged
示例#1
0
            public AttackActivity(Actor self, Target target, bool allowMove, bool forceAttack, Color?targetLineColor = null)
            {
                attack        = self.Trait <AttackFollow>();
                move          = allowMove ? self.TraitOrDefault <IMove>() : null;
                revealsShroud = self.TraitsImplementing <RevealsShroud>().ToArray();

                this.target          = target;
                this.forceAttack     = forceAttack;
                this.targetLineColor = targetLineColor;

                // The target may become hidden between the initial order request and the first tick (e.g. if queued)
                // Moving to any position (even if quite stale) is still better than immediately giving up
                if ((target.Type == TargetType.Actor && target.Actor.CanBeViewedByPlayer(self.Owner)) ||
                    target.Type == TargetType.FrozenActor || target.Type == TargetType.Terrain)
                {
                    lastVisibleTarget       = Target.FromPos(target.CenterPosition);
                    lastVisibleMaximumRange = attack.GetMaximumRangeVersusTarget(target);
                    lastVisibleMinimumRange = attack.GetMinimumRangeVersusTarget(target);

                    if (target.Type == TargetType.Actor)
                    {
                        lastVisibleOwner       = target.Actor.Owner;
                        lastVisibleTargetTypes = target.Actor.GetEnabledTargetTypes();
                    }
                    else if (target.Type == TargetType.FrozenActor)
                    {
                        lastVisibleOwner       = target.FrozenActor.Owner;
                        lastVisibleTargetTypes = target.FrozenActor.TargetTypes;
                    }
                }
            }
示例#2
0
 public AutoTarget(Actor self, AutoTargetInfo info)
 {
     this.info       = info;
     attack          = self.Trait <AttackBase>();
     Stance          = info.InitialStance;
     PredictedStance = Stance;
     at = self.TraitOrDefault <AttackFollow>();
 }
            public AttackActivity(Actor self, Target target, bool allowMove, bool forceAttack)
            {
                attack = self.Trait <AttackFollow>();
                move   = allowMove ? self.TraitOrDefault <IMove>() : null;

                this.target      = target;
                this.forceAttack = forceAttack;
            }
示例#4
0
            public AttackActivity(Actor self, Target target, bool allowMove)
            {
                attack = self.Trait<AttackFollow>();
                move = allowMove ? self.TraitOrDefault<IMove>() : null;

                // HACK: Mobile.OnRails is horrible
                var mobile = move as Mobile;
                if (mobile != null && mobile.Info.OnRails)
                    move = null;

                this.target = target;
            }
示例#5
0
            public AttackActivity(Actor self, Target target, bool allowMove)
            {
                attack = self.Trait <AttackFollow>();
                move   = allowMove ? self.TraitOrDefault <IMove>() : null;

                // HACK: Mobile.OnRails is horrible
                var mobile = move as Mobile;

                if (mobile != null && mobile.Info.OnRails)
                {
                    move = null;
                }

                this.target = target;
            }
示例#6
0
            public AttackActivity(Actor self, Target target, bool allowMove, bool forceAttack)
            {
                attack = self.Trait <AttackFollow>();
                move   = allowMove ? self.TraitOrDefault <IMove>() : null;

                // HACK: Mobile.OnRails is horrible. Blergh.
                var mobile = move as Mobile;

                if (mobile != null && mobile.Info.OnRails)
                {
                    move        = null;
                    onRailsHack = true;
                }

                this.target      = target;
                this.forceAttack = forceAttack;
            }
示例#7
0
        public AutoTarget(ActorInitializer init, AutoTargetInfo info)
        {
            var self = init.Self;

            this.info = info;
            attack    = self.Trait <AttackBase>();

            if (init.Contains <StanceInit>())
            {
                Stance = init.Get <StanceInit, UnitStance>();
            }
            else
            {
                Stance = self.Owner.IsBot || !self.Owner.Playable ? info.InitialStanceAI : info.InitialStance;
            }

            PredictedStance = Stance;
            at = self.TraitOrDefault <AttackFollow>();
        }
示例#8
0
            public AttackActivity(Actor self, Target target, bool allowMove, bool forceAttack)
            {
                attack = self.Trait<AttackFollow>();
                move = allowMove ? self.TraitOrDefault<IMove>() : null;

                // HACK: Mobile.OnRails is horrible. Blergh.
                var mobile = move as Mobile;
                if (mobile != null && mobile.Info.OnRails)
                {
                    move = null;
                    onRailsHack = true;
                }

                this.target = target;
                this.forceAttack = forceAttack;
            }