handleCallCommand method
void
handleCallCommand({
- required CallCommand callCommand,
- List<
CallCommand> calledCommands = const [], - Map<
String, String> replacements = const {}, - AssetReference? nullSound,
- SoundChannel? soundChannel,
- ZoneLevel? zoneLevel,
Call the specified callCommand
.
Implementation
void handleCallCommand({
required final CallCommand callCommand,
final List<CallCommand> calledCommands = const [],
final Map<String, String> replacements = const {},
final AssetReference? nullSound,
final SoundChannel? soundChannel,
final ZoneLevel? zoneLevel,
}) {
if (calledCommands.contains(callCommand)) {
final category = world.commandCategories.firstWhere(
(final element) => element.commands
.where(
(final element) => element.id == callCommand.commandId,
)
.isNotEmpty,
);
final commandName = category.commands.firstWhere(
(final element) => element.id == callCommand.commandId,
);
throw UnsupportedError(
'The $commandName command from the ${category.name} is attempting '
'to call itself.',
);
}
if (handleConditionals(callCommand.conditions) == false) {
return;
}
final command = world.getCommand(callCommand.commandId);
final callAfter = callCommand.callAfter;
if (callAfter == null) {
runCommand(
command: command,
replacements: replacements,
calledCommands: [...calledCommands, callCommand],
nullSound: nullSound,
soundChannel: soundChannel,
zoneLevel: zoneLevel,
);
} else {
game.callAfter(
runAfter: callAfter,
func: () => runCommand(
command: command,
replacements: replacements,
nullSound: nullSound,
soundChannel: soundChannel,
zoneLevel: zoneLevel,
),
);
}
}