/*!
  Invoked when a firing action is finished.

  Turns hit effects on, checks whether someone was hit, etc.
  */
void CcfQmlBaseScenario::firingActionFinished(int index, qreal targetX, qreal targetY) {
    QObject *unit = mUnits.at(index);

    if (unit->getInt("currentOrder") != -1) {
        // TODO: remove use of effect for smoke and attack - and optimise it away.
        QObject *effect = createEffect(mZoomArea);
        if (effect == 0)
            return;

        mEffects.append(effect);
        QString scheduledOperation;
        unit->metaObject()->invokeMethod(unit, "operation", Qt::DirectConnection, Q_RETURN_ARG(QString, scheduledOperation));

        if (scheduledOperation == "Attack") {
            effect->set("animationString", "gun_fire");
            // Check, whether a unit was hit.
            QObject *hitee = 0;
            hitee = unitAt(targetX, targetY);

            if ((hitee != 0)
                    && (hitee->property("unitIndex").isValid() == true)
                    && (hitee->property("unitType").isValid() == true)) {
                invoke(hitee, "hit", Q_ARG(QObject *, unit), Q_ARG(qreal, targetX), Q_ARG(qreal, targetY));
            }