Example #1
0
        public void OnTick(object sender, EventArgs e)
        {
            if (_shutDownRequestFlag)
            {
                return;
            }

            _tobiiTracker.Update();

            _debugGazeVisualization.Move(new Vector2(TobiiAPI.GetGazePoint().X *UI.WIDTH, TobiiAPI.GetGazePoint().Y *UI.HEIGHT));

            _controllerEmulation.Enabled = !Game.IsPaused;
            _mouseEmulation.Enabled      = !Game.IsPaused && !_menuPool.IsAnyMenuOpen() && _isWindowForeground;

            //CheckFreelookDevice();

            SaveSettingsOnMenuClosed();

            Game.Player.Character.CanBeKnockedOffBike = _settings.DontFallFromBikesEnabled;             //Bug in Script hook

            if (Game.IsPaused)
            {
                return;
            }

            if (!_settings.UserAgreementAccepted)
            {
                _introScreen.OpenMenu();
            }

            RecordGameSessionStarted();

            Vector3 shootCoord;
            Vector3 shootCoordSnap;
            Vector3 shootMissileCoord;
            Ped     ped;
            Entity  missileTarget;


            var         controllerState = _controllerEmulation.ControllerState;
            const float joystickRadius  = 0.1f;

            var joystickDelta = new Vector2(controllerState.Gamepad.RightThumbX, -controllerState.Gamepad.RightThumbY) *
                                (1.0f / 32768.0f) * joystickRadius;

            _gameState.Update();

            var centeredNormalizedGaze = new Vector2(TobiiAPI.GetGazePoint().X, TobiiAPI.GetGazePoint().Y) * 2 - new Vector2(1, 1);

            _gazeProjector.FindGazeProjection(
                centeredNormalizedGaze,
                joystickDelta,
                out shootCoord,
                out shootCoordSnap,
                out shootMissileCoord,
                out ped,
                out missileTarget);

            _controlsProcessor.Update(_lastTickTime, shootCoord, shootCoordSnap, shootMissileCoord, ped, missileTarget);

            //_aiming.TurnHead(ped, shootCoord);
            _menuPool.ProcessMenus();


            _animationHelper.Process();

            if (_debugOutput.Visible)
            {
                _debugGazeVisualization.Render();
            }

            _debugOutput.Process();

            _mouseEmulation.ProcessInput();

            _lastTickTime = DateTime.UtcNow;

            if (_shutDownRequestFlag)
            {
                _shutDownRequestedEvent.Set();
            }
        }
Example #2
0
        public void Update(Vector3 shootCoord, Entity missileTarget, bool isShootAtCenter)
        {
            var time = DateTime.UtcNow;

            _timeDelta = time - _lastTime;
            _lastTime  = time;

            IsCrosshairAtCenter = isShootAtCenter;

            if (_settings.MissilesAtGazeEnabled &&
                Game.Player.Character.IsInVehicle() &&
                missileTarget != null)
            {
                Vector2 screenCoords;
                if (Geometry.WorldToScreenRel(missileTarget.Position, out screenCoords))
                {
                    MoveCrosshair(screenCoords);
                    IsMissileLockedCrosshairVisible = true;
                }
            }
            else
            {
                Vector2 screenCoords;
                if (Geometry.WorldToScreenRel(shootCoord, out screenCoords))
                {
                    MoveCrosshair(screenCoords);
                    IsMissileLockedCrosshairVisible = false;
                }
            }



            if ((_settings.ExtendedViewEnabled || _settings.FireAtGazeEnabled) &&
                !(!_gameState.IsInVehicle && GameState.IsFirstPersonPedCameraActive()) &&
                (GameplayCamera.IsAimCamActive ||
                 _gameState.IsAimingWithMouse ||
                 _gameState.IsAimingWithGamepad ||
                 _gameState.IsShootingWithMouse ||
                 _gameState.IsShootingWithGamepad ||
                 (_settings.AlwaysShowCrosshairEnabled && !_gameState.IsInVehicle)) &&
                !_gameState.IsMeleeWeapon &&
                !_gameState.IsSniperWeaponAndZoomed &&
                !_gameState.IsInRadialMenu &&
                !_gameState.IsInCharacterSelectionMenu)
            {
                IsCrosshairVisible = true;
            }
            else
            {
                IsCrosshairVisible = false;
            }

            if (IsCrosshairVisible)
            {
                UI.HideHudComponentThisFrame((HudComponent)14);
            }

            if (IsCrosshairVisible &&
                !IsMissileLockedCrosshairVisible)
            {
                _dotCrosshair.Render();
            }

            if (_settings.MissilesAtGazeEnabled &&
                Game.Player.Character.IsInVehicle() &&
                IsMissileLockedCrosshairVisible)
            {
                _missileLockCrosshair.Render();
            }

            _homingMissilesHelper.Process();
        }