Add Engine.getSubsystem
This commit is contained in:
parent
6835823860
commit
246e83c27d
1 changed files with 13 additions and 0 deletions
|
@ -27,6 +27,7 @@ import de.staropensource.engine.base.utility.FileAccess
|
|||
import de.staropensource.engine.base.utility.dnihbd.BuildInformation
|
||||
import java.nio.charset.Charset
|
||||
import java.nio.charset.StandardCharsets
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
/**
|
||||
* Primary class of the engine.
|
||||
|
@ -102,6 +103,18 @@ class Engine private constructor() {
|
|||
*/
|
||||
fun getSubsystems(): Array<Subsystem> = subsystems.toTypedArray()
|
||||
|
||||
/**
|
||||
* Returns the loaded instance
|
||||
* of the specified [Subsystem].
|
||||
*
|
||||
* @since v1-alpha10
|
||||
*/
|
||||
fun getSubsystem(subsystemClass: KClass<out Subsystem>): Subsystem? = getSubsystems().find { subsystem -> try {
|
||||
subsystem::class.qualifiedName!! == subsystemClass.qualifiedName!!
|
||||
} catch (_: NullPointerException) {
|
||||
false
|
||||
} }
|
||||
|
||||
/**
|
||||
* Registers the specified subsystem.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue