custom exceptions, methods to create modules and states of specific type from generic ones
This commit is contained in:
@@ -1,23 +1,12 @@
|
||||
using System;
|
||||
using EscapeRoomEngine.Engine.Runtime.Utilities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace EscapeRoomEngine.Engine.Runtime.Modules
|
||||
{
|
||||
public class PuzzleModule : Module
|
||||
{
|
||||
internal PuzzleState PuzzleState
|
||||
{
|
||||
get
|
||||
{
|
||||
if (State is PuzzleState puzzleState)
|
||||
{
|
||||
return puzzleState;
|
||||
}
|
||||
internal PuzzleState PuzzleState => PuzzleState.FromState(State);
|
||||
|
||||
throw new Exception("PuzzleModule must contain a PuzzleState");
|
||||
}
|
||||
}
|
||||
|
||||
internal PuzzleModule(Space space, PuzzleModuleDescription description) : base(space, description)
|
||||
{
|
||||
srDimensions.Size = Vector2Int.one; // TODO: larger modules
|
||||
@@ -29,5 +18,15 @@ namespace EscapeRoomEngine.Engine.Runtime.Modules
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user