#ifndef SPLASHES_H
#define SPLASHES_H

#include "game_data.h"

class Splashes : public QObject
{
    Q_OBJECT
public:
    explicit Splashes(Game_Data * gd, QObject *parent = 0);
    void delSplash(int Id);
    void update();
    void setScene(QGraphicsScene * scene_) {scene = scene_;}

signals:
    void killAlien(int playerId, int alienId);

public slots:
    void addSplash(int player, srcSplashType * src, QPointF pos, QPointF dest, int aim = -1);
    void addSplash(const TowerType  &tower);
    void addSplash(srcTowerType * srctower, int id, QPointF pos, QPointF dest, int aim = -1, QPoint towerId = QPoint(-1,-1));
    void addSplash(SplashType *spl);

private:

    QGraphicsScene * scene;
    Game_Data *gameData;
    int nextId;
    struct DeadAlienIndex
    {
        DeadAlienIndex(int i, int p, QPoint t) {id = i; player = p; tower = t;}
        int player;
        int id;
        QPoint tower;
    };
    QHash <int, DeadAlienIndex> dead;

    void doTriggerOnDest(QHash<int, SplashType>::iterator
                         spl, QHash<int,int> * deadIndexes,
                         bool badAl);
    void doTriggerOnTimer(QHash<int, SplashType>::iterator
                          spl, QHash<int,int> * deadIndexes);
    void doTriggerOnAlien(QHash<int, SplashType>::iterator
                          spl, QHash<int,int> * deadIndexes);
};

#endif // SPLASHES_H
