public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
		{
			var type = target.Type;
			if (type != TargetType.Actor && type != TargetType.FrozenActor)
				return false;

			cursor = this.cursor;
			IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);

			if (ForceAttack != null && modifiers.HasModifier(TargetModifiers.ForceAttack) != ForceAttack)
				return false;

			var owner = type == TargetType.FrozenActor ? target.FrozenActor.Owner : target.Actor.Owner;
			var playerRelationship = self.Owner.Stances[owner];

			if (!modifiers.HasModifier(TargetModifiers.ForceAttack) && playerRelationship == Stance.Ally && !targetAllyUnits)
				return false;

			if (!modifiers.HasModifier(TargetModifiers.ForceAttack) && playerRelationship == Stance.Enemy && !targetEnemyUnits)
				return false;

			return type == TargetType.FrozenActor ?
				CanTargetFrozenActor(self, target.FrozenActor, modifiers, ref cursor) :
				CanTargetActor(self, target.Actor, modifiers, ref cursor);
		}
Exemple #2
0
			public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
			{
				// Obey force moving onto bridges
				if (modifiers.HasModifier(TargetModifiers.ForceMove))
					return false;

				return target.TraitsImplementing<IDemolishable>().Any(i => i.IsValidTarget(target, self));
			}
Exemple #3
0
        public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
        {
            var c = target.TraitOrDefault<ExternalCapturable>();

            var canTargetActor = c != null && !c.CaptureInProgress && c.Info.CanBeTargetedBy(self, target.Owner);
            cursor = canTargetActor ? "ability" : "move-blocked";
            return canTargetActor;
        }
Exemple #4
0
        public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
        {
            var c = target.Info.Traits.GetOrDefault<CapturableInfo>();

            var canTargetActor = c != null && c.CanBeTargetedBy(self, target.Owner);
            cursor = canTargetActor ? "ability" : "move-blocked";
            return canTargetActor;
        }
Exemple #5
0
        public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
        {
            var c = target.Info.TraitInfoOrDefault<ExternalCapturableInfo>();

            var canTargetActor = c != null && c.CanBeTargetedBy(self, target.Owner);
            var capturesInfo = self.Trait<ExternalCaptures>().Info;
            cursor = canTargetActor ? capturesInfo.CaptureCursor : capturesInfo.CaptureBlockedCursor;
            return canTargetActor;
        }
		public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, TargetModifiers modifiers, ref string cursor)
		{
			if (target.Type != TargetType.Actor)
				return false;

			IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);
			cursor = useDeployCursor() ? "deploy" : "deploy-blocked";

			return self == target.Actor;
		}
        public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
        {
            if (target.Type != TargetType.Actor)
                return false;

            IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);
            cursor = this.cursor();

            return self == target.Actor;
        }
Exemple #8
0
			public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, TargetModifiers modifiers, ref string cursor)
			{
				if (target.Type != TargetType.Terrain)
					return false;

				var location = self.World.Map.CellContaining(target.CenterPosition);
				if (self.World.Map.Contains(location))
				{
					cursor = "ability";
					return true;
				}

				return false;
			}
		public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
		{
			if (target.Type != TargetType.Terrain)
				return false;

			var location = self.World.Map.CellContaining(target.CenterPosition);
			var explored = self.Owner.Shroud.IsExplored(location);
			cursor = self.World.Map.Contains(location) ?
				(self.World.Map.GetTerrainInfo(location).CustomCursor ?? "move") :
				"move-blocked";

			IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);

			if (!explored && !info.MoveIntoShroud)
				cursor = "move-blocked";

			return true;
		}
Exemple #10
0
			public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
			{
				var hut = target.TraitOrDefault<BridgeHut>();
				if (hut == null)
					return false;

				// Require force attack to heal partially damaged bridges to avoid unnecessary cursor noise
				var damage = hut.BridgeDamageState;
				if (!modifiers.HasModifier(TargetModifiers.ForceAttack) && damage != DamageState.Dead)
					return false;

				// Obey force moving onto bridges
				if (modifiers.HasModifier(TargetModifiers.ForceMove))
					return false;

				// Can't repair a bridge that is undamaged, already under repair, or dangling
				if (damage == DamageState.Undamaged || hut.Repairing || hut.Bridge.IsDangling)
					cursor = "goldwrench-blocked";

				return true;
			}
