#include "Behaviour.hpp"
#include "GameObject.hpp"

Behaviour::Behaviour(GameObject* gameObject) : Component(gameObject) {
	// Add enable/disable handlers.
	gameObject->OnEnable += Delegate<void()>::Create<Behaviour, &Behaviour::Enable>(this);
	gameObject->OnDisable += Delegate<void()>::Create<Behaviour, &Behaviour::Disable>(this);
}

void Behaviour::Enable() {
	gameObject.OnInitialiseSelf += Delegate<void()>::Create<Behaviour, &Behaviour::InitialiseSelf>(this);
	gameObject.OnInitialise += Delegate<void()>::Create<Behaviour, &Behaviour::Initialise>(this);
	*updateEvent += Delegate<void(float)>::Create<Behaviour, &Behaviour::Update>(this);
	active = true;
}

void Behaviour::Disable() {
	gameObject.OnInitialiseSelf -= Delegate<void()>::Create<Behaviour, &Behaviour::InitialiseSelf>(this);
	gameObject.OnInitialise -= Delegate<void()>::Create<Behaviour, &Behaviour::Initialise>(this);
	*updateEvent -= Delegate<void(float)>::Create<Behaviour, &Behaviour::Update>(this);
	active = false;
}
