AddOperation() 공개 메소드

Adds a square change operation. This does not actually change the square, but rather stores the modification for handing in undo and redo.
public AddOperation ( AbstractSquare oldSquare, AbstractSquare newSquare, System.Vector3 location ) : void
oldSquare Sharplike.Mapping.AbstractSquare The square that was previously at the map location.
newSquare Sharplike.Mapping.AbstractSquare The new square being placed at the map location.
location System.Vector3 The location on the map that this operation takes place.
리턴 void
예제 #1
0
        public void End(Point tile)
        {
            if (region == null)
            {
                return;
            }

            EditorExtensionNode node = form.SelectedSquareType();

            if (node != null)
            {
                foreach (Point p in Line(start, tile))
                {
                    Vector3 loc = new Vector3(p.X + form.Map.View.X,
                                              p.Y + form.Map.View.Y, form.Map.View.Z);
                    AbstractSquare sq = (AbstractSquare)node.CreateInstance();
                    change.AddOperation(form.Map.GetSafeSquare(loc), sq, loc);
                    form.Map.SetSquare(loc, sq);
                }
            }
            if (change.Count > 0)
            {
                form.UndoRedo.AddChange(change);
            }

            change = null;

            region.Invalidate();

            region.Dispose();
            region = null;

            form.Map.ViewFrom(form.Map.View, true);
        }
예제 #2
0
        public override void End(Point tile)
        {
            base.End(tile);

            EditorExtensionNode node = form.SelectedSquareType();

            if (node != null)
            {
                for (int y = border.Location.Y; y < border.Location.Y + border.Size.Height; ++y)
                {
                    for (int x = border.Location.X; x < border.Location.X + border.Size.Width; ++x)
                    {
                        if (fill ||
                            (x == border.Location.X || x == border.Location.X + border.Size.Width - 1 ||
                             y == border.Location.Y || y == border.Location.Y + border.Size.Height - 1))
                        {
                            AbstractSquare sq  = (AbstractSquare)node.CreateInstance();
                            Vector3        loc = new Vector3(x + form.Map.View.x,
                                                             y + form.Map.View.y, form.Map.View.z);

                            change.AddOperation(form.Map.GetSafeSquare(loc), sq, loc);
                            form.Map.SetSquare(loc, sq);
                        }
                    }
                }
            }
            if (change.Count > 0)
            {
                form.UndoRedo.AddChange(change);
            }

            change = null;
            form.Map.ViewFrom(form.Map.View, true);
        }
예제 #3
0
        public void Run(Point tile)
        {
            if (tile != lastloc)
            {
                Vector3 squareloc = new Vector3(tile.X + form.Map.View.X,
                                                tile.Y + form.Map.View.Y, form.Map.View.Z);
                EditorExtensionNode node = form.SelectedSquareType();
                if (node != null)
                {
                    AbstractSquare sq = (AbstractSquare)node.CreateInstance();
                    change.AddOperation(form.Map.GetSafeSquare(squareloc), sq, squareloc);
                    form.Map.SetSquare(squareloc, sq);
                }
                form.Map.InvalidateTiles(new Rectangle(tile, new Size(1, 1)));
                form.Map.ViewFrom(form.Map.View, true);

                lastloc = tile;
            }
        }
예제 #4
0
        public void End(Point tile)
        {
            Vector3 start = new Vector3(tile.X + form.Map.View.X,
                                        tile.Y + form.Map.View.Y, form.Map.View.Z);
            EditorExtensionNode node = form.SelectedSquareType();
            AbstractSquare      sq   = form.Map.GetSafeSquare(start);

            if (sq != null && node != null && !sq.GetType().Equals(node.Type))
            {
                foreach (Vector3 v in Flood(form.Map, start))
                {
                    AbstractSquare square = (AbstractSquare)node.CreateInstance();
                    change.AddOperation(form.Map.GetSafeSquare(v), square, v);
                    form.Map.SetSquare(v, square);
                }
            }
            form.Map.ViewFrom(form.Map.View, true);
            if (change.Count > 0)
            {
                form.UndoRedo.AddChange(change);
            }
            change = null;
        }