158 lines
2.8 KiB
C++
158 lines
2.8 KiB
C++
#include "..\emanagers.h"
|
||
#include "..\eactions.h"
|
||
#include "..\Win\winbase.h"
|
||
|
||
static e2d::EVector<e2d::EAction*> s_vActions;
|
||
|
||
|
||
void e2d::EActionManager::addAction(EAction * action)
|
||
{
|
||
WARN_IF(action == nullptr, "EAction NULL pointer exception!");
|
||
|
||
if (action)
|
||
{
|
||
action->start();
|
||
action->retain();
|
||
s_vActions.push_back(action);
|
||
}
|
||
}
|
||
|
||
void e2d::EActionManager::startAllActionsBindedWith(ENode * pTargetNode)
|
||
{
|
||
if (pTargetNode)
|
||
{
|
||
for (const auto &action : s_vActions)
|
||
{
|
||
if (action->getTarget() == pTargetNode)
|
||
{
|
||
action->start();
|
||
}
|
||
}
|
||
for (const auto &child : pTargetNode->getChildren())
|
||
{
|
||
EActionManager::startAllActionsBindedWith(child);
|
||
}
|
||
}
|
||
}
|
||
|
||
void e2d::EActionManager::pauseAllActionsBindedWith(ENode * pTargetNode)
|
||
{
|
||
if (pTargetNode)
|
||
{
|
||
for (const auto &action : s_vActions)
|
||
{
|
||
if (action->getTarget() == pTargetNode)
|
||
{
|
||
action->pause();
|
||
}
|
||
}
|
||
for (const auto &child : pTargetNode->getChildren())
|
||
{
|
||
EActionManager::pauseAllActionsBindedWith(child);
|
||
}
|
||
}
|
||
}
|
||
|
||
void e2d::EActionManager::stopAllActionsBindedWith(ENode * pTargetNode)
|
||
{
|
||
if (pTargetNode)
|
||
{
|
||
for (const auto &action : s_vActions)
|
||
{
|
||
if (action->getTarget() == pTargetNode)
|
||
{
|
||
action->stop();
|
||
}
|
||
}
|
||
for (const auto &child : pTargetNode->getChildren())
|
||
{
|
||
EActionManager::stopAllActionsBindedWith(child);
|
||
}
|
||
}
|
||
}
|
||
|
||
void e2d::EActionManager::_clearAllActionsBindedWith(ENode * pTargetNode)
|
||
{
|
||
if (pTargetNode)
|
||
{
|
||
for (size_t i = 0; i < s_vActions.size();)
|
||
{
|
||
auto a = s_vActions[i];
|
||
if (a->getTarget() == pTargetNode)
|
||
{
|
||
SafeRelease(&a);
|
||
s_vActions.erase(s_vActions.begin() + i);
|
||
}
|
||
else
|
||
{
|
||
i++;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
void e2d::EActionManager::startAllActions()
|
||
{
|
||
for (auto child : EApp::getCurrentScene()->getChildren())
|
||
{
|
||
EActionManager::startAllActionsBindedWith(child);
|
||
}
|
||
}
|
||
|
||
void e2d::EActionManager::pauseAllActions()
|
||
{
|
||
for (auto child : EApp::getCurrentScene()->getChildren())
|
||
{
|
||
EActionManager::pauseAllActionsBindedWith(child);
|
||
}
|
||
}
|
||
|
||
void e2d::EActionManager::stopAllActions()
|
||
{
|
||
for (auto child : EApp::getCurrentScene()->getChildren())
|
||
{
|
||
EActionManager::stopAllActionsBindedWith(child);
|
||
}
|
||
}
|
||
|
||
void e2d::EActionManager::_clearManager()
|
||
{
|
||
s_vActions.clear();
|
||
}
|
||
|
||
void e2d::EActionManager::_resetAllActions()
|
||
{
|
||
for (const auto & action : s_vActions)
|
||
{
|
||
action->_resetTime();
|
||
}
|
||
}
|
||
|
||
void e2d::EActionManager::ActionProc()
|
||
{
|
||
if (s_vActions.empty())
|
||
return;
|
||
|
||
// ѭ<><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>еĶ<D0B5><C4B6><EFBFBD>
|
||
for (size_t i = 0; i < s_vActions.size(); i++)
|
||
{
|
||
auto &action = s_vActions[i];
|
||
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
||
if (action->isRunning() ||
|
||
(action->getTarget() && action->getTarget()->getParentScene() == EApp::getCurrentScene()))
|
||
{
|
||
if (action->_isEnding())
|
||
{
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD>
|
||
SafeRelease(&action);
|
||
s_vActions.erase(s_vActions.begin() + i);
|
||
}
|
||
else
|
||
{
|
||
// ִ<>ж<EFBFBD><D0B6><EFBFBD>
|
||
action->_callOn();
|
||
}
|
||
}
|
||
}
|
||
}
|