void UnitStateMgr::Update(uint32 diff) { if (m_needReinit) { m_needReinit = false; InitDefaults(true); } ActionInfo* state = CurrentState(); if (!m_oldAction) m_oldAction = state->Action(); else if (m_oldAction && m_oldAction != state->Action()) { if (ActionInfo* oldAction = GetAction(m_oldAction)) { if (oldAction->HasFlag(ACTION_STATE_ACTIVE) && !oldAction->HasFlag(ACTION_STATE_FINALIZED) && !oldAction->HasFlag(ACTION_STATE_INTERRUPTED)) oldAction->Interrupt(this); } // else do nothing - action be deleted without interrupt/finalize (may be need correct?) m_oldAction = state->Action(); } if (!state->Update(this, diff)) { DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "UnitStateMgr: %s finished action %s", GetOwnerStr().c_str(), state->TypeName()); DropAction(state->priority); } }