Example #1
0
        private async Task OnUpdate(CancellationToken token)
        {
            if (Game.IsPaused || !this.Owner.IsAlive || !PortalLocations.Any())
            {
                await Task.Delay(250, token);

                return;
            }

            if (Ensage.SDK.Extensions.UnitExtensions.HasModifier(this.Owner, "modifier_void_spirit_dissimilate_phase"))
            {
                if (UnitExtensions.FindModifier(this.Owner, "modifier_void_spirit_dissimilate_phase").RemainingTime >= 0.2f && this.VoidSpirit.RandomlyJump)
                {
                    foreach (var portalLocation in PortalLocations.ToList())
                    {
                        this.Owner.Move(portalLocation);
                        await Task.Delay(50, token);

                        if (UnitExtensions.FindModifier(this.Owner, "modifier_void_spirit_dissimilate_phase")
                            .RemainingTime <= 0.2f)
                        {
                            break;
                        }
                    }
                }
                else if (this.CurrentTarget != null)
                {
                    var closestPortal = this.PortalLocations
                                        .OrderBy(x => VectorExtensions.Distance2D(x, this.CurrentTarget)).FirstOrDefault();
                    if (this.Owner.Move(closestPortal))
                    {
                        await Task.Delay(50, token);
                    }
                }
                else
                {
                    var closestToMouse = this.PortalLocations.OrderBy(x => x.Distance2D(Game.MousePosition))
                                         .FirstOrDefault();
                    if (this.Owner.Move(closestToMouse))
                    {
                        await Task.Delay(50, token);
                    }
                }
            }
        }