예제 #1
0
        public AddRemoveGhostBlockUndoInstance(EditorUndoManager parent, GhostBlockInstance obj, bool created) : base(parent, obj.Room)
        {
            Created    = created;
            UndoObject = obj;

            Valid = () => UndoObject != null && ((Created && UndoObject.Room != null) ||
                                                 (!Created && Room.ExistsInLevel)) && !Room.CoordinateInvalid(UndoObject.SectorPosition);

            UndoAction = () =>
            {
                if (Created)
                {
                    EditorActions.DeleteObjectWithoutUpdate(UndoObject);
                }
                else
                {
                    var backupPos = obj.SectorPosition; // Preserve original position and reassign it after placement
                    EditorActions.PlaceGhostBlockWithoutUpdate(Room, obj.SectorPosition, UndoObject);
                }
            };

            RedoInstance = () =>
            {
                var result = new AddRemoveGhostBlockUndoInstance(Parent, UndoObject, !Created);
                result.Room = Room; // Relink parent room
                return(result);
            };
        }
예제 #2
0
        public TransformGhostBlockUndoInstance(EditorUndoManager parent, GhostBlockInstance obj) : base(parent, obj.Room)
        {
            UndoObject = obj;
            Floor      = obj.Floor;
            Ceiling    = obj.Ceiling;

            Valid = () => UndoObject != null && UndoObject.Room != null && Room.ExistsInLevel &&
                    !Room.CoordinateInvalid(UndoObject.SectorPosition);

            UndoAction = () =>
            {
                UndoObject.Floor   = Floor;
                UndoObject.Ceiling = Ceiling;
                Parent.Editor.ObjectChange(UndoObject, ObjectChangeType.Change);
            };
            RedoInstance = () => new TransformGhostBlockUndoInstance(Parent, UndoObject);
        }
예제 #3
0
 public void PushGhostBlockTransformed(GhostBlockInstance obj) => Push(new TransformGhostBlockUndoInstance(this, obj));
예제 #4
0
 public void PushGhostBlockDeleted(GhostBlockInstance obj) => Push(new AddRemoveGhostBlockUndoInstance(this, obj, false));
예제 #5
0
 public void PushGhostBlockCreated(GhostBlockInstance obj) => Push(new AddRemoveGhostBlockUndoInstance(this, obj, true));