#pragma once

//i don't know if its really worth the time, but I think a qued message dispatcher will make the gameflow
//a lot easier to do..

#include "main.h"
#include <list>

enum
{
  C_MESSAGE_SOUND,
  C_MESSAGE_TEXT,
  C_MESSAGE_ADD_ROCK,
  C_MESSAGE_ADD_PERSON,
  C_MESSAGE_GOT_RESCUED,
  C_MESSAGE_KILL_ENTITY,
  C_MESSAGE_START_NIGHT,
  C_MESSAGE_START_DAY,
  C_MESSAGE_INIT_NEW_GAME,
  C_MESSAGE_GAME_OVER
};

class Entity;

class Message
{
public:

    Message()
    {
        bDeleteMe = false;
        pDeliveryTarget = NULL;
        m_deliveryTime = 0;
        parm1 = 0;
    }



    unsigned int m_deliveryTime;
    int msg;
    Entity *pDeliveryTarget; //null if none
    CL_Vector2 m_pos;
    bool bDeleteMe;
    int parm1;
    std::string text;

};

class MessageDispatcher
{
public:

    void SendMsg(int message, int deliveryTimeMS, Entity *pEnt = NULL, int parm1 = 0);
    void SendMsgEx(Message &msg, int deliveryTimeMS);
    void DeliverMsg(Message &msg);
    void Update();
    void ClearAllMessages();
    void SendText(std::string text, int deliveryTime);
    void KillAllMessagesToThisEnt(Entity *pEnt); //avoid crashes..
    void KillMessageType(int msg); 

private:

    std::list<Message> m_message;

};