コード例 #1
0
        protected override void OnInside(Actor self)
        {
            if (target.IsDead)
            {
                return;
            }

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

            if (!validStances.HasStance(stance))
            {
                return;
            }

            if (cloak != null && cloak.Info.UncloakOn.HasFlag(UncloakType.Infiltrate))
            {
                cloak.Uncloak();
            }

            foreach (var t in target.TraitsImplementing <INotifyInfiltrated>())
            {
                t.Infiltrated(target, self);
            }

            if (!string.IsNullOrEmpty(notification))
            {
                Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech",
                                            notification, self.Owner.Faction.InternalName);
            }
        }
コード例 #2
0
        protected override void OnInside(Actor self)
        {
            if (target.IsDead)
            {
                return;
            }

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

            if (!infiltrates.Info.ValidStances.HasStance(stance))
            {
                return;
            }

            if (cloak != null && cloak.Info.UncloakOnInfiltrate)
            {
                cloak.Uncloak();
            }

            foreach (var t in target.TraitsImplementing <INotifyInfiltrated>())
            {
                t.Infiltrated(target, self);
            }

            self.Dispose();

            if (target.Info.HasTraitInfo <BuildingInfo>())
            {
                Game.Sound.PlayToPlayer(self.Owner, "bldginf1.aud");
            }
        }
コード例 #3
0
        public override Activity Tick(Actor self)
        {
            cargo.Unloading = false;
            if (IsCanceled || cargo.IsEmpty(self))
            {
                return(NextActivity);
            }

            if (cloak != null && cloak.Info.UncloakOnUnload)
            {
                cloak.Uncloak();
            }

            var actor = cargo.Peek(self);
            var spawn = self.CenterPosition;

            var exitSubCell = ChooseExitSubCell(actor);

            if (exitSubCell == null)
            {
                foreach (var blocker in BlockedExitCells(actor).SelectMany(p => self.World.ActorMap.GetUnitsAt(p)))
                {
                    foreach (var nbm in blocker.TraitsImplementing <INotifyBlockingMove>())
                    {
                        nbm.OnNotifyBlockingMove(blocker, self);
                    }
                }
                return(Util.SequenceActivities(new Wait(10), this));
            }

            cargo.Unload(self);
            self.World.AddFrameEndTask(w =>
            {
                if (actor.Destroyed)
                {
                    return;
                }

                var move = actor.Trait <IMove>();
                var pos  = actor.Trait <IPositionable>();

                actor.CancelActivity();
                pos.SetVisualPosition(actor, spawn);
                actor.QueueActivity(move.MoveIntoWorld(actor, exitSubCell.Value.First, exitSubCell.Value.Second));
                actor.SetTargetLine(Target.FromCell(w, exitSubCell.Value.First, exitSubCell.Value.Second), Color.Green, false);
                w.Add(actor);
            });

            if (!unloadAll || cargo.IsEmpty(self))
            {
                return(NextActivity);
            }

            cargo.Unloading = true;
            return(this);
        }
コード例 #4
0
        public override Activity Tick(Actor self)
        {
            cargo.Unloading = false;
            if (IsCanceled || cargo.IsEmpty(self))
            {
                return(NextActivity);
            }

            if (cloak != null && cloak.Info.UncloakOn.HasFlag(UncloakType.Unload))
            {
                cloak.Uncloak();
            }

            var actor = cargo.Peek(self);
            var spawn = self.CenterPosition;

            var exitSubCell = ChooseExitSubCell(actor);

            if (exitSubCell == null)
            {
                self.NotifyBlocker(BlockedExitCells(actor));

                return(ActivityUtils.SequenceActivities(new Wait(10), this));
            }

            cargo.Unload(self);
            self.World.AddFrameEndTask(w =>
            {
                if (actor.Disposed)
                {
                    return;
                }

                var move = actor.Trait <IMove>();
                var pos  = actor.Trait <IPositionable>();

                actor.CancelActivity();
                pos.SetVisualPosition(actor, spawn);
                actor.QueueActivity(move.MoveIntoWorld(actor, exitSubCell.Value.First, exitSubCell.Value.Second));
                actor.SetTargetLine(Target.FromCell(w, exitSubCell.Value.First, exitSubCell.Value.Second), Color.Green, false);
                w.Add(actor);
            });

            if (!unloadAll || cargo.IsEmpty(self))
            {
                return(NextActivity);
            }

            cargo.Unloading = true;
            return(this);
        }
コード例 #5
0
        protected override void OnInside(Actor self)
        {
            self.World.AddFrameEndTask(w =>
            {
                if (target.IsDead)
                {
                    return;
                }

                if (cloak != null && cloak.Info.UncloakOnDemolish)
                {
                    cloak.Uncloak();
                }

                for (var f = 0; f < flashes; f++)
                {
                    w.Add(new DelayedAction(flashesDelay + f * flashInterval, () =>
                                            w.Add(new FlashTarget(target, ticks: flashDuration))));
                }

                w.Add(new DelayedAction(delay, () =>
                {
                    if (target.IsDead)
                    {
                        return;
                    }

                    var modifiers = target.TraitsImplementing <IDamageModifier>()
                                    .Concat(self.Owner.PlayerActor.TraitsImplementing <IDamageModifier>())
                                    .Select(t => t.GetDamageModifier(self, null));

                    if (Util.ApplyPercentageModifiers(100, modifiers) > 0)
                    {
                        demolishables.Do(d => d.Demolish(target, self));
                    }
                }));

                if (enterBehaviour == EnterBehaviour.Suicide)
                {
                    self.Kill(self);
                }
                else if (enterBehaviour == EnterBehaviour.Dispose)
                {
                    self.Dispose();
                }
            });
        }
コード例 #6
0
        protected override void OnInside(Actor self)
        {
            self.World.AddFrameEndTask(w =>
            {
                if (target.IsDead)
                {
                    return;
                }

                if (cloak != null && cloak.Info.UncloakOn.HasFlag(UncloakType.Demolish))
                {
                    cloak.Uncloak();
                }

                var building = target.TraitOrDefault <Building>();
                if (building != null)
                {
                    building.Lock();
                }

                for (var f = 0; f < flashes; f++)
                {
                    w.Add(new DelayedAction(flashesDelay + f * flashInterval, () =>
                                            w.Add(new FlashTarget(target, ticks: flashDuration))));
                }

                w.Add(new DelayedAction(delay, () =>
                {
                    if (target.IsDead)
                    {
                        return;
                    }

                    var modifiers = target.TraitsImplementing <IDamageModifier>()
                                    .Concat(self.Owner.PlayerActor.TraitsImplementing <IDamageModifier>())
                                    .Select(t => t.GetDamageModifier(self, null));

                    if (Util.ApplyPercentageModifiers(100, modifiers) > 0)
                    {
                        demolishables.Do(d => d.Demolish(target, self));
                    }
                }));
            });
        }
コード例 #7
0
ファイル: Infiltrate.cs プロジェクト: wenzeslaus/OpenRA
        protected override void OnInside(Actor self)
        {
            if (target.IsDead || target.Owner == self.Owner)
            {
                return;
            }

            if (cloak != null && cloak.Info.UncloakOnInfiltrate)
            {
                cloak.Uncloak();
            }

            foreach (var t in target.TraitsImplementing <INotifyInfiltrated>())
            {
                t.Infiltrated(target, self);
            }

            self.Destroy();

            if (target.HasTrait <Building>())
            {
                Sound.PlayToPlayer(self.Owner, "bldginf1.aud");
            }
        }