void CParticleEditor::startMultiple()
{
	switch(_State)
	{
	case State::Stopped:
		{
			if (!_PW) return;
			nlassert(_PlayingNodes.empty());
			TPWNodeItr itr = _PW->getNodeList().begin();
			while(itr != _PW->getNodeList().end())
			{
				CWorkspaceNode *node = (*itr);
				if (node->isLoaded())
					if (checkHasLoop(*node)) return;
				itr++;
			}
			
			itr = _PW->getNodeList().begin();
			while(itr != _PW->getNodeList().end())
			{
				CWorkspaceNode *node = (*itr);
				if (node->isLoaded())
				{
					// really start the node only if there's no trigger anim
					if (node->getTriggerAnim().empty())
						play(*node);

					_PlayingNodes.push_back(node);
				}
				itr++;
			}
		}
		break;
		case State::PausedSingle:
		case State::RunningSingle:
			stop();
			startMultiple();
		break;
		case State::RunningMultiple:
			// no-op
			return;
		break;
		case State::PausedMultiple:
			for(uint k = 0; k < _PlayingNodes.size(); ++k)
			{
				if (_PlayingNodes[k])
				{
					unpause(*_PlayingNodes[k]);
				}
			}
		break;
		default:
			nlassert(0);
		break;
	}
	_State = State::RunningMultiple;
}
//******************************************************************************************************
void CStartStopParticleSystem::start()
{
	UpdateData();
	switch(_State)
	{
		case Stopped:
			if (_ActiveNode)
			{	
				if (checkHasLoop(*_ActiveNode)) return;
				play(*_ActiveNode);	
				nlassert(_PlayingNodes.empty());
				_PlayingNodes.push_back(_ActiveNode);
			}
			GetDlgItem(IDC_RESET_COUNT)->EnableWindow(TRUE);
		break;
		case RunningSingle:
			// no-op
		return;
		break;
		case RunningMultiple:
			stop();
			start();
		break;
		case PausedSingle:
			if (_ActiveNode)
			{
				unpause(*_ActiveNode);
			}
		break;
		case PausedMultiple:
			for(uint k = 0; k < _PlayingNodes.size(); ++k)
			{
				if (_PlayingNodes[k])
				{
					unpause(*_PlayingNodes[k]);
				}
			}
			stop();
			start();
		break;
		default:
			nlassert(0);
		break;
	}
	_State = RunningSingle;
	updateUIFromState();	
	if (m_LinkPlayToScenePlay) // is scene animation subordinated to the fx animation
	{
		// start animation for the scene too
		if (_AnimationDLG)
		{
			_AnimationDLG->Playing = true;
		}
	}	
}
void CParticleEditor::start()
{
	switch(_State)
	{
	case State::Stopped:
		if (_ActiveNode)
		{	
			if (checkHasLoop(*_ActiveNode)) return;
			play(*_ActiveNode);
			nlassert(_PlayingNodes.empty());
			_PlayingNodes.push_back(_ActiveNode);
		}
	break;
	case State::RunningSingle:
		// no-op
	return;
	break;
	case State::RunningMultiple:
		stop();
		start();
	break;
	case State::PausedSingle:
		if (_ActiveNode)
		{
			unpause(*_ActiveNode);
		}
	break;
	case State::PausedMultiple:
		for(uint k = 0; k < _PlayingNodes.size(); ++k)
		{
			if (_PlayingNodes[k])
			{
				unpause(*_PlayingNodes[k]);
			}
		}
		stop();
		start();
	break;
	default:
		nlassert(0);
	break;
	}
	_State = State::RunningSingle;
}
//******************************************************************************************************
void CStartStopParticleSystem::startMultiple()
{
	UpdateData();
	switch(_State)
	{
		case Stopped:
		{			
			CParticleWorkspace *pws = _ParticleDlg->getParticleWorkspace();
			if (!pws) return;
			nlassert(_PlayingNodes.empty());
			for(uint k = 0; k < pws->getNumNode(); ++k)
			{
				if (pws->getNode(k)->isLoaded())
				{				
					if (checkHasLoop(*pws->getNode(k))) return;
				}
			}
			for(uint k = 0; k < pws->getNumNode(); ++k)
			{
				if (pws->getNode(k)->isLoaded())
				{
					// really start the node only if there's no trigger anim
					if (pws->getNode(k)->getTriggerAnim().empty())
					{					
						play(*pws->getNode(k));
					}
					_PlayingNodes.push_back(pws->getNode(k));
				}
			}
			GetDlgItem(IDC_RESET_COUNT)->EnableWindow(TRUE);
		}
		break;
		case PausedSingle:
		case RunningSingle:
			stop();
			startMultiple();
		break;
		case RunningMultiple:
			// no-op
			return;
		break;			
		case PausedMultiple:
			for(uint k = 0; k < _PlayingNodes.size(); ++k)
			{
				if (_PlayingNodes[k])
				{
					unpause(*_PlayingNodes[k]);
				}
			}			
		break;
		default:
			nlassert(0);
		break;
	}
	_State = RunningMultiple;
	updateUIFromState();	
	if (m_LinkPlayToScenePlay) // is scene animation subordinated to the fx animation
	{
		// start animation for the scene too
		if (_AnimationDLG)
		{
			_AnimationDLG->Playing = true;
		}
	}	
}