Exemple #11
0
            public bool CanTarget(Actor self, Target target, List <Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
            {
                if (target.Type != TargetType.Terrain)
                {
                    return(false);
                }

                var location = self.World.Map.CellContaining(target.CenterPosition);

                if (self.World.Map.Contains(location))
                {
                    cursor = this.cursor;

                    // Notify force-set 'RallyPoint' order watchers with Ctrl and only if this is the only building of its type selected
                    if (modifiers.HasModifier(TargetModifiers.ForceAttack))
                    {
                        var selfName = self.Info.Name;
                        if (!self.World.Selection.Actors.Any(a => a.Info.Name == selfName && a.ActorID != self.ActorID))
                        {
                            ForceSet = true;
                        }
                    }

                    return(true);
                }

                return(false);
            }
Exemple #12
0
 public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
 {
     return(targetTypes.Overlaps(target.GetEnabledTargetTypes()));
 }
Exemple #13
0
 public abstract bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor);
Exemple #14
0
 public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
 {
     return(target.TargetTypes.Overlaps(targetTypes));
 }
Exemple #15
0
 public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
 {
     return target.TargetTypes.Overlaps(targetTypes);
 }
Exemple #16
0
        public bool CanTarget(Actor self, Target target, List <Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
        {
            if (modifiers.HasModifier(TargetModifiers.ForceMove))
            {
                var xy = self.World.Map.CellContaining(target.CenterPosition);

                IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);

                if (self.IsInWorld && self.Owner.Shroud.IsExplored(xy))
                {
                    cursor = targetCursor;
                    return(true);
                }

                return(false);
            }

            return(false);
        }
Exemple #17
0
 public bool TargetOverridesSelection(TargetModifiers modifiers)
 {
     return(modifiers.HasModifier(TargetModifiers.ForceMove));
 }
Exemple #18
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);

                // Targeting the terrain is only possible with force-attack modifier
                if (modifiers.HasModifier(TargetModifiers.ForceMove) || !modifiers.HasModifier(TargetModifiers.ForceAttack))
                {
                    return(false);
                }

                var target    = Target.FromCell(self.World, location);
                var armaments = ab.ChooseArmamentsForTarget(target, true);

                if (!armaments.Any())
                {
                    return(false);
                }

                // Use valid armament with highest range out of those that have ammo
                // If all are out of ammo, just use valid armament with highest range
                armaments = armaments.OrderByDescending(x => x.MaxRange());
                var a = armaments.FirstOrDefault(x => !x.IsTraitPaused);

                if (a == null)
                {
                    a = armaments.First();
                }

                cursor = !target.IsInRange(self.CenterPosition, a.MaxRange())
                                        ? ab.Info.OutsideRangeCursor ?? a.Info.OutsideRangeCursor
                                        : ab.Info.Cursor ?? a.Info.Cursor;

                OrderID = ab.forceAttackOrderName;
                return(true);
            }
Exemple #19
0
            public bool CanTarget(Actor self, Target target, List <Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
            {
                switch (target.Type)
                {
                case TargetType.Actor:
                case TargetType.FrozenActor:
                    return(CanTargetActor(self, target, ref modifiers, ref cursor));

                case TargetType.Terrain:
                    return(CanTargetLocation(self, self.World.Map.CellContaining(target.CenterPosition), othersAtTarget, modifiers, ref cursor));

                default:
                    return(false);
                }
            }
Exemple #20
0
            public bool CanTarget(Actor self, Target target, List <Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
            {
                if (target.Type != TargetType.Terrain)
                {
                    return(false);
                }

                var location = self.World.Map.CellContaining(target.CenterPosition);

                if (!self.World.Map.Contains(location))
                {
                    return(false);
                }

                cursor   = "ability";
                IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);

                return(!othersAtTarget.Any() && modifiers.HasModifier(TargetModifiers.ForceAttack));
            }
Exemple #21
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);
            }
Exemple #22
0
            public bool CanTarget(Actor self, Target target, List <Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
            {
                if (rejectMove || target.Type != TargetType.Terrain)
                {
                    return(false);
                }

                var location = self.World.Map.CellContaining(target.CenterPosition);

                IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);

                var explored = self.Owner.Shroud.IsExplored(location);

                cursor = self.World.Map.Contains(location) ?
                         (self.World.Map.GetTerrainInfo(location).CustomCursor ?? mobile.Info.Cursor) : mobile.Info.BlockedCursor;

                if (mobile.IsTraitDisabled ||
                    (!explored && !mobile.Info.MoveIntoShroud) ||
                    (explored && mobile.Info.MovementCostForCell(self.World, location) == int.MaxValue))
                {
                    cursor = mobile.Info.BlockedCursor;
                }

                return(true);
            }
