public void PerformTool(clsAction Tool)
 {
     foreach (var point in ChangedPoints)
     {
         Tool.PosNum = point;
         Tool.ActionPerform();
     }
 }
Beispiel #2
0
        private void PerformAction(clsAction action, sPosNum posNum, XYInt lastValidNum)
        {
            var y = 0;

            if (action.Map == null)
            {
                Debugger.Break();
                return;
            }

            var centre = GetPosNum(posNum);

            action.Effect = 1.0D;
            for (y = MathUtil.ClampInt(Tiles.YMin + centre.Y, 0, lastValidNum.Y) - centre.Y;
                 y <= MathUtil.ClampInt(Tiles.YMax + centre.Y, 0, lastValidNum.Y) - centre.Y;
                 y++)
            {
                action.PosNum.Y = centre.Y + y;
                var xNum = y - Tiles.YMin;
                var x    = 0;
                for (x = MathUtil.ClampInt(Tiles.XMin[xNum] + centre.X, 0, lastValidNum.X) - centre.X;
                     x <= MathUtil.ClampInt(Convert.ToInt32(Tiles.XMax[xNum] + centre.X), 0, lastValidNum.X) - centre.X;
                     x++)
                {
                    action.PosNum.X = centre.X + x;
                    if (action.UseEffect)
                    {
                        if (Tiles.ResultRadius > 0.0D)
                        {
                            switch (shape)
                            {
                            case ShapeType.Circle:
                                if (alignment)
                                {
                                    action.Effect =
                                        Convert.ToDouble(1.0D -
                                                         (new XYDouble(action.PosNum.X, action.PosNum.Y) -
                                                          new XYDouble(centre.X - 0.5D, centre.Y - 0.5D)).GetMagnitude() /
                                                         (Tiles.ResultRadius + 0.5D));
                                }
                                else
                                {
                                    action.Effect = Convert.ToDouble(1.0D - (centre - action.PosNum).ToDoubles().GetMagnitude() / (Tiles.ResultRadius + 0.5D));
                                }
                                break;

                            case ShapeType.Square:
                                if (alignment)
                                {
                                    action.Effect = 1.0D -
                                                    Math.Max(Math.Abs(action.PosNum.X - (centre.X - 0.5D)), Math.Abs(action.PosNum.Y - (centre.Y - 0.5D))) /
                                                    (Tiles.ResultRadius + 0.5D);
                                }
                                else
                                {
                                    action.Effect = 1.0D -
                                                    Math.Max(Math.Abs(action.PosNum.X - centre.X), Math.Abs(action.PosNum.Y - centre.Y)) /
                                                    (Tiles.ResultRadius + 0.5D);
                                }
                                break;
                            }
                        }
                    }
                    action.ActionPerform();
                }
            }
        }
Beispiel #3
0
            public void PerformTool(clsAction Tool)
            {
                clsXY_int Point = default(clsXY_int);

                foreach ( clsXY_int tempLoopVar_Point in ChangedPoints )
                {
                    Point = tempLoopVar_Point;
                    Tool.PosNum = Point.XY;
                    Tool.ActionPerform();
                }
            }
Beispiel #4
0
        private void PerformAction(clsAction Action, sPosNum PosNum, XYInt LastValidNum)
        {
            int   XNum   = 0;
            int   X      = 0;
            int   Y      = 0;
            XYInt Centre = new XYInt(0, 0);

            if (Action.Map == null)
            {
                Debugger.Break();
                return;
            }

            Centre = GetPosNum(PosNum);

            Action.Effect = 1.0D;
            for (Y = MathUtil.Clamp_int(Tiles.YMin + Centre.Y, 0, LastValidNum.Y) - Centre.Y;
                 Y <= MathUtil.Clamp_int(Tiles.YMax + Centre.Y, 0, LastValidNum.Y) - Centre.Y;
                 Y++)
            {
                Action.PosNum.Y = Centre.Y + Y;
                XNum            = Y - Tiles.YMin;
                for (X = MathUtil.Clamp_int(Tiles.XMin[XNum] + Centre.X, 0, LastValidNum.X) - Centre.X;
                     X <= MathUtil.Clamp_int(Convert.ToInt32(Tiles.XMax[XNum] + Centre.X), 0, LastValidNum.X) - Centre.X;
                     X++)
                {
                    Action.PosNum.X = Centre.X + X;
                    if (Action.UseEffect)
                    {
                        if (Tiles.ResultRadius > 0.0D)
                        {
                            switch (_Shape)
                            {
                            case enumShape.Circle:
                                if (_Alignment)
                                {
                                    Action.Effect =
                                        Convert.ToDouble(1.0D -
                                                         (new XYDouble(Action.PosNum.X, Action.PosNum.Y) -
                                                          new XYDouble(Centre.X - 0.5D, Centre.Y - 0.5D)).GetMagnitude() /
                                                         (Tiles.ResultRadius + 0.5D));
                                }
                                else
                                {
                                    Action.Effect = Convert.ToDouble(1.0D - (Centre - Action.PosNum).ToDoubles().GetMagnitude() / (Tiles.ResultRadius + 0.5D));
                                }
                                break;

                            case enumShape.Square:
                                if (_Alignment)
                                {
                                    Action.Effect = 1.0D -
                                                    Math.Max(Math.Abs(Action.PosNum.X - (Centre.X - 0.5D)), Math.Abs(Action.PosNum.Y - (Centre.Y - 0.5D))) /
                                                    (Tiles.ResultRadius + 0.5D);
                                }
                                else
                                {
                                    Action.Effect = 1.0D -
                                                    Math.Max(Math.Abs(Action.PosNum.X - Centre.X), Math.Abs(Action.PosNum.Y - Centre.Y)) /
                                                    (Tiles.ResultRadius + 0.5D);
                                }
                                break;
                            }
                        }
                    }
                    Action.ActionPerform();
                }
            }
        }