using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AddressableAssets;
namespace PuzzleS
{
///
/// Represents a complete chain of puzzle steps that form a logical sequence.
/// This is automatically generated from folder structure during asset import.
///
[CreateAssetMenu(fileName = "PuzzleChain", menuName = "AppleHills/Items & Puzzles/PuzzleChain")]
public class PuzzleChainSO : ScriptableObject
{
///
/// Unique identifier for this puzzle chain, automatically set to match folder name
///
public string chainId;
///
/// Display name for this chain
///
public string displayName;
///
/// Description of this puzzle chain
///
[TextArea]
public string description;
///
/// All steps that belong to this puzzle chain
///
public List allSteps = new List();
///
/// Initial steps that should be unlocked when the puzzle chain starts
/// (steps with no dependencies)
///
public List initialSteps = new List();
///
/// Optional requirement for this entire chain to be activated
/// If not null, this chain requires the specified chain to be completed first
///
public PuzzleChainSO requiredChain;
///
/// Pre-processed dependency data built at edit time.
/// Maps step IDs to arrays of dependency step IDs
///
[HideInInspector]
public Dictionary stepDependencies = new Dictionary();
///
/// Gets all steps that will be unlocked by completing the given step
///
public List GetUnlockedSteps(string stepId)
{
var result = new List();
foreach (var step in allSteps)
{
if (step.stepId == stepId && step != null)
{
return step.unlocks;
}
}
return result;
}
///
/// Gets all steps that will be unlocked by completing the given step
///
public List GetUnlockedSteps(PuzzleStepSO completedStep)
{
return completedStep != null ? completedStep.unlocks : new List();
}
///
/// Check if this step is an initial step (no dependencies)
///
public bool IsInitialStep(PuzzleStepSO step)
{
return step != null && initialSteps.Contains(step);
}
///
/// Check if all steps in this chain are completed
///
public bool IsChainComplete(HashSet completedSteps)
{
if (completedSteps == null) return false;
foreach (var step in allSteps)
{
if (step != null && !completedSteps.Contains(step))
{
return false;
}
}
return true;
}
}
}