Esempio n. 1
0
 public static PredictionOutput Predict(this PredictionInput input)
 {
     return(Picker.Current.Predict(input));
 }
Esempio n. 2
0
 public PredictionOutput Predict(PredictionInput predInput) => this.GetPrediction(predInput, true, true);
Esempio n. 3
0
        private static PredictionOutput GetDashingPrediction(PredictionInput input)
        {
            //var gapcloserInfo = input.Unit.GetGapcloserInfo();
            PredictionOutput predictionOutput = new PredictionOutput()
            {
                Input = input
            };

            //if (gapcloserInfo != null && gapcloserInfo.SpellName != "NullDash")
            //{
            //    Vector2 vector2 = gapcloserInfo.EndPosition.ToVector2();
            //    PredictionInput input1 = input;
            //    List<Vector2> path = new List<Vector2>();
            //    path.Add(input.Unit.Position.ToVector2());
            //    path.Add(vector2);
            //    double speed = (double)gapcloserInfo.Speed;
            //    PredictionOutput positionOnPath = GetPositionOnPath(input1, path, (float)speed);
            //    if (positionOnPath.Hitchance >= HitChance.High && (double)positionOnPath.UnitPosition.ToVector2().Distance(input.Unit.Position.ToVector2(), vector2, true) < Math.Sqrt(200.0))
            //    {
            //        positionOnPath.CastPosition = positionOnPath.UnitPosition;
            //        positionOnPath.Hitchance = HitChance.Dash;
            //        return positionOnPath;
            //    }
            //    if (gapcloserInfo.StartPosition.Distance(gapcloserInfo.EndPosition) > 200.0 && input.Delay / 2.0 + input.From.ToVector2().Distance(vector2) / input.Speed - 0.25 <= input.Unit.Distance(vector2) / (double)gapcloserInfo.Speed + input.RealRadius / input.Unit.MoveSpeed)
            //        return new PredictionOutput()
            //        {
            //            CastPosition = vector2.ToVector3(),
            //            UnitPosition = vector2.ToVector3(),
            //            Hitchance = HitChance.Dash
            //        };
            //    predictionOutput.CastPosition = gapcloserInfo.EndPosition;
            //    predictionOutput.UnitPosition = gapcloserInfo.EndPosition;
            //}
            //else
            //{
            input.Delay += 0.1f;
            var             dashInfo = input.Unit.GetDash();
            Vector2         vector2  = dashInfo.Path.Last().ToVector2();
            PredictionInput input1   = input;
            List <Vector2>  path     = new List <Vector2>();

            path.Add(dashInfo.StartPosition.ToVector2());
            path.Add(vector2);
            float            speed          = dashInfo.Speed;
            PredictionOutput positionOnPath = GetPositionOnPath(input1, path, speed);

            if (positionOnPath.Hitchance >= HitChance.High && positionOnPath.UnitPosition.ToVector2().Distance(input.Unit.Position.ToVector2(), vector2, true) < 200.0)
            {
                positionOnPath.CastPosition = positionOnPath.UnitPosition;
                positionOnPath.Hitchance    = HitChance.Dash;
                return(positionOnPath);
            }
            if (dashInfo.StartPosition.ToVector2().Distance(dashInfo.EndPosition.ToVector2()) > 200.0 && input.Delay / 2.0 + input.From.ToVector2().Distance(vector2) / input.Speed - 0.25 <= input.Unit.Position.ToVector2().Distance(vector2) / dashInfo.Speed + input.RealRadius / input.Unit.MoveSpeed)
            {
                return new PredictionOutput()
                       {
                           CastPosition = vector2.ToVector3(),
                           UnitPosition = vector2.ToVector3(),
                           Hitchance    = HitChance.Dash
                       }
            }
            ;
            predictionOutput.CastPosition = vector2.ToVector3();
            predictionOutput.UnitPosition = vector2.ToVector3();
            //}
            return(predictionOutput);
        }
