#include "MW4Headers.hpp"

#include "AI_SearchLight.hpp"

#include <Adept\Mission.hpp>
#include "CombatAI.hpp"



using namespace MW4AI;

SearchLightController::SearchLightController(CombatAI& combat_ai)
	: m_CombatAI(combat_ai)
	, m_State(UNSPECIFIED)
{
}

void SearchLightController::Update()
{
	bool on = false;

	if (m_State == ON)
	{
		on = true;
	}
	else
	{
		if (m_State == UNSPECIFIED)
		{
			Adept::Mission* mission = Adept::Mission::GetInstance();

			if (mission != 0)
			{
				on = mission->m_isNightMission;
			}
		}
	}

	if (on == m_CombatAI.GetSelf().IsSearchLightOn())
	{
		return;
	}

	if (on == true)
	{
		m_CombatAI.GetSelf().TurnOnSearchLight();
	}
	else
	{
		m_CombatAI.GetSelf().TurnOffSearchLight();
	}
}

void SearchLightController::SetState(State state)
{
	Verify(state >= STATE_FIRST);
	Verify(state <= STATE_LAST);

	m_State = state;
}
