refactor: extract shared MouseCapture helper
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Linq;
|
||||
using Game.Features.Players.Domain;
|
||||
using Game.Godot;
|
||||
using Game.Godot.Extensions;
|
||||
using Game.Godot.Mappings;
|
||||
using Godot;
|
||||
@@ -19,8 +20,6 @@ public partial class PlayerController : Node3D
|
||||
private PlayerMovement _movement;
|
||||
private PlayerLook _look;
|
||||
|
||||
private static bool IsMouseCaptured() => Input.MouseMode == Input.MouseModeEnum.Captured;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
this.AssertRequiredExports();
|
||||
@@ -32,7 +31,7 @@ public partial class PlayerController : Node3D
|
||||
|
||||
public override void _UnhandledInput(InputEvent @event)
|
||||
{
|
||||
if (@event is not InputEventMouseMotion mouseMotion || !IsMouseCaptured()) return;
|
||||
if (@event is not InputEventMouseMotion mouseMotion || !MouseCapture.IsCaptured) return;
|
||||
|
||||
Body.RotateY(_look.CalculateYawDelta(mouseMotion.Relative.X));
|
||||
_look.UpdatePitch(mouseMotion.Relative.Y);
|
||||
|
||||
Reference in New Issue
Block a user