runCommand method
void
runCommand({
- required WorldCommand command,
- Map<
String, String> replacements = const {}, - ZoneLevel? zoneLevel,
- SoundChannel? soundChannel,
- AssetReference? nullSound,
- List<
CallCommand> calledCommands = const [],
Run the given command
.
All of nullSound
, soundChannel
, and replacements
will be passed to
outputCustomMessage.
Implementation
void runCommand({
required final WorldCommand command,
final Map<String, String> replacements = const {},
final ZoneLevel? zoneLevel,
final SoundChannel? soundChannel,
final AssetReference? nullSound,
final List<CallCommand> calledCommands = const [],
}) {
final sound = command.sound;
final audioBusId = sound?.audioBusId;
final soundChannel = audioBusId == null
? game.interfaceSounds
: getAudioBus(
world.getAudioBus(
audioBusId,
),
);
final gain = sound?.gain ?? world.soundOptions.defaultGain;
final asset = sound == null ? null : getCustomSound(sound);
outputCustomMessage(
command.text,
replacements: replacements,
gain: gain,
sound: asset,
soundChannel: soundChannel,
);
if (zoneLevel != null) {
final walkingMode = command.walkingMode;
if (walkingMode != null) {
handleWalkingMode(
walkingMode: walkingMode,
zoneLevel: zoneLevel,
);
}
}
final zoneTeleport = command.zoneTeleport;
if (zoneTeleport != null) {
handleZoneTeleport(zoneTeleport: zoneTeleport);
}
final customCommandName = command.customCommandName;
if (customCommandName != null) {
handleCustomCommandName(customCommandName);
}
final callCommands = command.callCommands;
handleCallCommands(
callCommands: callCommands,
calledCommands: calledCommands,
nullSound: nullSound,
replacements: replacements,
soundChannel: soundChannel,
zoneLevel: zoneLevel,
);
final startConversation = command.startConversation;
if (startConversation != null) {
handleStartConversation(startConversation);
}
final setQuestStage = command.setQuestStage;
if (setQuestStage != null) {
handleSetQuestStage(setQuestStage);
}
final returnToMainMenu = command.returnToMainMenu;
if (returnToMainMenu != null) {
handleReturnToMainMenu(returnToMainMenu);
}
final showScene = command.showScene;
if (showScene != null) {
handleShowScene(showScene);
}
final playRumble = command.playRumble;
if (playRumble != null) {
handlePlayRumble(playRumble);
}
final url = command.url;
if (url != null) {
handleUrl(url);
}
final customMenuId = command.customMenuId;
if (customMenuId != null) {
handleCustomMenu(world.getMenu(customMenuId));
}
}