
#ifndef TDETECTOR_H_INCLUDED
#define TDETECTOR_H_INCLUDED

/*
OBJET       zone sensible = action

DATE        12/2022

AUTEUR      philippe Thebaud

COMMENTAIRE
*/

#include <GL/glew.h>
#include <string>
#include <fstream>
//#include <vector>
//#include <deque>

#include "../ECO/OUtils.h"
#include "../ECO/OSound.h"

#include "common.h"


// etat = (detecteur inexistant) / attente / déclenchée / ?
enum {DET_ALWAY_OFF, DET_OFF, DET_ON, DET_ALWAYS_ON};

const std::string gl_str_detect_state[] = {
    "always_off", "off", "on", "always_on"
};


class Tdetector
{
public:
	Tdetector();
	~Tdetector();

	void        create(std::string& flux);
    void        create(std::ifstream& flux);

    std::string getAction();
    std::string getCode();
    bool        getIn(OVec3_f& posSrc);
    OVec3_f&    getPos();
    int         getState();

    void        pause(bool mode);

	void        save(std::ofstream& flux);
	void        setPos(OVec3_f& pos);
    void        setSound(std::string file, int loop = 0, bool play = false);
    void        setState(int value);

    static void P_setPath(std::string path);

private:

    void        _composition();

private:

    std::string m_code;
    OVec3_f     m_pos;
    float       m_radius;

	int         m_state;
	std::string m_action, m_soundFile;
	int         m_loop;

    OSound      m_sound;
};

#endif
