DressUpObj.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. using System;
  4. using System.Linq;
  5. using ET;
  6. using FairyGUI;
  7. using ProtoBuf.Meta;
  8. namespace GFGGame
  9. {
  10. public enum DressUpOption
  11. {
  12. Auto,
  13. Add,
  14. Remove
  15. }
  16. public class DressUpObj
  17. {
  18. public int bgId
  19. {
  20. get
  21. {
  22. return _dressUpData.bgId;
  23. }
  24. }
  25. public int suitId
  26. {
  27. get
  28. {
  29. return _dressUpData.suitId;
  30. }
  31. }
  32. public int actionId
  33. {
  34. get
  35. {
  36. return _dressUpData.actionId;
  37. }
  38. }
  39. public bool IsAction
  40. {
  41. get
  42. {
  43. return _dressUpData.actionId > 0;
  44. }
  45. }
  46. public List<int> itemList
  47. {
  48. get
  49. {
  50. return _dressUpData.itemList.ToList();
  51. }
  52. }
  53. private Action onUpdateAction;
  54. /// <summary>
  55. ///
  56. /// </summary>
  57. /// <param name="sceneObj"></param>
  58. /// <param name="needSetMask"></param>
  59. /// <param name="showSceneType"></param>
  60. /// <param name="roleObj"></param>
  61. /// <param name="showBg"></param>
  62. /// <param name="resetData">是否重置装备数据</param>
  63. public void setSceneObj(GameObject sceneObj, bool needSetMask = false, bool showSceneType = true, GameObject roleObj = null, bool showBg = true, Action onUpdateAction = null)
  64. {
  65. if (_sceneObj != null && _sceneObj != sceneObj)
  66. {
  67. PrefabManager.Instance.Restore(_sceneObj);
  68. }
  69. _sceneObj = sceneObj;
  70. _needSetMask = needSetMask;
  71. _showSceneType = showSceneType;
  72. _showBg = showBg;
  73. _roleObj = roleObj;
  74. this.onUpdateAction = onUpdateAction;
  75. if (_dressUpData.IsNew)
  76. {
  77. PutOnDefaultDressUpData(_showBg);
  78. }
  79. else
  80. {
  81. var tempData = DressUpDataClone();
  82. TakeOffAll(false);
  83. PutOnDressUpData(tempData);
  84. }
  85. Timers.inst.AddUpdate(OnUpdate);
  86. }
  87. public DressUpData DressUpDataClone()
  88. {
  89. return _dressUpData.Clone();
  90. }
  91. public void Dispose()
  92. {
  93. _sceneObj = null;
  94. _dressUpData = null;
  95. Timers.inst.Remove(OnUpdate);
  96. foreach (var t in handlers)
  97. {
  98. t.Release();
  99. }
  100. onUpdateAction = null;
  101. }
  102. private void ClearView()
  103. {
  104. Timers.inst.Remove(OnUpdate);
  105. foreach (var t in handlers)
  106. {
  107. t.Cancel();
  108. t.Release();
  109. }
  110. }
  111. //传入一个服装部件Id,判断是否有与此部件同类型服装已穿着
  112. public bool CheckSameTypeIsOn(int itemId)
  113. {
  114. int subType = ItemUtilCS.GetItemSubType(itemId);
  115. for (int i = 0; i < _dressUpData.itemList.Count; i++)
  116. {
  117. int _subType = ItemUtilCS.GetItemSubType(_dressUpData.itemList[i]);
  118. if (subType == _subType) return true;
  119. }
  120. return false;
  121. }
  122. /// <summary>
  123. /// 仅判断换装部件是否已穿着
  124. /// </summary>
  125. /// <param name="itemId"></param>
  126. /// <returns></returns>
  127. public bool CheckDressUpItemIsOn(int itemId)
  128. {
  129. if (itemId == _dressUpData.bgId)
  130. {
  131. return true;
  132. }
  133. return _dressUpData.itemList.Contains(itemId);
  134. }
  135. /// <summary>
  136. /// 仅判断套装是否穿上
  137. /// </summary>
  138. /// <param name="id"></param>
  139. /// <returns></returns>
  140. public bool CheckSuitIsOn(int id)
  141. {
  142. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(id);
  143. if (suitCfg == null)
  144. {
  145. return false;
  146. }
  147. int[] items = suitCfg.partsArr;
  148. foreach (int itemId in items)
  149. {
  150. if (_dressUpData.actionId == id)
  151. {
  152. if (SuitCfgArray.Instance.CheckActionContainsItem(itemId, id))
  153. {
  154. continue;
  155. }
  156. }
  157. bool isOn = CheckDressUpItemIsOn(itemId);
  158. if (!isOn)
  159. {
  160. return false;
  161. }
  162. }
  163. return true;
  164. }
  165. public void AddOrRemove(int itemId, bool checkDefault, DressUpOption dressUpOption = DressUpOption.Auto)
  166. {
  167. int subType = ItemUtilCS.GetItemSubType(itemId);
  168. if (subType == ConstDressUpItemType.BEI_JING)
  169. {
  170. if (!_showBg)
  171. {
  172. return;
  173. }
  174. _dressUpData.bgId = itemId;
  175. List<DressUpLayerOperation> handlers = DressUpUtil.AddItemAsync(_dressUpData.bgId, _sceneObj, _needSetMask, true, _roleObj);
  176. TryAddHandlers(handlers);
  177. }
  178. else
  179. {
  180. if (!CheckDressUpItemIsOn(itemId))
  181. {
  182. if (dressUpOption != DressUpOption.Remove)
  183. {
  184. if (checkDefault)
  185. {
  186. TryCancelActionWhenPutOn(itemId);
  187. }
  188. CheckRemoveSameType(subType);
  189. Add(itemId);
  190. }
  191. }
  192. else
  193. {
  194. if (dressUpOption != DressUpOption.Add)
  195. {
  196. Remove(itemId);
  197. }
  198. }
  199. if (checkDefault)
  200. {
  201. checkDefaultItem();
  202. }
  203. }
  204. }
  205. //脱掉所有换装,换成默认装(不处理背景)
  206. public void TakeOffAll(bool checkDefault = true)
  207. {
  208. if(_sceneObj == null)
  209. {
  210. return;
  211. }
  212. _dressUpData.suitId = 0;
  213. _dressUpData.actionId = 0;
  214. foreach (int itemID in itemList)
  215. {
  216. AddOrRemove(itemID, false, DressUpOption.Remove);
  217. }
  218. if (checkDefault)
  219. {
  220. checkDefaultItem();
  221. }
  222. RoleLevelCfg roleLevelCfg = RoleLevelCfgArray.Instance.GetCfg(GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl));
  223. // FightDataManager.Instance.score = roleLevelCfg.baseScore;
  224. // foreach (int itemId in _dressUpData.itemList)
  225. // {
  226. // FightDataManager.Instance.score += ItemDataManager.GetItemAdditionScore(itemId, InstanceZonesDataManager.currentScoreType, InstanceZonesDataManager.currentFightTags);
  227. // }
  228. }
  229. //穿上或脱掉一个动作
  230. public void PutOnOrTakeOffAction(int actionId)
  231. {
  232. if (_dressUpData.actionId == actionId)
  233. {
  234. CancelAction();
  235. }
  236. else
  237. {
  238. PutOnAction(actionId);
  239. }
  240. }
  241. /// <summary>
  242. /// 尝试穿戴配置套装
  243. /// </summary>
  244. /// <param name="suitId">套装id</param>
  245. /// <param name="tryShowAction">尝试穿上动作</param>
  246. /// <param name="excludeType">排除类型列表</param>
  247. /// <param name="showOptional">是否显示可选部件</param>
  248. /// <param name="CheckOwn">是否只显示主角拥有的部件</param>
  249. public void PutOnSuitCfg(int suitId, bool tryShowAction, int[] excludeType = null, bool showOptional = true, bool CheckOwn = true)
  250. {
  251. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(suitId);
  252. if(suitCfg == null)
  253. {
  254. return;
  255. }
  256. bool oldIsAction = IsAction;
  257. _dressUpData.suitId = suitId;
  258. bool hasSuitActionRes = DressUpMenuSuitDataManager.CheckSuitHasActionRes(_dressUpData.suitId);
  259. _dressUpData.actionId = (hasSuitActionRes && tryShowAction) ? suitId : 0;
  260. //找到要穿的散件
  261. List<int> targetItemList = DressUpUtil.GetSuitItems(suitId, IsAction, excludeType, showOptional, CheckOwn);
  262. CompareAndAddItemList(oldIsAction, IsAction, targetItemList);
  263. checkDefaultItem();
  264. }
  265. /// <summary>
  266. /// 取消动作,默认直接脱下
  267. /// </summary>
  268. /// <param name="changeToStand">转换成站立动作</param>
  269. /// <param name="excludeType">转换成站立动作时排除一些类型不穿</param>
  270. public void CancelAction(bool changeToStand = false, int[] excludeType = null)
  271. {
  272. if (_dressUpData.actionId <= 0)
  273. {
  274. return;
  275. }
  276. var tempActionId = _dressUpData.actionId;
  277. _dressUpData.actionId = 0;
  278. //更新非场景类型部件形态
  279. foreach (int itemId in itemList)
  280. {
  281. if (!DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(itemId))
  282. {
  283. //场景类型不受动作影响并且本来就有动画,对非场景类型处理
  284. bool notInAction = SuitCfgArray.Instance.CheckItemNotInAction(itemId);
  285. if (notInAction)
  286. {
  287. //更新成图片模式
  288. Update(itemId);
  289. }
  290. }
  291. }
  292. if (changeToStand)
  293. {
  294. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(tempActionId);
  295. List<int> items = new List<int>(suitCfg.partsArr);
  296. if (suitCfg.partsOptionalArr != null && suitCfg.partsOptionalArr.Length > 0)
  297. {
  298. items.AddRange(suitCfg.partsOptionalArr);
  299. }
  300. foreach (int itemId in items)
  301. {
  302. if (DressUpMenuItemDataManager.CheckHasItem(itemId))
  303. {
  304. bool notInAction = SuitCfgArray.Instance.CheckItemNotInAction(itemId);
  305. if (!notInAction)
  306. {
  307. int subType = ItemDataManager.GetItemSubType(itemId);
  308. if (excludeType == null || Array.IndexOf(excludeType, subType) < 0)
  309. {
  310. AddOrRemove(itemId, false, DressUpOption.Add);
  311. }
  312. }
  313. }
  314. }
  315. }
  316. checkDefaultItem();
  317. }
  318. //穿戴一组换装数据
  319. public void PutOnDressUpData(DressUpData targetDressUpData, int[] excludeType = null)
  320. {
  321. bool oldIsAction = IsAction;
  322. _dressUpData.suitId = targetDressUpData.suitId;
  323. _dressUpData.actionId = targetDressUpData.actionId;
  324. var targetItemList = new List<int>();
  325. foreach(var itemId in targetDressUpData.itemList)
  326. {
  327. int subType = ItemUtilCS.GetItemSubType(itemId);
  328. if (excludeType == null || Array.IndexOf(excludeType, subType) < 0)
  329. {
  330. targetItemList.Add(itemId);
  331. }
  332. }
  333. if (targetDressUpData.bgId > 0 && (excludeType == null || Array.IndexOf(excludeType, ConstDressUpItemType.BEI_JING) < 0))
  334. {
  335. targetItemList.Add(targetDressUpData.bgId);
  336. }
  337. CompareAndAddItemList(oldIsAction, IsAction, targetItemList);
  338. checkDefaultItem();
  339. }
  340. //穿戴默认换装数据
  341. public void PutOnDefaultDressUpData(bool bgType = false)
  342. {
  343. var dressUpData = DressUpData.CreateDefault();
  344. if (bgType) {
  345. dressUpData.bgId = 180002;
  346. }
  347. PutOnDressUpData(dressUpData);
  348. }
  349. //穿戴一组散件数据(会脱掉不包含的部分)
  350. public void PutOnItemList(List<int> targetItemList)
  351. {
  352. bool oldIsAction = IsAction;
  353. _dressUpData.suitId = 0;
  354. _dressUpData.actionId = 0;
  355. CompareAndAddItemList(oldIsAction, IsAction, targetItemList);
  356. checkDefaultItem();
  357. }
  358. #region private
  359. private GameObject _sceneObj;
  360. private GameObject _roleObj;
  361. private bool _needSetMask;
  362. private bool _showSceneType = true;
  363. private bool _showBg = true;
  364. private DressUpData _dressUpData = new DressUpData();
  365. private List<DressUpOperationBase> handlers = new List<DressUpOperationBase>();
  366. //穿上一个动作
  367. private void PutOnAction(int actionId)
  368. {
  369. bool hasSuitActionRes = DressUpMenuSuitDataManager.CheckSuitHasActionRes(actionId);
  370. _dressUpData.actionId = actionId;
  371. if (hasSuitActionRes)
  372. {
  373. foreach (int itemId in itemList)
  374. {
  375. if (!DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(itemId))
  376. {
  377. //场景类型不受动作影响并且本来就有动画,对非场景类型处理
  378. bool notInAction = SuitCfgArray.Instance.CheckItemNotInAction(itemId);
  379. if (notInAction)
  380. {
  381. //更新成动画模式
  382. Update(itemId);
  383. }
  384. else
  385. {
  386. AddOrRemove(itemId, false, DressUpOption.Remove);
  387. }
  388. }
  389. }
  390. }
  391. else
  392. {
  393. CancelAction(true);
  394. }
  395. checkDefaultItem();
  396. }
  397. //当穿一件部件时检查是否需要取消动作,如果需要则取消该动作
  398. private void TryCancelActionWhenPutOn(int itemId)
  399. {
  400. if (_dressUpData.actionId > 0)
  401. {
  402. bool replaceableByAction = SuitCfgArray.Instance.CheckItemReaplaceableOnAction(itemId, _dressUpData.actionId);
  403. if (!replaceableByAction)
  404. {
  405. CancelAction();
  406. _dressUpData.actionId = 0;
  407. }
  408. }
  409. }
  410. private void Add(int itemId)
  411. {
  412. if (!_showSceneType)
  413. {
  414. if (DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(itemId))
  415. {
  416. return;
  417. }
  418. }
  419. if (!_dressUpData.itemList.Contains(itemId))
  420. {
  421. _dressUpData.itemList.Add(itemId);
  422. Update(itemId);
  423. }
  424. }
  425. private void Update(int itemId)
  426. {
  427. bool showAni = IsAction || DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(itemId);
  428. var handlers = DressUpUtil.AddItemAsync(itemId, _sceneObj, _needSetMask, showAni, _roleObj);
  429. TryAddHandlers(handlers);
  430. }
  431. private void Remove(int itemId)
  432. {
  433. if (_dressUpData.itemList == null)
  434. {
  435. return;
  436. }
  437. if (_dressUpData.itemList.Contains(itemId))
  438. {
  439. _dressUpData.itemList.Remove(itemId);
  440. var handler = DressUpUtil.RemoveItemAsync(itemId, _sceneObj, _roleObj);
  441. TryAddHandler(handler);
  442. }
  443. }
  444. private void CheckRemoveSameType(int subType)
  445. {
  446. int count = 0;
  447. int firstTeshuId = 0;
  448. for (int i = 0; i < _dressUpData.itemList.Count; i++)
  449. {
  450. int itemID = (int)_dressUpData.itemList[i];
  451. int itemSubType = ItemUtilCS.GetItemSubType(itemID);
  452. if (itemSubType == subType
  453. || (subType == ConstDressUpItemType.LIAN_YI_QUN && (itemSubType == ConstDressUpItemType.SHANG_YI || itemSubType == ConstDressUpItemType.XIA_ZHUANG || itemSubType == ConstDressUpItemType.NEI_DA))
  454. || (subType == ConstDressUpItemType.SHANG_YI && itemSubType == ConstDressUpItemType.LIAN_YI_QUN)
  455. || (subType == ConstDressUpItemType.XIA_ZHUANG && itemSubType == ConstDressUpItemType.LIAN_YI_QUN)
  456. || (subType == ConstDressUpItemType.NEI_DA && itemSubType == ConstDressUpItemType.LIAN_YI_QUN))
  457. {
  458. Remove(itemID);
  459. i--;
  460. }
  461. if (itemSubType > ConstDressUpItemType.TE_SHU)
  462. {
  463. if (count == 0)
  464. {
  465. firstTeshuId = itemID;
  466. }
  467. count++;
  468. }
  469. }
  470. if (subType > ConstDressUpItemType.TE_SHU && count >= 3)
  471. {
  472. //特殊饰品最多穿三件,第四件会自动顶掉第一件
  473. Remove(firstTeshuId);
  474. }
  475. }
  476. //与身上的散件对比差异然后添加
  477. private void CompareAndAddItemList(bool oldIsAction, bool newIsAction, List<int> targetItemList)
  478. {
  479. bool actionStatusChanged = (oldIsAction && !newIsAction) || (!oldIsAction && newIsAction);
  480. foreach (int itemID in itemList)
  481. {
  482. if (!targetItemList.Contains(itemID))
  483. {
  484. //移除不穿的部件
  485. AddOrRemove(itemID, false, DressUpOption.Remove);
  486. }
  487. else if (actionStatusChanged)
  488. {
  489. //当动画形态切换时
  490. if (!DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(itemID))
  491. {
  492. //非场景类型重穿
  493. Update(itemID);
  494. targetItemList.Remove(itemID);
  495. }
  496. }
  497. }
  498. foreach (int itemID in targetItemList)
  499. {
  500. AddOrRemove(itemID, false, DressUpOption.Add);
  501. }
  502. }
  503. //检测当前穿戴是否是一件完整套装,且只穿了一件套装,返回套装id
  504. private int CheckCurDressIsSuit()
  505. {
  506. var suitId = 0;
  507. var suitIdList = new List<int>();
  508. for (int i = 0; i < _dressUpData.itemList.Count; i++)
  509. {
  510. int itemSuitId = SuitCfgArray.Instance.GetSuitIdOfItem(_dressUpData.itemList[i]);
  511. if (!suitIdList.Contains(itemSuitId))
  512. {
  513. suitIdList.Add(itemSuitId);
  514. }
  515. }
  516. foreach (var itemSuitId in suitIdList)
  517. {
  518. if (CheckSuitIsOn(itemSuitId))
  519. {
  520. suitId = itemSuitId;
  521. break;
  522. }
  523. }
  524. _dressUpData.suitId = suitId;
  525. return _dressUpData.suitId;
  526. }
  527. private void checkDefaultItem()
  528. {
  529. //是否有头发
  530. bool hasFaXing = false;
  531. //检查默认资源
  532. //是否有连衣裙
  533. int itemIdLianYiQun = 0;
  534. //是否有内搭
  535. bool hasNeiDa = false;
  536. //是否有上衣
  537. bool hasShangYi = false;
  538. //是否有下装
  539. bool hasXiaZhuang = false;
  540. //是否有默认内搭
  541. bool hasNeiDaDefault = false;
  542. //是否有默认下装
  543. bool hasXiaZhuangDefault = false;
  544. //是否有妆容
  545. bool hasZhuangRong = false;
  546. for (int i = 0; i < _dressUpData.itemList.Count; i++)
  547. {
  548. int itemID = (int)_dressUpData.itemList[i];
  549. int subType = ItemUtilCS.GetItemSubType(itemID);
  550. if (subType == (int)ConstDressUpItemType.FA_XING)
  551. {
  552. hasFaXing = true;
  553. }
  554. else if (subType == ConstDressUpItemType.LIAN_YI_QUN)
  555. {
  556. itemIdLianYiQun = itemID;
  557. }
  558. else if (subType == ConstDressUpItemType.NEI_DA)
  559. {
  560. hasNeiDa = true;
  561. }
  562. else if (subType == ConstDressUpItemType.XIA_ZHUANG)
  563. {
  564. hasXiaZhuang = true;
  565. }
  566. else if (subType == ConstDressUpItemType.SHANG_YI)
  567. {
  568. hasShangYi = true;
  569. }
  570. else if (subType == ConstDressUpItemType.ZHUANG_RONG)
  571. {
  572. hasZhuangRong = true;
  573. }
  574. if (itemID == ConstItemID.DEFULT_NEI_DA)
  575. {
  576. hasNeiDaDefault = true;
  577. }
  578. else if (itemID == ConstItemID.DEFULT_XIA_ZHUANG)
  579. {
  580. hasXiaZhuangDefault = true;
  581. }
  582. }
  583. if (!hasFaXing)
  584. {
  585. Add(ConstItemID.DEFULT_FA_XING);
  586. }
  587. if (!IsAction)
  588. {
  589. if (itemIdLianYiQun <= 0)
  590. {
  591. if (!hasShangYi && (!hasNeiDa || hasNeiDaDefault) && (!hasXiaZhuang || hasXiaZhuangDefault))
  592. {
  593. Remove(ConstItemID.DEFULT_XIA_ZHUANG);
  594. Remove(ConstItemID.DEFULT_NEI_DA);
  595. Add(ConstItemID.DEFULT_LIAN_YI_QUN);
  596. }
  597. else
  598. {
  599. if (!hasXiaZhuang)
  600. {
  601. Add(ConstItemID.DEFULT_XIA_ZHUANG);
  602. }
  603. if (!hasNeiDa)
  604. {
  605. Add(ConstItemID.DEFULT_NEI_DA);
  606. }
  607. }
  608. }
  609. }
  610. CheckCurDressIsSuit();
  611. var handler = DressUpUtil.UpdateHeadAsync(!hasZhuangRong, _sceneObj, _needSetMask, _roleObj);
  612. TryAddHandler(handler);
  613. UpdateBodyView(itemIdLianYiQun);
  614. }
  615. //更新整个身体
  616. private void UpdateBodyView(int itemIdLianYiQun)
  617. {
  618. string actionRes = null;
  619. if (IsAction)
  620. {
  621. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_dressUpData.actionId);
  622. var hasAniRes = ResPathUtil.CheckDressUpAnimationResExist(suitCfg.aniRes);
  623. actionRes = hasAniRes ? suitCfg.aniRes : null;
  624. }
  625. var handler = DressUpUtil.UpdateBodyAsync(actionRes, _sceneObj, _needSetMask, _roleObj, itemIdLianYiQun);
  626. TryAddHandler(handler);
  627. }
  628. private void OnUpdate(object param = null)
  629. {
  630. if(_sceneObj == null)
  631. {
  632. ClearView();
  633. return;
  634. }
  635. if(handlers != null && handlers.Count > 0)
  636. {
  637. bool draw = true;
  638. foreach(var handler in handlers)
  639. {
  640. if(!handler.IsDone)
  641. {
  642. draw = false;
  643. }
  644. }
  645. if(draw)
  646. {
  647. var t = handlers.ToArray();
  648. handlers.Clear();
  649. foreach (var handler in t)
  650. {
  651. if(handler.Status == YooAsset.EOperationStatus.Succeed)
  652. {
  653. handler.UpdateView();
  654. }
  655. handler.Release();
  656. }
  657. onUpdateAction?.Invoke();
  658. //LogUtil.LogEditor($"draw {TimeHelper.ClientNow()}");
  659. }
  660. }
  661. }
  662. private void TryAddHandlers(List<DressUpLayerOperation> t)
  663. {
  664. if (t != null)
  665. {
  666. foreach(var h in t)
  667. {
  668. TryAddHandler(h);
  669. }
  670. //this.handlers.AddRange(t);
  671. }
  672. }
  673. private void TryAddHandler(DressUpOperationBase t)
  674. {
  675. if (t != null)
  676. {
  677. var len = handlers.Count;
  678. for (var i = len - 1; i >= 0; i--)
  679. {
  680. var h = handlers[i];
  681. if (h.CheckRepeated(t))
  682. {
  683. h.Cancel();
  684. h.Release();
  685. handlers.RemoveAt(i);
  686. }
  687. }
  688. this.handlers.Add(t);
  689. }
  690. }
  691. #endregion
  692. }
  693. }