Exemple #23
0
        public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
        {
            // TODO: When target modifiers are configurable this needs to be revisited
            if (modifiers.HasModifier(TargetModifiers.ForceMove) || modifiers.HasModifier(TargetModifiers.ForceQueue))
            {
                var xy = self.World.Map.CellContaining(target.CenterPosition);

                IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);

                if (self.IsInWorld && self.Owner.Shroud.IsExplored(xy))
                {
                    cursor = targetCursor;
                    return true;
                }

                return false;
            }

            return false;
        }
            public bool TargetOverridesSelection(Actor self, Target target, List <Actor> actorsAt, CPos xy, TargetModifiers modifiers)
            {
                // Always prioritise orders over selecting other peoples actors or own actors that are already selected
                if (target.Type == TargetType.Actor && (target.Actor.Owner != self.Owner || self.World.Selection.Contains(target.Actor)))
                {
                    return(true);
                }

                return(modifiers.HasModifier(TargetModifiers.ForceMove));
            }
 public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
 {
     return target.Info.Traits.WithInterface<ITargetableInfo>().Any(t => t.GetTargetTypes().Contains(targetType));
 }
            public bool CanTarget(Actor self, Target target, List <Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
            {
                if (target.Type != TargetType.Terrain || (aircraft.Info.RequiresForceMove && !modifiers.HasModifier(TargetModifiers.ForceMove)))
                {
                    return(false);
                }

                var location = self.World.Map.CellContaining(target.CenterPosition);
                var explored = self.Owner.Shroud.IsExplored(location);

                cursor = self.World.Map.Contains(location) ?
                         self.World.Map.GetTerrainInfo(location).CustomCursor ?? "move" : "move-blocked";

                IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);

                if (!(self.CurrentActivity is Transform || aircraft.transforms.Any(t => !t.IsTraitDisabled && !t.IsTraitPaused)) ||
                    (!explored && !aircraft.Info.MoveIntoShroud))
                {
                    cursor = "move-blocked";
                }

                return(true);
            }
Exemple #27
0
 public abstract bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor);
 public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
 {
     // You can't enter frozen actor.
     return(false);
 }
Exemple #29
0
            public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
            {
                var targetInfo = target.Info.TraitInfoOrDefault <AcceptsDeliveredCashInfo>();

                if (targetInfo == null || !targetInfo.ValidRelationships.HasRelationship(target.Owner.RelationshipWith(self.Owner)))
                {
                    return(false);
                }

                if (targetInfo.ValidTypes.Count == 0)
                {
                    return(true);
                }

                var type = self.Info.TraitInfo <DeliversCashInfo>().Type;

                return(!string.IsNullOrEmpty(type) && targetInfo.ValidTypes.Contains(type));
            }
 public bool TargetOverridesSelection(TargetModifiers modifiers)
 {
     return modifiers.HasModifier(TargetModifiers.ForceMove);
 }
Exemple #31
0
            public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
            {
                var captureManagerInfo = target.Info.TraitInfoOrDefault <CaptureManagerInfo>();

                if (captureManagerInfo == null || !captureManagerInfo.CanBeTargetedBy(target, self, captures))
                {
                    cursor = captures.Info.EnterBlockedCursor;
                    return(false);
                }

                cursor = captures.Info.EnterCursor;
                if (captures.Info.SabotageThreshold > 0 && !target.Owner.NonCombatant)
                {
                    var healthInfo = target.Info.TraitInfoOrDefault <IHealthInfo>();

                    // Sabotage instead of capture
                    if ((long)target.HP * 100 > captures.Info.SabotageThreshold * (long)healthInfo.MaxHP)
                    {
                        cursor = captures.Info.SabotageCursor;
                    }
                }

                return(true);
            }
Exemple #32
0
            public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
            {
                if (!target.Info.Traits.Contains <EngineerRepairable>())
                {
                    return(false);
                }

                if (self.Owner.Stances[target.Owner] != Stance.Ally)
                {
                    return(false);
                }

                if (target.DamageState == DamageState.Undamaged)
                {
                    cursor = "goldwrench-blocked";
                }

                return(true);
            }
Exemple #33
0
 public bool TargetOverridesSelection(Actor self, Target target, List <Actor> actorsAt, CPos xy, TargetModifiers modifiers)
 {
     return(true);
 }
Exemple #34
0
        public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
        {
            var stance = self.Owner.Stances[target.Owner];

            if (!info.ValidStances.HasStance(stance))
                return false;

            return target.Info.Traits.WithInterface<ITargetableInfo>().Any(t => t.GetTargetTypes().Intersect(info.Types).Any());
        }
