#include "ActionEndOrder.h"
#include "GroupAI.h"
#include "DebugAI.h"

#include "MemoryManager/debugNew.h"

ActionEndOrder::ActionEndOrder(Unit * u,unitEnumeration::UnitState state, std::string debugInfo) : UnitAction(u,state){
	debugOrderName = debugInfo;
	unit = u;
	hasNotified = false;
	DebugAI::trace('x', "\t UnitAction: ActionEndOrder created.\t"+debugOrderName);
}

ActionEndOrder::~ActionEndOrder(void)
{
	if (!hasNotified) {
		DebugAI::trace('x', "\t UnitAction: ActionEndOrder notify cause of deletion.\t"+debugOrderName);
		unit->getGroup()->notifyEndOrder(unit);
	}

}

void ActionEndOrder::execute()
{
	DebugAI::trace('x', "\t UnitAction: ActionEndOrder cause of executed.\t"+debugOrderName);
	hasNotified = true;
	unit->getGroup()->notifyEndOrder(unit);
	dispose();
}
