Sharplike.Editlike.MapTools.SquareChange.AddOperation C# (CSharp) Method

AddOperation() public method

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.
return void
        public void AddOperation(AbstractSquare oldSquare, AbstractSquare newSquare, Vector3 location)
        {
            if (!changes.ContainsKey(location) && oldSquare != newSquare)
            {
                SquareChanged c = new SquareChanged();
                c.oldSquare = oldSquare;
                c.newSquare = newSquare;
                changes.Add(location, c);
            }
        }

Usage Example

Example #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);
        }
All Usage Examples Of Sharplike.Editlike.MapTools.SquareChange::AddOperation