void UnitStateMgr::PushAction(UnitActionId actionId, UnitActionPtr state, UnitActionPriority priority, eActionType restoreable) { ActionInfo* oldInfo = CurrentState(); UnitActionPriority _priority = oldInfo ? oldInfo->priority : UNIT_ACTION_PRIORITY_IDLE; // Only interrupt action, if not drop his below and action lower by priority if (oldInfo && oldInfo->HasFlag(ACTION_STATE_ACTIVE) && oldInfo->Id != actionId && _priority < priority) oldInfo->Interrupt(this); if (_priority > UNIT_ACTION_PRIORITY_IDLE) { // Some speedup - testing - not need drop Idle/None actions DropAction(actionId, priority); DropAction(priority); } bool needInsert = true; if (restoreable != ACTION_TYPE_NONRESTOREABLE) { // Don't replace (only interrupt and reset!) restoreable actions UnitActionStorage::iterator itr = m_actions.find(priority); if (itr != m_actions.end()) { if (itr->second.Id == actionId) { itr->second.Reset(this); needInsert = false; } } } if (needInsert) m_actions.insert(UnitActionStorage::value_type(priority,ActionInfo(actionId, state, priority, restoreable))); IncreaseCounter(actionId); /* ActionInfo* newInfo = CurrentState(); if (newInfo && newInfo != oldInfo) { if (!newInfo->HasFlag(ACTION_STATE_INITIALIZED)) newInfo->Initialize(this); } */ }