Integration of the octo input system and centralization of player values

This commit is contained in:
2026-02-17 17:29:27 +01:00
parent 7b48e385b2
commit 79da2e5722
38 changed files with 2831 additions and 673 deletions
@@ -3,13 +3,13 @@ using UnityEngine;
using UnityEngine.InputSystem;
using Unheimlich.Core;
using Unheimlich.Gameplay.Items;
using InputManager = Unheimlich.Managers.PlayerInputManager;
using Unheimlich.Gameplay.Player;
using InputManager = Unheimlich.Managers.InputManager;
namespace Unheimlich.Interactions.Core
{
/// <summary>
/// Handles player item inspection mode.
/// When inspecting, disables player movement and allows item rotation using look input.
/// </summary>
public class PlayerInspectionHandler : Singleton<PlayerInspectionHandler>
{
@@ -42,7 +42,14 @@ namespace Unheimlich.Interactions.Core
IsInspecting = true;
_currentInspectedItem = item;
InputManager.ToggleInput(false);
// Set Inspection context (handles cursor automatically)
InputManager.SetContext(InputManager.InputContext.Inspection);
// Disable OctoPlayer to prevent movement and look
if (PlayerController.Instance?.Movement != null)
{
PlayerController.Instance.Movement.enabled = false;
}
item.PrepareForInspection(_inspectionHoldPoint);
@@ -77,7 +84,17 @@ namespace Unheimlich.Interactions.Core
private IEnumerator DelayedToggleInput(bool enable)
{
yield return new WaitForEndOfFrame();
InputManager.ToggleInput(enable);
// Re-enable OctoPlayer
if (PlayerController.Instance?.Movement != null)
{
PlayerController.Instance.Movement.enabled = true;
}
// Restore Normal context (handles cursor automatically)
InputManager.SetContext(InputManager.InputContext.Normal);
yield break;
}
@@ -109,21 +126,44 @@ namespace Unheimlich.Interactions.Core
private void HandleObjectRotation()
{
if (InputManager.Instance == null) return;
if (_currentInspectedItem == null) return;
Vector2 lookInput = InputManager.Instance.LookInput;
Vector2 lookInput = Vector2.zero;
bool hasInput = false;
if (lookInput != Vector2.zero)
// Read input directly (not cached)
if (Gamepad.current != null)
{
if (Gamepad.current != null && Gamepad.current.rightStick.ReadValue().magnitude > 0.01f)
Vector2 stickInput = Gamepad.current.rightStick.ReadValue();
if (stickInput.sqrMagnitude > 0.01f)
{
lookInput = stickInput;
hasInput = true;
_isUsingGamepad = true;
else if (Mouse.current != null && Mouse.current.delta.ReadValue().magnitude > 0.01f)
}
}
if (!hasInput && Mouse.current != null)
{
Vector2 mouseDelta = Mouse.current.delta.ReadValue();
if (mouseDelta.sqrMagnitude > 0.01f)
{
lookInput = mouseDelta;
hasInput = true;
_isUsingGamepad = false;
float deltaMultiplier = _isUsingGamepad ? Time.deltaTime : 0.005f;
}
}
// Only rotate if there's actual input
if (hasInput)
{
// Normalize to get constant rotation speed regardless of input magnitude
Vector2 direction = lookInput.normalized;
float rotX = lookInput.y * _currentInspectedItem.RotationSpeed * deltaMultiplier;
float rotY = lookInput.x * _currentInspectedItem.RotationSpeed * deltaMultiplier;
float rotationMultiplier = _isUsingGamepad ? Time.deltaTime : 0.02f;
float rotX = direction.y * _currentInspectedItem.RotationSpeed * rotationMultiplier;
float rotY = direction.x * _currentInspectedItem.RotationSpeed * rotationMultiplier;
_currentInspectedItem.transform.Rotate(transform.up, -rotY, Space.World);
_currentInspectedItem.transform.Rotate(transform.right, rotX, Space.World);