| 
									
										
										
										
											2018-04-21 21:24:46 +08:00
										 |  |  |  | #include "..\e2daction.h"
 | 
					
						
							| 
									
										
										
										
											2017-10-19 00:50:04 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-01 00:04:33 +08:00
										 |  |  |  | e2d::ActionSequence::ActionSequence() | 
					
						
							|  |  |  |  | 	: m_nActionIndex(0) | 
					
						
							| 
									
										
										
										
											2017-10-19 00:50:04 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-24 20:22:41 +08:00
										 |  |  |  | #ifdef HIGHER_THAN_VS2012
 | 
					
						
							| 
									
										
										
										
											2018-05-08 11:37:11 +08:00
										 |  |  |  | e2d::ActionSequence::ActionSequence(const std::initializer_list<ActionBase*>& vActions) | 
					
						
							| 
									
										
										
										
											2018-04-01 00:04:33 +08:00
										 |  |  |  | 	: m_nActionIndex(0) | 
					
						
							| 
									
										
										
										
											2017-10-19 00:50:04 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-03-31 18:12:01 +08:00
										 |  |  |  | 	this->add(vActions); | 
					
						
							| 
									
										
										
										
											2017-10-19 00:50:04 +08:00
										 |  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-04-01 13:16:07 +08:00
										 |  |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2018-04-30 16:49:44 +08:00
										 |  |  |  | e2d::ActionSequence::ActionSequence(int number, ActionBase * action1, ...) : | 
					
						
							| 
									
										
										
										
											2018-04-01 13:16:07 +08:00
										 |  |  |  | 	m_nActionIndex(0) | 
					
						
							|  |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-04-30 16:49:44 +08:00
										 |  |  |  | 	ActionBase ** ppAction = &action1; | 
					
						
							| 
									
										
										
										
											2018-04-01 13:16:07 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 	while (number > 0) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		WARN_IF((*ppAction) == nullptr, "ActionSequence NULL pointer exception!"); | 
					
						
							|  |  |  |  | 		this->add(*ppAction); | 
					
						
							|  |  |  |  | 		ppAction++; | 
					
						
							|  |  |  |  | 		number--; | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2017-10-19 00:50:04 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | e2d::ActionSequence::~ActionSequence() | 
					
						
							| 
									
										
										
										
											2017-10-19 00:50:04 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | void e2d::ActionSequence::_init() | 
					
						
							| 
									
										
										
										
											2017-10-19 00:50:04 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-04-30 16:49:44 +08:00
										 |  |  |  | 	ActionBase::_init(); | 
					
						
							| 
									
										
										
										
											2017-10-19 00:50:04 +08:00
										 |  |  |  | 	// <20><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2017-10-20 00:59:26 +08:00
										 |  |  |  | 	if (m_pTarget) | 
					
						
							| 
									
										
										
										
											2017-10-19 00:50:04 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-04-24 20:22:41 +08:00
										 |  |  |  | 		for (auto action : m_vActions) | 
					
						
							| 
									
										
										
										
											2017-10-20 00:59:26 +08:00
										 |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-02-06 15:34:47 +08:00
										 |  |  |  | 			action->m_pTarget = m_pTarget; | 
					
						
							| 
									
										
										
										
											2017-10-20 00:59:26 +08:00
										 |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-10-19 00:50:04 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  | 	m_vActions[0]->_init(); | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-21 18:22:01 +08:00
										 |  |  |  | void e2d::ActionSequence::destroy() | 
					
						
							|  |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-04-30 16:49:44 +08:00
										 |  |  |  | 	ActionBase::destroy(); | 
					
						
							| 
									
										
										
										
											2018-04-24 20:22:41 +08:00
										 |  |  |  | 	for (auto action : m_vActions) | 
					
						
							| 
									
										
										
										
											2018-04-21 18:22:01 +08:00
										 |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		SafeRelease(&action); | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | void e2d::ActionSequence::_update() | 
					
						
							| 
									
										
										
										
											2017-10-19 00:50:04 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-04-30 16:49:44 +08:00
										 |  |  |  | 	ActionBase::_update(); | 
					
						
							| 
									
										
										
										
											2017-11-03 12:51:01 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 	auto &action = m_vActions[m_nActionIndex]; | 
					
						
							| 
									
										
										
										
											2017-12-08 15:37:52 +08:00
										 |  |  |  | 	action->_update(); | 
					
						
							| 
									
										
										
										
											2017-10-19 00:50:04 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-08 11:37:11 +08:00
										 |  |  |  | 	if (action->_isDone()) | 
					
						
							| 
									
										
										
										
											2017-10-19 00:50:04 +08:00
										 |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		m_nActionIndex++; | 
					
						
							|  |  |  |  | 		if (m_nActionIndex == m_vActions.size()) | 
					
						
							|  |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			this->stop(); | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		else | 
					
						
							|  |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			m_vActions[m_nActionIndex]->_init(); | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | void e2d::ActionSequence::reset() | 
					
						
							| 
									
										
										
										
											2017-10-19 00:50:04 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-04-30 16:49:44 +08:00
										 |  |  |  | 	ActionBase::reset(); | 
					
						
							| 
									
										
										
										
											2018-04-24 20:22:41 +08:00
										 |  |  |  | 	for (auto action : m_vActions) | 
					
						
							| 
									
										
										
										
											2017-10-19 00:50:04 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-02-06 15:34:47 +08:00
										 |  |  |  | 		action->reset(); | 
					
						
							| 
									
										
										
										
											2017-10-19 00:50:04 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	m_nActionIndex = 0; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | void e2d::ActionSequence::_resetTime() | 
					
						
							| 
									
										
										
										
											2017-12-04 10:03:14 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-04-24 20:22:41 +08:00
										 |  |  |  | 	for (auto action : m_vActions) | 
					
						
							| 
									
										
										
										
											2017-12-04 10:03:14 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-02-03 22:04:43 +08:00
										 |  |  |  | 		action->_resetTime(); | 
					
						
							| 
									
										
										
										
											2017-12-04 10:03:14 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-30 16:49:44 +08:00
										 |  |  |  | void e2d::ActionSequence::add(ActionBase * action) | 
					
						
							| 
									
										
										
										
											2017-10-19 00:50:04 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-11-03 22:14:07 +08:00
										 |  |  |  | 	if (action) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		m_vActions.push_back(action); | 
					
						
							|  |  |  |  | 		action->retain(); | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-10-19 00:50:04 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-24 20:22:41 +08:00
										 |  |  |  | #ifdef HIGHER_THAN_VS2012
 | 
					
						
							| 
									
										
										
										
											2018-05-08 11:37:11 +08:00
										 |  |  |  | void e2d::ActionSequence::add(const std::initializer_list<ActionBase*>& vActions) | 
					
						
							| 
									
										
										
										
											2018-03-31 18:12:01 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | 	for (const auto &action : vActions) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		this->add(action); | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-04-01 13:16:07 +08:00
										 |  |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2018-04-30 16:49:44 +08:00
										 |  |  |  | void e2d::ActionSequence::add(int number, ActionBase * action, ...) | 
					
						
							| 
									
										
										
										
											2018-04-01 13:16:07 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-04-30 16:49:44 +08:00
										 |  |  |  | 	ActionBase ** ppAction = &action; | 
					
						
							| 
									
										
										
										
											2018-04-01 13:16:07 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 	while (number > 0) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		WARN_IF((*ppAction) == nullptr, "ActionSequence NULL pointer exception!"); | 
					
						
							|  |  |  |  | 		this->add(*ppAction); | 
					
						
							|  |  |  |  | 		ppAction++; | 
					
						
							|  |  |  |  | 		number--; | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2018-03-31 18:12:01 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | e2d::ActionSequence * e2d::ActionSequence::clone() const | 
					
						
							| 
									
										
										
										
											2017-10-19 00:50:04 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | 	auto a = new ActionSequence(); | 
					
						
							| 
									
										
										
										
											2018-04-24 20:22:41 +08:00
										 |  |  |  | 	for (auto action : m_vActions) | 
					
						
							| 
									
										
										
										
											2017-10-19 00:50:04 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-03-06 09:56:17 +08:00
										 |  |  |  | 		a->add(action->clone()); | 
					
						
							| 
									
										
										
										
											2017-10-19 00:50:04 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	return a; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | e2d::ActionSequence * e2d::ActionSequence::reverse(bool actionReverse) const | 
					
						
							| 
									
										
										
										
											2017-10-19 00:50:04 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | 	auto a = new ActionSequence(); | 
					
						
							| 
									
										
										
										
											2018-04-24 20:22:41 +08:00
										 |  |  |  | 	for (auto action : m_vActions) | 
					
						
							| 
									
										
										
										
											2017-10-19 00:50:04 +08:00
										 |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		if (actionReverse) | 
					
						
							|  |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-03-06 09:56:17 +08:00
										 |  |  |  | 			a->add(action->reverse()); | 
					
						
							| 
									
										
										
										
											2017-10-19 00:50:04 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 		else | 
					
						
							|  |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-03-06 09:56:17 +08:00
										 |  |  |  | 			a->add(action->clone()); | 
					
						
							| 
									
										
										
										
											2017-10-19 00:50:04 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  | 	a->m_vActions.reserve(m_vActions.size()); | 
					
						
							|  |  |  |  | 	return a; | 
					
						
							|  |  |  |  | } |