custom exceptions, methods to create modules and states of specific type from generic ones
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using EscapeRoomEngine.Engine.Runtime.Utilities;
|
||||
using NaughtyAttributes;
|
||||
using Logger = EscapeRoomEngine.Engine.Runtime.Utilities.Logger;
|
||||
@@ -58,14 +59,7 @@ namespace EscapeRoomEngine.Engine.Runtime.Modules
|
||||
|
||||
public override void SetModule(Module module)
|
||||
{
|
||||
if (module is PuzzleModule puzzleModule)
|
||||
{
|
||||
Module = puzzleModule;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Tried to set wrong type of module ({module.GetType()} instead of PuzzleModule)");
|
||||
}
|
||||
Module = PuzzleModule.FromModule(module);
|
||||
}
|
||||
|
||||
[Button(enabledMode: EButtonEnableMode.Playmode)]
|
||||
@@ -88,5 +82,15 @@ namespace EscapeRoomEngine.Engine.Runtime.Modules
|
||||
OnPuzzleEvent(PuzzleEventType.WrongInput);
|
||||
}
|
||||
}
|
||||
|
||||
public static PuzzleState FromState(ModuleState state)
|
||||
{
|
||||
if (state is PuzzleState puzzleState)
|
||||
{
|
||||
return puzzleState;
|
||||
}
|
||||
|
||||
throw new WrongTypeException(typeof(PuzzleState), state.GetType(), typeof(ModuleState));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user