Fix issues with the indicator null checks
This commit is contained in:
@@ -25,6 +25,7 @@ namespace PuzzleS
|
||||
|
||||
private Interactable _interactable;
|
||||
private bool _isUnlocked = false;
|
||||
private bool _isCompleted = false;
|
||||
private IPuzzlePrompt _indicator;
|
||||
|
||||
// Current proximity state tracked by PuzzleManager
|
||||
@@ -72,6 +73,7 @@ namespace PuzzleS
|
||||
public void UpdateProximityState(ProximityState newState)
|
||||
{
|
||||
if (_currentProximityState == newState) return;
|
||||
if (_indicator == null) return;
|
||||
|
||||
// Determine state changes and call appropriate methods
|
||||
if (newState == ProximityState.Close)
|
||||
@@ -96,7 +98,7 @@ namespace PuzzleS
|
||||
public virtual void OnShow()
|
||||
{
|
||||
// Delegate to indicator if available
|
||||
if (_indicator != null)
|
||||
if (IsIndicatorValid())
|
||||
{
|
||||
_indicator.OnShow();
|
||||
return;
|
||||
@@ -112,7 +114,7 @@ namespace PuzzleS
|
||||
public virtual void OnHide()
|
||||
{
|
||||
// Delegate to indicator if available
|
||||
if (_indicator != null)
|
||||
if (IsIndicatorValid())
|
||||
{
|
||||
_indicator.OnHide();
|
||||
return;
|
||||
@@ -131,7 +133,7 @@ namespace PuzzleS
|
||||
if (!_isUnlocked) return;
|
||||
|
||||
// Delegate to indicator if available
|
||||
if (_indicator != null)
|
||||
if (IsIndicatorValid())
|
||||
{
|
||||
_indicator.ShowFar();
|
||||
return;
|
||||
@@ -150,7 +152,7 @@ namespace PuzzleS
|
||||
if (!_isUnlocked) return;
|
||||
|
||||
// Delegate to indicator if available
|
||||
if (_indicator != null)
|
||||
if (IsIndicatorValid())
|
||||
{
|
||||
_indicator.ShowClose();
|
||||
return;
|
||||
@@ -169,7 +171,7 @@ namespace PuzzleS
|
||||
if (!_isUnlocked) return;
|
||||
|
||||
// Delegate to indicator if available
|
||||
if (_indicator != null)
|
||||
if (IsIndicatorValid())
|
||||
{
|
||||
_indicator.HideClose();
|
||||
return;
|
||||
@@ -188,7 +190,7 @@ namespace PuzzleS
|
||||
if (!_isUnlocked) return;
|
||||
|
||||
// Delegate to indicator if available
|
||||
if (_indicator != null)
|
||||
if (IsIndicatorValid())
|
||||
{
|
||||
_indicator.HideFar();
|
||||
return;
|
||||
@@ -266,7 +268,7 @@ namespace PuzzleS
|
||||
Logging.Debug($"[Puzzles] Step locked: {stepData?.stepId} on {gameObject.name}");
|
||||
|
||||
// Hide indicator
|
||||
if (_indicator != null)
|
||||
if (IsIndicatorValid())
|
||||
{
|
||||
_indicator.OnHide();
|
||||
}
|
||||
@@ -298,11 +300,17 @@ namespace PuzzleS
|
||||
if (success)
|
||||
{
|
||||
Logging.Debug($"[Puzzles] Step interacted: {stepData?.stepId} on {gameObject.name}");
|
||||
Destroy(puzzleIndicator);
|
||||
_isCompleted = true;
|
||||
PuzzleManager.Instance?.MarkPuzzleStepCompleted(stepData);
|
||||
Destroy(puzzleIndicator);
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsIndicatorValid()
|
||||
{
|
||||
return _indicator != null && puzzleIndicator != null && !_isCompleted;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Visualizes the puzzle prompt ranges in the editor.
|
||||
/// </summary>
|
||||
|
||||
@@ -29,19 +29,4 @@ public class PuzzleStepSO : ScriptableObject
|
||||
/// </summary>
|
||||
[Header("Unlocks")]
|
||||
public List<PuzzleStepSO> unlocks = new List<PuzzleStepSO>();
|
||||
|
||||
[Header("Interaction Settings")]
|
||||
[Tooltip("Whether to show an indicator when this step is unlocked")]
|
||||
[SerializeField] private bool showIndicator = false;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to show an indicator when this step is unlocked.
|
||||
/// </summary>
|
||||
public bool ShowIndicator => showIndicator;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether to show an indicator.
|
||||
/// </summary>
|
||||
public bool GetShowIndicator() => showIndicator;
|
||||
public void SetShowIndicator(bool value) => showIndicator = value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user