public static WorldAreaEnumerable <TForeground, TBackground> In <TForeground, TBackground>(
     this IWorldAreaEnumerable <TForeground, TBackground> blockArea, Point p1, Point p2)
     where TForeground : struct
     where TBackground : struct
 {
     return(blockArea.In(new Rectangle(p1, p2)));
 }
 public static WorldAreaEnumerable <TForeground, TBackground> In <TForeground, TBackground>(
     this IWorldAreaEnumerable <TForeground, TBackground> blockArea, int x, int y, int width, int height)
     where TForeground : struct
     where TBackground : struct
 {
     return(blockArea.In(new Rectangle(x, y, width, height)));
 }
 public static WorldItem <TForeground, TBackground> At <TForeground, TBackground>(
     this IWorldAreaEnumerable <TForeground, TBackground> blockArea, Point point)
     where TForeground : struct
     where TBackground : struct
 {
     return(blockArea.At(point.X, point.Y));
 }
 public static WorldItem <TForeground, TBackground> At <TForeground, TBackground>(
     this IWorldAreaEnumerable <TForeground, TBackground> blockArea, int x, int y)
     where TForeground : struct
     where TBackground : struct
 {
     return(new WorldItem <TForeground, TBackground>(blockArea.World, blockArea.Area.X + x, blockArea.Area.Y + y));
 }
Example #5
0
 public static ReadOnlyWorldAreaEnumerable <TForeground, TBackground> ToReadOnlyWorldAreaEnumerable <TForeground, TBackground>(
     this IWorldAreaEnumerable <TForeground, TBackground> worldArea)
     where TForeground : struct
     where TBackground : struct
 {
     return(new ReadOnlyWorldAreaEnumerable <TForeground, TBackground>(worldArea.World, worldArea.Area));
 }
 public static WorldAreaEnumerable <TForeground, TBackground> In <TForeground, TBackground>(
     this IWorldAreaEnumerable <TForeground, TBackground> blockArea, Rectangle area)
     where TForeground : struct
     where TBackground : struct
 {
     return(new WorldAreaEnumerable <TForeground, TBackground>(blockArea.World,
                                                               Rectangle.Intersect(area, blockArea.Area)));
 }
        /// <summary>
        ///     Creates a copy of the given world.
        /// </summary>
        /// <param name="worldArea">The block area.</param>
        /// <returns></returns>
        public static World CreateCopy(this IWorldAreaEnumerable <ForegroundBlock, BackgroundBlock> worldArea)
        {
            var area  = worldArea.Area;
            var world = new World(area.Width, area.Height);

            for (var x = area.Left; x <= area.Right; x++)
            {
                for (var y = area.Top; y <= area.Bottom; y++)
                {
                    world.Foreground[x - area.Left, y - area.Top] = worldArea.World.Foreground[x, y];
                    world.Background[x - area.Left, y - area.Top] = worldArea.World.Background[x, y];
                }
            }
            return(world);
        }
        public static void SetWorld <TForeground, TBackground>(
            this IWorldAreaEnumerable <TForeground, TBackground> worldArea,
            IWorldAreaEnumerable <TForeground, TBackground> worldArea2)
            where TForeground : struct
            where TBackground : struct
        {
            var area = worldArea.Area;

            if (worldArea2.Area.Width > area.Width || worldArea2.Area.Height > area.Height)
            {
                throw new ArgumentException("The world is too big for this area.", nameof(worldArea2));
            }

            for (var y = area.Top; y < area.Top + worldArea2.Area.Height; y++)
            {
                for (var x = area.Left; x < area.Left + worldArea2.Area.Width; x++)
                {
                    worldArea.World.Foreground[x, y] = worldArea2.World.Foreground[x - area.Left, y - area.Top];
                    worldArea.World.Background[x, y] = worldArea2.World.Background[x - area.Left, y - area.Top];
                }
            }
        }
 public static WorldDictionary ToWorldDictionary(this IWorldAreaEnumerable <ForegroundBlock, BackgroundBlock> worldArea)
 {
     return(new WorldDictionary(worldArea));
 }
Example #10
0
 public static ReadOnlyWorldDictionary ToReadOnlyWorldDictionary(this IWorldAreaEnumerable <ForegroundBlock, BackgroundBlock> worldArea, IBlockFilter filter)
 {
     return(new ReadOnlyWorldDictionary(worldArea, filter));
 }
Example #11
0
 public ReadOnlyWorldDictionary(IWorldAreaEnumerable <ForegroundBlock, BackgroundBlock> worldArea)
     : this(worldArea, null)
 {
 }
Example #12
0
 public ReadOnlyWorldDictionary(IWorldAreaEnumerable <ForegroundBlock, BackgroundBlock> worldArea, IBlockFilter filter)
     : this(worldArea.ToReadOnlyWorldAreaEnumerable(), filter)
 {
 }