Exemplo n.º 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);
		}
Exemplo n.º 2
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);
            }
Exemplo n.º 3
0
            public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
            {
                var bridge = target.TraitOrDefault <BridgeHut>();

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

                // Require force attack to heal partially damaged bridges to avoid unnecessary cursor noise
                var damage = bridge.BridgeDamageState;

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

                // Can't repair an undamaged bridge
                if (damage == DamageState.Undamaged)
                {
                    cursor = "goldwrench-blocked";
                }

                return(true);
            }
Exemplo n.º 4
0
            public bool CanTarget(Actor self, Target target, List <Actor> othersAtTarget, TargetModifiers modifiers, ref string cursor)
            {
                if (!target.IsValidFor(self))
                {
                    return(false);
                }

                var location = target.CenterPosition.ToCPos();

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

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

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

                return(true);
            }
Exemplo n.º 5
0
            public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
            {
                var stance = self.Owner.Stances[target.Owner];

                if (!info.TargetStances.HasStance(stance) && !modifiers.HasModifier(TargetModifiers.ForceAttack))
                {
                    return(false);
                }

                if (!info.ForceTargetStances.HasStance(stance) && modifiers.HasModifier(TargetModifiers.ForceAttack))
                {
                    return(false);
                }

                return(target.Info.TraitInfos <IDemolishableInfo>().Any(i => i.IsValidTarget(target.Info, self)));
            }
Exemplo n.º 6
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);
            }
Exemplo n.º 7
0
            public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
            {
                var relationship = target.Owner.RelationshipWith(self.Owner);

                if (!info.TargetRelationships.HasRelationship(relationship) && !modifiers.HasModifier(TargetModifiers.ForceAttack))
                {
                    return(false);
                }

                if (!info.ForceTargetRelationships.HasRelationship(relationship) && modifiers.HasModifier(TargetModifiers.ForceAttack))
                {
                    return(false);
                }

                return(target.Info.TraitInfos <IDemolishableInfo>().Any(i => i.IsValidTarget(target.Info, self)));
            }
Exemplo n.º 8
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);

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

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

                if ((!explored && !unitType.MoveIntoShroud) ||
                    (explored && unitType.MovementCostForCell(self.World, location) == int.MaxValue))
                {
                    cursor = "move-blocked";
                }

                return(true);
            }
