refactor: throw on uninitialized PlayerInteractionController instead of logging

This commit is contained in:
2026-08-28 23:00:09 +02:00
parent 9fdd565637
commit 888e39e15d
3 changed files with 20 additions and 12 deletions
@@ -3,9 +3,9 @@ using Game.Features.Interactions.Application;
using Game.Features.Interactions.Contracts;
using Game.Features.Interactions.Domain;
using Game.Features.Items.Contracts;
using Game.Features.Logging.Contracts;
using Game.Features.Players.Contracts;
using Game.Godot;
using Game.Godot.Exceptions;
using Game.Godot.Extensions;
using Game.Godot.Mappings;
using Godot;
@@ -35,10 +35,8 @@ public partial class PlayerInteractionController : Node, IItemSpawnPoint
[Export]
public Node3D RightHandAnchor;
private const string LogCategory = "PlayerInteraction";
private IItemInteractionService _items;
private IInteractionHandler _interactions;
private ILogger _logger;
private PlayerId _playerId;
private readonly HashSet<Hand> _dropActions = [];
private readonly ResolvePickupAvailability _resolvePickupAvailability = new();
@@ -158,14 +156,12 @@ public partial class PlayerInteractionController : Node, IItemSpawnPoint
public void Initialize(
PlayerId playerId,
IItemInteractionService items,
IInteractionHandler interactions,
ILogger logger
IInteractionHandler interactions
)
{
_playerId = playerId;
_items = items;
_interactions = interactions;
_logger = logger;
}
public Vector3 GetItemSpawnPosition() => CalculateDropPosition();
@@ -179,9 +175,7 @@ public partial class PlayerInteractionController : Node, IItemSpawnPoint
{
if (_items is null || _interactions is null)
{
_logger?.Warning(LogCategory, "Skipped frame: controller not yet initialized.");
PromptController.Clear();
return;
throw new ControllerNotInitializedException(Name);
}
if (GamePause.IsPaused || !MouseCapture.IsCaptured)
@@ -197,8 +191,7 @@ public partial class PlayerInteractionController : Node, IItemSpawnPoint
{
if (_items is null || _interactions is null)
{
_logger?.Warning(LogCategory, "Ignored input: controller not yet initialized.");
return;
throw new ControllerNotInitializedException(Name);
}
if (GamePause.IsPaused || !MouseCapture.IsCaptured)