Ejemplo n.º 1
0
        public override void Process()
        {
            if (Mods.HoverUnderbody == ModState.Off)
            {
                return;
            }

            // Automatically fold wheels in if fly mode is exited in any other way
            // Example: getting out of vehicle, flipping vehicle over, etc
            if (IsFlying && VehicleControl.GetDeluxoTransformation(Vehicle) <= 0)
            {
                SetFlyMode(false);
            }

            // Automatically set fly mode if deluxo is transformed in any other way.
            if (!IsFlying && VehicleControl.GetDeluxoTransformation(Vehicle) > 0 && !IsLanding)
            {
                SetFlyMode(true);
            }

            // Process the wheel animations
            wheelAnims?.Process();

            _flyModeInput.Process();

            if (Main.PlayerVehicle == Vehicle)
            {
                Function.Call(Hash.SET_PLAYER_CAN_DO_DRIVE_BY, Game.Player.Handle, false);
            }
            else
            {
                Function.Call(Hash.SET_PLAYER_CAN_DO_DRIVE_BY, Game.Player.Handle, true);
            }

            if (Vehicle == null || !Vehicle.IsVisible)
            {
                return;
            }

            // Process underbody lights
            UnderbodyLights();

            if (IsLanding)
            {
                // Reset force to be applied
                _forceToBeApplied = Vector3.Zero;

                // Process up/down movement
                UpDown();

                // Altitude holder
                //if (!Game.IsControlPressed(GTA.Control.VehicleFlyThrottleUp) && !Game.IsControlPressed(GTA.Control.VehicleFlyThrottleDown))
                //    HandleAltitudeHolding();

                // Apply force
                Vehicle.ApplyForce(_forceToBeApplied, Vector3.Zero);

                if (Vehicle.HeightAboveGround < 3 && !_landingSmoke)
                {
                    _smokeParticles.ForEach(x => x.Play());
                    _landingSmoke = true;
                }

                if (!Vehicle.IsUpsideDown && Vehicle.HeightAboveGround > 0.5f && Vehicle.HeightAboveGround < 20)
                {
                    return;
                }

                SetFlyMode(false);
            }

            if (!IsFlying)
            {
                return;
            }

            if (ModSettings.TurbulenceEvent && (World.Weather == Weather.Clearing || World.Weather == Weather.Raining || World.Weather == Weather.ThunderStorm || World.Weather == Weather.Blizzard))
            {
                if (Game.GameTime > _nextForce)
                {
                    float _force = 0;

                    switch (World.Weather)
                    {
                    case Weather.Clearing:
                        _force = 0.5f;
                        break;

                    case Weather.Raining:
                        _force = 0.75f;
                        break;

                    case Weather.ThunderStorm:
                    case Weather.Blizzard:
                        _force = 1;
                        break;
                    }

                    _force *= (Vehicle.HeightAboveGround / 20f);

                    if (_force > 1)
                    {
                        _force = 1;
                    }

                    Vehicle.ApplyForce(Vector3.RandomXYZ() * _force, Vector3.RandomXYZ() * _force);

                    _nextForce = Game.GameTime + 100;
                }
            }

            if (TimeCircuits.FlyingCircuitsBroken)
            {
                var force = Vehicle.UpVector;

                if (!Vehicle.IsUpsideDown)
                {
                    force.Z = -force.Z;
                }

                force *= 12 * Game.LastFrameTime;

                Vehicle.ApplyForce(force, Vector3.Zero);

                if (Vehicle.HeightAboveGround < 2)
                {
                    SetFlyMode(false);
                }

                return;
            }

            // Reset force to be applied
            _forceToBeApplied = Vector3.Zero;

            // Process boost
            HandleBoosting();

            // Process up/down movement
            UpDown();

            // Altitude holder
            if (IsAltitudeHolding)
            {
                HandleAltitudeHolding();
            }

            // Apply force
            Vehicle.ApplyForce(_forceToBeApplied, Vector3.Zero);

            // Force fly mode
            if (ModSettings.ForceFlyMode)
            {
                VehicleControl.SetDeluxoFlyMode(Vehicle, 1f);
            }

            // Force brake lights on if flying
            if (IsFlying)
            {
                Vehicle.AreBrakeLightsOn = true;
            }

            if (_startHoverGlowLater && Vehicle.IsEngineRunning)
            {
                SpawnHoverGlow();
            }
        }