onTap method

  1. @override
ActionResult onTap(
  1. EscapeGame escapeGame
)
override

Should be called when the user taps on this interactable.

Implementation

@override
ActionResult onTap(EscapeGame escapeGame) {
  if (keyId != null && !escapeGame.inventory.hasObjectId(keyId!)) {
    ActionResult unlockResult = onCantUnlock == null ? const ActionResult.failed() : onCantUnlock!(escapeGame);
    if (unlockResult.state != ActionResultState.success) {
      return unlockResult;
    }
  }

  ActionResult padlockResult = super.onTap(escapeGame);
  if (padlockResult.state != ActionResultState.success) {
    return padlockResult;
  }
  ActionResult foundResult = onFound == null ? const ActionResult.success() : onFound!(escapeGame);
  if (foundResult.state != ActionResultState.success) {
    return foundResult;
  }
  if (removeAfterFound) {
    escapeGame.currentRoom.removeInteractable(this, notify: false);
    if (removedTooltip != null) {
      escapeGame.currentRoom.addInteractable(Interactable(
        id: '$id-found',
        renderSettings: renderSettings,
        onHover: (escapeGame) => ActionResult.success(object: removedTooltip!),
      ));
    }
  }

  return const ActionResult.success();
}