/** ** Parse an animation frame ** ** @param str string formated as "animationType extraArgs" */ static CAnimation *ParseAnimationFrame(lua_State *l, const char *str) { const std::string all(str); const size_t len = all.size(); size_t end = all.find(' '); const std::string op1(all, 0, end); size_t begin = std::min(len, all.find_first_not_of(' ', end)); const std::string extraArg(all, begin); CAnimation *anim = NULL; if (op1 == "frame") { anim = new CAnimation_Frame; } else if (op1 == "exact-frame") { anim = new CAnimation_ExactFrame; } else if (op1 == "wait") { anim = new CAnimation_Wait; } else if (op1 == "random-wait") { anim = new CAnimation_RandomWait; } else if (op1 == "sound") { anim = new CAnimation_Sound; } else if (op1 == "random-sound") { anim = new CAnimation_RandomSound; } else if (op1 == "attack") { anim = new CAnimation_Attack; } else if (op1 == "spawn-missile") { anim = new CAnimation_SpawnMissile; } else if (op1 == "spawn-unit") { anim = new CAnimation_SpawnUnit; } else if (op1 == "if-var") { anim = new CAnimation_IfVar; } else if (op1 == "set-var") { anim = new CAnimation_SetVar; } else if (op1 == "set-player-var") { anim = new CAnimation_SetPlayerVar; } else if (op1 == "die") { anim = new CAnimation_Die(); } else if (op1 == "rotate") { anim = new CAnimation_Rotate; } else if (op1 == "random-rotate") { anim = new CAnimation_RandomRotate; } else if (op1 == "move") { anim = new CAnimation_Move; } else if (op1 == "unbreakable") { anim = new CAnimation_Unbreakable; } else if (op1 == "label") { anim = new CAnimation_Label; AddLabel(anim, extraArg); } else if (op1 == "goto") { anim = new CAnimation_Goto; } else if (op1 == "random-goto") { anim = new CAnimation_RandomGoto; } else if (op1 == "lua-callback") { anim = new CAnimation_LuaCallback; } else { LuaError(l, "Unknown animation: %s" _C_ op1.c_str()); } anim->Init(extraArg.c_str(), l); return anim; }
CAnimation* CAnimationManager::Create(char* szName) { CAnimation* pcAnimation; pcAnimation = mcList.Add(); if (pcAnimation) { pcAnimation->Init(); } return pcAnimation; }