Example #1
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);
		}
Example #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));
			}
Example #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;
        }
Example #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;
        }
Example #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;
        }
Example #6
0
		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;
		}
Example #7
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;
        }
Example #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;
		}
Example #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;
			}
Example #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);
            }
Example #12
0
 public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
 {
     return(targetTypes.Overlaps(target.GetEnabledTargetTypes()));
 }
Example #13
0
 public abstract bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor);
Example #14
0
 public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
 {
     return(target.TargetTypes.Overlaps(targetTypes));
 }
Example #15
0
 public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
 {
     return target.TargetTypes.Overlaps(targetTypes);
 }
Example #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);
        }
Example #17
0
 public bool TargetOverridesSelection(TargetModifiers modifiers)
 {
     return(modifiers.HasModifier(TargetModifiers.ForceMove));
 }
Example #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);
            }
Example #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);
                }
            }
Example #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));
            }
Example #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);
            }
Example #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);
            }
Example #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;
        }
Example #24
0
            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));
 }
Example #26
0
            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);
            }
Example #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);
 }
Example #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);
 }
Example #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);
            }
Example #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);
            }
Example #33
0
 public bool TargetOverridesSelection(Actor self, Target target, List <Actor> actorsAt, CPos xy, TargetModifiers modifiers)
 {
     return(true);
 }
Example #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());
        }
Example #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));
        }
Example #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));
		}
Example #37
0
 public bool TargetOverridesSelection(TargetModifiers modifiers)
 {
     return(true);
 }
Example #38
0
 public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
 {
     // TODO: Bridges don't yet support FrozenUnderFog.
     return(false);
 }
Example #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);
            }
Example #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));
 }
Example #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;
			}
Example #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);
            }
Example #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);
            }
Example #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;
			}
Example #46
0
 public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
 {
     return target.Info.Traits.Contains<AcceptsSuppliesInfo>();
 }
Example #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;
				}
			}
Example #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;
			}
Example #49
0
 public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
 {
     return targetTypes.Overlaps(target.GetEnabledTargetTypes());
 }
Example #50
0
 public bool TargetOverridesSelection(TargetModifiers modifiers)
 {
     return true;
 }
Example #51
0
 public static bool HasModifier(this TargetModifiers self, TargetModifiers m)
 {
     // PERF: Enum.HasFlag is slower and requires allocations.
     return((self & m) == m);
 }
Example #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)));
 }
Example #53
0
 public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
 {
     return target.HasTrait<AcceptsSupplies>();
 }
Example #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);
        }
Example #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;
            }
Example #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);
        }
Example #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);
            }
Example #58
0
 public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
 {
     return(false);
 }
Example #59
0
 public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
 {
     // TODO: Bridges don't yet support FrozenUnderFog.
     return false;
 }
Example #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));
 }