"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MoveTransformUndoRedo = void 0;
const core_1 = require("@vived/core");
const Dispatcher_1 = require("../../Dispatcher");
const UndoRedo_1 = require("../../UndoRedo");
class MoveTransformUndoRedo {
    constructor(dto, transform, appObjects) {
        this.dto = dto;
        this.transform = transform;
        this.undoAction = () => {
            this.transform.localPosition = this.dto.startPosition;
            this.transform.localRotation = this.dto.startRotation;
            this.dispatchStateChange?.doDispatch();
        };
        this.redoAction = () => {
            this.transform.localPosition = this.dto.endPosition;
            this.transform.localRotation = this.dto.endRotation;
            this.dispatchStateChange?.doDispatch();
        };
        if (core_1.Vector3.Close(dto.startPosition, dto.endPosition) &&
            core_1.Quaternion.Close(dto.startRotation, dto.endRotation)) {
            return;
        }
        this.dispatchStateChange = Dispatcher_1.DispatchStateChangeUC.get(appObjects);
        if (!this.dispatchStateChange) {
            appObjects.submitWarning("MoveTransformUndoRedo", "Unable to find DispatchStateChangeUC");
            return;
        }
        const undoRedo = UndoRedo_1.UndoRedoEntity.get(appObjects);
        if (!undoRedo) {
            appObjects.submitWarning("MoveTransformUndoRedo", "Unable to find UndoRedoEntity");
            return;
        }
        undoRedo.submitAction(this);
    }
}
exports.MoveTransformUndoRedo = MoveTransformUndoRedo;
//# sourceMappingURL=MoveTransformUndoRedo.js.map