DressUpRemoveOperation.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using UnityEngine;
  2. using YooAsset;
  3. using static FairyGUI.ControllerAction;
  4. namespace GFGGame
  5. {
  6. public class DressUpRemoveOperation : DressUpOperationBase
  7. {
  8. internal int itemID;
  9. internal GameObject parentObj;
  10. public DressUpRemoveOperation(int itemID, GameObject parentObj)
  11. {
  12. this.itemID = itemID;
  13. this.parentObj = parentObj;
  14. //LogUtil.LogEditor($"remove init {itemID}");
  15. }
  16. internal override void Release()
  17. {
  18. this.parentObj = null;
  19. }
  20. internal override void Start()
  21. {
  22. Status = EOperationStatus.Succeed;
  23. }
  24. internal override void Update()
  25. {
  26. }
  27. internal override void Cancel()
  28. {
  29. Status = EOperationStatus.Failed;
  30. Error = "User cancel.";
  31. }
  32. internal override bool CheckRepeated(DressUpOperationBase t)
  33. {
  34. DressUpLayerOperation layerOperation = t as DressUpLayerOperation;
  35. if (layerOperation != null && layerOperation.actionType == DressUpLayerOperation.EAction.Layer)
  36. {
  37. return (layerOperation.itemCfg != null
  38. && this.itemID == layerOperation.itemCfg.id
  39. && this.parentObj == layerOperation.parentObj);
  40. }
  41. var removeOperation = t as DressUpRemoveOperation;
  42. return (removeOperation != null
  43. && removeOperation.itemID == this.itemID
  44. && removeOperation.parentObj == this.parentObj);
  45. }
  46. internal override void UpdateView()
  47. {
  48. if(parentObj == null)
  49. {
  50. this.Release();
  51. return;
  52. }
  53. //LogUtil.LogEditor($"remove UpdateView {itemID}");
  54. DressUpUtil.RemoveItem(this.itemID, this.parentObj);
  55. }
  56. }
  57. }