#pragma once
#include <memory>
#include "sre/Camera.hpp"
#include "Behaviour.hpp"
#include "Transform.hpp"
// A camera used to render the scene.
class CameraComponent final : public Behaviour {
public:
	CameraComponent(GameObject*);
	// Provides selective 'friend' access for LevelBuilder
	// (Attorney-Client idiom)
	class Mutator final {
	private:
		// Note: you'll need to extract the camera from this as a ref. to set
		// up a useful render loop, after the scene is built it becomes useless
		inline static sre::Camera& GetCamera(std::shared_ptr<CameraComponent> target) {
			return target->camera;
		}
		inline static void SetHalfHeight(std::shared_ptr<CameraComponent> target, float halfHeight) {
			target->camera.setOrthographicProjection(halfHeight, -1, 1);
		}
		inline static void SetPlayerTransform(std::shared_ptr<CameraComponent> target,std::shared_ptr<GameObject> playerObject)
		{
			
			target->player = playerObject;
		}
		friend class LevelBuilder;
	};
protected:
	
	void Update(float) override;
	virtual void InitialiseSelf() override;
	virtual void Initialise() override;


private:
	float pos = 1.0f;
	glm::vec2 offset;
	sre::Camera camera;
	std::shared_ptr<GameObject> player;
	

	
	friend class Mutator;
};