コード例 #1
0
ファイル: Warhead.cs プロジェクト: wytsep/OpenRA
        ///<summary>Checks if the warhead is valid against (can do something to) the actor.</summary>
        public bool IsValidAgainst(Actor victim, Actor firedBy)
        {
            if (!CanTargetActor(victim.Info, firedBy))
            {
                return(false);
            }

            if (!AffectsParent && victim == firedBy)
            {
                return(false);
            }

            var stance = firedBy.Owner.Stances[victim.Owner];

            if (!ValidStances.HasFlag(stance))
            {
                return(false);
            }

            // A target type is valid if it is in the valid targets list, and not in the invalid targets list.
            var targetable = victim.TraitOrDefault <ITargetable>();

            if (targetable == null || !ValidTargets.Intersect(targetable.TargetTypes).Any() ||
                InvalidTargets.Intersect(targetable.TargetTypes).Any())
            {
                return(false);
            }

            return(true);
        }
コード例 #2
0
        public string TooltipForPlayerStance(Stance stance)
        {
            if (stance == Stance.None || !GenericVisibility.HasFlag(stance))
            {
                return(Name);
            }

            if (GenericStancePrefix && stance == Stance.Ally)
            {
                return("Allied " + GenericName);
            }

            if (GenericStancePrefix && stance == Stance.Enemy)
            {
                return("Enemy " + GenericName);
            }

            return(GenericName);
        }