Interface IScyllaModuleManager
Defines the full contract for the SMUT (Scylla ModUlar Topology) module manager, which orchestrates registration, dependency resolution, lifecycle management, and query operations for all IScyllaModule instances in the framework.
Namespace: Scylla.Core.Modules
Assembly: ScyllaCore.dll
Syntax
public interface IScyllaModuleManager
Remarks
The concrete implementation of this interface is owned by the
ScyllaCore singleton and is initialized by ScyllaBootstrap
during application startup. Game code and modules should obtain the manager
reference through ScyllaCore.Instance.ModuleManager or via the
InjectDependencies(IScyllaModuleManager) callback rather than holding
a direct reference to the concrete type.
The standard framework startup sequence is:
- RegistrationEach
ScyllaModuleMonoBehaviourcalls RegisterModule(IScyllaModule) from itsAwake()method, putting the module into the Discovered state. - ValidationValidateAllDependencies() checks every registered module's hard dependencies and advances valid modules to Validated. A single failure aborts startup.
- InitializationInitializeAllModules() injects dependencies and calls Initialize() in topological + priority order.
- StartStartAllModules() calls StartModule() followed by EnableModule() on every initialized module.
- ShutdownShutdownAllModules() calls Shutdown() in strict reverse initialization order.
If any step fails the framework rolls back all previously initialized modules, ensuring the application is never left in a partially-initialized state (fail-fast philosophy).
Properties
ModuleCount
Gets the number of modules currently registered with the manager.
Declaration
int ModuleCount { get; }
Property Value
| Type | Description |
|---|---|
| int | The total count of registered modules regardless of state, equivalent to
|
Modules
Gets a read-only view of all modules that are currently registered with the manager, regardless of their lifecycle state.
Declaration
IReadOnlyList<IScyllaModule> Modules { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<IScyllaModule> | A snapshot-safe, read-only list of every IScyllaModule registered since startup. The list order reflects registration order, not initialization priority. It includes modules in all states, including Error and Shutdown; call CleanupZombieModules(bool) to remove shutdown entries. |
Methods
CleanupZombieModules(bool)
Removes modules in the Shutdown state from the registry to prevent memory leaks from references to destroyed module objects.
Declaration
int CleanupZombieModules(bool suppressWarning = false)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | suppressWarning | When |
Returns
| Type | Description |
|---|---|
| int | The number of zombie modules that were removed from the registry. Returns
|
Remarks
A "zombie module" is a module that has been shut down (state == Shutdown) but whose entry remains in the Modules list. This can prevent the GC from collecting the module object if the manager holds the last strong reference to it.
This method is typically called by ScyllaBootstrap after
ShutdownAllModules() completes as part of the final framework
teardown sequence.
See Also
GetModule(string)
Retrieves a registered module by its unique string identifier.
Declaration
IScyllaModule GetModule(string moduleID)
Parameters
| Type | Name | Description |
|---|---|---|
| string | moduleID | The unique ID of the module to locate. Use the constants defined in ScyllaModuleID for built-in modules to avoid hard-coded strings. |
Returns
| Type | Description |
|---|---|
| IScyllaModule | The IScyllaModule with the matching ID, or |
See Also
GetModule<T>(string)
Retrieves a registered module by its unique string identifier and casts it to
the specified concrete or interface type T.
Declaration
T GetModule<T>(string moduleID) where T : class, IScyllaModule
Parameters
| Type | Name | Description |
|---|---|---|
| string | moduleID | The unique ID of the module to locate. Use the constants defined in ScyllaModuleID for built-in modules to avoid hard-coded strings. |
Returns
| Type | Description |
|---|---|
| T | The module cast to |
Type Parameters
| Name | Description |
|---|---|
| T | The type to cast the located module to. Must be a reference type that
implements IScyllaModule. Typically this is the concrete module
class (e.g., |
Remarks
This overload is the preferred way for one module to acquire a reference to another during InjectDependencies(IScyllaModuleManager). Caching the result avoids repeated dictionary lookups during gameplay.
Typical usage inside InjectDependencies:
public void InjectDependencies(IScyllaModuleManager moduleManager)
{
_inputModule = moduleManager.GetModule<ScyllaInputModule>(ScyllaModuleID.INPUT);
}
See Also
GetModulesInState(ScyllaModuleState)
Returns all registered modules that are currently in the specified lifecycle state.
Declaration
List<IScyllaModule> GetModulesInState(ScyllaModuleState state)
Parameters
| Type | Name | Description |
|---|---|---|
| ScyllaModuleState | state | The ScyllaModuleState value to filter by. For example, passing Error returns every module that failed validation or initialization. |
Returns
| Type | Description |
|---|---|
| List<IScyllaModule> | A new List<T> containing references to all modules in the requested state. Returns an empty list if no modules match. The returned list is a snapshot and will not reflect subsequent state changes. |
See Also
HasModule(string)
Determines whether a module with the given ID is currently registered with the manager.
Declaration
bool HasModule(string moduleID)
Parameters
| Type | Name | Description |
|---|---|---|
| string | moduleID | The unique ID to check. Use the constants defined in ScyllaModuleID for built-in modules. |
Returns
| Type | Description |
|---|---|
| bool |
|
See Also
InitializeAllModules()
Injects dependencies into and then initializes all validated modules in the order determined by topological sort of the dependency graph combined with each module's InitPriority. Modules with lower priority values initialize before those with higher values.
Declaration
void InitializeAllModules()
Remarks
For each module the framework calls:
- InjectDependencies(IScyllaModuleManager) - supplies the module manager reference.
- Initialize() - allocates module resources.
If any module's Initialize() throws or leaves the module in Error, the framework immediately halts and rolls back all previously initialized modules in reverse order by calling their Shutdown() methods.
Must be called after ValidateAllDependencies() returns
true. Calling this method when modules are not in the
Validated state results in undefined behavior.
See Also
RegisterModule(IScyllaModule)
Registers a module with the framework so that it participates in the SMUT lifecycle. Transitions the module to Discovered upon successful registration.
Declaration
void RegisterModule(IScyllaModule module)
Parameters
| Type | Name | Description |
|---|---|---|
| IScyllaModule | module | The module instance to register. Must not be |
Remarks
In a standard setup, ScyllaModule.Awake() calls this method
automatically (via base.Awake()), so game code does not typically
need to call it directly. Manual registration is only needed when hosting
non-MonoBehaviour modules.
See Also
ShutdownAllModules()
Shuts down all active modules in strict reverse initialization order so that no module is destroyed before the modules that depend on it have finished their own shutdown. Transitions each module to Shutdown.
Declaration
void ShutdownAllModules()
Remarks
For each module, in reverse initialization order, the framework:
- Calls DisableModule() if the module is currently enabled.
- Calls Shutdown() to release all resources.
This method is called by ScyllaBootstrap.OnDestroy() and also
during fail-fast rollback if initialization fails midway. After all modules
have been shut down, CleanupZombieModules(bool) may be called to
remove their entries from the registry.
See Also
StartAllModules()
Starts all modules that have successfully completed initialization, transitioning them from Initialized to Enabled via the intermediate Started state.
Declaration
void StartAllModules()
Remarks
For each module the framework calls, in order:
- StartModule() - begins runtime behavior (e.g., event subscriptions, coroutines).
- EnableModule() - makes the module fully operational.
This method is called by ScyllaBootstrap after
InitializeAllModules() completes. Modules skipped during
initialization (e.g., those in Error) are
also skipped here.
See Also
UnregisterModule(string)
Removes a previously registered module from the framework by its unique ID. The removed module will no longer participate in lifecycle events.
Declaration
bool UnregisterModule(string moduleID)
Parameters
| Type | Name | Description |
|---|---|---|
| string | moduleID | The unique string identifier of the module to remove. Use the constants in
ScyllaModuleID for built-in modules. Passing |
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
Unregistering a module that is in the Enabled or Initialized state without first calling Shutdown() may leave dependent modules in an inconsistent state. Prefer ShutdownAllModules() for orderly teardown rather than individual unregistration.
See Also
ValidateAllDependencies()
Validates the dependency declarations of all registered modules, checking that every hard dependency exists in the registry and that its version satisfies the declared minimum. Advances valid modules to Validated.
Declaration
bool ValidateAllDependencies()
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
Soft (Soft) and event-based
(EventBased) dependencies are
noted in the validation log but do not cause this method to return
false.
Version compatibility is checked via IsVersionCompatible(string, string). Unparseable version strings are treated leniently and do not cause a validation failure.