Handles everything to setup Matter. Includes a versatile plugins system to enable any mix of these functions:
- Hot-reloading
- Networking (using @rbxts/yetanothernet)
- Component replication
- Matter debugger
- ...and more! You can create your own plugins as seen in the example game
See the example game for more details
// server/bootstrap.server.ts
import { ServerScriptService } from "@rbxts/services"
import { Game } from "@rbxts/matter-bootstrap"
import PlayerEntities from "shared/plugins/PlayerEntities"
// A simple game with one system and one plugin
const helloWorldGame: HelloWorldGame = new Game({
// The greetPlayers system will say hi for us
systemsFolder: ServerScriptService.TS.systems,
plugins: {
// And the PlayerEntities plugin will create Player components to say hi to
playerEntities: PlayerEntities
},
})
helloWorldGame.begin()
// server/systems/greetPlayers.ts
import components from "shared/components"
// Greets new players
export = function({ world }: HelloWorldGame) {
for(const [,playerRecord] of world.queryChanged(components.Player)) {
if(playerRecord.new && !playerRecord.old) {
// Player has just spawned, greet them!
const player = playerRecord.new.instance
print(`Hello, ${player.DisplayName} (@${player.Name})`)
}
}
}