DressUpRemoveOperation.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using UnityEngine;
  2. using YooAsset;
  3. using static FairyGUI.ControllerAction;
  4. namespace GFGGame
  5. {
  6. //换装部件移除行为的操作器,负责缓存一个移除行为,有可能在后续的逻辑中被覆盖或取消
  7. public class DressUpRemoveOperation : DressUpOperationBase
  8. {
  9. internal int itemID;
  10. internal GameObject parentObj;
  11. public DressUpRemoveOperation(int itemID, GameObject parentObj)
  12. {
  13. this.itemID = itemID;
  14. this.parentObj = parentObj;
  15. //LogUtil.LogEditor($"remove init {itemID}");
  16. }
  17. internal override void Release()
  18. {
  19. this.parentObj = null;
  20. }
  21. internal override void Start()
  22. {
  23. Status = EOperationStatus.Succeed;
  24. }
  25. internal override void Update()
  26. {
  27. }
  28. internal override void Cancel()
  29. {
  30. Status = EOperationStatus.Failed;
  31. Error = "User cancel.";
  32. }
  33. internal override bool CheckRepeated(DressUpOperationBase t)
  34. {
  35. DressUpLayerOperation layerOperation = t as DressUpLayerOperation;
  36. if (layerOperation != null && layerOperation.actionType == DressUpLayerOperation.EAction.Layer)
  37. {
  38. return (layerOperation.itemCfg != null
  39. && this.itemID == layerOperation.itemCfg.id
  40. && this.parentObj == layerOperation.parentObj);
  41. }
  42. var removeOperation = t as DressUpRemoveOperation;
  43. return (removeOperation != null
  44. && removeOperation.itemID == this.itemID
  45. && removeOperation.parentObj == this.parentObj);
  46. }
  47. internal override void UpdateView()
  48. {
  49. if(parentObj == null)
  50. {
  51. this.Release();
  52. return;
  53. }
  54. //LogUtil.LogEditor($"remove UpdateView {itemID}");
  55. DressUpUtil.RemoveItem(this.itemID, this.parentObj);
  56. }
  57. }
  58. }