Smooth 3C & simplify hallucination trigger
This commit is contained in:
@@ -22,23 +22,23 @@ namespace Unheimlich.Core.Interaction
|
||||
_playerCamera = GetComponent<Camera>();
|
||||
}
|
||||
|
||||
private bool _didHit;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (RaycastHelper.ThrottledRaycastComponent(
|
||||
ref _raycastTimer,
|
||||
_didHit = RaycastHelper.ThrottledRaycastComponent(
|
||||
ref _raycastTimer,
|
||||
_raycastInterval,
|
||||
_playerCamera,
|
||||
_interactionRange,
|
||||
_interactableLayers,
|
||||
out InteractableBase interactable))
|
||||
{
|
||||
_playerCamera,
|
||||
_interactionRange,
|
||||
_interactableLayers,
|
||||
out InteractableBase interactable);
|
||||
|
||||
if (_didHit)
|
||||
_currentInteractable = interactable;
|
||||
}
|
||||
else if (_raycastTimer == 0f)
|
||||
{
|
||||
else if (!_didHit && _raycastTimer <= 0f)
|
||||
_currentInteractable = null;
|
||||
}
|
||||
|
||||
|
||||
HandleInteractionInput();
|
||||
}
|
||||
|
||||
|
||||
@@ -85,8 +85,6 @@ namespace Unheimlich.Core.Interaction
|
||||
|
||||
private void ResetSessionState()
|
||||
{
|
||||
// Force-despawn any leftover words from the previous session
|
||||
// (their GOs were destroyed but _spawnedWords list may still have stale entries).
|
||||
if (_isActive)
|
||||
{
|
||||
foreach (var word in _spawnedWords)
|
||||
@@ -103,19 +101,19 @@ namespace Unheimlich.Core.Interaction
|
||||
_isActive = false;
|
||||
_isMerged = false;
|
||||
_hasBeenMergedOnce = false;
|
||||
// _hasCompletedMergeOnce intentionally NOT reset here — persists during session
|
||||
// so a merged object stays merged when the player re-enters its activation range.
|
||||
// It is only reset at the start of a new Play Mode session (see OnPlayModeReset).
|
||||
_hasCompletedMergeOnce = false; // reset so MergeOnce objects start fresh each session
|
||||
_currentConvergenceRadius = 0f;
|
||||
}
|
||||
|
||||
// Resets _hasCompletedMergeOnce at the very start of each Play Mode session,
|
||||
// before any scene loads, so objects start fresh without full Domain Reload.
|
||||
// Resets _hasCompletedMergeOnce at the very start of each Play Mode session so
|
||||
// merged objects start fresh without requiring a full Domain Reload.
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
|
||||
private static void OnPlayModeReset()
|
||||
{
|
||||
// Static reset — instance fields will be re-initialized by Awake/Start naturally.
|
||||
// No instance access needed here; ResetSessionState() handles the rest on OnEnable.
|
||||
// Finding all instances isn't possible from a static context with SubsystemRegistration.
|
||||
// The reset is handled per-instance in OnEnable via _hasCompletedMergeOnce being
|
||||
// re-initialized when the scene reloads. For Enter Play Mode without scene reload,
|
||||
// ResetSessionState() is called from OnEnable and now correctly clears the flag.
|
||||
}
|
||||
|
||||
void Update()
|
||||
|
||||
Reference in New Issue
Block a user