Add utils + refacto

This commit is contained in:
2026-01-30 17:39:26 +01:00
parent 9ff17b5305
commit 23d3cb5d2c
29 changed files with 675 additions and 461 deletions
@@ -4,6 +4,7 @@ using Unheimlich.Gameplay.Player;
using Unheimlich.Interactions.Dialogues;
using Unheimlich.Interactions.FloatingWords;
using Unheimlich.Data.Dialogues;
using Unheimlich.Utility;
namespace Unheimlich.Managers
{
@@ -32,8 +33,6 @@ namespace Unheimlich.Managers
private readonly float _focusRetentionTime;
private readonly float _fallbackShakeIntensity;
private static readonly Vector3 ViewportCenter = new Vector3(0.5f, 0.5f, 0f);
public event Action<DialogueChoiceData> OnChoiceMade;
public DialogueFocusSystem(
@@ -96,16 +95,13 @@ namespace Unheimlich.Managers
if (_mainCamera == null)
return;
Ray ray = _mainCamera.ViewportPointToRay(ViewportCenter);
ChoiceFocusHandler hitHandler = null;
bool raycastHitChoice = Physics.Raycast(ray, out RaycastHit hit, _focusRange, _choiceLayer);
if (raycastHitChoice)
ChoiceFocusHandler hitHandler = null;
if (RaycastHelper.RaycastFromCameraCenter(_mainCamera, _focusRange, _choiceLayer, out RaycastHit hit))
{
hitHandler = hit.collider.GetComponent<ChoiceFocusHandler>();
if (_playerLook != null)
if (_playerLook != null && hitHandler != null)
_playerLook.ApplyAimAssist(hit.collider.bounds.center);
}
@@ -1,5 +1,6 @@
using UnityEngine;
using System;
using Unheimlich.Core;
using Unheimlich.Data.Dialogues;
using Unheimlich.Gameplay.Player;
using Unheimlich.UI;
@@ -8,9 +9,8 @@ using System.Collections.Generic;
namespace Unheimlich.Managers
{
public class DialogueManager : MonoBehaviour
{
public static DialogueManager Instance { get; private set; }
public class DialogueManager : Singleton<DialogueManager>
{
[Header("State")]
public bool IsInDialogue = false;
@@ -51,14 +51,8 @@ namespace Unheimlich.Managers
private float _autoCloseTimer = 0f;
private bool _isWaitingForAutoClose = false;
private void Awake()
protected override void OnAwake()
{
if (Instance != null && Instance != this)
{
Destroy(this);
return;
}
Instance = this;
}
private void Start()
@@ -1,5 +1,6 @@
using UnityEngine;
using UnityEngine.InputSystem;
using Unheimlich.Core;
using Unheimlich.Gameplay.Player;
namespace Unheimlich.Managers
@@ -10,7 +11,7 @@ namespace Unheimlich.Managers
/// Supports different input contexts (Normal, Dialogue, Listening) to control which inputs are active.
/// </summary>
[RequireComponent(typeof(PlayerInput))]
public class PlayerInputManager : MonoBehaviour
public class PlayerInputManager : Singleton<PlayerInputManager>
{
/// <summary>
/// Defines different input contexts that control which player actions are enabled.
@@ -22,8 +23,6 @@ namespace Unheimlich.Managers
Listening // Only look enabled, movement disabled (for diapason camera pan)
}
public static PlayerInputManager Instance { get; private set; }
[Header("Input Values (Read only)")]
public Vector2 MoveInput;
public Vector2 LookInput;
@@ -44,15 +43,8 @@ namespace Unheimlich.Managers
private PlayerLook _playerLook;
private CameraHeadBob _headBob;
private void Awake()
protected override void OnAwake()
{
if (Instance != null && Instance != this)
{
Destroy(this);
return;
}
Instance = this;
IsInputEnabled = true;
PlayerInput playerInput = GetComponent<PlayerInput>();
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using UnityEngine;
using Unheimlich.Core;
using Unheimlich.Gameplay.Portals;
namespace Unheimlich.Managers
@@ -9,9 +10,8 @@ namespace Unheimlich.Managers
/// Monitors player distance to portals and loads/unloads room instances accordingly.
/// Supports room pooling (keeping inactive rooms in memory) and distance-based activation.
/// </summary>
public class PortalRoomManager : MonoBehaviour
public class PortalRoomManager : Singleton<PortalRoomManager>
{
public static PortalRoomManager Instance { get; private set; }
[Header("Settings")]
[SerializeField] private float _loadDistance = 15f;
@@ -44,16 +44,6 @@ namespace Unheimlich.Managers
public bool BoundsCalculated = false;
}
private void Awake()
{
if (Instance != null && Instance != this)
{
Destroy(this);
return;
}
Instance = this;
}
private void Start()
{
_player = GameObject.FindGameObjectWithTag("Player")?.transform;