IsValidFor() 공개 메소드

public IsValidFor ( Actor targeter ) : bool
targeter Actor
리턴 bool
예제 #1
1
        public override void DoImpact(Target target, Actor firedBy, IEnumerable<int> damageModifiers)
        {
            if (!target.IsValidFor(firedBy))
                return;

            var pos = target.CenterPosition;
            var world = firedBy.World;
            var targetTile = world.Map.CellContaining(pos);
            var isValid = IsValidImpact(pos, firedBy);

            if ((!world.Map.Contains(targetTile)) || (!isValid))
                return;

            var palette = ExplosionPalette;
            if (UsePlayerPalette)
                palette += firedBy.Owner.InternalName;

            var explosion = Explosions.RandomOrDefault(Game.CosmeticRandom);
            if (Image != null && explosion != null)
                world.AddFrameEndTask(w => w.Add(new SpriteEffect(pos, w, Image, explosion, palette)));

            var impactSound = ImpactSounds.RandomOrDefault(Game.CosmeticRandom);
            if (impactSound != null)
                Game.Sound.Play(impactSound, pos);
        }
예제 #2
0
        protected override bool CanAttack(Actor self, Target target)
        {
            if (!target.IsValidFor(self))
                return false;

            return base.CanAttack(self, target);
        }
예제 #3
0
        public void AttackTarget(Target target, bool queued, bool allowMove)
        {
            if (!target.IsValidFor(self))
                return;

            if (!queued)
                self.CancelActivity();

            self.QueueActivity(GetAttackActivity(self, target, allowMove));
        }
예제 #4
0
        public MoveAdjacentTo(Actor self, Target target)
        {
            Target = target;

            mobile = self.Trait<Mobile>();
            pathFinder = self.World.WorldActor.Trait<IPathFinder>();
            domainIndex = self.World.WorldActor.Trait<DomainIndex>();
            movementClass = (uint)mobile.Info.GetMovementClass(self.World.TileSet);

            if (target.IsValidFor(self))
                targetPosition = self.World.Map.CellContaining(target.CenterPosition);

            repath = true;
        }
예제 #5
0
		protected virtual bool CanAttack(Actor self, Target target)
		{
			if (!self.IsInWorld)
				return false;

			// Building is under construction or is being sold
			if (building.Value != null && !building.Value.BuildComplete)
				return false;

			if (!target.IsValidFor(self))
				return false;

			if (Armaments.All(a => a.IsReloading))
				return false;

			if (self.IsDisabled())
				return false;

			return true;
		}
예제 #6
0
        static UnitOrderResult OrderForUnit(Actor self, Target target, MouseInput mi)
        {
            if (self.Owner != self.World.LocalPlayer)
                return null;

            if (self.Destroyed || !target.IsValidFor(self))
                return null;

            if (mi.Button == Game.Settings.Game.MouseButtonPreference.Action)
            {
                foreach (var o in self.TraitsImplementing<IIssueOrder>()
                    .SelectMany(trait => trait.Orders
                        .Select(x => new { Trait = trait, Order = x }))
                    .OrderByDescending(x => x.Order.OrderPriority))
                {
                    var actorsAt = self.World.ActorMap.GetUnitsAt(self.World.Map.CellContaining(target.CenterPosition)).ToList();

                    var modifiers = TargetModifiers.None;
                    if (mi.Modifiers.HasModifier(Modifiers.Ctrl))
                        modifiers |= TargetModifiers.ForceAttack;
                    if (mi.Modifiers.HasModifier(Modifiers.Shift))
                        modifiers |= TargetModifiers.ForceQueue;
                    if (mi.Modifiers.HasModifier(Modifiers.Alt))
                        modifiers |= TargetModifiers.ForceMove;

                    string cursor = null;
                    if (o.Order.CanTarget(self, target, actorsAt, modifiers, ref cursor))
                        return new UnitOrderResult(self, o.Order, o.Trait, cursor, target);
                }
            }

            return null;
        }
예제 #7
0
        /// <summary>
        /// Returns the most appropriate order for a given actor and target.
        /// First priority is given to orders that interact with the given actors.
        /// Second priority is given to actors in the given cell.
        /// </summary>
        static UnitOrderResult OrderForUnit(Actor self, Target target, List<Actor> actorsAt, CPos xy, MouseInput mi)
        {
            if (mi.Button != Game.Settings.Game.MouseButtonPreference.Action)
                return null;

            if (self.Owner != self.World.LocalPlayer)
                return null;

            if (self.World.IsGameOver)
                return null;

            if (self.Disposed || !target.IsValidFor(self))
                return null;

            var modifiers = TargetModifiers.None;
            if (mi.Modifiers.HasModifier(Modifiers.Ctrl))
                modifiers |= TargetModifiers.ForceAttack;
            if (mi.Modifiers.HasModifier(Modifiers.Shift))
                modifiers |= TargetModifiers.ForceQueue;
            if (mi.Modifiers.HasModifier(Modifiers.Alt))
                modifiers |= TargetModifiers.ForceMove;

            var orders = self.TraitsImplementing<IIssueOrder>()
                .SelectMany(trait => trait.Orders.Select(x => new { Trait = trait, Order = x }))
                .OrderByDescending(x => x.Order.OrderPriority);

            for (var i = 0; i < 2; i++)
            {
                foreach (var o in orders)
                {
                    var localModifiers = modifiers;
                    string cursor = null;
                    if (o.Order.CanTarget(self, target, actorsAt, ref localModifiers, ref cursor))
                        return new UnitOrderResult(self, o.Order, o.Trait, cursor, target);
                }

                // No valid orders, so check for orders against the cell
                target = Target.FromCell(self.World, xy);
            }

            return null;
        }
예제 #8
0
        protected virtual bool CanAttack(Actor self, Target target)
        {
            if (!self.IsInWorld)
                return false;

            if (!target.IsValidFor(self))
                return false;

            if (Armaments.All(a => a.IsReloading))
                return false;

            if (self.IsDisabled())
                return false;

            return true;
        }