Ejemplo n.º 1
0
    public override void _Input(InputEvent @event)
    {
        if (@event is InputEventMouseMotion)
        {
            float Sensitivity = 0.3f;
            if (IsAiming)
            {
                Sensitivity *= 0.5f;
            }

            Vector3 BodyRotation = BodyNode.RotationDeg;
            BodyRotation.y = ((BodyRotation.y - ((InputEventMouseMotion)@event).Relative.x * Sensitivity) % 360.0f);

            Vector3 CameraRotation = CameraNode.RotationDeg;
            CameraRotation.x = Mathf.clamp(CameraRotation.x - ((InputEventMouseMotion)@event).Relative.y * Sensitivity, -89.0f, 89.0f);

            BodyNode.RotationDeg   = BodyRotation;
            CameraNode.RotationDeg = CameraRotation;

            ViewModel.AddMotion(((InputEventMouseMotion)@event).Relative);
        }

        if (@event is InputEventMouseButton)
        {
            if (((InputEventMouseButton)@event).ButtonIndex == GD.BUTTON_RIGHT)
            {
                ToggleAim(((InputEventMouseButton)@event).Pressed);
            }

            if (((InputEventMouseButton)@event).ButtonIndex == GD.BUTTON_LEFT)
            {
                IsFiring = ((InputEventMouseButton)@event).Pressed;
            }
        }
    }