#ifndef GAME_EDITOR_REFERENCES_H
#define GAME_EDITOR_REFERENCES_H

#include <memory>
#include <vector>

class CEnvelope;
class CLayerQuads;
class CLayerSounds;
class CLayerTiles;

class IEditorEnvelopeReference
{
public:
	virtual void SetEnvelope(const std::shared_ptr<CEnvelope> &pEnvelope, int EnvelopeIndex) = 0;
	virtual ~IEditorEnvelopeReference() = default;
};

class CLayerTilesEnvelopeReference : public IEditorEnvelopeReference
{
public:
	CLayerTilesEnvelopeReference(std::shared_ptr<CLayerTiles> pLayerTiles) :
		m_pLayerTiles(std::move(pLayerTiles)) {}
	void SetEnvelope(const std::shared_ptr<CEnvelope> &pEnvelope, int EnvelopeIndex) override;

private:
	std::shared_ptr<CLayerTiles> m_pLayerTiles;
};

class CLayerQuadsEnvelopeReference : public IEditorEnvelopeReference
{
public:
	CLayerQuadsEnvelopeReference(std::shared_ptr<CLayerQuads> pLayerQuads) :
		m_pLayerQuads(std::move(pLayerQuads)) {}
	void SetEnvelope(const std::shared_ptr<CEnvelope> &pEnvelope, int EnvelopeIndex) override;
	void AddQuadIndex(int QuadIndex) { m_vQuadIndices.push_back(QuadIndex); }
	bool Empty() const { return m_vQuadIndices.empty(); }

private:
	std::vector<int> m_vQuadIndices;
	std::shared_ptr<CLayerQuads> m_pLayerQuads;
};

class CLayerSoundEnvelopeReference : public IEditorEnvelopeReference
{
public:
	CLayerSoundEnvelopeReference(std::shared_ptr<CLayerSounds> pLayerSounds) :
		m_pLayerSounds(std::move(pLayerSounds)) {}
	void SetEnvelope(const std::shared_ptr<CEnvelope> &pEnvelope, int EnvelopeIndex) override;
	void AddSoundSourceIndex(int SoundSourceIndex) { m_vSoundSourceIndices.push_back(SoundSourceIndex); }
	bool Empty() const { return m_vSoundSourceIndices.empty(); }

private:
	std::vector<int> m_vSoundSourceIndices;
	std::shared_ptr<CLayerSounds> m_pLayerSounds;
};

#endif
