custom exceptions, methods to create modules and states of specific type from generic ones
This commit is contained in:
@@ -41,14 +41,7 @@ namespace EscapeRoomEngine.Engine.Runtime.Modules
|
||||
|
||||
public override void SetModule(Module module)
|
||||
{
|
||||
if (module is DoorModule doorModule)
|
||||
{
|
||||
Module = doorModule;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Tried to set wrong type of module ({module.GetType()} instead of DoorModule)");
|
||||
}
|
||||
Module = DoorModule.FromModule(module);
|
||||
}
|
||||
|
||||
[Button(enabledMode: EButtonEnableMode.Playmode)]
|
||||
@@ -62,5 +55,15 @@ namespace EscapeRoomEngine.Engine.Runtime.Modules
|
||||
{
|
||||
Unlocked = false;
|
||||
}
|
||||
|
||||
public static DoorState FromState(ModuleState state)
|
||||
{
|
||||
if (state is DoorState doorState)
|
||||
{
|
||||
return doorState;
|
||||
}
|
||||
|
||||
throw new WrongTypeException(typeof(DoorState), state.GetType(), typeof(ModuleState));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user