#pragma once
#include "Event_forward.hpp"
#include "Component.hpp"

// A Component which can be enabled/disabled seperatley from its GameObject.
// Also updates every frame. Base class for 'scripts'.
class Behaviour : public Component {
public:
	//TODO: ~Behaviour : Component ();
	void Enable();
	void Disable();
	// Provides selective 'friend' access for LevelBuilder
	// (Attorney-Client idiom)
	class Mutator final {
	private:
		inline static void SetUpdateEvent(Behaviour& target, Event<void(float)>* event) {
			target.updateEvent = event;
		}
		friend class LevelBuilder;
	};
protected:
	Behaviour(GameObject*);
	// Event handlers, override to add functionality on these events.
	virtual void InitialiseSelf() = 0;
	virtual void Initialise() = 0;
	virtual void Update(float deltaTime) = 0;
private:
	bool active;
	Event<void(float)>* updateEvent;
	friend class Mutator;
};
