Systems
Systems are the home of your plugin's logic and are designed to be as flexible as possible. Systems provide optional lifecycle events and a robust API to allow you to quickly get going.
Example
Below is an example system. Notice how we are using two of the lifecycle events here.
If you've used Flamework Singletons (opens in a new tab), then you will feel right at home. Systems are very similar to flamework's Controllers and Components.
import { System } from "@rbxts/comet"
export class MySystem extends System implements onInit, onEnd {
onInit(): void {
print ("plugin loaded!")
}
onEnd(): void {
print ("plugin unloaded!")
}
}
Lifecycle Events
Lifecycle Events are essentially extensions you can add to your systems as needed. They can be mixed in to your class using the implements
keyword.
-
onInit
- Called sequentially for each system. This means that any yielding logic may delay other systems from loading.
-
onStart
- onStart is called for each system simultaneously directly after all
onInit
methods finish.
- onStart is called for each system simultaneously directly after all
-
onRender
- onRender is called for each frame and is bound to
RenderStepped
. This method will provide delta time as its one argument.
- onRender is called for each frame and is bound to
-
onEnd
- onEnd is called when the plugin is unloaded. Useful for cleaning up any system specific connections or instances.
System API
The system api is inherited by all systems and can be accessed via the this
keyword.
UI / FX
createWidget()
Creates and returns a view that is mounted to a dock widget.
this.createWidget(name: string, size: Vector2, maxSize: Vector2): View
createOverlay()
Creates and returns a view that is mounted to the viewport.
this.createOverlay(name: string): View
playSFX()
Easily play an sound effect.
Under the hood, the initial call will load the sound which may cause a delay. Subsequent calls will be instantaneous as sounds are cached.
this.playSFX(soundId: string | number, looped?: boolean): void
Other methods will be documented soon. This section is currently under construction.