Esempio n. 4
0
        private static PredictionOutput GetPositionOnPath(
            PredictionInput input,
            List <Vector2> path,
            float speed         = -1f,
            bool needToFixSpeed = false)
        {
            if (needToFixSpeed && (double)input.Unit.Distance(input.From) < 250.0)
            {
                speed *= 1.5f;
            }
            speed = (double)Math.Abs(speed - -1f) < 1.40129846432482E-45 ? input.Unit.MoveSpeed : speed;
            Vector3 previousPosition = input.Unit.PreviousPosition;

            if (path.Count <= 1 || input.Unit.IsWindingUp && !input.Unit.IsDashing())
            {
                return new PredictionOutput()
                       {
                           Input        = input,
                           UnitPosition = previousPosition,
                           CastPosition = previousPosition,
                           Hitchance    = HitChance.VeryHigh
                       }
            }
            ;
            float pathLength = path.PathLength();

            if (path.Count == 2 && (double)pathLength < 5.0 && (input.Unit.CharName == "PracticeTool_TargetDummy" || input.Unit is IMinion minion && (minion.IsMinion() || minion.IsJungle())))
            {
                return new PredictionOutput()
                       {
                           Input        = input,
                           UnitPosition = input.Unit.Position,
                           CastPosition = input.Unit.Position,
                           Hitchance    = HitChance.VeryHigh
                       }
            }
            ;
            if ((double)pathLength >= (double)input.Delay * (double)speed - (double)input.RealRadius && (double)Math.Abs(input.Speed - float.MaxValue) < 1.40129846432482E-45)
            {
                float num = input.Delay * speed - input.RealRadius;

                for (int index = 0; index < path.Count - 1; ++index)
                {
                    Vector2 vector2_1 = path[index];
                    Vector2 toVector2 = path[index + 1];
                    float   val2      = vector2_1.Distance(toVector2);
                    if ((double)val2 >= (double)num)
                    {
                        Vector2 vector2_2 = (toVector2 - vector2_1).Normalized();
                        Vector2 vector2_3 = vector2_1 + vector2_2 * num;
                        Vector2 vector2_4 = vector2_1 + vector2_2 * (index == path.Count - 2 ? Math.Min(num + input.RealRadius, val2) : num + input.RealRadius);
                        return(new PredictionOutput()
                        {
                            Input = input,
                            CastPosition = vector2_3.ToVector3().SetZ(),
                            UnitPosition = vector2_4.ToVector3().SetZ(),
                            Hitchance = GetHitchance(input.Unit)
                        });
                    }
                    num -= val2;
                }
            }
            if ((double)pathLength >= (double)input.Delay * (double)speed - (double)input.RealRadius && (double)Math.Abs(input.Speed - float.MaxValue) > 1.40129846432482E-45)
            {
                float distance = input.Delay * speed - input.RealRadius;
                if ((input.Type == SpellType.Line || input.Type == SpellType.Cone) && Vector3.DistanceSquared(input.From, previousPosition) < Math.Pow(200.0, 2.0))
                {
                    distance = input.Delay * speed;
                }
                path = path.CutPath(distance);
                float delay = 0.0f;
                for (int index = 0; index < path.Count - 1; ++index)
                {
                    Vector2 vector2_1 = path[index];
                    Vector2 vector2_2 = path[index + 1];
                    float   num       = vector2_1.Distance(vector2_2) / speed;
                    Vector2 vector2_3 = (vector2_2 - vector2_1).Normalized();
                    MovementCollisionInfo movementCollisionInfo = (vector2_1 - speed * delay * vector2_3).VectorMovementCollision(vector2_2, speed, input.From.ToVector2(), input.Speed, delay);
                    float   collisionTime     = movementCollisionInfo.CollisionTime;
                    Vector2 collisionPosition = movementCollisionInfo.CollisionPosition;
                    if (collisionPosition.IsValid() && (double)collisionTime >= (double)delay && (double)collisionTime <= (double)delay + (double)num)
                    {
                        if (collisionPosition.Distance(vector2_2) >= Math.Sqrt(20d))
                        {
                            Vector2 vector2_4 = collisionPosition - input.RealRadius * vector2_3;
                            return(new PredictionOutput()
                            {
                                Input = input,
                                CastPosition = collisionPosition.ToVector3().SetZ(),
                                UnitPosition = vector2_4.ToVector3().SetZ(),
                                Hitchance = GetHitchance(input.Unit)
                            });
                        }
                        break;
                    }
                    delay += num;
                }
            }
            Vector2 vector2 = path.LastOrDefault();

            return(new PredictionOutput()
            {
                Input = input,
                CastPosition = vector2.ToVector3().SetZ(),
                UnitPosition = vector2.ToVector3().SetZ(),
                Hitchance = HitChance.Medium
            });
        }