Inheritance: OpenRA.Traits.AttackBase, ITick, INotifyOwnerChanged
Esempio n. 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;
                    }
                }
            }
Esempio n. 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;
            }
Esempio n. 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;
            }
Esempio n. 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;
            }
Esempio n. 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;
            }
Esempio n. 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>();
        }
Esempio n. 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;
            }