Exemplo n.º 9
0
            public bool CanTarget(Actor self, Target target, List <Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
            {
                if (rejectMove || target.Type != TargetType.Terrain || (mobile.Info.RequiresForceMove && !modifiers.HasModifier(TargetModifiers.ForceMove)))
                {
                    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 (!(self.CurrentActivity is Transform || mobile.transforms.Any(t => !t.IsTraitDisabled && !t.IsTraitPaused)) ||
                    (!explored && !mobile.locomotor.Info.MoveIntoShroud) ||
                    (explored && !CanEnterCell(self, location)))
                {
                    cursor = mobile.Info.BlockedCursor;
                }

                return(true);
            }
Exemplo n.º 10
0
            public override bool CanTarget(Actor self, Target target, List <Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
            {
                if (modifiers.HasModifier(TargetModifiers.ForceMove))
                {
                    return(false);
                }

                var type = target.Type;

                if (type == TargetType.Actor && self == target.Actor)
                {
                    var altitude = self.World.Map.DistanceAboveTerrain(self.CenterPosition);
                    if (altitude.Length - carryableOffset.Z < aircraftInfo.MinAirborneAltitude)
                    {
                        cursor  = "deploy";
                        OrderID = "Unload";
                        return(true);
                    }
                }
                else if ((type == TargetType.Actor && target.Actor.Info.HasTraitInfo <BuildingInfo>()) ||
                         (target.Type == TargetType.FrozenActor && target.FrozenActor.Info.HasTraitInfo <BuildingInfo>()))
                {
                    cursor = "move-blocked";
                    return(true);
                }

                return(base.CanTarget(self, target, othersAtTarget, ref modifiers, ref cursor));
            }
Exemplo n.º 11
0
        bool IsCorrectGarrisonType(Actor target, TargetModifiers modifiers)
        {
            if (requireForceMove && !modifiers.HasModifier(TargetModifiers.ForceMove))
            {
                return(false);
            }

            return(IsCorrectGarrisonType(target));
        }
Exemplo n.º 12
0
        bool CanRepairAt(Actor target, TargetModifiers modifiers)
        {
            if (Info.RequiresForceMove && !modifiers.HasModifier(TargetModifiers.ForceMove))
            {
                return(false);
            }

            return(CanRepairAt(target));
        }
Exemplo n.º 13
0
        bool CanRepairAt(Actor target, TargetModifiers modifiers)
        {
            if (requireForceMove && !modifiers.HasModifier(TargetModifiers.ForceMove))
            {
                return(false);
            }

            return(Info.RepairActors.Contains(target.Info.Name));
        }
Exemplo n.º 14
0
        public bool AircraftCanEnter(Actor a, TargetModifiers modifiers)
        {
            if (Info.RequiresForceMove && !modifiers.HasModifier(TargetModifiers.ForceMove))
            {
                return(false);
            }

            return(AircraftCanEnter(a));
        }
Exemplo n.º 15
0
        bool IsCorrectCargoType(Actor target, TargetModifiers modifiers)
        {
            if (Info.RequiresForceMove && !modifiers.HasModifier(TargetModifiers.ForceMove))
            {
                return(false);
            }

            return(IsCorrectCargoType(target));
        }
Exemplo n.º 16
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;
		}
Exemplo n.º 17
0
            bool CanTargetActor(Actor self, Target target, ref TargetModifiers modifiers, ref string cursor)
            {
                IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);

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

                if (target.Type == TargetT.Actor && target.Actor.EffectiveOwner != null &&
                    target.Actor.EffectiveOwner.Disguised && self.Owner.Stances[target.Actor.Owner] == Stance.Enemy)
                {
                    modifiers |= TargetModifiers.ForceAttack;
                }

                var forceAttack = modifiers.HasModifier(TargetModifiers.ForceAttack);
                var armaments   = ab.ChooseArmamentsForTarget(target, forceAttack);

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

                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;

                if (!forceAttack)
                {
                    return(true);
                }

                OrderID = ab.forceAttackOrderName;
                return(true);
            }
Exemplo n.º 18
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)));
            }
Exemplo n.º 19
0
        public bool CanTarget(Actor self, Target target, List <Actor> othersAtTarget, 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 = "chrono-target";
                    return(true);
                }
                return(false);
            }

            return(false);
        }
        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);
        }
Exemplo n.º 21
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;
        }
Exemplo n.º 22
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));
            }
Exemplo n.º 23
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));
            }
Exemplo n.º 24
0
        public bool CanTarget(Actor self, Target target, List <Actor> othersAtTarget, TargetModifiers modifiers, ref string cursor)
        {
            if (target.Type != TargetType.Terrain)
            {
                return(false);
            }

            IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);
            cursor   = self.World.Map.IsInMap(target.CenterPosition.ToCPos()) ? "move" : "move-blocked";
            return(true);
        }
Exemplo n.º 25
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);
            }
Exemplo n.º 26
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);
                }

                var minelayer = self.Trait <Minelayer>();

                cursor   = minelayer.Info.Cursor;
                IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);

                return(modifiers.HasModifier(TargetModifiers.ForceAttack));
            }
Exemplo n.º 27
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);
                }

                var stance = self.Owner.Stances[target.Owner];

                if (!info.TargetStances.HasStance(stance) && !modifiers.HasModifier(TargetModifiers.ForceAttack))
                {
                    return(false);
                }
                if (!info.ForceTargetStances.HasStance(stance) && modifiers.HasModifier(TargetModifiers.ForceAttack))
                {
                    return(false);
                }

                return(info.Types.Overlaps(target.GetAllTargetTypes()));
            }
