예제 #1
0
파일: actor.cpp 프로젝트: Duion/GuideBot
void Actor::releaseActionEffectors(Action* action,const EffectorIDVector& effectorIDs)
{
	for (size_t i=0;i<effectorIDs.size();i++)
	{
		Effector* effector = getEffector(effectorIDs[i]);
		GB_ASSERT(effector, format("Actor::getEffector: actor doesn't have effector %s", Effector::convertToString(effectorIDs[i])));
		Actions children;
		effector->getDirectChildren(action, children);
		GB_ASSERT(children.empty(), "Actor::releaseActionEffectors: action isn't allowed to have children on effector at this moment");

		Actions becameActive;
		effector->removeAction(action,becameActive);
		for(size_t j=0; j<becameActive.size(); j++)
		{
			m_activatedEffectors[becameActive[j]].push_back(effectorIDs[i]);
		}
	}
}
예제 #2
0
파일: actor.cpp 프로젝트: Duion/GuideBot
void Actor::releaseAction(Action* action)
{
	//GB_INFO("ReleaseAction begin: %s (%p)",action->getDescString().c_str(), action);
	static std::string tabs;
	//GB_INFO("%sReleaseAction: %s (%p)",tabs.c_str(), action->getDescString().c_str(), action);
	tabs.append("    ");

	GB_ASSERT(m_actionsToDelete.find(action) == m_actionsToDelete.end(),
						"Action has already been deleted. Action logic is corrupted!");
	m_actionsToDelete.insert(action);

	//terminate childs
	Actions childs;
	action->getChilds(childs);
	for (Actions::iterator it=childs.begin(), end=childs.end();
			it!=end; it++)
	{
		Action* child = *it;
		child->terminate(Action::CANCELED);
	}
	
	//remove from effectors
	const EffectorIDVector& effectorIDs = action->getRequiredEffectors();
	for (size_t i=0;i<effectorIDs.size();i++)
	{
		Effector* effector = getEffector(effectorIDs[i]);
		GB_ASSERT(effector, format("Actor::getEffector: actor doesn't have effector %s", Effector::convertToString(effectorIDs[i])));

		Actions becameActive;
		effector->removeAction(action,becameActive);
		for(size_t j=0; j<becameActive.size(); j++)
		{
			m_activatedEffectors[becameActive[j]].push_back(effectorIDs[i]);
		}		
	}
	tabs.erase(tabs.size()-4,4);
	//GB_INFO("ReleaseAction end: %s",action->getDescString().c_str());
}