Example #1
0
        protected void PerformMove(Actor self, int2 targetLocation, bool queued)
        {
            var ph = new QueuedActivity(
                (qa) =>
                {
                    int2 currentLocation = NearestMoveableCell(targetLocation);

                    if (!CanEnterCell(currentLocation))
                    {
                        if (queued) self.CancelActivity();
                        return;
                    }

                    if (!queued) self.CancelActivity();

                    ticksBeforePathing = avgTicksBeforePathing + self.World.SharedRandom.Next(-spreadTicksBeforePathing, spreadTicksBeforePathing);

                    qa.Insert(new Move(currentLocation, 8));

                    self.SetTargetLine(Target.FromCell(currentLocation), Color.Green);
                });

            self.QueueActivity(queued ? ph : ph.Run(self));
        }
Example #2
0
        protected void PerformMove(Actor self, int2 targetLocation, bool queued)
        {
            var ph = new QueuedActivity(
                (qa) =>
                {
                    int2 currentLocation = NearestMoveableCell(targetLocation);

                    if (!CanEnterCell(currentLocation))
                    {
                        if (queued) self.CancelActivity();
                        return;
                    }

                    if (!queued) self.CancelActivity();

                    ticksBeforePathing = avgTicksBeforePathing + self.World.SharedRandom.Next(-spreadTicksBeforePathing, spreadTicksBeforePathing);

                    qa.Insert(new Move(currentLocation, 8));

                    if (self.Owner == self.World.LocalPlayer)
                        self.World.AddFrameEndTask(
                            w =>
                            {
                                if (self.Destroyed) return;
                                w.Add(new MoveFlash(self.World, targetLocation));
                                var line = self.TraitOrDefault<DrawLineToTarget>();
                                if (line != null)
                                    line.SetTarget(self, Target.FromCell(currentLocation),
                                                   Color.Green);
                            });
                });

            self.QueueActivity(queued ? ph : ph.Run(self));
        }