コード例 #1
0
 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)));
 }
コード例 #2
0
 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)));
 }
コード例 #3
0
 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));
 }
コード例 #4
0
 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));
 }
コード例 #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));
 }
コード例 #6
0
 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)));
 }
コード例 #7
0
        /// <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);
        }
コード例 #8
0
        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];
                }
            }
        }
コード例 #9
0
 public static WorldDictionary ToWorldDictionary(this IWorldAreaEnumerable <ForegroundBlock, BackgroundBlock> worldArea)
 {
     return(new WorldDictionary(worldArea));
 }
コード例 #10
0
 public static ReadOnlyWorldDictionary ToReadOnlyWorldDictionary(this IWorldAreaEnumerable <ForegroundBlock, BackgroundBlock> worldArea, IBlockFilter filter)
 {
     return(new ReadOnlyWorldDictionary(worldArea, filter));
 }
コード例 #11
0
 public ReadOnlyWorldDictionary(IWorldAreaEnumerable <ForegroundBlock, BackgroundBlock> worldArea)
     : this(worldArea, null)
 {
 }
コード例 #12
0
 public ReadOnlyWorldDictionary(IWorldAreaEnumerable <ForegroundBlock, BackgroundBlock> worldArea, IBlockFilter filter)
     : this(worldArea.ToReadOnlyWorldAreaEnumerable(), filter)
 {
 }