using EscapeRoomEngine.Engine.Runtime.Modules.Description;
using EscapeRoomEngine.Engine.Runtime.Modules.State;
using EscapeRoomEngine.Engine.Runtime.Utilities;
using UnityEngine;
namespace EscapeRoomEngine.Engine.Runtime.Modules
{
///
/// The main component of any puzzle module.
///
public class PuzzleModule : Module
{
///
/// The module state of this puzzle as a .
///
internal PuzzleState PuzzleState => PuzzleState.FromState(State);
internal PuzzleModule(Space space, PuzzleModuleDescription description) : base(space, description) {}
internal override void InstantiateModule(Transform parent)
{
base.InstantiateModule(parent);
// the room needs to know about this puzzle
space.room.AddPuzzle(this);
}
public static PuzzleModule FromModule(Module module)
{
if (module is PuzzleModule puzzleModule)
{
return puzzleModule;
}
throw new WrongTypeException(typeof(PuzzleModule), module.GetType(), typeof(Module));
}
}
}