Subsystems
If you’re looking for the subsystems that SML provides by default, check out the Registry page. |
Subsystems are actors that exist only once in the world (similar to Singletons, but not quite) as an instance general manager. These subsystems are accessible from anywhere you have a world context available (f.e. actors). Subsystems allow you to implement custom game state information, for example, that you want to have saved to the save file, or when you want to manage multiple actors or some system from one central point.
For example, the mod Light It Up uses subsystems to create a lamp group system. With this system, every lamp can get information about the current group settings without storing that data again in each lamp instance.
Registering a Subsystem
If you want to have a subsystem you will need at least one class that inherits the ModSubsystem
class.
To register a subsystem, you should add it to the Mod Subsystems
array of the
Game World Module.
The subsystems are held by the SubsystemActorManager
, that can be obtained using the GetSubsystemActorManager
function.
Referencing a Subsystem
A subsystem itself is an actor inheriting from ModSubsystem
.
You can also use subsystems to store data to save states.
You should use the GetSubsystemActor
function to reference your desired subsystem.
-
The first parameter of the function is a reference to your
SubsystemActorManager
acquired using theGetSubsystemActorManager
function. -
The second parameter is just a name for the actor in this example
ExampleSubsystem
.