예제 #1
0
        private void OnTick(object sender, EventArgs e)
        {
            GameplayCamera.ClampPitch(-179, 179);

            if (!PlayerController.ModEnabled)
            {
                if (!_spideySenseOn)
                {
                    return;
                }
                Game.TimeScale = 0;
                _spideySenseOn = false;
                return;
            }

            Game.DisableControlThisFrame(2, Control.SpecialAbility);
            Game.DisableControlThisFrame(2, Control.SpecialAbilityPC);
            Game.DisableControlThisFrame(2, Control.SpecialAbilitySecondary);

            if (Game.IsDisabledControlJustPressed(2, Control.SpecialAbility) ||
                Game.IsDisabledControlJustPressed(2, Control.SpecialAbilityPC))
            {
                _spideySenseOn = !_spideySenseOn;
            }

            if (_spideySenseOn)
            {
                var scroll = Game.GetControlNormal(2, Control.CursorScrollUp);
                //UI.ShowSubtitle(scroll.ToString(CultureInfo.InvariantCulture));
                _timeScale = Maths.Clamp(_timeScale, 0.0001f, 0.2f);
            }

            Game.TimeScale = _spideySenseOn ? _timeScale : 1f;
        }
예제 #2
0
        private void RotateGameplayCameraTowardsTarget()
        {
            if (!_lastTarget.HasValue)
            {
                return;
            }

            var dir = _lastTarget.Value - _forwardCamera.Position;

            _yawToTarget   = Geometry.DirectionToRotation(dir).Z;
            _pitchToTarget = Geometry.DirectionToRotation(dir).X;

            Game.Player.Character.Heading = _yawToTarget;

            GameplayCamera.RelativeHeading = 0;
            GameplayCamera.ClampPitch(_pitchToTarget, _pitchToTarget);
            GameplayCamera.RelativePitch   = _pitchToTarget;
            GameplayCameraRotationFiltered = Geometry.DirectionToRotation(dir);

            var deltaPitch = _forwardCamera.Rotation.Z - _yawToTarget;
            var deltaYaw   = _forwardCamera.Rotation.X - _pitchToTarget;
            var minAngle   = 0.01f;

            if (Math.Abs(deltaYaw) < minAngle && Math.Abs(deltaPitch) < minAngle)
            {
                _lastTarget = null;
            }
        }
예제 #3
0
        private void UpdateClimbing(Vector3 surfacePosition, Vector3 surfaceNormal)
        {
            // Create the attachmentObject.
            var attachmentObject = World.CreateProp("w_pi_pistol", surfacePosition, false, false);

            attachmentObject.PositionNoOffset = surfacePosition;
            attachmentObject.HasCollision     = false;
            attachmentObject.FreezePosition   = true;
            attachmentObject.Quaternion       = Maths.LookRotation(Vector3.WorldUp, surfaceNormal);
            attachmentObject.Alpha            = 0;
            // attachmentObject.Alpha = 0;

            // Attach the player to the attachment object.
            Profile.LocalUser.Task.ClearAllImmediately();
            Profile.LocalUser.AttachTo(attachmentObject, 0, new Vector3(0, 0, 1), Vector3.Zero);
            Profile.LocalUser.Task.PlayAnimation("move_crouch_proto", "idle_intro", 8.0f, -1, AnimationFlags.Loop);

            // Delay for the control.
            GameWaiter.Wait(10);

            // Create camera.
            var camDirection  = Vector3.Zero;
            var moveDirection = Vector3.Zero;
            //var camSpawn = attachmentObject.GetOffsetInWorldCoords(new Vector3(0, -2, 1));
            //var cam = World.CreateCamera(camSpawn, Vector3.Zero, 60);
            //cam.Direction = attachmentObject.Position - cam.Position;
            //cam.TransitionIn(100);

            //var pivot = World.CreateProp("w_pi_pistol", attachmentObject.Position, false, false);
            //pivot.FreezePosition = true;
            //pivot.IsVisible = false;
            //pivot.Quaternion = attachmentObject.Quaternion;

            //// Camera rotation.
            //var xRotation = 0f;
            //var yRotation = 45f;

            // flags.
            var cancelClimb = false;
            var idleTimer   = 0f;

            while (!cancelClimb)
            {
                // Override the enabled controls.
                SetActiveControls();

                GameplayCamera.ClampPitch(-90, 90);

                // Rotate the wall cam.
                //RotateCam(cam, pivot, attachmentObject, ref xRotation, ref yRotation);

                // Get the movement vector.
                var movement = GetMovementVector();

                // Move the player attachment.
                Move(/*cam, */ surfaceNormal, attachmentObject, ref camDirection, ref moveDirection, movement);

                // Play the player movement animations.
                DoMovementAnimations(attachmentObject, movement.Length(), ref idleTimer);

                // Start a new surface ray.
                var surfaceRay = WorldProbe.StartShapeTestRay(attachmentObject.Position + attachmentObject.UpVector,
                                                              attachmentObject.Position - attachmentObject.UpVector,
                                                              ShapeTestFlags.IntersectMap, attachmentObject);

                // Handle the ejection keys.
                HandleEject(ref cancelClimb, attachmentObject);

                // Make sure the result is not empty.
                var result = surfaceRay.GetResult();
                if (!result.Hit)
                {
                    DetachPlayer(attachmentObject);
                    GameWaiter.Wait(10);
                    if (Game.IsDisabledControlPressed(2, Control.Sprint))
                    {
                        Profile.LocalUser.HasCollision     = false;
                        Profile.LocalUser.IsCollisionProof = true;
                        Profile.LocalUser.SetConfigFlag(60, false);
                        Profile.LocalUser.Task.Skydive();
                        Profile.LocalUser.Task.PlayAnimation("swimming@swim", "recover_back_to_idle",
                                                             2.0f, -2.0f, 1150, AnimationFlags.AllowRotation, 0.0f);
                        Profile.LocalUser.Velocity = Vector3.WorldUp * 25f;
                        WebZip.OverrideFallHeight(float.MaxValue);
                        var t = 0.1f;
                        while (t > 0f)
                        {
                            t -= Game.LastFrameTime;
                            Profile.LocalUser.HasCollision = false;
                            Script.Yield();
                        }
                        Profile.LocalUser.HasCollision     = true;
                        Profile.LocalUser.IsCollisionProof = false;
                    }
                    else
                    {
                        Profile.LocalUser.Task.Climb();
                        WebZip.OverrideFallHeight(0f);
                    }
                    break;
                }

                // Set the surface position.
                surfacePosition = result.EndCoords;

                // Check the surface normal.
                if (surfaceNormal != result.SurfaceNormal)
                {
                    // If the surface normal has changed, then change immediately rotation the player
                    // to match the normal.
                    surfaceNormal = result.SurfaceNormal;
                    Move(/*cam, */ surfaceNormal, attachmentObject, ref camDirection, ref moveDirection, movement,
                         false);
                }

                attachmentObject.PositionNoOffset = surfacePosition;

                Script.Yield();
            }

            // Destroy the camera.
            //Utilities.DestroyAllCameras();

            // Delte the camera pivot.
            //pivot.Delete();
        }