12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- using UnityEngine;
- using YooAsset;
- using static FairyGUI.ControllerAction;
- namespace GFGGame
- {
- //换装部件移除行为的操作器,负责缓存一个移除行为,有可能在后续的逻辑中被覆盖或取消
- public class DressUpRemoveOperation : DressUpOperationBase
- {
- internal int itemID;
- internal GameObject parentObj;
- public DressUpRemoveOperation(int itemID, GameObject parentObj)
- {
- this.itemID = itemID;
- this.parentObj = parentObj;
- //LogUtil.LogEditor($"remove init {itemID}");
- }
- internal override void Release()
- {
- this.parentObj = null;
- }
- internal override void Start()
- {
- Status = EOperationStatus.Succeed;
- }
- internal override void Update()
- {
-
- }
- internal override void Cancel()
- {
- Status = EOperationStatus.Failed;
- Error = "User cancel.";
- }
- internal override bool CheckRepeated(DressUpOperationBase t)
- {
- DressUpLayerOperation layerOperation = t as DressUpLayerOperation;
- if (layerOperation != null && layerOperation.actionType == DressUpLayerOperation.EAction.Layer)
- {
- return (layerOperation.itemCfg != null
- && this.itemID == layerOperation.itemCfg.id
- && this.parentObj == layerOperation.parentObj);
- }
- var removeOperation = t as DressUpRemoveOperation;
- return (removeOperation != null
- && removeOperation.itemID == this.itemID
- && removeOperation.parentObj == this.parentObj);
- }
- internal override void UpdateView()
- {
- if(parentObj == null)
- {
- this.Release();
- return;
- }
- //LogUtil.LogEditor($"remove UpdateView {itemID}");
- DressUpUtil.RemoveItem(this.itemID, this.parentObj);
- }
- }
- }
|