Exemple #35
0
        public bool CanTarget(Actor self, Target target, List <Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
        {
            var type = target.Type;

            if (type != TargetType.Actor && type != TargetType.FrozenActor)
            {
                return(false);
            }

            cursor   = this.cursor;
            IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);

            if (ForceAttack != null && modifiers.HasModifier(TargetModifiers.ForceAttack) != ForceAttack)
            {
                return(false);
            }

            var owner = type == TargetType.FrozenActor ? target.FrozenActor.Owner : target.Actor.Owner;
            var playerRelationship = self.Owner.Stances[owner];

            if (!modifiers.HasModifier(TargetModifiers.ForceAttack) && playerRelationship == Stance.Ally && !targetAllyUnits)
            {
                return(false);
            }

            if (!modifiers.HasModifier(TargetModifiers.ForceAttack) && playerRelationship == Stance.Enemy && !targetEnemyUnits)
            {
                return(false);
            }

            return(type == TargetType.FrozenActor ?
                   CanTargetFrozenActor(self, target.FrozenActor, modifiers, ref cursor) :
                   CanTargetActor(self, target.Actor, modifiers, ref cursor));
        }
Exemple #36
0
		public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
		{
			return target.TraitsImplementing<ITargetable>().Any(t => t.IsTraitEnabled() && t.TargetTypes.Overlaps(targetTypes));
		}
Exemple #37
0
 public bool TargetOverridesSelection(TargetModifiers modifiers)
 {
     return(true);
 }
Exemple #38
0
 public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
 {
     // TODO: Bridges don't yet support FrozenUnderFog.
     return(false);
 }
Exemple #39
0
            public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
            {
                var trait = self.Info.TraitInfo <AcolytePreyInfo>();

                if (!trait.TargetActors.Contains(target.Info.Name))
                {
                    return(false);
                }
                if (target.Info.HasTraitInfo <ValidPreyTargetInfo>() && !target.Actor.TraitOrDefault <ValidPreyTarget>().Actors.Any())
                {
                    return(false);
                }

                return(true);
            }
Exemple #40
0
 public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
 {
     return target.Info.Traits.WithInterface<IDemolishableInfo>().Any(i => i.IsValidTarget(target.Info, self));
 }
 public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
 {
     return target.TraitsImplementing<ITargetable>().Any(t => t.TargetTypes.Contains(targetType));
 }
Exemple #42
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;
			}
Exemple #43
0
            public bool CanTarget(Actor self, Target target, List <Actor> othersAtTarget, TargetModifiers modifiers, ref string cursor)
            {
                if (rejectMove || !target.IsValidFor(self))
                {
                    return(false);
                }

                var location = self.World.Map.CellContaining(target.CenterPosition);

                IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);
                cursor   = "move";

                if (self.Owner.Shroud.IsExplored(location))
                {
                    cursor = self.World.Map.GetTerrainInfo(location).CustomCursor ?? cursor;
                }

                if (!self.World.Map.Contains(location) || (self.Owner.Shroud.IsExplored(location) &&
                                                           unitType.MovementCostForCell(self.World, location) == int.MaxValue))
                {
                    cursor = "move-blocked";
                }

                return(true);
            }
Exemple #44
0
            public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
            {
                // TODO: FrozenActors don't yet have a way of caching conditions, so we can't filter disabled traits
                // This therefore assumes that all EngineerRepairable traits are enabled, which is probably wrong.
                // Actors with FrozenUnderFog should therefore not disable the EngineerRepairable trait if
                // ValidStances includes Enemy actors.
                var engineerRepairable = target.Info.TraitInfoOrDefault <EngineerRepairableInfo>();

                if (engineerRepairable == null)
                {
                    return(false);
                }

                if (!engineerRepairable.Types.IsEmpty && !engineerRepairable.Types.Overlaps(info.Types))
                {
                    return(false);
                }

                if (!info.ValidRelationships.HasRelationship(target.Owner.RelationshipWith(self.Owner)))
                {
                    return(false);
                }

                if (target.DamageState == DamageState.Undamaged)
                {
                    cursor = info.RepairBlockedCursor;
                }

                return(true);
            }
Exemple #45
0
			bool CanTargetActor(Actor self, Target target, TargetModifiers modifiers, ref string cursor)
			{
				IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);

				var a = ab.ChooseArmamentForTarget(target);
				cursor = a != null && !target.IsInRange(self.CenterPosition, a.Weapon.Range)
					? ab.info.OutsideRangeCursor
					: ab.info.Cursor;

				if (target.Type == TargetType.Actor && target.Actor == self)
					return false;

				if (!ab.HasAnyValidWeapons(target))
					return false;

				if (modifiers.HasModifier(TargetModifiers.ForceAttack))
					return true;

				if (modifiers.HasModifier(TargetModifiers.ForceMove))
					return false;

				if (target.RequiresForceFire)
					return false;

				var targetableRelationship = negativeDamage ? Stance.Ally : Stance.Enemy;

				var owner = target.Type == TargetType.FrozenActor ? target.FrozenActor.Owner : target.Actor.Owner;
				return self.Owner.Stances[owner] == targetableRelationship;
			}
