public void Execute(EntityInfo entity, long deltaTime)
{
if (entity.IsUnderControl()) {
return;
}
if (entity.GetAIEnable()) {
AiStateInfo npcAi = entity.GetAiStateInfo();
if (!npcAi.IsInited) {
OnStateLogicInit(entity, deltaTime);
npcAi.IsInited = true;
}
int curState = npcAi.CurState;
if (curState > (int)AiStateId.Invalid && curState < (int)AiStateId.MaxNum) {
AiStateHandler handler;
if (m_Handlers.TryGetValue(curState, out handler)) {
if (OnStateLogicCheck(entity, deltaTime) && null != handler) {
handler(entity, deltaTime);
}
} else {
LogSystem.Error("Illegal ai state: " + curState + " entity:" + entity.GetId());
}
} else {
ChangeToState(entity, (int)AiStateId.Idle);
}
}
}