WorldContext class

A class for running World instances.

Constructors

WorldContext({required Sdl sdl, required Game game, required World world, CustomCommandsMap customCommands = const {}, ConditionalFunctionsMap conditionalFunctions = const {}, ErrorHandler? errorHandler})
Create an instance.
WorldContext.loadEncrypted({required String encryptionKey, String filename = encryptedWorldFilename, Game? game, CustomCommandsMap customCommands = const {}, ErrorHandler? errorHandler})
Return an instance with its world loaded from an encrypted file.
factory

Properties

conditionalFunctions ConditionalFunctionsMap
The map of custom conditional functions.
final
customCommands CustomCommandsMap
The map of custom commands.
final
errorHandler ErrorHandler?
A function that will handle errors from WorldCommand instances.
final
game → Game
The game to use.
final
hapticDevices List<Haptic>
The list of initialised haptic devices.
final
hashCode int
The hash code for this object.
no setterinherited
playerPreferences PlayerPreferences
Get the current player preferences.
no setter
playerPreferencesFile File
The file where playerPreferences should be saved.
no setter
playerStats Statistics
The current player statistics.
no setter
preferencesDirectory String
The directory where preferences should be stored.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sdl → Sdl
The SDL instance to use.
final
triggerMapFile File
The file where the trigger map should be stored.
no setter
world World
The world to use.
final

Methods

changeSoundChannelGain({required SoundChannel soundChannel, required double value}) → void
Increase the gain on the given soundChannel by value.
getAssetStore(CustomSoundAssetStore customSoundAssetStore) → AssetStore
Get the asset store for the given customSoundAssetStore.
getAudioBus(AudioBus audioBus) → SoundChannel
Get a sound channel that represents the given audioBus.
getButton(TaskFunction func) → Button
Get a button with the proper activate sound.
getControlsMenu() ControlsMenu
Returns a menu that will show game controls.
getConversationLevel({required Conversation conversation, required int pushInitialBranchAfter, int? fadeTime}) ConversationLevel
Get a suitable level for the given conversation.
getCreditsMenu() CreditsMenu
Returns a menu that will show credits.
getCustomMenuLevel(CustomMenu menu) CustomMenuLevel
Get a custom menu level.
getCustomMessage({String? message, Map<String, String> replacements = const {}, AssetReference? sound, double? gain, bool keepAlive = false}) → Message
Get a message with the given parameters.
getCustomSound(CustomSound sound) → AssetReference
Get the sound from the given sound.
getDirectionName(int bearing) String
Get the name of the nearest direction to bearing.
getGainParameter({required String title, required SoundChannel soundChannel}) → ParameterMenuParameter
Get a valid parameter for the given soundChannel and title.
getMainMenu() MainMenu
Get the main menu for the given WorldContext.
getMenuItemMessage({String? text, Sound? sound}) → Message
Get a message suitable for a MenuItem label.
getPauseMenu(Zone zone) PauseMenu
Returns the pause menu.
getQuestMenu() QuestMenu
Get the quests menu.
getReverb(ReverbPresetReference preset) → CreateReverb
Get the reverb with the given preset.
getSceneLevel({required Scene scene, CallCommand? callCommand}) SceneLevel
Get a level for the given scene.
getSoundMessage({required Sound sound, required AssetList assets, required String? text, bool keepAlive = false}) → Message
Get a message with the given sound.
getSoundOptionsMenu() SoundOptionsMenu
Returns a menu that will allow the configuration of sound options.
getWorldJsonString({bool compact = true}) String
Returns the given world as a JSON string.
getZoneLevel(Zone zone) ZoneLevel
Return a zone level.
handleCallCommand({required CallCommand callCommand, List<CallCommand> calledCommands = const [], Map<String, String> replacements = const {}, AssetReference? nullSound, SoundChannel? soundChannel, ZoneLevel? zoneLevel}) → void
Call the specified callCommand.
handleCallCommands({required List<CallCommand> callCommands, List<CallCommand> calledCommands = const [], Map<String, String> replacements = const {}, AssetReference? nullSound, SoundChannel? soundChannel, ZoneLevel? zoneLevel}) → void
Handle a list of callCommands.
handleConditional(Conditional conditional) bool
Handle the given conditional.
handleConditionalFunction(String name) bool
Handle a conditional function with the given name.
handleConditionals(Iterable<Conditional> conditionals) bool
Handle a list of conditionals.
handleCustomCommandName(String name) → void
Handle the custom command with the given name.
handleCustomMenu(CustomMenu menu) → void
Handle the showing of a custom menu.
handleCustomSound(CustomSound customSound) → void
Handle the given customSound.
handlePlayRumble(PlayRumble playRumble) → void
Handle playing a rumble effect.
handleQuestCondition(QuestCondition questCondition) bool
Handle the given questCondition.
handleReturnToMainMenu(ReturnToMainMenu returnToMainMenu) → void
Return to the main menu.
handleSetQuestStage(SetQuestStage setQuestStage) → void
Handle a setQuestStage instance.
handleShowScene(ShowScene showScene) → void
Handle a show scene event.
handleStartConversation(StartConversation startConversation) → void
Handle a startConversation command.
handleStatCondition(StatCondition statCondition) bool
Handle the given statCondition for the player.
handleUrl(String url) → void
Handle opening a URL.
handleWalkingMode({required WalkingMode walkingMode, required ZoneLevel zoneLevel}) → void
Handle a walkingMode command.
handleZoneTeleport({required ZoneTeleport zoneTeleport}) → void
Handle a zoneTeleport command.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onEdgeOfZoneLevel(ZoneLevel zoneLevel, Point<double> coordinates) → void
A function that will be called when hitting the edge of a ZoneLevel.
outputCustomMessage(String? message, {Map<String, String> replacements = const {}, AssetReference? sound, double? gain, bool keepAlive = false, PlaySound? oldSound, SoundChannel? soundChannel}) → PlaySound?
Output the given message.
playMenuCancelSound() → void
Play the menu cancel sound, if it is set.
playMenuSwitchSound() → void
Play the menu switch sound.
run({EventCallback<SoundEvent>? onSound}) Future<void>
Run this world.
runCommand({required WorldCommand command, Map<String, String> replacements = const {}, ZoneLevel? zoneLevel, SoundChannel? soundChannel, AssetReference? nullSound, List<CallCommand> calledCommands = const []}) → void
Run the given command.
runWorldCommandId(String? id, {Map<String, String> replacements = const {}, AssetReference? nullSound, SoundChannel? soundChannel, ZoneLevel? zoneLevel}) → void
Run the command with the given id.
saveEncrypted({String filename = encryptedWorldFilename}) String
Save the given world with a random encryption key.
savePlayerPreferences() → void
Save the current playerPreferences;
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited