VitalMinigameInstanceService
The global minigame instance manager to use when creating multiple minigames on the same game server. Each minigame will run in its own capsulated instance, which can have n-amount of states. A state may also have n-amount of event handlers mapped to it. Each event handler will only be active when the state is also active.
E.g. "StartingState" -> JoinEvent -> Event handler will only be active when the starting state is active. Once you switch to a different state, like "IngameState", the event handlers from "StartingState" will no longer fire.
Functions
Loads a new instance world by the given templateWorldName. This function will copy all world files from the templateWorldName to a new world that can be used for a new VitalMinigameInstance, e.g. "VitalMinigameInstance.id_templateWorldName", and will then immediately return. An action function can be provided to perform an action on the newly loaded world.
Registers a new game instance on this service. An instance may perform custom logic during registration via VitalMinigameInstance.onRegister. Additionally, an afterRegisterAction function can be provided to perform an action right after instance registration, but before VitalMinigameInstance.onRegister is called.
Unregisters all existing game instances by calling unregisterInstance for every one.
Unregisters an existing game instance. An instance may perform custom logic during unregistration via VitalMinigameInstance.onUnregister. Additionally, an beforeDeleteAction function can be provided to perform an action right after instance unregistration, but before VitalMinigameInstance.onUnregister is called and before the world is deleted. An afterDeleteAction function can also be provided to perform an action right after the world unloaded and deleted from the file system.
Unregisters an existing game instance by its id, fails if no instance with the given id exists. Once unregistered, the instance's world will be unloaded and then deleted. Additionally, an beforeDeleteAction function can be provided to perform an action right after instance unregistration, but before VitalMinigameInstance.onUnregister is called and before the world is deleted. An afterDeleteAction function can also be provided to perform an action right after the world unloaded and deleted from the file system.