36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
using EscapeRoomEngine.Engine.Runtime.Utilities;
|
|
using UnityEngine;
|
|
|
|
namespace EscapeRoomEngine.Engine.Runtime.Modules
|
|
{
|
|
/// <summary>
|
|
/// The main component of any puzzle module.
|
|
/// </summary>
|
|
public class PuzzleModule : Module
|
|
{
|
|
/// <summary>
|
|
/// The module state of this puzzle as a <see cref="PuzzleState"/>.
|
|
/// </summary>
|
|
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));
|
|
}
|
|
}
|
|
} |