actorSequFrameAnimManager.lua 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112
  1. local actorSequFrameAnimManager = class("actorSequFrameAnimManager")
  2. local actorSequenceFrameAnim = require( "animation/actorSequenceFrameAnim" )
  3. local Queue = requireUtil( "queue" )
  4. local MMO = global.MMO
  5. local rawTempID = 9999
  6. -------------------------------------------------------------
  7. local AnimDataDesc = class( "AnimDataDesc" )
  8. function AnimDataDesc:ctor( animID, rawAnimID, sex, animType )
  9. --------- for loading ------------
  10. self.animID = animID
  11. self.rawAnimID = rawAnimID
  12. self.animType = animType
  13. self.sex = sex
  14. self.loadCallback = nil
  15. ----------------------------------
  16. self.timeStamp = os.time()
  17. self.loadStateUnit = {}
  18. for i = 0, MMO.ANIM_COUNT - 1 do
  19. self.loadStateUnit[i] = MMO.LOAD_STATE_UNLOADING
  20. end
  21. --
  22. self.hudTop = 20
  23. self.offset = cc.p(0,0)
  24. self.animDelays = {} -- with ANIM_ACT * ORIENT ;
  25. self.animFrameVecs = {} -- with ANIM_ACT * ORIENT ;contain cocos obj[]
  26. self.frameLoaded = {}
  27. self.ignoreSync = false
  28. self.enlarge = 1
  29. self.standPoint = cc.p(0.5,0.5)
  30. self.blendMode = 0
  31. self.hasShadow = true
  32. -- OOM
  33. self.loadOOMUnit = {}
  34. end
  35. function AnimDataDesc:checkIsInUsed()
  36. for i = 0, MMO.ANIM_COUNT - 1 do
  37. if (MMO.LOAD_STATE_LOADING == self.loadStateUnit[i] or
  38. MMO.LOAD_STATE_INUSED == self.loadStateUnit[i] or
  39. MMO.LOAD_STATE_FOREVER == self.loadStateUnit[i] or
  40. MMO.LOAD_STATE_FAILED == self.loadStateUnit[i]) then
  41. return true
  42. end
  43. end
  44. return false
  45. end
  46. function AnimDataDesc:setUnused()
  47. for i = 0, MMO.ANIM_COUNT - 1 do
  48. if MMO.LOAD_STATE_INUSED == self.loadStateUnit[i] or MMO.LOAD_STATE_FAILED == self.loadStateUnit[i] then
  49. self.loadStateUnit[i] = MMO.LOAD_STATE_UNUSED
  50. end
  51. end
  52. self.timeStamp = os.time()
  53. end
  54. -------------------------------------------------------------
  55. function actorSequFrameAnimManager:ctor()
  56. self._animLoads = {}
  57. self._animDataMgr = {}
  58. self._animLoadQueue = Queue.new()
  59. self._animRefsMgr = {}
  60. self._memoryInfo = {}
  61. self._memorySize = 0
  62. self._memoryWarning = 400 * 1024 * 1024
  63. self._memoryCleanup = 350 * 1024 * 1024
  64. self._loadingCount = 0
  65. self._loadingLimit = 3
  66. self._expiredInterval = 30
  67. self._forNextUnloadFrame = 0
  68. self._globalElapsed = 0
  69. self._animFrameVecEmpty = {}
  70. end
  71. function actorSequFrameAnimManager:textureMemAdd(texture, filename)
  72. if not texture then
  73. return
  74. end
  75. if self._memoryInfo[filename] then
  76. return
  77. end
  78. local bpp = texture:getBitsPerPixelForFormat()
  79. local bytes = texture:getPixelsWide() * texture:getPixelsHigh() * bpp / 8
  80. self._memoryInfo[filename] = bytes
  81. self._memorySize = self._memorySize + bytes
  82. -- log
  83. -- print("++++++++++++++++ANIM MEMORY ADD", filename, self._memorySize / 1024 / 1024)
  84. end
  85. function actorSequFrameAnimManager:textureMemDel(filename)
  86. if not self._memoryInfo[filename] then
  87. return
  88. end
  89. local bytes = self._memoryInfo[filename] or 0
  90. self._memorySize = self._memorySize - bytes
  91. self._memoryInfo[filename] = nil
  92. -- log
  93. -- print("----------------ANIM MEMORY DEL", filename, self._memorySize / 1024 / 1024)
  94. end
  95. function actorSequFrameAnimManager:isMemWarning(animType)
  96. -- PC不限制
  97. if global.isWindows then
  98. return false
  99. end
  100. -- NPC特效不限制
  101. if animType == MMO.SFANIM_TYPE_NPC then
  102. return false
  103. end
  104. return self._memorySize >= self._memoryWarning
  105. end
  106. function actorSequFrameAnimManager:checkMemEnough()
  107. -- 50M 50*1024*1024
  108. return self._memorySize >= (self._memoryWarning - 52428800)
  109. end
  110. function actorSequFrameAnimManager:setMemWarningInMB(size)
  111. size = size or 500
  112. self._memoryWarning = size * 1024 * 1024
  113. self._memoryCleanup = (size-50) * 1024 * 1024
  114. end
  115. function actorSequFrameAnimManager:isMemCleanup()
  116. -- PC不限制
  117. if global.isWindows then
  118. return false
  119. end
  120. return self._memorySize >= self._memoryCleanup
  121. end
  122. function actorSequFrameAnimManager:setBlendFunc(anim, blendType)
  123. if not anim then
  124. return
  125. end
  126. if 1 == blendType then -- add
  127. anim:setBlendFunc( MMO.add_blend_func )
  128. elseif 2 == blendType then -- screen
  129. anim:setBlendFunc( MMO.screen_blend_func )
  130. elseif 3 == blendType then -- 叠加
  131. anim:setBlendFunc( MMO.overlying_blend_func )
  132. elseif 4 == blendType then -- 无
  133. anim:setBlendFunc( MMO.ALPHA_PREMULTIPLIED )
  134. else
  135. anim:setBlendFunc( MMO.normal_blend_func )
  136. end
  137. end
  138. function actorSequFrameAnimManager:CheckETC2()
  139. local etc2_enable = global.LuaBridgeCtl:GetModulesSwitch( MMO.Modules_Index_Enable_ETC2)
  140. local support = etc2_enable == 1
  141. if not support then
  142. local function callback()
  143. end
  144. local data = {}
  145. if global.isWindows then
  146. data.str = GET_STRING( 800602 )
  147. else
  148. data.str = GET_STRING( 800601 )
  149. end
  150. data.btnDesc = { GET_STRING( 1002 ) }
  151. data.callback = callback
  152. global.Facade:sendNotification( global.NoticeTable.Layer_CommonTips_Open, data )
  153. end
  154. if not support and cc.PLATFORM_OS_ANDROID == global.Platform then
  155. buglyAddUserValue("etc2 not support")
  156. end
  157. releasePrint( "etc2 support:", support )
  158. return support
  159. end
  160. function actorSequFrameAnimManager:Init()
  161. print( "init FrameAnimManager" )
  162. local playerAnimLoader = require( "animation/sequFrameAnimLoaderImpPlayer" )
  163. local weaponAnimLoader = require( "animation/sequFrameAnimLoaderImpWeapon" )
  164. local shieldAnimLoader = require( "animation/sequFrameAnimLoaderImpShield" )
  165. local wingsAnimLoader = require( "animation/sequFrameAnimLoaderImpWings" )
  166. local hairAnimLoader = require( "animation/sequFrameAnimLoaderImpHair" )
  167. local monsterAnimLoader = require( "animation/sequFrameAnimLoaderImpMonster" )
  168. local npcAnimLoader = require( "animation/sequFrameAnimLoaderImpNpc" )
  169. local skillAnimLoader = require( "animation/sequFrameAnimLoaderImpSkill" )
  170. self._animLoads[MMO.SFANIM_TYPE_PLAYER] = playerAnimLoader.new()
  171. self._animLoads[MMO.SFANIM_TYPE_WEAPON] = weaponAnimLoader.new()
  172. self._animLoads[MMO.SFANIM_TYPE_SHIELD] = shieldAnimLoader.new()
  173. self._animLoads[MMO.SFANIM_TYPE_WINGS] = wingsAnimLoader.new()
  174. self._animLoads[MMO.SFANIM_TYPE_HAIR] = hairAnimLoader.new()
  175. self._animLoads[MMO.SFANIM_TYPE_MONSTER] = monsterAnimLoader.new()
  176. self._animLoads[MMO.SFANIM_TYPE_NPC] = npcAnimLoader.new()
  177. self._animLoads[MMO.SFANIM_TYPE_SKILL] = skillAnimLoader.new()
  178. for i = 1, MMO.SFANIM_TYPE_NUM do
  179. self._animDataMgr[i] = {}
  180. self._animRefsMgr[i] = {}
  181. end
  182. -- check etc2 support
  183. if not self:CheckETC2() then
  184. return nil
  185. end
  186. --------------------------------------- Player ---------------------------------------
  187. self:InitTemporaryPlayer(global.MMO.ACTOR_PLAYER_SEX_M, global.MMO.SFANIM_TYPE_PLAYER)
  188. self:InitTemporaryPlayer(global.MMO.ACTOR_PLAYER_SEX_F, global.MMO.SFANIM_TYPE_PLAYER)
  189. -- --------------------------------------- Weapon ---------------------------------------
  190. -- self:InitTemporaryPlayer(global.MMO.ACTOR_PLAYER_SEX_M, global.MMO.SFANIM_TYPE_WEAPON)
  191. -- self:InitTemporaryPlayer(global.MMO.ACTOR_PLAYER_SEX_F, global.MMO.SFANIM_TYPE_WEAPON)
  192. --------------------------------------- Hair ---------------------------------------
  193. self:InitTemporaryPlayer(global.MMO.ACTOR_PLAYER_SEX_M, global.MMO.SFANIM_TYPE_HAIR)
  194. self:InitTemporaryPlayer(global.MMO.ACTOR_PLAYER_SEX_F, global.MMO.SFANIM_TYPE_HAIR)
  195. -- --------------------------------------- Shield ---------------------------------------
  196. -- self:InitTemporaryPlayer(global.MMO.ACTOR_PLAYER_SEX_M, global.MMO.SFANIM_TYPE_SHIELD)
  197. -- self:InitTemporaryPlayer(global.MMO.ACTOR_PLAYER_SEX_F, global.MMO.SFANIM_TYPE_SHIELD)
  198. -- --------------------------------------- Wings ---------------------------------------
  199. -- self:InitTemporaryPlayer(global.MMO.ACTOR_PLAYER_SEX_M, global.MMO.SFANIM_TYPE_WINGS)
  200. -- self:InitTemporaryPlayer(global.MMO.ACTOR_PLAYER_SEX_F, global.MMO.SFANIM_TYPE_WINGS)
  201. --------------------------------------- Monster ---------------------------------------
  202. self:InitTemporaryMonster()
  203. --------------------------------------- NPC ---------------------------------------
  204. -- self:InitTemporaryNpc()
  205. --------------------------------------- Skill ---------------------------------------
  206. -- self:InitTemporarySFX()
  207. --------------------------------------- Empty Temp ---------------------------------------
  208. local spriteFrame = cc.SpriteFrame:create("res/public/0.png", cc.rect(0, 0, 1, 1))
  209. for i = 1, 6 do
  210. local animFrame = cc.AnimationFrame:create( spriteFrame, 1, {} )
  211. animFrame:retain()
  212. table.insert(self._animFrameVecEmpty, animFrame)
  213. end
  214. end
  215. function actorSequFrameAnimManager:Cleanup()
  216. for i = 1, MMO.SFANIM_TYPE_NUM do
  217. local datas = self._animDataMgr[i]
  218. if nil == datas then break end
  219. for k, animDataDesc in pairs(datas) do
  220. if self._animLoads[i] then
  221. self._animLoads[i]:unloadSequAnim( animDataDesc )
  222. end
  223. end
  224. -- may be unnecessary
  225. local animRefs = self._animRefsMgr[i]
  226. for animID, anims in pairs( animRefs ) do
  227. for _, item in pairs( anims ) do
  228. item.animInst:Cleanup()
  229. end
  230. end
  231. if self._animLoads[i] then
  232. self._animLoads[i]:Cleanup()
  233. self._animLoads[i] = nil
  234. end
  235. self._animDataMgr[i] = {}
  236. self._animRefsMgr[i] = {}
  237. end
  238. -- release animation frame
  239. for k, v in pairs(self._animFrameVecEmpty) do
  240. v:autorelease()
  241. end
  242. self._animFrameVecEmpty = {}
  243. -- cleanup loading
  244. self._animLoadQueue:reset()
  245. self._loadingCount = 0
  246. end
  247. function actorSequFrameAnimManager:refreshAnimData( animDataDesc, act )
  248. -- Mark animation data has loaded.
  249. local animID = animDataDesc.animID
  250. local rawAnimID = animDataDesc.rawAnimID
  251. local sex = animDataDesc.sex
  252. local animType = animDataDesc.animType
  253. local loader = self._animLoads[animType]
  254. local animDataMgr = self._animDataMgr[animType]
  255. local animRefsMgr = self._animRefsMgr[animType]
  256. -- connect to sequence animation
  257. local seqFrmAnims = animRefsMgr[animID]
  258. local anim = nil
  259. for k,v in pairs( seqFrmAnims ) do
  260. anim = v.animInst
  261. -- 刷新属性
  262. self:refreshAnimAttr(anim)
  263. if anim:CheckCurrUnit( act ) then
  264. -- reset play
  265. anim:resetAnimPlay(act)
  266. end
  267. if v.extCB then
  268. v.extCB( animID, anim )
  269. end
  270. end
  271. end
  272. function actorSequFrameAnimManager:loadAnimDataError( animDataDesc, act )
  273. -- Mark animation data has loaded.
  274. local animID = animDataDesc.animID
  275. local rawAnimID = animDataDesc.rawAnimID
  276. local sex = animDataDesc.sex
  277. local animType = animDataDesc.animType
  278. local animRefsMgr = self._animRefsMgr[animType]
  279. -- connect to sequence animation
  280. local seqFrmAnims = animRefsMgr[animID]
  281. local anim = nil
  282. for k,v in pairs( seqFrmAnims ) do
  283. anim = v.animInst
  284. anim:onAnimationLoadError( animID, anim )
  285. end
  286. end
  287. local animTypeName = { "player", "monster", "npc", "sfx", "sfx", "weapon", "shield", "wings", "hair" }
  288. local loadErrorMsg = { "LOAD_SPRITES_ERROR", "LOAD_TEX_ERROR", "CONFIG_ERROR" }
  289. function actorSequFrameAnimManager:onAnimDataLoadCompleted( animDataDesc, act, loadcode )
  290. if loadcode ~= MMO.ANIM_LOAD_SUCCESS then
  291. local lastLoadState = animDataDesc.loadStateUnit[act]
  292. if self:IsReferenced( animDataDesc.animType, animDataDesc.rawAnimID, animDataDesc.sex ) then
  293. -- LOADING --> FAILED
  294. animDataDesc.loadStateUnit[act] = MMO.LOAD_STATE_FAILED
  295. else
  296. -- LOADING --> UNUSED
  297. animDataDesc.loadStateUnit[act] = MMO.LOAD_STATE_UNUSED
  298. end
  299. -- load error, OOM, record, need refresh again
  300. animDataDesc.loadOOMUnit[act] = lastLoadState == MMO.ANIM_LOAD_OOM
  301. -- load error
  302. self:loadAnimDataError( animDataDesc, act )
  303. else
  304. if self:IsReferenced( animDataDesc.animType, animDataDesc.rawAnimID, animDataDesc.sex ) then
  305. -- LOADING --> INUSED
  306. animDataDesc.loadStateUnit[act] = MMO.LOAD_STATE_INUSED
  307. else
  308. -- LOADING --> UNUSED
  309. animDataDesc.loadStateUnit[act] = MMO.LOAD_STATE_UNUSED
  310. end
  311. -- oom flag
  312. animDataDesc.loadOOMUnit[act] = nil
  313. local animID = animDataDesc.animID
  314. local animType = animDataDesc.animType
  315. local config = self:GetAnimConfig( animID, animType )
  316. self:setAnimDataDescByConfig(animDataDesc, config)
  317. -- refresh sequence animations that were associated by animation data.
  318. self:refreshAnimData( animDataDesc, act )
  319. end
  320. end
  321. function actorSequFrameAnimManager:refreshAnimAttr( anim )
  322. -- set blend func
  323. self:setBlendFunc( anim, anim:GetBlendMode() )
  324. -- set anchor point
  325. anim:setAnchorPoint( anim:GetStandPoint() )
  326. -- set position
  327. anim:setPosition(anim:getTurePosition())
  328. end
  329. function actorSequFrameAnimManager:cloneTemporaryAnimDesc( animDataDesc, tempAnimDataDesc )
  330. if tempAnimDataDesc then
  331. animDataDesc.hasShadow = tempAnimDataDesc.hasShadow
  332. animDataDesc.blendMode = tempAnimDataDesc.blendMode
  333. animDataDesc.standPoint = clone(tempAnimDataDesc.standPoint)
  334. animDataDesc.ignoreSync = tempAnimDataDesc.ignoreSync
  335. animDataDesc.hudTop = tempAnimDataDesc.hudTop
  336. animDataDesc.boxWidth = tempAnimDataDesc.width
  337. animDataDesc.boxHeight = tempAnimDataDesc.height
  338. animDataDesc.offset = clone(tempAnimDataDesc.offset)
  339. animDataDesc.animDelays = clone(tempAnimDataDesc.animDelays)
  340. for k, v in pairs(tempAnimDataDesc.animFrameVecs) do
  341. animDataDesc.animFrameVecs[k] = v
  342. end
  343. end
  344. end
  345. function actorSequFrameAnimManager:setAnimDataDescByConfig( animDataDesc, config )
  346. if config then
  347. animDataDesc.offset = cc.p(config.offsetx or 0, config.offsety or 0)
  348. animDataDesc.ignoreSync = tonumber(config.ignoreSync) == 1
  349. animDataDesc.standPoint = cc.p(config.stand_pos_x or 0.5, config.stand_pos_y or 0.5)
  350. animDataDesc.blendMode = config.blendmode or 0
  351. animDataDesc.hasShadow = config.shadow ~= 1
  352. animDataDesc.hudTop = config.hud_top
  353. animDataDesc.boxWidth = config.width
  354. animDataDesc.boxHeight = config.height
  355. end
  356. end
  357. function actorSequFrameAnimManager:createSequFrmAnimAsync( rawAnimID, sex, animType, act, extCB, immediate )
  358. rawAnimID = tonumber(rawAnimID)
  359. animType = tonumber(animType)
  360. sex = tonumber(sex)
  361. if not rawAnimID or not sex then
  362. return nil
  363. end
  364. local animDataMgr = self._animDataMgr[animType]
  365. local animRefsMgr = self._animRefsMgr[animType]
  366. local loader = self._animLoads[animType]
  367. if not animDataMgr or not animRefsMgr or not loader then
  368. return nil
  369. end
  370. local newAnim = actorSequenceFrameAnim.new()
  371. -- convert animID
  372. local animID = self:KEY_ID_SEX( rawAnimID, sex, animType )
  373. local config = self:GetAnimConfig( animID, animType )
  374. local isNeedLoad = false
  375. local animDataDesc = animDataMgr[animID]
  376. if nil == animDataDesc then
  377. -- Animation Data dose not exist
  378. isNeedLoad = true
  379. animDataDesc = AnimDataDesc.new( animID, rawAnimID, sex, animType )
  380. animDataMgr[animID] = animDataDesc
  381. -- find temporary
  382. local tempID = self:GetAnimTemporaryID( animType, sex )
  383. local tempAnimDataDesc = animDataMgr[tempID]
  384. self:cloneTemporaryAnimDesc(animDataDesc, tempAnimDataDesc)
  385. -- load anim data desc
  386. if animType == global.MMO.SFANIM_TYPE_SKILL or not tempAnimDataDesc then
  387. self:setAnimDataDescByConfig(animDataDesc, config)
  388. end
  389. else
  390. -- UNUSED --> INUSED
  391. if MMO.LOAD_STATE_UNUSED == animDataDesc.loadStateUnit[act] then
  392. animDataDesc.loadStateUnit[act] = MMO.LOAD_STATE_INUSED
  393. end
  394. -- if in unloading, begin load
  395. if MMO.LOAD_STATE_UNLOADING == animDataDesc.loadStateUnit[act] then
  396. isNeedLoad = true
  397. end
  398. -- load failed, try again
  399. if MMO.LOAD_STATE_FAILED == animDataDesc.loadStateUnit[act] then
  400. isNeedLoad = true
  401. end
  402. -- load anim data desc
  403. self:setAnimDataDescByConfig(animDataDesc, config)
  404. end
  405. -- enlarge 不等加载成功,均使用配置表真正的缩放,
  406. if config then
  407. animDataDesc.enlarge = config and config.enlarge or 1
  408. end
  409. -- bind animation data
  410. newAnim:SetAnimDataDesc(animDataDesc)
  411. -- reset position
  412. newAnim:setPosition(cc.p(0,0))
  413. -- set scale
  414. newAnim:setScale(newAnim:GetEnlarge())
  415. ----------------------------------------------------------
  416. self:refreshAnimAttr(newAnim)
  417. -- to reference map
  418. if not animRefsMgr[animID] then animRefsMgr[animID] = {} end
  419. local refIndex = #animRefsMgr[animID] + 1
  420. newAnim.refIndex = refIndex
  421. local animRef = {}
  422. animRef.animInst = newAnim
  423. animRef.extCB = extCB
  424. animRefsMgr[animID][refIndex] = animRef
  425. -- load
  426. if isNeedLoad then
  427. self:loadSequFrmAnimUnit( animDataDesc, act, immediate )
  428. end
  429. return newAnim
  430. end
  431. function actorSequFrameAnimManager:resetSequFrmAnimAsync( anim, rawAnimID, sex, animType, act, extCB, immediate )
  432. rawAnimID = tonumber(rawAnimID)
  433. animType = tonumber(animType)
  434. sex = tonumber(sex)
  435. if not anim or not rawAnimID or not sex then
  436. return nil
  437. end
  438. local animDataMgr = self._animDataMgr[animType]
  439. local animRefsMgr = self._animRefsMgr[animType]
  440. local loader = self._animLoads[animType]
  441. if not animDataMgr or not animRefsMgr or not loader then
  442. return nil
  443. end
  444. -- remove from reference map
  445. local refIndex = anim.refIndex
  446. local lastAnimDataDesc = anim:GetAnimDataDesc()
  447. local lastAnimID = lastAnimDataDesc.animID
  448. animRefsMgr[lastAnimID][refIndex] = nil
  449. self:CheckSequAnimUnused(anim)
  450. -- convert animID
  451. local animID = self:KEY_ID_SEX( rawAnimID, sex, animType )
  452. local config = self:GetAnimConfig( animID, animType )
  453. local isNeedLoad = false
  454. local animDataDesc = animDataMgr[animID]
  455. if nil == animDataDesc then
  456. -- Animation Data dose not exist
  457. isNeedLoad = true
  458. animDataDesc = AnimDataDesc.new( animID, rawAnimID, sex, animType )
  459. animDataMgr[animID] = animDataDesc
  460. -- find temporary
  461. local tempID = self:GetAnimTemporaryID( animType, sex )
  462. local tempAnimDataDesc = animDataMgr[tempID]
  463. self:cloneTemporaryAnimDesc(animDataDesc, tempAnimDataDesc)
  464. -- load anim data desc
  465. if animType == global.MMO.SFANIM_TYPE_SKILL or not tempAnimDataDesc then
  466. self:setAnimDataDescByConfig(animDataDesc, config)
  467. end
  468. else
  469. -- UNUSED --> INUSED
  470. if MMO.LOAD_STATE_UNUSED == animDataDesc.loadStateUnit[act] then
  471. animDataDesc.loadStateUnit[act] = MMO.LOAD_STATE_INUSED
  472. end
  473. -- if in unloading, begin load
  474. if MMO.LOAD_STATE_UNLOADING == animDataDesc.loadStateUnit[act] then
  475. isNeedLoad = true
  476. end
  477. -- load failed, try again
  478. if MMO.LOAD_STATE_FAILED == animDataDesc.loadStateUnit[act] then
  479. isNeedLoad = true
  480. end
  481. -- load anim data desc
  482. self:setAnimDataDescByConfig(animDataDesc, config)
  483. end
  484. -- enlarge 不等加载成功,均使用配置表真正的缩放,
  485. if config then
  486. animDataDesc.enlarge = config and config.enlarge or 1
  487. end
  488. -- bind animation data
  489. anim:SetAnimDataDesc(animDataDesc)
  490. -- reset position 0
  491. anim:setPosition(cc.p(0,0))
  492. -- set scale
  493. anim:setScale(anim:GetEnlarge())
  494. ----------------------------------------------------------
  495. self:refreshAnimAttr(anim)
  496. -- to reference map
  497. if not animRefsMgr[animID] then animRefsMgr[animID] = {} end
  498. local refIndex = #animRefsMgr[animID] + 1
  499. anim.refIndex = refIndex
  500. local animRef = {}
  501. animRef.animInst = anim
  502. animRef.extCB = extCB
  503. animRefsMgr[animID][refIndex] = animRef
  504. -- load
  505. if isNeedLoad then
  506. self:loadSequFrmAnimUnit( animDataDesc, act, immediate )
  507. end
  508. return anim
  509. end
  510. function actorSequFrameAnimManager:loadSequFrmAnimUnit( animDataDesc, act, immediate )
  511. -- 1.check load flag
  512. if( MMO.LOAD_STATE_UNLOADING ~= animDataDesc.loadStateUnit[act] and MMO.LOAD_STATE_FAILED ~= animDataDesc.loadStateUnit[act] ) then
  513. return
  514. end
  515. -- 2.record load state
  516. animDataDesc.loadStateUnit[act] = MMO.LOAD_STATE_LOADING
  517. -- 3.loading
  518. local function loadCallback( loadAct, loadcode )
  519. self:onAnimDataLoadCompleted( animDataDesc, loadAct, loadcode )
  520. end
  521. animDataDesc.loadCallback = loadCallback
  522. self:loadAnim( animDataDesc, act, immediate )
  523. end
  524. function actorSequFrameAnimManager:loadAnim( animDataDesc, act, immediate )
  525. local animType = animDataDesc.animType
  526. if animType <= 0 or animType > MMO.SFANIM_TYPE_NUM then
  527. return
  528. end
  529. local loader = self._animLoads[animType]
  530. if not immediate then
  531. local loadDesc = {
  532. loader = loader,
  533. animDataDesc = animDataDesc,
  534. act = act,
  535. }
  536. self._animLoadQueue:push( loadDesc )
  537. else
  538. loader:loadSequAnim( animDataDesc, act )
  539. end
  540. end
  541. function actorSequFrameAnimManager:KEY_ID_SEX( id, sex, animType )
  542. return GetFrameAnimConfigID( id, sex, animType )
  543. end
  544. -----------------------------------------------------------------------------
  545. function actorSequFrameAnimManager:CreateActorPlayerAnim( clothID, sex, act, extCB, immediate )
  546. return self:createSequFrmAnimAsync( clothID, sex, MMO.SFANIM_TYPE_PLAYER, act, extCB, immediate )
  547. end
  548. function actorSequFrameAnimManager:ResetActorPlayerAnim( anim, clothID, sex, act, extCB, immediate )
  549. return self:resetSequFrmAnimAsync( anim, clothID, sex, MMO.SFANIM_TYPE_PLAYER, act, extCB, immediate )
  550. end
  551. -----------------------------------------------------------------------------
  552. function actorSequFrameAnimManager:CreateActorPlayerWeaponAnim( weaponID, sex, act, extCB, immediate )
  553. return self:createSequFrmAnimAsync( weaponID, sex, MMO.SFANIM_TYPE_WEAPON, act, extCB, immediate )
  554. end
  555. function actorSequFrameAnimManager:ResetActorPlayerWeaponAnim( anim, weaponID, sex, act, extCB, immediate )
  556. return self:resetSequFrmAnimAsync( anim, weaponID, sex, MMO.SFANIM_TYPE_WEAPON, act, extCB, immediate )
  557. end
  558. -----------------------------------------------------------------------------
  559. function actorSequFrameAnimManager:CreateActorPlayerHairAnim( hairID, sex, act, extCB, immediate )
  560. return self:createSequFrmAnimAsync( hairID, sex, MMO.SFANIM_TYPE_HAIR, act, extCB, immediate )
  561. end
  562. function actorSequFrameAnimManager:ResetActorPlayerHairAnim( anim, hairID, sex, act, extCB, immediate )
  563. return self:resetSequFrmAnimAsync( anim, hairID, sex, MMO.SFANIM_TYPE_HAIR, act, extCB, immediate )
  564. end
  565. -----------------------------------------------------------------------------
  566. function actorSequFrameAnimManager:CreateActorPlayerShieldAnim( shieldID, sex, act, extCB, immediate )
  567. return self:createSequFrmAnimAsync( shieldID, sex, MMO.SFANIM_TYPE_SHIELD, act, extCB, immediate )
  568. end
  569. function actorSequFrameAnimManager:ResetActorPlayerShieldAnim( anim, shieldID, sex, act, extCB, immediate )
  570. return self:resetSequFrmAnimAsync( anim, shieldID, sex, MMO.SFANIM_TYPE_SHIELD, act, extCB, immediate )
  571. end
  572. -----------------------------------------------------------------------------
  573. function actorSequFrameAnimManager:CreateActorPlayerWingsAnim( wingsID, sex, act, extCB, immediate )
  574. return self:createSequFrmAnimAsync( wingsID, sex, MMO.SFANIM_TYPE_WINGS, act, extCB, immediate )
  575. end
  576. function actorSequFrameAnimManager:ResetActorPlayerWingsAnim( anim, wingsID, sex, act, extCB, immediate )
  577. return self:resetSequFrmAnimAsync( anim, wingsID, sex, MMO.SFANIM_TYPE_WINGS, act, extCB, immediate )
  578. end
  579. -----------------------------------------------------------------------------
  580. function actorSequFrameAnimManager:CreateActorMountPlayerAnim( mountID, sex, act, extCB, immediate )
  581. return self:createSequFrmAnimAsync( mountID, sex, MMO.SFANIM_TYPE_MOUNT_PLAYER, act, extCB, immediate )
  582. end
  583. function actorSequFrameAnimManager:ResetActorMountPlayerAnim( anim, mountID, sex, act, extCB, immediate )
  584. return self:resetSequFrmAnimAsync( anim, mountID, sex, MMO.SFANIM_TYPE_MOUNT_PLAYER, act, extCB, immediate )
  585. end
  586. -----------------------------------------------------------------------------
  587. function actorSequFrameAnimManager:CreateActorMountBodyAnim( mountID, act, extCB, immediate )
  588. return self:createSequFrmAnimAsync( mountID, MMO.SFANIM_TYPE_MOUNT_BODY, act, extCB, immediate )
  589. end
  590. function actorSequFrameAnimManager:ResetActorMountBodyAnim( anim, mountID, act, extCB, immediate )
  591. return self:resetSequFrmAnimAsync( anim, mountID, MMO.SFANIM_TYPE_MOUNT_BODY, act, extCB, immediate )
  592. end
  593. -----------------------------------------------------------------------------
  594. function actorSequFrameAnimManager:CreateActorMountHeadAnim( mountID, act, extCB, immediate )
  595. return self:createSequFrmAnimAsync( mountID, MMO.ACTOR_DEFAULT_SEX, MMO.SFANIM_TYPE_MOUNT_HEAD, act, extCB, immediate )
  596. end
  597. function actorSequFrameAnimManager:ResetActorMountHeadAnim( anim, mountID, act, extCB, immediate )
  598. return self:resetSequFrmAnimAsync( anim, mountID, MMO.ACTOR_DEFAULT_SEX, MMO.SFANIM_TYPE_MOUNT_HEAD, act, extCB, immediate )
  599. end
  600. -----------------------------------------------------------------------------
  601. function actorSequFrameAnimManager:CreateActorMonsterAnim( monsterID, act, extCB, sex, immediate )
  602. return self:createSequFrmAnimAsync( monsterID, sex or MMO.ACTOR_DEFAULT_SEX, MMO.SFANIM_TYPE_MONSTER, act, extCB, immediate )
  603. end
  604. function actorSequFrameAnimManager:ResetActorMonsterAnim( anim, monsterID, act, extCB, sex, immediate )
  605. return self:resetSequFrmAnimAsync( anim, monsterID, sex or MMO.ACTOR_DEFAULT_SEX, MMO.SFANIM_TYPE_MONSTER, act, extCB, immediate )
  606. end
  607. -----------------------------------------------------------------------------
  608. function actorSequFrameAnimManager:CreateActorNpcAnim( npcID, extCB, immediate )
  609. return self:createSequFrmAnimAsync( npcID, MMO.ACTOR_DEFAULT_SEX, MMO.SFANIM_TYPE_NPC, MMO.ANIM_DEFAULT, extCB, immediate )
  610. end
  611. -----------------------------------------------------------------------------
  612. function actorSequFrameAnimManager:CreateSkillEffAnim( skillID, dir, extCB, immediate )
  613. dir = dir or MMO.ORIENT_U
  614. local ret = self:createSequFrmAnimAsync( skillID, MMO.ACTOR_DEFAULT_SEX, MMO.SFANIM_TYPE_SKILL, dir, extCB, immediate )
  615. return ret
  616. end
  617. -----------------------------------------------------------------------------
  618. function actorSequFrameAnimManager:CreateSFXAnim( sfxID, dir, extCB, immediate)
  619. dir = dir or MMO.ORIENT_U
  620. local ret = self:createSequFrmAnimAsync( sfxID, MMO.ACTOR_DEFAULT_SEX, MMO.SFANIM_TYPE_SKILL, dir, extCB, immediate )
  621. return ret
  622. end
  623. -----------------------------------------------------------------------------
  624. function actorSequFrameAnimManager:LoadAnimUnit( animID, animType, unitID )
  625. if animType < 0 or animType > MMO.SFANIM_TYPE_NUM then
  626. return nil
  627. end
  628. if 0 > unitID or unitID > MMO.ANIM_COUNT then
  629. return nil
  630. end
  631. local animDataMgr = self._animDataMgr[animType]
  632. local animDataDesc = animDataMgr[animID]
  633. if animDataDesc then
  634. self:loadSequFrmAnimUnit( animDataDesc, unitID, false )
  635. end
  636. end
  637. -----------------------------------------------------------------------------
  638. function actorSequFrameAnimManager:CheckSequAnimUnused(anim)
  639. local animDataDesc = anim:GetAnimDataDesc()
  640. local animID = animDataDesc.animID
  641. local animType = animDataDesc.animType
  642. local rawAnimID = animDataDesc.rawAnimID
  643. local animRefsMgr = self._animRefsMgr[animType]
  644. local animDataMgr = self._animDataMgr[animType]
  645. local seqFrmAnims = animRefsMgr[ animID ]
  646. if rawAnimID ~= rawTempID and nil == next(seqFrmAnims) then
  647. -- mark unused
  648. animDataDesc:setUnused()
  649. local rawAnimID = animDataDesc.rawAnimID
  650. local sex = animDataDesc.sex
  651. -- print( string.format( "reset, anim is unused:[type:%d][rawAnimID:%d][sex:%d]", animType, rawAnimID, sex ) )
  652. end
  653. end
  654. -----------------------------------------------------------------------------
  655. function actorSequFrameAnimManager:RemoveSequAnim( anim )
  656. -- Mark animation data has loaded.
  657. local animDataDesc = anim:GetAnimDataDesc()
  658. local animID = animDataDesc.animID
  659. local animType = animDataDesc.animType
  660. local rawAnimID = animDataDesc.rawAnimID
  661. local animRefsMgr = self._animRefsMgr[animType]
  662. local animDataMgr = self._animDataMgr[animType]
  663. local seqFrmAnims = animRefsMgr[ animID ]
  664. local refIndex = anim.refIndex
  665. seqFrmAnims[refIndex] = nil
  666. if rawAnimID ~= rawTempID and nil == next(seqFrmAnims) then
  667. -- mark unused
  668. animDataDesc:setUnused()
  669. local rawAnimID = animDataDesc.rawAnimID
  670. local sex = animDataDesc.sex
  671. -- print( string.format( "remove, anim is unused:[type:%d][rawAnimID:%d][sex:%d]", animType, rawAnimID, sex ) )
  672. end
  673. end
  674. -----------------------------------------------------------------------------
  675. function actorSequFrameAnimManager:Tick(dt)
  676. self._globalElapsed = self._globalElapsed + dt
  677. -- Check unsued animation data periodically
  678. if self._forNextUnloadFrame <= 0 then
  679. self:unloadExpiredAnimData()
  680. self._forNextUnloadFrame = 10
  681. end
  682. if self._forNextUnloadFrame > 0 then
  683. self._forNextUnloadFrame = self._forNextUnloadFrame - 1
  684. end
  685. if self._animLoadQueue:size() > 0 and self:CheckAbleLoading() == true then
  686. local loadDesc = self._animLoadQueue:pop()
  687. local loader = loadDesc.loader
  688. local animDataDesc = loadDesc.animDataDesc
  689. local referenced = self:IsReferenced( animDataDesc.animType, animDataDesc.rawAnimID, animDataDesc.sex )
  690. if referenced then
  691. loader:loadSequAnim( animDataDesc, loadDesc.act )
  692. else
  693. animDataDesc.loadStateUnit[loadDesc.act] = MMO.LOAD_STATE_UNLOADING
  694. end
  695. end
  696. end
  697. -----------------------------------------------------------------------------
  698. function actorSequFrameAnimManager:CheckAbleLoading()
  699. return self._loadingCount < self._loadingLimit
  700. end
  701. function actorSequFrameAnimManager:GetLoadingCount()
  702. return self._loadingCount
  703. end
  704. function actorSequFrameAnimManager:AddLoadingCount()
  705. self._loadingCount = self._loadingCount + 1
  706. end
  707. function actorSequFrameAnimManager:DecLoadingCount()
  708. if self._loadingCount > 0 then
  709. self._loadingCount = self._loadingCount - 1
  710. end
  711. end
  712. -----------------------------------------------------------------------------
  713. function actorSequFrameAnimManager:IS_EXPIRED( intvl )
  714. return self._expiredInterval <= intvl
  715. end
  716. -----------------------------------------------------------------------------
  717. function actorSequFrameAnimManager:unloadExpiredAnimData()
  718. local currTime = os.time()
  719. local animDataMgr = nil
  720. for i = 1, MMO.SFANIM_TYPE_NUM do
  721. animDataMgr = self._animDataMgr[i]
  722. for k, animDataDesc in pairs(animDataMgr) do
  723. if not animDataDesc:checkIsInUsed() then
  724. if self:IS_EXPIRED( currTime - animDataDesc.timeStamp ) then
  725. -- unload
  726. print(string.format("Anim data is EXPIRED, ID[%d] TYPE[%s]", animDataDesc.rawAnimID, animTypeName[i]))
  727. self._animLoads[i]:unloadSequAnim( animDataDesc )
  728. animDataMgr[k] = nil
  729. -- reload OOM ANIM
  730. if self:checkMemEnough() then
  731. for animType, animDataMgr in pairs(self._animDataMgr) do
  732. for animID, animDataDesc in pairs(animDataMgr) do
  733. if next(animDataDesc.loadOOMUnit) then
  734. for act, _ in pairs(animDataDesc.loadOOMUnit) do
  735. self:loadAnim(animDataDesc, act)
  736. animDataDesc.loadOOMUnit[act] = nil
  737. break
  738. end
  739. end
  740. end
  741. end
  742. end
  743. -- unload one
  744. return
  745. end
  746. end
  747. end
  748. end
  749. end
  750. -----------------------------------------------------------------------------
  751. function actorSequFrameAnimManager:unloadUnusedAnimData()
  752. local animDataMgr = nil
  753. for i = 1, MMO.SFANIM_TYPE_NUM do
  754. animDataMgr = self._animDataMgr[i]
  755. for k, animDataDesc in pairs(animDataMgr) do
  756. if not animDataDesc:checkIsInUsed() then
  757. -- unload
  758. print(string.format("Anim data is UNUSED, ID[%d] TYPE[%s]", animDataDesc.rawAnimID, animTypeName[i]))
  759. self._animLoads[i]:unloadSequAnim( animDataDesc )
  760. animDataMgr[k] = nil
  761. -- unload one
  762. return true
  763. end
  764. end
  765. end
  766. return false
  767. end
  768. -----------------------------------------------------------------------------
  769. function actorSequFrameAnimManager:unloadUnusedAnimDataByTypeID(sfxType, sfxID)
  770. local animDataMgr = self._animDataMgr[sfxType]
  771. if not animDataMgr then
  772. return false
  773. end
  774. for k, animDataDesc in pairs(animDataMgr) do
  775. if sfxID == animDataDesc.rawAnimID and (not animDataDesc:checkIsInUsed()) then
  776. -- unload
  777. print(string.format("Anim data is UNUSED, ID[%d] TYPE[%s]", sfxID, animTypeName[sfxType]))
  778. self._animLoads[sfxType]:unloadSequAnim( animDataDesc )
  779. animDataMgr[k] = nil
  780. break
  781. end
  782. end
  783. end
  784. -----------------------------------------------------------------------------
  785. function actorSequFrameAnimManager:unloadAllUnusedAnimData()
  786. while true do
  787. if (not self:unloadUnusedAnimData()) then
  788. break
  789. end
  790. end
  791. end
  792. -----------------------------------------------------------------------------
  793. function actorSequFrameAnimManager:unloadAnimDataDesc(animDataDesc)
  794. local animType = animDataDesc.animType
  795. local animDataMgr = self._animDataMgr[animType]
  796. local loader = self._animLoads[animType]
  797. if not loader or not animDataMgr then
  798. return false
  799. end
  800. loader:unloadSequAnim( animDataDesc )
  801. animDataMgr[animType] = nil
  802. end
  803. -----------------------------------------------------------------------------
  804. function actorSequFrameAnimManager:GetAnimTemporaryID( animType, sex )
  805. sex = nil == sex and MMO.ACTOR_DEFAULT_SEX or sex
  806. return self:KEY_ID_SEX( rawTempID, sex, animType )
  807. end
  808. -----------------------------------------------------------------------------
  809. function actorSequFrameAnimManager:GetAnimConfig( animID, animType )
  810. if animType < 0 or animType > MMO.SFANIM_TYPE_NUM then
  811. return nil
  812. end
  813. return self._animLoads[animType]:getConfig( animID )
  814. end
  815. -----------------------------------------------------------------------------
  816. function actorSequFrameAnimManager:GetAnimTotalDuration( rawAnimID, animType, action, sex )
  817. local ret = 0.51 -- default value
  818. sex = nil == sex and MMO.ACTOR_DEFAULT_SEX or sex
  819. rawAnimID = nil == rawAnimID and self:GetAnimTemporaryID( animType, sex ) or rawAnimID
  820. local animID = self:KEY_ID_SEX( rawAnimID, sex, animType )
  821. local config = self:GetAnimConfig( animID, animType )
  822. if not config then -- get temporary config
  823. config = self:GetAnimConfig( self:GetAnimTemporaryID( animType, sex ), animType )
  824. end
  825. if config then
  826. local interval = config.interval[action]
  827. local frame = config.frame[action]
  828. if interval and frame then
  829. ret = interval * frame
  830. end
  831. end
  832. return ret
  833. end
  834. -----------------------------------------------------------------------------
  835. function actorSequFrameAnimManager:IsLoaded( animType, rawAnimID, sex )
  836. if animType <= 0 or animType > MMO.SFANIM_TYPE_NUM then
  837. return false
  838. end
  839. local animID = self:KEY_ID_SEX( rawAnimID, sex, animType )
  840. local itr = self._animRefsMgr[animType][animID]
  841. if itr == nil then
  842. return false
  843. end
  844. return true
  845. end
  846. function actorSequFrameAnimManager:IsReferenced( animType, rawAnimID, sex )
  847. if animType <= 0 or animType > MMO.SFANIM_TYPE_NUM then
  848. return false
  849. end
  850. local animID = self:KEY_ID_SEX( rawAnimID, sex, animType )
  851. local seqFrmAnims = self._animRefsMgr[animType][animID]
  852. if seqFrmAnims and next(seqFrmAnims) ~= nil then
  853. return true
  854. end
  855. return false
  856. end
  857. function actorSequFrameAnimManager:IsNeedOffset( rawAnimID )
  858. return (rawAnimID < 4000 or rawAnimID >= 5000)
  859. end
  860. function actorSequFrameAnimManager:unloadUnusedInOOM()
  861. if not self:isMemCleanup() then
  862. return false
  863. end
  864. self:unloadUnusedAnimData()
  865. return true
  866. end
  867. function actorSequFrameAnimManager:getGlobalElapsed()
  868. return self._globalElapsed
  869. end
  870. function actorSequFrameAnimManager:getAnimFrameVecEmpty()
  871. return self._animFrameVecEmpty
  872. end
  873. function actorSequFrameAnimManager:InitTemporaryPlayer(sex, animType)
  874. local animDataMgr = self._animDataMgr[animType]
  875. local loader = self._animLoads[animType]
  876. local animID = self:KEY_ID_SEX( rawTempID, sex, animType )
  877. local config = self:GetAnimConfig( animID, animType )
  878. local animDataDesc = AnimDataDesc.new( animID, rawTempID, sex, animType )
  879. animDataMgr[animID] = animDataDesc
  880. self:setAnimDataDescByConfig(animDataDesc, config)
  881. for act = 0, global.MMO.ANIM_COUNT - 1 do
  882. if config.interval[act] then
  883. animDataDesc.loadStateUnit[act] = global.MMO.LOAD_STATE_FOREVER
  884. loader:loadSequAnim( animDataDesc, act )
  885. end
  886. end
  887. end
  888. function actorSequFrameAnimManager:InitTemporaryMonster()
  889. local sex = MMO.ACTOR_PLAYER_SEX_M
  890. local animType = MMO.SFANIM_TYPE_MONSTER
  891. local animDataMgr = self._animDataMgr[animType]
  892. local loader = self._animLoads[animType]
  893. local animID = self:KEY_ID_SEX( rawTempID, sex, animType )
  894. local config = self:GetAnimConfig( animID, animType )
  895. local animDataDesc = AnimDataDesc.new( animID, rawTempID, sex, animType )
  896. animDataMgr[animID] = animDataDesc
  897. self:setAnimDataDescByConfig(animDataDesc, config)
  898. for act = MMO.ACTION_IDLE, MMO.ACTION_IDLE_LOCK do
  899. if config.interval[act] then
  900. animDataDesc.loadStateUnit[act] = global.MMO.LOAD_STATE_FOREVER
  901. loader:loadSequAnim( animDataDesc, act )
  902. end
  903. end
  904. end
  905. function actorSequFrameAnimManager:InitTemporaryNpc()
  906. local sex = MMO.ACTOR_PLAYER_SEX_M
  907. local animType = MMO.SFANIM_TYPE_NPC
  908. local animDataMgr = self._animDataMgr[animType]
  909. local loader = self._animLoads[animType]
  910. local animID = self:KEY_ID_SEX( rawTempID, sex, animType )
  911. local config = self:GetAnimConfig( animID, animType )
  912. local animDataDesc = AnimDataDesc.new( animID, rawTempID, sex, animType )
  913. animDataMgr[animID] = animDataDesc
  914. self:setAnimDataDescByConfig(animDataDesc, config)
  915. local tempACT = {
  916. MMO.ANIM_IDLE,
  917. MMO.ACTION_BORN
  918. }
  919. for index, act in ipairs(tempACT) do
  920. if config.interval[act] then
  921. animDataDesc.loadStateUnit[act] = global.MMO.LOAD_STATE_FOREVER
  922. loader:loadSequAnim( animDataDesc, act )
  923. end
  924. end
  925. end
  926. function actorSequFrameAnimManager:InitTemporarySFX()
  927. local sex = MMO.ACTOR_PLAYER_SEX_M
  928. local animType = MMO.SFANIM_TYPE_SKILL
  929. local animDataMgr = self._animDataMgr[animType]
  930. local loader = self._animLoads[animType]
  931. local animID = self:KEY_ID_SEX( rawTempID, sex, animType )
  932. local config = self:GetAnimConfig( animID, animType )
  933. local animDataDesc = AnimDataDesc.new( animID, rawTempID, sex, animType )
  934. animDataMgr[animID] = animDataDesc
  935. self:setAnimDataDescByConfig(animDataDesc, config)
  936. local tempACT = {
  937. MMO.ANIM_IDLE,
  938. }
  939. for index, act in ipairs(tempACT) do
  940. if config.interval[act] then
  941. animDataDesc.loadStateUnit[act] = global.MMO.LOAD_STATE_FOREVER
  942. loader:loadSequAnim( animDataDesc, act )
  943. end
  944. end
  945. end
  946. return actorSequFrameAnimManager