Beispiel #1
0
        private void Aim()
        {
            var aimVector       = Vector3.ProjectOnPlane(_fireTransform.forward, Vector3.up);
            var directionVector = (_playerTransform.position - transform.position).normalized;
            var angle           = AIHelper.GetRotationAngle(aimVector, directionVector);

            var aimFactor = Mathf.Abs(angle) > _rotationThreshold?Mathf.Sign(angle) : 0;

            _aimer.Aim(aimFactor);
        }
Beispiel #2
0
        public bool Tick(double dt, Rectangle region, Esp esp)
        {
            time += dt;

            if (process != null && grabber != null)
            {
                var image = grabber.Grab(process.MainWindowHandle, region, esp, true, out var changed);
                if (image != IntPtr.Zero && changed)
                {
                    if (detector != null)
                    {
                        stopwatch.Restart();

                        var position   = new Point(region.X + region.Width / 2, region.Y + region.Height / 2);
                        var detections = detector.Detect(image, region, esp);

                        if (tracker != null && selector != null)
                        {
                            tracker.Track(detections, esp, time);
                            var target = selector.Select(tracker, position, esp, activated, time);

                            if (aimer != null)
                            {
                                if (activated)
                                {
                                    aimer.Aim(injector, target, position, dt);
                                }
                                else
                                {
                                    aimer.Tick(injector, activated, dt);
                                }
                            }

                            if (trigger != null)
                            {
                                trigger.Trigger(injector, position, target, region, esp, ref activated, time);
                            }
                        }

                        time = 0.0;
                        stopwatch.Stop();

                        if (esp != null)
                        {
                            var fps = 1000.0 / (double)stopwatch.Elapsed.TotalMilliseconds;
                            esp.Add(new TextShape(new Point(region.X, region.Y - 20), $"FPS: {Math.Round(fps)}", Color.LimeGreen, 12));
                        }
                    }
                    else
                    {
                        tracker?.Clear();
                        selector?.Clear();
                        aimer?.Clear();
                        trigger?.Clear();
                    }

                    return(activated);
                }
                else
                {
                    if (aimer != null)
                    {
                        aimer.Tick(injector, activated, dt);
                    }

                    stopwatch.Stop();
                }
            }

            return(false);
        }