Exemplo n.º 28
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);
        }
Exemplo n.º 29
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);
                }

                var relationship = self.Owner.RelationshipWith(target.Owner);

                if (!info.TargetRelationships.HasRelationship(relationship) && !modifiers.HasModifier(TargetModifiers.ForceAttack))
                {
                    return(false);
                }
                if (!info.ForceTargetRelationships.HasRelationship(relationship) && modifiers.HasModifier(TargetModifiers.ForceAttack))
                {
                    return(false);
                }

                return(info.Types.Overlaps(target.GetAllTargetTypes()));
            }
Exemplo n.º 30
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);
        }
Exemplo n.º 31
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);
            }
Exemplo n.º 32
0
            bool CanTargetActor(Actor self, Target target, ref TargetModifiers modifiers, ref string cursor)
            {
                IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);

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

                // Disguised actors are revealed by the attack cursor
                // HACK: works around limitations in the targeting code that force the
                // targeting and attacking logic (which should be logically separate)
                // to use the same code
                if (target.Type == TargetType.Actor && target.Actor.EffectiveOwner != null &&
                    target.Actor.EffectiveOwner.Disguised && self.Owner.Stances[target.Actor.Owner] == Stance.Enemy)
                {
                    modifiers |= TargetModifiers.ForceAttack;
                }

                var forceAttack = modifiers.HasModifier(TargetModifiers.ForceAttack);
                var a           = ab.ChooseArmamentsForTarget(target, forceAttack).FirstOrDefault();

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

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

                if (!forceAttack)
                {
                    return(true);
                }

                OrderID = ab.forceAttackOrderName;
                return(true);
            }
Exemplo n.º 33
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);
                }

                var stance = target.Owner.RelationshipWith(self.Owner);

                if (!info.TargetRelationships.HasStance(stance) && !modifiers.HasModifier(TargetModifiers.ForceAttack))
                {
                    return(false);
                }

                if (!info.ForceTargetRelationships.HasStance(stance) && modifiers.HasModifier(TargetModifiers.ForceAttack))
                {
                    return(false);
                }

                return(target.TraitsImplementing <IDemolishable>().Any(i => i.IsValidTarget(target, self)));
            }
Exemplo n.º 34
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);
			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;
		}
Exemplo n.º 35
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;
			}
Exemplo n.º 36
0
 public bool TargetOverridesSelection(TargetModifiers modifiers)
 {
     return modifiers.HasModifier(TargetModifiers.ForceMove);
 }
Exemplo n.º 37
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;
            }
Exemplo n.º 38
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;
        }
Exemplo n.º 39
0
            bool CanTargetActor(Actor self, Target target, TargetModifiers modifiers, ref string cursor)
            {
                IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);

                cursor = self.Info.Traits.Get<AttackBaseInfo>().Cursor;

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

                if (!self.Trait<AttackBase>().HasAnyValidWeapons(target))
                    return false;

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

                if (modifiers.HasModifier(TargetModifiers.ForceMove))
                    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;
            }
Exemplo n.º 40
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));
            }
Exemplo n.º 41
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);
            }
Exemplo n.º 42
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;

                var demolishable = target.TraitOrDefault<IDemolishable>();
                if (demolishable == null || !demolishable.IsValidTarget(target, self))
                    return false;

                return true;
            }
Exemplo n.º 43
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;
			}
Exemplo n.º 44
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 = info.TargetBlockedCursor;

                return true;
            }
Exemplo n.º 45
0
            bool CanTargetLocation(Actor self, CPos location, List<Actor> actorsAtLocation, TargetModifiers modifiers, ref string cursor)
            {
                if (!self.World.Map.IsInMap(location))
                    return false;

                IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);

                cursor = self.Info.Traits.Get<AttackBaseInfo>().Cursor;

                if (negativeDamage)
                    return false;

                if (!self.Trait<AttackBase>().HasAnyValidWeapons(Target.FromCell(location)))
                    return false;

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

                return false;
            }