Exemple #46
0
 public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
 {
     return target.Info.Traits.Contains<AcceptsSuppliesInfo>();
 }
Exemple #47
0
			public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, TargetModifiers modifiers, ref string cursor)
			{
				switch (target.Type)
				{
				case TargetType.Actor:
				case TargetType.FrozenActor:
					return CanTargetActor(self, target, modifiers, ref cursor);
				case TargetType.Terrain:
					return CanTargetLocation(self, self.World.Map.CellContaining(target.CenterPosition), othersAtTarget, modifiers, ref cursor);
				default:
					return false;
				}
			}
Exemple #48
0
			public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
			{
				var c = target.Info.Traits.GetOrDefault<CapturableInfo>();
				if (c == null || !c.CanBeTargetedBy(self, target.Owner))
				{
					cursor = "enter-blocked";
					return false;
				}

				var health = target.Trait<Health>();
				var lowEnoughHealth = health.HP <= c.CaptureThreshold * health.MaxHP;

				cursor = !sabotage || lowEnoughHealth || target.Owner.NonCombatant
					? "enter" : "capture";
				return true;
			}
Exemple #49
0
 public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
 {
     return targetTypes.Overlaps(target.GetEnabledTargetTypes());
 }
Exemple #50
0
 public bool TargetOverridesSelection(TargetModifiers modifiers)
 {
     return true;
 }
Exemple #51
0
 public static bool HasModifier(this TargetModifiers self, TargetModifiers m)
 {
     // PERF: Enum.HasFlag is slower and requires allocations.
     return((self & m) == m);
 }
Exemple #52
0
 public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
 {
     return(target.Info.TraitInfos <IDemolishableInfo>().Any(i => i.IsValidTarget(target.Info, self)));
 }
Exemple #53
0
 public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
 {
     return target.HasTrait<AcceptsSupplies>();
 }
Exemple #54
0
        public bool CanTarget(Actor self, Target target, List <Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
        {
            if (target.Type != TargetType.Actor)
            {
                return(false);
            }

            IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);
            cursor   = this.cursor();

            return(self == target.Actor);
        }
Exemple #55
0
            public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, TargetModifiers modifiers, ref string cursor)
            {
                if (target.Type != TargetType.Terrain)
                    return false;

                if (modifiers.HasModifier(TargetModifiers.ForceMove))
                    return false;

                var location = self.World.Map.CellContaining(target.CenterPosition);
                // Don't leak info about resources under the shroud
                if (!self.Owner.Shroud.IsExplored(location))
                    return false;

                var res = self.World.WorldActor.Trait<ResourceLayer>().GetRenderedResource(location);
                var info = self.Info.Traits.Get<HarvesterInfo>();

                if (res == null || !info.Resources.Contains(res.Info.Name))
                    return false;

                cursor = "harvest";
                IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);

                return true;
            }
Exemple #56
0
        public bool CanTarget(Actor self, Target target, List <Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
        {
            if (target.Type != TargetType.Terrain)
            {
                return(false);
            }

            if (modifiers.HasModifier(TargetModifiers.ForceMove))
            {
                return(false);
            }

            var location = self.World.Map.CellContaining(target.CenterPosition);

            // Don't leak info about resources under the shroud
            if (!self.Owner.Shroud.IsExplored(location))
            {
                return(false);
            }

            var res  = self.World.WorldActor.Trait <ResourceLayer>().GetRenderedResource(location);
            var info = self.Info.TraitInfo <T>();

            if (res == null || !info.Resources.Contains(res.Info.Type))
            {
                return(false);
            }

            cursor   = "harvest";
            IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);

            return(true);
        }
Exemple #57
0
            public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
            {
                if (target.Type != TargetType.Terrain)
                    return false;

                var location = self.World.Map.CellContaining(target.CenterPosition);
                if (!self.World.Map.Contains(location))
                    return false;

                cursor = "ability";
                IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);

                return !othersAtTarget.Any() && modifiers.HasModifier(TargetModifiers.ForceAttack);
            }
Exemple #58
0
 public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
 {
     return(false);
 }
Exemple #59
0
 public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
 {
     // TODO: Bridges don't yet support FrozenUnderFog.
     return false;
 }
Exemple #60
0
 public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
 {
     return(self.Info.TraitInfo <AcolytePreyInfo>().TargetActors.Contains(target.Info.Name));
 }