2025-11-10 15:56:30 +01:00
|
|
|
|
using Input;
|
2025-09-11 13:00:26 +02:00
|
|
|
|
using Interactions;
|
2025-09-06 21:01:54 +02:00
|
|
|
|
using UnityEngine;
|
2025-10-14 15:53:58 +02:00
|
|
|
|
using Core;
|
2025-11-07 15:38:31 +00:00
|
|
|
|
using Core.Lifecycle;
|
2025-09-03 15:43:47 +02:00
|
|
|
|
|
2025-09-11 13:00:26 +02:00
|
|
|
|
namespace PuzzleS
|
2025-09-03 15:43:47 +02:00
|
|
|
|
{
|
2025-09-06 21:01:54 +02:00
|
|
|
|
/// <summary>
|
2025-09-11 13:00:26 +02:00
|
|
|
|
/// Manages the state and interactions for a single puzzle step, including unlock/lock logic and event handling.
|
2025-09-06 21:01:54 +02:00
|
|
|
|
/// </summary>
|
Refactoring of the interaction system and preliminary integration of save/load functionality across the game. (#44)
### Interactables Architecture Refactor
- Converted composition to inheritance, moved from component-based to class-based interactables. No more requirement for chain of "Interactable -> Item" etc.
- Created `InteractableBase` abstract base class with common functionality that replaces the old component
- Specialized child classes: `Pickup`, `ItemSlot`, `LevelSwitch`, `MinigameSwitch`, `CombinationItem`, `OneClickInteraction` are now children classes
- Light updates to the interactable inspector, moved some things arround, added collapsible inspector sections in the UI for better editor experience
### State Machine Integration
- Custom `AppleMachine` inheritong from Pixelplacement's StateMachine which implements our own interface for saving, easy place for future improvements
- Replaced all previous StateMachines by `AppleMachine`
- Custom `AppleState` extends from default `State`. Added serialization, split state logic into "EnterState", "RestoreState", "ExitState" allowing for separate logic when triggering in-game vs loading game
- Restores directly to target state without triggering transitional logic
- Migration tool converts existing instances
### Prefab Organization
- Saved changes from scenes into prefabs
- Cleaned up duplicated components, confusing prefabs hierarchies
- Created prefab variants where possible
- Consolidated Environment prefabs and moved them out of Placeholders subfolder into main Environment folder
- Organized item prefabs from PrefabsPLACEHOLDER into proper Items folder
- Updated prefab references - All scene references updated to new locations
- Removed placeholder files from Characters, Levels, UI, and Minigames folders
### Scene Updates
- Quarry scene with major updates
- Saved multiple working versions (Quarry, Quarry_Fixed, Quarry_OLD)
- Added proper lighting data
- Updated all interactable components to new architecture
### Minor editor tools
- New tool for testing cards from an editor window (no in-scene object required)
- Updated Interactable Inspector
- New debug option to opt in-and-out of the save/load system
- Tooling for easier migration
Co-authored-by: Michal Pikulski <michal.a.pikulski@gmail.com>
Reviewed-on: https://homelab.tailf7f81b.ts.net/tschesky/AppleHillsProduction/pulls/44
2025-11-03 10:12:51 +00:00
|
|
|
|
[RequireComponent(typeof(InteractableBase))]
|
2025-11-07 15:38:31 +00:00
|
|
|
|
public class ObjectiveStepBehaviour : ManagedBehaviour, IPuzzlePrompt
|
2025-09-03 15:43:47 +02:00
|
|
|
|
{
|
2025-09-11 13:00:26 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The data object representing this puzzle step.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public PuzzleStepSO stepData;
|
2025-10-02 05:42:17 +00:00
|
|
|
|
|
|
|
|
|
|
[Header("Indicator Settings")]
|
|
|
|
|
|
[SerializeField] private GameObject puzzleIndicator;
|
|
|
|
|
|
[SerializeField] private bool drawPromptRangeGizmo = true;
|
|
|
|
|
|
|
Refactoring of the interaction system and preliminary integration of save/load functionality across the game. (#44)
### Interactables Architecture Refactor
- Converted composition to inheritance, moved from component-based to class-based interactables. No more requirement for chain of "Interactable -> Item" etc.
- Created `InteractableBase` abstract base class with common functionality that replaces the old component
- Specialized child classes: `Pickup`, `ItemSlot`, `LevelSwitch`, `MinigameSwitch`, `CombinationItem`, `OneClickInteraction` are now children classes
- Light updates to the interactable inspector, moved some things arround, added collapsible inspector sections in the UI for better editor experience
### State Machine Integration
- Custom `AppleMachine` inheritong from Pixelplacement's StateMachine which implements our own interface for saving, easy place for future improvements
- Replaced all previous StateMachines by `AppleMachine`
- Custom `AppleState` extends from default `State`. Added serialization, split state logic into "EnterState", "RestoreState", "ExitState" allowing for separate logic when triggering in-game vs loading game
- Restores directly to target state without triggering transitional logic
- Migration tool converts existing instances
### Prefab Organization
- Saved changes from scenes into prefabs
- Cleaned up duplicated components, confusing prefabs hierarchies
- Created prefab variants where possible
- Consolidated Environment prefabs and moved them out of Placeholders subfolder into main Environment folder
- Organized item prefabs from PrefabsPLACEHOLDER into proper Items folder
- Updated prefab references - All scene references updated to new locations
- Removed placeholder files from Characters, Levels, UI, and Minigames folders
### Scene Updates
- Quarry scene with major updates
- Saved multiple working versions (Quarry, Quarry_Fixed, Quarry_OLD)
- Added proper lighting data
- Updated all interactable components to new architecture
### Minor editor tools
- New tool for testing cards from an editor window (no in-scene object required)
- Updated Interactable Inspector
- New debug option to opt in-and-out of the save/load system
- Tooling for easier migration
Co-authored-by: Michal Pikulski <michal.a.pikulski@gmail.com>
Reviewed-on: https://homelab.tailf7f81b.ts.net/tschesky/AppleHillsProduction/pulls/44
2025-11-03 10:12:51 +00:00
|
|
|
|
private InteractableBase _interactable;
|
2025-09-11 13:00:26 +02:00
|
|
|
|
private bool _isUnlocked = false;
|
2025-10-15 14:02:12 +02:00
|
|
|
|
private bool _isCompleted = false;
|
2025-10-02 05:42:17 +00:00
|
|
|
|
private IPuzzlePrompt _indicator;
|
|
|
|
|
|
|
|
|
|
|
|
// Current proximity state tracked by PuzzleManager
|
|
|
|
|
|
private ProximityState _currentProximityState = ProximityState.Far;
|
|
|
|
|
|
|
|
|
|
|
|
// Enum for tracking proximity state (simplified to just Close and Far)
|
|
|
|
|
|
public enum ProximityState { Close, Far }
|
2025-09-03 16:55:21 +02:00
|
|
|
|
|
2025-11-10 21:59:47 +01:00
|
|
|
|
internal override void OnManagedAwake()
|
2025-09-04 15:01:28 +02:00
|
|
|
|
{
|
Refactoring of the interaction system and preliminary integration of save/load functionality across the game. (#44)
### Interactables Architecture Refactor
- Converted composition to inheritance, moved from component-based to class-based interactables. No more requirement for chain of "Interactable -> Item" etc.
- Created `InteractableBase` abstract base class with common functionality that replaces the old component
- Specialized child classes: `Pickup`, `ItemSlot`, `LevelSwitch`, `MinigameSwitch`, `CombinationItem`, `OneClickInteraction` are now children classes
- Light updates to the interactable inspector, moved some things arround, added collapsible inspector sections in the UI for better editor experience
### State Machine Integration
- Custom `AppleMachine` inheritong from Pixelplacement's StateMachine which implements our own interface for saving, easy place for future improvements
- Replaced all previous StateMachines by `AppleMachine`
- Custom `AppleState` extends from default `State`. Added serialization, split state logic into "EnterState", "RestoreState", "ExitState" allowing for separate logic when triggering in-game vs loading game
- Restores directly to target state without triggering transitional logic
- Migration tool converts existing instances
### Prefab Organization
- Saved changes from scenes into prefabs
- Cleaned up duplicated components, confusing prefabs hierarchies
- Created prefab variants where possible
- Consolidated Environment prefabs and moved them out of Placeholders subfolder into main Environment folder
- Organized item prefabs from PrefabsPLACEHOLDER into proper Items folder
- Updated prefab references - All scene references updated to new locations
- Removed placeholder files from Characters, Levels, UI, and Minigames folders
### Scene Updates
- Quarry scene with major updates
- Saved multiple working versions (Quarry, Quarry_Fixed, Quarry_OLD)
- Added proper lighting data
- Updated all interactable components to new architecture
### Minor editor tools
- New tool for testing cards from an editor window (no in-scene object required)
- Updated Interactable Inspector
- New debug option to opt in-and-out of the save/load system
- Tooling for easier migration
Co-authored-by: Michal Pikulski <michal.a.pikulski@gmail.com>
Reviewed-on: https://homelab.tailf7f81b.ts.net/tschesky/AppleHillsProduction/pulls/44
2025-11-03 10:12:51 +00:00
|
|
|
|
_interactable = GetComponent<InteractableBase>();
|
2025-10-16 19:43:19 +02:00
|
|
|
|
|
|
|
|
|
|
// Initialize the indicator if it exists, but ensure it's hidden initially
|
|
|
|
|
|
if (puzzleIndicator != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
// The indicator should start inactive until we determine its proper state
|
|
|
|
|
|
puzzleIndicator.SetActive(false);
|
|
|
|
|
|
|
|
|
|
|
|
// Get the IPuzzlePrompt component
|
|
|
|
|
|
_indicator = puzzleIndicator.GetComponent<IPuzzlePrompt>();
|
|
|
|
|
|
|
|
|
|
|
|
if (_indicator == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Try to find it in children if not on the root
|
|
|
|
|
|
_indicator = puzzleIndicator.GetComponentInChildren<IPuzzlePrompt>();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (_indicator == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Logging.Warning($"[Puzzles] Indicator prefab for {stepData?.stepId} does not implement IPuzzlePrompt");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-10 21:59:47 +01:00
|
|
|
|
internal override void OnManagedStart()
|
2025-10-16 19:43:19 +02:00
|
|
|
|
{
|
2025-11-07 15:38:31 +00:00
|
|
|
|
// Register with PuzzleManager - safe to access .Instance here
|
2025-10-16 19:43:19 +02:00
|
|
|
|
if (stepData != null && PuzzleManager.Instance != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
PuzzleManager.Instance.RegisterStepBehaviour(this);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (stepData == null)
|
2025-09-12 14:38:56 +02:00
|
|
|
|
{
|
2025-10-16 19:43:19 +02:00
|
|
|
|
Logging.Warning($"[Puzzles] Cannot register step on {gameObject.name}: stepData is null");
|
2025-09-12 14:38:56 +02:00
|
|
|
|
}
|
2025-09-04 15:01:28 +02:00
|
|
|
|
}
|
2025-09-03 15:43:47 +02:00
|
|
|
|
|
2025-11-07 15:38:31 +00:00
|
|
|
|
void OnEnable()
|
2025-09-11 13:00:26 +02:00
|
|
|
|
{
|
2025-11-07 15:38:31 +00:00
|
|
|
|
if (_interactable == null)
|
|
|
|
|
|
_interactable = GetComponent<InteractableBase>();
|
|
|
|
|
|
|
2025-09-11 13:00:26 +02:00
|
|
|
|
if (_interactable != null)
|
|
|
|
|
|
{
|
2025-11-07 15:38:31 +00:00
|
|
|
|
_interactable.interactionStarted.AddListener(OnInteractionStarted);
|
|
|
|
|
|
_interactable.interactionComplete.AddListener(OnInteractionComplete);
|
2025-09-11 13:00:26 +02:00
|
|
|
|
}
|
2025-11-07 15:38:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnDestroy()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.OnDestroy();
|
2025-10-16 19:43:19 +02:00
|
|
|
|
|
|
|
|
|
|
if (PuzzleManager.Instance != null && stepData != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
PuzzleManager.Instance.UnregisterStepBehaviour(this);
|
|
|
|
|
|
}
|
2025-11-07 15:38:31 +00:00
|
|
|
|
|
|
|
|
|
|
if (_interactable != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_interactable.interactionStarted.RemoveListener(OnInteractionStarted);
|
|
|
|
|
|
_interactable.interactionComplete.RemoveListener(OnInteractionComplete);
|
|
|
|
|
|
}
|
2025-09-11 13:00:26 +02:00
|
|
|
|
}
|
2025-10-02 05:42:17 +00:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Updates the proximity state from PuzzleManager and triggers appropriate methods.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="newState">The new proximity state.</param>
|
|
|
|
|
|
public void UpdateProximityState(ProximityState newState)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_currentProximityState == newState) return;
|
2025-10-16 19:43:19 +02:00
|
|
|
|
if (!_isUnlocked) return; // Don't process state changes if locked
|
2025-10-02 05:42:17 +00:00
|
|
|
|
|
|
|
|
|
|
// Determine state changes and call appropriate methods
|
|
|
|
|
|
if (newState == ProximityState.Close)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Transitioning from Far to Close
|
|
|
|
|
|
ShowClose();
|
|
|
|
|
|
}
|
|
|
|
|
|
else // newState == ProximityState.Far
|
|
|
|
|
|
{
|
|
|
|
|
|
// Transitioning from Close to Far
|
|
|
|
|
|
HideClose();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_currentProximityState = newState;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// IPuzzlePrompt interface implementation - delegates to indicator if available
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called when the prompt should be initially shown (e.g., when step is unlocked)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public virtual void OnShow()
|
|
|
|
|
|
{
|
2025-10-16 19:43:19 +02:00
|
|
|
|
if (puzzleIndicator != null)
|
|
|
|
|
|
puzzleIndicator.SetActive(true);
|
|
|
|
|
|
|
2025-10-02 05:42:17 +00:00
|
|
|
|
// Delegate to indicator if available
|
2025-10-15 14:02:12 +02:00
|
|
|
|
if (IsIndicatorValid())
|
2025-10-02 05:42:17 +00:00
|
|
|
|
{
|
|
|
|
|
|
_indicator.OnShow();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-14 15:53:58 +02:00
|
|
|
|
Logging.Debug($"[Puzzles] Prompt shown for {stepData?.stepId} on {gameObject.name}");
|
2025-10-02 05:42:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called when the prompt should be hidden (e.g., when step is locked)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public virtual void OnHide()
|
|
|
|
|
|
{
|
2025-10-16 19:43:19 +02:00
|
|
|
|
if (puzzleIndicator != null)
|
|
|
|
|
|
puzzleIndicator.SetActive(false);
|
|
|
|
|
|
|
2025-10-02 05:42:17 +00:00
|
|
|
|
// Delegate to indicator if available
|
2025-10-15 14:02:12 +02:00
|
|
|
|
if (IsIndicatorValid())
|
2025-10-02 05:42:17 +00:00
|
|
|
|
{
|
|
|
|
|
|
_indicator.OnHide();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-14 15:53:58 +02:00
|
|
|
|
Logging.Debug($"[Puzzles] Prompt hidden for {stepData?.stepId} on {gameObject.name}");
|
2025-10-02 05:42:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called when player enters the far range
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public virtual void ShowFar()
|
|
|
|
|
|
{
|
|
|
|
|
|
// Only show if step is unlocked
|
|
|
|
|
|
if (!_isUnlocked) return;
|
|
|
|
|
|
|
|
|
|
|
|
// Delegate to indicator if available
|
2025-10-15 14:02:12 +02:00
|
|
|
|
if (IsIndicatorValid())
|
2025-10-02 05:42:17 +00:00
|
|
|
|
{
|
|
|
|
|
|
_indicator.ShowFar();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called when player enters the close range
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public virtual void ShowClose()
|
|
|
|
|
|
{
|
|
|
|
|
|
// Only show if step is unlocked
|
|
|
|
|
|
if (!_isUnlocked) return;
|
|
|
|
|
|
|
|
|
|
|
|
// Delegate to indicator if available
|
2025-10-15 14:02:12 +02:00
|
|
|
|
if (IsIndicatorValid())
|
2025-10-02 05:42:17 +00:00
|
|
|
|
{
|
|
|
|
|
|
_indicator.ShowClose();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called when player exits the close range
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public virtual void HideClose()
|
|
|
|
|
|
{
|
|
|
|
|
|
// Only respond if step is unlocked
|
|
|
|
|
|
if (!_isUnlocked) return;
|
|
|
|
|
|
|
|
|
|
|
|
// Delegate to indicator if available
|
2025-10-15 14:02:12 +02:00
|
|
|
|
if (IsIndicatorValid())
|
2025-10-02 05:42:17 +00:00
|
|
|
|
{
|
|
|
|
|
|
_indicator.HideClose();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called when player exits the far range
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public virtual void HideFar()
|
|
|
|
|
|
{
|
|
|
|
|
|
// Only respond if step is unlocked
|
|
|
|
|
|
if (!_isUnlocked) return;
|
|
|
|
|
|
|
|
|
|
|
|
// Delegate to indicator if available
|
2025-10-15 14:02:12 +02:00
|
|
|
|
if (IsIndicatorValid())
|
2025-10-02 05:42:17 +00:00
|
|
|
|
{
|
|
|
|
|
|
_indicator.HideFar();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-09-03 15:43:47 +02:00
|
|
|
|
|
2025-09-11 13:00:26 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Unlocks this puzzle step, allowing interaction.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public void UnlockStep()
|
|
|
|
|
|
{
|
2025-10-16 19:43:19 +02:00
|
|
|
|
if (_isUnlocked) return;
|
|
|
|
|
|
|
2025-09-11 13:00:26 +02:00
|
|
|
|
_isUnlocked = true;
|
2025-10-14 15:53:58 +02:00
|
|
|
|
Logging.Debug($"[Puzzles] Step unlocked: {stepData?.stepId} on {gameObject.name}");
|
2025-10-02 05:42:17 +00:00
|
|
|
|
|
2025-10-16 19:43:19 +02:00
|
|
|
|
// Make the indicator visible since this step is now unlocked
|
|
|
|
|
|
OnShow();
|
|
|
|
|
|
|
|
|
|
|
|
if (IsIndicatorValid())
|
2025-10-02 05:42:17 +00:00
|
|
|
|
{
|
2025-10-16 19:43:19 +02:00
|
|
|
|
// Set the correct state based on current player distance
|
|
|
|
|
|
Transform playerTransform = GameObject.FindGameObjectWithTag("Player")?.transform;
|
|
|
|
|
|
if (playerTransform != null)
|
2025-10-02 05:42:17 +00:00
|
|
|
|
{
|
2025-10-16 19:43:19 +02:00
|
|
|
|
float distance = Vector3.Distance(transform.position, playerTransform.position);
|
|
|
|
|
|
float promptRange = AppleHills.SettingsAccess.GetPuzzlePromptRange();
|
2025-10-02 05:42:17 +00:00
|
|
|
|
|
2025-10-16 19:43:19 +02:00
|
|
|
|
if (distance <= promptRange)
|
2025-10-02 05:42:17 +00:00
|
|
|
|
{
|
2025-10-16 19:43:19 +02:00
|
|
|
|
// Player is in close range
|
|
|
|
|
|
_currentProximityState = ProximityState.Close;
|
|
|
|
|
|
_indicator.ShowClose();
|
2025-10-02 05:42:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2025-10-16 19:43:19 +02:00
|
|
|
|
// Player is in far range
|
2025-10-02 05:42:17 +00:00
|
|
|
|
_currentProximityState = ProximityState.Far;
|
|
|
|
|
|
_indicator.ShowFar();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-10-16 19:43:19 +02:00
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
// Default to far if player not found
|
|
|
|
|
|
_currentProximityState = ProximityState.Far;
|
|
|
|
|
|
_indicator.ShowFar();
|
|
|
|
|
|
}
|
2025-10-02 05:42:17 +00:00
|
|
|
|
}
|
2025-09-11 13:00:26 +02:00
|
|
|
|
}
|
2025-09-03 15:43:47 +02:00
|
|
|
|
|
2025-09-11 13:00:26 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Locks this puzzle step, preventing interaction.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public void LockStep()
|
|
|
|
|
|
{
|
2025-10-16 19:43:19 +02:00
|
|
|
|
if (!_isUnlocked && puzzleIndicator != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Make sure indicator is hidden if we're already locked
|
|
|
|
|
|
puzzleIndicator.SetActive(false);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-11 13:00:26 +02:00
|
|
|
|
_isUnlocked = false;
|
2025-10-14 15:53:58 +02:00
|
|
|
|
Logging.Debug($"[Puzzles] Step locked: {stepData?.stepId} on {gameObject.name}");
|
2025-10-02 05:42:17 +00:00
|
|
|
|
|
2025-10-16 19:43:19 +02:00
|
|
|
|
// Hide the indicator
|
|
|
|
|
|
OnHide();
|
2025-09-11 13:00:26 +02:00
|
|
|
|
}
|
2025-09-03 15:43:47 +02:00
|
|
|
|
|
2025-09-11 13:00:26 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Returns whether this step is currently unlocked.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool IsStepUnlocked()
|
|
|
|
|
|
{
|
|
|
|
|
|
return _isUnlocked;
|
|
|
|
|
|
}
|
2025-09-04 15:01:28 +02:00
|
|
|
|
|
2025-09-11 13:00:26 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Handles the start of an interaction (can be used for visual feedback).
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void OnInteractionStarted(PlayerTouchController playerRef, FollowerController followerRef)
|
|
|
|
|
|
{
|
2025-10-16 19:43:19 +02:00
|
|
|
|
// Empty - handled by Interactable
|
2025-09-11 13:00:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Handles completion of the interaction, notifies PuzzleManager if successful and unlocked.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="success">Whether the interaction was successful.</param>
|
|
|
|
|
|
private void OnInteractionComplete(bool success)
|
2025-09-04 15:01:28 +02:00
|
|
|
|
{
|
2025-09-11 13:00:26 +02:00
|
|
|
|
if (!_isUnlocked) return;
|
2025-10-16 19:43:19 +02:00
|
|
|
|
if (success && !_isCompleted)
|
2025-09-11 13:00:26 +02:00
|
|
|
|
{
|
2025-10-14 15:53:58 +02:00
|
|
|
|
Logging.Debug($"[Puzzles] Step interacted: {stepData?.stepId} on {gameObject.name}");
|
2025-10-15 14:02:12 +02:00
|
|
|
|
_isCompleted = true;
|
2025-09-29 09:34:15 +00:00
|
|
|
|
PuzzleManager.Instance?.MarkPuzzleStepCompleted(stepData);
|
2025-10-16 19:43:19 +02:00
|
|
|
|
|
|
|
|
|
|
if (puzzleIndicator != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Destroy(puzzleIndicator);
|
|
|
|
|
|
_indicator = null;
|
|
|
|
|
|
}
|
2025-09-11 13:00:26 +02:00
|
|
|
|
}
|
2025-09-04 15:01:28 +02:00
|
|
|
|
}
|
2025-10-02 05:42:17 +00:00
|
|
|
|
|
2025-10-15 14:02:12 +02:00
|
|
|
|
private bool IsIndicatorValid()
|
|
|
|
|
|
{
|
|
|
|
|
|
return _indicator != null && puzzleIndicator != null && !_isCompleted;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-02 05:42:17 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Visualizes the puzzle prompt ranges in the editor.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void OnDrawGizmos()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!drawPromptRangeGizmo) return;
|
|
|
|
|
|
|
|
|
|
|
|
// Use the global puzzle prompt range from settings
|
|
|
|
|
|
float promptRange = AppleHills.SettingsAccess.GetPuzzlePromptRange();
|
|
|
|
|
|
|
|
|
|
|
|
// Draw threshold circle
|
|
|
|
|
|
Gizmos.color = Color.cyan;
|
2025-10-16 19:43:19 +02:00
|
|
|
|
Gizmos.DrawWireSphere(transform.position, promptRange);
|
2025-10-02 05:42:17 +00:00
|
|
|
|
}
|
2025-09-03 15:43:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|